27 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
29 #include <X11/cursorfont.h>
30 #include <X11/keysym.h>
46 struct MWMHintsProperty_t {
65 struct KeySymbolMap_t {
73 static KeySymbolMap_t gKeyMap[] = {
76 #ifndef XK_ISO_Left_Tab
140 struct RXGCValues:XGCValues{};
141 struct RXColor:XColor{};
142 struct RXpmAttributes:XpmAttributes{};
143 struct RXSetWindowAttributes:XSetWindowAttributes{};
144 struct RVisual:Visual{};
163 conv.i[0] = (
Int_t) i1;
164 conv.i[1] = (
Int_t) i2;
174 XGetErrorText(disp, err->error_code, msg, 80);
179 ::Error(
"RootX11ErrorHandler",
"%s (XID: %u, XREQ: %u)", msg,
180 (
UInt_t)err->resourceid, err->request_code);
186 if (!err->resourceid)
return 0;
191 ::Error(
"RootX11ErrorHandler",
"%s (XID: %u, XREQ: %u)", msg,
192 (
UInt_t)err->resourceid, err->request_code);
194 ::Error(
"RootX11ErrorHandler",
"%s (%s XID: %u, XREQ: %u)", msg, w->
ClassName(),
195 (
UInt_t)err->resourceid, err->request_code);
211 ::Error(
"RootX11IOErrorHandler",
"fatal X11 error (connection to server lost?!)");
212 fprintf(stderr,
"\n**** Save data and exit application ****\n\n");
376 XSetWindowBackgroundPixmap((Display*)
fDisplay, (
Window)
id, (Pixmap) pxm);
387 RXSetWindowAttributes xattr;
397 if (
fColormap && !(xmask & CWColormap)) {
402 xmask |= CWBorderPixel;
407 w, h, border, depth, clss, (Visual*)visual,
417 Long_t lxemask = NoEventMask;
419 lxemask |= KeyPressMask;
421 lxemask |= KeyReleaseMask;
423 lxemask |= ButtonPressMask;
425 lxemask |= ButtonReleaseMask;
427 lxemask |= PointerMotionMask;
429 lxemask |= ButtonMotionMask;
431 lxemask |= ExposureMask;
433 lxemask |= StructureNotifyMask;
435 lxemask |= EnterWindowMask;
437 lxemask |= LeaveWindowMask;
439 lxemask |= FocusChangeMask;
441 lxemask |= OwnerGrabButtonMask;
443 lxemask |= ColormapChangeMask;
447 if ((xemask & KeyPressMask))
449 if ((xemask & KeyReleaseMask))
451 if ((xemask & ButtonPressMask))
453 if ((xemask & ButtonReleaseMask))
455 if ((xemask & PointerMotionMask))
457 if ((xemask & ButtonMotionMask))
459 if ((xemask & ExposureMask))
461 if ((xemask & StructureNotifyMask))
463 if ((xemask & EnterWindowMask))
465 if ((xemask & LeaveWindowMask))
467 if ((xemask & FocusChangeMask))
469 if ((xemask & OwnerGrabButtonMask))
471 if ((xemask & ColormapChangeMask))
480 ULong_t &xmask, RXSetWindowAttributes &xattr)
486 xmask |= CWBackPixmap;
488 xattr.background_pixmap =
None;
490 xattr.background_pixmap = ParentRelative;
495 xmask |= CWBackPixel;
499 xmask |= CWBorderPixmap;
503 xmask |= CWBorderPixel;
507 xmask |= CWBitGravity;
511 xmask |= CWWinGravity;
515 xmask |= CWBackingStore;
517 xattr.backing_store = NotUseful;
519 xattr.backing_store = WhenMapped;
521 xattr.backing_store = Always;
526 xmask |= CWBackingPlanes;
530 xmask |= CWBackingPixel;
534 xmask |= CWOverrideRedirect;
538 xmask |= CWSaveUnder;
542 xmask |= CWEventMask;
545 xattr.event_mask = xmsk;
548 xmask |= CWDontPropagate;
581 xmask |= GCPlaneMask;
585 xmask |= GCForeground;
589 xmask |= GCBackground;
593 xmask |= GCLineWidth;
597 xmask |= GCLineStyle;
605 xmask |= GCJoinStyle;
609 xmask |= GCFillStyle;
618 xgval.tile = (Pixmap) gval.
fTile;
622 xgval.stipple = (Pixmap) gval.
fStipple;
625 xmask |= GCTileStipXOrigin;
629 xmask |= GCTileStipYOrigin;
635 xgval.font = (Font) gval.
fFont;
639 xmask |= GCSubwindowMode;
643 xmask |= GCGraphicsExposures;
647 xmask |= GCClipXOrigin;
651 xmask |= GCClipYOrigin;
656 xgval.clip_mask = (Pixmap) gval.
fClipMask;
659 xmask |= GCDashOffset;
664 xgval.dashes = gval.
fDashes[0];
675 if ((xmask & GCFunction)) {
679 if ((xmask & GCPlaneMask)) {
683 if ((xmask & GCForeground)) {
687 if ((xmask & GCBackground)) {
691 if ((xmask & GCLineWidth)) {
695 if ((xmask & GCLineStyle)) {
699 if ((xmask & GCCapStyle)) {
703 if ((xmask & GCJoinStyle)) {
707 if ((xmask & GCFillStyle)) {
711 if ((xmask & GCFillRule)) {
715 if ((xmask & GCTile)) {
719 if ((xmask & GCStipple)) {
723 if ((xmask & GCTileStipXOrigin)) {
727 if ((xmask & GCTileStipYOrigin)) {
731 if ((xmask & GCFont)) {
735 if ((xmask & GCSubwindowMode)) {
739 if ((xmask & GCGraphicsExposures)) {
743 if ((xmask & GCClipXOrigin)) {
747 if ((xmask & GCClipYOrigin)) {
751 if ((xmask & GCClipMask)) {
755 if ((xmask & GCDashOffset)) {
759 if ((xmask & GCDashList)) {
761 gval.
fDashes[0] = xgval.dashes;
764 if ((xmask & GCArcMode)) {
779 XWindowAttributes xattr;
781 XGetWindowAttributes((Display*)
fDisplay,
id, &xattr);
785 attr.
fWidth = xattr.width;
788 attr.
fDepth = xattr.depth;
829 Warning(
"OpenDisplay",
"system has no X11 thread support");
834 if (!(dpy = XOpenDisplay(dpyName)))
842 XSynchronize(dpy, 1);
848 return ConnectionNumber(dpy);
916 Atom a = XInternAtom((Display*)
fDisplay, (
char *)atom_name, (
Bool)only_if_exist);
942 XQueryTree((Display*)
fDisplay, (
Window)
id, &root, &parent, &children, &nchildren);
944 if (children) XFree(children);
957 XFontStruct *fs = XLoadQueryFont((Display*)
fDisplay, (
char *)font_name);
967 XFontStruct *fss = (XFontStruct *)fs;
1015 XChangeGC((Display*)
fDisplay, (GC) gc, xmask, &xgval);
1040 XCopyGC((Display*)
fDisplay, (GC) org, xmask, (GC) dest);
1051 XFreeGC((Display*)
fDisplay, (GC) gc);
1090 width, height, forecolor, backcolor, depth);
1124 xmask |= XpmColormap;
1129 xpmattr.depth = attr.
fDepth;
1133 xpmattr.width = attr.
fWidth;
1134 xpmattr.height = attr.
fHeight;
1137 xmask |= XpmHotspot;
1142 xmask |= XpmReturnPixels;
1144 xpmattr.npixels = 0;
1147 xmask |= XpmCloseness;
1150 xpmattr.valuemask = xmask;
1152 ULong_t xmask = xpmattr.valuemask;
1158 if ((xmask & XpmColormap)) {
1162 attr.
fDepth = xpmattr.depth;
1164 if ((xmask & XpmSize)) {
1166 attr.
fWidth = xpmattr.width;
1167 attr.
fHeight = xpmattr.height;
1169 if ((xmask & XpmHotspot)) {
1174 if ((xmask & XpmReturnPixels)) {
1176 if (xpmattr.npixels) {
1178 for (
UInt_t i = 0; i < xpmattr.npixels; i++)
1179 attr.
fPixels[i] = xpmattr.pixels[i];
1183 if ((xmask & XpmCloseness)) {
1201 if (strstr(filename,
".gif") || strstr(filename,
".GIF")) {
1202 pict =
ReadGIF(0, 0, filename,
id);
1211 RXpmAttributes xpmattr;
1217 xpmattr.valuemask |= XpmDepth;
1222 (Pixmap*)&pict, (Pixmap*)&pict_mask, &xpmattr);
1225 XpmFreeAttributes(&xpmattr);
1227 if (res == XpmSuccess || res == XpmColorError)
1231 XFreePixmap((Display*)
fDisplay, (Pixmap)pict);
1235 XFreePixmap((Display*)
fDisplay, (Pixmap)pict_mask);
1239 Error(
"CreatePictureFromFile",
"cannot get picture, not compiled with Xpm");
1254 RXpmAttributes xpmattr;
1260 xpmattr.valuemask |= XpmDepth;
1265 (Pixmap*)&pict_mask, &xpmattr);
1268 XpmFreeAttributes(&xpmattr);
1270 if (res == XpmSuccess || res == XpmColorError)
1274 XFreePixmap((Display*)
fDisplay, (Pixmap)pict);
1278 XFreePixmap((Display*)
fDisplay, (Pixmap)pict_mask);
1282 Error(
"CreatePictureFromData",
"cannot get picture, not compiled with Xpm");
1295 if (XpmReadFileToData((
char*)filename, ret_data) == XpmSuccess)
1298 Error(
"ReadPictureFromDataFile",
"cannot get picture, not compiled with Xpm");
1323 XSetDashes((Display*)
fDisplay, (GC) gc, offset, (
char *)dash_list, n);
1331 xcolor.pixel = color->
fPixel;
1332 xcolor.red = color->
fRed;
1333 xcolor.green = color->
fGreen;
1334 xcolor.blue = color->
fBlue;
1335 xcolor.flags = color->
fMask;
1351 color.
fRed = xc.red;
1353 color.
fBlue = xc.blue;
1397 color.
fRed = xc.red;
1399 color.
fBlue = xc.blue;
1417 return XPending((Display*)
fDisplay);
1441 xstate |= ShiftMask;
1445 xstate |= ControlMask;
1457 xstate |= Button1Mask;
1459 xstate |= Button2Mask;
1461 xstate |= Button3Mask;
1463 xstate |= AnyModifier;
1466 if ((xstate & ShiftMask))
1468 if ((xstate & LockMask))
1470 if ((xstate & ControlMask))
1472 if ((xstate & Mod1Mask))
1474 if ((xstate & Mod2Mask))
1476 if ((xstate & Mod3Mask))
1478 if ((xstate & Mod4Mask))
1480 if ((xstate & Mod5Mask))
1482 if ((xstate & Button1Mask))
1484 if ((xstate & Button2Mask))
1486 if ((xstate & Button3Mask))
1488 if ((xstate & AnyModifier))
1499 XEvent &xev = *(XEvent *)xevi;
1526 xev.xany.display = (Display*)
fDisplay;
1532 xev.xkey.x_root = ev.
fXRoot;
1533 xev.xkey.y_root = ev.
fYRoot;
1535 xev.xkey.keycode = ev.
fCode;
1540 xev.xselection.selection = (
Atom) ev.
fUser[1];
1541 xev.xselection.target = (
Atom) ev.
fUser[2];
1542 xev.xselection.property = (
Atom) ev.
fUser[3];
1545 xev.xclient.message_type = ev.
fHandle;
1546 xev.xclient.format = ev.
fFormat;
1547 xev.xclient.data.l[0] = ev.
fUser[0];
1548 if (
sizeof(ev.
fUser[0]) > 4) {
1549 SplitLong(ev.
fUser[1], xev.xclient.data.l[1], xev.xclient.data.l[3]);
1550 SplitLong(ev.
fUser[2], xev.xclient.data.l[2], xev.xclient.data.l[4]);
1552 xev.xclient.data.l[1] = ev.
fUser[1];
1553 xev.xclient.data.l[2] = ev.
fUser[2];
1554 xev.xclient.data.l[3] = ev.
fUser[3];
1555 xev.xclient.data.l[4] = ev.
fUser[4];
1589 ev.
fXRoot = xev.xkey.x_root;
1590 ev.
fYRoot = xev.xkey.y_root;
1592 ev.
fCode = xev.xkey.keycode;
1593 ev.
fUser[0] = xev.xkey.subwindow;
1597 ev.
fX = xev.xbutton.x;
1598 ev.
fY = xev.xbutton.y;
1599 ev.
fXRoot = xev.xbutton.x_root;
1600 ev.
fYRoot = xev.xbutton.y_root;
1602 ev.
fCode = xev.xbutton.button;
1603 ev.
fUser[0] = xev.xbutton.subwindow;
1607 ev.
fX = xev.xmotion.x;
1608 ev.
fY = xev.xmotion.y;
1609 ev.
fXRoot = xev.xmotion.x_root;
1610 ev.
fYRoot = xev.xmotion.y_root;
1612 ev.
fUser[0] = xev.xmotion.subwindow;
1616 ev.
fX = xev.xcrossing.x;
1617 ev.
fY = xev.xcrossing.y;
1618 ev.
fXRoot = xev.xcrossing.x_root;
1619 ev.
fYRoot = xev.xcrossing.y_root;
1620 ev.
fCode = xev.xcrossing.mode;
1625 ev.
fCode = xev.xfocus.mode;
1626 ev.
fState = xev.xfocus.detail;
1629 ev.
fX = xev.xexpose.x;
1630 ev.
fY = xev.xexpose.y;
1631 ev.
fWidth = xev.xexpose.width;
1632 ev.
fHeight = xev.xexpose.height;
1633 ev.
fCount = xev.xexpose.count;
1636 ev.
fX = xev.xconfigure.x;
1637 ev.
fY = xev.xconfigure.y;
1638 ev.
fWidth = xev.xconfigure.width;
1639 ev.
fHeight = xev.xconfigure.height;
1645 ev.
fHandle = xev.xdestroywindow.window;
1648 ev.
fHandle = xev.xclient.message_type;
1649 ev.
fFormat = xev.xclient.format;
1650 ev.
fUser[0] = xev.xclient.data.l[0];
1651 if (
sizeof(ev.
fUser[0]) > 4) {
1652 AsmLong(xev.xclient.data.l[1], xev.xclient.data.l[3], ev.
fUser[1]);
1653 AsmLong(xev.xclient.data.l[2], xev.xclient.data.l[4], ev.
fUser[2]);
1655 ev.
fUser[1] = xev.xclient.data.l[1];
1656 ev.
fUser[2] = xev.xclient.data.l[2];
1657 ev.
fUser[3] = xev.xclient.data.l[3];
1658 ev.
fUser[4] = xev.xclient.data.l[4];
1662 ev.
fUser[0] = xev.xselectionclear.selection;
1666 ev.
fUser[0] = xev.xselectionrequest.requestor;
1667 ev.
fUser[1] = xev.xselectionrequest.selection;
1668 ev.
fUser[2] = xev.xselectionrequest.target;
1669 ev.
fUser[3] = xev.xselectionrequest.property;
1673 ev.
fUser[0] = xev.xselection.requestor;
1674 ev.
fUser[1] = xev.xselection.selection;
1675 ev.
fUser[2] = xev.xselection.target;
1676 ev.
fUser[3] = xev.xselection.property;
1679 ev.
fHandle = xev.xcolormap.colormap;
1680 ev.
fCode = xev.xcolormap.state;
1681 ev.
fState = xev.xcolormap.c_new;
1691 XBell((Display*)
fDisplay, percent);
1703 if (!src || !dest)
return;
1705 XCopyArea((Display*)
fDisplay, src, dest, (GC) gc, src_x, src_y, width, height,
1716 RXSetWindowAttributes xattr;
1722 XChangeWindowAttributes((Display*)
fDisplay, (
Window)
id, xmask, &xattr);
1739 8, PropModeReplace, data, len);
1783 tev.
fX = tev.
fY = 0;
1800 if (!ev || !
id)
return;
1827 XAutoRepeatOff((Display*)
fDisplay);
1846 GrabModeAsync, GrabModeAsync);
1872 GrabModeAsync, GrabModeAsync, (
Window) confine,
1893 xevmask, GrabModeAsync, GrabModeAsync, (
Window) confine,
1894 (
Cursor) cursor, CurrentTime);
1896 XUngrabPointer((Display*)
fDisplay, CurrentTime);
1906 XTextProperty wname;
1908 if (XStringListToTextProperty(&name, 1, &wname) == 0) {
1909 Error(
"SetWindowName",
"cannot allocate window name \"%s\"", name);
1923 XTextProperty wname;
1925 if (XStringListToTextProperty(&name, 1, &wname) == 0) {
1926 Error(
"SetIconName",
"cannot allocate icon name \"%s\"", name);
1942 hints.flags = IconPixmapHint;
1943 hints.icon_pixmap = (Pixmap) pic;
1955 XClassHint class_hints;
1957 class_hints.res_class = className;
1958 class_hints.res_name = resourceName;
1969 MWMHintsProperty_t
prop;
1971 prop.fDecorations =
value;
1972 prop.fFunctions = funcs;
1973 prop.fInputMode = input;
1977 PropModeReplace, (
UChar_t *)&prop, kPropMWMHintElements);
1989 hints.flags = USPosition | PPosition;
2005 hints.flags = USSize | PSize | PBaseSize;
2006 hints.width = hints.base_width = w;
2007 hints.height = hints.base_height =
h;
2024 hints.flags = PMinSize | PMaxSize | PResizeInc;
2025 hints.min_width = (
Int_t)wmin;
2026 hints.max_width = (
Int_t)wmax;
2027 hints.min_height = (
Int_t)hmin;
2028 hints.max_height = (
Int_t)hmax;
2029 hints.width_inc = (
Int_t)winc;
2030 hints.height_inc = (
Int_t)hinc;
2043 Int_t xstate = NormalState;
2046 xstate = NormalState;
2048 xstate = IconicState;
2050 hints.flags = StateHint;
2051 hints.initial_state = xstate;
2070 const char *s,
Int_t len)
2074 XDrawString((Display*)
fDisplay, (
Drawable)
id, (GC) gc, x, y, (
char *) s, len);
2082 return XTextWidth((XFontStruct*) font, (
char*) s, len);
2090 XFontStruct *
f = (XFontStruct *) font;
2092 max_ascent = f->max_bounds.ascent;
2093 max_descent = f->max_bounds.descent;
2113 XGetGCValues((Display*)
fDisplay, (GC) gc, xmask, &xgval);
2126 fs = XQueryFont((Display*)
fDisplay, (Font) fh);
2137 static int xfree86_400 = -1;
2138 if (xfree86_400 == -1) {
2139 if (strstr(XServerVendor((Display*)
fDisplay),
"XFree86") &&
2140 XVendorRelease((Display*)
fDisplay) == 4000)
2146 if (xfree86_400 == 0)
2147 XFreeFontInfo(0, (XFontStruct *) fs, 1);
2170 return XKeysymToKeycode((Display*)
fDisplay, xkeysym);
2200 XDrawSegments((Display*)
fDisplay, (
Drawable)
id, (GC) gc, (XSegment *) seg, nseg);
2228 XGetInputFocus((Display*)
fDisplay, &focus, &return_to);
2239 XWindowAttributes xattr;
2243 if (xattr.map_state == IsViewable)
2244 XSetInputFocus((Display*)
fDisplay, (
Window)
id, RevertToParent, CurrentTime);
2299 int n = XLookupString(&xev.xkey, buf, buflen-1, &xkeysym, 0);
2301 Error(
"LookupString",
"buf too small, must be at least %d", n+1);
2307 keysym = (
Int_t) ks;
2317 xkeysym = XK_VoidSymbol;
2323 for (
int i = 0; gKeyMap[i].fKeySym; i++) {
2324 if (keysym == (
UInt_t) gKeyMap[i].fKeySym) {
2325 xkeysym = (
UInt_t) gKeyMap[i].fXKeySym;
2333 if (xkeysym < 127) {
2335 }
else if (xkeysym >= XK_F1 && xkeysym <= XK_F35) {
2336 keysym =
kKey_F1 + (xkeysym - XK_F1);
2337 }
else if (xkeysym >= XK_KP_0 && xkeysym <= XK_KP_9) {
2338 keysym =
kKey_0 + (xkeysym - XK_KP_0);
2340 for (
int i = 0; gKeyMap[i].fXKeySym; i++) {
2341 if (xkeysym == gKeyMap[i].fXKeySym) {
2342 keysym = (
UInt_t) gKeyMap[i].fKeySym;
2359 Atom actual_type,
property = (
Atom) atom;
2361 ULong_t nitems, bytes_after, nread;
2362 unsigned char *data;
2367 if (property ==
None)
return;
2372 if (XGetWindowProperty((Display*)
fDisplay, (
Window)
id, property,
2373 nread/4, 1024, (
Bool)del,
2375 &actual_type, &actual_format,
2376 &nitems, &bytes_after,
2377 (
unsigned char **) &data)
2387 }
while (bytes_after > 0);
2389 nchar = (
Int_t) nread;
2401 if (!src || !dest)
return;
2406 src_y, &dest_x, &dest_y, &xchild);
2421 XGetGeometry((Display*)
fDisplay, (
Drawable)
id, &wdummy, &x, &y, &w, &h, &bdum, &ddum);
2436 XFillPolygon((Display*)
fDisplay, (
Window)
id, (GC) gc, (XPoint *) points, npnt,
2437 Convex, CoordModeOrigin);
2458 XQueryPointer((Display*)
fDisplay, (
Window)
id, &xrootw, &xchildw,
2459 &root_x, &root_y, &win_x, &win_y, &xmask);
2473 XSetForeground((Display*)
fDisplay, (GC) gc, foreground);
2483 XSetClipRectangles((Display*)
fDisplay, (GC) gc, x, y, (XRectangle *) recs, n, Unsorted);
2512 XDestroyRegion((Region)reg);
2520 XRectangle *
r = (XRectangle *) rect;
2521 XUnionRectWithRegion(r, (Region) src, (Region) dest);
2530 XPoint *p = (XPoint *) points;
2531 return (
Region_t) XPolygonRegion(p, np, winding ? WindingRule : EvenOddRule);
2540 XUnionRegion((Region) rega, (Region) regb, (Region) result);
2549 XIntersectRegion((Region) rega, (Region) regb, (Region) result);
2557 XSubtractRegion((Region) rega, (Region) regb, (Region) result);
2566 XXorRegion((Region) rega, (Region) regb, (Region) result);
2574 return (
Bool_t) XEmptyRegion((Region) reg);
2582 return (
Bool_t) XPointInRegion((Region) reg, x, y);
2590 return (
Bool_t) XEqualRegion((Region) rega, (Region) regb);
2598 XClipBox((Region) reg, (XRectangle*) rect);
2607 Int_t fontcount = 0;
2608 fontlist = XListFonts((Display*)
fDisplay, (
char *)fontname, max, &fontcount);
2618 XFreeFontNames(fontlist);
2636 0, 0, width, height, bitmap_pad, 0);
2639 if (xim) xim->data = (
char *) calloc(xim->bytes_per_line * xim->height, 1);
2649 width = ((XImage*)img)->width;
2650 height = ((XImage*)img)->height;
2658 XPutPixel((XImage*) img, x, y, pixel);
2670 x, y, dx, dy, w, h);
2678 XDestroyImage((XImage*) img);
2697 return (
UInt_t)WidthMMOfScreen(DefaultScreenOfDisplay((Display*)
fDisplay));
2707 XDeleteProperty((Display*)
fDisplay, win, prop);
2719 unsigned char **prop_list)
2721 return XGetWindowProperty((Display*)
fDisplay, win, prop, offset, length, del, req_type,
2722 act_type, act_format, nitems, bytes, prop_list);
2736 XChangeActivePointerGrab((Display*)
fDisplay, xevmask, cur, CurrentTime);
2746 XConvertSelection((Display*)
fDisplay, sel, target, prop, win, stamp);
2754 return XSetSelectionOwner((Display*)
fDisplay, sel, owner, CurrentTime);
2768 format, PropModeReplace, data, len);
2777 unsigned char version = 4;
2780 32, PropModeReplace, (
unsigned char *) &version, 1);
2785 for (n = 0; typelist[
n]; n++) { }
2787 XChangeProperty((Display*)
fDisplay, win, dndaware, XA_ATOM, 32, PropModeAppend,
2788 (
unsigned char *) typelist, n);
2800 for (n = 0; typelist[
n]; n++) { }
2802 XChangeProperty((Display*)
fDisplay, win, prop,
XA_ATOM, 32, PropModeAppend,
2803 (
unsigned char *) typelist, n);
2814 int x,
int y,
int maxd)
2817 static Atom_t *dndTypeList = 0;
2819 if (dndTypeList == 0) {
2820 dndTypeList =
new Atom_t[3];
2826 if (maxd <= 0)
return kNone;
2828 if (win == dragwin || win == input)
return kNone;
2832 x >= wattr.
fX && x < wattr.
fX + wattr.
fWidth &&
2835 if (
IsDNDAware(win, dndTypeList))
return win;
2841 if (XQueryTree((Display*)
fDisplay, win, &r, &p, &children, &numch)) {
2842 if (children && numch > 0) {
2846 for (i = numch-1; i >= 0; --i) {
2848 x - wattr.
fX, y - wattr.
fY, maxd-1);
2849 if (r !=
kNone)
break;
2852 if (r !=
kNone)
return r;
2869 unsigned char *data = 0;
2876 if (dndaware ==
kNone)
2879 XGetWindowProperty((Display*)
fDisplay, win, dndaware, 0, 0x8000000L,
kFALSE,
2880 XA_ATOM, &actual, &format, &count, &remaining, &data);
2882 if ((actual !=
XA_ATOM) || (format != 32) || (count == 0) || !data) {
2883 if (data) XFree(data);
2889 if ((count > 1) && typelist) {
2891 for (t = typelist; *t; t++) {
2892 for (
ULong_t j = 1; j < count; j++) {
2893 if (types[j] == *t) {
void GetPasteBuffer(Window_t id, Atom_t atom, TString &text, Int_t &nchar, Bool_t del)
Get contents of paste buffer atom into string.
void GetGCValues(GContext_t gc, GCValues_t &gval)
Get current values from graphics context gc.
const Mask_t kKeyReleaseMask
void * fDisplay
Pointer to display.
void MapRaised(Window_t id)
Map window on screen and put on top of all windows.
void MapEvent(Event_t &ev, void *xev, Bool_t tox=kTRUE)
Map Event_t structure to XEvent structure.
void SetWMPosition(Window_t id, Int_t x, Int_t y)
Tell the window manager the desired window position.
void SendEvent(Window_t id, Event_t *ev)
Send event ev to window id.
Int_t GetScreen() const
Returns screen number (might be useful in some cases where direct X11 manipulation outside of TVirtua...
Int_t GetDepth() const
Returns depth of screen (number of bit planes).
void SetDashes(GContext_t gc, Int_t offset, const char *dash_list, Int_t n)
Specify a dash pattern.
Window_t CreateWindow(Window_t parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype)
Return handle to newly created X window.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
const Mask_t kColormapChangeMask
void ChangeProperty(Window_t id, Atom_t property, Atom_t type, UChar_t *data, Int_t len)
This function alters the property for the specified window and causes the X server to generate a Prop...
void DeleteFont(FontStruct_t fs)
Explicitly delete font structure obtained with LoadQueryFont().
void GrabKey(Window_t id, Int_t keycode, UInt_t modifier, Bool_t grab=kTRUE)
Establish passive grab on a certain key.
static Int_t RootX11IOErrorHandler(Display *)
Handle X11 I/O error (happens when connection to display server is broken).
void MapColorStruct(ColorStruct_t *color, RXColor &xcolor)
Map a ColorStruct_t to a XColor structure.
void DeletePictureData(void *data)
Delete picture data created by the function ReadPictureDataFromFile.
const Mask_t kButton2Mask
Bool_t ReadPictureDataFromFile(const char *filename, char ***ret_data)
Read picture data from file and store in ret_data.
void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx, Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax, UChar_t *image, Drawable_t id)
Draw image.
Colormap_t GetColormap() const
Returns handle to colormap (might be useful in some cases where direct X11 manipulation outside of TV...
FontStruct_t GetFontStruct(FontH_t fh)
Retrieve associated font structure once we have the font handle.
const Mask_t kKeyMod2Mask
void SetDNDAware(Window_t, Atom_t *)
Add XdndAware property and the list of drag and drop types to the Window win.
char ** ListFonts(const char *fontname, Int_t max, Int_t &count)
Return list of font names matching fontname regexp, like "-*-times-*".
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Draw a line.
Pixmap_t fBackgroundPixmap
void SetWindowBackground(Window_t id, ULong_t color)
Set the window background color.
const Mask_t kKeyShiftMask
const Mask_t kKeyMod1Mask
Bool_t Init(void *display)
Initialize X11 system. Returns kFALSE in case of failure.
Bool_t fHasXft
True when XftFonts are used.
const Mask_t kButtonMotionMask
void Update(Int_t mode=0)
Flush (mode = 0, default) or synchronize (mode = 1) X output buffer.
Int_t fScreenNumber
Screen number.
void GetWindowSize(Drawable_t id, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Return geometry of window (should be called GetGeometry but signature already used).
const Mask_t kGCDashOffset
static Int_t RootX11ErrorHandler(Display *disp, XErrorEvent *err)
Handle X11 error.
const Mask_t kLeaveWindowMask
void GrabPointer(Window_t id, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE, Bool_t owner_events=kTRUE)
Establish an active pointer grab.
const Mask_t kWABackPixmap
const Mask_t kWABorderPixel
void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest)
Union of rectangle with a region.
const Mask_t kWABitGravity
static const char * filename()
Window_t GetPrimarySelectionOwner()
Returns the window id of the current owner of the primary selection.
void SetClassHints(Window_t id, char *className, char *resourceName)
Set the windows class and resource name.
R__EXTERN Atom_t gWM_DELETE_WINDOW
void ChangeGC(GContext_t gc, GCValues_t *gval)
Change entries in an existing graphics context, gc, by values from gval.
Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg)
Returns true if the point x,y is in the region.
const Mask_t kGCLineStyle
Int_t EventsPending()
Returns number of pending events.
Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding)
Create region for the polygon defined by the points array.
void RaiseWindow(Window_t id)
Put window on top of window stack.
const Mask_t kWABackingStore
Window_t GetDefaultRootWindow() const
Return handle to the default root window created when calling XOpenDisplay().
Cursor fCursors[kNumCursors]
List of cursors.
void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n)
Set clipping rectangles in graphics context.
void QueryColor(Colormap_t cmap, ColorStruct_t &color)
Fill in the primary color components for a specific pixel value.
static std::string format(double x, double y, int digits, int width)
void MapSubwindows(Window_t id)
Map sub windows.
TString & Insert(Ssiz_t pos, const char *s)
void ReparentWindow(Window_t id, Window_t pid, Int_t x, Int_t y)
Reparent window to new parent window at position (x,y).
void SetCursor(Int_t win, ECursor cursor)
Set the cursor.
EGraphicsFunction fFunction
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
const ULong_t kMWMHintsFunctions
Bool_t EqualRegion(Region_t rega, Region_t regb)
Returns true if two regions are equal.
void SetWindowName(Window_t id, char *name)
Set window name.
Atom_t InternAtom(const char *atom_name, Bool_t only_if_exist)
Return atom handle for atom_name.
void DeleteImage(Drawable_t img)
Destroy XImage img.
const Mask_t kWABorderPixmap
const Mask_t kPointerMotionMask
const Mask_t kPAReturnPixels
void GetRegionBox(Region_t reg, Rectangle_t *)
Return smallest enclosing rectangle.
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
void UnionRegion(Region_t rega, Region_t regb, Region_t result)
Compute the union of rega and regb and return result region.
static const double x2[5]
void FillPolygon(Window_t id, GContext_t gc, Point_t *points, Int_t npnt)
FillPolygon fills the region closed by the specified path.
Bool_t SetSelectionOwner(Window_t, Atom_t &)
Changes the owner and last-change time for the specified selection.
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
void DestroySubwindows(Window_t id)
Destroy subwindows of this window.
Drawable fVisRootWin
Root window with fVisual to be used to create GC's and XImages.
void SetWindowBackgroundPixmap(Window_t id, Pixmap_t pxm)
Set pixmap as window background.
Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t, Atom_t *, Int_t *, ULong_t *, ULong_t *, unsigned char **)
Returns the actual type of the property; the actual format of the property; the number of 8-bit...
void ResizeWindow(Int_t wid)
Resize the current window if necessary.
Region_t CreateRegion()
Create a new empty region.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
R__EXTERN TFileHandler * gXDisplay
void Bell(Int_t percent)
Sound bell. Percent is loudness from -100% .. 100%.
const Mask_t kGCLineWidth
void DestroyWindow(Window_t id)
Destroy window.
void ClearWindow()
Clear current window.
const Mask_t kKeyLockMask
if(pyself &&pyself!=Py_None)
Visual_t GetVisual() const
Returns handle to visual (might be useful in some cases where direct X11 manipulation outside of TVir...
void LookupString(Event_t *event, char *buf, Int_t buflen, UInt_t &keysym)
Convert the keycode from the event structure to a key symbol (according to the modifiers specified in...
const Mask_t kGCGraphicsExposures
Colormap fColormap
Default colormap, 0 if b/w.
const ULong_t kMWMHintsInputMode
void SetKeyAutoRepeat(Bool_t on=kTRUE)
Turn key auto repeat on or off.
Bool_t CreatePictureFromFile(Drawable_t id, const char *filename, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr)
Create a picture pixmap from data on file.
void XShapeCombineMask(Display *, Window, int, int, int, Pixmap, int)
void DrawRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a rectangle outline.
const Mask_t kKeyMod4Mask
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
UInt_t ScreenWidthMM() const
Returns the width of the screen in millimeters.
void SetForeground(GContext_t gc, ULong_t foreground)
Set foreground color in graphics context (shortcut for ChangeGC with only foreground mask set)...
const Mask_t kWABackingPlanes
void Error(const char *location, const char *msgfmt,...)
void PutPixel(Drawable_t id, Int_t x, Int_t y, ULong_t pixel)
Set pixel at specified location in XImage img.
void IconifyWindow(Window_t id)
Iconify the window.
void WMDeleteNotify(Window_t id)
Tell WM to send message when window is closed via WM.
void CopyGC(GContext_t org, GContext_t dest, Mask_t mask)
Copies graphics context from org to dest.
const ULong_t kMWMHintsDecorations
void SubtractRegion(Region_t rega, Region_t regb, Region_t result)
Subtract rega from regb.
Int_t fDepth
Number of color planes.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
void ConvertSelection(Window_t, Atom_t &, Atom_t &, Atom_t &, Time_t &)
Requests that the specified selection be converted to the specified target type.
const Mask_t kButtonPressMask
void * fXEvent
Current native (X11) event.
void SelectInput(Window_t id, UInt_t evmask)
Defines which input events the window is interested in.
const Mask_t kKeyPressMask
const Mask_t kButton3Mask
void QueryPointer(Int_t &ix, Int_t &iy)
Query pointer position.
void GetWindowAttributes(Window_t id, WindowAttributes_t &attr)
Get window attributes and return filled in attributes structure.
void SetWMSize(Window_t id, UInt_t w, UInt_t h)
Tell the window manager the desired window size.
Bool_t fGraphicsExposures
Bool_t CheckEvent(Window_t id, EGEventType type, Event_t &ev)
Check if there is for window "id" an event of type "type".
const Int_t kPropMWMHintElements
void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist)
Add the list of drag and drop types to the Window win.
Pixmap_t CreatePixmap(Drawable_t id, UInt_t w, UInt_t h)
Creates a pixmap of the width and height you specified and returns a pixmap ID that identifies it...
void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent)
Return some font properties.
Double_t length(const TVector2 &v)
void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t)
Changes the specified dynamic parameters if the pointer is actively grabbed by the client...
const Mask_t kWAEventMask
R__EXTERN TSystem * gSystem
Long_t fDoNotPropagateMask
const Mask_t kWASaveUnder
void UnmapWindow(Window_t id)
Unmap window from screen.
const Mask_t kKeyMod5Mask
const Mask_t kGCClipXOrigin
Long_t fDoNotPropagateMask
FontH_t GetFontHandle(FontStruct_t fs)
Return handle to font described by font structure.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Drawable_t CreateImage(UInt_t width, UInt_t height)
Create a client-side XImage. Returns handle to XImage.
void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len)
Draw a string using a specific graphics context in position (x,y).
const Mask_t kExposureMask
FontStruct_t LoadQueryFont(const char *font_name)
Load font and query font.
Display_t GetDisplay() const
Returns handle to display (might be useful in some cases where direct X11 manipulation outside of TVi...
void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x, Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child)
TranslateCoordinates translates coordinates from the frame of reference of one window to another...
void DeleteProperty(Window_t, Atom_t &)
Deletes the specified property only if the property was defined on the specified window and causes th...
const Mask_t kOwnerGrabButtonMask
char * Form(const char *fmt,...)
void DeletePixmap(Pixmap_t pmap)
Explicitly delete pixmap resource.
Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id=0)
If id is NULL - loads the specified gif file at position [x0,y0] in the current window.
void DrawSegments(Drawable_t id, GContext_t gc, Segment_t *seg, Int_t nseg)
Draws multiple line segments. Each line is specified by a pair of points.
void ShapeCombineMask(Window_t id, Int_t x, Int_t y, Pixmap_t mask)
The Nonrectangular Window Shape Extension adds nonrectangular windows to the System.
void MoveWindow(Int_t wid, Int_t x, Int_t y)
Move the window wid.
void SetMWMHints(Window_t id, UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
void NextEvent(Event_t &event)
Copies first pending event from event queue to Event_t structure and removes event from queue...
const Mask_t kGCClipYOrigin
GContext_t CreateGC(Drawable_t id, GCValues_t *gval)
Create a graphics context using the values set in gval (but only for those entries that are in the ma...
const Mask_t kGCJoinStyle
void FreeFontStruct(FontStruct_t fs)
Free font structure returned by GetFontStruct().
void ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h)
Clear a window area to the background color.
void DestroyRegion(Region_t reg)
Destroy region.
Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input, int x, int y, int maxd)
Recursively search in the children of Window for a Window which is at location x, y and is DND aware...
void MoveResizeWindow(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize a window.
Pixmap_t CreateBitmap(Drawable_t id, const char *bitmap, UInt_t width, UInt_t height)
Create a bitmap (i.e. pixmap with depth 1) from the bitmap data.
void ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr)
Change window attributes.
const Mask_t kEnterWindowMask
static const double x1[5]
void MapPictureAttributes(PictureAttributes_t &attr, RXpmAttributes &xpmattr, Bool_t toxpm=kTRUE)
Map a PictureAttributes_t to a XpmAttributes structure.
const Mask_t kGCFillStyle
void MapSetWindowAttributes(SetWindowAttributes_t *attr, ULong_t &xmask, RXSetWindowAttributes &xattr)
Map a SetWindowAttributes_t to a XSetWindowAttributes structure.
const Mask_t kStructureNotifyMask
void MapGCValues(GCValues_t &gval, ULong_t &xmask, RXGCValues &xgval, Bool_t tox=kTRUE)
Map a GCValues_t to a XCGValues structure if tox is true.
void FreeColor(Colormap_t cmap, ULong_t pixel)
Free color cell with specified pixel value.
void FreeFontNames(char **fontlist)
Free list of font names.
const Mask_t kButtonReleaseMask
const Handle_t kParentRelative
void GrabButton(Window_t id, EMouseButton button, UInt_t modifier, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE)
Establish passive grab on a certain mouse button.
Bool_t EmptyRegion(Region_t reg)
Return true if the region is empty.
void LowerWindow(Window_t id)
Lower window so it lays below all its siblings.
const Mask_t kWAOverrideRedirect
static RooMathCoreReg dummy
void AsmLong(Long_t i1, Long_t i2, Long_t &ll)
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
const Mask_t kWAWinGravity
const Mask_t kGCForeground
void SetIconPixmap(Window_t id, Pixmap_t pic)
Set pixmap the WM can use when the window is iconized.
void SetWMSizeHints(Window_t id, UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
double Time(TStopwatch &w)
Bool_t CreatePictureFromData(Drawable_t id, char **data, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr)
Create a picture pixmap from data.
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
void DeleteGC(GContext_t gc)
Explicitly delete a graphics context.
#define org(otri, vertexptr)
void XorRegion(Region_t rega, Region_t regb, Region_t result)
Calculate the difference between the union and intersection of two regions.
void MapKeySym(UInt_t &keysym, UInt_t &xkeysym, Bool_t tox=kTRUE)
Map to and from X key symbols.
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set...
Mother of all ROOT objects.
void SetInputFocus(Window_t id)
Set keyboard input focus to window id.
R__EXTERN Atom_t gMOTIF_WM_HINTS
void SplitLong(Long_t ll, Long_t &i1, Long_t &i2)
void GetImageSize(Drawable_t id, UInt_t &width, UInt_t &height)
Get size of XImage img.
const Mask_t kGCTileStipYOrigin
void IntersectRegion(Region_t rega, Region_t regb, Region_t result)
Compute the intersection of rega and regb and return result region.
void SetPrimarySelectionOwner(Window_t id)
Makes the window id the current owner of the primary selection.
const Mask_t kGCSubwindowMode
void ConvertPrimarySelection(Window_t id, Atom_t clipboard, Time_t when)
XConvertSelection() causes a SelectionRequest event to be sent to the current primary selection owner...
const Mask_t kWABorderWidth
#define dest(otri, vertexptr)
RVisual * fVisual
Pointer to visual used by all windows.
void MapWindow(Window_t id)
Map window on screen.
Bool_t IsDNDAware(Window_t win, Atom_t *typelist)
Checks if Window win is DND aware, and knows any of the DND formats passed in argument.
const Mask_t kGCBackground
virtual void MapGCFont(GContext_t, FontStruct_t)
Map the XftFont with the Graphics Context using it.
const Mask_t kGCTileStipXOrigin
const Mask_t kFocusChangeMask
void SetWMState(Window_t id, EInitialState state)
Set the initial state of the window. Either kNormalState or kIconicState.
const Int_t kPropMotifWMHintsElements
Window_t GetInputFocus()
Returns the window id of the window having the input focus.
void SetWMTransientHint(Window_t id, Window_t main_id)
Tell window manager that window is a transient window of main.
Bool_t ParseColor(Colormap_t cmap, const char *cname, ColorStruct_t &color)
Parse string cname containing color name, like "green" or "#00FF00".
Drawable fRootWin
Root window used as parent of all windows.
Int_t KeysymToKeycode(UInt_t keysym)
Convert a keysym to the appropriate keycode.
const Mask_t kWABackPixel
void SetIconName(Window_t id, char *name)
Set window icon name.
void FillRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a filled rectangle. Filling is done according to the gc.
const Mask_t kWABackingPixel
const Mask_t kPACloseness
const Mask_t kKeyControlMask
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Cursor_t CreateCursor(ECursor cursor)
Create cursor handle (just return cursor from cursor pool fCursors).
const Mask_t kWADontPropagate
const Mask_t kAnyModifier
void CopyArea(Drawable_t src, Drawable_t dest, GContext_t gc, Int_t src_x, Int_t src_y, UInt_t width, UInt_t height, Int_t dest_x, Int_t dest_y)
Copy a drawable (i.e.
Window_t GetParent(Window_t id) const
Return the parent of the window.
Int_t TextWidth(FontStruct_t font, const char *s, Int_t len)
Return length of string in pixels. Size depends on font.
ULong_t fBlackPixel
Value of black pixel in colormap.
const Mask_t kButton1Mask
void ChangeProperties(Window_t id, Atom_t property, Atom_t type, Int_t format, UChar_t *data, Int_t len)
This function alters the property for the specified window and causes the X server to generate a Prop...
void CloseDisplay()
Close connection to display server.
void MapEventMask(UInt_t &emask, UInt_t &xemask, Bool_t tox=kTRUE)
Map event mask to or from X.
const Mask_t kGCPlaneMask
void MapModifierState(UInt_t &state, UInt_t &xstate, Bool_t tox=kTRUE)
Map modifier key state to or from X.
const Mask_t kKeyMod3Mask
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.