X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fdisplay.cc;h=4613b9ba9a5b5da75b8a5b5a43d5fdfeeb2c96e8;hb=1eef416eee7b4df16a5cb1b834595e0419b102d2;hp=9e6685b9864d7fb1a5eb7cea0e0adf061d50930d;hpb=fa8cefef63feb1d559c40db3cf9407e5bd1ac4df;p=chaz%2Fopenbox diff --git a/otk/display.cc b/otk/display.cc index 9e6685b9..4613b9ba 100644 --- a/otk/display.cc +++ b/otk/display.cc @@ -11,6 +11,10 @@ extern "C" { #include +#ifdef SHAPE +#include +#endif // SHAPE + #ifdef HAVE_STDIO_H # include #endif // HAVE_STDIO_H @@ -39,7 +43,14 @@ extern "C" { namespace otk { -Display *display = (Display*) 0; +Display *OBDisplay::display = (Display*) 0; +bool OBDisplay::_shape = false; +int OBDisplay::_shape_event_basep = 0; +bool OBDisplay::_xinerama = false; +int OBDisplay::_xinerama_event_basep = 0; +unsigned int OBDisplay::_mask_list[8]; +OBDisplay::ScreenInfoList OBDisplay::_screenInfoList; +BGCCache *OBDisplay::_gccache = (BGCCache*) 0; int OBDisplay::xerrorHandler(Display *d, XErrorEvent *e) @@ -47,8 +58,11 @@ int OBDisplay::xerrorHandler(Display *d, XErrorEvent *e) #ifdef DEBUG char errtxt[128]; - XGetErrorText(d, e->error_code, errtxt, 128); - printf("X Error: %s\n", errtxt); + //if (e->error_code != BadWindow) + { + XGetErrorText(d, e->error_code, errtxt, 128); + printf("X Error: %s\n", errtxt); + } #else (void)d; (void)e; @@ -90,14 +104,10 @@ line argument.\n\n")); // find the availability of X extensions we like to use #ifdef SHAPE _shape = XShapeQueryExtension(display, &_shape_event_basep, &junk); -#else - _shape = false; #endif #ifdef XINERAMA _xinerama = XineramaQueryExtension(display, &_xinerama_event_basep, &junk); -#else - _xinerama = false; #endif // XINERAMA // get lock masks that are defined by the display (not constant) @@ -155,4 +165,51 @@ void OBDisplay::destroy() } +const ScreenInfo* OBDisplay::screenInfo(int snum) { + assert(snum >= 0); + assert(snum < static_cast(_screenInfoList.size())); + return &_screenInfoList[snum]; +} + + + + + + + + + +/* + * Grabs a button, but also grabs the button in every possible combination + * with the keyboard lock keys, so that they do not cancel out the event. + + * if allow_scroll_lock is true then only the top half of the lock mask + * table is used and scroll lock is ignored. This value defaults to false. + */ +void OBDisplay::grabButton(unsigned int button, unsigned int modifiers, + Window grab_window, bool owner_events, + unsigned int event_mask, int pointer_mode, + int keyboard_mode, Window confine_to, + Cursor cursor, bool allow_scroll_lock) { + unsigned int length = (allow_scroll_lock) ? 8 / 2: + 8; + for (size_t cnt = 0; cnt < length; ++cnt) + XGrabButton(otk::OBDisplay::display, button, modifiers | _mask_list[cnt], + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); +} + + +/* + * Releases the grab on a button, and ungrabs all possible combinations of the + * keyboard lock keys. + */ +void OBDisplay::ungrabButton(unsigned int button, unsigned int modifiers, + Window grab_window) { + for (size_t cnt = 0; cnt < 8; ++cnt) + XUngrabButton(otk::OBDisplay::display, button, modifiers | _mask_list[cnt], + grab_window); +} + + }