X11 Work Bench Toolkit  1.0
window_helper.h
Go to the documentation of this file.
1 // _ _ _ _ _ //
3 // __ __(_) _ __ __| | ___ __ __ | |__ ___ | | _ __ ___ _ __ | |__ //
4 // \ \ /\ / /| || '_ \ / _` | / _ \\ \ /\ / / | '_ \ / _ \| || '_ \ / _ \| '__|| '_ \ //
5 // \ V V / | || | | || (_| || (_) |\ V V / | | | || __/| || |_) || __/| | _ | | | | //
6 // \_/\_/ |_||_| |_| \__,_| \___/ \_/\_/_____|_| |_| \___||_|| .__/ \___||_|(_)|_| |_| //
7 // |_____| |_| //
8 // //
9 // basic window creation and message handling //
10 // //
11 // Copyright (c) 2010-2016 by 'Big Bad Bombastic Bob' Frazier - all rights reserved. //
12 // You may use this file in any way you see fit provided that any copy or derived work //
13 // includes the above copyright notice. //
14 // //
15 // NOTE: 'WB' is for 'Work Bench', aka 'X11workbench Toolkit' //
16 // //
18 
19 /*****************************************************************************
20 
21  X11workbench - X11 programmer's 'work bench' application and toolkit
22  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
23  all rights reserved
24 
25  DISCLAIMER: The X11workbench application and toolkit software are supplied
26  'as-is', with no warranties, either implied or explicit.
27  Any claims to alleged functionality or features should be
28  considered 'preliminary', and might not function as advertised.
29 
30  BSD-like license:
31 
32  There is no restriction as to what you can do with this software, so long
33  as you include the above copyright notice and DISCLAIMER for any distributed
34  work that is equal to or derived from this one, along with this paragraph
35  that explains the terms of the license if the source is also being made
36  available. A "derived work" describes a work that uses a significant portion
37  of the source files or algorithms that are included with this one.
38  Specifically excluded from this are files that were generated by the software,
39  or anything that is included with the software that is part of another package
40  (such as files that were created or added during the 'configure' process).
41  Specifically included is the use of part or all of any of the X11 workbench
42  toolkit source or header files in your distributed application. If you do not
43  ship the source, the above copyright statement is still required to be placed
44  in a reasonably prominent place, such as documentation, splash screens, and/or
45  'about the application' dialog boxes.
46 
47  Use and distribution are in accordance with GPL, LGPL, and/or the above
48  BSD-like license. See COPYING and README files for more information.
49 
50 
51  Additional information at http://sourceforge.net/projects/X11workbench
52 
53 ******************************************************************************/
54 
55 
57 // - DOXYGEN RELATED STUFF - //
59 
74 // doxygen top-level stuff has been moved to doxy_comments.dox
75 
77 // - END DOXYGEN RELATED STUFF - //
79 
80 
81 
82 // window helpers - defines manager for callback procs, font, GC, and a generic event dispatcher
83 
84 #ifndef WINDOW_HELPER_H_INCLUDED
85 #define WINDOW_HELPER_H_INCLUDED
86 
87 // headers that must be included or I break
88 
89 #include <string.h> // for memset, mostly
90 
91 #include "platform_helper.h"
92 #include "debug_helper.h"
93 #include "font_helper.h"
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif // __cplusplus
98 
102 #define WB_DEFAULT_CURSOR XC_left_ptr
103 
106 #define WB_WAIT_CURSOR XC_watch /*XC_clock*/
107 
110 #define WB_DEFAULT_FONT "fixed"
111 
114 #define WB_DEFAULT_FONT_SIZE 13 /* override via settings */
115 
118 #define WINDOW_DATA_SIZE 4 /* size of a 'void *' array that stores per-window data */
119 
123 #define EVENT_ALL_MASK 0x01ffffffL /* 2^24 | 2^23 ... 2^0 - see X.h */
124 
125 
129 #define GCAll (GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | \
130  GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | \
131  GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | \
132  GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | \
133  GCClipMask | GCDashOffset | GCDashList | GCArcMode)
134 
135 
136 
137 // debug helpers (to be eliminated at some point)
138 
142 extern const char *sz_xcall_func;
146 extern int i_xcall_line;
151 #define BEGIN_XCALL_DEBUG_WRAPPER { const char *__szOldXCallFunc__ = sz_xcall_func; int __iOldXCallLine__ = i_xcall_line; sz_xcall_func = __FUNCTION__; i_xcall_line = __LINE__; {
152 
156 #define END_XCALL_DEBUG_WRAPPER } sz_xcall_func = __szOldXCallFunc__; i_xcall_line = __iOldXCallLine__; }
157 
158 
171 typedef int (* WBWinEvent)(Window wID, XEvent *pEvent);
183 typedef int (* WBAppEvent)(XEvent *pEvent);
184 
219 typedef struct _WBPoint_
220 {
221  int x;
222  int y;
223 } WB_POINT;
224 
249 typedef struct _WBExtent_
250 {
251  unsigned int width;
252  unsigned int height;
253 } WB_EXTENT;
254 
290 typedef struct _WBRect_
291 {
292  int left;
293  int top;
294  int right;
295  int bottom;
296 } WB_RECT;
297 
336 typedef struct _WBGeom_
337 {
338  int x;
339  int y;
340  unsigned int width;
341  unsigned int height;
342  unsigned int border;
343 } WB_GEOM;
344 
345 
346 
348 // //
349 // ____ _ _ _ _ ____ _ _ _ //
350 // / ___| | |_ __ _ _ __ | |_ _ _ _ __ / \ _ __ __| | / ___| | |__ _ _ | |_ __| | ___ __ __ _ __ //
351 // \___ \ | __|/ _` || '__|| __|| | | || '_ \ / _ \ | '_ \ / _` | \___ \ | '_ \ | | | || __|/ _` | / _ \\ \ /\ / /| '_ \ //
352 // ___) || |_| (_| || | | |_ | |_| || |_) | / ___ \ | | | || (_| | ___) || | | || |_| || |_| (_| || (_) |\ V V / | | | | //
353 // |____/ \__|\__,_||_| \__| \__,_|| .__/ /_/ \_\|_| |_| \__,_| |____/ |_| |_| \__,_| \__|\__,_| \___/ \_/\_/ |_| |_| //
354 // |_| //
355 // //
357 
358 
360 // window-specific initialization
362 
377 Display *WBInit(const char *szDisplayName);
378 
395 int WBInitDisplay(Display *pDisplay);
396 
415 int WBInitClipboardSystem(Display *pDisplay, const char *szDisplayName);
416 
426 void WBExit(void);
427 
435 void WBExitClipboardSystem(Display *pDisplay);
436 
448 Display *WBThreadInitDisplay(void);
449 
460 void WBThreadFreeDisplay(Display *pThreadDisplay);
461 
462 
473 const char *GetStartupDisplayName(void);
474 
484 void GetStartupGeometry(WB_GEOM *pGeom);
493 int GetStartupMinMax(void);
494 
503 static __inline__ Colormap WBDefaultColormap(Display *pDisplay)
504 {
505  return DefaultColormap(pDisplay, DefaultScreen(pDisplay));
506 }
507 
523 void WBInitWindowAttributes(XSetWindowAttributes *pXSWA, unsigned long lBorderPixel,
524  unsigned long lBackgroundPixel, Colormap clrMap, int iBitGravity);
525 
541 void WBInitSizeHints(XSizeHints *pSH, Display *pDisplay, int iMinHeight, int iMinWidth);
542 
543 
544 
546 // ____ _____ _____ _ _ _ _ _____ ____ //
547 // | _ \ | ____|| ___|/ \ | | | || | |_ _|/ ___| //
548 // | | | || _| | |_ / _ \ | | | || | | | \___ \ //
549 // | |_| || |___ | _|/ ___ \| |_| || |___ | | ___) | //
550 // |____/ |_____||_| /_/ \_\\___/ |_____||_| |____/ //
551 // //
553 
570 static __inline__ Display * WBGetDefaultDisplay(void)
571 {
572  extern Display *pDefaultDisplay;
573  return pDefaultDisplay;
574 }
575 
588 XFontStruct *WBGetDefaultFont(void);
589 
603 XFontSet WBGetDefaultFontSet(Display *pDisplay);
604 
614 Window WBGetHiddenHelperWindow(void); // if you need "a window" for the default display, use this
615 
616 
617 
618 
620 // ____ _ ___ ____ _ _ _ _____ ___ __ __ ____ //
621 // / ___|| | / _ \ | __ ) / \ | | / \ |_ _|/ _ \ | \/ |/ ___| //
622 // | | _ | | | | | || _ \ / _ \ | | / _ \ | | | | | || |\/| |\___ \ //
623 // | |_| || |___| |_| || |_) |/ ___ \ | |___ / ___ \ | | | |_| || | | | ___) | //
624 // \____||_____|\___/ |____//_/ \_\|_____| /_/ \_\|_| \___/ |_| |_||____/ //
625 // //
627 
628 // global atoms (for convenience they are referenced directly via global variables)
629 
630 #if !defined(_WINDOW_HELPER_C_) && !defined(_CLIPBOARD_HELPER_C)
631  /* this declares the atoms 'const' outside of window_helper.c, and does NOT declare them in clipboard_helper.c */
632  /* These atoms are GLOBAL variables, assigned by the DEFAULT Display, and may not work for other threads. */
633 extern const Atom aMENU_COMMAND; // commands sent by menus via ClientMessage
634 extern const Atom aMENU_UI_COMMAND; // UI notification sent by menus to owning frame windows via ClientMessage using WBWindowDispatch
635 extern const Atom aRESIZE_NOTIFY; // notification of window re-size via ClientMessage
636 extern const Atom aSCROLLBAR_NOTIFY; // notification of scroll bar/position changes via ClientMessage
637 extern const Atom aDESTROY_NOTIFY; // notify parent that child is being destroyed
638 extern const Atom aCONTROL_NOTIFY; // dialog control and child window notification messages
639  // l[0] contains control ID or -1, l[1] is notify code, l[2] is window ID
640 extern const Atom aSCROLL_NOTIFY; // specific notification for scrollbars (see enumeration, below)
641  // data.l[0] is scrollbar enum, data.l[1] is notification enum, data.l[2] is optional position modifier
642 extern const Atom aQUERY_CLOSE; // command sent by Client Message - return 0 if ok to close, 1 if not ok to close, -1 on error
643 extern const Atom aRECALC_LAYOUT; // notify window that it should re-calculate things like scrollbars and viewports
644 
645 extern const Atom aDLG_FOCUS; // dialog focus messages: l[0] is <,0,> for prev, 'set to', next. For 'set to' l[1] is control ID
646 extern const Atom aSET_FOCUS; // 'set focus' messages (send/post to application)
647 extern const Atom aWM_CHAR; // character notifications (generated by API; avoids key up/down handling)
648 extern const Atom aWM_TIMER; // timer notifications (generated by API)
649 extern const Atom aWM_POINTER; // pointer notifications (generated by API)
650 
651 // things used by window managers
652 extern const Atom aWM_PROTOCOLS; // WM supported protocols (see 'freedesktop.org' WM docs)
653 extern const Atom aWM_DELETE_WINDOW; // WM command to delete a window (a click on the 'x')
654 extern const Atom aWM_TAKE_FOCUS; // WM protocol (part of WM_PROTOCOLS spec, ICCCM, assoc with focus bit in WM_HINTS)
655 
656 // things used by fonts
657 extern const Atom aAVERAGE_WIDTH; // Average Character Width (font property)
658 
659 // things used by the clipboard
660 extern const Atom aCLIPBOARD; // Atom for 'CLIPBOARD'
661 extern const Atom aPRIMARY; // Atom for 'PRIMARY'
662 extern const Atom aSECONDARY; // Atom for 'SECONDARY'
663 extern const Atom aMANAGER; // Atom for 'MANAGER'
664 extern const Atom aTARGET; // Atom for 'TARGET'
665 extern const Atom aINCR; // Atom for 'INCR' (incremental transfers)
666 extern const Atom aWINDOW; // Atom for 'WINDOW'
667 extern const Atom aBITMAP; // Atom for 'BITMAP'
668 extern const Atom aDRAWABLE; // Atom for 'DRAWABLE'
669 extern const Atom aCOLORMAP; // Atom for 'COLORMAP'
670 extern const Atom aPIXEL; // Atom for 'PIXEL'
671 extern const Atom aPIXMAP; // Atom for 'PIXMAP'
672 extern const Atom aTEXT; // Atom for 'TEXT'
673 extern const Atom aSTRING; // Atom for 'STRING'
674 extern const Atom aUTF8_STRING; // Atom for 'UTF8_STRING'
675 extern const Atom aC_STRING; // Atom for 'C_STRING'
676 extern const Atom aCOMPOUND_TEXT; // Atom for 'COMPOUND_TEXT'
677 extern const Atom aTARGETS; // Atom for 'TARGETS'
678 extern const Atom aMULTIPLE; // Atom for 'MULTIPLE'
679 extern const Atom aTIMESTAMP; // Atom for 'TIMESTAMP'
680 extern const Atom aNULL; // Atom for 'NULL'
681 #endif // !_WINDOW_HELPER_C, !_CLIPBOARD_HELPER_C
682 
683 
684 
685 // parameter enumerations for aSCROLL_NOTIFY ClientMessage
686 
694 enum
695 {
699 
707 
709 
712 
713  WB_SCROLL_NA = 0x80000000
714 };
715 
716 
717 
718 
719 
720 
721 
723 // ____ ___ ____ _____ _ ____ ___ //
724 // / ___|/ _ \ | _ \ | ____| / \ | _ \|_ _| //
725 // | | | | | || |_) || _| / _ \ | |_) || | //
726 // | |___| |_| || _ < | |___ / ___ \ | __/ | | //
727 // \____|\___/ |_| \_\|_____| /_/ \_\|_| |___| //
728 // //
730 
771 #define WB_STANDARD_INPUT_MASK (FocusChangeMask | PropertyChangeMask | ExposureMask | StructureNotifyMask | VisibilityChangeMask | SubstructureNotifyMask)
772 
779 #define WB_KEYBOARD_INPUT_MASK (KeyPressMask | KeyReleaseMask)
780 
787 #define WB_MOUSE_INPUT_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask)
788 
789 
797 {
798  // must be ONLY ONE of the items below
799  WMPropertiesWindowType_TypeMask = 0x3f,
800  WMPropertiesWindowType_Normal = 0,
801  WMPropertiesWindowType_Desktop = 1,
802  WMPropertiesWindowType_Dock = 2,
803  WMPropertiesWindowType_ToolBar = 3,
804  WMPropertiesWindowType_Menu = 4,
805  WMPropertiesWindowType_Utility = 5,
806  WMPropertiesWindowType_Splash = 6,
807  WMPropertiesWindowType_Dialog = 7,
808  WMPropertiesWindowType_DropDownMenu = 8,
809  WMPropertiesWindowType_PopupMenu = 9,
810  WMPropertiesWindowType_ToolTip = 10,
811  WMPropertiesWindowType_Notification = 11,
812  WMPropertiesWindowType_Combo = 12,
813  WMPropertiesWindowType_Drag_N_Drop = 13,
814  WMPropertiesWindowType_Reserved14 = 14,
815  WMPropertiesWindowType_Reserved15 = 15,
816 
817 
818  // may be A COMBINATION of the items below
819  WMPropertiesWindowType_StateMask = 0xfffC0,
820 
821  WMPropertiesWindowType_NoState = 0,
822  WMPropertiesWindowType_Modal = 0x00040,
823  WMPropertiesWindowType_Sticky = 0x00080,
824  WMPropertiesWindowType_VMax = 0x00100,
825  WMPropertiesWindowType_HMax = 0x00200,
826  WMPropertiesWindowType_FullScreen = 0x00400,
827  WMPropertiesWindowType_Hidden = 0x00800,
828  WMPropertiesWindowType_Shaded = 0x01000,
829  WMPropertiesWindowType_SkipTaskbar = 0x02000,
830  WMPropertiesWindowType_SkipPager = 0x04000,
831  WMPropertiesWindowType_Above = 0x08000,
832  WMPropertiesWindowType_Below = 0x10000,
833  WMPropertiesWindowType_Focused = 0x20000,
834  WMPropertiesWindowType_DemandsAttention = 0x40000,
835  WMPropertiesWindowType_Reserved80000 = 0x80000,
836 
837 
838  // TODO: other stuff
839 
840  WMPropertiesWindowType_Max = 0x80000000
841 };
842 
850 {
851  // The following flags indicate WM_PROTOCOLS support
852  // Assigning these directly can have unexpected consequences
853  WMPropertiesWMProtocols_Mask = 0xff,
854  WMPropertiesWMProtocols_None = 0x0, // the default
855  WMPropertiesWMProtocols_DeleteWindow = 0x01,
856  WMPropertiesWMProtocols_Reserved2 = 0x02,
857  WMPropertiesWMProtocols_Reserved3 = 0x04,
858  WMPropertiesWMProtocols_Reserved4 = 0x08,
859  WMPropertiesWMProtocols_Reserved5 = 0x10,
860  WMPropertiesWMProtocols_Reserved6 = 0x20,
861  WMPropertiesWMProtocols_Reserved7 = 0x40,
862  WMPropertiesWMProtocols_Reserved8 = 0x80,
863 };
864 
865 
866 
892 Window WBCreateWindow(Display *pDisplay, Window wIDParent,
893  WBWinEvent pProc, const char *szClass,
894  int iX, int iY, int iWidth, int iHeight, int iBorder, int iIO,
895  int iFlags, XSetWindowAttributes *pXSWA);
896 
904 void WBDestroyWindow(Window wID);
905 
916 Window WBGetApplicationWindow(void);
917 
930 void WBSetApplicationWindow(Window wID);
931 
937 int WBDefault(Window wID, XEvent *pEvent);
938 
944 int WBAppDefault(XEvent *pEvent);
945 
955 void WBRegisterAppCallback(WBAppEvent pCallback);
956 
963 
969 void WBRegisterWindowCallback(Window wID, WBWinEvent pCallback);
970 
976 void WBUnregisterWindowCallback(Window wID);
977 
989 void WBSetWMProperties(Window wID, const char *szTitle, XSizeHints *pNormalHints,
990  XWMHints *pWMHints, XClassHint *pClassHints);
999 void WBSetWindowTitle(Window wID, const char *szTitle);
1000 
1012 void WBSetWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmProp);
1013 
1026 void WBChangeWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmPropSet, enum WMPropertiesWindowType wmChangeMask);
1027 
1028 
1040 
1054 void WBSetWMProtocols(Window wID, Atom aProperty, ...);
1055 
1056 
1066 typedef int (*WBLocateWindowCallback)(Window wID, void *pData);
1067 
1087 Window WBLocateWindow(WBLocateWindowCallback callback, void *pData);
1088 
1099 void WBSetInputFocus(Window wID);
1100 
1109 Display * WBGetWindowDisplay(Window wID);
1110 
1119 void WBSetWindowIcon(Window wID, int idIcon);
1120 
1129 void WBSetWindowFontStruct(Window wID, XFontStruct *pFontStruct);
1130 
1139 void WBSetWindowFontSet(Window wID, XFontSet fontSet);
1140 
1149 void WBSetWindowDefaultCursor(Window wID, int idStandardCursor);
1150 
1159 int WBGetWindowDefaultCursor(Window wID);
1160 
1170 void WBCreateWindowDefaultGC(Window wID, unsigned long clrFG, unsigned long clrBG);
1171 
1180 void WBSetWindowDefaultGC(Window wID, GC hGC);
1181 
1190 GC WBGetWindowCopyGC(Window wID);
1191 
1204 #define WBGetWindowCopyGC2(wID, gcSrc) WBCopyDrawableGC(WBGetWindowDisplay(wID), wID, gcSrc)
1205 
1219 GC WBCopyDrawableGC(Display *pDisplay, Drawable dw, GC gcSrc);
1220 
1235 XFontStruct * WBGetGCFont(Display *pDisplay, GC gc);
1236 
1246 void WBSetWindowData(Window wID, int iIndex, void *pData);
1247 
1255 void WBBeginWaitCursor(Window wID);
1256 
1264 void WBEndWaitCursor(Window wID);
1265 
1274 void WBSetWindowCursor(Window wID, int idCursor);
1275 
1283 void WBRestoreDefaultCursor(Window wID);
1284 
1301 GC WBGetWindowDefaultGC(Window wID);
1302 
1311 XFontStruct *WBGetWindowFontStruct(Window wID);
1312 
1321 XFontSet WBGetWindowFontSet(Window wID);
1322 
1331 unsigned long WBGetWindowFGColor(Window wID);
1332 
1341 unsigned long WBGetWindowBGColor(Window wID);
1342 
1355 unsigned long WBGetGCFGColor(Display *pDisplay, GC gc);
1356 
1369 unsigned long WBGetGCBGColor(Display *pDisplay, GC gc);
1370 
1391 void WBDefaultStandardColormap(Display *pDisplay, XStandardColormap *pMap);
1392 
1406 void WBSetWindowClassName(Window wID, const char *szClassName);
1407 
1420 const char *WBGetWindowClassName(Window wID);
1421 
1438 void *WBGetWindowData(Window wID, int iIndex);
1439 
1448 void WBGetWindowGeom(Window wID, WB_GEOM *pGeom);
1449 
1458 void WBGetWindowGeom2(Window wID, WB_GEOM *pGeom);
1459 
1460 
1478 void WBGetWindowGeom0(Window wID, WB_GEOM *pGeom); // absolute window geometry (from latest notification)
1479 
1488 void WBGetWindowRect(Window wID, WB_RECT *pRect);
1489 
1498 void WBGetClientRect(Window wID, WB_RECT *pRect);
1499 
1500 
1509 Window WBGetParentWindow(Window wID);
1510 
1511 
1526 void WBSetParentWindow(Window wID, Window wIDParent);
1527 
1543 int WBReparentWindow(Window wID, Window wIDParent, int iX, int iY); // keeps internal info up to date
1544 
1559 int WBIsChildWindow(Window wIDParent, Window wIDChild); // non-zero if 'wIDParent' is in a parent relationship with 'wIDChild'
1560 
1569 #define WBPointInRect(X,Y,R) ((X) >= (R).left && (X) < (R).right && (Y) >= (R).top && (Y) < (R).bottom)
1570 
1578 #define WBPointInGeom(X,Y,G) ((X) >= (G).x && (X) < ((G).x + (G).width) && (Y) >= (G).y && (Y) < ((G).y + (G).height))
1579 
1586 #define WBRectOverlapped(R1,R2) \
1587  ((((R1).left >= (R2).left && (R1).left < (R2).right) || \
1588  ((R2).left >= (R1).left && (R2).left < (R1).right)) && \
1589  (((R1).top >= (R2).top && (R1).top < (R2).bottom) || \
1590  ((R2).top >= (R1).top && (R2).top < (R1).bottom)))
1591 
1598 #define WBGeomOverlapped(G1,G2) \
1599  ((((G1).x >= (G2).x && (G1).x < (G2).x + (G2).width) || \
1600  ((G2).x >= (G1).x && (G2).x < (G1).x + (G1).width)) && \
1601  (((G1).y >= (G2).y && (G1).y < (G2).y + (G2).height) || \
1602  ((G2).y >= (G1).y && (G2).y < (G1).y + (G1).height)))
1603 
1621 void WBXlatCoordPoint(Window wIDSrc, int iXSrc, int iYSrc, Window wIDDest, int *piXDest, int *piYDest);
1622 
1638 void WBXlatCoordGeom(Window wIDSrc, const WB_GEOM *pGeomSrc, Window wIDDest, WB_GEOM *pGeomDest);
1639 
1655 void WBXlatCoordRect(Window wIDSrc, const WB_RECT *pRectSrc, Window wIDDest, WB_RECT *pRectDest);
1656 
1672 int WBPointInWindow(Window wIDRef, int iX, int iY, Window wIDQuery);
1673 
1674 // keyboard translation helpers
1675 
1679 #define WB_KEYEVENT_KEYSYM 8 /* bit flags for 'piAltCtrlShift' below */
1680 
1684 #define WB_KEYEVENT_ALT 4
1685 
1689 #define WB_KEYEVENT_CTRL 2
1690 
1694 #define WB_KEYEVENT_SHIFT 1
1695 
1699 #define WB_KEYEVENT_ACSMASK 7
1700 
1701 
1722 int WBKeyEventProcessKey(const XKeyEvent *pEvent, char *pBuf, int *pcbLen, int *piAltCtrlShift);
1723  // NOTE: WM_CHAR notification messages (related to WBKeyEventProcessKey)
1724  // message_type == aWM_CHAR
1725  // data.l[0] is return frmo WBKeyEventProcessKey
1726  // data.l[1] is *piAltCtrlShift from WBKeyEventProcessKey
1727  // data.l[2] is number of characters decoded into data.l[3..4]
1728  // data.l[3..4] (as char[]) is decode buffer (at least 8 chars long, possibly 16 for 64-bit)
1729 
1730 
1731 
1732 // pointer event definitions - WM_POINTER
1733 // data.l[0] is notification code (below)
1734 // data.l[1] is bitmap of mouse button state (button 1 is bit 0, button 2 is bit 1, etc.)
1735 // data.l[2] is 'WB_KEYEVENT_' mask for CTRL+ALT+SHIFT
1736 // data.l[3] is translated X coordinate
1737 // data.l[4] is translated Y coordinate
1738 
1742 #define WB_POINTER_UNSPECIFIED 0 /* possible motion or state-change notifications */
1743 
1747 #define WB_POINTER_CLICK 1
1748 
1752 #define WB_POINTER_DBLCLICK 2
1753 
1757 #define WB_POINTER_DRAG 3 /* window proc returns window ID to support drag/drop */
1758 
1762 #define WB_POINTER_DROP 4 /* may not happen if drag is canceled */
1763 
1767 #define WB_POINTER_MOVE 5 /* motion notify while dragging */
1768 
1772 #define WB_POINTER_CANCEL 6 /* reservedly any kind of cancellation, but for now, 'drag cancel' */
1773 
1777 #define WB_POINTER_SCROLLUP 7 /* scroll event, mouse button 4 */
1778 
1782 #define WB_POINTER_SCROLLDOWN 8 /* scroll event, mouse button 5 */
1783 
1787 #define WB_POINTER_BUTTON1 1 /* these are bitmasks */
1788 
1791 #define WB_POINTER_BUTTON2 2
1792 
1795 #define WB_POINTER_BUTTON3 4
1796 
1799 #define WB_POINTER_BUTTON4 8
1800 
1803 #define WB_POINTER_BUTTON5 16
1804 
1805 // (you can add multiple menus to multiple windows)
1811 void WBRegisterMenuCallback(Window wID, WBWinEvent pCallback);
1812 
1821 void WBAddMenuWindow(Window wID, Window wIDMenu);
1830 Window WBGetMenuWindow(Window wID); // returns ID of menu window assigned by above (one only)
1839 void WBRemoveMenuWindow(Window wID, Window wIDMenu);
1840 
1855 int WBIsValid(Display *pDisplay, Window wID);
1856 
1857 
1858 
1860 // _____ __ __ _____ _ _ _____ ____ //
1861 // | ____|\ \ / /| ____|| \ | ||_ _|/ ___| //
1862 // | _| \ \ / / | _| | \| | | | \___ \ //
1863 // | |___ \ V / | |___ | |\ | | | ___) | //
1864 // |_____| \_/ |_____||_| \_| |_| |____/ //
1865 // //
1867 
1868 // message loop helpers
1869 
1881 Time WBGetLastEventTime(void);
1882 
1883 
1942 int WBCheckGetEvent(Display *pDisplay, XEvent *pEvent);
1943 
1957 void WBWaitForEvent(Display *pDisplay);
1958 
1959 
1971 void WBDispatch(XEvent *pEvent);
1972 
1984 int WBAppDispatch(XEvent *pEvent);
1985 
2001 int WBWindowDispatch(Window wID, XEvent *pEvent);
2002 
2015 const char * WBEventName(int iEventID);
2016 
2034 int WBShowModal(Window wID, int bMenuSplashFlag); // modal window - returns 'EndModal' value or -1 on error
2035 
2047 void WBEndModal(Window wID, int iReturn);
2048 
2049 // client-side message queue (avoids XSendEvent)
2050 // to send a message directly use WBAppDispatch and WBWindowDispatch
2051 
2070 int WBNextEvent(Display *pDisplay, XEvent *pEvent);
2071 
2088 int WBPostEvent(Window wID, XEvent *pEvent);
2089 
2103 int WBPostPriorityEvent(Window wID, XEvent *pEvent); // like above but it goes at the beginning of the queue
2104 
2119 void WBPostDelayedEvent(XEvent *pEvent, unsigned int nDelay);
2120 
2133 int WBPostAppEvent(XEvent *pEvent);
2134 
2154 void WBPostDelayedSetFocusAppEvent(Display *pDisplay, Window wID, Window wIDFrom, unsigned int nDelay);
2155 
2172 void WBProcessExposeEvent(XExposeEvent *pEvent); // paint optimization
2173 
2174 
2175 
2177 // //
2178 // _ _ ___ _ _ _ //
2179 // | | | ||_ _| | | | | ___ | | _ __ ___ _ __ ___ //
2180 // | | | | | | | |_| | / _ \| || '_ \ / _ \| '__|/ __| //
2181 // | |_| | | | | _ || __/| || |_) || __/| | \__ \ //
2182 // \___/ |___| |_| |_| \___||_|| .__/ \___||_| |___/ //
2183 // |_| //
2184 // //
2186 
2187 
2204 void WBMouseCancel(Display *pDisplay, Window wID);
2205 
2206 
2207 
2208 
2210 // ____ _ ___ ____ ____ ___ _ ____ ____ //
2211 // / ___| | |_ _| _ \| __ ) / _ \ / \ | _ \| _ \ //
2212 // | | | | | || |_) | _ \| | | |/ _ \ | |_) | | | | //
2213 // | |___| |___ | || __/| |_) | |_| / ___ \| _ <| |_| | //
2214 // \____|_____|___|_| |____/ \___/_/ \_\_| \_\____/ //
2215 // //
2217 
2246 void * WBGetClipboardData(Display *pDisplay, Atom *paType, int *piFormat, unsigned long *pnData);
2247 
2263 int WBSetClipboardData(Display *pDisplay, Atom aType, int iFormat, const void *pData, unsigned long nData);
2264 
2265 
2266 // lower level functions for 'Selections'
2267 
2286 void * WBGetSelectionData(Display *pDisplay, Atom aSelection, Atom *paType, int *piFormat, unsigned long *pnData);
2287 
2288 
2305 int WBSetSelectionData(Display *pDisplay, Atom aSelection, Atom aType, int iFormat, const void *pData, unsigned long nData);
2306 
2307 
2308 
2309 
2311 // _____ __ __ ____ ___ ____ _ _ ____ _____ //
2312 // | ____|\ \/ /| _ \ / _ \ / ___| | | | || _ \ | ____| //
2313 // | _| \ / | |_) || | | |\___ \ | | | || |_) || _| //
2314 // | |___ / \ | __/ | |_| | ___) || |_| || _ < | |___ //
2315 // |_____|/_/\_\|_| \___/ |____/ \___/ |_| \_\|_____| //
2316 // //
2318 
2373 int WBMapWindow(Display *pDisplay, Window wID);
2386 int WBMapRaised(Display *pDisplay, Window wID);
2399 int WBUnmapWindow(Display *pDisplay, Window wID);
2400 
2415 int WBIsMapped(Display *pDisplay, Window wID); // non-zero if mapped, zero otherwise
2416  // NOTE: this only works for windows that have been registered with a callback
2417 
2418 
2419 // paint helpers (working in conjunction with 'WBProcessExposeEvent')
2420 
2436 void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintFlag);
2452 void WBInvalidateRegion(Window wID, Region rgn, int bPaintFlag);
2466 void WBValidateGeom(Window wID, const WB_GEOM *pGeom);
2480 void WBValidateRegion(Window wID, Region rgn);
2481 
2493 Region WBGetInvalidRegion(Window wID);
2494 
2508 Region WBGetPaintRegion(Window wID);
2509 
2521 Region WBRectToRegion(const WB_RECT *pRect);
2522 
2534 Region WBGeomToRegion(const WB_GEOM *pGeom);
2535 
2546 void WBUpdateWindow(Window wID); // posts an expose event for the specified window
2547 
2559 void WBUpdateWindowImmediately(Window wID); // sends expose event synchronously (can cause recursion)
2560 
2580 GC WBBeginPaint(Window wID, XExposeEvent *pEvent, WB_GEOM *pgRet); // GC has invalid region assigned
2581 
2598 GC WBBeginPaintGeom(Window wID, WB_GEOM *pgBounds); // GC has invalid region assigned
2599 
2611 void WBEndPaint(Window wID, GC gc); // frees the 'paint GC' and also resets the invalid region
2612 
2624 void WBClearWindow(Window wID, GC gc);
2625 
2626 
2627 // RECT versions (as inline)
2628 
2644 static __inline__ void WBInvalidateRect(Window wID, const WB_RECT *pRCT, int bPaintFlag)
2645 {
2646  WB_GEOM geom;
2647 
2648  if(!pRCT)
2649  {
2650  WBInvalidateGeom(wID, NULL, bPaintFlag);
2651  return;
2652  }
2653 
2654  geom.x = pRCT->left;
2655  geom.y = pRCT->top;
2656  geom.width = pRCT->right - pRCT->left;
2657  geom.height = pRCT->bottom - pRCT->top;
2658  geom.border = 0;
2659 
2660  WBInvalidateGeom(wID, &geom, bPaintFlag);
2661 }
2662 
2676 static __inline__ void WBValidateRect(Window wID, WB_RECT *pRCT)
2677 {
2678  WB_GEOM geom;
2679 
2680  if(!pRCT)
2681  {
2682  WBValidateGeom(wID, NULL);
2683  return;
2684  }
2685 
2686  geom.x = pRCT->left;
2687  geom.y = pRCT->top;
2688  geom.width = pRCT->right - pRCT->left;
2689  geom.height = pRCT->bottom - pRCT->top;
2690  geom.border = 0;
2691 
2692  WBValidateGeom(wID, &geom);
2693 }
2694 
2695 
2696 
2698 // _____ ___ __ __ _____ ____ ____ //
2699 // |_ _||_ _|| \/ || ____|| _ \ / ___| //
2700 // | | | | | |\/| || _| | |_) |\___ \ //
2701 // | | | | | | | || |___ | _ < ___) | //
2702 // |_| |___||_| |_||_____||_| \_\|____/ //
2703 // //
2705 
2733 WB_UINT64 WBGetTimeIndex(void); // returns current 'time index' (in microseconds) which never wraps around
2734  // NOTE: it is derived from the 'gettimeofday' call on BSD, Linux, etc.
2735 
2753 int CreateTimer(Display *pDisplay, Window wID, unsigned long lInterval, long lID, int iPeriodic);
2754  // NOTE: 'iPeriodic' non-zero for periodic, zero for one-shot. 'lInterval' is in microseconds
2755  // Assign 'lID' to a unique value for the specified pDisplay and wID
2756 
2771 void DeleteTimer(Display *pDisplay, Window wID, long lID); // deletes entry with matching Display, Window, ID
2772 
2773 
2774 
2775 // ****************************************************
2776 //
2777 // E R R O R H A N D L I N G
2778 //
2779 // ****************************************************
2780 
2805 typedef struct __WB_ERROR_INFO__
2806 {
2807  Display *pDisplay;
2808  const char *pFunc;
2809  int iLine;
2810  unsigned long serial;
2815 } WB_ERROR_INFO;
2816 
2817 
2818 
2828 static __inline__ void WBSupressErrorOutput(void)
2829 {
2830 extern int bIgnoreXErrors;
2831 
2832  bIgnoreXErrors++;
2833 }
2834 
2844 static __inline__ void WBAllowErrorOutput(void)
2845 {
2846 extern int bIgnoreXErrors;
2847 
2848  if(bIgnoreXErrors > 0)
2849  {
2850  bIgnoreXErrors--;
2851  }
2852  else
2853  {
2854  bIgnoreXErrors = 0;
2855  }
2856 }
2857 
2858 
2864 void WBErrorClear(void);
2865 
2877 int WBErrorCheck(void);
2878 
2891 int WBErrorCheckRetry(void);
2892 
2905 const WB_ERROR_INFO * WBGetLastError(void);
2906 
2907 
2908 
2909 #ifdef __cplusplus
2910 };
2911 #endif // __cplusplus
2912 
2913 #endif // WINDOW_HELPER_H_INCLUDED
2914 
void WBEndWaitCursor(Window wID)
decrement &#39;wait cursor&#39; count, restore to default when zero
GC WBBeginPaint(Window wID, XExposeEvent *pEvent, WB_GEOM *pgRet)
&#39;Paint&#39; helper, creates a GC for use in updating the window in an Expose event handler ...
internal wrapper struct for &#39;extent&#39; definition
unsigned long WBGetGCBGColor(Display *pDisplay, GC gc)
returns the currently assigned background color for a GC
const Atom aPRIMARY
Atoms for the clipboard.
void WBSetWMProtocols(Window wID, Atom aProperty,...)
re-assign standard WM (Window Manager) &#39;window type&#39; properties and notify the root window (reserved)...
static __inline__ void WBValidateRect(Window wID, WB_RECT *pRCT)
&#39;Paint&#39; helper, validates a WB_RECT for asynchronous Expose event generation
const Atom aCOMPOUND_TEXT
Atoms for the clipboard.
const Atom aSECONDARY
Atoms for the clipboard.
static __inline__ Display * WBGetDefaultDisplay(void)
Returns the default Display.
void WBAddMenuWindow(Window wID, Window wIDMenu)
Add a MENU WINDOW to a (frame) window - more than one is possible, only one currently supported...
void WBGetWindowGeom(Window wID, WB_GEOM *pGeom)
Returns the RAW geometry of the window as reported by the window manager.
2nd parameter (direction) - bottom, end
1st parameter (bar) - The horizontal scroll bar for the control or window
unsigned long serial
serial number from XErrorEvent
void WBSetWindowFontSet(Window wID, XFontSet fontSet)
assigns the default XFontSet to a window
2nd parameter (direction) - down, right
static __inline__ Colormap WBDefaultColormap(Display *pDisplay)
returns the default colormap for the default screen of the specified display
void * WBGetWindowData(Window wID, int iIndex)
Gets the data associated with this window and the specified index.
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 ...
int error_code
error code from XErrorEvent
int minor_code
minor code from XErrorEvent
int WBKeyEventProcessKey(const XKeyEvent *pEvent, char *pBuf, int *pcbLen, int *piAltCtrlShift)
Generic keyboard event translation utility.
const Atom aMULTIPLE
Atoms for the clipboard.
int WBUnmapWindow(Display *pDisplay, Window wID)
wrapper for XUnmapWindow, makes window invisible without destroying it
void WBXlatCoordRect(Window wIDSrc, const WB_RECT *pRectSrc, Window wIDDest, WB_RECT *pRectDest)
Translate rectangle coordinates relative to a window.
const Atom aSCROLLBAR_NOTIFY
notification of window scrollbar position/range changes via ClientMessage
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...
1st parameter (bar) - The vertical scroll bar for the control or window.
GC WBGetWindowCopyGC(Window wID)
makes a copy of the default GC so that it can be modified
Display * WBThreadInitDisplay(void)
initializes default Display for a thread (must call WBInit() first)
void WBExit(void)
deletes any remaining global objects, frees the Display pointer, and terminates event processing ...
static __inline__ void WBSupressErrorOutput(void)
Supress X11 XErrorEvent output to stderr.
void WBWaitForEvent(Display *pDisplay)
Wait for an event, blocking indefinitely.
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)
GC WBCopyDrawableGC(Display *pDisplay, Drawable dw, GC gcSrc)
makes a copy of the specified GC for the desired &#39;Drawable&#39;
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&#39;s class name pointer.
void WBSetParentWindow(Window wID, Window wIDParent)
Assigns the parent to the specified window within the internal structure.
int WBShowModal(Window wID, int bMenuSplashFlag)
Shows a &#39;modal&#39; window by processing events until the window closes.
Window WBLocateWindow(WBLocateWindowCallback callback, void *pData)
Locate a window by enumerating with a callback function.
void WBGetWindowRect(Window wID, WB_RECT *pRect)
Returns the WB_RECT (rectangle) defined by the window&#39;s geometry, including the border area...
const Atom aQUERY_CLOSE
query if it&#39;s ok to close (and optionally destroy yourself if ok) a window
Window WBGetHiddenHelperWindow(void)
Returns a special &#39;hidden&#39; window used for information purposes.
const Atom aINCR
Atoms for the clipboard.
const Atom aMENU_UI_COMMAND
UI notifications sent by menus to owning Frame windows via ClientMessage using &#39;WBWindowDispatch&#39;.
Definition file for font helper functions and structures.
const char * GetStartupDisplayName(void)
returns character name of the display to be opened and passed to WBInit
int WBWindowDispatch(Window wID, XEvent *pEvent)
Dispatches a window XEvent. May be called directly.
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...
GC WBBeginPaintGeom(Window wID, WB_GEOM *pgBounds)
&#39;Paint&#39; helper, creates a GC for use in updating the window for a specified rectangular area ...
int WBSetSelectionData(Display *pDisplay, Atom aSelection, Atom aType, int iFormat, const void *pData, unsigned long nData)
Get clipboard data of requested type.
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.
void WBSetWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmProp)
assign standard WM (Window Manager) &#39;window type&#39; properties BEFORE mapping it (reserved) ...
const Atom aWM_TIMER
timer notifications generated by API
unsigned int border
const Atom aWM_DELETE_WINDOW
Delete Window notification event.
const Atom aWM_PROTOCOLS
WM supported protocols.
const Atom aWM_CHAR
keystroke/character notifications generated by API
void WBUpdateWindowImmediately(Window wID)
&#39;Paint&#39; helper, generates an immediate Expose event for non-empty &#39;invalid&#39; region ...
int WBPostPriorityEvent(Window wID, XEvent *pEvent)
Places a copy of the specified event at the end of the priority (internal) event queue.
2nd parameter (direction) - pgup, pgleft
WMPropertiesWindowType
Window type enumeration. Reserved for future implementation.
Window WBGetApplicationWindow(void)
Destroy a window.
unsigned long long WB_UINT64
Platform abstract unsigned 64-bit integer.
int iLine
Line number of the function as assigned by BEGIN_XCALL_DEBUG_WRAPPER.
const Atom aTIMESTAMP
Atoms for the clipboard.
void WBInvalidateRegion(Window wID, Region rgn, int bPaintFlag)
&#39;Paint&#39; helper, invalidates a region for asynchronous Expose event generation
const Atom aDRAWABLE
Atoms for the clipboard.
struct _WBGeom_ WB_GEOM
internal wrapper struct for X11 &#39;geometry&#39; definition
int WBSetClipboardData(Display *pDisplay, Atom aType, int iFormat, const void *pData, unsigned long nData)
Get clipboard data of requested type.
void WBSetWindowCursor(Window wID, int idCursor)
immediately set the window cursor
WMPropertiesWMProtocols
Window WMProtocols support enumeration.
2nd parameter (direction) - up, left
void WBRegisterWindowCallback(Window wID, WBWinEvent pCallback)
register callback function for a window (required)
const Atom aMANAGER
Atoms for the clipboard.
void WBSetWindowFontStruct(Window wID, XFontStruct *pFontStruct)
assigns the default XFontStruct to a window
int(* WBAppEvent)(XEvent *pEvent)
event callback function type for application events
Structure definition for X11 error information.
const Atom aPIXEL
Atoms for the clipboard.
void DeleteTimer(Display *pDisplay, Window wID, long lID)
Deletes an existing timer&#39;s resources.
void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintFlag)
&#39;Paint&#39; helper, invalidates a geometry for asynchronous Expose event generation
const Atom aSET_FOCUS
dialog focus messages
unsigned int width
the &#39;width&#39; value of the extent.
int y
the &#39;y&#39; value of the point. can be negative.
void WBClearWindow(Window wID, GC gc)
&#39;Paint&#39; helper, erases background by painting the background color within the clipping region ...
Region WBGetPaintRegion(Window wID)
&#39;Paint&#39; helper, returns a copy of the current &#39;paint&#39; region for the window
void WBCreateWindowDefaultGC(Window wID, unsigned long clrFG, unsigned long clrBG)
creates a default GC for a window
Region WBRectToRegion(const WB_RECT *pRect)
&#39;Paint&#39; helper, converts a WB_RECT structure to a Region.
const char * pFunc
Name of the function as assigned by BEGIN_XCALL_DEBUG_WRAPPER.
unsigned long WBGetWindowFGColor(Window wID)
Returns the currently assigned foreground color.
void WBSetApplicationWindow(Window wID)
Destroy a window.
const Atom aWINDOW
Atoms for the clipboard.
const Atom aAVERAGE_WIDTH
Atoms for fonts - Average Character Width.
unsigned int width
Window WBGetParentWindow(Window wID)
Returns the window&#39;s parent (or None if there is no parent)
int WBIsValid(Display *pDisplay, Window wID)
returns non-zero if &#39;valid&#39; (i.e. &#39;not destroyed&#39;)
void WBSetWindowDefaultCursor(Window wID, int idStandardCursor)
Assigns a default cursor (by ID) to a window.
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)
&#39;Paint&#39; helper, validates a geometry for asynchronous Expose event generation
unsigned int height
Region WBGetInvalidRegion(Window wID)
&#39;Paint&#39; 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 WBGetMenuWindow(Window wID)
Returns the Window ID of the (first) menu window assigned to a (frame) window.
struct _WBExtent_ WB_EXTENT
internal wrapper struct for &#39;extent&#39; definition
void WBRestoreDefaultCursor(Window wID)
restore the default cursor
unsigned long WBGetWindowBGColor(Window wID)
Returns the currently assigned background color.
int WBAppDispatch(XEvent *pEvent)
Dispatches an application XEvent. May be called directly.
const Atom aDLG_FOCUS
dialog focus messages
static __inline__ void WBInvalidateRect(Window wID, const WB_RECT *pRCT, int bPaintFlag)
&#39;Paint&#39; 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.
int WBMapRaised(Display *pDisplay, Window wID)
wrapper for XMapRaised, makes window visible and moves to top
void WBDestroyWindow(Window wID)
Destroy a window.
struct _WBPoint_ WB_POINT
internal wrapper struct for &#39;point&#39; definition
Display * pDisplay
Display pointer passed into error handler function (NULL if no error)
void WBSetWindowDefaultGC(Window wID, GC hGC)
assigns a default GC to a window
void * WBGetSelectionData(Display *pDisplay, Atom aSelection, Atom *paType, int *piFormat, unsigned long *pnData)
Get clipboard data of requested type.
2nd parameter (direction) - &#39;knob track&#39; - pos in data.l[2]
void WBUpdateWindow(Window wID)
&#39;Paint&#39; helper, generates an asynchronous Expose event for non-empty &#39;invalid&#39; region ...
void WBSetWindowIcon(Window wID, int idIcon)
assigns an icon resource (by ID) to a window
const Atom aSCROLL_NOTIFY
2nd parameter (direction) - relative scroll - rel pos in data.l[2]
const Atom aRESIZE_NOTIFY
notification of window re-size via ClientMessage
1st parameter (bar) - &#39;Default Bar&#39;, currently not implemented, probably won&#39;t be used ...
XID resourceid
resource ID (usually a Window) from XErrorEvent
void WBXlatCoordGeom(Window wIDSrc, const WB_GEOM *pGeomSrc, Window wIDDest, WB_GEOM *pGeomDest)
Translate geometry coordinates relative to a window.
const Atom aCLIPBOARD
Atoms for the clipboard.
void WBXlatCoordPoint(Window wIDSrc, int iXSrc, int iYSrc, Window wIDDest, int *piXDest, int *piYDest)
Translate X,Y point coordinates relative to a window.
int WBIsChildWindow(Window wIDParent, Window wIDChild)
Returns non-zero if wIDParent is in a parent relationsihp with wIDChild.
internal wrapper struct for &#39;rectangle&#39; definition
2nd parameter (direction) - home, top
int WBInitDisplay(Display *pDisplay)
initializes default objects for the specified Display
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
void WBUnregisterWindowCallback(Window wID)
un-register the window&#39;s callback function (implies resource destruction)
void WBErrorClear(void)
Clear the &#39;last error&#39; information obtained via WBGetLastError()
const char * sz_xcall_func
debug helper variable tracking the function calling into the X11 library
Definition: window_helper.c:95
int(* WBWinEvent)(Window wID, XEvent *pEvent)
event callback function type for window events
2nd parameter (direction) - pgdn, pgright
enum WMPropertiesWindowType WBGetWMPropertiesWindowType(Window wID)
re-assign standard WM (Window Manager) &#39;window type&#39; properties and notify the root window (reserved)...
const Atom aWM_POINTER
pointer click/double-click/drag notifications generated by API
const Atom aWM_TAKE_FOCUS
&#39;Take Focus&#39; - TODO document this properly
int WBReparentWindow(Window wID, Window wIDParent, int iX, int iY)
Assigns a new parent to the specified window (aka &#39;Re-parent&#39;)
generic &#39;NA&#39; or &#39;UNDEFINED&#39; value
const Atom aPIXMAP
Atoms for the clipboard.
void WBMouseCancel(Display *pDisplay, Window wID)
low-level event processing, internal handling of Expose events
const char * WBGetWindowClassName(Window wID)
Returns the window&#39;s assigned class name pointer.
int WBAppDefault(XEvent *pEvent)
implements the default application event callback behavior
const Atom aMENU_COMMAND
commands sent by menus via ClientMessage
int(* WBLocateWindowCallback)(Window wID, void *pData)
callback definition for WBLocateWindow
int WBErrorCheckRetry(void)
Check to see whether or not an X11 error was detected AND can be re-tried.
XFontStruct * WBGetDefaultFont(void)
Returns a pointer to the default font&#39;s XFontStruct.
int WBErrorCheck(void)
Check to see whether or not an X11 error was detected.
int request_code
request code from XErrorEvent
Display * WBGetWindowDisplay(Window wID)
returns the Display associated with a window
int WBInitClipboardSystem(Display *pDisplay, const char *szDisplayName)
initializes clipboard sub-system
const Atom aRECALC_LAYOUT
notify window that it should re-calculate things like scrollbars and viewports
struct __WB_ERROR_INFO__ WB_ERROR_INFO
Structure definition for X11 error information.
void WBSetWindowData(Window wID, int iIndex, void *pData)
assign &#39;data pointer&#39; for a window and specified index value
XFontStruct * WBGetGCFont(Display *pDisplay, GC gc)
return a copy of the XFontStruct that was assigned to a GC
struct _WBRect_ WB_RECT
internal wrapper struct for &#39;rectangle&#39; definition
const Atom aTARGETS
Atoms for the clipboard.
internal wrapper struct for &#39;point&#39; definition
const Atom aTARGET
Atoms for the clipboard.
void WBRegisterAppCallback(WBAppEvent pCallback)
Registers a callback function for application events.
void WBThreadFreeDisplay(Display *pThreadDisplay)
un-initializes a Display for a thread that was allocated by WBThreadInitDisplay() ...
GC WBGetWindowDefaultGC(Window wID)
Returns the default GC currently assigned to the window.
const Atom aCONTROL_NOTIFY
dialog control and child window notification messages
void WBSetInputFocus(Window wID)
set input focus to a specific window
void WBBeginWaitCursor(Window wID)
increment &#39;wait cursor&#39; count, set cursor to WB_WAIT_CURSOR
const Atom aCOLORMAP
Atoms for the clipboard.
const Atom aBITMAP
Atoms for the clipboard.
void WBRegisterMenuCallback(Window wID, WBWinEvent pCallback)
(internal) Register a MENU callback for a window
Region WBGeomToRegion(const WB_GEOM *pGeom)
&#39;Paint&#39; helper, converts a WB_GEOM structure to a Region.
Window WBCreateWindow(Display *pDisplay, Window wIDParent, WBWinEvent pProc, const char *szClass, int iX, int iY, int iWidth, int iHeight, int iBorder, int iIO, int iFlags, XSetWindowAttributes *pXSWA)
Create a window.
unsigned long WBGetGCFGColor(Display *pDisplay, GC gc)
returns the currently assigned foreground color for a GC
void WBGetClientRect(Window wID, WB_RECT *pRect)
Returns the WB_RECT (rectangle) defined by the window&#39;s geometry, excluding the border area...
const Atom aDESTROY_NOTIFY
notify parent that child is being destroyed
int WBDefault(Window wID, XEvent *pEvent)
implements the default window event callback behavior
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 iReturn)
End a modal window with a specific return value.
void WBSetWMProperties(Window wID, const char *szTitle, XSizeHints *pNormalHints, XWMHints *pWMHints, XClassHint *pClassHints)
assign standard WM (Window Manager) properties via XSetWMProperties
int GetStartupMinMax(void)
returns the min/max/normal window state for startup
unsigned int height
the &#39;height&#39; value of the extent.
int WBGetWindowDefaultCursor(Window wID)
returns the default cursor ID for a window
Definition file for platform-specific utility functions.
XFontSet WBGetWindowFontSet(Window wID)
Returns the current XFontSet assigned to the window (may be None)
const Atom aNULL
Atoms for the clipboard.
void * WBGetClipboardData(Display *pDisplay, Atom *paType, int *piFormat, unsigned long *pnData)
Get clipboard data of requested type.
void WBSetWindowTitle(Window wID, const char *szTitle)
assign window (and icon) title
const Atom aTEXT
Atoms for the clipboard.
void WBGetWindowGeom0(Window wID, WB_GEOM *pGeom)
Returns the ABSOLUTE window geometry relative the screen.
Time WBGetLastEventTime(void)
Main message loop, high level API to check for and retrieve the next event.
XFontStruct * WBGetWindowFontStruct(Window wID)
Returns the current XFontStruct pointer assigned to the window (may be NULL)
const Atom aC_STRING
Atoms for the clipboard.
void WBChangeWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmPropSet, enum WMPropertiesWindowType wmChangeMask)
re-assign standard WM (Window Manager) &#39;window type&#39; properties and notify the root window (reserved)...
int WBMapWindow(Display *pDisplay, Window wID)
Wrapper for XMapWindow, makes window visible.
internal wrapper struct for X11 &#39;geometry&#39; definition
2nd parameter (direction) - double-clicked item (no selection change info) (sent to list control&#39;s ow...
void WBEndPaint(Window wID, GC gc)
&#39;Paint&#39; helper, frees resources and marks the update region &#39;valid&#39;
const Atom aSTRING
Atoms for the clipboard.
int x
the &#39;x&#39; value of the point. can be negative.
void WBExitClipboardSystem(Display *pDisplay)
Shut down the clipboard sub-system.
WB_UINT64 WBGetTimeIndex(void)
Returns the current &#39;time index&#39; (in microseconds)
XFontSet WBGetDefaultFontSet(Display *pDisplay)
Returns an XFontSet for the default font.
void WBValidateRegion(Window wID, Region rgn)
&#39;Paint&#39; helper, validates a region for asynchronous Expose event generation
void WBGetWindowGeom2(Window wID, WB_GEOM *pGeom)
Returns the geometry of the window relative to the root window.
const Atom aUTF8_STRING
Atoms for the clipboard.
int i_xcall_line
debug helper variable indicating the line number of the function calling into the X11 library ...
Definition: window_helper.c:96
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.
2nd parameter (direction) - absolute scroll - pos in data.l[2]
void WBPostDelayedSetFocusAppEvent(Display *pDisplay, Window wID, Window wIDFrom, unsigned int nDelay)
Creates a &#39;set focus&#39; ClientMessage event for the application event handler.