81 #include <X11/cursorfont.h> 84 #include <X11/keysymdef.h> 87 #define _WINDOW_HELPER_C_ 90 #include "pixmap_helper.h" 94 #define MIN_EVENT_LOOP_SLEEP_PERIOD 100 95 #define MAX_EVENT_LOOP_SLEEP_PERIOD 50000 138 Display *pDefaultDisplay = NULL;
140 int iStartupMinMax = 0;
692 #error _XSERVER64 defined 806 #define WINDOW_ENTRY_ARRAY_SIZE 2048 807 #define WINDOW_ENTRY_ARRAY_MAX 2047 808 #define WINDOW_ENTRY_HASH(X) (((((unsigned long)X & 0xf00) + \ 809 (((unsigned long)X >> 3) & 0x1f) + \ 810 (((unsigned long)X << 5) & 0xe0)) ^ \ 811 ((unsigned long)X >> 12)) & WINDOW_ENTRY_ARRAY_MAX) 813 #define WINDOW_ENTRY_UNUSED ((Window)-1) 815 #define WB_WINDOW_DELETE -3 816 #define WB_WINDOW_DESTROYED -2 817 #define WB_WINDOW_DESTROYING -1 818 #define WB_WINDOW_UNMAPPED 0 819 #define WB_WINDOW_MAPPED 1 820 #define WB_WINDOW_SET_FOCUS_ON_MAP 2 821 #define WB_WINDOW_DELETE_TIMEOUT 5 823 #define WB_CHECK_SET_FOCUS_ON_MAP(X) ((X).iWindowState == WB_WINDOW_SET_FOCUS_ON_MAP) 824 #define WB_IS_WINDOW_UNMAPPED(X) ((X).iWindowState == WB_WINDOW_UNMAPPED || (X).iWindowState == WB_WINDOW_SET_FOCUS_ON_MAP) 825 #define WB_IS_WINDOW_MAPPED(X) ((X).iWindowState == WB_WINDOW_MAPPED) 826 #define WB_IS_WINDOW_BEING_DESTROYED(X) ((X).iWindowState == WB_WINDOW_DESTROYING) 827 #define WB_IS_WINDOW_DESTROYED(X) ((X).iWindowState == WB_WINDOW_DESTROYED || (X).iWindowState == WB_WINDOW_DELETE) 828 #define WB_TO_DELETE_WINDOW_ENTRY(X) ((X).iWindowState == WB_WINDOW_DELETE) 835 static _WINDOW_ENTRY_ sWBHashEntries[WINDOW_ENTRY_ARRAY_SIZE]={{0,0}};
836 static volatile int nWBHashEntries = 0;
837 static Window wWBFakeWindow = 0;
838 static Window wIDApplication = None;
841 int bIgnoreXErrors = 0;
842 static WB_ERROR_INFO xErrorInfo = {NULL, NULL, 0, 0, 0, 0, 0, None};
845 Time tmDefaultDisplay = 0;
848 int bStandardColormap = 0;
849 XStandardColormap cmapDefault;
859 #define EVENT_ARRAY_SIZE 0x2000 860 #define EVENT_ARRAY_MASK 0x1fff 884 char padding[256 -
sizeof(Display *) -
sizeof(Window) -
sizeof(int) -
sizeof(XEvent)];
890 static int iWBQueuedEvent = -1, iWBQueueLast = -1, iWBPaintEvent = -1, iWBPaintLast = -1, iWBFreeEvent = -1;
891 static int iInitEventFlag = 0;
894 static int (* pAppEventCallback)(XEvent *pEvent) = NULL;
897 #define TIMER_ARRAY_SIZE 512 919 static TIMER_ENTRY *pTimerEntryActive = NULL, *pTimerEntryFree = NULL;
939 static DELAYED_EVENT_ENTRY *pDelayedEventEntryActive = NULL, *pDelayedEventEntryFree = NULL;
952 #define WBGetWindowEntry(X) Debug_WBGetWindowEntry(X, __FUNCTION__, __LINE__) 953 static __inline__
_WINDOW_ENTRY_ *Debug_WBGetWindowEntry(Window wID,
const char *szFunction,
int nLine);
956 static void __WBInitEvent();
957 static int __WBAddEvent(Display *pDisp, Window wID, XEvent *pEvent);
958 static void __WBDelWindowPaintEvents(Display *pDisp, Window wID);
959 static void __WBDelWindowEvents(Display *pDisp, Window wID);
960 static int __WBInsertPriorityEvent(Display *pDisp, Window wID, XEvent *pEvent);
961 static int __WBNextPaintEvent(Display *pDisp, XEvent *pEvent, Window wID);
962 static int __WBNextDisplayEvent(Display *pDisp, XEvent *pEvent);
963 static void WBInternalProcessExposeEvent(XExposeEvent *pEvent);
965 static Window __internal_GetParent(Display *pDisplay, Window wID, Window *pwRoot);
966 static const char * __internal_event_type_string(
int iEventType);
967 static int __InternalCheckGetEvent(Display *pDisplay, XEvent *pEvent, Window wIDModal);
968 static void DeletAllTimersForWindow(Display *pDisplay, Window wID);
970 void __InternalDestroyWindow(Display *pDisp, Window wID,
_WINDOW_ENTRY_ *pEntry);
979 static int disable_imagecache = 0;
980 static int (*pOldDisplayIOErrorHandler)(Display *) = NULL;
981 static int WBXIOErrorHandler(Display *pDisp);
982 static int WBXErrorHandler(Display *pDisplay, XErrorEvent *pError);
983 static int hBogus[3];
986 #ifdef WB_C99_INITIALIZERS 987 = {.
x=0,.y=0,.width=0,.height=0,.border=0};
989 #else // WB_C99_INITIALIZERS 991 #error this compiler does not support C99 structure initializers. Some code will not (yet) compile. 992 #endif // WB_C99_INITIALIZERS 993 static char szStartupDisplayName[512]=
":0.0";
994 static char szDefaultDisplayName[512]=
"";
997 #ifdef X11WORKBENCH_TOOLKIT_HAVE_XFT 998 extern FT_Library __ftlib;
999 #endif // X11WORKBENCH_TOOLKIT_HAVE_XFT 1005 void __internal_startup_display(
const char *szVal)
1007 strncpy(szStartupDisplayName, szVal,
sizeof(szStartupDisplayName));
1009 szStartupDisplayName[
sizeof(szStartupDisplayName) - 1] = 0;
1013 void __internal_startup_minimize(
void)
1015 iStartupMinMax = -1;
1019 void __internal_startup_maximize(
void)
1025 void __internal_startup_geometry(
const char *szVal)
1027 sscanf(szVal,
"%dx%d+%d+%d",
1028 &geomStartup.
width, &geomStartup.
height, &geomStartup.
x, &geomStartup.
y);
1032 void __internal_disable_imagecache(
void)
1034 disable_imagecache = 1;
1048 signal(SIGCHLD, SIG_IGN);
1067 for(i1=0; i1 < 3; i1++)
1069 hBogus[i1] = open(
"/dev/null", O_RDWR);
1075 for(i1=2; i1 >= 0; i1--)
1092 if(!szDisplayName || !*szDisplayName)
1094 szDisplayName =
":0.0";
1098 if((pRval = XOpenDisplay(szDisplayName)) == NULL)
1100 WB_ERROR_PRINT(
"%s - can't open display %s\n", __FUNCTION__, szDisplayName);
1106 strncpy(szDefaultDisplayName, szDisplayName,
sizeof(szDefaultDisplayName));
1112 pOldDisplayIOErrorHandler = XSetIOErrorHandler(WBXIOErrorHandler);
1118 WB_ERROR_PRINT(
"%s - Unable to initialize X11 WorkBench Toolkit\n", __FUNCTION__);
1126 #if 0 // see if I still need this by removing it 1146 static int WBXIOErrorHandler(Display *pDisp)
1149 "I/O error occurred, setting 'bQuitFlag'\n");
1162 unsigned long long ullTick;
1166 pDefaultDisplay = pDisplay;
1169 wWBFakeWindow = XCreateSimpleWindow(pDisplay, DefaultRootWindow(pDisplay), -1, -1, 1, 1, 0, 0, 0);
1175 XSetErrorHandler(WBXErrorHandler);
1182 WB_ERROR_PRINT(
"%s - unable to initialize clipboard system\n", __FUNCTION__);
1204 WB_ERROR_PRINT(
"%s - NO DEFAULT FONT, returning 0\n", __FUNCTION__);
1252 aWM_PROTOCOLS = XInternAtom(pDisplay,
"WM_PROTOCOLS", False);
1260 aCLIPBOARD = XInternAtom(pDisplay,
"CLIPBOARD", False);
1261 aMANAGER = XInternAtom(pDisplay,
"MANAGER", False);
1262 aTARGET = XInternAtom(pDisplay,
"TARGET", False);
1263 aINCR = XInternAtom(pDisplay,
"INCR", False);
1264 aPIXEL = XInternAtom(pDisplay,
"PIXEL", False);
1265 aTEXT = XInternAtom(pDisplay,
"TEXT", False);
1266 #ifdef X_HAVE_UTF8_STRING 1267 aUTF8_STRING = XInternAtom(pDisplay,
"UTF8_STRING", False);
1268 #endif // X_HAVE_UTF8_STRING 1269 aC_STRING = XInternAtom(pDisplay,
"C_STRING", False);
1271 aTARGETS = XInternAtom(pDisplay,
"TARGETS", False);
1272 aMULTIPLE = XInternAtom(pDisplay,
"MULTIPLE", False);
1273 aTIMESTAMP = XInternAtom(pDisplay,
"TIMESTAMP", False);
1287 aNULL = XInternAtom(pDisplay,
"NULL", False);
1314 #ifdef X_HAVE_UTF8_STRING
1340 WB_ERROR_PRINT(
"%s - unable to initialize clipboard system\n", __FUNCTION__);
1359 #define MIN_STARTUP_DELAY 100000LL 1361 #define MIN_STARTUP_DELAY 250000LL 1365 if(ullTick < MIN_STARTUP_DELAY)
1369 usleep(MIN_STARTUP_DELAY - ullTick);
1419 if(wWBFakeWindow == None)
1424 return wWBFakeWindow;
1427 void __InternalDestroyWindow(Display *pDisp, Window wID,
_WINDOW_ENTRY_ *pEntry)
1431 XClientMessageEvent xMsg;
1442 for(i1=0; i1 < WINDOW_ENTRY_ARRAY_SIZE; i1++)
1444 if(
WB_LIKELY(sWBHashEntries[i1].wID == WINDOW_ENTRY_UNUSED) ||
1445 WB_LIKELY(sWBHashEntries[i1].wID == None))
1450 if(sWBHashEntries[i1].wID == wID)
1457 if(sWBHashEntries[i1].wParent == wID)
1459 if(WB_IS_WINDOW_BEING_DESTROYED(sWBHashEntries[i1]))
1464 else if(WB_IS_WINDOW_DESTROYED(sWBHashEntries[i1]))
1469 else if(WB_TO_DELETE_WINDOW_ENTRY(sWBHashEntries[i1]))
1479 __InternalDestroyWindow(pDisp, sWBHashEntries[i1].wID, &(sWBHashEntries[i1]));
1485 if(!pEntry || !(pEntry->
eWMProtocols & WMPropertiesWMProtocols_DeleteWindow))
1500 XDestroyWindow(pDisp, wID);
1505 XSync(pDefaultDisplay, FALSE);
1512 pTempImage = pEntry->
pImage;
1518 XDestroyImage(pTempImage);
1528 pDisp = pDefaultDisplay;
1531 wIDTemp = DefaultRootWindow(pDisp);
1535 WB_ERROR_PRINT(
"ERROR - %s - default root window = 'None'\n", __FUNCTION__);
1536 goto destroy_without_wm;
1539 aNCW = XInternAtom(pDisp,
"_NET_CLOSE_WINDOW", False);
1543 WB_ERROR_PRINT(
"ERROR - %s - atom for _NET_CLOSE_WINDOW = 'None'\n", __FUNCTION__);
1544 goto destroy_without_wm;
1547 memset(&xMsg, 0,
sizeof(xMsg));
1549 xMsg.type = ClientMessage;
1551 xMsg.send_event = 1;
1552 xMsg.display = pDisp;
1554 xMsg.message_type = aNCW;
1556 xMsg.data.l[0] = CurrentTime;
1562 st = XSendEvent(pDisp, wIDTemp, False, NoEventMask, (XEvent *)&xMsg);
1566 XSync(pDefaultDisplay, FALSE);
1578 WB_ERROR_PRINT(
"INFO: %s - 'DESTROY WINDOW' message sent OK to WM\n", __FUNCTION__);
1585 WBDelay(MIN_EVENT_LOOP_SLEEP_PERIOD);
1588 if(XCheckTypedEvent(pDisp, DestroyNotify, &evt))
1593 if(WB_IS_WINDOW_DESTROYED(*pEntry))
1597 WB_ERROR_PRINT(
"INFO: %s - 'DESTROY WINDOW' message acknowledged by WM\n", __FUNCTION__);
1618 XDestroyWindow(pDisp, wID);
1622 XSync(pDefaultDisplay, FALSE);
1627 pTempImage = pEntry->
pImage;
1633 XDestroyImage(pTempImage);
1649 if(!pDefaultDisplay)
1651 WB_ERROR_PRINT(
"ERROR: %s - default display contains NULL\n", __FUNCTION__);
1659 XFlush(pDefaultDisplay);
1662 for(i1=WINDOW_ENTRY_ARRAY_MAX - 1; i1 >= 0; i1--)
1664 Display *pDisp = sWBHashEntries[i1].
pDisplay;
1665 Window wID = sWBHashEntries[i1].
wID;
1667 if(!wID || wID == WINDOW_ENTRY_UNUSED)
1674 pDisp = pDefaultDisplay;
1677 if(WB_IS_WINDOW_MAPPED(sWBHashEntries[i1]))
1679 WB_ERROR_PRINT(
"INFO: %s destroying window %d\n", __FUNCTION__, (
int)wID);
1683 __InternalDestroyWindow(pDisp, wID, &(sWBHashEntries[i1]));
1704 pDefaultFont = NULL;
1707 if(wWBFakeWindow != None)
1709 WB_ERROR_PRINT(
"INFO: %s destroying 'fake' window %d\n", __FUNCTION__, (
int)wWBFakeWindow);
1712 XDestroyWindow(pDefaultDisplay, wWBFakeWindow);
1717 XSync(pDefaultDisplay, FALSE);
1718 XCloseDisplay(pDefaultDisplay);
1721 wWBFakeWindow = None;
1722 pDefaultDisplay = NULL;
1729 if(pOldDisplayIOErrorHandler)
1731 XSetIOErrorHandler(pOldDisplayIOErrorHandler);
1732 pOldDisplayIOErrorHandler = NULL;
1738 return szStartupDisplayName;
1745 memcpy(pGeom, &geomStartup,
sizeof(
WB_GEOM));
1751 return iStartupMinMax;
1759 if(!szDefaultDisplayName[0])
1764 pDisplay = XOpenDisplay(szDefaultDisplayName);
1774 XSync(pDisplay, FALSE);
1787 XSync(pThreadDisplay, FALSE);
1788 XCloseDisplay(pThreadDisplay);
1794 unsigned long lBackgroundPixel, Colormap clrMap,
int iBitGravity)
1796 memset(pXSWA, 0,
sizeof(*pXSWA));
1798 pXSWA->border_pixel = lBorderPixel;
1799 pXSWA->background_pixel = lBackgroundPixel;
1800 pXSWA->colormap = clrMap;
1801 pXSWA->bit_gravity = iBitGravity;
1813 #define WBInitSizeHints__max(X,Y) ((X) > (Y) ? (X) : (Y)) 1815 memset(pSH, 0,
sizeof(*pSH));
1817 pSH->flags = (PPosition | PSize);
1826 int iDisplayHeight = DisplayHeight(pDisplay, DefaultScreen(pDisplay));
1827 int iDisplayWidth = DisplayWidth(pDisplay, DefaultScreen(pDisplay));
1828 int iActualDisplayWidth = iDisplayWidth;
1830 if(iDisplayWidth > iDisplayHeight * 4 / 3)
1832 iDisplayWidth = iDisplayHeight * 4 / 3;
1837 pSH->width = WBInitSizeHints__max(iMinWidth, iDisplayWidth * 2 / 3);
1838 pSH->height = WBInitSizeHints__max(iMinHeight, iDisplayHeight * 2 / 3);
1842 pSH->x = (iActualDisplayWidth - pSH->width) / 2;
1843 pSH->y = (iDisplayHeight - pSH->height) / 2;
1849 pSH->x = geomStartup.
x;
1850 pSH->y = geomStartup.
y;
1852 pSH->width = geomStartup.
width;
1853 pSH->height = geomStartup.
height;
1856 #undef WBInitSizeHints__max 1877 "Show Modal %d (%08xH) bMenuSplashFlag=%d\n", (
int)wID, (
int)wID, bMenuSplashFlag);
1880 if(bMenuSplashFlag <= 0)
1885 a1 = XInternAtom(pEntry->
pDisplay,
"_NET_WM_STATE", False);
1886 a2 = XInternAtom(pEntry->
pDisplay,
"_NET_WM_STATE_MODAL", False);
1887 XChangeProperty(pEntry->
pDisplay, wID, a1, XA_ATOM, 32, PropModePrepend, (
unsigned char *)&a2, 1);
1898 if(!bMenuSplashFlag)
1903 if(bMenuSplashFlag > 0)
1914 XGrabPointer(pEntry->
pDisplay,wID, 1,
1915 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask
1916 | EnterWindowMask | LeaveWindowMask,
1919 None, None, CurrentTime);
1920 XGrabKeyboard(pEntry->
pDisplay, wID, 1,
1934 iSleepPeriod = MIN_EVENT_LOOP_SLEEP_PERIOD;
1947 pEntry = WBGetWindowEntry(wID);
1963 if(iSleepPeriod < MAX_EVENT_LOOP_SLEEP_PERIOD)
1965 iSleepPeriod += (iSleepPeriod >> 1);
1969 iSleepPeriod = MAX_EVENT_LOOP_SLEEP_PERIOD;
1975 iSleepPeriod = MIN_EVENT_LOOP_SLEEP_PERIOD;
1980 if(
event.xany.window == None)
1995 if(bMenuSplashFlag > 0)
1997 if((
event.type == ButtonPress ||
event.type == ButtonRelease) &&
2000 WB_DEBUG_PRINT(DebugLevel_Chatty | DebugSubSystem_Mouse | DebugSubSystem_Menu,
2001 "WBShowModal - (menu) mouse button press outside of grab window\n");
2004 XUngrabPointer(pEntry->
pDisplay, CurrentTime);
2005 XUngrabKeyboard(pEntry->
pDisplay, CurrentTime);
2006 XAllowEvents(pEntry->
pDisplay, ReplayPointer, CurrentTime);
2015 else if(bMenuSplashFlag < 0)
2018 else if(
event.xany.window != wID &&
event.type == FocusIn)
2048 if(
event.xany.window == wID ||
2049 event.type == Expose ||
2050 event.type == GraphicsExpose ||
2052 event.type == DestroyNotify ||
2053 event.type == SelectionRequest ||
2054 event.type == SelectionClear ||
2055 event.type == SelectionNotify ||
2056 (bMenuSplashFlag > 0 &&
2057 (
event.type == KeyPress ||
event.type == KeyRelease ||
2058 event.type == ButtonPress ||
event.type == ButtonRelease ||
2059 event.type == MotionNotify ||
event.type == EnterNotify ||
2060 event.type == LeaveNotify)) ||
2066 if(
event.xany.window != wID && bMenuSplashFlag > 0 &&
2067 (
event.type == KeyPress ||
event.type == KeyRelease ||
event.type == MotionNotify))
2069 if(
event.type == MotionNotify)
2076 event.xmotion.x = iX;
2077 event.xmotion.y = iY;
2078 event.xmotion.window = wID;
2085 event.xany.window = wID;
2091 if(
event.xany.window != wID &&
2096 WB_DEBUG_PRINT(DebugLevel_Chatty | DebugSubSystem_Event | DebugSubSystem_Window,
2097 "%s - event %s for window %d (%08xH) in modal loop\n",
2100 (
int)
event.xany.window, (
int)
event.xany.window);
2103 if(
event.type == KeyPress ||
event.type == KeyRelease)
2105 WB_DEBUG_PRINT(DebugLevel_Chatty | DebugSubSystem_Keyboard | DebugSubSystem_Event | DebugSubSystem_Window,
2106 "%s - TEMPORARY - processing key press/release within modal loop: %d (%08xH), %d (%08xH)\n",
2107 __FUNCTION__, (
int)
event.xany.window, (
int)
event.xany.window, (
int)wID, (
int)wID);
2124 if(
event.type == KeyPress ||
event.type == KeyRelease)
2126 WB_DEBUG_PRINT(DebugLevel_Chatty | DebugSubSystem_Keyboard | DebugSubSystem_Event | DebugSubSystem_Window,
2127 "%s - key press/release in modal loop: %d (%08xH), %d (%08xH)\n",
2128 __FUNCTION__, (
int)
event.xany.window, (
int)
event.xany.window, (
int)wID, (
int)wID);
2142 if(bMenuSplashFlag > 0)
2145 XUngrabPointer(pEntry->
pDisplay, CurrentTime);
2146 XUngrabKeyboard(pEntry->
pDisplay, CurrentTime);
2153 "Exit from modal loop, window %d (%08xH) - returning %d (%08xH)\n",
2154 (
int)wID, (
int)wID, iRval, iRval);
2176 "WBEndModal - Window %d (%08xH), returning %d (%08xH)\n",
2177 (
int)wID, (
int)wID, iRval, iRval);
2185 Display *pDisp = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
2188 XGetInputFocus(pDisp, &wIDCurrent, &iRevert);
2191 if(wID != wIDCurrent)
2196 if(WB_CHECK_SET_FOCUS_ON_MAP(*pPrev))
2199 "%s:%d - %d (%08xH) disabling focus change on map\n",
2200 __FUNCTION__, __LINE__, (
int)wIDCurrent, (
int)wIDCurrent);
2211 "%s:%d - %d (%08xH) not yet visible, enabling focus change on map\n",
2212 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
2219 "%s:%d - %d (%08xH) calling XSetInputFocus\n",
2220 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
2225 XSetInputFocus(pDisp, wID, RevertToParent, CurrentTime);
2236 Display *pDisplay = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
2239 if(pEntry && WB_IS_WINDOW_DESTROYED(*pEntry))
2242 __FUNCTION__, (
int)wID, (
int)wID);
2244 __WBDelWindowPaintEvents(pDisplay, wID);
2249 if(pEntry && WB_IS_WINDOW_BEING_DESTROYED(*pEntry))
2253 WB_ERROR_PRINT(
"INFO: %s recursively destroying window %d\n", __FUNCTION__, (
int)wID);
2256 XDestroyWindow(pDisplay, wID);
2259 XSync(pDisplay, False);
2262 __WBDelWindowPaintEvents(pDisplay, wID);
2268 "%s - Window %d (%08xH) class %s\n",
2269 __FUNCTION__, (
int)wID, (
int)wID, pEntry ? (pEntry->
szClassName ? pEntry->
szClassName :
"NULL") :
"*Unk*");
2274 XSync(pDisplay, FALSE);
2284 WB_WARN_PRINT(
"WARNING: WBDestroyWindow for wID not in list - window already destroyed?\n");
2288 __WBDelWindowEvents(pDefaultDisplay, wID);
2290 WB_ERROR_PRINT(
"INFO: %s destroying UN-REGISTERED window %d\n", __FUNCTION__, (
int)wID);
2295 __InternalDestroyWindow(pDisplay, wID, NULL);
2302 "WBDestroyWindow - wID %d (%08xH)\n",
2303 (
int)wID, (
int)wID);
2319 "WBDestroyWindow - wID %d (%08xH), display flushed\n",
2320 (
int)wID, (
int)wID);
2322 if(WB_IS_WINDOW_MAPPED(*pEntry))
2325 "WBDestroyWindow - wID %d (%08xH), calling XDestroyWindow\n",
2326 (
int)wID, (
int)wID);
2328 __InternalDestroyWindow(pDisplay, wID, pEntry);
2346 else if(!WB_IS_WINDOW_BEING_DESTROYED(*pEntry) && !WB_IS_WINDOW_DESTROYED(*pEntry))
2349 "WBDestroyWindow - wID %d (%08xH), destroying 'unmapped' window\n",
2350 (
int)wID, (
int)wID);
2352 __InternalDestroyWindow(pDisplay, wID, pEntry);
2355 else if(!WB_TO_DELETE_WINDOW_ENTRY(*pEntry))
2358 "WBDestroyWindow - wID %d (%08xH), Marking 'unmapped' window 'destroyed'\n",
2359 (
int)wID, (
int)wID);
2364 __WBDelWindowEvents(pDisplay, wID);
2366 if(!WB_TO_DELETE_WINDOW_ENTRY(*pEntry))
2369 "WARNING - %s - last ditch attempt, unregistering window callback for window %d\n", __FUNCTION__, (
int)wID);
2380 pAppEventCallback = pCallback;
2385 pAppEventCallback = NULL;
2396 static __inline__
void InternalRestoreWindowDefaults(
int iIndex)
2399 sWBHashEntries[iIndex].
wParent = 0;
2403 sWBHashEntries[iIndex].
curRecent = None;
2404 bzero(&(sWBHashEntries[iIndex].geomAbsolute),
sizeof(sWBHashEntries[iIndex].geomAbsolute));
2405 sWBHashEntries[iIndex].
rgnClip = 0;
2406 sWBHashEntries[iIndex].
rgnPaint = 0;
2411 sWBHashEntries[iIndex].
width = sWBHashEntries[iIndex].
height 2412 = sWBHashEntries[iIndex].
border = 0;
2416 sWBHashEntries[iIndex].
wIDMenu = 0;
2418 sWBHashEntries[iIndex].
iWindowState = WB_WINDOW_UNMAPPED;
2420 sWBHashEntries[iIndex].
eWindowType = WMPropertiesWindowType_Normal;
2424 bzero(sWBHashEntries[iIndex].aWindowData,
sizeof(sWBHashEntries[iIndex].aWindowData));
2443 #define WBGetWindowEntry(X) Debug_WBGetWindowEntry(X, __FUNCTION__, __LINE__) 2444 static _WINDOW_ENTRY_ *Debug_WBGetWindowEntry(Window wID,
const char *szFunction,
int nLine)
2453 "%s:%d - Window hash table empty, %d (%08xH) not found\n",
2454 szFunction, nLine, (
int)wID, (
int)wID);
2459 i1 = iStart = WINDOW_ENTRY_HASH(wID);
2461 while(sWBHashEntries[i1].wID)
2463 if(sWBHashEntries[i1].wID == wID)
2465 gettimeofday(&(sWBHashEntries[i1].tvLastActivity), NULL);
2466 return(sWBHashEntries + i1);
2470 i1 &= WINDOW_ENTRY_ARRAY_MAX;
2478 "%s:%d - Window ID %d (%08xH) not found\n",
2479 szFunction, nLine, (
int)wID, (
int)wID);
2491 register int i1, i2, iStart;
2496 i1 = WINDOW_ENTRY_HASH(wID);
2501 "__AddOrLocateEntry - zero out window hash/array since it's empty\n");
2502 bzero(sWBHashEntries,
sizeof(sWBHashEntries));
2510 while(sWBHashEntries[i1].wID)
2512 if(sWBHashEntries[i1].wID == wID)
2514 pRval = sWBHashEntries + i1;
2518 if(sWBHashEntries[i1].wID == WINDOW_ENTRY_UNUSED)
2524 i1 &= WINDOW_ENTRY_ARRAY_MAX;
2542 if(i1 < 0 && i2 < 0)
2552 if((nWBHashEntries * 4) > (3 *
sizeof(sWBHashEntries)/
sizeof(sWBHashEntries[0])))
2560 pRval = sWBHashEntries + i1;
2565 InternalRestoreWindowDefaults(i1);
2578 static void __WindowEntryRestoreDefaultResources(
int iIndex)
2580 Display *pDisp = pDefaultDisplay;
2582 if(sWBHashEntries[iIndex].pDisplay)
2584 pDisp = sWBHashEntries[iIndex].
pDisplay;
2598 if(sWBHashEntries[iIndex].pFont && sWBHashEntries[iIndex].pFont != pDefaultFont)
2600 WBFreeFont(pDisp, sWBHashEntries[iIndex].pFont);
2601 sWBHashEntries[iIndex].
pFont = NULL;
2603 if(sWBHashEntries[iIndex].pxIcon)
2605 XFreePixmap(pDisp, sWBHashEntries[iIndex].pxIcon);
2606 sWBHashEntries[iIndex].
pxIcon = 0;
2608 if(sWBHashEntries[iIndex].pxMask)
2610 XFreePixmap(pDisp, sWBHashEntries[iIndex].pxMask);
2611 sWBHashEntries[iIndex].
pxMask = 0;
2613 if(sWBHashEntries[iIndex].pWMHints)
2615 XFree(sWBHashEntries[iIndex].pWMHints);
2616 sWBHashEntries[iIndex].
pWMHints = NULL;
2618 if(sWBHashEntries[iIndex].curRecent != None)
2620 XFreeCursor(pDisp, sWBHashEntries[iIndex].curRecent);
2621 sWBHashEntries[iIndex].
curRecent = None;
2623 if(sWBHashEntries[iIndex].rgnClip != 0)
2625 XDestroyRegion(sWBHashEntries[iIndex].rgnClip);
2626 sWBHashEntries[iIndex].
rgnClip = 0;
2628 if(sWBHashEntries[iIndex].rgnPaint != 0)
2630 WB_WARN_PRINT(
"WARNING: paint region non-zero in __WindowEntryRestoreDefaultResources\n");
2631 XDestroyRegion(sWBHashEntries[iIndex].rgnPaint);
2632 sWBHashEntries[iIndex].
rgnPaint = 0;
2634 if(sWBHashEntries[iIndex].pImage != NULL)
2636 XDestroyImage(sWBHashEntries[iIndex].pImage);
2637 sWBHashEntries[iIndex].
pImage = NULL;
2643 static void __WindowEntryDestructor(
int iIndex)
2647 __WindowEntryRestoreDefaultResources(iIndex);
2650 sWBHashEntries[iIndex].
pDisplay = NULL;
2653 InternalRestoreWindowDefaults(iIndex);
2675 iPrev = (iIndex - 1) & WINDOW_ENTRY_ARRAY_MAX;
2676 iNext = (iIndex + 1) & WINDOW_ENTRY_ARRAY_MAX;
2678 if(!sWBHashEntries[iNext].wID)
2680 sWBHashEntries[iIndex].
wID = 0;
2682 for(iIndex=iPrev; iIndex != iNext && sWBHashEntries[iIndex].
wID == WINDOW_ENTRY_UNUSED;
2683 iIndex = (iIndex - 1) & WINDOW_ENTRY_ARRAY_MAX)
2685 sWBHashEntries[iIndex].
wID = 0;
2690 if(!sWBHashEntries[iPrev].wID)
2693 sWBHashEntries[iIndex].
wID = 0;
2697 sWBHashEntries[iIndex].
wID = WINDOW_ENTRY_UNUSED;
2704 static void __PeriodicWindowEntryCleanup(
void)
2707 struct timeval tvNow;
2708 static struct timeval tvLastTime = {0,0};
2710 gettimeofday(&tvNow, NULL);
2712 if(tvNow.tv_sec == tvLastTime.tv_sec)
2717 tvLastTime.tv_sec = tvNow.tv_sec;
2719 tvNow.tv_sec -= WB_WINDOW_DELETE_TIMEOUT;
2725 for(i1=WINDOW_ENTRY_ARRAY_MAX - 1; i1 >= 0; i1--)
2727 Window wID = sWBHashEntries[i1].
wID;
2729 if(!wID || wID == WINDOW_ENTRY_UNUSED)
2734 if(sWBHashEntries[i1].iWindowState == WB_WINDOW_DELETE &&
2735 sWBHashEntries[i1].tvLastActivity.tv_sec < tvNow.tv_sec)
2738 "%s - destroying entry %d for window %u (%08xH)\n",
2740 (
int)sWBHashEntries[i1].wID, (
int)sWBHashEntries[i1].wID);
2748 __WindowEntryDestructor(i1);
2755 int iX,
int iY,
int iWidth,
int iHeight,
int iBorder,
int iIO,
2756 WB_UINT64 iFlags, XSetWindowAttributes *pXSWA)
2761 unsigned long valuemask;
2762 XSetWindowAttributes xswa;
2776 #ifdef HAS_WB_UINT64_BUILTIN 2777 valuemask = (
unsigned long)(iFlags & 0xffffffffL);
2778 #else // HAS_WB_UINT64_BUILTIN 2779 valuemask = iFlags.dw2;
2780 #endif // HAS_WB_UINT64_BUILTIN 2784 valuemask = CWBorderPixel | CWBackPixel | CWColormap | CWBitGravity;
2790 BlackPixel(pDisplay, DefaultScreen(pDisplay)),
2791 WhitePixel(pDisplay, DefaultScreen(pDisplay)),
2792 DefaultColormap(pDisplay, DefaultScreen(pDisplay)),
2797 idRval = XCreateWindow(pDisplay,
2798 wIDParent != None ? wIDParent : DefaultRootWindow(pDisplay),
2799 iX, iY, iWidth, iHeight, iBorder,
2800 DefaultDepth(pDisplay, DefaultScreen(pDisplay)),
2802 DefaultVisual(pDisplay, DefaultScreen(pDisplay)),
2811 if(wIDParent != None)
2816 pEntry = WBGetWindowEntry(idRval);
2820 WB_ERROR_PRINT(
"ERROR: %s - unable to get window entry (window still created)\n", __FUNCTION__);
2831 if(!__internal_alloc_WMHints(pEntry))
2834 XSetWMHints(pDisplay, idRval, pEntry->
pWMHints);
2841 geom.
width = iWidth;
2853 XWMHints *pWMHints, XClassHint *pClassHints)
2856 Display *pDisplay = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
2857 XTextProperty xTextProp;
2871 xTextProp.value = (
void *)szTitle;
2872 xTextProp.encoding = XA_STRING;
2873 xTextProp.format = 8;
2874 xTextProp.nitems = strlen(szTitle);
2883 if(__internal_alloc_WMHints(pEntry))
2893 if(pWMHints->flags & InputHint)
2895 pEntry->
pWMHints->input = pWMHints->input;
2896 pEntry->
pWMHints->flags |= InputHint;
2899 if(pWMHints->flags & StateHint)
2901 pEntry->
pWMHints->initial_state = pWMHints->initial_state;
2902 pEntry->
pWMHints->flags |= StateHint;
2905 if(pWMHints->flags & IconPixmapHint)
2908 if(pEntry->
pxIcon != None)
2910 XFreePixmap(pDisplay, pEntry->
pxIcon);
2915 pEntry->
pxIcon = pWMHints->icon_pixmap;
2916 pEntry->
pWMHints->icon_pixmap = pWMHints->icon_pixmap;
2917 pEntry->
pWMHints->flags |= IconPixmapHint;
2919 else if(pEntry->
pxIcon != None &&
2920 (!(pEntry->
pWMHints->flags & IconPixmapHint) || pEntry->
pWMHints->icon_pixmap == None))
2923 pEntry->
pWMHints->flags |= IconPixmapHint;
2926 if(pWMHints->flags & IconMaskHint)
2929 if(pEntry->
pxMask != None)
2931 XFreePixmap(pDisplay, pEntry->
pxMask);
2936 pEntry->
pxMask = pWMHints->icon_mask;
2937 pEntry->
pWMHints->icon_mask = pWMHints->icon_mask;
2938 pEntry->
pWMHints->flags |= IconMaskHint;
2940 else if(pEntry->
pxMask != None &&
2941 (!(pEntry->
pWMHints->flags & IconMaskHint) || pEntry->
pWMHints->icon_mask == None))
2944 pEntry->
pWMHints->flags |= IconMaskHint;
2947 if(pWMHints->flags & IconWindowHint)
2949 pEntry->
pWMHints->icon_window = pWMHints->icon_window;
2950 pEntry->
pWMHints->flags |= IconWindowHint;
2953 if(pWMHints->flags & IconPositionHint)
2955 pEntry->
pWMHints->icon_x = pWMHints->icon_x;
2956 pEntry->
pWMHints->icon_y = pWMHints->icon_y;
2957 pEntry->
pWMHints->flags |= IconPositionHint;
2960 if(pWMHints->flags & WindowGroupHint)
2962 pEntry->
pWMHints->window_group = pWMHints->window_group;
2963 pEntry->
pWMHints->flags |= WindowGroupHint;
2971 XSetWMProperties(pDisplay, wID, &xTextProp, &xTextProp, NULL, 0,
2978 XSetWMProperties(pDisplay, wID, NULL, NULL, NULL, 0,
2993 pEntry->
pWMHints = XGetWMHints(pDisplay, wID);
3007 Display *pDisplay = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
3011 a1 = XInternAtom(pDisplay,
"WM_NAME", False);
3012 a2 = XInternAtom(pDisplay,
"WM_ICON_NAME", False);
3017 XChangeProperty(pDisplay, wID, a1, XA_STRING, 8, PropModeReplace, (
unsigned char *)szTitle, strlen(szTitle));
3024 XChangeProperty(pDisplay, wID, a2, XA_STRING, 8, PropModeReplace, (
unsigned char *)szTitle, strlen(szTitle));
3055 if(wID == wIDApplication)
3057 wIDApplication = None;
3063 "%s - nWBHashEntries == NULL\n", __FUNCTION__);
3067 i1 = iStart = WINDOW_ENTRY_HASH(wID);
3069 while(sWBHashEntries[i1].wID)
3071 if(sWBHashEntries[i1].wID == wID)
3075 i1 &= WINDOW_ENTRY_ARRAY_MAX;
3090 if(i1 >= 0 && sWBHashEntries[i1].wID == wID)
3095 DeletAllTimersForWindow(sWBHashEntries[i1].pDisplay, wID);
3097 if(sWBHashEntries[i1].iWindowState != WB_WINDOW_DELETE)
3100 "Entry %d for window %d (%08xH) marked as 'to be destroyed'\n",
3101 i1, (
int)wID, (
int)wID);
3104 __WindowEntryRestoreDefaultResources(i1);
3106 gettimeofday(&(sWBHashEntries[i1].tvLastActivity), NULL);
3143 return WMPropertiesWindowType_Normal;
3167 WB_ERROR_PRINT(
"ERROR - %s - no Display pointer\n", __FUNCTION__);
3171 if(aProperty == None)
3173 WB_ERROR_PRINT(
"TEMPORARY: %s - removing WM PROTOCOLS atom list\n", __FUNCTION__);
3176 XSetWMProtocols(pDisplay, wID, pTemp, 0);
3182 va_start(va, aProperty);
3190 aArg = va_arg(va2, Atom);
3205 if(nItems >=
sizeof(aTemp)/
sizeof(aTemp[0]))
3207 pTemp = (Atom *)
WBAlloc((nItems + 1) *
sizeof(Atom));
3211 WB_ERROR_PRINT(
"ERROR - %s - not enough memory for atom list, errno=%d (%xH)\n", __FUNCTION__, errno, errno);
3216 pTemp[0] = aProperty;
3218 for(i1=1; i1 < nItems; i1++)
3220 aArg = va_arg(va, Atom);
3227 pTemp[nItems] = None;
3237 for(i1=0; i1 < nItems; i1++)
3241 pEntry->
eWMProtocols |= WMPropertiesWMProtocols_DeleteWindow;
3251 XSetWMProtocols(pDisplay, wID, pTemp, nItems);
3272 for(i1=0; i1 <= WINDOW_ENTRY_ARRAY_MAX; i1++)
3274 Window wID = sWBHashEntries[i1].
wID;
3275 if(wID && wID != WINDOW_ENTRY_UNUSED)
3277 i2 = callback(wID, pData);
3297 return wIDApplication;
3306 wIDApplication = None;
3310 pEntry = WBGetWindowEntry(wID);
3314 wIDApplication = None;
3318 wIDApplication = wID;
3347 int CreateTimer(Display *pDisplay, Window wID,
unsigned long lInterval,
long lID,
int iPeriodic)
3354 if(!pTimerEntryActive && !pTimerEntryFree)
3356 bzero(axWBTimer,
sizeof(axWBTimer));
3358 for(i1=1; i1 < TIMER_ARRAY_SIZE; i1++)
3360 axWBTimer[i1 - 1].
pNext = axWBTimer + i1;
3363 pTimerEntryFree = axWBTimer;
3367 pCur = pTimerEntryActive;
3380 if(!pTimerEntryFree)
3385 pCur = pTimerEntryFree;
3386 pTimerEntryFree = pTimerEntryFree->
pNext;
3403 pCur->
pNext = pTimerEntryActive;
3404 pTimerEntryActive = pCur;
3418 if(pTimerEntryActive != pEntry)
3421 WB_ERROR_PRINT(
"%s - (1) unable to properly delete timer due to pointer inconsistency %p %p %p\n",
3422 __FUNCTION__, pTimerEntryActive, pEntry, pEntry->
pNext);
3426 pTimerEntryActive = pEntry->
pNext;
3427 pEntry->
pNext = pTimerEntryFree;
3428 pTimerEntryFree = pEntry;
3431 else if(pPrev->
pNext == pEntry)
3434 pEntry->
pNext = pTimerEntryFree;
3435 pTimerEntryFree = pEntry;
3439 WB_ERROR_PRINT(
"%s - (2) unable to properly delete timer due to pointer inconsistency %p %p %p %p\n",
3440 __FUNCTION__, pPrev, pPrev->
pNext, pEntry, pEntry->
pNext);
3448 pCur = pTimerEntryActive;
3457 __DeleteTimer(pPrev, pCur);
3466 static void DeletAllTimersForWindow(Display *pDisplay, Window wID)
3470 pCur = pTimerEntryActive;
3478 pNext = pCur->
pNext;
3480 __DeleteTimer(pPrev, pCur);
3493 static int __CheckTimers(Display *pDisplay, XEvent *pEvent)
3500 pCur = pTimerEntryActive;
3524 __DeleteTimer(pPrev, pCur);
3528 bzero(pEvent,
sizeof(*pEvent));
3530 pEvent->xclient.type = ClientMessage;
3531 pEvent->xclient.serial = 0;
3532 pEvent->xclient.send_event = 0;
3533 pEvent->xclient.display = pDisplay;
3534 pEvent->xclient.window = pCur->
wID;
3535 pEvent->xclient.message_type =
aWB_TIMER;
3536 pEvent->xclient.format=32;
3537 pEvent->xclient.data.l[0] = pCur->
lID;
3549 static void __CreateDelayedEvent(XEvent *pEvent,
unsigned int uiInterval)
3556 if(!pDelayedEventEntryActive && !pDelayedEventEntryFree)
3558 bzero(axWBDelayedEvent,
sizeof(axWBDelayedEvent));
3560 for(i1=1; i1 < TIMER_ARRAY_SIZE; i1++)
3562 axWBDelayedEvent[i1 - 1].
pNext = axWBDelayedEvent + i1;
3565 pDelayedEventEntryFree = axWBDelayedEvent;
3569 pCur = pDelayedEventEntryFree;
3570 pDelayedEventEntryFree = pDelayedEventEntryFree->
pNext;
3573 memcpy(&(pCur->
event), pEvent,
sizeof(pCur->
event));
3577 pCur->
pNext = pDelayedEventEntryActive;
3578 pDelayedEventEntryActive = pCur;
3584 bzero(&(pEntry->
event),
sizeof(pEntry->
event));
3588 if(pDelayedEventEntryActive != pEntry)
3591 WB_ERROR_PRINT(
"%s - (1) unable to properly delete delayed event due to pointer inconsistency %p %p %p\n",
3592 __FUNCTION__, pTimerEntryActive, pEntry, pEntry->
pNext);
3596 pDelayedEventEntryActive = pEntry->
pNext;
3597 pEntry->
pNext = pDelayedEventEntryFree;
3598 pDelayedEventEntryFree = pEntry;
3601 else if(pPrev->
pNext == pEntry)
3604 pEntry->
pNext = pDelayedEventEntryFree;
3605 pDelayedEventEntryFree = pEntry;
3609 WB_ERROR_PRINT(
"%s - (2) unable to properly delete delayed event due to pointer inconsistency %p %p %p %p\n",
3610 __FUNCTION__, pPrev, pPrev->
pNext, pEntry, pEntry->
pNext);
3614 static int __attribute__((noinline)) __CheckDelayedEvents(Display *pDisplay, XEvent *pEvent)
3621 pCur = pDelayedEventEntryActive;
3626 if((pCur->
event.xany.display == pDisplay || pCur->
event.xany.window == None) &&
3631 if(pCur->
event.xany.window != None)
3635 if(!pEntry || WB_IS_WINDOW_DESTROYED(*pEntry))
3637 __DeleteDelayedEvent(pPrev, pCur);
3644 memcpy(pEvent, &(pCur->
event),
sizeof(*pEvent));
3646 __DeleteDelayedEvent(pPrev, pCur);
3667 static Bool __WBCheckIfEventPredicate(Display *pDisplay, XEvent *pEvent, XPointer arg)
3669 if(pEvent && pEvent->type != Expose)
3679 static Bool __WBCheckIfEventPredicate0(Display *pDisplay, XEvent *pEvent, XPointer arg)
3682 (pEvent->type == SelectionNotify ||
3683 pEvent->type == SelectionClear ||
3684 pEvent->type == SelectionRequest))
3696 static int iMouseState = 0;
3697 static int iMouseModShiftCtrl = 0;
3698 static int iMouseDragButtonState = 0;
3700 static Window wMouseCapture = None;
3701 static int iMouseX = 0, iMouseY = 0;
3706 MouseState_NONE = 0,
3707 MouseState_LCLICK = 1,
3708 MouseState_WAS_LCLICK,
3711 MouseState_WAS_RCLICK,
3714 MouseState_WAS_CCLICK,
3722 return tmDefaultDisplay + (qwTick - qwDefaultDisplayTick) / 1000;
3727 return __InternalCheckGetEvent(pDisplay, pEvent, None);
3732 int iTemp, iSleepPeriod;
3736 iTemp = iWBQueuedEvent;
3741 iSleepPeriod = MIN_EVENT_LOOP_SLEEP_PERIOD;
3745 if(
WB_LIKELY(axWBEvt[iTemp].pDisplay == pDisplay))
3750 iTemp = axWBEvt[iTemp].
iNext;
3753 iTemp = iWBPaintEvent;
3757 if(
WB_LIKELY(axWBEvt[iTemp].pDisplay == pDisplay))
3762 iTemp = axWBEvt[iTemp].
iNext;
3769 if(__CheckTimers(pDisplay, NULL))
3774 if(__CheckDelayedEvents(pDisplay, NULL))
3779 if(XEventsQueued(pDisplay, QueuedAfterFlush))
3792 if(iSleepPeriod < MAX_EVENT_LOOP_SLEEP_PERIOD)
3794 iSleepPeriod += (iSleepPeriod >> 2);
3798 iSleepPeriod = MAX_EVENT_LOOP_SLEEP_PERIOD;
3806 int __InternalCheckGetEvent(Display *pDisplay, XEvent *pEvent, Window wIDModal)
3808 int iRval = 0, iQueued;
3817 iQueued = XEventsQueued(pDisplay, QueuedAfterFlush);
3823 iQueued = XEventsQueued(pDisplay, QueuedAlready);
3832 XCheckIfEvent(pDisplay, pEvent, __WBCheckIfEventPredicate0, NULL);
3837 if(
WB_UNLIKELY(0 != (iRval = __CheckDelayedEvents(pDisplay, pEvent))))
3842 if(
WB_UNLIKELY(0 != (iRval = __CheckTimers(pDisplay, pEvent))))
3851 (XCheckIfEvent(pDisplay, pEvent, __WBCheckIfEventPredicate, NULL) ||
3852 XCheckMaskEvent(pDisplay, ExposureMask, pEvent));
3858 if(pDisplay == pDefaultDisplay)
3865 switch(pEvent->type)
3869 tmEvent =((XKeyEvent *)pEvent)->time;
3873 tmEvent =((XButtonEvent *)pEvent)->time;
3876 tmEvent =((XMotionEvent *)pEvent)->time;
3880 tmEvent =((XCrossingEvent *)pEvent)->time;
3882 case PropertyNotify:
3883 tmEvent =((XPropertyEvent *)pEvent)->time;
3885 case SelectionRequest:
3886 tmEvent =((XSelectionRequestEvent *)pEvent)->time;
3888 case SelectionClear:
3889 tmEvent =((XSelectionClearEvent *)pEvent)->time;
3891 case SelectionNotify:
3892 tmEvent =((XSelectionEvent *)pEvent)->time;
3896 if(tmEvent > tmDefaultDisplay)
3898 tmDefaultDisplay = tmEvent;
3903 if(pEvent->type == Expose)
3920 else if(pEvent->type == NoExpose)
3935 if(XEventsQueued(pDisplay, QueuedAfterFlush) > 0)
3954 if(pEvent->type == ConfigureNotify)
3961 _WINDOW_ENTRY_ *pEntry = WBGetWindowEntry(pEvent->xconfigure.window);
3982 pEntry->
width = pEvent->xconfigure.width;
3983 pEntry->
height = pEvent->xconfigure.height;
3984 pEntry->
border = pEvent->xconfigure.border_width;
3986 pEntry->
rgnClip = XCreateRegion();
3995 xrct.width = (
unsigned short)pEntry->
width;
3996 xrct.height = (
unsigned short)pEntry->
height;
4001 else if(WB_IS_WINDOW_MAPPED(*pEntry))
4003 wIDTemp = pEvent->xconfigure.window;
4012 if(wIDTemp == pEvent->xconfigure.window)
4024 WB_ERROR_PRINT(
"TEMPORARY: %s - subsequent ConfigureNotify and window is not yet mapped\n", __FUNCTION__);
4028 "%s - update internal geometry %d (%08xH) %d, %d, %d, %d\n",
4030 (
int)pEvent->xconfigure.window, (
int)pEvent->xconfigure.window,
4040 if(pEvent->type == ButtonPress ||
4041 pEvent->type == ButtonRelease ||
4042 pEvent->type == MotionNotify)
4044 int iButton1 = (((XButtonEvent *)pEvent)->state & Button1Mask)
4045 || ((XButtonEvent *)pEvent)->button == Button1;
4046 int iButton2 = (((XButtonEvent *)pEvent)->state & Button2Mask)
4047 || ((XButtonEvent *)pEvent)->button == Button2;
4048 int iButton3 = (((XButtonEvent *)pEvent)->state & Button3Mask)
4049 || ((XButtonEvent *)pEvent)->button == Button3;
4050 int iButton4 = (((XButtonEvent *)pEvent)->state & Button4Mask)
4051 || ((XButtonEvent *)pEvent)->button == Button4;
4052 int iButton5 = (((XButtonEvent *)pEvent)->state & Button5Mask)
4053 || ((XButtonEvent *)pEvent)->button == Button5;
4055 int iDragButtonState = (iButton1 ? 1 : 0)
4056 | (iButton2 ? 2 : 0)
4057 | (iButton3 ? 4 : 0);
4059 int iModShiftCtrl = ((XButtonEvent *)pEvent)->state & (ShiftMask | LockMask | ControlMask | Mod1Mask
4060 | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
4063 if(pEvent->type == ButtonPress &&
4064 (iMouseState == MouseState_NONE ||
4065 iMouseState == MouseState_WAS_LCLICK))
4067 Window wIDCurrent = None;
4069 Window wID0 = ((XButtonEvent *)pEvent)->window;
4076 XGetInputFocus(pDisplay, &wIDCurrent, &iRevert);
4082 if(wIDCurrent != wID0 &&
4083 ( wIDModal == None ||
4098 if(WB_CHECK_SET_FOCUS_ON_MAP(*pPrev))
4101 "%s:%d - %d (%08xH) disabling focus change on map\n",
4102 __FUNCTION__, __LINE__, (
int)wIDCurrent, (
int)wIDCurrent);
4113 "%s:%d - %d (%08xH) not yet visible, enabling focus change on map\n",
4114 __FUNCTION__, __LINE__, (
int)wID0, (
int)wID0);
4121 "%s:%d - %d (%08xH) calling XSetInputFocus\n",
4122 __FUNCTION__, __LINE__, (
int)wID0, (
int)wID0);
4127 XSetInputFocus(pDisplay, wID0, RevertToParent, CurrentTime);
4131 iMouseState = MouseState_NONE;
4141 case MouseState_WAS_LCLICK:
4143 if(pEvent->type == ButtonPress)
4148 if(abs(iMouseX - ((XButtonEvent *)pEvent)->x) >= iDblClickThresh ||
4149 abs(iMouseY - ((XButtonEvent *)pEvent)->y) >= iDblClickThresh ||
4152 iMouseState = MouseState_NONE;
4156 else if(!iButton1 || iButton2 || iButton3)
4158 iMouseState = MouseState_NONE;
4166 XClientMessageEvent evt = {
4167 .type=ClientMessage,
4171 .window=((XButtonEvent *)pEvent)->window,
4177 evt.data.l[1] = iDragButtonState;
4182 WBXlatCoordPoint(((XButtonEvent *)pEvent)->window, ((XButtonEvent *)pEvent)->x, ((XButtonEvent *)pEvent)->y,
4183 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4193 else if(pEvent->type == ButtonRelease)
4195 iMouseState = MouseState_NONE;
4208 case MouseState_NONE:
4209 if(pEvent->type == ButtonPress)
4213 XClientMessageEvent evt = {
4214 .type=ClientMessage,
4218 .window=((XButtonEvent *)pEvent)->window,
4224 evt.data.l[1] = iDragButtonState
4225 | (iButton4 ? 8 : 0)
4226 | (iButton5 ? 16 : 0);
4231 WBXlatCoordPoint(((XButtonEvent *)pEvent)->window, ((XButtonEvent *)pEvent)->x, ((XButtonEvent *)pEvent)->y,
4232 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4243 if(iButton1 && !iButton2 && !iButton3 && !iButton4 && !iButton5)
4246 iMouseState = MouseState_LCLICK;
4247 iMouseModShiftCtrl = iModShiftCtrl;
4251 iMouseX = ((XButtonEvent *)pEvent)->x;
4252 iMouseY = ((XButtonEvent *)pEvent)->y;
4254 else if(iButton4 || iButton5)
4258 XClientMessageEvent evt = {
4259 .type=ClientMessage,
4263 .window=pEvent->xany.window,
4277 evt.data.l[1] = iDragButtonState
4278 | (iButton4 ? 8 : 0)
4279 | (iButton5 ? 16 : 0);
4285 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4293 else if(pEvent->type == ButtonRelease)
4312 case MouseState_LCLICK:
4314 if(pEvent->type == ButtonPress)
4316 if(!iButton1 || iButton2 || iButton3)
4319 iMouseState = MouseState_NONE;
4326 else if(pEvent->type == ButtonRelease)
4328 iMouseState = MouseState_WAS_LCLICK;
4330 else if(iMouseModShiftCtrl != iModShiftCtrl)
4332 iMouseState = MouseState_NONE;
4340 if(abs(iMouseX - ((XButtonEvent *)pEvent)->x) >= iDragThresh ||
4341 abs(iMouseY - ((XButtonEvent *)pEvent)->y) >= iDragThresh)
4345 XClientMessageEvent evt = {
4346 .type=ClientMessage,
4350 .window=pEvent->xany.window,
4356 evt.data.l[1] = iDragButtonState
4357 | (iButton4 ? 8 : 0)
4358 | (iButton5 ? 16 : 0);
4363 iMouseDragButtonState = iDragButtonState;
4366 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4372 WBXlatCoordPoint(((XButtonEvent *)pEvent)->window, ((XButtonEvent *)pEvent)->x, ((XButtonEvent *)pEvent)->y,
4373 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4376 if(iTemp == (
int)evt.window)
4378 iMouseState = MouseState_LDRAG;
4380 if(wMouseCapture == None)
4382 XGrabPointer(pDisplay, ((XButtonEvent *)pEvent)->window, 1,
4383 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask
4384 | EnterWindowMask | LeaveWindowMask,
4387 None, None, CurrentTime);
4389 wMouseCapture = ((XButtonEvent *)pEvent)->window;
4398 iMouseX = ((XButtonEvent *)pEvent)->x;
4399 iMouseY = ((XButtonEvent *)pEvent)->y;
4417 iMouseState = MouseState_NONE;
4424 case MouseState_LDRAG:
4425 case MouseState_RDRAG:
4426 case MouseState_CDRAG:
4428 if(pEvent->type == ButtonPress ||
4429 iMouseDragButtonState != iDragButtonState ||
4430 iMouseModShiftCtrl != iModShiftCtrl)
4436 else if(pEvent->type == MotionNotify)
4441 (iMouseX != ((XButtonEvent *)pEvent)->x ||
4442 iMouseY != ((XButtonEvent *)pEvent)->y))
4444 XClientMessageEvent evt = {
4445 .type=ClientMessage,
4449 .window=((XButtonEvent *)pEvent)->window,
4457 evt.data.l[1] = iDragButtonState
4458 | (iButton4 ? 8 : 0)
4459 | (iButton5 ? 16 : 0);
4464 WBXlatCoordPoint(((XButtonEvent *)pEvent)->window, ((XButtonEvent *)pEvent)->x, ((XButtonEvent *)pEvent)->y,
4465 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4470 iMouseX = ((XButtonEvent *)pEvent)->x;
4471 iMouseY = ((XButtonEvent *)pEvent)->y;
4482 else if(pEvent->type == ButtonRelease)
4486 XClientMessageEvent evt = {
4487 .type=ClientMessage,
4491 .window=((XButtonEvent *)pEvent)->window,
4497 evt.data.l[1] = iDragButtonState;
4502 WBXlatCoordPoint(((XButtonEvent *)pEvent)->window, ((XButtonEvent *)pEvent)->x, ((XButtonEvent *)pEvent)->y,
4503 ((XButtonEvent *)pEvent)->window, &iX, &iY);
4510 if(wMouseCapture != None)
4513 XUngrabPointer(pDisplay, CurrentTime);
4514 wMouseCapture = None;
4517 iMouseState = MouseState_NONE;
4523 else if(iMouseState != MouseState_NONE &&
4524 (pEvent->type == KeyPress ||
4525 pEvent->type == KeyRelease))
4527 int iModShiftCtrl = ((XKeyEvent *)pEvent)->state & (ShiftMask | LockMask | ControlMask | Mod1Mask
4528 | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
4530 int iKey = XLookupKeysym((XKeyEvent *)pEvent, 0);
4536 if(iModShiftCtrl != iMouseModShiftCtrl ||
4537 (pEvent->type == KeyPress &&
4538 (iKey == XK_Escape || iKey == XK_Return || iKey == XK_KP_Enter)))
4565 if(pEvent->xany.type == ClientMessage
4566 && pEvent->xclient.message_type ==
aSET_FOCUS)
4569 Window wID = (Window)pEvent->xclient.data.l[0];
4570 Window wIDFrom = (Window)pEvent->xclient.data.l[1];
4571 Window wIDRoot = None;
4575 if(pEntry && pEntry->
pDisplay && pEvent->xany.display &&
4576 pEvent->xany.display != pEntry->
pDisplay)
4579 WB_ERROR_PRINT(
"ERROR - %s - display pointer mismatch\n", __FUNCTION__);
4590 pDisplay = pDefaultDisplay;
4593 else if(pEvent->xany.display)
4595 pDisplay = pEvent->xany.display;
4599 pDisplay = pDefaultDisplay;
4606 aTemp = XInternAtom (pEvent->xany.display ? pEvent->xany.display : pDefaultDisplay,
4607 "_NET_ACTIVE_WINDOW", False);
4609 bzero(&evtTemp,
sizeof(evtTemp));
4611 evtTemp.xany.type = ClientMessage;
4612 evtTemp.xany.send_event = True;
4613 evtTemp.xany.display = pEvent->xany.display ? pEvent->xany.display : pDefaultDisplay;
4614 evtTemp.xany.window = wID;
4615 evtTemp.xany.serial = 0;
4617 __internal_GetParent(evtTemp.xany.display, wID, &wIDRoot);
4620 evtTemp.xclient.message_type = aTemp;
4621 evtTemp.xclient.format = 32;
4622 evtTemp.xclient.data.l[0] = 0;
4623 evtTemp.xclient.data.l[1] = 0;
4624 evtTemp.xclient.data.l[2] = wIDFrom;
4627 XSendEvent(pDisplay, wIDRoot, False,
4628 SubstructureRedirectMask | SubstructureNotifyMask,
4636 bzero(&xwc,
sizeof(xwc));
4637 xwc.stack_mode = Above;
4642 XConfigureWindow(pDisplay, wID, CWStackMode, &xwc);
4643 XMapWindow(pDisplay, wID);
4650 if(!pAppEventCallback || !pAppEventCallback(pEvent))
4665 if(pEvent->xany.window == None)
4674 __PeriodicWindowEntryCleanup();
4681 int iRval = 0, iSetFocus = 0;
4683 if(pEvent->type == ClientMessage)
4685 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_Event | DebugSubSystem_Window,
4686 "%s - client message, pEntry==%pH\n", __FUNCTION__, pEntry);
4699 WB_WARN_PRINT(
"%s - pMenuEntry is NULL, pEntry->wIDMenu = %d (%08xH)\n",
4702 else if(
WB_UNLIKELY(WB_IS_WINDOW_DESTROYED(*pMenuEntry)))
4707 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
4712 (pEvent->type == ConfigureNotify ||
4713 pEvent->type == EnterNotify ||
4714 pEvent->type == LeaveNotify ||
4715 pEvent->type == KeyPress ||
4716 pEvent->type == KeyRelease ||
4717 pEvent->type == ButtonPress ||
4718 pEvent->type == ButtonRelease ||
4719 pEvent->type == MotionNotify ||
4720 pEvent->type == ClientMessage))
4734 if(pEvent->type == Expose)
4743 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
4754 iSetFocus = WB_CHECK_SET_FOCUS_ON_MAP(*pEntry);
4757 if(pEvent->type == ReparentNotify && wID == pEvent->xreparent.window)
4759 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_Window | DebugSubSystem_Event,
4760 "%s - re-parent event, %d (%08xH), %d (%08xH)\n",
4761 __FUNCTION__, (
int)wID, (
int)wID,
4762 (
int)pEvent->xreparent.parent, (
int)pEvent->xreparent.parent);
4764 pEntry->
wParent = pEvent->xreparent.parent;
4774 "%s:%d - %d (%08xH) mapped, setting focus\n",
4775 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
4780 XSetInputFocus(pEntry->
pDisplay, wID, RevertToParent, CurrentTime);
4786 if(pEvent->type != DestroyNotify ||
4787 pEvent->xdestroywindow.window != wID)
4789 if(pEvent->type == DestroyNotify)
4791 WB_ERROR_PRINT(
"%s - UNEXPECTED - DestroyNotify for %d and message is for %d\n",
4792 __FUNCTION__, (
int)pEvent->xdestroywindow.window, (
int)wID);
4803 else if(pEvent->type == DestroyNotify)
4805 if(pEvent->xdestroywindow.window == wID)
4808 if(!WB_IS_WINDOW_DESTROYED(*pEntry))
4811 WB_ERROR_PRINT(
"INFO: %s - DestroyNotify for wID %d (%s) and NO CALLBACK (this is sometimes expected)\n",
4817 WB_ERROR_PRINT(
"ERROR: %s - (UNEXPECTED) DestroyNotify for %d and message is for %d (no callback)\n",
4818 __FUNCTION__, (
int)pEvent->xdestroywindow.window, (
int)wID);
4824 "%s:%d - %d (%08xH) mapped, setting focus\n",
4825 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
4830 XSetInputFocus(pEntry->
pDisplay, wID, RevertToParent, CurrentTime);
4839 if(pEvent->type == DestroyNotify &&
4840 pEvent->xdestroywindow.window == wID)
4846 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_Window | DebugSubSystem_Event,
4847 "%s - DestroyNotify for %d (%08xH)\n",
4848 __FUNCTION__, (
int)wID, (
int)wID);
4850 if(pEntry2 && !iRval)
4857 if(wID == wIDApplication)
4862 if(pEntry2 && pEntry2 == pEntry)
4865 __WBDelWindowEvents(pEntry->
pDisplay, wID);
4876 WB_ERROR_PRINT(
"WARNING - %s - pEntry == %p, pEntry2 == %p\n", __FUNCTION__, pEntry, pEntry2);
4882 WB_DEBUG_PRINT(DebugLevel_WARN | DebugSubSystem_Window | DebugSubSystem_Event ,
4883 "%s - Event %s for window %d (%08xH) not handled [no pEntry]\n",
4884 __FUNCTION__,
WBEventName(pEvent->type), (
int)wID, (
int)wID);
4915 Display *pDisplay = pEvent->xany.display ? pEvent->xany.display
4916 : pEntry ? pEntry->
pDisplay : pDefaultDisplay;
4919 if (pEvent->type == Expose && pEvent->xexpose.count == 0)
4922 if(pEntry && pEntry->
hGC != NULL)
4935 XClearWindow(pDisplay, wID);
4940 else if(pEvent->type == ConfigureNotify && pEvent->xconfigure.window == wID)
4942 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_Window | DebugSubSystem_Event,
4943 "%s - window %08xH gets ConfigureNotify\n",
4944 __FUNCTION__, (
unsigned int)wID);
4949 if(pEvent->xconfigure.width != pEntry->
width ||
4950 pEvent->xconfigure.height != pEntry->
height ||
4951 pEvent->xconfigure.border_width != pEntry->
border)
4953 if(!WB_IS_WINDOW_MAPPED(*pEntry) ||
4960 pEntry->
width = pEvent->xconfigure.width;
4961 pEntry->
height = pEvent->xconfigure.height;
4962 pEntry->
border = pEvent->xconfigure.border_width;
4966 XDestroyRegion(pEntry->
rgnClip);
4969 pEntry->
rgnClip = XCreateRegion();
4976 xrct.width = (
unsigned short)pEntry->
width;
4977 xrct.height = (
unsigned short)pEntry->
height;
4992 else if(pEvent->type == VisibilityNotify &&
4993 pEvent->xvisibility.window == wID &&
4994 pEvent->xvisibility.state != VisibilityFullyObscured)
5001 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_Window | DebugSubSystem_Event,
5002 "%s - window %08xH gets VisibilityNotify, state=%d\n",
5003 __FUNCTION__, (
unsigned int)pEvent->xvisibility.window, pEvent->xvisibility.state);
5009 else if(pEvent->type == MapRequest &&
5010 (pEvent->xmaprequest.parent == wID || pEvent->xmaprequest.window == wID))
5014 WB_ERROR_PRINT(
"TEMPORARY: %s - window %08xH gets MapRequest for %08xH\n",
5015 __FUNCTION__, (
unsigned int)pEvent->xmaprequest.parent, (
unsigned int)pEvent->xmaprequest.window);
5017 else if(pEvent->type == ClientMessage)
5020 if(pEvent->xclient.message_type ==
aWM_PROTOCOLS && pEvent->xclient.window == wID)
5027 XClientMessageEvent evt;
5029 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_Window | DebugSubSystem_Event,
5030 "%s - WM_DELETE_WINDOW for %d (%08xH)\n",
5031 __FUNCTION__, (
int)wID, (
int)wID);
5033 WB_ERROR_PRINT(
"TEMPORARY: %s - WM_PROTOCOLS WM_DELETE_WINDOW, requests call to XDestroyWindow for %u (%08xH)\n", __FUNCTION__, (
int)wID, (
int)wID);
5039 bzero(&evt,
sizeof(evt));
5040 evt.type = ClientMessage;
5041 evt.display = pDisplay;
5053 WB_ERROR_PRINT(
"ERROR: %s - QUERY_CLOSE returns %d, destroying window %u (%08xH) anyway\n",
5054 __FUNCTION__, i1, (
int)wID, (
int)wID);
5058 WB_ERROR_PRINT(
"INFO: %s - QUERY_CLOSE returns %d, ok to destroy window %u (%08xH)\n",
5059 __FUNCTION__, i1, (
int)wID, (
int)wID);
5062 if(wID == wIDApplication)
5070 __WBDelWindowEvents(pEntry->
pDisplay, wID);
5080 XDestroyWindow(pDisplay, wID);
5087 else if(pEvent->xclient.message_type ==
aWB_TIMER && pEvent->xclient.window == wID)
5089 WB_DEBUG_PRINT(DebugLevel_Light | DebugSubSystem_Window | DebugSubSystem_Event,
5090 "%s - un-handled WB_TIMER for %d (%08xH)\n",
5091 __FUNCTION__, (
int)wID, (
int)wID);
5093 #ifndef NO_DEBUG // uncomment this block to dump every event NOT handled 5096 WB_DEBUG_PRINT(DebugLevel_Light | DebugSubSystem_Window | DebugSubSystem_Event,
5097 "%s - un-handled ClientMessage for %d (%08xH)\n",
5098 __FUNCTION__, (
int)wID, (
int)wID);
5100 WB_IF_DEBUG_LEVEL(DebugLevel_Light | DebugSubSystem_Window | DebugSubSystem_Event)
5107 else if(pEvent->type == KeyPress ||
5108 pEvent->type == KeyRelease)
5110 WB_DEBUG_PRINT(DebugLevel_Excessive | DebugSubSystem_Window | DebugSubSystem_Event | DebugSubSystem_Keyboard,
5111 "%s - key press/release event for %d (%08xH) in default handler\n",
5112 __FUNCTION__, (
int)wID, (
int)wID);
5114 if(pEvent->type == KeyPress )
5120 XClientMessageEvent evt;
5121 int cbData, iACS = 0;
5125 bzero(&evt,
sizeof(evt));
5126 evt.type = ClientMessage;
5127 evt.display = pDisplay;
5128 evt.window = pEvent->xany.window;
5132 cbData =
sizeof(evt.data) - 3 *
sizeof(evt.data.l[0]);
5134 (
char *)&(evt.data.l[3]),
5137 evt.data.l[1] = iACS;
5138 evt.data.l[2] = cbData;
5143 if(evt.data.l[0] < XK_Shift_L || evt.data.l[0] > XK_Hyper_R)
5153 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_Event | DebugSubSystem_Keyboard,
5154 "%s - generating WB_CHAR for KEYSYM %ld (%lxH) iACS=%xH window %d (%08xH)\n",
5155 __FUNCTION__, evt.data.l[0], evt.data.l[0], iACS,
5156 (
int)pEvent->xany.window, (
int)pEvent->xany.window);
5161 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_Event | DebugSubSystem_Keyboard,
5162 "%s - generating WB_CHAR \"%.*s\" iACS=%xH window %d (%08xH)\n",
5163 __FUNCTION__, cbData, (
char *)&(evt.data.l[3]), iACS,
5164 (
int)pEvent->xany.window, (
int)pEvent->xany.window);
5172 else if(pEvent->type == DestroyNotify &&
5173 pEvent->xdestroywindow.window == wID)
5179 Window wIDMenu = pEntry->
wIDMenu;
5186 for(i1=0; i1 <= WINDOW_ENTRY_ARRAY_MAX; i1++)
5188 if(sWBHashEntries[i1].wIDMenu == wIDMenu)
5193 if(i1 > WINDOW_ENTRY_ARRAY_MAX)
5199 else if(pEvent->type == SelectionRequest)
5205 char *p1 = pEvent->xselectionrequest.selection != None ?
WBGetAtomName(pDisplay, pEvent->xselectionrequest.selection) : NULL;
5206 char *p2 = pEvent->xselectionrequest.target != None ?
WBGetAtomName(pDisplay, pEvent->xselectionrequest.target) : NULL;
5207 char *p3 = pEvent->xselectionrequest.property != None ?
WBGetAtomName(pDisplay, pEvent->xselectionrequest.property) : NULL;
5209 WB_ERROR_PRINT(
"TEMPORARY - %s - SelectionRequest wID=%d(%08xH) class=%s owner=%d requestor=%d selection=%s target=%s property=%s\n",
5212 (
const char *)(pEntry ? pEntry->
szClassName :
"UNK"),
5213 (
int)pEvent->xselectionrequest.owner,
5214 (
int)pEvent->xselectionrequest.requestor,
5236 if(pEvent->xselectionrequest.owner == wID)
5238 XSelectionEvent evtN;
5240 memset(&evtN, 0,
sizeof(evtN));
5242 evtN.type = SelectionNotify;
5243 evtN.send_event = True;
5244 evtN.requestor = pEvent->xselectionrequest.requestor;
5245 evtN.selection = pEvent->xselectionrequest.selection;
5246 evtN.target = pEvent->xselectionrequest.target;
5247 evtN.property = None;
5248 evtN.time = pEvent->xselectionrequest.time;
5251 XSendEvent(pDisplay, evtN.requestor, False, 0, (XEvent *)&evtN);
5255 else if(pEvent->type == SelectionClear)
5258 char *p1 =
WBGetAtomName(pDisplay, pEvent->xselectionclear.selection);
5260 WB_ERROR_PRINT(
"TEMPORARY - %s - SelectionClear wID=%d(%08xH) class=%s window=%d selection=%s\n",
5263 (
const char *)(pEntry ? pEntry->
szClassName :
"UNK"),
5264 (
int)pEvent->xselectionclear.window,
5275 else if(pEvent->type == SelectionNotify)
5278 char *p1 = pEvent->xselection.selection != None ?
WBGetAtomName(pDisplay, pEvent->xselection.selection) : NULL;
5279 char *p2 = pEvent->xselection.target != None ?
WBGetAtomName(pDisplay, pEvent->xselection.target) : NULL;
5280 char *p3 = pEvent->xselection.property != None ?
WBGetAtomName(pDisplay, pEvent->xselection.property) : NULL;
5282 WB_ERROR_PRINT(
"TEMPORARY - %s - SelectionNotify wID=%d(%08xH) class=%s requestor=%d selection=%s target=%s property=%s\n",
5285 (
const char *)(pEntry ? pEntry->
szClassName :
"UNK"),
5286 (
int)pEvent->xselection.requestor,
5321 WBInternalProcessExposeEvent(pEvent);
5326 XSync(pEvent->display, 0);
5328 while(!
bQuitFlag && XCheckTypedWindowEvent(pEvent->display, pEvent->window, Expose, &xevt))
5330 WBInternalProcessExposeEvent((XExposeEvent *)&xevt);
5337 XClientMessageEvent evt;
5341 if((iMouseState != MouseState_LDRAG &&
5342 iMouseState != MouseState_RDRAG &&
5343 iMouseState != MouseState_CDRAG &&
5344 iMouseState != MouseState_WAS_LCLICK &&
5345 iMouseState != MouseState_WAS_RCLICK &&
5346 iMouseState != MouseState_WAS_CCLICK)
5347 || wMouseCapture == None)
5349 if(wMouseCapture != None)
5351 WB_ERROR_PRINT(
"ERROR: %s - incorrect mouse state: %d (%08xH)\n", __FUNCTION__, iMouseState, iMouseState);
5355 wMouseCapture = None;
5357 else if(iMouseState == MouseState_NONE)
5361 else if(iMouseState != MouseState_WAS_LCLICK &&
5362 iMouseState != MouseState_WAS_RCLICK &&
5363 iMouseState != MouseState_WAS_CCLICK)
5367 WB_ERROR_PRINT(
"ERROR: %s - mouse not captured. mouse state: %d (%08xH) \n", __FUNCTION__, iMouseState, iMouseState);
5372 iMouseState = MouseState_NONE;
5379 wID = wMouseCapture;
5391 bzero(&evt,
sizeof(evt));
5392 evt.type=ClientMessage;
5393 evt.display=pDisplay;
5399 evt.data.l[1] = iMouseDragButtonState;
5404 WBXlatCoordPoint(wMouseCapture, iMouseX, iMouseY, wMouseCapture, &iX, &iY);
5411 iMouseState = MouseState_NONE;
5413 XUngrabPointer(pDisplay, CurrentTime);
5415 wMouseCapture = None;
5416 iMouseModShiftCtrl = iMouseDragButtonState = 0;
5424 int iRval, iSetFocus = 0;
5428 iSetFocus = WB_CHECK_SET_FOCUS_ON_MAP(*pEntry);
5436 if(!__internal_alloc_WMHints(pEntry))
5446 iRval = XMapWindow(pDisplay, wID);
5452 "%s:%d - %d (%08xH) mapped, setting focus\n",
5453 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
5458 XSetInputFocus(pEntry->
pDisplay, wID, RevertToParent, CurrentTime);
5469 int iRval, iSetFocus = 0;
5473 iSetFocus = WB_CHECK_SET_FOCUS_ON_MAP(*pEntry);
5481 if(!__internal_alloc_WMHints(pEntry))
5490 iRval = XMapRaised(pDisplay, wID);
5495 "%s:%d - %d (%08xH) mapped, setting focus\n",
5496 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
5501 XSetInputFocus(pEntry->
pDisplay, wID, RevertToParent, CurrentTime);
5515 if(WB_IS_WINDOW_UNMAPPED(*pEntry) || WB_IS_WINDOW_DESTROYED(*pEntry))
5524 iRval = XUnmapWindow(pDisplay, wID);
5537 if(pEntry && WB_IS_WINDOW_MAPPED(*pEntry) && !WB_IS_WINDOW_DESTROYED(*pEntry))
5551 if(pEntry && !WB_IS_WINDOW_DESTROYED(*pEntry))
5580 pEntry->
pWMHints = XAllocWMHints();
5584 pEntry->
pWMHints->initial_state = NormalState;
5586 pEntry->
pWMHints->flags = InputHint | StateHint;
5605 return pDefaultDisplay;
5611 Display *pDisp = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
5615 if(__internal_alloc_WMHints(pEntry))
5621 if(pEntry->
pxIcon != None)
5623 XFreePixmap(pDisp, pEntry->
pxIcon);
5627 if(pEntry->
pxMask != None)
5629 XFreePixmap(pDisp, pEntry->
pxMask);
5636 pEntry->
pWMHints->flags |= IconPixmapHint;
5638 pEntry->
pWMHints->flags |= IconMaskHint;
5640 pEntry->
pWMHints->flags &= ~IconMaskHint;
5646 XSetWMHints(pDisp, wID, pEntry->
pWMHints);
5710 if(pEntry->
pFont && pEntry->
pFont != pDefaultFont)
5744 memset(&gcv, 0,
sizeof(gcv));
5746 gcv.foreground = clrFG;
5747 gcv.background = clrBG;
5760 #warning does the default GC _REALLY_ need to have a default X11 (legacy) font ID assigned in the XGCValues struct??? 5765 if(pEntry->
hGC && ((CARD32)pEntry->
hGC->
values.clip_mask & 0xe0000000))
5767 WB_ERROR_PRINT(
"ERROR: %s - hGC clip_mask is NOT VALID\n", __FUNCTION__);
5770 pEntry->
clrFG = clrFG;
5771 pEntry->
clrBG = clrBG;
5788 if(hGC && ((CARD32)hGC->
values.clip_mask & 0xe0000000))
5790 WB_ERROR_PRINT(
"ERROR: %s - hGC clip_mask is NOT VALID\n", __FUNCTION__);
5811 return(pEntry->
hGC);
5839 return(pEntry->
clrFG);
5851 return(pEntry->
clrBG);
5878 return gc->
values.foreground;
5908 return gc->
values.background;
5919 XStandardColormap *pMaps = NULL;
5920 XStandardColormap cmap;
5922 unsigned long lTemp;
5923 XColor clrRed, clrGreen, clrBlue;
5942 memcpy(pMap, &cmapDefault,
sizeof(cmapDefault));
5947 bzero(&cmap,
sizeof(cmap));
5949 cmDefault = DefaultColormap(pDisplay, DefaultScreen(pDisplay));
5952 if(!XGetRGBColormaps(pDisplay, DefaultRootWindow(pDisplay), &pMaps, &nMaps, XA_RGB_DEFAULT_MAP) ||
5962 if(!XGetRGBColormaps(pDisplay, DefaultRootWindow(pDisplay), &pMaps, &nMaps, XA_RGB_BEST_MAP) ||
5976 for(i1=0; i1 < nMaps; i1++)
5978 if(pMaps[i1].colormap == cmDefault)
5980 memcpy(&cmap, &(pMaps[i1]),
sizeof(XStandardColormap));
5988 cmap.visualid = None;
5994 memcpy(&cmapDefault, &cmap,
sizeof(cmap));
5997 memcpy(pMap, &cmap,
sizeof(cmap));
6008 bzero(&clrRed,
sizeof(clrRed));
6009 bzero(&clrGreen,
sizeof(clrGreen));
6010 bzero(&clrBlue,
sizeof(clrBlue));
6013 clrGreen.green = 65535;
6014 clrBlue.blue = 65535;
6015 XAllocColor(pDisplay, cmDefault, &clrRed);
6016 XAllocColor(pDisplay, cmDefault, &clrGreen);
6017 XAllocColor(pDisplay, cmDefault, &clrBlue);
6023 cmap.base_pixel = BlackPixel(pDisplay, DefaultScreen(pDisplay));
6026 if(clrRed.pixel >= clrGreen.pixel && clrRed.pixel >= clrBlue.pixel)
6028 if(clrGreen.pixel >= clrBlue.pixel)
6030 cmap.blue_max = clrBlue.pixel - cmap.base_pixel;
6033 cmap.green_mult = 1;
6034 while(cmap.green_mult < cmap.blue_max)
6036 cmap.green_mult <<= 1;
6039 lTemp = (clrGreen.pixel - cmap.base_pixel);
6040 cmap.green_max = lTemp / cmap.green_mult;
6042 cmap.red_mult = cmap.green_mult;
6044 while(cmap.red_mult < lTemp)
6046 cmap.red_mult <<= 1;
6049 cmap.red_max = (clrRed.pixel - cmap.base_pixel)
6054 cmap.green_max = clrGreen.pixel - cmap.base_pixel;
6055 cmap.green_mult = 1;
6059 while(cmap.blue_mult < cmap.green_max)
6061 cmap.blue_mult <<= 1;
6064 lTemp = (clrBlue.pixel - cmap.base_pixel);
6065 cmap.blue_max = lTemp / cmap.blue_mult;
6067 cmap.red_mult = cmap.blue_mult;
6069 while(cmap.red_mult < lTemp)
6071 cmap.red_mult <<= 1;
6074 cmap.red_max = (clrRed.pixel - cmap.base_pixel)
6078 else if(clrGreen.pixel >= clrRed.pixel && clrGreen.pixel >= clrBlue.pixel)
6080 if(clrRed.pixel >= clrBlue.pixel)
6082 cmap.blue_max = clrBlue.pixel - cmap.base_pixel;
6086 while(cmap.red_mult < cmap.blue_max)
6088 cmap.red_mult <<= 1;
6091 lTemp = (clrRed.pixel - cmap.base_pixel);
6092 cmap.red_max = lTemp / cmap.red_mult;
6094 cmap.green_mult = cmap.red_mult;
6096 while(cmap.green_mult < lTemp)
6098 cmap.green_mult <<= 1;
6101 cmap.green_max = (clrGreen.pixel - cmap.base_pixel)
6106 cmap.red_max = clrRed.pixel - cmap.base_pixel;
6111 while(cmap.blue_mult < cmap.green_max)
6113 cmap.blue_mult <<= 1;
6116 lTemp = (clrBlue.pixel - cmap.base_pixel);
6117 cmap.blue_max = lTemp / cmap.blue_mult;
6119 cmap.green_mult = cmap.blue_mult;
6121 while(cmap.green_mult < lTemp)
6123 cmap.green_mult <<= 1;
6126 cmap.green_max = (clrGreen.pixel - cmap.base_pixel)
6132 if(clrRed.pixel >= clrGreen.pixel)
6134 cmap.green_max = clrGreen.pixel - cmap.base_pixel;
6135 cmap.green_mult = 1;
6138 while(cmap.red_mult < cmap.green_max)
6140 cmap.red_mult <<= 1;
6143 lTemp = (clrRed.pixel - cmap.base_pixel);
6144 cmap.red_max = lTemp / cmap.red_mult;
6146 cmap.blue_mult = cmap.red_mult;
6148 while(cmap.blue_mult < lTemp)
6150 cmap.blue_mult <<= 1;
6153 cmap.blue_max = (clrBlue.pixel - cmap.base_pixel)
6158 cmap.red_max = clrRed.pixel - cmap.base_pixel;
6161 cmap.green_mult = 1;
6162 while(cmap.green_mult < cmap.red_max)
6164 cmap.green_mult <<= 1;
6167 lTemp = (clrGreen.pixel - cmap.base_pixel);
6168 cmap.green_max = lTemp / cmap.green_mult;
6171 cmap.blue_mult = cmap.green_mult;
6173 while(cmap.blue_mult < lTemp)
6175 cmap.blue_mult <<= 1;
6178 cmap.blue_max = (clrBlue.pixel - cmap.base_pixel)
6183 XFreeColors(pDisplay, cmDefault, &clrRed.pixel, 1, 0);
6184 XFreeColors(pDisplay, cmDefault, &clrGreen.pixel, 1, 0);
6185 XFreeColors(pDisplay, cmDefault, &clrBlue.pixel, 1, 0);
6194 memcpy(&cmapDefault, &cmap,
sizeof(cmap));
6197 memcpy(pMap, &cmap,
sizeof(cmap));
6205 if(pEntry && pEntry->
pFont)
6207 return pEntry->
pFont;
6217 if(pEntry && pEntry->
pFont)
6284 static void __InternalSetWindowCursor(Window wID,
int idCursor)
6287 Display *pDisplay = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
6288 Cursor curNew = idCursor != -1 ? XCreateFontCursor(pDisplay, idCursor) : None;
6291 if(curNew == None && idCursor != -1)
6293 WB_ERROR_PRINT(
"ERROR - %s - Cursor ID %d (%xH) returns 'None'\n", __FUNCTION__, idCursor, idCursor);
6299 XDefineCursor(pDisplay, wID, curNew);
6301 XUndefineCursor(pDisplay, wID);
6308 XFreeCursor(pDisplay, pEntry->
curRecent);
6321 bzero(&clrF,
sizeof(clrF));
6322 bzero(&clrB,
sizeof(clrB));
6323 clrB.pixel = WhitePixel(pDisplay, DefaultScreen(pDisplay));
6324 clrF.pixel = BlackPixel(pDisplay, DefaultScreen(pDisplay));
6325 XQueryColor(pDisplay, DefaultColormap(pDisplay, DefaultScreen(pDisplay)), &clrF);
6326 XQueryColor(pDisplay, DefaultColormap(pDisplay, DefaultScreen(pDisplay)), &clrB);
6328 XRecolorCursor(pDisplay, curNew, &clrB, &clrF);
6329 XRecolorCursor(pDisplay, curNew, &clrF, &clrB);
6361 Window wIDRoot = 0, wIDParent = 0;
6362 Window *pwIDChildren = NULL;
6363 unsigned int u1, nChildren = 0;
6373 if(XQueryTree(pEntry->
pDisplay, wID, &wIDRoot, &wIDParent, &pwIDChildren, &nChildren))
6377 for(u1=nChildren; u1; u1--)
6379 Window wKid = pwIDChildren[u1 - 1];
6388 XFree(pwIDChildren);
6402 Window wIDRoot = 0, wIDParent = 0;
6403 Window *pwIDChildren = NULL;
6404 unsigned int u1, nChildren = 0;
6413 __InternalSetWindowCursor(wID, pEntry->
idCursor);
6417 if(XQueryTree(pEntry->
pDisplay, wID, &wIDRoot, &wIDParent, &pwIDChildren, &nChildren))
6421 for(u1=nChildren; u1; u1--)
6423 Window wKid = pwIDChildren[u1 - 1];
6428 __InternalSetWindowCursor(wKid, pE->
idCursor);
6432 XFree(pwIDChildren);
6443 __InternalSetWindowCursor(wID, -1);
6456 __InternalSetWindowCursor(wID, idCursor);
6481 bzero(pGeom,
sizeof(*pGeom));
6483 Window wIDTemp = wID;
6500 "%s - geometry for window %d (%08xH) = %d,%d,%d,%d,%d\n",
6501 __FUNCTION__, (
int)wID, (
int)wID,
6507 "%s - geometry for parent window %d (%08xH) = %d,%d,%d,%d,%d\n",
6508 __FUNCTION__, (
int)wIDTemp, (
int)wIDTemp,
6517 memcpy(pGeom, &(pEntry->
geomAbsolute),
sizeof(*pGeom));
6525 Display *pDisp = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
6526 Window winRoot = None;
6527 unsigned int uiDepth = 0;
6535 bzero(pGeom,
sizeof(*pGeom));
6538 WB_UNLIKELY(WB_IS_WINDOW_DESTROYED(*pEntry) || WB_IS_WINDOW_BEING_DESTROYED(*pEntry)))
6541 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
6548 "%s:%d - pEntry is NULL, %d (%08xH) may NOT be mapped\n",
6549 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
6551 else if(!WB_IS_WINDOW_MAPPED(*pEntry) &&
6562 WB_ERROR_PRINT(
"TEMPORARY: %s - unmapped window geometry %d, %d, %d, %d\n",
6563 __FUNCTION__, pGeom->
x, pGeom->
y, pGeom->
width, pGeom->
height);
6574 XGetGeometry(pDisp, wID, &winRoot,
6575 &(pGeom->
x), &(pGeom->
y),
6577 &(pGeom->
border), &uiDepth);
6590 XWindowAttributes xwa;
6591 memset(&xwa, 0,
sizeof(xwa));
6592 if(XGetWindowAttributes(pDisp, winRoot, &xwa))
6595 "%s - window %08xH %d, %d, %d, %d\n",
6596 __FUNCTION__, winRoot, xwa.x, xwa.y, xwa.width, xwa.height);
6610 Display *pDisp = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
6611 Window winRoot = 0, wParent;
6612 unsigned int uiDepth = 0;
6615 bzero(pGeom,
sizeof(*pGeom));
6618 WB_UNLIKELY(WB_IS_WINDOW_DESTROYED(*pEntry) || WB_IS_WINDOW_BEING_DESTROYED(*pEntry)))
6621 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
6624 else if(!WB_IS_WINDOW_MAPPED(*pEntry) &&
6635 WB_ERROR_PRINT(
"TEMPORARY: %s - unmapped window geometry %d, %d, %d, %d\n",
6636 __FUNCTION__, pGeom->
x, pGeom->
y, pGeom->
width, pGeom->
height);
6647 XGetGeometry(pDisp, wID, &winRoot,
6648 &(pGeom->
x), &(pGeom->
y),
6650 &(pGeom->
border), &uiDepth);
6654 "%s - geometry for window %d (%08xH) = %d,%d,%d,%d,%d\n",
6655 __FUNCTION__, (
int)wID, (
int)wID,
6660 while(wParent > 0 && winRoot != wParent)
6665 WB_UNLIKELY(WB_IS_WINDOW_DESTROYED(*pParentEntry) || WB_IS_WINDOW_BEING_DESTROYED(*pParentEntry)))
6668 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
6672 bzero(&geom,
sizeof(geom));
6675 XGetGeometry(pDisp, wParent, &winRoot,
6682 "%s - geometry for parent window %d (%08xH) = %d,%d,%d,%d,%d\n",
6683 __FUNCTION__, (
int)wParent, (
int)wParent,
6702 pRect->
left = geom.
x;
6703 pRect->
top = geom.
y;
6727 void WBXlatCoordPoint(Window wIDSrc,
int iXSrc,
int iYSrc, Window wIDDest,
int *piXDest,
int *piYDest)
6731 if(wIDSrc == wIDDest)
6743 bzero(&gOrig,
sizeof(gOrig));
6748 bzero(&gXlat,
sizeof(gXlat));
6754 *piXDest = iXSrc + gOrig.
x 6758 *piYDest = iYSrc + gOrig.
y 6766 if(!pGeomSrc || !pGeomDest)
6769 if(wIDSrc == wIDDest)
6771 memcpy(pGeomDest, pGeomSrc,
sizeof(*pGeomDest));
6778 bzero(&gOrig,
sizeof(gOrig));
6783 bzero(&gXlat,
sizeof(gXlat));
6785 pGeomDest->
x = pGeomSrc->
x + gOrig.
x - gXlat.
x;
6786 pGeomDest->
y = pGeomSrc->
y + gOrig.
y - gXlat.
y;
6796 if(!pRectSrc || !pRectDest)
6799 if(wIDSrc == wIDDest)
6801 memcpy(pRectDest, pRectSrc,
sizeof(*pRectDest));
6805 geomSrc.
x = pRectSrc->
left;
6806 geomSrc.
y = pRectSrc->
top;
6813 pRectDest->
left = geomDest.
x;
6814 pRectDest->
right = geomDest.
y;
6823 if(wIDRef != wIDQuery)
6828 return(iX >= rctDest.
left && iX < rctDest.
right 6829 && iY >= rctDest.
top && iY < rctDest.
bottom);
6837 int cRval = 0, cbLen, cbLen0 = pcbLen ? *pcbLen : 1;
6838 int iACSMask = ShiftMask | ControlMask | Mod1Mask ;
6843 iACSMask &= ((XKeyEvent *)pEvent)->state;
6847 *piAltCtrlShift = 0;
6857 cbLen = XLookupString((XKeyEvent *)pEvent, pBuf, cbLen0, &ks, NULL);
6859 if((
int)ks == XK_Delete || (
int)ks == XK_KP_Delete)
6891 cbLen = XLookupString((XKeyEvent *)pEvent, (
char *)tbuf,
sizeof(tbuf) - 1, &ks, NULL);
6905 cRval = *((
unsigned char *)tbuf);
6909 cRval = *((
unsigned short *)tbuf);
6913 cRval = *((
unsigned int *)tbuf);
6917 cRval = *((
unsigned char *)tbuf);
6936 static Window __internal_GetParent(Display *pDisplay, Window wID, Window *pwRoot)
6938 Window wIDRoot = 0, wIDParent = 0;
6939 Window *pwIDChildren = NULL;
6940 unsigned int nChildren = 0;
6944 if(XQueryTree(pDisplay, wID, &wIDRoot, &wIDParent, &pwIDChildren, &nChildren))
6947 XFree(pwIDChildren);
6961 Display *pDisplay = pEntry ? pEntry->
pDisplay : pDefaultDisplay;
6962 Window wIDRoot = 0, wIDParent = 0;
6963 Window *pwIDChildren = NULL;
6964 unsigned int nChildren = 0;
6966 if(pEntry && pEntry->
wParent > 0)
6971 if(XQueryTree(pDisplay, wID, &wIDRoot, &wIDParent, &pwIDChildren, &nChildren))
6974 XFree(pwIDChildren);
6977 if(wIDParent > 0 && pEntry)
6996 Display *pDisplay = pDefaultDisplay;
7004 iRval = XReparentWindow(pDisplay, wID, wIDParent, iX, iY);
7006 if(iRval < 0 && pEntry)
7018 Display *pDisplay = pDefaultDisplay;
7019 Window wIDRoot = 0, wIDP = 0;
7020 Window *pwIDChildren = NULL;
7022 unsigned int i1, nChildren = 0;
7025 if(wIDParent == wIDChild)
7028 if(pEntry2 && pEntry2->
wParent > 0)
7030 return pEntry2->
wParent == wIDParent ? 1 : 0;
7043 if(WB_IS_WINDOW_DESTROYED(*pEntry) || WB_IS_WINDOW_UNMAPPED(*pEntry))
7058 if(XQueryTree(pDisplay, wIDParent, &wIDRoot, &wIDP, &pwIDChildren, &nChildren))
7060 for(i1=0; pwIDChildren && i1 < nChildren; i1++)
7062 if(pwIDChildren[i1] == wIDChild)
7070 for(i1=0; !iRval && pwIDChildren && i1 < nChildren; i1++)
7076 XFree(pwIDChildren);
7083 Display *pDisplay = pDefaultDisplay;
7084 Window wIDRoot = 0, wIDP = 0;
7085 Window *pwIDChildren = NULL;
7086 unsigned int i1, nChildren = 0;
7088 if(wIDParent == wIDChild)
7094 if(XQueryTree(pDisplay, wIDChild, &wIDRoot, &wIDP, &pwIDChildren, &nChildren))
7097 XFree(pwIDChildren);
7099 if(wIDRoot == wIDParent ||
7104 else if(!wIDP || wIDP == wIDRoot)
7134 WB_WARN_PRINT(
"%s - NULL pEntry wID = %d (%08xH)\n", __FUNCTION__, (
int)wID, (
int)wID);
7150 WB_WARN_PRINT(
"%s - NULL pEntry wID = %d (%08xH)\n", __FUNCTION__, (
int)wID, (
int)wID);
7164 WB_WARN_PRINT(
"%s - NULL pEntry wID = %d (%08xH)\n", __FUNCTION__, (
int)wID, (
int)wID);
7178 for(i1=0; i1 <= WINDOW_ENTRY_ARRAY_MAX; i1++)
7180 if(sWBHashEntries[i1].wIDMenu == wIDMenu)
7182 sWBHashEntries[i1].
wIDMenu = 0;
7189 pEntry = WBGetWindowEntry(wID);
7192 if(pEntry->
wIDMenu == wIDMenu)
7199 WB_WARN_PRINT(
"%s - NULL pEntry wID = %d (%08xH)\n", __FUNCTION__, (
int)wID, (
int)wID);
7223 XEmptyRegion(pEntry->
rgnClip))
7228 WB_ERROR_PRINT(
"ERROR: %s - clipping region is 'None'\n", __FUNCTION__);
7232 XClipBox(pEntry->
rgnClip, &xrct);
7234 if(xrct.width != 0 && xrct.height != 0)
7236 WB_ERROR_PRINT(
"ERROR: %s - clipping region is 'empty', but bounds = %d, %d, %d, %d\n", __FUNCTION__,
7237 xrct.x, xrct.y, xrct.width, xrct.height);
7246 XClipBox(pEntry->
rgnClip, &xrct);
7249 bzero(&evt,
sizeof(evt));
7255 evt.width = xrct.width;
7256 evt.height = xrct.height;
7259 "%s.%d creating/handling Expose event, %d,%d,%d,%d\n",
7260 __FUNCTION__, __LINE__, evt.x, evt.y, evt.width, evt.height);
7278 #define WB_IS_WINDOW_UNMAPPED(X) ((X).iWindowState == WB_WINDOW_UNMAPPED || (X).iWindowState == WB_WINDOW_SET_FOCUS_ON_MAP) 7279 #define WB_IS_WINDOW_MAPPED(X) ((X).iWindowState == WB_WINDOW_MAPPED) 7280 #define WB_IS_WINDOW_BEING_DESTROYED(X) ((X).iWindowState == WB_WINDOW_DESTROYING) 7281 #define WB_IS_WINDOW_DESTROYED(X) ((X).iWindowState == WB_WINDOW_DESTROYED || (X).iWindowState == WB_WINDOW_DELETE) 7288 WB_IS_WINDOW_MAPPED(*pEntry) &&
7292 XClipBox(pEntry->
rgnClip, &xrct);
7297 bzero(&evt,
sizeof(evt));
7303 evt.width = xrct.width;
7304 evt.height = xrct.height;
7307 "%s.%d creating/handling Expose event, %d,%d,%d,%d\n",
7308 __FUNCTION__, __LINE__, evt.x, evt.y, evt.width, evt.height);
7310 WBInternalProcessExposeEvent(&evt);
7313 if(__WBNextPaintEvent(pEntry->
pDisplay, &evt0, wID) >= 0)
7346 "%s.%d - NULL pGeom, %d,%d,%d,%d\n", __FUNCTION__, __LINE__,
7352 "%s.%d - %d,%d,%d,%d\n", __FUNCTION__, __LINE__,
7358 xrct.x = (short)pGeom->
x;
7359 xrct.y = (
short)pGeom->
y;
7360 xrct.width = (
unsigned short)pGeom->
width;
7361 xrct.height = (
unsigned short)pGeom->
height;
7365 pEntry->
rgnClip = XCreateRegion();
7373 "%s.%d - resulting invalid rect: %d,%d,%d,%d\n", __FUNCTION__, __LINE__,
7374 xrct.x, xrct.y, xrct.width, xrct.height);
7381 XClipBox(pEntry->
rgnClip, &xrct);
7384 WB_ERROR_PRINT(
"%s.%d - Bounding rectangle of new invalid region: %d, %d, %d, %d\n",
7385 __FUNCTION__, __LINE__, xrct.x, xrct.y, xrct.width, xrct.height);
7419 pEntry->
rgnClip = XCreateRegion();
7438 XClipBox(pEntry->
rgnClip, &xrct);
7442 WB_ERROR_PRINT(
"%s.%d - Bounding rectangle of new invalid region: %d, %d, %d, %d\n",
7443 __FUNCTION__, __LINE__, xrct.x, xrct.y, xrct.width, xrct.height);
7450 WB_ERROR_PRINT(
"%s.%d - unable to create clipping region\n", __FUNCTION__, __LINE__);
7462 pEntry = WBGetWindowEntry(wID);
7472 pEntry->
rgnClip = XCreateRegion();
7482 XDestroyRegion(pEntry->
rgnClip);
7486 pEntry->
rgnClip = XCreateRegion();
7491 xrct.x = (short)pGeom->
x;
7492 xrct.y = (
short)pGeom->
y;
7493 xrct.width = (
unsigned short)pGeom->
width;
7494 xrct.height = (
unsigned short)pGeom->
height;
7497 rgnTemp = XCreateRegion();
7506 XUnionRectWithRegion(&xrct, rgnTemp, rgnTemp);
7509 XDestroyRegion(rgnTemp);
7511 if(XEmptyRegion(pEntry->
rgnClip))
7524 pEntry = WBGetWindowEntry(wID);
7534 pEntry->
rgnClip = XCreateRegion();
7544 XDestroyRegion(pEntry->
rgnClip);
7548 pEntry->
rgnClip = XCreateRegion();
7555 if(XEmptyRegion(pEntry->
rgnClip))
7576 iRet = XEmptyRegion(pEntry->
rgnClip);
7585 Region rgnRval = XCreateRegion();
7594 XUnionRegion(pEntry->
rgnClip, rgnRval, rgnRval);
7615 Region rgnRval = XCreateRegion();
7624 XUnionRegion(pEntry->
rgnPaint, rgnRval, rgnRval);
7638 if((CARD32)(intptr_t)rgnSource & 0xe0000000)
7640 WB_ERROR_PRINT(
"ERROR: %s - invalid source region %d (%08xH), no region created\n",
7641 __FUNCTION__, (
int)(intptr_t)rgnSource, (
int)(intptr_t)rgnSource);
7647 rgnRval = XCreateRegion();
7652 WB_ERROR_PRINT(
"ERROR: %s - unable to create region\n", __FUNCTION__);
7657 XUnionRegion(rgnSource, rgnRval, rgnRval);
7675 rgnRval = XCreateRegion();
7684 xrct.x = (short)pRect->
left;
7685 xrct.y = (
short)pRect->
top;
7686 xrct.width = (
unsigned short)(pRect->
right - pRect->
left);
7687 xrct.height = (
unsigned short)(pRect->
bottom - pRect->
top);
7690 XUnionRectWithRegion(&xrct, rgnRval, rgnRval);
7708 rgnRval = XCreateRegion();
7717 xrct.x = (short)pGeom->
x;
7718 xrct.y = (
short)pGeom->
y;
7719 xrct.width = (
unsigned short)pGeom->
width;
7720 xrct.height = (
unsigned short)pGeom->
height;
7723 XUnionRectWithRegion(&xrct, rgnRval, rgnRval);
7740 if(!pEvent || pEvent->type != Expose || !pEntry)
7743 "%s.%d - returning None (bad parameter)\n", __FUNCTION__, __LINE__);
7747 geomTemp.
x = pEvent->x;
7748 geomTemp.
y = pEvent->y;
7749 geomTemp.
width = pEvent->width;
7750 geomTemp.
height = pEvent->height;
7753 iRet = XEmptyRegion(pEntry->
rgnClip);
7758 geomTemp.
x = geomTemp.
y = geomTemp.
width = geomTemp.
height = 0;
7762 "%s.%d - returning NULL (nothing to paint)\n", __FUNCTION__, __LINE__);
7768 if(gcRval && pgBounds)
7770 pgBounds->
x = geomTemp.
x;
7771 pgBounds->
y = geomTemp.
y;
7789 if(!pEntry || !pgBounds)
7791 WB_ERROR_PRINT(
"%s.%d - invalid parameters\n", __FUNCTION__, __LINE__);
7800 iRet = XEmptyRegion(pEntry->
rgnClip);
7809 "%s.%d - no clip region (returning NULL)\n", __FUNCTION__, __LINE__);
7814 "%s.%d - empty clip region - bounds = %d,%d,%d,%d (returning NULL)\n",
7815 __FUNCTION__, __LINE__, pgBounds->
x, pgBounds->
y, pgBounds->
width, pgBounds->
height);
7824 pEntry->
rgnClip = XCreateRegion();
7835 WB_ERROR_PRINT(
"%s - * BUG * at line %d - unable to copy GC for window %d (%08xH)\n",
7836 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
7846 WB_WARN_PRINT(
"%s - * BUG * at line %d - non-zero paint region for window %d (%08xH)\n",
7847 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
7859 rgnPaint = XCreateRegion();
7864 Region rgnTemp = XCreateRegion();
7869 XDestroyRegion(rgnPaint);
7877 WB_ERROR_PRINT(
"ERROR: %s - could not create clip region\n", __FUNCTION__);
7882 xrct.x = pgBounds->
x;
7883 xrct.y = pgBounds->
y;
7884 xrct.width = pgBounds->
width;
7885 xrct.height = pgBounds->
height;
7888 XUnionRectWithRegion(&xrct, rgnTemp, rgnTemp);
7889 XUnionRegion(pEntry->
rgnClip, rgnPaint, rgnPaint);
7890 XIntersectRegion(rgnTemp, rgnPaint, rgnPaint);
7895 XDestroyRegion(rgnTemp);
7910 iRet = XEmptyRegion(rgnPaint);
7916 XDestroyRegion(rgnPaint);
7922 "%s.%d - empty paint region - returning NULL gcRval for window %d (%08xH)\n",
7923 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
7945 XClipBox(rgnPaint, &xrct);
7948 pgBounds->
x = xrct.x;
7949 pgBounds->
y = xrct.y;
7950 pgBounds->
width = xrct.width;
7951 pgBounds->
height = xrct.height;
7956 "%s.%d - bounds=%d,%d,%d,%d\n",
7957 __FUNCTION__, __LINE__,
7958 xrct.x, xrct.y, xrct.width, xrct.height);
7964 "%s.%d - returning NULL gcRval for window %d (%08xH)\n",
7965 __FUNCTION__, __LINE__, (
int)wID, (
int)wID);
7973 unsigned long clrFG, clrBG;
7979 if(!pEntry || pEntry->
rgnPaint == None)
7981 WB_ERROR_PRINT(
"ERROR: %s - WBClearWindow with no paint region\n", __FUNCTION__);
8022 if(xrct.width > 0 && xrct.height > 0)
8027 WBFillRectangle(pDisplay, wID, gc, xrct.x, xrct.y, xrct.width, xrct.height);
8116 if(!pEntry || pEntry->
iWindowState == WB_WINDOW_DESTROYED)
8126 #ifdef USE_WINDOW_XIMAGE 8127 if(!disable_imagecache && !(pEntry->
pImage))
8129 Window winRoot = None;
8131 unsigned int iWidth0=0, iHeight0=0, iBorder;
8132 unsigned int uiDepth = 0;
8144 XGetGeometry(pDisplay, wID, &winRoot, &iX0, &iY0, &iWidth0, &iHeight0, &iBorder, &uiDepth);
8150 pEntry->
pImage =
WBXGetImage(pDisplay, wID, 0, 0, iWidth0, iHeight0, 0xffffffff, ZPixmap);
8160 #endif // USE_WINDOW_XIMAGE 8182 int xSrc,
int ySrc,
int width,
int height,
8183 int xOffs,
int yOffs)
8205 if(!pEntry || pEntry->
iWindowState == WB_WINDOW_DESTROYED)
8209 WB_WARN_PRINT(
"WARNING: %s - no 'window entry' for Window %d (%08xH)\n",
8210 __FUNCTION__, (
unsigned int)wID, (
unsigned int)wID);
8214 WB_DEBUG_PRINT(DebugLevel_Medium,
"WARNING: %s - NOT updating 'destroyed' Window %d (%08xH)\n",
8215 __FUNCTION__, (
unsigned int)wID, (
unsigned int)wID);
8225 if(pEntry->
hGC == None)
8227 WB_DEBUG_PRINT(DebugLevel_Light,
"WARNING: %s - no GC for Window %d (%08xH)\n",
8228 __FUNCTION__, (
unsigned int)wID, (
unsigned int)wID);
8234 WB_WARN_PRINT(
"WARNING: %s - no XImage for %d (%08xH) - this should never happen\n",
8235 __FUNCTION__, (
unsigned int)wID, (
unsigned int)wID);
8239 Window winRoot = None;
8241 unsigned int iWidth0=0, iHeight0=0, iBorder;
8242 unsigned int uiDepth = 0;
8255 XGetGeometry(pDisplay, wID, &winRoot, &iX0, &iY0, &iWidth0, &iHeight0, &iBorder, &uiDepth);
8262 iWidth0 = pEntry->
pImage->width;
8267 iHeight0 = pEntry->
pImage->height;
8286 static void __WBInitEvent()
8300 for(i1=1; i1 < EVENT_ARRAY_SIZE; i1++)
8302 axWBEvt[i1 - 1].
iNext = i1;
8305 axWBEvt[EVENT_ARRAY_SIZE - 1].
iNext = -1;
8306 iWBQueuedEvent = iWBQueueLast = -1;
8307 iWBPaintEvent = iWBPaintLast = -1;
8311 static int __WBAddEvent(Display *pDisp, Window wID, XEvent *pEvent)
8321 if(iWBFreeEvent < 0)
8326 if(pEvent->type == Expose)
8331 iEvent = iWBFreeEvent;
8332 iWBFreeEvent = axWBEvt[iWBFreeEvent].
iNext;
8333 axWBEvt[iEvent].
iNext = -1;
8337 if(iWBQueuedEvent < 0)
8339 iWBQueuedEvent = iEvent;
8340 iWBQueueLast = iEvent;
8344 if(iWBQueueLast < 0)
8347 iWBQueueLast = iWBQueuedEvent;
8348 while(axWBEvt[iWBQueueLast].iNext != -1)
8350 iWBQueueLast = axWBEvt[iWBQueueLast].
iNext;
8354 axWBEvt[iWBQueueLast].
iNext = iEvent;
8355 iWBQueueLast = iEvent;
8359 axWBEvt[iEvent].
wID = wID;
8360 memcpy(&(axWBEvt[iEvent].xEvt), pEvent,
sizeof(XEvent));
8365 static void __WBDelWindowPaintEvents(Display *pDisp, Window wID)
8367 int iEvent, iPrev, iTemp;
8370 if(iWBPaintEvent < 0)
8375 iEvent = iWBPaintEvent;
8380 if(axWBEvt[iEvent].wID == wID &&
8381 axWBEvt[iEvent].pDisplay == pDisp)
8385 iWBPaintEvent = axWBEvt[iEvent].
iNext;
8386 if(iWBPaintEvent < 0)
8393 axWBEvt[iPrev].
iNext = axWBEvt[iEvent].
iNext;
8394 if(axWBEvt[iPrev].iNext < 0)
8396 iWBPaintLast = iPrev;
8403 iEvent = axWBEvt[iTemp].
iNext;
8404 axWBEvt[iTemp].
iNext = iWBFreeEvent;
8405 iWBFreeEvent = iTemp;
8410 iEvent = axWBEvt[iEvent].
iNext;
8417 while(XCheckWindowEvent(pDisp, wID, ExposureMask, &event))
8421 static void __WBDelWindowEvents(Display *pDisp, Window wID)
8423 int iEvent, iPrev, iTemp;
8433 iEvent = iWBQueuedEvent;
8437 if(axWBEvt[iEvent].wID == wID &&
8438 axWBEvt[iEvent].pDisplay == pDisp)
8442 iWBQueuedEvent = axWBEvt[iEvent].
iNext;
8443 if(iWBQueuedEvent < 0)
8450 axWBEvt[iPrev].
iNext = axWBEvt[iEvent].
iNext;
8451 if(axWBEvt[iPrev].iNext < 0)
8453 iWBQueueLast = iPrev;
8460 iEvent = axWBEvt[iTemp].
iNext;
8461 axWBEvt[iTemp].
iNext = iWBFreeEvent;
8462 iWBFreeEvent = iTemp;
8467 iEvent = axWBEvt[iEvent].
iNext;
8473 iEvent = iWBPaintEvent;
8477 if(axWBEvt[iEvent].wID == wID &&
8478 axWBEvt[iEvent].pDisplay == pDisp)
8482 iWBPaintEvent = axWBEvt[iEvent].
iNext;
8483 if(iWBPaintEvent < 0)
8490 axWBEvt[iPrev].
iNext = axWBEvt[iEvent].
iNext;
8491 if(axWBEvt[iPrev].iNext < 0)
8493 iWBPaintLast = iPrev;
8500 iEvent = axWBEvt[iTemp].
iNext;
8501 axWBEvt[iTemp].
iNext = iWBFreeEvent;
8502 iWBFreeEvent = iTemp;
8507 iEvent = axWBEvt[iEvent].
iNext;
8526 static int __WBInsertPriorityEvent(Display *pDisp, Window wID, XEvent *pEvent)
8536 if(iWBFreeEvent < 0)
8545 iEvent = iWBFreeEvent;
8546 iWBFreeEvent = axWBEvt[iEvent].
iNext;
8547 axWBEvt[iEvent].
iNext = -1;
8551 if(iWBQueuedEvent < 0)
8553 iWBQueuedEvent = iEvent;
8554 iWBQueueLast = iEvent;
8558 int iTempEvent = iWBQueuedEvent;
8561 iWBQueuedEvent = iEvent;
8562 axWBEvt[iWBQueuedEvent].
iNext = iTempEvent;
8566 axWBEvt[iEvent].
wID = wID;
8567 memcpy(&(axWBEvt[iEvent].xEvt), pEvent,
sizeof(XEvent));
8572 static int __WBNextPaintEvent(Display *pDisp, XEvent *pEvent, Window wID)
8574 int iRval = iWBPaintEvent, iPrev = -1;
8578 if(
WB_LIKELY(axWBEvt[iRval].pDisplay == pDisp) &&
8579 (
WB_LIKELY(wID == None) || axWBEvt[iRval].xEvt.xany.window == wID))
8585 iRval = axWBEvt[iRval].
iNext;
8590 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_Window | DebugSubSystem_Event,
8591 "%s - getting an EXPOSE event for %d (%08xH)\n",
8593 (
int)axWBEvt[iRval].xEvt.xany.window,
8594 (
int)axWBEvt[iRval].xEvt.xany.window);
8596 if(iRval == iWBPaintEvent)
8598 iWBPaintEvent = axWBEvt[iRval].
iNext;
8602 if(iRval == iWBPaintLast)
8604 iWBPaintLast = iPrev;
8605 axWBEvt[iPrev].
iNext = -1;
8613 if(iWBPaintEvent < 0)
8620 memcpy(pEvent, &(axWBEvt[iRval].xEvt),
sizeof(XEvent));
8623 axWBEvt[iRval].
iNext = iWBFreeEvent;
8624 iWBFreeEvent = iRval;
8631 static int __WBNextDisplayEvent(Display *pDisp, XEvent *pEvent)
8633 int iRval = iWBQueuedEvent, iPrev = -1;
8637 if(
WB_LIKELY(axWBEvt[iRval].pDisplay == pDisp))
8643 iRval = axWBEvt[iRval].
iNext;
8650 iWBQueuedEvent = axWBEvt[iRval].
iNext;
8652 if(iWBQueuedEvent < 0)
8659 if(iRval == iWBQueueLast)
8661 iWBQueueLast = iPrev;
8662 axWBEvt[iPrev].
iNext = -1;
8670 WB_DEBUG_PRINT(DebugLevel_Excessive | DebugSubSystem_Window | DebugSubSystem_Event,
8671 "%s - getting %s event for %d (%08xH)\n",
8674 (
int)axWBEvt[iRval].xEvt.xany.window,
8675 (
int)axWBEvt[iRval].xEvt.xany.window);
8679 memcpy(pEvent, &(axWBEvt[iRval].xEvt),
sizeof(XEvent));
8682 axWBEvt[iRval].
iNext = iWBFreeEvent;
8683 iWBFreeEvent = iRval;
8691 iRval = __WBNextPaintEvent(pDisp, pEvent, None);
8697 static void WBInternalProcessExposeEvent(XExposeEvent *pEvent)
8718 wID = pEvent->window;
8719 pDisp = pEvent->display;
8723 for(iEvent=iWBPaintEvent; iEvent >= 0; iEvent = axWBEvt[iEvent].
iNext)
8725 if(axWBEvt[iEvent].wID == wID && axWBEvt[iEvent].pDisplay == pDisp)
8735 if(axWBEvt[iEvent].xEvt.xexpose.x > pEvent->x)
8737 axWBEvt[iEvent].
xEvt.xexpose.x = pEvent->x;
8740 if(axWBEvt[iEvent].xEvt.xexpose.y > pEvent->y)
8742 axWBEvt[iEvent].
xEvt.xexpose.y = pEvent->y;
8745 if(axWBEvt[iEvent].xEvt.xexpose.x + axWBEvt[iEvent].xEvt.xexpose.width < pEvent->x + pEvent->width)
8747 axWBEvt[iEvent].
xEvt.xexpose.width = pEvent->x + pEvent->width - axWBEvt[iEvent].
xEvt.xexpose.x;
8750 if(axWBEvt[iEvent].xEvt.xexpose.y + axWBEvt[iEvent].xEvt.xexpose.height < pEvent->y + pEvent->height)
8752 axWBEvt[iEvent].
xEvt.xexpose.height = pEvent->y + pEvent->height - axWBEvt[iEvent].
xEvt.xexpose.y;
8760 if(iWBFreeEvent < 0)
8762 WB_ERROR_PRINT(
"ERROR: %s - no more free 'event queue' entries\n", __FUNCTION__);
8767 iEvent = iWBFreeEvent;
8768 iWBFreeEvent = axWBEvt[iWBFreeEvent].
iNext;
8770 axWBEvt[iEvent].
iNext = -1;
8774 if(iWBPaintEvent < 0)
8776 iWBPaintEvent = iEvent;
8777 iWBPaintLast = iEvent;
8781 if(iWBPaintLast < 0)
8784 iWBPaintLast = iWBPaintEvent;
8785 while(axWBEvt[iWBPaintLast].iNext != -1)
8787 iWBPaintLast = axWBEvt[iWBPaintLast].
iNext;
8791 axWBEvt[iWBPaintLast].
iNext = iEvent;
8792 iWBPaintLast = iEvent;
8796 axWBEvt[iEvent].
wID = wID;
8797 memcpy(&(axWBEvt[iEvent].xEvt), pEvent,
sizeof(XEvent));
8799 axWBEvt[iEvent].
xEvt.xexpose.count = 0;
8807 geom.
width = pEvent->width;
8808 geom.
height = pEvent->height;
8821 if(pEntry && WB_IS_WINDOW_UNMAPPED(*pEntry))
8823 if(WB_CHECK_SET_FOCUS_ON_MAP(*pEntry))
8841 return __WBNextDisplayEvent(pDisplay, pEvent);
8854 return __WBAddEvent(pEntry->
pDisplay, wID, pEvent);
8859 __CreateDelayedEvent(pEvent, nDelay);
8875 return __WBInsertPriorityEvent(pEntry->
pDisplay, wID, pEvent);
8880 Display *pDisp = pDefaultDisplay;
8883 if(pEvent->xany.display)
8885 pDisp = pEvent->xany.display;
8888 return __WBAddEvent(pDisp, 0, pEvent);
8893 XClientMessageEvent evtClient;
8905 pDisplay = pDefaultDisplay;
8909 memset(&evtClient, 0,
sizeof(evtClient));
8911 evtClient.type = ClientMessage;
8912 evtClient.display = pDisplay;
8913 evtClient.window = None;
8915 evtClient.format = 32;
8916 evtClient.data.l[0] = wID;
8917 evtClient.data.l[1] = wIDFrom;
8931 #define EVENT_NAME_ENTRY(X) { X, #X } 8939 EVENT_NAME_ENTRY(KeyPress),
8940 EVENT_NAME_ENTRY(KeyRelease),
8941 EVENT_NAME_ENTRY(ButtonPress),
8942 EVENT_NAME_ENTRY(ButtonRelease),
8943 EVENT_NAME_ENTRY(MotionNotify),
8944 EVENT_NAME_ENTRY(EnterNotify),
8945 EVENT_NAME_ENTRY(LeaveNotify),
8946 EVENT_NAME_ENTRY(FocusIn),
8947 EVENT_NAME_ENTRY(FocusOut),
8948 EVENT_NAME_ENTRY(KeymapNotify),
8949 EVENT_NAME_ENTRY(Expose),
8950 EVENT_NAME_ENTRY(GraphicsExpose),
8951 EVENT_NAME_ENTRY(NoExpose),
8952 EVENT_NAME_ENTRY(VisibilityNotify),
8953 EVENT_NAME_ENTRY(CreateNotify),
8954 EVENT_NAME_ENTRY(DestroyNotify),
8955 EVENT_NAME_ENTRY(UnmapNotify),
8956 EVENT_NAME_ENTRY(MapNotify),
8957 EVENT_NAME_ENTRY(MapRequest),
8958 EVENT_NAME_ENTRY(ReparentNotify),
8959 EVENT_NAME_ENTRY(ConfigureNotify),
8960 EVENT_NAME_ENTRY(ConfigureRequest),
8961 EVENT_NAME_ENTRY(GravityNotify),
8962 EVENT_NAME_ENTRY(ResizeRequest),
8963 EVENT_NAME_ENTRY(CirculateNotify),
8964 EVENT_NAME_ENTRY(CirculateRequest),
8965 EVENT_NAME_ENTRY(PropertyNotify),
8966 EVENT_NAME_ENTRY(SelectionClear),
8967 EVENT_NAME_ENTRY(SelectionRequest),
8968 EVENT_NAME_ENTRY(SelectionNotify),
8969 EVENT_NAME_ENTRY(ColormapNotify),
8970 EVENT_NAME_ENTRY(ClientMessage),
8971 EVENT_NAME_ENTRY(MappingNotify),
8972 EVENT_NAME_ENTRY(LASTEvent),
8979 static char aTemp[32];
8981 for(i1=0; aIDName[i1].iID; i1++)
8983 if(aIDName[i1].iID == iEventID)
8985 return aIDName[i1].szName;
8989 sprintf(aTemp,
"[Event %d]", iEventID);
8993 #include <X11/Xproto.h> 8995 #define X_PROTO_ENTRY(X) { X, #X }, 9000 const char *szProto;
9003 X_PROTO_ENTRY(X_CreateWindow)
9004 X_PROTO_ENTRY(X_ChangeWindowAttributes)
9005 X_PROTO_ENTRY(X_GetWindowAttributes)
9006 X_PROTO_ENTRY(X_DestroyWindow)
9007 X_PROTO_ENTRY(X_DestroySubwindows)
9008 X_PROTO_ENTRY(X_ChangeSaveSet)
9009 X_PROTO_ENTRY(X_ReparentWindow)
9010 X_PROTO_ENTRY(X_MapWindow)
9011 X_PROTO_ENTRY(X_MapSubwindows)
9012 X_PROTO_ENTRY(X_UnmapWindow)
9013 X_PROTO_ENTRY(X_UnmapSubwindows)
9014 X_PROTO_ENTRY(X_ConfigureWindow)
9015 X_PROTO_ENTRY(X_CirculateWindow)
9016 X_PROTO_ENTRY(X_GetGeometry)
9017 X_PROTO_ENTRY(X_QueryTree)
9018 X_PROTO_ENTRY(X_InternAtom)
9019 X_PROTO_ENTRY(X_GetAtomName)
9020 X_PROTO_ENTRY(X_ChangeProperty)
9021 X_PROTO_ENTRY(X_DeleteProperty)
9022 X_PROTO_ENTRY(X_GetProperty)
9023 X_PROTO_ENTRY(X_ListProperties)
9024 X_PROTO_ENTRY(X_SetSelectionOwner)
9025 X_PROTO_ENTRY(X_GetSelectionOwner)
9026 X_PROTO_ENTRY(X_ConvertSelection)
9027 X_PROTO_ENTRY(X_SendEvent)
9028 X_PROTO_ENTRY(X_GrabPointer)
9029 X_PROTO_ENTRY(X_UngrabPointer)
9030 X_PROTO_ENTRY(X_GrabButton)
9031 X_PROTO_ENTRY(X_UngrabButton)
9032 X_PROTO_ENTRY(X_ChangeActivePointerGrab)
9033 X_PROTO_ENTRY(X_GrabKeyboard)
9034 X_PROTO_ENTRY(X_UngrabKeyboard)
9035 X_PROTO_ENTRY(X_GrabKey)
9036 X_PROTO_ENTRY(X_UngrabKey)
9037 X_PROTO_ENTRY(X_AllowEvents)
9038 X_PROTO_ENTRY(X_GrabServer)
9039 X_PROTO_ENTRY(X_UngrabServer)
9040 X_PROTO_ENTRY(X_QueryPointer)
9041 X_PROTO_ENTRY(X_GetMotionEvents)
9042 X_PROTO_ENTRY(X_TranslateCoords)
9043 X_PROTO_ENTRY(X_WarpPointer)
9044 X_PROTO_ENTRY(X_SetInputFocus)
9045 X_PROTO_ENTRY(X_GetInputFocus)
9046 X_PROTO_ENTRY(X_QueryKeymap)
9047 X_PROTO_ENTRY(X_OpenFont)
9048 X_PROTO_ENTRY(X_CloseFont)
9049 X_PROTO_ENTRY(X_QueryFont)
9050 X_PROTO_ENTRY(X_QueryTextExtents)
9051 X_PROTO_ENTRY(X_ListFonts)
9052 X_PROTO_ENTRY(X_ListFontsWithInfo)
9053 X_PROTO_ENTRY(X_SetFontPath)
9054 X_PROTO_ENTRY(X_GetFontPath)
9055 X_PROTO_ENTRY(X_CreatePixmap)
9056 X_PROTO_ENTRY(X_FreePixmap)
9057 X_PROTO_ENTRY(X_CreateGC)
9058 X_PROTO_ENTRY(X_ChangeGC)
9059 X_PROTO_ENTRY(X_CopyGC)
9060 X_PROTO_ENTRY(X_SetDashes)
9061 X_PROTO_ENTRY(X_SetClipRectangles)
9062 X_PROTO_ENTRY(X_FreeGC)
9063 X_PROTO_ENTRY(X_ClearArea)
9064 X_PROTO_ENTRY(X_CopyArea)
9065 X_PROTO_ENTRY(X_CopyPlane)
9066 X_PROTO_ENTRY(X_PolyPoint)
9067 X_PROTO_ENTRY(X_PolyLine)
9068 X_PROTO_ENTRY(X_PolySegment)
9069 X_PROTO_ENTRY(X_PolyRectangle)
9070 X_PROTO_ENTRY(X_PolyArc)
9071 X_PROTO_ENTRY(X_FillPoly)
9072 X_PROTO_ENTRY(X_PolyFillRectangle)
9073 X_PROTO_ENTRY(X_PolyFillArc)
9074 X_PROTO_ENTRY(X_PutImage)
9075 X_PROTO_ENTRY(X_GetImage)
9076 X_PROTO_ENTRY(X_PolyText8)
9077 X_PROTO_ENTRY(X_PolyText16)
9078 X_PROTO_ENTRY(X_ImageText8)
9079 X_PROTO_ENTRY(X_ImageText16)
9080 X_PROTO_ENTRY(X_CreateColormap)
9081 X_PROTO_ENTRY(X_FreeColormap)
9082 X_PROTO_ENTRY(X_CopyColormapAndFree)
9083 X_PROTO_ENTRY(X_InstallColormap)
9084 X_PROTO_ENTRY(X_UninstallColormap)
9085 X_PROTO_ENTRY(X_ListInstalledColormaps)
9086 X_PROTO_ENTRY(X_AllocColor)
9087 X_PROTO_ENTRY(X_AllocNamedColor)
9088 X_PROTO_ENTRY(X_AllocColorCells)
9089 X_PROTO_ENTRY(X_AllocColorPlanes)
9090 X_PROTO_ENTRY(X_FreeColors)
9091 X_PROTO_ENTRY(X_StoreColors)
9092 X_PROTO_ENTRY(X_StoreNamedColor)
9093 X_PROTO_ENTRY(X_QueryColors)
9094 X_PROTO_ENTRY(X_LookupColor)
9095 X_PROTO_ENTRY(X_CreateCursor)
9096 X_PROTO_ENTRY(X_CreateGlyphCursor)
9097 X_PROTO_ENTRY(X_FreeCursor)
9098 X_PROTO_ENTRY(X_RecolorCursor)
9099 X_PROTO_ENTRY(X_QueryBestSize)
9100 X_PROTO_ENTRY(X_QueryExtension)
9101 X_PROTO_ENTRY(X_ListExtensions)
9102 X_PROTO_ENTRY(X_ChangeKeyboardMapping)
9103 X_PROTO_ENTRY(X_GetKeyboardMapping)
9104 X_PROTO_ENTRY(X_ChangeKeyboardControl)
9105 X_PROTO_ENTRY(X_GetKeyboardControl)
9106 X_PROTO_ENTRY(X_Bell)
9107 X_PROTO_ENTRY(X_ChangePointerControl)
9108 X_PROTO_ENTRY(X_GetPointerControl)
9109 X_PROTO_ENTRY(X_SetScreenSaver)
9110 X_PROTO_ENTRY(X_GetScreenSaver)
9111 X_PROTO_ENTRY(X_ChangeHosts)
9112 X_PROTO_ENTRY(X_ListHosts)
9113 X_PROTO_ENTRY(X_SetAccessControl)
9114 X_PROTO_ENTRY(X_SetCloseDownMode)
9115 X_PROTO_ENTRY(X_KillClient)
9116 X_PROTO_ENTRY(X_RotateProperties)
9117 X_PROTO_ENTRY(X_ForceScreenSaver)
9118 X_PROTO_ENTRY(X_SetPointerMapping)
9119 X_PROTO_ENTRY(X_GetPointerMapping)
9120 X_PROTO_ENTRY(X_SetModifierMapping)
9121 X_PROTO_ENTRY(X_GetModifierMapping)
9122 X_PROTO_ENTRY(X_NoOperation)
9127 static const char * __internal_event_type_string(
int iEventType)
9134 return "KeyRelease";
9136 return "ButtonPress";
9138 return "ButtonRelease";
9140 return "MotionNotify";
9142 return "EnterNotify";
9144 return "LeaveNotify";
9150 return "KeymapNotify";
9153 case GraphicsExpose:
9154 return "GraphicsExpose";
9157 case VisibilityNotify:
9158 return "VisibilityNotify";
9160 return "CreateNotify";
9162 return "DestroyNotify";
9164 return "UnmapNotify";
9168 return "MapRequest";
9169 case ReparentNotify:
9170 return "ReparentNotify";
9171 case ConfigureNotify:
9172 return "ConfigureNotify";
9173 case ConfigureRequest:
9174 return "ConfigureRequest";
9176 return "GravityNotify";
9178 return "ResizeRequest";
9179 case CirculateNotify:
9180 return "CirculateNotify";
9181 case CirculateRequest:
9182 return "CirculateRequest";
9183 case PropertyNotify:
9184 return "PropertyNotify";
9185 case SelectionClear:
9186 return "SelectionClear";
9187 case SelectionRequest:
9188 return "SelectionRequest";
9189 case SelectionNotify:
9190 return "SelectionNotify";
9191 case ColormapNotify:
9192 return "ColormapNotify";
9194 return "ClientMessage";
9196 return "MappingNotify";
9199 return "GenericEvent";
9200 #endif // GenericEvent 9202 return "*Unknown Event";
9216 bzero(&xgcv,
sizeof(xgcv));
9217 memcpy(&xgcv, &(hGC->
values),
sizeof(xgcv));
9220 GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCCapStyle
9221 | GCJoinStyle | GCFillStyle | GCFillRule | GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin
9222 | GCFont | GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin
9223 | GCDashOffset | GCArcMode,
9226 WBDebugPrint(
"WBGC DUMP - GC = %ld (%08lxH)\n", (
long)(hGC->
gc), (
long)(hGC->
gc));
9227 WBDebugPrint(
"function = %d (%08xH)\n", xgcv.function, xgcv.function);
9228 WBDebugPrint(
"plane_mask = %ld (%016lxH)\n", xgcv.plane_mask, xgcv.plane_mask);
9229 WBDebugPrint(
"foreground = %ld (%016lxH)\n", xgcv.foreground, xgcv.foreground);
9230 WBDebugPrint(
"background = %ld (%016lxH)\n", xgcv.background, xgcv.background);
9231 WBDebugPrint(
"line_width = %d (%08xH)\n", xgcv.line_width, xgcv.line_width);
9232 WBDebugPrint(
"line_style = %d (%08xH)\n", xgcv.line_style, xgcv.line_style);
9233 WBDebugPrint(
"cap_style = %d (%08xH)\n", xgcv.cap_style, xgcv.cap_style);
9234 WBDebugPrint(
"join_style = %d (%08xH)\n", xgcv.join_style, xgcv.join_style);
9235 WBDebugPrint(
"fill_style = %d (%08xH)\n", xgcv.fill_style, xgcv.fill_style);
9236 WBDebugPrint(
"fill_rule = %d (%08xH)\n", xgcv.fill_rule, xgcv.fill_rule);
9237 WBDebugPrint(
"arc_mode = %d (%08xH)\n", xgcv.arc_mode, xgcv.arc_mode);
9238 WBDebugPrint(
"tile = %d (%08xH)\n", (
int)xgcv.tile, (
int)xgcv.tile);
9239 WBDebugPrint(
"stipple = %d (%08xH)\n", (
int)xgcv.stipple, (
int)xgcv.stipple);
9240 WBDebugPrint(
"ts_x_origin = %d (%08xH)\n", xgcv.ts_x_origin, xgcv.ts_x_origin);
9241 WBDebugPrint(
"ts_y_origin = %d (%08xH)\n", xgcv.ts_y_origin, xgcv.ts_y_origin);
9242 WBDebugPrint(
"font = %d (%08xH)\n", (
int)xgcv.font, (
int)xgcv.font);
9243 WBDebugPrint(
"subwindow_mode = %d (%08xH)\n", xgcv.subwindow_mode, xgcv.subwindow_mode);
9244 WBDebugPrint(
"graphics_exposures = %d (%08xH)\n", xgcv.graphics_exposures, xgcv.graphics_exposures);
9245 WBDebugPrint(
"clip_x_origin = %d (%08xH)\n", xgcv.clip_x_origin, xgcv.clip_x_origin);
9246 WBDebugPrint(
"clip_y_origin = %d (%08xH)\n", xgcv.clip_y_origin, xgcv.clip_y_origin);
9248 WBDebugPrint(
"dash_offset = %d (%08xH)\n", xgcv.dash_offset, xgcv.dash_offset);
9257 WBDebugPrint(
"EVENT %s\n", __internal_event_type_string(pEvent->xany.type));
9259 WBDebugPrint(
" send_event: %c\n", pEvent->xany.send_event ?
'T' :
'F');
9261 WBDebugPrint(
" Window: %08xH\n", (
unsigned int)pEvent->xany.window);
9263 switch(pEvent->xany.type)
9266 p1 =
WBGetAtomName(pEvent->xany.display, pEvent->xclient.message_type);
9271 WBDebugPrint(
" data[0].l: %ld (%08lxH)\n", pEvent->xclient.data.l[0], pEvent->xclient.data.l[0]);
9272 WBDebugPrint(
" data[1].l: %ld (%08lxH)\n", pEvent->xclient.data.l[1], pEvent->xclient.data.l[1]);
9273 WBDebugPrint(
" data[2].l: %ld (%08lxH)\n", pEvent->xclient.data.l[2], pEvent->xclient.data.l[2]);
9274 WBDebugPrint(
" data[3].l: %ld (%08lxH)\n", pEvent->xclient.data.l[3], pEvent->xclient.data.l[3]);
9275 WBDebugPrint(
" data[4].l: %ld (%08lxH)\n", pEvent->xclient.data.l[4], pEvent->xclient.data.l[4]);
9277 WBDebugDump(
"** client event data dump **", &(pEvent->xclient.data),
sizeof(pEvent->xclient.data));
9281 case SelectionNotify:
9282 p1 = XGetAtomName(pEvent->xany.display, pEvent->xselection.selection);
9286 p1 = XGetAtomName(pEvent->xany.display, pEvent->xselection.target);
9290 p1 = XGetAtomName(pEvent->xany.display, pEvent->xselection.property);
9294 WBDebugPrint(
" time: %ld\n", (
unsigned long)pEvent->xselection.time);
9298 case SelectionRequest:
9299 WBDebugPrint(
" Requestor: %08xH\n", (
unsigned int)pEvent->xselectionrequest.requestor);
9301 p1 = XGetAtomName(pEvent->xany.display, pEvent->xselectionrequest.selection);
9305 p1 = XGetAtomName(pEvent->xany.display, pEvent->xselectionrequest.target);
9309 p1 = XGetAtomName(pEvent->xany.display, pEvent->xselectionrequest.property);
9313 WBDebugPrint(
" time: %ld\n", (
unsigned long)pEvent->xselectionrequest.time);
9327 XClipBox(hRgn, &xrct);
9329 WBDebugPrint(
"REGION %u (%08xH): clip rect: %d, %d, %d, %d bRotate=%d\n",
9332 xrct.x, xrct.y, xrct.width + xrct.x, xrct.height + xrct.y,
9335 if(xrct.width == 0 || xrct.height == 0)
9348 xrct.width = xrct.height;
9353 for(iW=xrct.x; iW < xrct.x + xrct.width; iW++)
9360 for(iW=xrct.x; iW < xrct.x + xrct.width; iW++)
9367 for(iW=xrct.x; iW < xrct.x + xrct.width; iW++)
9374 for(iW=xrct.x; iW < xrct.x + xrct.width; iW++)
9382 for(iH=xrct.y; iH < xrct.y + xrct.height; iH++)
9385 for(iW=xrct.x; iW < xrct.x + xrct.width; iW++)
9387 if((!bRotate && XPointInRegion(hRgn, iW, iH)) ||
9388 (bRotate && XPointInRegion(hRgn, iH, iW)))
9402 for(iW=xrct.x; iW < xrct.x + xrct.width; iW++)
9418 static int WBXErrorHandler(Display *pDisplay, XErrorEvent *pError)
9433 xErrorInfo.
serial = pError->serial;
9447 WB_ERROR_PRINT(
"%s",
"************************************************************************\n");
9451 WB_ERROR_PRINT(
"window_helper.c:%d %s\n display %pH serial %08lxH\n",
9452 __LINE__, __FUNCTION__, pDisplay, pError->serial);
9462 XGetErrorText(pDisplay, pError->error_code, tbuf,
sizeof(tbuf));
9463 WB_ERROR_PRINT(
" Error Code: %d %s\n", pError->error_code, tbuf);
9465 for(i1=0; aXProto[i1].szProto; i1++)
9467 if(aXProto[i1].iProto == pError->request_code)
9474 if(!aXProto[i1].szProto)
9476 WB_ERROR_PRINT(
" Request Code: UNKNOWN (%d, %08xH)\n", pError->request_code, pError->request_code);
9479 WB_ERROR_PRINT(
" Minor Request Code: %d (%08xH)\n", pError->minor_code, pError->minor_code);
9481 if(pError->error_code == BadWindow ||
9482 ((pError->error_code == BadMatch || pError->error_code == BadDrawable) &&
9483 (pError->request_code == X_SetInputFocus ||
9484 pError->request_code == X_GetGeometry)))
9486 pEntry = WBGetWindowEntry((Window)pError->resourceid);
9496 case WB_WINDOW_DELETE:
9497 pState =
"WB_WINDOW_DELETE";
9499 case WB_WINDOW_DESTROYED:
9500 pState =
"WB_WINDOW_DESTROYED";
9502 case WB_WINDOW_UNMAPPED:
9503 pState =
"WB_WINDOW_UNMAPPED";
9505 case WB_WINDOW_MAPPED:
9506 pState =
"WB_WINDOW_MAPPED";
9508 case WB_WINDOW_SET_FOCUS_ON_MAP:
9509 pState =
"WB_WINDOW_SET_FOCUS_ON_MAP";
9512 pState =
"UNKNOWN STATE";
9516 (
int)pError->resourceid, (
int)pError->resourceid,
9526 while(pEntry && pEntry->
wParent != None)
9529 pEntry = WBGetWindowEntry(wID);
9534 (
int)wID, (
int)wID);
9542 case WB_WINDOW_DELETE:
9543 pState =
"WB_WINDOW_DELETE";
9545 case WB_WINDOW_DESTROYED:
9546 pState =
"WB_WINDOW_DESTROYED";
9548 case WB_WINDOW_UNMAPPED:
9549 pState =
"WB_WINDOW_UNMAPPED";
9551 case WB_WINDOW_MAPPED:
9552 pState =
"WB_WINDOW_MAPPED";
9554 case WB_WINDOW_SET_FOCUS_ON_MAP:
9555 pState =
"WB_WINDOW_SET_FOCUS_ON_MAP";
9558 pState =
"UNKNOWN STATE";
9576 WB_ERROR_PRINT(
" X Resource ID: %d (%08xH) (no window entry)\n", (
int)pError->resourceid, (
int)pError->resourceid);
9581 WB_ERROR_PRINT(
" X Resource ID: %d (%08xH)\n", (
int)pError->resourceid, (
int)pError->resourceid);
9584 WB_ERROR_PRINT(
"%s",
"************************************************************************\n");
9591 memset(&xErrorInfo, 0,
sizeof(xErrorInfo));
9596 return xErrorInfo.
pDisplay != NULL;
9620 #if !defined(__DOXYGEN__) && !defined(__GNUC__) && !defined(_MSVC_VER) 9624 return pDefaultDisplay;
9637 geom.
x = pRCT->
left;
9656 geom.
x = pRCT->
left;
9667 extern int bIgnoreXErrors;
9675 extern int bIgnoreXErrors;
9678 if(bIgnoreXErrors > 0)
9688 #endif // !defined(__DOXYGEN__) && !defined(__GNUC__) && !defined(_MSVC_VER)
int WBPointInWindow(Window wIDRef, int iX, int iY, Window wIDQuery)
Returna a non-zero value if X,Y coordinates relative to the reference window are within the query win...
Core (internal) structure for storing and dispatching events.
void WBSetWMProperties(Window wID, const char *szTitle, XSizeHints *pNormalHints, XWMHints *pWMHints, XClassHint *pClassHints)
assign standard WM (Window Manager) properties via XSetWMProperties
void WBPlatformOnExit(void)
Resource 'free-up' on exit (must call)
int border
cached border value from latest 'Expose' event (TODO: ConfigureNotify?)
Atom aPRIMARY
PRIMARY Atom for the clipboard - uses XA_PRIMARY.
unsigned long clrFG
default foreground color (also assigned to GC)
Pixmap PXM_GetIconPixmap(int idIcon, XPM_ATTRIBUTES *pAttr, Pixmap *pMask)
Create Icon pixmap pair using pre-defined resource ID.
unsigned long lTimeInterval
interval (or zero for one-shot timer)
enum WMPropertiesWMProtocols eWMProtocols
a combination of WMPropertiesWMProtocols values, indicating supported protocols (default None)
int CHGetDoubleClickDistance(Display *pDisplay)
returns default double click distance (from X settings)
Display * pDisplay
display associated with timer
static __inline__ void WBValidateRect(Window wID, WB_RECT *pRCT)
'Paint' helper, validates a WB_RECT for asynchronous Expose event generation
Structure definition for X11 error information.
Atom aCOMPOUND_TEXT
COMPOUND_TEXT Atom for the clipboard.
#define WB_POINTER_DBLCLICK
WB_POINTER 'double-click' event, send in lieu of WB_POINTER_CLICK for double-click.
void * aWindowData[WINDOW_DATA_SIZE]
4 void pointers, to be uased as needed for 'window data'
'window helper' main header file for the X11workbench Toolkit API
Atom aSECONDARY
SECONDARY Atom for the clipboard - uses XA_SECONDARY.
#define WB_POINTER_CLICK
Mouse 'click' event.
void WBAddMenuWindow(Window wID, Window wIDMenu)
Add a MENU WINDOW to a (frame) window.
void WBFreeFont(Display *pDisplay, WB_FONT pFont)
free a WB_FONT that was created using one of the WBFont APIs
int bQuitFlag
'Quit' Flag - you should check this periodically in your main (message) loop and exit whenever it is ...
unsigned long clrBG
default background color (also assigned to GC)
void WBClearWindow(Window wID, WBGC gc)
'Paint' helper, erases background by painting the background color within the clipping region
#define EVENT_ALL_MASK
An event mask for ALL events, with bits 0 through 24 set - see X.h which only defines bits 0 to 24 fo...
void __internal_font_helper_exit(void)
un-initialization for font helper - call once at end of program (WBExit() does this for you)
#define WB_DEBUG_PRINT(L,...)
Preferred method of implementing conditional debug output.
void * WBGetWindowData(Window wID, int iIndex)
Gets the data associated with this window and the specified index.
#define WB_POINTER_DROP
WB_POINTER 'drop' event, only sent if drag/drop supported AND was not 'canceled'; see WB_POINTER_CANC...
void WBUnregisterAppCallback()
unregister callback function for application events
void WBDefaultStandardColormap(Display *pDisplay, XStandardColormap *pMap)
returns a default XStandardColormap structure for the default screen of the specified display
static __inline__ int WBCheckDebugLevel(WB_UINT64 dwLevel)
Check specified debug level against the value returned by WBGetDebugLevel() and return non-zero for a...
int WBKeyEventProcessKey(const XKeyEvent *pEvent, char *pBuf, int *pcbLen, int *piAltCtrlShift)
Generic keyboard event translation utility.
Atom aMULTIPLE
MULTIPLE Atom for the clipboard.
int WBUnmapWindow(Display *pDisplay, Window wID)
wrapper for XUnmapWindow, makes window invisible without destroying it
void WBPostDelayedEvent(XEvent *pEvent, unsigned int nDelay)
Delays placing a copy of the specified event at the end of the regular (internal) event queue by a sp...
Display * WBThreadInitDisplay(void)
initializes default Display for a thread (must call WBInit() first)
void WBRestoreDefaultCursor(Window wID)
restore the default cursor
WB_GEOM geomAbsolute
absolute window geometry (from notification)
int iNext
index for 'next' in a linked list
void WBExit()
deletes any remaining global objects, frees the Display pointer, and terminates event processing
static __inline__ void WBSupressErrorOutput(void)
Supress X11 XErrorEvent output to stderr.
XImage * WBGetWindowImage(Display *pDisplay, Window wID)
Obtain an XImage for the entire window.
void WBCreateWindowDefaultGC(Window wID, unsigned long clrFG, unsigned long clrBG)
creates a default WBGC for a window
void WBWaitForEvent(Display *pDisplay)
Wait for an event, blocking indefinitely.
void WBGetWindowRect(Window wID, WB_RECT *pRect)
Returns the WB_RECT (rectangle) defined by the window's geometry, including the border area.
#define WB_POINTER_SCROLLDOWN
WB_POINTER 'scroll down' event, caused by mouse button 5.
int(* pCallback)(Window wIDEvent, XEvent *pEvent)
Pointer to the window's event callback function.
void WBInitWindowAttributes(XSetWindowAttributes *pXSWA, unsigned long lBorderPixel, unsigned long lBackgroundPixel, Colormap clrMap, int iBitGravity)
initializes the XSetWIndowAttributes structure with minimal attributes
Display * WBInit(const char *szDisplayName)
initializes default objects for the specified Display (required)
int iModalFlag
current modal state (0 for modeless) (see WBShowModal)
struct s_TIMER_ENTRY TIMER_ENTRY
Core (internal) structure for managing timers.
int WBCheckGetEvent(Display *pDisplay, XEvent *pEvent)
Main message loop, high level API to check for and retrieve the next event.
int WBNextEvent(Display *pDisplay, XEvent *pEvent)
low-level event queue wrapper. Implements the client-side event queue. Does not block if no events av...
void WBSetWindowClassName(Window wID, const char *szClassName)
Assignes the window's class name pointer.
void WBSetParentWindow(Window wID, Window wIDParent)
Assigns the parent to the specified window within the internal structure.
#define WB_KEYEVENT_ALT
'AltCtrlShift' bit flag for ALT modifier for WBKeyEventProcessKey()
void CHOnExit(void)
frees resources used by Configuration 'helper' functions
int __StartInitClipboardSystem(Display *pDisplay, const char *szDisplayName)
initializes clipboard sub-system
WB_FONT WBCopyFont(Display *pDisplay, WB_FONTC pOldFont)
make a copy of an existing font (best when assigning to a window)
int idCursor
last cursor ID used by 'WBSetCursor()'
int WBShowModal(Window wID, int bMenuSplashFlag)
Shows a 'modal' window by processing events until the window closes.
Window WBLocateWindow(WBLocateWindowCallback callback, void *pData)
Locate a window by enumerating with a callback function.
void WBGetWindowGeom0(Window wID, WB_GEOM *pGeom)
Returns the ABSOLUTE window geometry relative to the screen.
char padding[256 - sizeof(Display *) - sizeof(Window) - sizeof(int) - sizeof(XEvent)]
alignment padding to make the struct exactly 256 bytes in length
Window wIDMenu
window ID for attached menu window
Atom aINCR
INCR Atom for the clipboard.
unsigned long serial
serial number from XErrorEvent
const char * GetStartupDisplayName(void)
returns character name of the display to be opened and passed to WBInit
Pixmap pxMask
icon mask pixmap (may be None)
int WBWindowDispatch(Window wID, XEvent *pEvent)
Dispatches a window XEvent. May be called directly.
void WBDebugDump(const char *szTitle, void *pData, int cbData)
conditionally dumps binary data to debug message output
int width
cached width value from latest 'Expose' event
void GetStartupGeometry(WB_GEOM *pGeom)
returns the startup geometry based on command line parameters
const char * WBEventName(int iEventID)
debug function to return the name of an X11 event
static __inline__ void WBAllowErrorOutput(void)
Restore X11 XErrorEvent output to stderr.
int WBCopyIntoWindowImage(Display *pDisplay, Window wID, XImage *pSrcImage, int xSrc, int ySrc, int width, int height, int xOffs, int yOffs)
Copy an XImage into the cached XImage for the entire window.
int WBXPutImage(Display *pDisplay, Drawable dw, WBGC gc, XImage *pImage, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height)
Write contents of an XImage onto a Drawable.
struct s_EVENT_ENTRY EVENT_ENTRY
Core (internal) structure for storing and dispatching events.
void PXM_OnExit(void)
Frees resources allocated by Pixmap utility functions.
Atom aWM_DELETE_WINDOW
Delete Window notification event.
int iWindowState
indicates if window mapped
Atom aWM_PROTOCOLS
WM supported protocols.
void WBUpdateWindowImmediately(Window wID)
'Paint' helper, generates an immediate Expose event for non-empty 'invalid' region
int WBPostPriorityEvent(Window wID, XEvent *pEvent)
Places a copy of the specified event at the end of the priority (internal) event queue.
#define WINDOW_DATA_SIZE
The 'window data' array size (currently 4 void pointers)
Atom aWB_CHAR
keystroke/character notifications generated by API
void WBGetClientRect(Window wID, WB_RECT *pRect)
Returns the WB_RECT (rectangle) defined by the window's geometry, excluding the border area.
static __inline__ Display * WBGetDefaultDisplay(void)
Returns the default Display.
internal wrapper struct for X11 'geometry' definition
'configuration helper' main header file for the X11 Work Bench Toolkit API
Display * pDisplay
the Display pointer for the event
Region WBCopyRegion(Region rgnSource)
Simple utility to copy a region.
Atom aRECALC_LAYOUT
notify window that it should re-calculate things like scrollbars and viewports
Window WBGetApplicationWindow(void)
Get the main 'Application' window.
struct s_DELAYED_EVENT_ENTRY * pNext
linked lists for performance
Atom aDLG_FOCUS
dialog focus messages
Window wID
window to receive timer event
Atom aTIMESTAMP
TIMESTAMP Atom for the clipboard.
Core (internal) structure for managing timers.
void WBInvalidateRegion(Window wID, Region rgn, int bPaintFlag)
'Paint' helper, invalidates a region for asynchronous Expose event generation
int WBSetForeground(WBGC hGC, unsigned long foreground)
Assign foreground color, a wrapper for XSetForeground()
WB_UINT64 lTimeIndex
time index for which this timer next expires
Atom aDRAWABLE
DRAWABLE Atom for the clipboard - uses XA_DRAWABLE.
int WBAssignWindowImage(Display *pDisplay, Window wID, XImage *pImage)
Assign an XImage for the entire window.
Atom aWB_POINTER
pointer click/double-click/drag notifications generated by API
WB_UINT64 lTimeIndex
time index for which this timer next expires
XEvent event
copy of delayed event
WMPropertiesWindowType
Window type enumeration. Reserved for future implementation.
WB_FONT WBLoadFont(Display *pDisplay, const char *szFontName, int iFontSize, int iFlags)
load a WB_FONT font object based on a font name, size, and font flags
do not use a 'backing store' when drawing the window (native X11 calls)
WB_FONTC WBQueryWindowFont(Window wID)
Returns the WB_FONT assigned to the window (may be NULL), not a copy.
void WBRegisterWindowCallback(Window wID, WBWinEvent pCallback)
register callback function for a window (required)
Atom aMANAGER
MANAGER Atom for the clipboard.
int(* WBAppEvent)(XEvent *pEvent)
event callback function type definition for application events
Atom aPIXEL
PIXEL Atom for the clipboard.
void DeleteTimer(Display *pDisplay, Window wID, long lID)
Deletes an existing timer's resources.
void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintNow)
'Paint' helper, invalidates a geometry for asynchronous Expose event generation
void WBSetWindowCursor(Window wID, int idCursor)
immediately set the window cursor
void WBSetWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmProp)
assign standard WM (Window Manager) 'window type' properties BEFORE mapping it (reserved)
Region WBGetPaintRegion(Window wID)
'Paint' helper, returns a copy of the current 'paint' region for the window
Region WBRectToRegion(const WB_RECT *pRect)
'Paint' helper, converts a WB_RECT structure to a Region.
unsigned long WBGetWindowFGColor(Window wID)
Returns the currently assigned foreground color.
void WBSetApplicationWindow(Window wID)
Assign the main 'Appklication' window.
WB_FONT WBGetWindowFont(Window wID)
Returns a copy of the current WB_FONT assigned to the window (may be NULL)
void WBGetWindowGeom2(Window wID, WB_GEOM *pGeom)
Returns the geometry of the window relative to the root window.
struct s_DELAYED_EVENT_ENTRY DELAYED_EVENT_ENTRY
Core (internal) structure for managing delayed events.
Atom aWINDOW
WINDOW Atom for the clipboard - uses XA_WINDOW.
Atom aAVERAGE_WIDTH
Atoms for fonts - Average Character Width.
void * WBAlloc(int nSize)
High performance memory sub-allocator 'allocate'.
const char * szClassName
window 'class name', mostly for debug and tracing, points to NULL or persistent name string
Window WBGetParentWindow(Window wID)
Returns the window's parent (or None if there is no parent)
#define END_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro follows the call(s)
#define WB_POINTER_SCROLLUP
WB_POINTER 'scroll up' event, caused by mouse button 4.
Pixmap pxIcon
icon pixmap (may be None)
int height
cached height value from latest 'Expose' event (TODO: ConfigureNotify?)
Region rgnClip
complex clip (aka 'invalid') region (0 implies 'none')
void WBProcessExposeEvent(XExposeEvent *pEvent)
low-level event processing, internal handling of Expose events
int WBPostAppEvent(XEvent *pEvent)
Places a copy of the specified event at the end of the priority (internal) event queue.
void WBValidateGeom(Window wID, const WB_GEOM *pGeom)
'Paint' helper, validates a geometry for asynchronous Expose event generation
int WBSetRegion(WBGC hGC, Region rgnClip)
Assign clipping region, wrapper for XSetRegion()
Region WBGetInvalidRegion(Window wID)
'Paint' helper, returns a copy of the invalid region for a window
int WBIsMapped(Display *pDisplay, Window wID)
Returns non-zero if window has been mapped; zero otherwise.
Window wParent
cached window parent ID
Window WBGetMenuWindow(Window wID)
Returns the Window ID of the (first) menu window assigned to a (frame) window.
WBGC WBCopyGC(WBGC hGCOrig)
makes a copy of a WBGC, a more sensible wrapper for XCopyGC()
#define WB_ERROR_PRINT(...)
Preferred method of implementing an 'error level' debug message for all subsystems.
WB_UINT64 iFlags
'iFlags' specified when window was created (for reference)
unsigned long WBGetWindowBGColor(Window wID)
Returns the currently assigned background color.
int WBAppDispatch(XEvent *pEvent)
Dispatches an application XEvent. May be called directly.
Window WBGetHiddenHelperWindow(void)
Returns a special 'hidden' window used for information purposes.
void WBFree(void *pBuf)
High performance memory sub-allocator 'free'.
static __inline__ void WBInvalidateRect(Window wID, const WB_RECT *pRCT, int bPaintFlag)
'Paint' helper, invalidates a WB_RECT for asynchronous Expose event generation
int WBPostEvent(Window wID, XEvent *pEvent)
Places a copy of the specified event at the end of the regular (internal) event queue.
WBGC hGC
default graphics context
int WBMapRaised(Display *pDisplay, Window wID)
wrapper for XMapRaised, makes window visible and moves to top
void WBDestroyWindow(Window wID)
Destroy a window.
XImage * pImage
locally cached XImage for the window
int CHGetDoubleClickTime(Display *pDisplay)
returns default double click time (from X settings)
#define WB_POINTER_CANCEL
WB_POINTER 'cancel' event, cancels an ongoing operation, such as drag/drop (useful for resource clean...
#define WB_KEYEVENT_SHIFT
'AltCtrlShift' bit flag for Shift modifier for WBKeyEventProcessKey()
XGCValues values
cached XGCValues for the GC
WBGC WBCreateGC(Display *pDisplay, Drawable dw, unsigned long valuemask, const XGCValues *values)
Creates a WBGC, wrapper for XCreateGC()
#define WB_DEFAULT_CURSOR
The default window cursor (this is what xterm uses)
void WBSetWindowFont(Window wID, WB_FONTC pFont)
assigns the default WB_FONT object for a window
int iLine
Line number of the function as assigned by BEGIN_XCALL_DEBUG_WRAPPER.
Window wID
the window for which the event is queued
XWMHints * pWMHints
XWMHints structure (cached)
void WBPlatformOnInit(void)
Resource initialization on startup.
void WBXlatCoordPoint(Window wIDSrc, int iXSrc, int iYSrc, Window wIDDest, int *piXDest, int *piYDest)
Translate X,Y point coordinates relative to a window.
void WBUpdateWindow(Window wID)
'Paint' helper, generates an asynchronous Expose event for non-empty 'invalid' region
void WBSetWindowIcon(Window wID, int idIcon)
assigns an icon resource (by ID) to a window
#define WB_POINTER_MOVE
WB_POINTER 'move' event, for motion notification during drag/drop.
#define WB_POINTER_DRAG
WB_POINTER 'drag' event, window proc MUST return the window ID to auto-support drag/drop.
Window WBCreateWindow(Display *pDisplay, Window wIDParent, WBWinEvent pProc, const char *szClass, int iX, int iY, int iWidth, int iHeight, int iBorder, int iIO, WB_UINT64 iFlags, XSetWindowAttributes *pXSWA)
Create a window.
Atom aCLIPBOARD
CLIPBOARD Atom for the clipboard.
WBGC WBGetWindowDefaultGC(Window wID)
Returns the default WBGC currently assigned to the window (not a copy)
int WBIsChildWindow(Window wIDParent, Window wIDChild)
Returns non-zero if wIDParent is in a parent relationsihp with wIDChild.
int WBInitDisplay(Display *pDisplay)
initializes default objects for the specified Display
int WBGetWindowDefaultCursor(Window wID)
returns the default cursor ID for a window
void WBDispatch(XEvent *pEvent)
Generic Event Dispatcher, using message type to dispatch.
void WBInitSizeHints(XSizeHints *pSH, Display *pDisplay, int iMinHeight, int iMinWidth)
initializes the XSizeHints structure with standard attributes
Window wID
window to which the structure is mapped
int WBIsValid(Display *pDisplay, Window wID)
returns non-zero if 'valid' (i.e. 'not destroyed')
#define WB_WAIT_CURSOR
The 'wait' cursor (this is what xterm uses)
void WBDebugDumpEvent(XEvent *pEvent)
dumps the contents of an XEvent
void WBUnregisterWindowCallback(Window wID)
un-register the window's callback function (implies resource destruction)
void WBErrorClear(void)
Clear the 'last error' information obtained via WBGetLastError()
const char * sz_xcall_func
debug helper variable tracking the function calling into the X11 library
XImage * WBXGetImage(Display *pDisplay, Drawable dw, int x, int y, unsigned int width, unsigned int height, unsigned long plane_mask, int format)
Read contents of a Drawable onto an XImage.
int iModalReturn
return value for a modal window (see WBShowModal)
Region rgnPaint
rectangular paint region (0 implies 'none')
Display * pDisplay
display associated with this window
WBGC WBBeginPaint(Window wID, XExposeEvent *pEvent, WB_GEOM *pgBounds)
'Paint' helper, creates a WBGC for use in updating the window in an Expose event handler
int(* WBWinEvent)(Window wID, XEvent *pEvent)
event callback function type for window events
WBGC WBGetWindowCopyGC(Window wID)
makes a copy of the default WBGC so that it can be modified
int minor_code
minor code from XErrorEvent
Atom aWM_TAKE_FOCUS
'Take Focus' - TODO document this properly
void CHSettingsRefresh(Display *pDisplay)
refresh the internally cached X settings
Display * pDisplay
Display pointer passed into error handler function (NULL if no error)
int WBReparentWindow(Window wID, Window wIDParent, int iX, int iY)
Assigns a new parent to the specified window (aka 'Re-parent')
Atom aPIXMAP
PIXMAP Atom for the clipboard - uses XA_PIXMAP.
void WBMouseCancel(Display *pDisplay, Window wID)
low-level event processing, internal handling of Expose events
WB_FONT pFont
default font for window, NULL to use pDefaultFont
enum WMPropertiesWindowType WBGetWMPropertiesWindowType(Window wID)
re-assign standard WM (Window Manager) 'window type' properties and notify the root window (reserved)
void WBDebugDumpGC(Display *pDisplay, WBGC hGC)
dumps a GC's settings
void WBXlatCoordRect(Window wIDSrc, const WB_RECT *pRectSrc, Window wIDDest, WB_RECT *pRectDest)
Translate rectangle coordinates relative to a window.
void WBBeginWaitCursor(Window wID)
increment 'wait cursor' count, set cursor to WB_WAIT_CURSOR
const char * WBGetWindowClassName(Window wID)
Returns the window's assigned class name pointer.
int WBAppDefault(XEvent *pEvent)
implements the default application event callback behavior
internal wrapper struct for 'rectangle' definition
int(* WBLocateWindowCallback)(Window wID, void *pData)
callback definition for WBLocateWindow
#define WB_DEFAULT_FONT
The default X11 font name (currently "fixed")
int WBErrorCheckRetry(void)
Check to see whether or not an X11 error was detected AND can be re-tried.
int WBSetClipOrigin(WBGC hGC, int clip_x_origin, int clip_y_origin)
Set clip origin, a wrapper for XSetClipOrigin()
int WBErrorCheck(void)
Check to see whether or not an X11 error was detected.
Atom aQUERY_CLOSE
query if it's ok to close (and optionally destroy yourself if ok) a window
void WBSetWindowDefaultCursor(Window wID, int idStandardCursor)
Assigns a default cursor (by ID) to a window.
WMPropertiesWMProtocols
Window WMProtocols support enumeration.
void WBRegisterMenuCallback(Window wID, WBWinEvent pMenuCallback)
(internal) Register a MENU callback for a window
Display * WBGetWindowDisplay(Window wID)
returns the Display associated with a window
Atom aCONTROL_NOTIFY
dialog control and child window notification messages
void WBFreeGC(WBGC hGC)
Free resources for a WBGC, wrapper for XFreeGC()
int error_code
error code from XErrorEvent
void WBSetWindowData(Window wID, int iIndex, void *pData)
assign 'data pointer' for a window and specified index value
void WBChangeWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmProp, enum WMPropertiesWindowType wmChangeMask)
re-assign standard WM (Window Manager) 'window type' properties and notify the root window (reserved)
#define WB_DEFAULT_FONT_SIZE
The default X11 font size (currently 13)
XID resourceid
resource ID (usually a Window) from XErrorEvent
Atom aTARGETS
TARGETS Atom for the clipboard.
Core (internal) structure for managing delayed events.
void __internal_font_helper_init(void)
initialization for font helper - call once at start of program (WBInit() does this for you)
struct s_TIMER_ENTRY * pNext
linked lists for performance
Atom aTARGET
TARGET Atom for the clipboard.
void WBSetWMProtocols(Window wID, Atom aProperty,...)
re-assign standard WM (Window Manager) 'window type' properties and notify the root window (reserved)
Status WBGetGCValues(WBGC hGC, unsigned long valuemask, XGCValues *values)
Change a WBGC, a wrapper for XGetGCValues()
void WBRegisterAppCallback(WBAppEvent pCallback)
Registers a callback function for application events.
#define BEGIN_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro precedes the call(s)
unsigned long WBGetGCFGColor(WBGC gc)
returns the currently assigned foreground color for a WBGC
void WBThreadFreeDisplay(Display *pThreadDisplay)
un-initializes a Display for a thread that was allocated by WBThreadInitDisplay()
unsigned long WBGetGCBGColor(WBGC gc)
returns the currently assigned background color for a WBGC
struct timeval tvLastActivity
time of last activity (TODO: find a better way than 'gettimeofday')
int idDefaultCursor
default cursor
int CHGetDragThreshold(Display *pDisplay)
returns default drag threshold (from X settings)
void WBSetWindowDefaultGC(Window wID, WBGC hGC)
assigns a default WBGC to a window
void WBSetInputFocus(Window wID)
set input focus to a specific window
int iWaitCursorCount
current 'count' for wait cursor
Atom aCOLORMAP
COLORMAP Atom for the clipboard - uses XA_COLORMAP.
Atom aBITMAP
BITMAP Atom for the clipboard - uses XA_BITMAP.
int WBFillRectangle(Display *display, Drawable d, WBGC gc, int x, int y, unsigned int width, unsigned int height)
Wrapper for XFillRectangle()
void WBGetWindowGeom(Window wID, WB_GEOM *pGeom)
Returns the RAW geometry of the window as reported by the window manager.
Region WBGeomToRegion(const WB_GEOM *pGeom)
'Paint' helper, converts a WB_GEOM structure to a Region.
enum WMPropertiesWindowType eWindowType
a combination of WMPropertiesWindowType values (default None)
void WBDebugPrint(const char *pFmt,...) __attribute__((format(printf
conditional debug message output
Atom aWB_TIMER
timer notifications generated by API
Atom aDESTROY_NOTIFY
notify parent that child is being destroyed
#define WB_KEYEVENT_CTRL
'AltCtrlShift' bit flag for Control modifier for WBKeyEventProcessKey()
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
int WBDefault(Window wID, XEvent *pEvent)
implements the default window event callback behavior
void WBEndWaitCursor(Window wID)
decrement 'wait cursor' count, restore to default when zero
int CreateTimer(Display *pDisplay, Window wID, unsigned long lInterval, long lID, int iPeriodic)
Creates a one-shot or periodic timer.
void WBEndModal(Window wID, int iRval)
End a modal window with a specific return value.
int GetStartupMinMax(void)
returns the min/max/normal window state for startup
Cursor curRecent
most recent cursor resource (must be freed via XFreeCursor)
void WBUpdateWindowWithImage(Display *pDisplay, Window wID)
Update the window's appearance with the contents of the cached XImage.
XEvent xEvt
the event I'm queueing
Atom aNULL
NULL Atom for the clipboard.
void WBSetWindowTitle(Window wID, const char *szTitle)
assign window (and icon) title
#define WB_IF_DEBUG_LEVEL(L)
Preferred method of implementing conditional debug 'if block' code.
void WBEndPaint(Window wID, WBGC gc)
'Paint' helper, frees resources and marks the update region 'valid'
internal wrapper struct for GC with local cache
Atom aRESIZE_NOTIFY
notification of window re-size via ClientMessage
#define WBPointInGeom(X, Y, G)
Returns logical TRUE if the point (X,Y) is within the borders of the geometry 'G'.
Atom aTEXT
TEXT Atom for the clipboard.
int(* pMenuCallback)(Window wIDEvent, XEvent *pEvent)
Pointer to the window's MENU callback function - may be NULL, valid only for windows with menus.
Atom aSET_FOCUS
dialog focus messages
const char * pFunc
Name of the function as assigned by BEGIN_XCALL_DEBUG_WRAPPER.
Time WBGetLastEventTime(void)
Main message loop, high level API to check for and retrieve the next event.
Atom aC_STRING
C_STRING Atom for the clipboard.
void WBDebugDumpRegion(Region hRgn, int bRotate)
dumps contents of a region
int WBMapWindow(Display *pDisplay, Window wID)
Wrapper for XMapWindow, makes window visible.
int __FinishInitClipboardSystem(Display *pDisplay, const char *szDisplayName)
initializes clipboard sub-system
Atom aSTRING
STRING Atom for the clipboard - uses XA_STRING.
int request_code
request code from XErrorEvent
#define WB_WARN_PRINT(...)
Preferred method of implementing a 'warning level' debug message for all subsystems.
void WBExitClipboardSystem(Display *pDisplay)
Shut down the clipboard sub-system.
void WBValidateRegion(Window wID, Region rgn)
'Paint' helper, validates a region for asynchronous Expose event generation
Atom aUTF8_STRING
UTF8_STRING Atom for the clipboard.
int i_xcall_line
debug helper variable indicating the line number of the function calling into the X11 library
void WBRemoveMenuWindow(Window wID, Window wIDMenu)
Remove (detach) the specified menu window from a (frame) window.
const WB_ERROR_INFO * WBGetLastError(void)
Obtain a const pointer to the internal WB_ERROR_INFO structure.
void WBPostDelayedSetFocusAppEvent(Display *pDisplay, Window wID, Window wIDFrom, unsigned int iDelay)
Creates a 'set focus' ClientMessage event for the application event handler.
WBGC WBBeginPaintGeom(Window wID, WB_GEOM *pgBounds)
'Paint' helper, creates a WBGC for use in updating the window for a specified rectangular area
#define WB_KEYEVENT_KEYSYM
'AltCtrlShift' bit flag for 'VK_' keys for WBKeyEventProcessKey()
void WBXlatCoordGeom(Window wIDSrc, const WB_GEOM *pGeomSrc, Window wIDDest, WB_GEOM *pGeomDest)
Translate geometry coordinates relative to a window.
WB_FONTC WBGetDefaultFont(void)
Returns a pointer to the default font WB_FONT for the default display. This is a shared resource; do ...