X11workbench 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-2018 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-2018 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 // window helpers - defines manager for callback procs, font, GC, and a generic event dispatcher
82 
83 #ifndef WINDOW_HELPER_H_INCLUDED
84 #define WINDOW_HELPER_H_INCLUDED
85 
86 // headers that must be included or I break
87 
88 #include <string.h> // for memset, mostly
89 
90 #include "platform_helper.h"
91 #include "debug_helper.h"
92 #include "font_helper.h"
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif // __cplusplus
97 
101 #define WB_DEFAULT_CURSOR XC_left_ptr
102 
105 #define WB_WAIT_CURSOR XC_watch /*XC_clock*/
106 
109 #define WB_DEFAULT_FONT "fixed"
110 
113 #define WB_DEFAULT_FONT_SIZE 13 /* override via settings */
114 
117 #define WINDOW_DATA_SIZE 4 /* size of a 'void *' array that stores per-window data */
118 
122 #define EVENT_ALL_MASK 0x01ffffffL /* 2^24 | 2^23 ... 2^0 - see X.h */
123 
124 
128 #define GCAll (GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | \
129  GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | \
130  GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont | \
131  GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin | \
132  GCClipMask | GCDashOffset | GCDashList | GCArcMode)
133 
134 
135 
136 // debug helpers (may be eliminated at some point)
137 
141 extern const char *sz_xcall_func;
145 extern int i_xcall_line;
150 #define BEGIN_XCALL_DEBUG_WRAPPER { const char *__szOldXCallFunc__ = sz_xcall_func; int __iOldXCallLine__ = i_xcall_line; sz_xcall_func = __FUNCTION__; i_xcall_line = __LINE__; {
151 
155 #define END_XCALL_DEBUG_WRAPPER } sz_xcall_func = __szOldXCallFunc__; i_xcall_line = __iOldXCallLine__; }
156 
157 
170 typedef int (* WBWinEvent)(Window wID, XEvent *pEvent);
182 typedef int (* WBAppEvent)(XEvent *pEvent);
183 
184 
186 // //
187 // ____ ____ _ _ //
188 // / ___| ___ _ __ ___ / ___| | |_ _ __ _ _ ___ | |_ _ _ _ __ ___ ___ //
189 // | | / _ \ | '__|/ _ \ \___ \ | __|| '__|| | | | / __|| __|| | | || '__|/ _ \/ __| //
190 // | |___| (_) || | | __/ ___) || |_ | | | |_| || (__ | |_ | |_| || | | __/\__ \ //
191 // \____|\___/ |_| \___| |____/ \__||_| \__,_| \___| \__| \__,_||_| \___||___/ //
192 // //
193 // //
195 
196 
235 typedef struct _WBPoint_
236 {
237  int x;
238  int y;
239 } WB_POINT;
240 
265 typedef struct _WBExtent_
266 {
267  unsigned int width;
268  unsigned int height;
269 } WB_EXTENT;
270 
306 typedef struct _WBRect_
307 {
308  int left;
309  int top;
310  int right;
311  int bottom;
312 } WB_RECT;
313 
352 typedef struct _WBGeom_
353 {
354  int x;
355  int y;
356  unsigned int width;
357  unsigned int height;
358  unsigned int border;
359 } WB_GEOM;
360 
361 
362 
364 // //
365 // ____ _ _ _ _ ____ _ _ _ //
366 // / ___| | |_ __ _ _ __ | |_ _ _ _ __ / \ _ __ __| | / ___| | |__ _ _ | |_ __| | ___ __ __ _ __ //
367 // \___ \ | __|/ _` || '__|| __|| | | || '_ \ / _ \ | '_ \ / _` | \___ \ | '_ \ | | | || __|/ _` | / _ \\ \ /\ / /| '_ \ //
368 // ___) || |_| (_| || | | |_ | |_| || |_) | / ___ \ | | | || (_| | ___) || | | || |_| || |_| (_| || (_) |\ V V / | | | | //
369 // |____/ \__|\__,_||_| \__| \__,_|| .__/ /_/ \_\|_| |_| \__,_| |____/ |_| |_| \__,_| \__|\__,_| \___/ \_/\_/ |_| |_| //
370 // |_| //
371 // //
373 
374 
376 // window-specific initialization
378 
393 Display *WBInit(const char *szDisplayName);
394 
411 int WBInitDisplay(Display *pDisplay);
412 
431 int WBInitClipboardSystem(Display *pDisplay, const char *szDisplayName);
432 
442 void WBExit(void);
443 
451 void WBExitClipboardSystem(Display *pDisplay);
452 
464 Display *WBThreadInitDisplay(void);
465 
476 void WBThreadFreeDisplay(Display *pThreadDisplay);
477 
478 
489 const char *GetStartupDisplayName(void);
490 
500 void GetStartupGeometry(WB_GEOM *pGeom);
509 int GetStartupMinMax(void);
510 
519 static __inline__ Colormap WBDefaultColormap(Display *pDisplay)
520 {
521  return DefaultColormap(pDisplay, DefaultScreen(pDisplay));
522 }
523 
539 void WBInitWindowAttributes(XSetWindowAttributes *pXSWA, unsigned long lBorderPixel,
540  unsigned long lBackgroundPixel, Colormap clrMap, int iBitGravity);
541 
557 void WBInitSizeHints(XSizeHints *pSH, Display *pDisplay, int iMinHeight, int iMinWidth);
558 
559 
560 
562 // ____ _____ _____ _ _ _ _ _____ ____ //
563 // | _ \ | ____|| ___|/ \ | | | || | |_ _|/ ___| //
564 // | | | || _| | |_ / _ \ | | | || | | | \___ \ //
565 // | |_| || |___ | _|/ ___ \| |_| || |___ | | ___) | //
566 // |____/ |_____||_| /_/ \_\\___/ |_____||_| |____/ //
567 // //
569 
581 static __inline__ Display * WBGetDefaultDisplay(void)
582 {
583  extern Display *pDefaultDisplay;
584  return pDefaultDisplay;
585 }
586 
599 XFontStruct *WBGetDefaultFont(void);
600 
614 XFontSet WBGetDefaultFontSet(Display *pDisplay);
615 
625 Window WBGetHiddenHelperWindow(void); // if you need "a window" for the default display, use this
626 
627 
628 
629 
631 // ____ _ ___ ____ _ _ _ _____ ___ __ __ ____ //
632 // / ___|| | / _ \ | __ ) / \ | | / \ |_ _|/ _ \ | \/ |/ ___| //
633 // | | _ | | | | | || _ \ / _ \ | | / _ \ | | | | | || |\/| |\___ \ //
634 // | |_| || |___| |_| || |_) |/ ___ \ | |___ / ___ \ | | | |_| || | | | ___) | //
635 // \____||_____|\___/ |____//_/ \_\|_____| /_/ \_\|_| \___/ |_| |_||____/ //
636 // //
638 
639 // global atoms (for convenience they are referenced directly via global variables)
640 
641 #if !defined(_WINDOW_HELPER_C_) && !defined(_CLIPBOARD_HELPER_C)
642  /* this declares the atoms 'const' outside of window_helper.c, and does NOT declare them in clipboard_helper.c */
643  /* These atoms are GLOBAL variables, assigned by the DEFAULT Display, and may not work for other threads. */
644 extern const Atom aMENU_COMMAND; // commands sent by menus via ClientMessage
645 extern const Atom aMENU_UI_COMMAND; // UI notification sent by menus to owning frame windows via ClientMessage using WBWindowDispatch
646 extern const Atom aRESIZE_NOTIFY; // notification of window re-size via ClientMessage
647 extern const Atom aDESTROY_NOTIFY; // notify parent that child is being destroyed
648 extern const Atom aCONTROL_NOTIFY; // dialog control and child window notification messages
649  // l[0] contains control ID or -1, l[1] is notify code, l[2] is window ID
650 extern const Atom aSCROLL_NOTIFY; // specific notification for scrollbars (see enumeration, below)
651  // data.l[0] is scrollbar enum, data.l[1] is notification enum, data.l[2] is optional position modifier
652 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
653 extern const Atom aRECALC_LAYOUT; // notify window that it should re-calculate things like scrollbars and viewports
654 
655 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
656 extern const Atom aSET_FOCUS; // 'set focus' messages (send/post to application)
657 extern const Atom aWB_CHAR; // character notifications (generated by API; avoids key up/down handling)
658 extern const Atom aWB_TIMER; // timer notifications (generated by API)
659 extern const Atom aWB_POINTER; // pointer notifications (generated by API)
660 
661 // things used by window managers
662 extern const Atom aWM_PROTOCOLS; // WM supported protocols (see 'freedesktop.org' WM docs)
663 extern const Atom aWM_DELETE_WINDOW; // WM command to delete a window (a click on the 'x')
664 extern const Atom aWM_TAKE_FOCUS; // WM protocol (part of WM_PROTOCOLS spec, ICCCM, assoc with focus bit in WM_HINTS)
665 
666 // things used by fonts
667 extern const Atom aAVERAGE_WIDTH; // Average Character Width (font property)
668 
669 // things used by the clipboard
670 extern const Atom aCLIPBOARD; // Atom for 'CLIPBOARD'
671 extern const Atom aPRIMARY; // Atom for 'PRIMARY'
672 extern const Atom aSECONDARY; // Atom for 'SECONDARY'
673 extern const Atom aMANAGER; // Atom for 'MANAGER'
674 extern const Atom aTARGET; // Atom for 'TARGET'
675 extern const Atom aINCR; // Atom for 'INCR' (incremental transfers)
676 extern const Atom aWINDOW; // Atom for 'WINDOW'
677 extern const Atom aBITMAP; // Atom for 'BITMAP'
678 extern const Atom aDRAWABLE; // Atom for 'DRAWABLE'
679 extern const Atom aCOLORMAP; // Atom for 'COLORMAP'
680 extern const Atom aPIXEL; // Atom for 'PIXEL'
681 extern const Atom aPIXMAP; // Atom for 'PIXMAP'
682 extern const Atom aTEXT; // Atom for 'TEXT'
683 extern const Atom aSTRING; // Atom for 'STRING'
684 extern const Atom aUTF8_STRING; // Atom for 'UTF8_STRING'
685 extern const Atom aC_STRING; // Atom for 'C_STRING'
686 extern const Atom aCOMPOUND_TEXT; // Atom for 'COMPOUND_TEXT'
687 extern const Atom aTARGETS; // Atom for 'TARGETS'
688 extern const Atom aMULTIPLE; // Atom for 'MULTIPLE'
689 extern const Atom aTIMESTAMP; // Atom for 'TIMESTAMP'
690 extern const Atom aNULL; // Atom for 'NULL'
691 #endif // !_WINDOW_HELPER_C, !_CLIPBOARD_HELPER_C
692 
693 
694 
695 // parameter enumerations for aSCROLL_NOTIFY ClientMessage
696 
705 {
709 
717 
719 
722 
723  WB_SCROLL_NA = 0x80000000
724 };
725 
726 
727 
728 
729 
730 
731 
733 // ____ ___ ____ _____ _ ____ ___ //
734 // / ___|/ _ \ | _ \ | ____| / \ | _ \|_ _| //
735 // | | | | | || |_) || _| / _ \ | |_) || | //
736 // | |___| |_| || _ < | |___ / ___ \ | __/ | | //
737 // \____|\___/ |_| \_\|_____| /_/ \_\|_| |___| //
738 // //
740 
747 #define WB_STANDARD_INPUT_MASK (FocusChangeMask | PropertyChangeMask | ExposureMask | StructureNotifyMask | VisibilityChangeMask | SubstructureNotifyMask)
748 
755 #define WB_KEYBOARD_INPUT_MASK (KeyPressMask | KeyReleaseMask)
756 
763 #define WB_MOUSE_INPUT_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask)
764 
765 
773 {
774  // must be ONLY ONE of the items below
775  WMPropertiesWindowType_TypeMask = 0x3f,
776  WMPropertiesWindowType_Normal = 0,
777  WMPropertiesWindowType_Desktop = 1,
778  WMPropertiesWindowType_Dock = 2,
779  WMPropertiesWindowType_ToolBar = 3,
780  WMPropertiesWindowType_Menu = 4,
781  WMPropertiesWindowType_Utility = 5,
782  WMPropertiesWindowType_Splash = 6,
783  WMPropertiesWindowType_Dialog = 7,
784  WMPropertiesWindowType_DropDownMenu = 8,
785  WMPropertiesWindowType_PopupMenu = 9,
786  WMPropertiesWindowType_ToolTip = 10,
787  WMPropertiesWindowType_Notification = 11,
788  WMPropertiesWindowType_Combo = 12,
789  WMPropertiesWindowType_Drag_N_Drop = 13,
790  WMPropertiesWindowType_Reserved14 = 14,
791  WMPropertiesWindowType_Reserved15 = 15,
792 
793 
794  // may be A COMBINATION of the items below
795  WMPropertiesWindowType_StateMask = 0xfffC0,
796 
797  WMPropertiesWindowType_NoState = 0,
798  WMPropertiesWindowType_Modal = 0x00040,
799  WMPropertiesWindowType_Sticky = 0x00080,
800  WMPropertiesWindowType_VMax = 0x00100,
801  WMPropertiesWindowType_HMax = 0x00200,
802  WMPropertiesWindowType_FullScreen = 0x00400,
803  WMPropertiesWindowType_Hidden = 0x00800,
804  WMPropertiesWindowType_Shaded = 0x01000,
805  WMPropertiesWindowType_SkipTaskbar = 0x02000,
806  WMPropertiesWindowType_SkipPager = 0x04000,
807  WMPropertiesWindowType_Above = 0x08000,
808  WMPropertiesWindowType_Below = 0x10000,
809  WMPropertiesWindowType_Focused = 0x20000,
810  WMPropertiesWindowType_DemandsAttention = 0x40000,
811  WMPropertiesWindowType_Reserved80000 = 0x80000,
812 
813 
814  // TODO: other stuff
815 
816  WMPropertiesWindowType_Max = 0x80000000
817 };
818 
826 {
827  // The following flags indicate WM_PROTOCOLS support
828  // Assigning these directly can have unexpected consequences
829  WMPropertiesWMProtocols_Mask = 0xff,
830  WMPropertiesWMProtocols_None = 0x0, // the default
831  WMPropertiesWMProtocols_DeleteWindow = 0x01,
832  WMPropertiesWMProtocols_Reserved2 = 0x02,
833  WMPropertiesWMProtocols_Reserved3 = 0x04,
834  WMPropertiesWMProtocols_Reserved4 = 0x08,
835  WMPropertiesWMProtocols_Reserved5 = 0x10,
836  WMPropertiesWMProtocols_Reserved6 = 0x20,
837  WMPropertiesWMProtocols_Reserved7 = 0x40,
838  WMPropertiesWMProtocols_Reserved8 = 0x80,
839 };
840 
841 
842 
868 Window WBCreateWindow(Display *pDisplay, Window wIDParent,
869  WBWinEvent pProc, const char *szClass,
870  int iX, int iY, int iWidth, int iHeight, int iBorder, int iIO,
871  int iFlags, XSetWindowAttributes *pXSWA);
872 
880 void WBDestroyWindow(Window wID);
881 
892 Window WBGetApplicationWindow(void);
893 
906 void WBSetApplicationWindow(Window wID);
907 
913 int WBDefault(Window wID, XEvent *pEvent);
914 
920 int WBAppDefault(XEvent *pEvent);
921 
931 void WBRegisterAppCallback(WBAppEvent pCallback);
932 
939 
945 void WBRegisterWindowCallback(Window wID, WBWinEvent pCallback);
946 
952 void WBUnregisterWindowCallback(Window wID);
953 
965 void WBSetWMProperties(Window wID, const char *szTitle, XSizeHints *pNormalHints,
966  XWMHints *pWMHints, XClassHint *pClassHints);
975 void WBSetWindowTitle(Window wID, const char *szTitle);
976 
988 void WBSetWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmProp);
989 
1002 void WBChangeWMPropertiesWindowType(Window wID, enum WMPropertiesWindowType wmPropSet, enum WMPropertiesWindowType wmChangeMask);
1003 
1004 
1016 
1030 void WBSetWMProtocols(Window wID, Atom aProperty, ...);
1031 
1032 
1042 typedef int (*WBLocateWindowCallback)(Window wID, void *pData);
1043 
1063 Window WBLocateWindow(WBLocateWindowCallback callback, void *pData);
1064 
1075 void WBSetInputFocus(Window wID);
1076 
1085 Display * WBGetWindowDisplay(Window wID);
1086 
1095 void WBSetWindowIcon(Window wID, int idIcon);
1096 
1105 void WBSetWindowFontStruct(Window wID, XFontStruct *pFontStruct);
1106 
1115 void WBSetWindowFontSet(Window wID, XFontSet fontSet);
1116 
1125 void WBSetWindowDefaultCursor(Window wID, int idStandardCursor);
1126 
1135 int WBGetWindowDefaultCursor(Window wID);
1136 
1146 void WBCreateWindowDefaultGC(Window wID, unsigned long clrFG, unsigned long clrBG);
1147 
1156 void WBSetWindowDefaultGC(Window wID, GC hGC);
1157 
1166 GC WBGetWindowCopyGC(Window wID);
1167 
1180 #define WBGetWindowCopyGC2(wID, gcSrc) WBCopyDrawableGC(WBGetWindowDisplay(wID), wID, gcSrc)
1181 
1195 GC WBCopyDrawableGC(Display *pDisplay, Drawable dw, GC gcSrc);
1196 
1211 XFontStruct * WBGetGCFont(Display *pDisplay, GC gc);
1212 
1222 void WBSetWindowData(Window wID, int iIndex, void *pData);
1223 
1231 void WBBeginWaitCursor(Window wID);
1232 
1240 void WBEndWaitCursor(Window wID);
1241 
1250 void WBSetWindowCursor(Window wID, int idCursor);
1251 
1259 void WBRestoreDefaultCursor(Window wID);
1260 
1277 GC WBGetWindowDefaultGC(Window wID);
1278 
1287 XFontStruct *WBGetWindowFontStruct(Window wID);
1288 
1297 XFontSet WBGetWindowFontSet(Window wID);
1298 
1307 unsigned long WBGetWindowFGColor(Window wID);
1308 
1317 unsigned long WBGetWindowBGColor(Window wID);
1318 
1331 unsigned long WBGetGCFGColor(Display *pDisplay, GC gc);
1332 
1345 unsigned long WBGetGCBGColor(Display *pDisplay, GC gc);
1346 
1367 void WBDefaultStandardColormap(Display *pDisplay, XStandardColormap *pMap);
1368 
1382 void WBSetWindowClassName(Window wID, const char *szClassName);
1383 
1396 const char *WBGetWindowClassName(Window wID);
1397 
1414 void *WBGetWindowData(Window wID, int iIndex);
1415 
1424 void WBGetWindowGeom(Window wID, WB_GEOM *pGeom);
1425 
1434 void WBGetWindowGeom2(Window wID, WB_GEOM *pGeom);
1435 
1436 
1454 void WBGetWindowGeom0(Window wID, WB_GEOM *pGeom); // absolute window geometry (from latest notification)
1455 
1464 void WBGetWindowRect(Window wID, WB_RECT *pRect);
1465 
1474 void WBGetClientRect(Window wID, WB_RECT *pRect);
1475 
1476 
1485 Window WBGetParentWindow(Window wID);
1486 
1487 
1502 void WBSetParentWindow(Window wID, Window wIDParent);
1503 
1519 int WBReparentWindow(Window wID, Window wIDParent, int iX, int iY); // keeps internal info up to date
1520 
1535 int WBIsChildWindow(Window wIDParent, Window wIDChild); // non-zero if 'wIDParent' is in a parent relationship with 'wIDChild'
1536 
1545 #define WBPointInRect(X,Y,R) ((X) >= (R).left && (X) < (R).right && (Y) >= (R).top && (Y) < (R).bottom)
1546 
1554 #define WBPointInGeom(X,Y,G) ((X) >= (G).x && (X) < ((G).x + (G).width) && (Y) >= (G).y && (Y) < ((G).y + (G).height))
1555 
1562 #define WBRectOverlapped(R1,R2) \
1563  ((((R1).left >= (R2).left && (R1).left < (R2).right) || \
1564  ((R2).left >= (R1).left && (R2).left < (R1).right)) && \
1565  (((R1).top >= (R2).top && (R1).top < (R2).bottom) || \
1566  ((R2).top >= (R1).top && (R2).top < (R1).bottom)))
1567 
1574 #define WBGeomOverlapped(G1,G2) \
1575  ((((G1).x >= (G2).x && (G1).x < (G2).x + (G2).width) || \
1576  ((G2).x >= (G1).x && (G2).x < (G1).x + (G1).width)) && \
1577  (((G1).y >= (G2).y && (G1).y < (G2).y + (G2).height) || \
1578  ((G2).y >= (G1).y && (G2).y < (G1).y + (G1).height)))
1579 
1597 void WBXlatCoordPoint(Window wIDSrc, int iXSrc, int iYSrc, Window wIDDest, int *piXDest, int *piYDest);
1598 
1614 void WBXlatCoordGeom(Window wIDSrc, const WB_GEOM *pGeomSrc, Window wIDDest, WB_GEOM *pGeomDest);
1615 
1631 void WBXlatCoordRect(Window wIDSrc, const WB_RECT *pRectSrc, Window wIDDest, WB_RECT *pRectDest);
1632 
1648 int WBPointInWindow(Window wIDRef, int iX, int iY, Window wIDQuery);
1649 
1650 // keyboard translation helpers
1651 
1655 #define WB_KEYEVENT_KEYSYM 8 /* bit flags for 'piAltCtrlShift' below */
1656 
1660 #define WB_KEYEVENT_ALT 4
1661 
1665 #define WB_KEYEVENT_CTRL 2
1666 
1670 #define WB_KEYEVENT_SHIFT 1
1671 
1675 #define WB_KEYEVENT_ACSMASK 7
1676 
1677 
1698 int WBKeyEventProcessKey(const XKeyEvent *pEvent, char *pBuf, int *pcbLen, int *piAltCtrlShift);
1699  // NOTE: WB_CHAR notification messages (related to WBKeyEventProcessKey)
1700  // message_type == aWB_CHAR
1701  // data.l[0] is return frmo WBKeyEventProcessKey
1702  // data.l[1] is *piAltCtrlShift from WBKeyEventProcessKey
1703  // data.l[2] is number of characters decoded into data.l[3..4]
1704  // data.l[3..4] (as char[]) is decode buffer (at least 8 chars long, possibly 16 for 64-bit)
1705 
1706 
1707 
1708 // pointer event definitions - WB_POINTER
1709 // data.l[0] is notification code (below)
1710 // data.l[1] is bitmap of mouse button state (button 1 is bit 0, button 2 is bit 1, etc.)
1711 // data.l[2] is 'WB_KEYEVENT_' mask for CTRL+ALT+SHIFT
1712 // data.l[3] is translated X coordinate
1713 // data.l[4] is translated Y coordinate
1714 
1718 #define WB_POINTER_UNSPECIFIED 0 /* possible motion or state-change notifications */
1719 
1723 #define WB_POINTER_CLICK 1
1724 
1728 #define WB_POINTER_DBLCLICK 2
1729 
1733 #define WB_POINTER_DRAG 3 /* window proc returns window ID to support drag/drop */
1734 
1738 #define WB_POINTER_DROP 4 /* may not happen if drag is canceled */
1739 
1743 #define WB_POINTER_MOVE 5 /* motion notify while dragging */
1744 
1748 #define WB_POINTER_CANCEL 6 /* reservedly any kind of cancellation, but for now, 'drag cancel' */
1749 
1753 #define WB_POINTER_SCROLLUP 7 /* scroll event, mouse button 4 */
1754 
1758 #define WB_POINTER_SCROLLDOWN 8 /* scroll event, mouse button 5 */
1759 
1763 #define WB_POINTER_BUTTON1 1 /* these are bitmasks */
1764 
1767 #define WB_POINTER_BUTTON2 2
1768 
1771 #define WB_POINTER_BUTTON3 4
1772 
1775 #define WB_POINTER_BUTTON4 8
1776 
1779 #define WB_POINTER_BUTTON5 16
1780 
1781 // (you can add multiple menus to multiple windows)
1787 void WBRegisterMenuCallback(Window wID, WBWinEvent pCallback);
1788 
1797 void WBAddMenuWindow(Window wID, Window wIDMenu);
1806 Window WBGetMenuWindow(Window wID); // returns ID of menu window assigned by above (one only)
1815 void WBRemoveMenuWindow(Window wID, Window wIDMenu);
1816 
1831 int WBIsValid(Display *pDisplay, Window wID);
1832 
1833 
1834 
1836 // _____ __ __ _____ _ _ _____ ____ //
1837 // | ____|\ \ / /| ____|| \ | ||_ _|/ ___| //
1838 // | _| \ \ / / | _| | \| | | | \___ \ //
1839 // | |___ \ V / | |___ | |\ | | | ___) | //
1840 // |_____| \_/ |_____||_| \_| |_| |____/ //
1841 // //
1843 
1844 // message loop helpers
1845 
1857 Time WBGetLastEventTime(void);
1858 
1859 
1908 int WBCheckGetEvent(Display *pDisplay, XEvent *pEvent);
1909 
1923 void WBWaitForEvent(Display *pDisplay);
1924 
1925 
1937 void WBDispatch(XEvent *pEvent);
1938 
1950 int WBAppDispatch(XEvent *pEvent);
1951 
1968 int WBWindowDispatch(Window wID, XEvent *pEvent);
1969 
1982 const char * WBEventName(int iEventID);
1983 
2001 int WBShowModal(Window wID, int bMenuSplashFlag); // modal window - returns 'EndModal' value or -1 on error
2002 
2014 void WBEndModal(Window wID, int iReturn);
2015 
2016 // client-side message queue (avoids XSendEvent)
2017 // to send a message directly use WBAppDispatch and WBWindowDispatch
2018 
2037 int WBNextEvent(Display *pDisplay, XEvent *pEvent);
2038 
2055 int WBPostEvent(Window wID, XEvent *pEvent);
2056 
2070 int WBPostPriorityEvent(Window wID, XEvent *pEvent); // like above but it goes at the beginning of the queue
2071 
2086 void WBPostDelayedEvent(XEvent *pEvent, unsigned int nDelay);
2087 
2100 int WBPostAppEvent(XEvent *pEvent);
2101 
2121 void WBPostDelayedSetFocusAppEvent(Display *pDisplay, Window wID, Window wIDFrom, unsigned int nDelay);
2122 
2139 void WBProcessExposeEvent(XExposeEvent *pEvent); // paint optimization
2140 
2141 
2142 
2144 // //
2145 // _ _ ___ _ _ _ //
2146 // | | | ||_ _| | | | | ___ | | _ __ ___ _ __ ___ //
2147 // | | | | | | | |_| | / _ \| || '_ \ / _ \| '__|/ __| //
2148 // | |_| | | | | _ || __/| || |_) || __/| | \__ \ //
2149 // \___/ |___| |_| |_| \___||_|| .__/ \___||_| |___/ //
2150 // |_| //
2151 // //
2153 
2154 
2171 void WBMouseCancel(Display *pDisplay, Window wID);
2172 
2173 
2174 
2175 
2177 // ____ _ ___ ____ ____ ___ _ ____ ____ //
2178 // / ___| | |_ _| _ \| __ ) / _ \ / \ | _ \| _ \ //
2179 // | | | | | || |_) | _ \| | | |/ _ \ | |_) | | | | //
2180 // | |___| |___ | || __/| |_) | |_| / ___ \| _ <| |_| | //
2181 // \____|_____|___|_| |____/ \___/_/ \_\_| \_\____/ //
2182 // //
2184 
2202 void * WBGetClipboardData(Display *pDisplay, Atom *paType, int *piFormat, unsigned long *pnData);
2203 
2219 int WBSetClipboardData(Display *pDisplay, Atom aType, int iFormat, const void *pData, unsigned long nData);
2220 
2221 
2222 // lower level functions for 'Selections'
2223 
2242 void * WBGetSelectionData(Display *pDisplay, Atom aSelection, Atom *paType, int *piFormat, unsigned long *pnData);
2243 
2244 
2261 int WBSetSelectionData(Display *pDisplay, Atom aSelection, Atom aType, int iFormat, const void *pData, unsigned long nData);
2262 
2263 
2264 
2265 
2267 // _____ __ __ ____ ___ ____ _ _ ____ _____ //
2268 // | ____|\ \/ /| _ \ / _ \ / ___| | | | || _ \ | ____| //
2269 // | _| \ / | |_) || | | |\___ \ | | | || |_) || _| //
2270 // | |___ / \ | __/ | |_| | ___) || |_| || _ < | |___ //
2271 // |_____|/_/\_\|_| \___/ |____/ \___/ |_| \_\|_____| //
2272 // //
2274 
2287 int WBMapWindow(Display *pDisplay, Window wID);
2300 int WBMapRaised(Display *pDisplay, Window wID);
2313 int WBUnmapWindow(Display *pDisplay, Window wID);
2314 
2329 int WBIsMapped(Display *pDisplay, Window wID); // non-zero if mapped, zero otherwise
2330  // NOTE: this only works for windows that have been registered with a callback
2331 
2332 
2333 // paint helpers (working in conjunction with 'WBProcessExposeEvent')
2334 
2350 void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintFlag);
2366 void WBInvalidateRegion(Window wID, Region rgn, int bPaintFlag);
2380 void WBValidateGeom(Window wID, const WB_GEOM *pGeom);
2394 void WBValidateRegion(Window wID, Region rgn);
2395 
2407 Region WBGetInvalidRegion(Window wID);
2408 
2422 Region WBGetPaintRegion(Window wID);
2423 
2435 Region WBRectToRegion(const WB_RECT *pRect);
2436 
2448 Region WBGeomToRegion(const WB_GEOM *pGeom);
2449 
2460 void WBUpdateWindow(Window wID); // posts an expose event for the specified window
2461 
2473 void WBUpdateWindowImmediately(Window wID); // sends expose event synchronously (can cause recursion)
2474 
2494 GC WBBeginPaint(Window wID, XExposeEvent *pEvent, WB_GEOM *pgRet); // GC has invalid region assigned
2495 
2512 GC WBBeginPaintGeom(Window wID, WB_GEOM *pgBounds); // GC has invalid region assigned
2513 
2525 void WBEndPaint(Window wID, GC gc); // frees the 'paint GC' and also resets the invalid region
2526 
2538 void WBClearWindow(Window wID, GC gc);
2539 
2540 
2541 // RECT versions (as inline)
2542 
2558 static __inline__ void WBInvalidateRect(Window wID, const WB_RECT *pRCT, int bPaintFlag)
2559 {
2560  WB_GEOM geom;
2561 
2562  if(!pRCT)
2563  {
2564  WBInvalidateGeom(wID, NULL, bPaintFlag);
2565  return;
2566  }
2567 
2568  geom.x = pRCT->left;
2569  geom.y = pRCT->top;
2570  geom.width = pRCT->right - pRCT->left;
2571  geom.height = pRCT->bottom - pRCT->top;
2572  geom.border = 0;
2573 
2574  WBInvalidateGeom(wID, &geom, bPaintFlag);
2575 }
2576 
2590 static __inline__ void WBValidateRect(Window wID, WB_RECT *pRCT)
2591 {
2592  WB_GEOM geom;
2593 
2594  if(!pRCT)
2595  {
2596  WBValidateGeom(wID, NULL);
2597  return;
2598  }
2599 
2600  geom.x = pRCT->left;
2601  geom.y = pRCT->top;
2602  geom.width = pRCT->right - pRCT->left;
2603  geom.height = pRCT->bottom - pRCT->top;
2604  geom.border = 0;
2605 
2606  WBValidateGeom(wID, &geom);
2607 }
2608 
2609 
2610 
2612 // _____ ___ __ __ _____ ____ ____ //
2613 // |_ _||_ _|| \/ || ____|| _ \ / ___| //
2614 // | | | | | |\/| || _| | |_) |\___ \ //
2615 // | | | | | | | || |___ | _ < ___) | //
2616 // |_| |___||_| |_||_____||_| \_\|____/ //
2617 // //
2619 
2637 int CreateTimer(Display *pDisplay, Window wID, unsigned long lInterval, long lID, int iPeriodic);
2638  // NOTE: 'iPeriodic' non-zero for periodic, zero for one-shot. 'lInterval' is in microseconds
2639  // Assign 'lID' to a unique value for the specified pDisplay and wID
2640 
2655 void DeleteTimer(Display *pDisplay, Window wID, long lID); // deletes entry with matching Display, Window, ID
2656 
2657 
2658 
2659 // ****************************************************
2660 //
2661 // E R R O R H A N D L I N G
2662 //
2663 // ****************************************************
2664 
2689 typedef struct __WB_ERROR_INFO__
2690 {
2691  Display *pDisplay;
2692  const char *pFunc;
2693  int iLine;
2694  unsigned long serial;
2699 } WB_ERROR_INFO;
2700 
2701 
2702 
2712 static __inline__ void WBSupressErrorOutput(void)
2713 {
2714 extern int bIgnoreXErrors;
2715 
2716  // TODO: serialize this with a mutex or other sync object?
2717  bIgnoreXErrors++;
2718 }
2719 
2729 static __inline__ void WBAllowErrorOutput(void)
2730 {
2731 extern int bIgnoreXErrors;
2732 
2733  // TODO: serialize this with a mutex or other sync object?
2734  if(bIgnoreXErrors > 0)
2735  {
2736  bIgnoreXErrors--;
2737  }
2738  else
2739  {
2740  bIgnoreXErrors = 0;
2741  }
2742 }
2743 
2744 
2750 void WBErrorClear(void);
2751 
2763 int WBErrorCheck(void);
2764 
2777 int WBErrorCheckRetry(void);
2778 
2791 const WB_ERROR_INFO * WBGetLastError(void);
2792 
2793 
2794 
2795 #ifdef __cplusplus
2796 };
2797 #endif // __cplusplus
2798 
2799 #endif // WINDOW_HELPER_H_INCLUDED
2800 
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
PRIMARY Atom for the clipboard - uses XA_PRIMARY.
void WBSetWMProtocols(Window wID, Atom aProperty,...)
re-assign standard WM (Window Manager) &#39;window type&#39; properties and notify the root window (reserved)...
2nd parameter (direction) - up, left
const Atom aMENU_UI_COMMAND
UI notifications sent by menus to owning Frame windows via ClientMessage using &#39;WBWindowDispatch&#39;.
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
COMPOUND_TEXT Atom for the clipboard.
const Atom aSECONDARY
SECONDARY Atom for the clipboard - uses XA_SECONDARY.
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.
unsigned long serial
serial number from XErrorEvent
void WBSetWindowFontSet(Window wID, XFontSet fontSet)
assigns the default XFontSet to a window
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.
struct _WBGeom_ WB_GEOM
internal wrapper struct for X11 &#39;geometry&#39; definition
const Atom aMULTIPLE
MULTIPLE Atom 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.
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...
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.
generic &#39;NA&#39; or &#39;UNDEFINED&#39; value
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.
struct _WBExtent_ WB_EXTENT
internal wrapper struct for &#39;extent&#39; definition
Definition: font_helper.h:74
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...
Window WBGetHiddenHelperWindow(void)
Returns a special &#39;hidden&#39; window used for information purposes.
const Atom aINCR
INCR Atom for the clipboard.
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
1st parameter (bar) - The vertical scroll bar for the control or window.
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) ...
2nd parameter (direction) - &#39;knob track&#39; - pos in data.l[2]
unsigned int border
const Atom aWM_DELETE_WINDOW
Delete Window notification event.
const Atom aWM_PROTOCOLS
WM supported protocols.
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.
const Atom aWB_CHAR
keystroke/character notifications generated by API
WMPropertiesWindowType
Window type enumeration. Reserved for future implementation.
const Atom aRECALC_LAYOUT
notify window that it should re-calculate things like scrollbars and viewports
Window WBGetApplicationWindow(void)
Destroy a window.
int iLine
Line number of the function as assigned by BEGIN_XCALL_DEBUG_WRAPPER.
const Atom aDLG_FOCUS
dialog focus messages
const Atom aTIMESTAMP
TIMESTAMP Atom 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
DRAWABLE Atom for the clipboard - uses XA_DRAWABLE.
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
const Atom aWB_POINTER
pointer click/double-click/drag notifications generated by API
WMPropertiesWMProtocols
Window WMProtocols support enumeration.
void WBRegisterWindowCallback(Window wID, WBWinEvent pCallback)
register callback function for a window (required)
const Atom aMANAGER
MANAGER Atom for the clipboard.
const Atom aMENU_COMMAND
commands sent by menus via ClientMessage
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
PIXEL Atom for the clipboard.
void DeleteTimer(Display *pDisplay, Window wID, long lID)
Deletes an existing timer&#39;s resources.
const Atom aSCROLL_NOTIFY
void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintFlag)
&#39;Paint&#39; helper, invalidates a geometry for asynchronous Expose event generation
unsigned int width
the &#39;width&#39; value of the extent.
1st parameter (bar) - The horizontal scroll bar for the control or window
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.
2nd parameter (direction) - bottom, end
const Atom aWINDOW
WINDOW Atom for the clipboard - uses XA_WINDOW.
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.
2nd parameter (direction) - relative scroll - rel pos in data.l[2]
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.
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.
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.
2nd parameter (direction) - pgup, pgleft
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.
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
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.
2nd parameter (direction) - absolute scroll - pos in data.l[2]
const Atom aCLIPBOARD
CLIPBOARD Atom for the clipboard.
WBScrollEventParam
Enumeration for aSCROLL_NOTIFY ClientMessage.
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
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
2nd parameter (direction) - double-clicked item (no selection change info) (sent to list control&#39;s ow...
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
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_TAKE_FOCUS
&#39;Take Focus&#39; - TODO document this properly
2nd parameter (direction) - home, top
struct _WBPoint_ WB_POINT
internal wrapper struct for &#39;point&#39; definition
int WBReparentWindow(Window wID, Window wIDParent, int iX, int iY)
Assigns a new parent to the specified window (aka &#39;Re-parent&#39;)
const 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
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
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.
const Atom aQUERY_CLOSE
query if it&#39;s ok to close (and optionally destroy yourself if ok) a window
int request_code
request code from XErrorEvent
Display * WBGetWindowDisplay(Window wID)
returns the Display associated with a window
const Atom aCONTROL_NOTIFY
dialog control and child window notification messages
int WBInitClipboardSystem(Display *pDisplay, const char *szDisplayName)
initializes clipboard sub-system
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
const Atom aTARGETS
TARGETS Atom for the clipboard.
internal wrapper struct for &#39;point&#39; definition
2nd parameter (direction) - pgdn, pgright
struct _WBRect_ WB_RECT
internal wrapper struct for &#39;rectangle&#39; definition
const Atom aTARGET
TARGET Atom 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.
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
COLORMAP Atom for the clipboard - uses XA_COLORMAP.
const Atom aBITMAP
BITMAP Atom for the clipboard - uses XA_BITMAP.
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.
1st parameter (bar) - &#39;Default Bar&#39;, currently not implemented, probably won&#39;t be used ...
const Atom aWB_TIMER
timer notifications generated by API
const Atom aDESTROY_NOTIFY
notify parent that child is being destroyed
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...
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
NULL Atom 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 aRESIZE_NOTIFY
notification of window re-size via ClientMessage
const Atom aTEXT
TEXT Atom for the clipboard.
void WBGetWindowGeom0(Window wID, WB_GEOM *pGeom)
Returns the ABSOLUTE window geometry relative the screen.
const Atom aSET_FOCUS
dialog focus messages
Time WBGetLastEventTime(void)
Main message loop, high level API to check for and retrieve the next event.
2nd parameter (direction) - down, right
XFontStruct * WBGetWindowFontStruct(Window wID)
Returns the current XFontStruct pointer assigned to the window (may be NULL)
const Atom aC_STRING
C_STRING Atom 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
void WBEndPaint(Window wID, GC gc)
&#39;Paint&#39; helper, frees resources and marks the update region &#39;valid&#39;
const Atom aSTRING
STRING Atom for the clipboard - uses XA_STRING.
int x
the &#39;x&#39; value of the point. can be negative.
void WBExitClipboardSystem(Display *pDisplay)
Shut down the clipboard sub-system.
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
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 ...
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.
void WBPostDelayedSetFocusAppEvent(Display *pDisplay, Window wID, Window wIDFrom, unsigned int nDelay)
Creates a &#39;set focus&#39; ClientMessage event for the application event handler.