user127517
user127517

Reputation: 51

How to distinguish Xsun from Xorg, programmatically?

VendorString() doesn't work, it's always Sun Microsystems, even if it is Xorg built for Solaris.

Upvotes: 5

Views: 469

Answers (3)

user127517
user127517

Reputation: 51

Thank you! Oops, VendorRelease() string it is. Anyway, unfortunately we cannot bet on this string. It changes often enough to have a trouble, for Xsun as well as for Xorg. I have found a solution working (hopefully) for them and for various other (derived) servers like Xvfb, Xnest etc.

Xsun does use a third value in an array of the keysyms for KP_ (numpad) keycodes. Xorg uses 1-st or 2-nd. A sniffer should first, obtain a keycode for a KP_ keysym, for instance XK_KP_7, second, sniff what is in the XKeycodeToKeysym(d,keycode, [0-3]). Our XK_KP_7 will be on the index 2 for Xsun.

Upvotes: 0

DaveR
DaveR

Reputation: 9640

It's possibly a little hacky, but if you look at the list of extensions returned from Xsun and Xorg you should see that Xorg has a few extra XFree86-derived extensions.

xdpyinfo can be used to list the extensions via the command-line to check for differences; programmatically you can use XListExtensions() or XQueryExtension().

(I haven't got a Xsun X Server to hand but I'm pretty sure when I've looked in the past they have differed quite abit).

Upvotes: 1

ephemient
ephemient

Reputation: 204698

$ xdpyinfo | grep vendor
vendor string:    The X.Org Foundation
vendor release number:    10601901

This is xorg-server 1.6.1 on Linux. Hopefully XOrg and XSun on Solaris will differ here.

To output these two fields, xdpyinfo calls the ServerVendor macro to determine the vendor, then parses the return of the VendorRelease macro differently depending on what ServerVendor was.

By the way, what's VendorString()? I don't have a function or macro by that name...

Upvotes: 2

Related Questions