From: Dana Jansens Date: Sun, 3 Nov 2002 11:46:05 +0000 (+0000) Subject: WE DONT USE BASE DISPLAY FOR ANYTHING ANY MORE!!@^!*@*!! YAY X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=ace8c8896aa13a6fc4e489277cf9c96f49175322;p=chaz%2Fopenbox WE DONT USE BASE DISPLAY FOR ANYTHING ANY MORE!!@^!*@*!! YAY --- diff --git a/otk/Makefile.am b/otk/Makefile.am index 4a2b9f84..7f862287 100644 --- a/otk/Makefile.am +++ b/otk/Makefile.am @@ -5,7 +5,7 @@ INCLUDES= -I../src noinst_LIBRARIES=libotk.a libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \ - imagecontrol.cc rect.cc texture.cc + imagecontrol.cc rect.cc screeninfo.cc texture.cc MAINTAINERCLEANFILES= Makefile.in diff --git a/otk/display.cc b/otk/display.cc index 9e6685b9..45924428 100644 --- a/otk/display.cc +++ b/otk/display.cc @@ -39,7 +39,14 @@ extern "C" { namespace otk { -Display *display = (Display*) 0; +Display *OBDisplay::display = (Display*) 0; +bool OBDisplay::_shape = false; +int OBDisplay::_shape_event_basep; +bool OBDisplay::_xinerama = false; +int OBDisplay::_xinerama_event_basep; +unsigned int OBDisplay::_mask_list[8]; +OBDisplay::ScreenInfoList OBDisplay::_screenInfoList; +BGCCache *OBDisplay::_gccache = (BGCCache*) 0; int OBDisplay::xerrorHandler(Display *d, XErrorEvent *e) @@ -90,14 +97,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 +158,46 @@ void OBDisplay::destroy() } + + + + + + + + + +/* + * 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); +} + + } diff --git a/otk/display.hh b/otk/display.hh index aa457bcd..7724bbab 100644 --- a/otk/display.hh +++ b/otk/display.hh @@ -62,6 +62,19 @@ public: inline static int shapeEventBase() { return _shape_event_basep; } //! Returns if the display has the xinerama extention available inline static bool xinerama() { return _xinerama; } + + + + + + /* TEMPORARY */ + static void 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); + static void ungrabButton(unsigned int button, unsigned int modifiers, + Window grab_window); }; } diff --git a/otk/screeninfo.cc b/otk/screeninfo.cc index 22ec6d02..c1c0c2ac 100644 --- a/otk/screeninfo.cc +++ b/otk/screeninfo.cc @@ -4,8 +4,14 @@ # include "../config.h" #endif // HAVE_CONFIG_H +extern "C" { +#include +#include +} + #include "screeninfo.hh" #include "display.hh" +#include "src/util.hh" using std::string; @@ -14,7 +20,7 @@ namespace otk { ScreenInfo::ScreenInfo(unsigned int num) { screen_number = num; - root_window = RootWindow(ob::OBDisplay::display, screen_number); + root_window = RootWindow(OBDisplay::display, screen_number); rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display, screen_number)), @@ -73,7 +79,7 @@ ScreenInfo::ScreenInfo(unsigned int num) { default_string.resize(pos); display_string = string("DISPLAY=") + default_string + '.' + - itostring(static_cast(screen_number)); + ob::itostring(static_cast(screen_number)); #ifdef XINERAMA xinerama_active = False; diff --git a/po/POTFILES.in b/po/POTFILES.in index 187f9acd..07fc4208 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,3 +1,4 @@ # List of source files containing translatable strings. -src/main.cc \ No newline at end of file +src/openbox.cc +src/display.cc \ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index b6e36e05..4a5ea177 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,7 @@ bin_PROGRAMS= openbox openbox_LDADD=../otk/libotk.a @LIBINTL@ -openbox_SOURCES= basedisplay.cc configuration.cc screen.cc screeninfo.cc \ +openbox_SOURCES= configuration.cc screen.cc openbox.cc \ timer.cc util.cc window.cc workspace.cc xatom.cc blackbox.cc \ main.cc diff --git a/src/basedisplay.hh b/src/basedisplay.hh index dde34adc..aa1481ca 100644 --- a/src/basedisplay.hh +++ b/src/basedisplay.hh @@ -13,7 +13,6 @@ extern "C" { #include // forward declaration -class BaseDisplay; class BGCCache; class BaseDisplay: public TimerQueueManager { diff --git a/src/blackbox.cc b/src/blackbox.cc index 8040ca36..a845431a 100644 --- a/src/blackbox.cc +++ b/src/blackbox.cc @@ -76,19 +76,22 @@ extern "C" { using std::string; #include "blackbox.hh" -#include "gccache.hh" -#include "image.hh" +#include "otk/gccache.hh" +#include "otk/image.hh" +#include "otk/assassin.hh" #include "screen.hh" #include "util.hh" #include "window.hh" #include "workspace.hh" #include "xatom.hh" +namespace ob { + Blackbox *blackbox; -Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) - : BaseDisplay(m_argv[0], dpy_name) { +Blackbox::Blackbox(int argc, char **m_argv, char *rc) + : Openbox(argc, m_argv) { if (! XSupportsLocale()) fprintf(stderr, "X server does not support locale\n"); @@ -96,7 +99,7 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) if (XSetLocaleModifiers("") == NULL) fprintf(stderr, "cannot set locale modifiers\n"); - ::blackbox = this; + ob::blackbox = this; argv = m_argv; // try to make sure the ~/.openbox directory exists @@ -117,16 +120,16 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) load_rc(); - xatom = new XAtom(getXDisplay()); + xatom = new XAtom(otk::OBDisplay::display); - cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr); - cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur); - cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle); - cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle); - cursor.ul_angle = XCreateFontCursor(getXDisplay(), XC_ul_angle); - cursor.ur_angle = XCreateFontCursor(getXDisplay(), XC_ur_angle); + cursor.session = XCreateFontCursor(otk::OBDisplay::display, XC_left_ptr); + cursor.move = XCreateFontCursor(otk::OBDisplay::display, XC_fleur); + cursor.ll_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ll_angle); + cursor.lr_angle = XCreateFontCursor(otk::OBDisplay::display, XC_lr_angle); + cursor.ul_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ul_angle); + cursor.ur_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ur_angle); - for (unsigned int i = 0; i < getNumberOfScreens(); i++) { + for (int i = 0; i < ScreenCount(otk::OBDisplay::display); i++) { BScreen *screen = new BScreen(this, i); if (! screen->isScreenManaged()) { @@ -150,8 +153,8 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) active_screen = screenList.front(); setFocusedWindow(0); - XSynchronize(getXDisplay(), False); - XSync(getXDisplay(), False); + XSynchronize(otk::OBDisplay::display, False); + XSync(otk::OBDisplay::display, False); reconfigure_wait = False; @@ -161,7 +164,7 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) Blackbox::~Blackbox(void) { - std::for_each(screenList.begin(), screenList.end(), PointerAssassin()); + std::for_each(screenList.begin(), screenList.end(), otk::PointerAssassin()); delete xatom; @@ -173,7 +176,7 @@ void Blackbox::process_event(XEvent *e) { switch (e->type) { case ButtonPress: { // strip the lock key modifiers - e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask); + //e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask); last_time = e->xbutton.time; @@ -201,7 +204,7 @@ void Blackbox::process_event(XEvent *e) { case ButtonRelease: { // strip the lock key modifiers - e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask); + //e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask); last_time = e->xbutton.time; @@ -230,7 +233,7 @@ void Blackbox::process_event(XEvent *e) { xwc.sibling = e->xconfigurerequest.above; xwc.stack_mode = e->xconfigurerequest.detail; - XConfigureWindow(getXDisplay(), e->xconfigurerequest.window, + XConfigureWindow(otk::OBDisplay::display, e->xconfigurerequest.window, e->xconfigurerequest.value_mask, &xwc); } } @@ -276,7 +279,7 @@ void Blackbox::process_event(XEvent *e) { the window is on */ XWindowAttributes wattrib; - if (! XGetWindowAttributes(getXDisplay(), e->xmaprequest.window, + if (! XGetWindowAttributes(otk::OBDisplay::display, e->xmaprequest.window, &wattrib)) { // failed to get the window attributes, perhaps the window has // now been destroyed? @@ -339,7 +342,7 @@ void Blackbox::process_event(XEvent *e) { // motion notify compression... XEvent realevent; unsigned int i = 0; - while (XCheckTypedWindowEvent(getXDisplay(), e->xmotion.window, + while (XCheckTypedWindowEvent(otk::OBDisplay::display, e->xmotion.window, MotionNotify, &realevent)) { i++; } @@ -353,7 +356,7 @@ void Blackbox::process_event(XEvent *e) { break; // strip the lock key modifiers - e->xmotion.state &= ~(NumLockMask | ScrollLockMask | LockMask); + //e->xmotion.state &= ~(NumLockMask | ScrollLockMask | LockMask); last_time = e->xmotion.time; @@ -415,7 +418,7 @@ void Blackbox::process_event(XEvent *e) { ey1 = e->xexpose.y; ex2 = ex1 + e->xexpose.width - 1; ey2 = ey1 + e->xexpose.height - 1; - while (XCheckTypedWindowEvent(getXDisplay(), e->xexpose.window, + while (XCheckTypedWindowEvent(otk::OBDisplay::display, e->xexpose.window, Expose, &realevent)) { i++; @@ -515,7 +518,7 @@ void Blackbox::process_event(XEvent *e) { (the FocusIn event handler sets the window in the event structure to None to indicate this). */ - if (XCheckTypedEvent(getXDisplay(), FocusIn, &event)) { + if (XCheckTypedEvent(otk::OBDisplay::display, FocusIn, &event)) { process_event(&event); if (event.xfocus.window == None) { @@ -532,7 +535,7 @@ void Blackbox::process_event(XEvent *e) { BlackboxWindow *focus; Window w; int revert; - XGetInputFocus(getXDisplay(), &w, &revert); + XGetInputFocus(otk::OBDisplay::display, &w, &revert); focus = searchWindow(w); if (focus) { /* @@ -870,8 +873,8 @@ bool Blackbox::handleSignal(int sig) { bool Blackbox::validateWindow(Window window) { XEvent event; - if (XCheckTypedWindowEvent(getXDisplay(), window, DestroyNotify, &event)) { - XPutBackEvent(getXDisplay(), &event); + if (XCheckTypedWindowEvent(otk::OBDisplay::display, window, DestroyNotify, &event)) { + XPutBackEvent(otk::OBDisplay::display, &event); return False; } @@ -961,20 +964,20 @@ void Blackbox::restart(const char *prog) { // fall back in case the above execlp doesn't work execvp(argv[0], argv); - string name = basename(argv[0]); + string name = ::basename(argv[0]); execvp(name.c_str(), argv); } void Blackbox::shutdown(void) { - BaseDisplay::shutdown(); + Openbox::shutdown(); - XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime); + XSetInputFocus(otk::OBDisplay::display, PointerRoot, None, CurrentTime); std::for_each(screenList.begin(), screenList.end(), std::mem_fun(&BScreen::shutdown)); - XSync(getXDisplay(), False); + XSync(otk::OBDisplay::display, False); } @@ -983,9 +986,7 @@ void Blackbox::saveXineramaPlacement(bool x) { resource.xinerama_placement = x; config.setValue("session.xineramaSupport.windowPlacement", resource.xinerama_placement); - reconfigure(); // make sure all screens get this change -} - + reconfigure(); // make sure all screens get this void Blackbox::saveXineramaMaximizing(bool x) { resource.xinerama_maximize = x; @@ -1125,7 +1126,7 @@ void Blackbox::load_rc(void) { void Blackbox::reconfigure(void) { // don't reconfigure while saving the initial rc file, it's a waste and it // breaks somethings (workspace names) - if (isStartup()) return; + if (state() == Openbox::State_Starting) return; reconfigure_wait = True; @@ -1136,7 +1137,7 @@ void Blackbox::reconfigure(void) { void Blackbox::real_reconfigure(void) { load_rc(); - gcCache()->purge(); + otk::OBDisplay::gcCache()->purge(); std::for_each(screenList.begin(), screenList.end(), std::mem_fun(&BScreen::reconfigure)); @@ -1188,18 +1189,18 @@ void Blackbox::setFocusedWindow(BlackboxWindow *win) { if (! old_screen) { if (active_screen) { // set input focus to the toolbar of the screen with mouse - XSetInputFocus(getXDisplay(), + XSetInputFocus(otk::OBDisplay::display, active_screen->getRootWindow(), RevertToPointerRoot, CurrentTime); } else { // set input focus to the toolbar of the first managed screen - XSetInputFocus(getXDisplay(), + XSetInputFocus(otk::OBDisplay::display, screenList.front()->getRootWindow(), RevertToPointerRoot, CurrentTime); } } else { // set input focus to the toolbar of the last screen - XSetInputFocus(getXDisplay(), old_screen->getRootWindow(), + XSetInputFocus(otk::OBDisplay::display, old_screen->getRootWindow(), RevertToPointerRoot, CurrentTime); } } @@ -1212,3 +1213,16 @@ void Blackbox::setFocusedWindow(BlackboxWindow *win) { old_screen->updateNetizenWindowFocus(); } } + + +void Blackbox::addTimer(BTimer *timer) { + (void)timer; +} + + +void Blackbox::removeTimer(BTimer *timer) { + (void)timer; +} + + +} diff --git a/src/blackbox.hh b/src/blackbox.hh index acce7b8b..818a7842 100644 --- a/src/blackbox.hh +++ b/src/blackbox.hh @@ -25,7 +25,7 @@ extern "C" { #include #include -#include "basedisplay.hh" +#include "openbox.hh" #include "configuration.hh" #include "timer.hh" #include "xatom.hh" @@ -47,6 +47,8 @@ extern "C" { #define DecorTiny (2) #define DecorTool (3) +namespace ob { + struct BlackboxHints { unsigned long flags, attrib, workspace, stack, decoration; }; @@ -67,7 +69,7 @@ class Blackbox; class BlackboxWindow; class BWindowGroup; -class Blackbox : public BaseDisplay, public TimeoutHandler { +class Blackbox : public Openbox, public TimeoutHandler, public TimerQueueManager { private: struct BCursor { Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle; @@ -79,7 +81,7 @@ private: std::string style_file; int colors_per_channel; - timeval auto_raise_delay; + ::timeval auto_raise_delay; unsigned long cache_life, cache_max; std::string titlebar_layout; unsigned int mod_mask; // modifier mask used for window-mouse interaction @@ -127,7 +129,7 @@ private: public: - Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0); + Blackbox(int argc, char **m_argv, char *rc = 0); virtual ~Blackbox(void); BWindowGroup *searchGroup(Window window); @@ -174,7 +176,7 @@ public: inline std::string getTitlebarLayout(void) const { return resource.titlebar_layout; } - inline const timeval &getAutoRaiseDelay(void) const + inline const ::timeval &getAutoRaiseDelay(void) const { return resource.auto_raise_delay; } inline unsigned long getCacheLife(void) const @@ -214,7 +216,11 @@ public: virtual void timeout(void); enum { B_AmericanDate = 1, B_EuropeanDate }; + + virtual void addTimer(BTimer *timer); + virtual void removeTimer(BTimer *timer); }; +} #endif // __blackbox_hh diff --git a/src/configuration.cc b/src/configuration.cc index 51f02b8e..4d0af097 100644 --- a/src/configuration.cc +++ b/src/configuration.cc @@ -17,6 +17,8 @@ extern "C" { using std::string; +namespace ob { + bool Configuration::_initialized = False; Configuration::Configuration(const string &file, bool autosave) { @@ -231,3 +233,5 @@ char Configuration::toUpper(char c) const { return c - 'a' + 'A'; return c; } + +} diff --git a/src/configuration.hh b/src/configuration.hh index 418c2639..a45bd3f8 100644 --- a/src/configuration.hh +++ b/src/configuration.hh @@ -6,6 +6,8 @@ #include #include +namespace ob { + /* * The Configuration class is a generic wrapper for configuration settings. * @@ -74,4 +76,6 @@ private: XrmDatabase _database; }; +} + #endif // __Configuration_hh diff --git a/src/main.cc b/src/main.cc index 2bc4b3ce..af0dcf38 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,163 +1,29 @@ // -*- mode: C++; indent-tabs-mode: nil; -*- -#include "../version.h" - #ifdef HAVE_CONFIG_H # include "../config.h" #endif // HAVE_CONFIG_H extern "C" { -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H - -#ifdef HAVE_STDLIB_H -# include -#endif // HAVE_STDLIB_H - -#ifdef HAVE_STRING_H -# include -#endif // HAVE_STRING_H - -#ifdef HAVE_UNISTD_H -#include -#endif // HAVE_UNISTD_H - -#ifdef HAVE_SYS_PARAM_H -# include -#endif // HAVE_SYS_PARAM_H -} - #include "gettext.h" -#define _(str) gettext(str) +} #include using std::string; #include "blackbox.hh" - - -static void showHelp(int exitval) { - // print program usage and command line options - printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"), - OPENBOX_VERSION); - printf(_(" -display use display connection.\n\ - -rc use alternate resource file.\n\ - -menu use alternate menu file.\n\ - -version display version and exit.\n\ - -help display this help text and exit.\n\n")); - - // some people have requested that we print out compile options - // as well - printf(_("Compile time options:\n\ - Debugging:\t\t\t%s\n\ - Shape:\t\t\t%s\n\ - Xft:\t\t\t\t%s\n\ - Xinerama:\t\t\t%s\n\ - 8bpp Ordered Dithering:\t%s\n\n"), -#ifdef DEBUG - _("yes"), -#else // !DEBUG - _("no"), -#endif // DEBUG - -#ifdef SHAPE - _("yes"), -#else // !SHAPE - _("no"), -#endif // SHAPE - -#ifdef XFT - _("yes"), -#else // !XFT - _("no"), -#endif // XFT - -#ifdef XINERAMA - _("yes"), -#else // !XINERAMA - _("no"), -#endif // XINERAMA - -#ifdef ORDEREDPSEUDO - _("yes") -#else // !ORDEREDPSEUDO - _("no") -#endif // ORDEREDPSEUDO - ); - - ::exit(exitval); -} +#include "openbox.hh" int main(int argc, char **argv) { - char *session_display = (char *) 0; - char *rc_file = (char *) 0; - char *menu_file = (char *) 0; - // initialize the locale setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - - for (int i = 1; i < argc; ++i) { - if (! strcmp(argv[i], "-rc")) { - // look for alternative rc file to use - - if ((++i) >= argc) { - fprintf(stderr, _("error: '-rc' requires and argument\n")); - - ::exit(1); - } - - rc_file = argv[i]; - } else if (! strcmp(argv[i], "-menu")) { - // look for alternative menu file to use - - if ((++i) >= argc) { - fprintf(stderr, _("error: '-menu' requires and argument\n")); - - ::exit(1); - } - menu_file = argv[i]; - } else if (! strcmp(argv[i], "-display")) { - // check for -display option... to run on a display other than the one - // set by the environment variable DISPLAY - - if ((++i) >= argc) { - fprintf(stderr, _("error: '-display' requires an argument\n")); - - ::exit(1); - } - - session_display = argv[i]; - string dtmp = "DISPLAY="; - dtmp += session_display; - - if (putenv(const_cast(dtmp.c_str()))) { - fprintf(stderr, - _("warning: couldn't set environment variable 'DISPLAY'\n")); - perror("putenv()"); - } - } else if (! strcmp(argv[i], "-version")) { - // print current version string - printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"), - OPENBOX_VERSION); - printf("\n"); - - ::exit(0); - } else if (! strcmp(argv[i], "-help")) { - showHelp(0); - } else { // invalid command line option - showHelp(-1); - } - } - -#ifdef __EMX__ - _chdir2(getenv("X11ROOT")); -#endif // __EMX__ - - Blackbox blackbox(argv, session_display, rc_file); + //ob::Openbox openbox(argc, argv); + ob::Blackbox blackbox(argc, argv, 0); + + //Blackbox blackbox(argv, session_display, rc_file); blackbox.eventLoop(); return(0); diff --git a/src/openbox.cc b/src/openbox.cc new file mode 100644 index 00000000..440c4f70 --- /dev/null +++ b/src/openbox.cc @@ -0,0 +1,261 @@ +// -*- mode: C++; indent-tabs-mode: nil; -*- + +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif + +#include "../version.h" +#include "openbox.hh" +#include "otk/display.hh" + +extern "C" { +#ifdef HAVE_STDIO_H +# include +#endif // HAVE_STDIO_H + +#ifdef HAVE_STDLIB_H +# include +#endif // HAVE_STDLIB_H + +#ifdef HAVE_SIGNAL_H +# include +#endif // HAVE_SIGNAL_H + +#ifdef HAVE_FCNTL_H +# include +#endif // HAVE_FCNTL_H + +#ifdef HAVE_UNISTD_H +# include +# include +#endif // HAVE_UNISTD_H + +#ifdef HAVE_SYS_SELECT_H +# include +#endif // HAVE_SYS_SELECT_H + +#include "gettext.h" +#define _(str) gettext(str) +} + +namespace ob { + + +Openbox *Openbox::instance = (Openbox *) 0; + + +int Openbox::xerrorHandler(Display *d, XErrorEvent *e) +{ +#ifdef DEBUG + char errtxt[128]; + + XGetErrorText(d, e->error_code, errtxt, 128); + printf("X Error: %s\n", errtxt); +#else + (void)d; + (void)e; +#endif + + return false; +} + + +void Openbox::signalHandler(int signal) +{ + switch (signal) { + case SIGHUP: + // XXX: Do something with HUP? Really shouldn't, we get this when X shuts + // down and hangs-up on us. + + case SIGINT: + case SIGTERM: + case SIGPIPE: + printf("Caught signal %d. Exiting.", signal); + // XXX: Make Openbox exit + break; + case SIGFPE: + case SIGSEGV: + printf("Caught signal %d. Aborting and dumping core.", signal); + abort(); + } +} + + +Openbox::Openbox(int argc, char **argv) +{ + struct sigaction action; + + _state = State_Starting; + + Openbox::instance = this; + + _displayreq = (char*) 0; + _argv0 = argv[0]; + + parseCommandLine(argc, argv); + + // open the X display (and gets some info about it, and its screens) + otk::OBDisplay::initialize(_displayreq); + assert(otk::OBDisplay::display); + + // set up the signal handler + action.sa_handler = Openbox::signalHandler; + action.sa_mask = sigset_t(); + action.sa_flags = SA_NOCLDSTOP | SA_NODEFER; + sigaction(SIGPIPE, &action, (struct sigaction *) 0); + sigaction(SIGSEGV, &action, (struct sigaction *) 0); + sigaction(SIGFPE, &action, (struct sigaction *) 0); + sigaction(SIGTERM, &action, (struct sigaction *) 0); + sigaction(SIGINT, &action, (struct sigaction *) 0); + sigaction(SIGHUP, &action, (struct sigaction *) 0); + + + + _state = State_Normal; // done starting +} + + +Openbox::~Openbox() +{ + // close the X display + otk::OBDisplay::destroy(); +} + + +void Openbox::parseCommandLine(int argc, char **argv) +{ + bool err = false; + + for (int i = 1; i < argc; ++i) { + std::string arg(argv[i]); + + if (arg == "-display") { + if (++i >= argc) + err = true; + else + _displayreq = argv[i]; + } else if (arg == "-rc") { + if (++i >= argc) + err = true; + else + _rcfilepath = argv[i]; + } else if (arg == "-menu") { + if (++i >= argc) + err = true; + else + _menufilepath = argv[i]; + } else if (arg == "-version") { + showVersion(); + ::exit(0); + } else if (arg == "-help") { + showHelp(); + ::exit(0); + } else + err = true; + + if (err) { + showHelp(); + exit(1); + } + } +} + + +void Openbox::showVersion() +{ + printf(_("Openbox - version %s\n"), OPENBOX_VERSION); + printf(" (c) 2002 - 2002 Ben Jansens\n\n"); +} + + +void Openbox::showHelp() +{ + showVersion(); // show the version string and copyright + + // print program usage and command line options + printf(_("Usage: %s [OPTIONS...]\n\ + Options:\n\ + -display use display connection.\n\ + -rc use alternate resource file.\n\ + -menu use alternate menu file.\n\ + -version display version and exit.\n\ + -help display this help text and exit.\n\n"), _argv0); + + printf(_("Compile time options:\n\ + Debugging: %s\n\ + Shape: %s\n\ + Xinerama: %s\n"), +#ifdef DEBUG + _("yes"), +#else // !DEBUG + _("no"), +#endif // DEBUG + +#ifdef SHAPE + _("yes"), +#else // !SHAPE + _("no"), +#endif // SHAPE + +#ifdef XINERAMA + _("yes") +#else // !XINERAMA + _("no") +#endif // XINERAMA + ); +} + + +void Openbox::eventLoop() +{ + const int xfd = ConnectionNumber(otk::OBDisplay::display); + + while (_state == State_Normal) { + if (XPending(otk::OBDisplay::display)) { + XEvent e; + XNextEvent(otk::OBDisplay::display, &e); + process_event(&e); + } else { + fd_set rfds; + timeval now, tm, *timeout = (timeval *) 0; + + FD_ZERO(&rfds); + FD_SET(xfd, &rfds); + +/* if (! timerList.empty()) { + const BTimer* const timer = timerList.top(); + + gettimeofday(&now, 0); + tm = timer->timeRemaining(now); + + timeout = &tm; + } + + select(xfd + 1, &rfds, 0, 0, timeout); + + // check for timer timeout + gettimeofday(&now, 0); + + // there is a small chance for deadlock here: + // *IF* the timer list keeps getting refreshed *AND* the time between + // timer->start() and timer->shouldFire() is within the timer's period + // then the timer will keep firing. This should be VERY near impossible. + while (! timerList.empty()) { + BTimer *timer = timerList.top(); + if (! timer->shouldFire(now)) + break; + + timerList.pop(); + + timer->fireTimeout(); + timer->halt(); + if (timer->isRecurring()) + timer->start(); + }*/ + } + } +} + + +} + diff --git a/src/openbox.hh b/src/openbox.hh new file mode 100644 index 00000000..56e31d06 --- /dev/null +++ b/src/openbox.hh @@ -0,0 +1,71 @@ +// -*- mode: C++; indent-tabs-mode: nil; -*- +#ifndef __openbox_hh +#define __openbox_hh + +extern "C" { +#include +} + +#include +#include + +#include "otk/screeninfo.hh" + +namespace ob { + +class Openbox +{ +public: + static Openbox *instance; // there can only be ONE instance of this class in + // the program, and it is held in here + + typedef std::vector ScreenInfoList; + + enum RunState { + State_Starting, + State_Normal, + State_Exiting + }; + +private: + std::string _rcfilepath; // path to the config file to use/in use + std::string _menufilepath; // path to the menu file to use/in use + char *_displayreq; // display requested by the user + char *_argv0; // argv[0], how the program was called + + RunState _state; // the state of the window manager + + ScreenInfoList _screenInfoList; // info for all screens on the display + + void parseCommandLine(int argv, char **argv); + void showVersion(); + void showHelp(); + + static int xerrorHandler(Display *d, XErrorEvent *e); + static void signalHandler(int signal); + +public: + //! Openbox constructor. + /*! + \param argc Number of command line arguments, as received in main() + \param argv The command line arguments, as received in main() + */ + Openbox(int argc, char **argv); + //! Openbox destructor. + virtual ~Openbox(); + + //! Returns the state of the window manager (starting, exiting, etc). + inline RunState state() const { return _state; } + + void eventLoop(); + + // XXX: TEMPORARY!#!@%*!^#*!#!#! + virtual void process_event(XEvent *) = 0; + + //! Requests that the window manager exit. + inline void shutdown() { _state = State_Exiting; } +}; + +} + +#endif // __openbox_hh diff --git a/src/screen.cc b/src/screen.cc index 6cd94b50..7ac74c3c 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -54,11 +54,12 @@ extern "C" { #include using std::string; -#include "blackbox.hh" -#include "font.hh" -#include "gccache.hh" -#include "image.hh" #include "screen.hh" +#include "otk/font.hh" +#include "otk/gccache.hh" +#include "otk/image.hh" +#include "otk/assassin.hh" +#include "openbox.hh" #include "util.hh" #include "window.hh" #include "workspace.hh" @@ -69,6 +70,7 @@ using std::string; #define FONT_ELEMENT_SIZE 50 #endif // FONT_ELEMENT_SIZE +namespace ob { static bool running = True; @@ -84,7 +86,7 @@ static int anotherWMRunning(Display *display, XErrorEvent *) { } -BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { +BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) { blackbox = bb; screenstr = "session.screen" + itostring(scrn) + '.'; config = blackbox->getConfig(); @@ -94,8 +96,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask; XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); - XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask); - XSync(getBaseDisplay()->getXDisplay(), False); + XSelectInput(otk::OBDisplay::display, getRootWindow(), event_mask); + XSync(otk::OBDisplay::display, False); XSetErrorHandler((XErrorHandler) old); managed = running; @@ -106,7 +108,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { getScreenNumber(), XVisualIDFromVisual(getVisual()), getDepth()); - resource.wstyle.font = (BFont *) 0; + resource.wstyle.font = (otk::BFont *) 0; geom_pixmap = None; @@ -124,14 +126,14 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { XAtom::cardinal, viewport, 2); - XDefineCursor(blackbox->getXDisplay(), getRootWindow(), + XDefineCursor(otk::OBDisplay::display, getRootWindow(), blackbox->getSessionCursor()); updateAvailableArea(); image_control = - new BImageControl(blackbox, this, True, blackbox->getColorsPerChannel(), - blackbox->getCacheLife(), blackbox->getCacheMax()); + new otk::BImageControl(this, True, blackbox->getColorsPerChannel(), + blackbox->getCacheLife(), blackbox->getCacheMax()); image_control->installRootColormap(); root_colormap_installed = True; @@ -139,11 +141,11 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { LoadStyle(); XGCValues gcv; - gcv.foreground = WhitePixel(blackbox->getXDisplay(), getScreenNumber()) - ^ BlackPixel(blackbox->getXDisplay(), getScreenNumber()); + gcv.foreground = WhitePixel(otk::OBDisplay::display, getScreenNumber()) + ^ BlackPixel(otk::OBDisplay::display, getScreenNumber()); gcv.function = GXxor; gcv.subwindow_mode = IncludeInferiors; - opGC = XCreateGC(blackbox->getXDisplay(), getRootWindow(), + opGC = XCreateGC(otk::OBDisplay::display, getRootWindow(), GCForeground | GCFunction | GCSubwindowMode, &gcv); const char *s = "0: 0000 x 0: 0000"; @@ -156,23 +158,23 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { attrib.colormap = getColormap(); attrib.save_under = True; - geom_window = XCreateWindow(blackbox->getXDisplay(), getRootWindow(), + geom_window = XCreateWindow(otk::OBDisplay::display, getRootWindow(), 0, 0, geom_w, geom_h, resource.border_width, getDepth(), InputOutput, getVisual(), mask, &attrib); geom_visible = False; - BTexture* texture = &(resource.wstyle.l_focus); + otk::BTexture* texture = &(resource.wstyle.l_focus); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap); if (geom_pixmap == ParentRelative) { texture = &(resource.wstyle.t_focus); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap); } if (! geom_pixmap) - XSetWindowBackground(blackbox->getXDisplay(), geom_window, + XSetWindowBackground(otk::OBDisplay::display, geom_window, texture->color().pixel()); else - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, geom_window, geom_pixmap); if (resource.workspaces > 0) { @@ -203,14 +205,14 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { unsigned int i, j, nchild; Window r, p, *children; - XQueryTree(blackbox->getXDisplay(), getRootWindow(), &r, &p, + XQueryTree(otk::OBDisplay::display, getRootWindow(), &r, &p, &children, &nchild); // preen the window list of all icon windows... for better dockapp support for (i = 0; i < nchild; i++) { if (children[i] == None) continue; - XWMHints *wmhints = XGetWMHints(blackbox->getXDisplay(), + XWMHints *wmhints = XGetWMHints(otk::OBDisplay::display, children[i]); if (wmhints) { @@ -234,7 +236,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { continue; XWindowAttributes attrib; - if (XGetWindowAttributes(blackbox->getXDisplay(), children[i], &attrib)) { + if (XGetWindowAttributes(otk::OBDisplay::display, children[i], &attrib)) { if (attrib.override_redirect) continue; if (attrib.map_state != IsUnmapped) { @@ -257,12 +259,12 @@ BScreen::~BScreen(void) { image_control->removeImage(geom_pixmap); if (geom_window != None) - XDestroyWindow(blackbox->getXDisplay(), geom_window); + XDestroyWindow(otk::OBDisplay::display, geom_window); std::for_each(workspacesList.begin(), workspacesList.end(), - PointerAssassin()); + otk::PointerAssassin()); - std::for_each(iconList.begin(), iconList.end(), PointerAssassin()); + std::for_each(iconList.begin(), iconList.end(), otk::PointerAssassin()); while (! systrayWindowList.empty()) removeSystrayWindow(systrayWindowList[0]); @@ -273,19 +275,19 @@ BScreen::~BScreen(void) { delete resource.wstyle.font; if (resource.wstyle.close_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask); if (resource.wstyle.max_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask); if (resource.wstyle.icon_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask); if (resource.wstyle.stick_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask); resource.wstyle.max_button.mask = resource.wstyle.close_button.mask = resource.wstyle.icon_button.mask = resource.wstyle.stick_button.mask = None; - XFreeGC(blackbox->getXDisplay(), opGC); + XFreeGC(otk::OBDisplay::display, opGC); } @@ -722,7 +724,7 @@ void BScreen::changeWorkspaceCount(unsigned int new_count) { void BScreen::reconfigure(void) { // don't reconfigure while saving the initial rc file, it's a waste and it // breaks somethings (workspace names) - if (blackbox->isStartup()) return; + if (blackbox->state() == Openbox::State_Starting) return; load_rc(); LoadStyle(); @@ -732,11 +734,11 @@ void BScreen::reconfigure(void) { changeWorkspaceCount(resource.workspaces); XGCValues gcv; - gcv.foreground = WhitePixel(blackbox->getXDisplay(), + gcv.foreground = WhitePixel(otk::OBDisplay::display, getScreenNumber()); gcv.function = GXinvert; gcv.subwindow_mode = IncludeInferiors; - XChangeGC(blackbox->getXDisplay(), opGC, + XChangeGC(otk::OBDisplay::display, opGC, GCForeground | GCFunction | GCSubwindowMode, &gcv); const char *s = "0: 0000 x 0: 0000"; @@ -744,22 +746,22 @@ void BScreen::reconfigure(void) { geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2; geom_h = resource.wstyle.font->height() + resource.bevel_width * 2; - BTexture* texture = &(resource.wstyle.l_focus); + otk::BTexture* texture = &(resource.wstyle.l_focus); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap); if (geom_pixmap == ParentRelative) { texture = &(resource.wstyle.t_focus); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap); } if (! geom_pixmap) - XSetWindowBackground(blackbox->getXDisplay(), geom_window, + XSetWindowBackground(otk::OBDisplay::display, geom_window, texture->color().pixel()); else - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, geom_window, geom_pixmap); - XSetWindowBorderWidth(blackbox->getXDisplay(), geom_window, + XSetWindowBorderWidth(otk::OBDisplay::display, geom_window, resource.border_width); - XSetWindowBorder(blackbox->getXDisplay(), geom_window, + XSetWindowBorder(otk::OBDisplay::display, geom_window, resource.border_color.pixel()); typedef std::vector SubList; @@ -836,13 +838,13 @@ void BScreen::LoadStyle(void) { readDatabaseTexture("window.button.pressed.unfocus", "black", style, true); if (resource.wstyle.close_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask); if (resource.wstyle.max_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask); if (resource.wstyle.icon_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask); if (resource.wstyle.stick_button.mask != None) - XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask); + XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask); resource.wstyle.close_button.mask = resource.wstyle.max_button.mask = resource.wstyle.icon_button.mask = @@ -859,14 +861,15 @@ void BScreen::LoadStyle(void) { // we create the window.frame texture by hand because it exists only to // make the code cleaner and is not actually used for display - BColor color = readDatabaseColor("window.frame.focusColor", "white", style); - resource.wstyle.f_focus = BTexture("solid flat", getBaseDisplay(), - getScreenNumber(), image_control); + otk::BColor color = readDatabaseColor("window.frame.focusColor", "white", + style); + resource.wstyle.f_focus = otk::BTexture("solid flat", getScreenNumber(), + image_control); resource.wstyle.f_focus.setColor(color); color = readDatabaseColor("window.frame.unfocusColor", "white", style); - resource.wstyle.f_unfocus = BTexture("solid flat", getBaseDisplay(), - getScreenNumber(), image_control); + resource.wstyle.f_unfocus = otk::BTexture("solid flat", getScreenNumber(), + image_control); resource.wstyle.f_unfocus.setColor(color); resource.wstyle.l_text_focus = @@ -887,13 +890,13 @@ void BScreen::LoadStyle(void) { } // sanity checks - if (resource.wstyle.t_focus.texture() == BTexture::Parent_Relative) + if (resource.wstyle.t_focus.texture() == otk::BTexture::Parent_Relative) resource.wstyle.t_focus = resource.wstyle.f_focus; - if (resource.wstyle.t_unfocus.texture() == BTexture::Parent_Relative) + if (resource.wstyle.t_unfocus.texture() == otk::BTexture::Parent_Relative) resource.wstyle.t_unfocus = resource.wstyle.f_unfocus; - if (resource.wstyle.h_focus.texture() == BTexture::Parent_Relative) + if (resource.wstyle.h_focus.texture() == otk::BTexture::Parent_Relative) resource.wstyle.h_focus = resource.wstyle.f_focus; - if (resource.wstyle.h_unfocus.texture() == BTexture::Parent_Relative) + if (resource.wstyle.h_unfocus.texture() == otk::BTexture::Parent_Relative) resource.wstyle.h_unfocus = resource.wstyle.f_unfocus; resource.border_color = @@ -1021,12 +1024,12 @@ void BScreen::changeWorkspaceID(unsigned int id) { BlackboxWindow *win = (BlackboxWindow *) 0; bool f = False; - XSync(blackbox->getXDisplay(), False); + XSync(otk::OBDisplay::display, False); // If sloppy focus and we can find the client window under the pointer, // try to focus it. if (resource.sloppy_focus && - XQueryPointer(blackbox->getXDisplay(), getRootWindow(), &r, &c, + XQueryPointer(otk::OBDisplay::display, getRootWindow(), &r, &c, &rx, &ry, &x, &y, &m) && c != None) { if ( (win = blackbox->searchWindow(c)) ) @@ -1112,21 +1115,21 @@ void BScreen::updateStackingList(void) { void BScreen::addSystrayWindow(Window window) { - XGrabServer(blackbox->getXDisplay()); + XGrabServer(otk::OBDisplay::display); - XSelectInput(blackbox->getXDisplay(), window, StructureNotifyMask); + XSelectInput(otk::OBDisplay::display, window, StructureNotifyMask); systrayWindowList.push_back(window); xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows, XAtom::window, &systrayWindowList[0], systrayWindowList.size()); blackbox->saveSystrayWindowSearch(window, this); - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); } void BScreen::removeSystrayWindow(Window window) { - XGrabServer(blackbox->getXDisplay()); + XGrabServer(otk::OBDisplay::display); WindowList::iterator it = systrayWindowList.begin(); const WindowList::iterator end = systrayWindowList.end(); @@ -1137,13 +1140,13 @@ void BScreen::removeSystrayWindow(Window window) { XAtom::window, &systrayWindowList[0], systrayWindowList.size()); blackbox->removeSystrayWindowSearch(window); - XSelectInput(blackbox->getXDisplay(), window, NoEventMask); + XSelectInput(otk::OBDisplay::display, window, NoEventMask); break; } assert(it != end); // not a systray window - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); } @@ -1157,7 +1160,7 @@ void BScreen::manageWindow(Window w) { } // is the window a docking app - XWMHints *wmhint = XGetWMHints(blackbox->getXDisplay(), w); + XWMHints *wmhint = XGetWMHints(otk::OBDisplay::display, w); if (wmhint && (wmhint->flags & StateHint) && wmhint->initial_state == WithdrawnState) { //slit->addClient(w); @@ -1183,7 +1186,9 @@ void BScreen::manageWindow(Window w) { XMapRequestEvent mre; mre.window = w; - if (blackbox->isStartup() && win->isNormal()) win->restoreAttributes(); + if (blackbox->state() == Openbox::State_Starting && + win->isNormal()) + win->restoreAttributes(); win->mapRequestEvent(&mre); } @@ -1259,7 +1264,7 @@ void BScreen::updateWorkArea(void) { unsigned long *dims = new unsigned long[4 * workspacesList.size()]; for (unsigned int i = 0, m = workspacesList.size(); i < m; ++i) { // XXX: this could be different for each workspace - const Rect &area = availableArea(); + const otk::Rect &area = availableArea(); dims[(i * 4) + 0] = area.x(); dims[(i * 4) + 1] = area.y(); dims[(i * 4) + 2] = area.width(); @@ -1309,7 +1314,7 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) { while (k--) *(session_stack + i++) = *(workspace_stack + k); - XRestackWindows(blackbox->getXDisplay(), session_stack, i); + XRestackWindows(otk::OBDisplay::display, session_stack, i); delete [] session_stack; @@ -1323,7 +1328,7 @@ void BScreen::lowerWindows(Window *workspace_stack, unsigned int num) { Window *session_stack = new Window[(num + desktopWindowList.size())]; unsigned int i = 0, k = num; - XLowerWindow(blackbox->getXDisplay(), workspace_stack[0]); + XLowerWindow(otk::OBDisplay::display, workspace_stack[0]); while (k--) *(session_stack + i++) = *(workspace_stack + k); @@ -1333,7 +1338,7 @@ void BScreen::lowerWindows(Window *workspace_stack, unsigned int num) { for (; dit != d_end; ++dit) *(session_stack + i++) = *dit; - XRestackWindows(blackbox->getXDisplay(), session_stack, i); + XRestackWindows(otk::OBDisplay::display, session_stack, i); delete [] session_stack; @@ -1438,8 +1443,8 @@ void BScreen::raiseFocus(void) const { void BScreen::shutdown(void) { - XSelectInput(blackbox->getXDisplay(), getRootWindow(), NoEventMask); - XSync(blackbox->getXDisplay(), False); + XSelectInput(otk::OBDisplay::display, getRootWindow(), NoEventMask); + XSync(otk::OBDisplay::display, False); while(! windowList.empty()) unmanageWindow(windowList.front(), True); @@ -1454,11 +1459,11 @@ void BScreen::shutdown(void) { void BScreen::showPosition(int x, int y) { if (! geom_visible) { - XMoveResizeWindow(blackbox->getXDisplay(), geom_window, + XMoveResizeWindow(otk::OBDisplay::display, geom_window, (getWidth() - geom_w) / 2, (getHeight() - geom_h) / 2, geom_w, geom_h); - XMapWindow(blackbox->getXDisplay(), geom_window); - XRaiseWindow(blackbox->getXDisplay(), geom_window); + XMapWindow(otk::OBDisplay::display, geom_window); + XRaiseWindow(otk::OBDisplay::display, geom_window); geom_visible = True; } @@ -1467,7 +1472,7 @@ void BScreen::showPosition(int x, int y) { sprintf(label, "X: %4d x Y: %4d", x, y); - XClearWindow(blackbox->getXDisplay(), geom_window); + XClearWindow(otk::OBDisplay::display, geom_window); resource.wstyle.font->drawString(geom_window, resource.bevel_width, resource.bevel_width, @@ -1478,11 +1483,11 @@ void BScreen::showPosition(int x, int y) { void BScreen::showGeometry(unsigned int gx, unsigned int gy) { if (! geom_visible) { - XMoveResizeWindow(blackbox->getXDisplay(), geom_window, + XMoveResizeWindow(otk::OBDisplay::display, geom_window, (getWidth() - geom_w) / 2, (getHeight() - geom_h) / 2, geom_w, geom_h); - XMapWindow(blackbox->getXDisplay(), geom_window); - XRaiseWindow(blackbox->getXDisplay(), geom_window); + XMapWindow(otk::OBDisplay::display, geom_window); + XRaiseWindow(otk::OBDisplay::display, geom_window); geom_visible = True; } @@ -1491,7 +1496,7 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { sprintf(label, "W: %4d x H: %4d", gx, gy); - XClearWindow(blackbox->getXDisplay(), geom_window); + XClearWindow(otk::OBDisplay::display, geom_window); resource.wstyle.font->drawString(geom_window, resource.bevel_width, resource.bevel_width, @@ -1502,7 +1507,7 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { void BScreen::hideGeometry(void) { if (geom_visible) { - XUnmapWindow(blackbox->getXDisplay(), geom_window); + XUnmapWindow(otk::OBDisplay::display, geom_window); geom_visible = False; } } @@ -1518,7 +1523,7 @@ void BScreen::removeStrut(Strut *strut) { } -const Rect& BScreen::availableArea(void) const { +const otk::Rect& BScreen::availableArea(void) const { if (doFullMax()) return getRect(); // return the full screen return usableArea; @@ -1538,7 +1543,7 @@ const RectList& BScreen::allAvailableAreas(void) const { void BScreen::updateAvailableArea(void) { - Rect old_area = usableArea; + otk::Rect old_area = usableArea; usableArea = getRect(); // reset to full screen #ifdef XINERAMA @@ -1677,11 +1682,11 @@ void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask, if (s[0] != '/' && s[0] != '~') { std::string xbmFile = std::string("~/.openbox/buttons/") + s; - ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(), + ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(), expandTilde(xbmFile).c_str(), &pixmapMask.w, &pixmapMask.h, &pixmapMask.mask, &hx, &hy); } else - ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(), + ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(), expandTilde(s).c_str(), &pixmapMask.w, &pixmapMask.h, &pixmapMask.mask, &hx, &hy); @@ -1693,25 +1698,25 @@ void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask, pixmapMask.w = pixmapMask.h = 0; } -BTexture BScreen::readDatabaseTexture(const string &rname, - const string &default_color, - const Configuration &style, - bool allowNoTexture) { - BTexture texture; +otk::BTexture BScreen::readDatabaseTexture(const string &rname, + const string &default_color, + const Configuration &style, + bool allowNoTexture) { + otk::BTexture texture; string s; if (style.getValue(rname, s)) - texture = BTexture(s); + texture = otk::BTexture(s); else if (allowNoTexture) //no default - texture.setTexture(BTexture::NoTexture); + texture.setTexture(otk::BTexture::NoTexture); else - texture.setTexture(BTexture::Solid | BTexture::Flat); + texture.setTexture(otk::BTexture::Solid | otk::BTexture::Flat); // associate this texture with this screen - texture.setDisplay(getBaseDisplay(), getScreenNumber()); + texture.setScreen(getScreenNumber()); texture.setImageControl(image_control); - if (texture.texture() != BTexture::NoTexture) { + if (texture.texture() != otk::BTexture::NoTexture) { texture.setColor(readDatabaseColor(rname + ".color", default_color, style)); texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color, @@ -1724,21 +1729,21 @@ BTexture BScreen::readDatabaseTexture(const string &rname, } -BColor BScreen::readDatabaseColor(const string &rname, - const string &default_color, - const Configuration &style) { - BColor color; +otk::BColor BScreen::readDatabaseColor(const string &rname, + const string &default_color, + const Configuration &style) { + otk::BColor color; string s; if (style.getValue(rname, s)) - color = BColor(s, getBaseDisplay(), getScreenNumber()); + color = otk::BColor(s, getScreenNumber()); else - color = BColor(default_color, getBaseDisplay(), getScreenNumber()); + color = otk::BColor(default_color, getScreenNumber()); return color; } -BFont *BScreen::readDatabaseFont(const string &rbasename, - const Configuration &style) { +otk::BFont *BScreen::readDatabaseFont(const string &rbasename, + const Configuration &style) { string fontname; string s; @@ -1773,9 +1778,9 @@ BFont *BScreen::readDatabaseFont(const string &rbasename, } - BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, - italic, dropShadow && resource.shadow_fonts, offset, - tint, resource.aa_fonts); + otk::BFont *b = new otk::BFont(getScreenNumber(), family, i, bold, italic, + dropShadow && resource.shadow_fonts, + offset, tint, resource.aa_fonts); if (b->valid()) return b; delete b; @@ -1783,3 +1788,5 @@ BFont *BScreen::readDatabaseFont(const string &rbasename, exit(2); // can't continue without a font } + +} diff --git a/src/screen.hh b/src/screen.hh index d818a684..a1f36956 100644 --- a/src/screen.hh +++ b/src/screen.hh @@ -20,15 +20,16 @@ extern "C" { #include #include -#include "color.hh" -#include "texture.hh" -#include "image.hh" +#include "otk/color.hh" +#include "otk/font.hh" +#include "otk/texture.hh" +#include "otk/image.hh" #include "timer.hh" #include "workspace.hh" #include "blackbox.hh" -class Slit; // forward reference -class BFont; +namespace ob { + class XAtom; struct Strut; @@ -40,14 +41,14 @@ struct PixmapMask { }; struct WindowStyle { - BColor l_text_focus, l_text_unfocus, b_pic_focus, + otk::BColor l_text_focus, l_text_unfocus, b_pic_focus, b_pic_unfocus; - BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus, + otk::BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus, b_focus, b_unfocus, b_pressed, b_pressed_focus, b_pressed_unfocus, g_focus, g_unfocus; PixmapMask close_button, max_button, icon_button, stick_button; - BFont *font; + otk::BFont *font; TextJustify justify; @@ -55,7 +56,7 @@ struct WindowStyle { unsigned int max_length, unsigned int modifier) const; }; -class BScreen : public ScreenInfo { +class BScreen : public otk::ScreenInfo { private: bool root_colormap_installed, managed, geom_visible; GC opGC; @@ -63,7 +64,7 @@ private: Window geom_window; Blackbox *blackbox; - BImageControl *image_control; + otk::BImageControl *image_control; Configuration *config; XAtom *xatom; @@ -77,7 +78,7 @@ private: unsigned int geom_w, geom_h; unsigned long event_mask; - Rect usableArea; + otk::Rect usableArea; #ifdef XINERAMA RectList xineramaUsableArea; #endif // XINERAMA @@ -98,7 +99,7 @@ private: int snap_to_windows, snap_to_edges; unsigned int snap_offset; - BColor border_color; + otk::BColor border_color; unsigned int workspaces; int placement_policy, @@ -120,15 +121,15 @@ private: PixmapMask &pixmapMask, const Configuration &style); - BTexture readDatabaseTexture(const std::string &rname, + otk::BTexture readDatabaseTexture(const std::string &rname, const std::string &default_color, const Configuration &style, bool allowNoTexture = false); - BColor readDatabaseColor(const std::string &rname, + otk::BColor readDatabaseColor(const std::string &rname, const std::string &default_color, const Configuration &style); - BFont *readDatabaseFont(const std::string &rbasename, - const Configuration &style); + otk::BFont *readDatabaseFont(const std::string &rbasename, + const Configuration &style); void LoadStyle(void); @@ -182,8 +183,8 @@ public: inline const GC &getOpGC(void) const { return opGC; } inline Blackbox *getBlackbox(void) { return blackbox; } - inline BColor *getBorderColor(void) { return &resource.border_color; } - inline BImageControl *getImageControl(void) { return image_control; } + inline otk::BColor *getBorderColor(void) { return &resource.border_color; } + inline otk::BImageControl *getImageControl(void) { return image_control; } Workspace *getWorkspace(unsigned int index) const; @@ -264,7 +265,7 @@ public: // allAvailableAreas should be used whenever possible instead of this function // as then Xinerama will work correctly. - const Rect& availableArea(void) const; + const otk::Rect& availableArea(void) const; #ifdef XINERAMA const RectList& allAvailableAreas(void) const; #endif // XINERAMA @@ -308,5 +309,6 @@ public: void propertyNotifyEvent(const XPropertyEvent *pe); }; +} #endif // __Screen_hh diff --git a/src/screeninfo.cc b/src/screeninfo.cc deleted file mode 100644 index 586b5f30..00000000 --- a/src/screeninfo.cc +++ /dev/null @@ -1,114 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H - -#include "screeninfo.hh" -#include "basedisplay.hh" - -using std::string; - -ScreenInfo::ScreenInfo(BaseDisplay *d, unsigned int num) { - basedisplay = d; - screen_number = num; - - root_window = RootWindow(basedisplay->getXDisplay(), screen_number); - - rect.setSize(WidthOfScreen(ScreenOfDisplay(basedisplay->getXDisplay(), - screen_number)), - HeightOfScreen(ScreenOfDisplay(basedisplay->getXDisplay(), - screen_number))); - /* - If the default depth is at least 8 we will use that, - otherwise we try to find the largest TrueColor visual. - Preference is given to 24 bit over larger depths if 24 bit is an option. - */ - - depth = DefaultDepth(basedisplay->getXDisplay(), screen_number); - visual = DefaultVisual(basedisplay->getXDisplay(), screen_number); - colormap = DefaultColormap(basedisplay->getXDisplay(), screen_number); - - if (depth < 8) { - // search for a TrueColor Visual... if we can't find one... - // we will use the default visual for the screen - XVisualInfo vinfo_template, *vinfo_return; - int vinfo_nitems; - int best = -1; - - vinfo_template.screen = screen_number; - vinfo_template.c_class = TrueColor; - - vinfo_return = XGetVisualInfo(basedisplay->getXDisplay(), - VisualScreenMask | VisualClassMask, - &vinfo_template, &vinfo_nitems); - if (vinfo_return) { - int max_depth = 1; - for (int i = 0; i < vinfo_nitems; ++i) { - if (vinfo_return[i].depth > max_depth) { - if (max_depth == 24 && vinfo_return[i].depth > 24) - break; // prefer 24 bit over 32 - max_depth = vinfo_return[i].depth; - best = i; - } - } - if (max_depth < depth) best = -1; - } - - if (best != -1) { - depth = vinfo_return[best].depth; - visual = vinfo_return[best].visual; - colormap = XCreateColormap(basedisplay->getXDisplay(), root_window, - visual, AllocNone); - } - - XFree(vinfo_return); - } - - // get the default display string and strip the screen number - string default_string = DisplayString(basedisplay->getXDisplay()); - const string::size_type pos = default_string.rfind("."); - if (pos != string::npos) - default_string.resize(pos); - - display_string = string("DISPLAY=") + default_string + '.' + - itostring(static_cast(screen_number)); - -#ifdef XINERAMA - xinerama_active = False; - - if (d->hasXineramaExtensions()) { - if (d->getXineramaMajorVersion() == 1) { - // we know the version 1(.1?) protocol - - /* - in this version of Xinerama, we can't query on a per-screen basis, but - in future versions we should be able, so the 'activeness' is checked - on a pre-screen basis anyways. - */ - if (XineramaIsActive(d->getXDisplay())) { - /* - If Xinerama is being used, there there is only going to be one screen - present. We still, of course, want to use the screen class, but that - is why no screen number is used in this function call. There should - never be more than one screen present with Xinerama active. - */ - int num; - XineramaScreenInfo *info = XineramaQueryScreens(d->getXDisplay(), &num); - if (num > 0 && info) { - xinerama_areas.reserve(num); - for (int i = 0; i < num; ++i) { - xinerama_areas.push_back(Rect(info[i].x_org, info[i].y_org, - info[i].width, info[i].height)); - } - XFree(info); - - // if we can't find any xinerama regions, then we act as if it is not - // active, even though it said it was - xinerama_active = True; - } - } - } - } -#endif // XINERAMA -} diff --git a/src/screeninfo.hh b/src/screeninfo.hh deleted file mode 100644 index 880b4ae5..00000000 --- a/src/screeninfo.hh +++ /dev/null @@ -1,52 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -#ifndef __screeninfo_hh -#define __screeninfo_hh - -#include "util.hh" - -extern "C" { -#include -} - -#include - -class BaseDisplay; - -class ScreenInfo { -private: - BaseDisplay *basedisplay; - Visual *visual; - Window root_window; - Colormap colormap; - - int depth; - unsigned int screen_number; - std::string display_string; - Rect rect; -#ifdef XINERAMA - RectList xinerama_areas; - bool xinerama_active; -#endif - -public: - ScreenInfo(BaseDisplay *d, unsigned int num); - - inline BaseDisplay *getBaseDisplay(void) const { return basedisplay; } - inline Visual *getVisual(void) const { return visual; } - inline Window getRootWindow(void) const { return root_window; } - inline Colormap getColormap(void) const { return colormap; } - inline int getDepth(void) const { return depth; } - inline unsigned int getScreenNumber(void) const - { return screen_number; } - inline const Rect& getRect(void) const { return rect; } - inline unsigned int getWidth(void) const { return rect.width(); } - inline unsigned int getHeight(void) const { return rect.height(); } - inline const std::string& displayString(void) const - { return display_string; } -#ifdef XINERAMA - inline const RectList &getXineramaAreas(void) const { return xinerama_areas; } - inline bool isXineramaActive(void) const { return xinerama_active; } -#endif -}; - -#endif // __screeninfo_hh diff --git a/src/timer.cc b/src/timer.cc index c785b345..76fb022d 100644 --- a/src/timer.cc +++ b/src/timer.cc @@ -4,10 +4,11 @@ # include "../config.h" #endif // HAVE_CONFIG_H -#include "basedisplay.hh" #include "timer.hh" #include "util.hh" +namespace ob { + BTimer::BTimer(TimerQueueManager *m, TimeoutHandler *h) { manager = m; handler = h; @@ -88,3 +89,5 @@ bool BTimer::shouldFire(const timeval &tm) const { return ! ((tm.tv_sec < end.tv_sec) || (tm.tv_sec == end.tv_sec && tm.tv_usec < end.tv_usec)); } + +} diff --git a/src/timer.hh b/src/timer.hh index b022b0c4..121dfbc9 100644 --- a/src/timer.hh +++ b/src/timer.hh @@ -15,6 +15,12 @@ extern "C" { #endif // TIME_WITH_SYS_TIME } +#include +#include +#include + +namespace ob { + // forward declaration class TimerQueueManager; @@ -64,9 +70,6 @@ public: }; -#include -#include - template class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> { public: @@ -97,7 +100,6 @@ struct TimerLessThan { } }; -#include typedef _timer_queue, TimerLessThan> TimerQueue; class TimerQueueManager { @@ -106,4 +108,6 @@ public: virtual void removeTimer(BTimer* timer) = 0; }; +} + #endif // _BLACKBOX_Timer_hh diff --git a/src/util.cc b/src/util.cc index 83b07677..6a6ac417 100644 --- a/src/util.cc +++ b/src/util.cc @@ -10,22 +10,15 @@ extern "C" { #ifdef HAVE_STRING_H #include #endif + #ifdef HAVE_STDLIB_H #include #endif -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else // !TIME_WITH_SYS_TIME -# ifdef HAVE_SYS_TIME_H -# include -# else // !HAVE_SYS_TIME_H -# include -# endif // HAVE_SYS_TIME_H -#endif // TIME_WITH_SYS_TIME + #ifdef HAVE_UNISTD_H #include #endif // HAVE_UNISTD_H + #if defined(HAVE_PROCESS_H) && defined(__EMX__) # include #endif // HAVE_PROCESS_H __EMX__ @@ -39,98 +32,7 @@ extern "C" { using std::string; - -void Rect::setX(int x) { - _x2 += x - _x1; - _x1 = x; -} - - -void Rect::setY(int y) -{ - _y2 += y - _y1; - _y1 = y; -} - - -void Rect::setPos(int x, int y) { - _x2 += x - _x1; - _x1 = x; - _y2 += y - _y1; - _y1 = y; -} - - -void Rect::setWidth(unsigned int w) { - _x2 = w + _x1 - 1; -} - - -void Rect::setHeight(unsigned int h) { - _y2 = h + _y1 - 1; -} - - -void Rect::setSize(unsigned int w, unsigned int h) { - _x2 = w + _x1 - 1; - _y2 = h + _y1 - 1; -} - - -void Rect::setRect(int x, int y, unsigned int w, unsigned int h) { - *this = Rect(x, y, w, h); -} - - -void Rect::setCoords(int l, int t, int r, int b) { - _x1 = l; - _y1 = t; - _x2 = r; - _y2 = b; -} - - -Rect Rect::operator|(const Rect &a) const { - Rect b; - - b._x1 = std::min(_x1, a._x1); - b._y1 = std::min(_y1, a._y1); - b._x2 = std::max(_x2, a._x2); - b._y2 = std::max(_y2, a._y2); - - return b; -} - - -Rect Rect::operator&(const Rect &a) const { - Rect b; - - b._x1 = std::max(_x1, a._x1); - b._y1 = std::max(_y1, a._y1); - b._x2 = std::min(_x2, a._x2); - b._y2 = std::min(_y2, a._y2); - - return b; -} - - -bool Rect::intersects(const Rect &a) const { - return std::max(_x1, a._x1) <= std::min(_x2, a._x2) && - std::max(_y1, a._y1) <= std::min(_y2, a._y2); -} - - -bool Rect::contains(int x, int y) const { - return x >= _x1 && x <= _x2 && - y >= _y1 && y <= _y2; -} - - -bool Rect::contains(const Rect& a) const { - return a._x1 >= _x1 && a._x2 <= _x2 && - a._y1 >= _y1 && a._y2 <= _y2; -} - +namespace ob { string expandTilde(const string& s) { if (s[0] != '~') return s; @@ -157,16 +59,6 @@ void bexec(const string& command, const string& displaystring) { } -#ifndef HAVE_BASENAME -string basename (const string& path) { - string::size_type slash = path.rfind('/'); - if (slash == string::npos) - return path; - return path.substr(slash+1); -} -#endif // HAVE_BASENAME - - string textPropertyToString(Display *display, XTextProperty& text_prop) { string ret; @@ -231,3 +123,15 @@ string itostring(long i) { tmp.insert(tmp.begin(), '-'); return tmp; } + +} + +#ifndef HAVE_BASENAME +string basename (const string& path) { + string::size_type slash = path.rfind('/'); + if (slash == string::npos) + return path; + return path.substr(slash+1); +} +#endif // HAVE_BASENAME + diff --git a/src/util.hh b/src/util.hh index 74e1a036..1e17657e 100644 --- a/src/util.hh +++ b/src/util.hh @@ -2,62 +2,27 @@ #ifndef _BLACKBOX_UTIL_HH #define _BLACKBOX_UTIL_HH +extern "C" { #include #include +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else // !TIME_WITH_SYS_TIME +# ifdef HAVE_SYS_TIME_H +# include +# else // !HAVE_SYS_TIME_H +# include +# endif // HAVE_SYS_TIME_H +#endif // TIME_WITH_SYS_TIME +} + + #include #include -class Rect { -public: - inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { } - inline Rect(int __x, int __y, unsigned int __w, unsigned int __h) - : _x1(__x), _y1(__y), _x2(__w + __x - 1), _y2(__h + __y - 1) { } - inline explicit Rect(const XRectangle& xrect) - : _x1(xrect.x), _y1(xrect.y), _x2(xrect.width + xrect.x - 1), - _y2(xrect.height + xrect.y - 1) { } - - inline int left(void) const { return _x1; } - inline int top(void) const { return _y1; } - inline int right(void) const { return _x2; } - inline int bottom(void) const { return _y2; } - - inline int x(void) const { return _x1; } - inline int y(void) const { return _y1; } - void setX(int __x); - void setY(int __y); - void setPos(int __x, int __y); - - inline unsigned int width(void) const { return _x2 - _x1 + 1; } - inline unsigned int height(void) const { return _y2 - _y1 + 1; } - void setWidth(unsigned int __w); - void setHeight(unsigned int __h); - void setSize(unsigned int __w, unsigned int __h); - - void setRect(int __x, int __y, unsigned int __w, unsigned int __h); - - void setCoords(int __l, int __t, int __r, int __b); - - inline bool operator==(const Rect &a) - { return _x1 == a._x1 && _y1 == a._y1 && _x2 == a._x2 && _y2 == a._y2; } - inline bool operator!=(const Rect &a) { return ! operator==(a); } - - Rect operator|(const Rect &a) const; - Rect operator&(const Rect &a) const; - inline Rect &operator|=(const Rect &a) { *this = *this | a; return *this; } - inline Rect &operator&=(const Rect &a) { *this = *this & a; return *this; } - - inline bool valid(void) const { return _x2 > _x1 && _y2 > _y1; } - - bool intersects(const Rect &a) const; - bool contains(int __x, int __y) const; - bool contains(const Rect &a) const; - -private: - int _x1, _y1, _x2, _y2; -}; - -typedef std::vector RectList; +namespace ob { struct Strut { unsigned int top, bottom, left, right; @@ -72,27 +37,21 @@ std::string expandTilde(const std::string& s); void bexec(const std::string& command, const std::string& displaystring); -#ifndef HAVE_BASENAME -std::string basename(const std::string& path); -#endif - std::string textPropertyToString(Display *display, XTextProperty& text_prop); -struct timeval; // forward declare to avoid the header timeval normalizeTimeval(const timeval &tm); -struct PointerAssassin { - template - inline void operator()(const T ptr) const { - delete ptr; - } -}; - std::string itostring(unsigned long i); std::string itostring(long i); inline std::string itostring(unsigned int i) { return itostring((unsigned long) i); } inline std::string itostring(int i) { return itostring((long) i); } - + +} + +#ifndef HAVE_BASENAME +std::string basename(const std::string& path); +#endif + #endif diff --git a/src/window.cc b/src/window.cc index e7f5db1d..94589a2d 100644 --- a/src/window.cc +++ b/src/window.cc @@ -35,6 +35,8 @@ extern "C" { using std::string; using std::abs; +namespace ob { + /* * Initializes the class with default values/the window's set initial values. */ @@ -64,7 +66,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { // fetch client size and placement XWindowAttributes wattrib; - if (! XGetWindowAttributes(blackbox->getXDisplay(), + if (! XGetWindowAttributes(otk::OBDisplay::display, client.window, &wattrib) || ! wattrib.screen || wattrib.override_redirect) { #ifdef DEBUG @@ -83,7 +85,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { StructureNotifyMask; attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; - XChangeWindowAttributes(blackbox->getXDisplay(), client.window, + XChangeWindowAttributes(otk::OBDisplay::display, client.window, CWEventMask|CWDontPropagate, &attrib_set); flags.moving = flags.resizing = flags.shaded = flags.visible = @@ -214,11 +216,12 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { upsize(); bool place_window = True; - if (blackbox->isStartup() || isTransient() || + if (blackbox->state() == Openbox::State_Starting || isTransient() || client.normal_hint_flags & (PPosition|USPosition)) { applyGravity(frame.rect); - if (blackbox->isStartup() || client.rect.intersects(screen->getRect())) + if (blackbox->state() == Openbox::State_Starting || + client.rect.intersects(screen->getRect())) place_window = False; } @@ -232,7 +235,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { We hold the grab until after we are done moving the window around. */ - XGrabServer(blackbox->getXDisplay()); + XGrabServer(otk::OBDisplay::display); associateClientWindow(); @@ -254,7 +257,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { positionWindows(); - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); #ifdef SHAPE if (blackbox->hasShapeExtensions() && flags.shaped) @@ -267,7 +270,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { grabButtons(); - XMapSubwindows(blackbox->getXDisplay(), frame.window); + XMapSubwindows(otk::OBDisplay::display, frame.window); // this ensures the title, buttons, and other decor are properly displayed redrawWindowFrame(); @@ -355,12 +358,12 @@ BlackboxWindow::~BlackboxWindow(void) { if (frame.plate) { blackbox->removeWindowSearch(frame.plate); - XDestroyWindow(blackbox->getXDisplay(), frame.plate); + XDestroyWindow(otk::OBDisplay::display, frame.plate); } if (frame.window) { blackbox->removeWindowSearch(frame.window); - XDestroyWindow(blackbox->getXDisplay(), frame.window); + XDestroyWindow(otk::OBDisplay::display, frame.window); } blackbox->removeWindowSearch(client.window); @@ -377,8 +380,8 @@ void BlackboxWindow::enableDecor(bool enable) { shade(); if (flags.visible && frame.window) { - XMapSubwindows(blackbox->getXDisplay(), frame.window); - XMapWindow(blackbox->getXDisplay(), frame.window); + XMapSubwindows(otk::OBDisplay::display, frame.window); + XMapWindow(otk::OBDisplay::display, frame.window); } reconfigure(); @@ -448,7 +451,7 @@ Window BlackboxWindow::createToplevelWindow(void) { window's frame. */ - return XCreateWindow(blackbox->getXDisplay(), screen->getRootWindow(), + return XCreateWindow(otk::OBDisplay::display, screen->getRootWindow(), 0, 0, 1, 1, frame.border_w, screen->getDepth(), InputOutput, screen->getVisual(), create_mask, &attrib_create); @@ -474,20 +477,20 @@ Window BlackboxWindow::createChildWindow(Window parent, attrib_create.cursor = cursor; } - return XCreateWindow(blackbox->getXDisplay(), parent, 0, 0, 1, 1, 0, + return XCreateWindow(otk::OBDisplay::display, parent, 0, 0, 1, 1, 0, screen->getDepth(), InputOutput, screen->getVisual(), create_mask, &attrib_create); } void BlackboxWindow::associateClientWindow(void) { - XSetWindowBorderWidth(blackbox->getXDisplay(), client.window, 0); + XSetWindowBorderWidth(otk::OBDisplay::display, client.window, 0); getWMName(); getWMIconName(); - XChangeSaveSet(blackbox->getXDisplay(), client.window, SetModeInsert); + XChangeSaveSet(otk::OBDisplay::display, client.window, SetModeInsert); - XSelectInput(blackbox->getXDisplay(), frame.plate, SubstructureRedirectMask); + XSelectInput(otk::OBDisplay::display, frame.plate, SubstructureRedirectMask); /* note we used to grab around this call to XReparentWindow however the @@ -495,24 +498,24 @@ void BlackboxWindow::associateClientWindow(void) { */ unsigned long event_mask = PropertyChangeMask | FocusChangeMask | StructureNotifyMask; - XSelectInput(blackbox->getXDisplay(), client.window, + XSelectInput(otk::OBDisplay::display, client.window, event_mask & ~StructureNotifyMask); - XReparentWindow(blackbox->getXDisplay(), client.window, frame.plate, 0, 0); - XSelectInput(blackbox->getXDisplay(), client.window, event_mask); + XReparentWindow(otk::OBDisplay::display, client.window, frame.plate, 0, 0); + XSelectInput(otk::OBDisplay::display, client.window, event_mask); - XRaiseWindow(blackbox->getXDisplay(), frame.plate); - XMapSubwindows(blackbox->getXDisplay(), frame.plate); + XRaiseWindow(otk::OBDisplay::display, frame.plate); + XMapSubwindows(otk::OBDisplay::display, frame.plate); #ifdef SHAPE if (blackbox->hasShapeExtensions()) { - XShapeSelectInput(blackbox->getXDisplay(), client.window, + XShapeSelectInput(otk::OBDisplay::display, client.window, ShapeNotifyMask); Bool shaped = False; int foo; unsigned int ufoo; - XShapeQueryExtents(blackbox->getXDisplay(), client.window, &shaped, + XShapeQueryExtents(otk::OBDisplay::display, client.window, &shaped, &foo, &foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo); flags.shaped = shaped; @@ -522,7 +525,7 @@ void BlackboxWindow::associateClientWindow(void) { void BlackboxWindow::decorate(void) { - BTexture* texture; + otk::BTexture* texture; texture = &(screen->getWindowStyle()->b_focus); frame.fbutton = texture->render(frame.button_w, frame.button_w, @@ -540,7 +543,7 @@ void BlackboxWindow::decorate(void) { texture = &(screen->getWindowStyle()->b_pressed_focus); - if (texture->texture() != BTexture::NoTexture) { + if (texture->texture() != otk::BTexture::NoTexture) { frame.pfbutton = texture->render(frame.button_w, frame.button_w, frame.pfbutton); if (! frame.pfbutton) @@ -551,7 +554,7 @@ void BlackboxWindow::decorate(void) { texture = &(screen->getWindowStyle()->b_pressed_unfocus); - if (texture->texture() != BTexture::NoTexture) { + if (texture->texture() != otk::BTexture::NoTexture) { frame.pubutton = texture->render(frame.button_w, frame.button_w, frame.pubutton); if (! frame.pubutton) @@ -594,7 +597,7 @@ void BlackboxWindow::decorate(void) { if (! frame.utitle) frame.utitle_pixel = texture->color().pixel(); - XSetWindowBorder(blackbox->getXDisplay(), frame.title, + XSetWindowBorder(otk::OBDisplay::display, frame.title, screen->getBorderColor()->pixel()); decorateLabel(); @@ -628,21 +631,21 @@ void BlackboxWindow::decorate(void) { if (! frame.ugrip) frame.ugrip_pixel = texture->color().pixel(); - XSetWindowBorder(blackbox->getXDisplay(), frame.handle, + XSetWindowBorder(otk::OBDisplay::display, frame.handle, screen->getBorderColor()->pixel()); - XSetWindowBorder(blackbox->getXDisplay(), frame.left_grip, + XSetWindowBorder(otk::OBDisplay::display, frame.left_grip, screen->getBorderColor()->pixel()); - XSetWindowBorder(blackbox->getXDisplay(), frame.right_grip, + XSetWindowBorder(otk::OBDisplay::display, frame.right_grip, screen->getBorderColor()->pixel()); } - XSetWindowBorder(blackbox->getXDisplay(), frame.window, + XSetWindowBorder(otk::OBDisplay::display, frame.window, screen->getBorderColor()->pixel()); } void BlackboxWindow::decorateLabel(void) { - BTexture *texture; + otk::BTexture *texture; texture = &(screen->getWindowStyle()->l_focus); frame.flabel = texture->render(frame.label_w, frame.label_h, frame.flabel); @@ -694,12 +697,12 @@ void BlackboxWindow::destroyHandle(void) { blackbox->removeWindowSearch(frame.left_grip); blackbox->removeWindowSearch(frame.right_grip); - XDestroyWindow(blackbox->getXDisplay(), frame.left_grip); - XDestroyWindow(blackbox->getXDisplay(), frame.right_grip); + XDestroyWindow(otk::OBDisplay::display, frame.left_grip); + XDestroyWindow(otk::OBDisplay::display, frame.right_grip); frame.left_grip = frame.right_grip = None; blackbox->removeWindowSearch(frame.handle); - XDestroyWindow(blackbox->getXDisplay(), frame.handle); + XDestroyWindow(otk::OBDisplay::display, frame.handle); frame.handle = None; } @@ -754,8 +757,8 @@ void BlackboxWindow::destroyTitlebar(void) { blackbox->removeWindowSearch(frame.title); blackbox->removeWindowSearch(frame.label); - XDestroyWindow(blackbox->getXDisplay(), frame.label); - XDestroyWindow(blackbox->getXDisplay(), frame.title); + XDestroyWindow(otk::OBDisplay::display, frame.label); + XDestroyWindow(otk::OBDisplay::display, frame.title); frame.title = frame.label = None; } @@ -773,7 +776,7 @@ void BlackboxWindow::createCloseButton(void) { void BlackboxWindow::destroyCloseButton(void) { blackbox->removeWindowSearch(frame.close_button); - XDestroyWindow(blackbox->getXDisplay(), frame.close_button); + XDestroyWindow(otk::OBDisplay::display, frame.close_button); frame.close_button = None; } @@ -791,7 +794,7 @@ void BlackboxWindow::createIconifyButton(void) { void BlackboxWindow::destroyIconifyButton(void) { blackbox->removeWindowSearch(frame.iconify_button); - XDestroyWindow(blackbox->getXDisplay(), frame.iconify_button); + XDestroyWindow(otk::OBDisplay::display, frame.iconify_button); frame.iconify_button = None; } @@ -809,7 +812,7 @@ void BlackboxWindow::createMaximizeButton(void) { void BlackboxWindow::destroyMaximizeButton(void) { blackbox->removeWindowSearch(frame.maximize_button); - XDestroyWindow(blackbox->getXDisplay(), frame.maximize_button); + XDestroyWindow(otk::OBDisplay::display, frame.maximize_button); frame.maximize_button = None; } @@ -825,7 +828,7 @@ void BlackboxWindow::createStickyButton(void) { void BlackboxWindow::destroyStickyButton(void) { blackbox->removeWindowSearch(frame.stick_button); - XDestroyWindow(blackbox->getXDisplay(), frame.stick_button); + XDestroyWindow(otk::OBDisplay::display, frame.stick_button); frame.stick_button = None; } @@ -895,30 +898,30 @@ void BlackboxWindow::positionButtons(bool redecorate_label) { switch(*it) { case 'C': if (! frame.close_button) createCloseButton(); - XMoveResizeWindow(blackbox->getXDisplay(), frame.close_button, x, by, + XMoveResizeWindow(otk::OBDisplay::display, frame.close_button, x, by, frame.button_w, frame.button_w); x += frame.button_w + bsep; break; case 'I': if (! frame.iconify_button) createIconifyButton(); - XMoveResizeWindow(blackbox->getXDisplay(), frame.iconify_button, x, by, + XMoveResizeWindow(otk::OBDisplay::display, frame.iconify_button, x, by, frame.button_w, frame.button_w); x += frame.button_w + bsep; break; case 'S': if (! frame.stick_button) createStickyButton(); - XMoveResizeWindow(blackbox->getXDisplay(), frame.stick_button, x, by, + XMoveResizeWindow(otk::OBDisplay::display, frame.stick_button, x, by, frame.button_w, frame.button_w); x += frame.button_w + bsep; break; case 'M': if (! frame.maximize_button) createMaximizeButton(); - XMoveResizeWindow(blackbox->getXDisplay(), frame.maximize_button, x, by, + XMoveResizeWindow(otk::OBDisplay::display, frame.maximize_button, x, by, frame.button_w, frame.button_w); x += frame.button_w + bsep; break; case 'L': - XMoveResizeWindow(blackbox->getXDisplay(), frame.label, x, ty, + XMoveResizeWindow(otk::OBDisplay::display, frame.label, x, ty, frame.label_w, frame.label_h); x += frame.label_w + bsep; break; @@ -949,48 +952,48 @@ void BlackboxWindow::grabButtons(void) { if (! screen->isSloppyFocus() || screen->doClickRaise()) // grab button 1 for changing focus/raising - blackbox->grabButton(Button1, 0, frame.plate, True, ButtonPressMask, - GrabModeSync, GrabModeSync, frame.plate, None, - screen->allowScrollLock()); + otk::OBDisplay::grabButton(Button1, 0, frame.plate, True, ButtonPressMask, + GrabModeSync, GrabModeSync, frame.plate, None, + screen->allowScrollLock()); if (functions & Func_Move) - blackbox->grabButton(Button1, mod_mask, frame.window, True, + otk::OBDisplay::grabButton(Button1, mod_mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, frame.window, None, screen->allowScrollLock()); if (functions & Func_Resize) - blackbox->grabButton(Button3, mod_mask, frame.window, True, + otk::OBDisplay::grabButton(Button3, mod_mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, frame.window, None, screen->allowScrollLock()); // alt+middle lowers the window - blackbox->grabButton(Button2, mod_mask, frame.window, True, + otk::OBDisplay::grabButton(Button2, mod_mask, frame.window, True, ButtonReleaseMask, GrabModeAsync, GrabModeAsync, frame.window, None, screen->allowScrollLock()); } void BlackboxWindow::ungrabButtons(void) { - blackbox->ungrabButton(Button1, 0, frame.plate); - blackbox->ungrabButton(Button1, mod_mask, frame.window); - blackbox->ungrabButton(Button2, mod_mask, frame.window); - blackbox->ungrabButton(Button3, mod_mask, frame.window); + otk::OBDisplay::ungrabButton(Button1, 0, frame.plate); + otk::OBDisplay::ungrabButton(Button1, mod_mask, frame.window); + otk::OBDisplay::ungrabButton(Button2, mod_mask, frame.window); + otk::OBDisplay::ungrabButton(Button3, mod_mask, frame.window); } void BlackboxWindow::positionWindows(void) { - XMoveResizeWindow(blackbox->getXDisplay(), frame.window, + XMoveResizeWindow(otk::OBDisplay::display, frame.window, frame.rect.x(), frame.rect.y(), frame.inside_w, (flags.shaded) ? frame.title_h : frame.inside_h); - XSetWindowBorderWidth(blackbox->getXDisplay(), frame.window, + XSetWindowBorderWidth(otk::OBDisplay::display, frame.window, frame.border_w); - XSetWindowBorderWidth(blackbox->getXDisplay(), frame.plate, + XSetWindowBorderWidth(otk::OBDisplay::display, frame.plate, frame.mwm_border_w); - XMoveResizeWindow(blackbox->getXDisplay(), frame.plate, + XMoveResizeWindow(otk::OBDisplay::display, frame.plate, frame.margin.left - frame.mwm_border_w - frame.border_w, frame.margin.top - frame.mwm_border_w - frame.border_w, client.rect.width(), client.rect.height()); - XMoveResizeWindow(blackbox->getXDisplay(), client.window, + XMoveResizeWindow(otk::OBDisplay::display, client.window, 0, 0, client.rect.width(), client.rect.height()); // ensure client.rect contains the real location client.rect.setPos(frame.rect.left() + frame.margin.left, @@ -999,45 +1002,45 @@ void BlackboxWindow::positionWindows(void) { if (decorations & Decor_Titlebar) { if (frame.title == None) createTitlebar(); - XSetWindowBorderWidth(blackbox->getXDisplay(), frame.title, + XSetWindowBorderWidth(otk::OBDisplay::display, frame.title, frame.border_w); - XMoveResizeWindow(blackbox->getXDisplay(), frame.title, -frame.border_w, + XMoveResizeWindow(otk::OBDisplay::display, frame.title, -frame.border_w, -frame.border_w, frame.inside_w, frame.title_h); positionButtons(); - XMapSubwindows(blackbox->getXDisplay(), frame.title); - XMapWindow(blackbox->getXDisplay(), frame.title); + XMapSubwindows(otk::OBDisplay::display, frame.title); + XMapWindow(otk::OBDisplay::display, frame.title); } else if (frame.title) { destroyTitlebar(); } if (decorations & Decor_Handle) { if (frame.handle == None) createHandle(); - XSetWindowBorderWidth(blackbox->getXDisplay(), frame.handle, + XSetWindowBorderWidth(otk::OBDisplay::display, frame.handle, frame.border_w); - XSetWindowBorderWidth(blackbox->getXDisplay(), frame.left_grip, + XSetWindowBorderWidth(otk::OBDisplay::display, frame.left_grip, frame.border_w); - XSetWindowBorderWidth(blackbox->getXDisplay(), frame.right_grip, + XSetWindowBorderWidth(otk::OBDisplay::display, frame.right_grip, frame.border_w); // use client.rect here so the value is correct even if shaded - XMoveResizeWindow(blackbox->getXDisplay(), frame.handle, + XMoveResizeWindow(otk::OBDisplay::display, frame.handle, -frame.border_w, client.rect.height() + frame.margin.top + frame.mwm_border_w - frame.border_w, frame.inside_w, frame.handle_h); - XMoveResizeWindow(blackbox->getXDisplay(), frame.left_grip, + XMoveResizeWindow(otk::OBDisplay::display, frame.left_grip, -frame.border_w, -frame.border_w, frame.grip_w, frame.handle_h); - XMoveResizeWindow(blackbox->getXDisplay(), frame.right_grip, + XMoveResizeWindow(otk::OBDisplay::display, frame.right_grip, frame.inside_w - frame.grip_w - frame.border_w, -frame.border_w, frame.grip_w, frame.handle_h); - XMapSubwindows(blackbox->getXDisplay(), frame.handle); - XMapWindow(blackbox->getXDisplay(), frame.handle); + XMapSubwindows(otk::OBDisplay::display, frame.handle); + XMapWindow(otk::OBDisplay::display, frame.handle); } else if (frame.handle) { destroyHandle(); } - XSync(blackbox->getXDisplay(), False); + XSync(otk::OBDisplay::display, False); } @@ -1169,7 +1172,7 @@ void BlackboxWindow::getWMProtocols(void) { Atom *proto; int num_return = 0; - if (XGetWMProtocols(blackbox->getXDisplay(), client.window, + if (XGetWMProtocols(otk::OBDisplay::display, client.window, &proto, &num_return)) { for (int i = 0; i < num_return; ++i) { if (proto[i] == xatom->getAtom(XAtom::wm_delete_window)) { @@ -1198,7 +1201,7 @@ void BlackboxWindow::getWMHints(void) { } client.window_group = None; - XWMHints *wmhint = XGetWMHints(blackbox->getXDisplay(), client.window); + XWMHints *wmhint = XGetWMHints(otk::OBDisplay::display, client.window); if (! wmhint) { return; } @@ -1258,7 +1261,7 @@ void BlackboxWindow::getWMNormalHints(void) { client.max_height = (unsigned) -1; - if (! XGetWMNormalHints(blackbox->getXDisplay(), client.window, + if (! XGetWMNormalHints(otk::OBDisplay::display, client.window, &sizehint, &icccm_mask)) return; @@ -1496,7 +1499,7 @@ void BlackboxWindow::getTransientInfo(void) { client.transient_for = (BlackboxWindow *) 0; Window trans_for; - if (! XGetTransientForHint(blackbox->getXDisplay(), client.window, + if (! XGetTransientForHint(otk::OBDisplay::display, client.window, &trans_for)) { // transient_for hint not set return; @@ -1598,7 +1601,7 @@ void BlackboxWindow::configure(int dx, int dy, } else { frame.rect.setPos(dx, dy); - XMoveWindow(blackbox->getXDisplay(), frame.window, + XMoveWindow(otk::OBDisplay::display, frame.window, frame.rect.x(), frame.rect.y()); /* we may have been called just after an opaque window move, so even though @@ -1616,7 +1619,7 @@ void BlackboxWindow::configure(int dx, int dy, XEvent event; event.type = ConfigureNotify; - event.xconfigure.display = blackbox->getXDisplay(); + event.xconfigure.display = otk::OBDisplay::display; event.xconfigure.event = client.window; event.xconfigure.window = client.window; event.xconfigure.x = client.rect.x(); @@ -1627,16 +1630,16 @@ void BlackboxWindow::configure(int dx, int dy, event.xconfigure.above = frame.window; event.xconfigure.override_redirect = False; - XSendEvent(blackbox->getXDisplay(), client.window, False, + XSendEvent(otk::OBDisplay::display, client.window, False, StructureNotifyMask, &event); - XFlush(blackbox->getXDisplay()); + XFlush(otk::OBDisplay::display); } } #ifdef SHAPE void BlackboxWindow::configureShape(void) { - XShapeCombineShape(blackbox->getXDisplay(), frame.window, ShapeBounding, + XShapeCombineShape(otk::OBDisplay::display, frame.window, ShapeBounding, frame.margin.left - frame.border_w, frame.margin.top - frame.border_w, client.window, ShapeBounding, ShapeSet); @@ -1660,14 +1663,14 @@ void BlackboxWindow::configureShape(void) { ++num; } - XShapeCombineRectangles(blackbox->getXDisplay(), frame.window, + XShapeCombineRectangles(otk::OBDisplay::display, frame.window, ShapeBounding, 0, 0, xrect, num, ShapeUnion, Unsorted); } void BlackboxWindow::clearShape(void) { - XShapeCombineMask(blackbox->getXDisplay(), frame.window, ShapeBounding, + XShapeCombineMask(otk::OBDisplay::display, frame.window, ShapeBounding, frame.margin.left - frame.border_w, frame.margin.top - frame.border_w, None, ShapeSet); @@ -1703,7 +1706,7 @@ bool BlackboxWindow::setInputFocus(void) { bool ret = True; if (focus_mode == F_LocallyActive || focus_mode == F_Passive) { - XSetInputFocus(blackbox->getXDisplay(), client.window, + XSetInputFocus(otk::OBDisplay::display, client.window, RevertToPointerRoot, CurrentTime); } else { /* we could set the focus to none, since the window doesn't accept focus, @@ -1717,7 +1720,7 @@ bool BlackboxWindow::setInputFocus(void) { XEvent ce; ce.xclient.type = ClientMessage; ce.xclient.message_type = xatom->getAtom(XAtom::wm_protocols); - ce.xclient.display = blackbox->getXDisplay(); + ce.xclient.display = otk::OBDisplay::display; ce.xclient.window = client.window; ce.xclient.format = 32; ce.xclient.data.l[0] = xatom->getAtom(XAtom::wm_take_focus); @@ -1725,9 +1728,9 @@ bool BlackboxWindow::setInputFocus(void) { ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; - XSendEvent(blackbox->getXDisplay(), client.window, False, + XSendEvent(otk::OBDisplay::display, client.window, False, NoEventMask, &ce); - XFlush(blackbox->getXDisplay()); + XFlush(otk::OBDisplay::display); } return ret; @@ -1751,14 +1754,14 @@ void BlackboxWindow::iconify(void) { */ unsigned long event_mask = PropertyChangeMask | FocusChangeMask | StructureNotifyMask; - XGrabServer(blackbox->getXDisplay()); - XSelectInput(blackbox->getXDisplay(), client.window, + XGrabServer(otk::OBDisplay::display); + XSelectInput(otk::OBDisplay::display, client.window, event_mask & ~StructureNotifyMask); - XUnmapWindow(blackbox->getXDisplay(), client.window); - XSelectInput(blackbox->getXDisplay(), client.window, event_mask); - XUngrabServer(blackbox->getXDisplay()); + XUnmapWindow(otk::OBDisplay::display, client.window); + XSelectInput(otk::OBDisplay::display, client.window, event_mask); + XUngrabServer(otk::OBDisplay::display); - XUnmapWindow(blackbox->getXDisplay(), frame.window); + XUnmapWindow(otk::OBDisplay::display, frame.window); flags.visible = False; flags.iconic = True; @@ -1799,14 +1802,14 @@ void BlackboxWindow::show(void) { current_state = (flags.shaded) ? IconicState : NormalState; setState(current_state); - XMapWindow(blackbox->getXDisplay(), client.window); - XMapSubwindows(blackbox->getXDisplay(), frame.window); - XMapWindow(blackbox->getXDisplay(), frame.window); + XMapWindow(otk::OBDisplay::display, client.window); + XMapSubwindows(otk::OBDisplay::display, frame.window); + XMapWindow(otk::OBDisplay::display, frame.window); #if 0 int real_x, real_y; Window child; - XTranslateCoordinates(blackbox->getXDisplay(), client.window, + XTranslateCoordinates(otk::OBDisplay::display, client.window, screen->getRootWindow(), 0, 0, &real_x, &real_y, &child); fprintf(stderr, "%s -- assumed: (%d, %d), real: (%d, %d)\n", getTitle(), @@ -1842,7 +1845,7 @@ void BlackboxWindow::close(void) { XEvent ce; ce.xclient.type = ClientMessage; ce.xclient.message_type = xatom->getAtom(XAtom::wm_protocols); - ce.xclient.display = blackbox->getXDisplay(); + ce.xclient.display = otk::OBDisplay::display; ce.xclient.window = client.window; ce.xclient.format = 32; ce.xclient.data.l[0] = xatom->getAtom(XAtom::wm_delete_window); @@ -1850,8 +1853,8 @@ void BlackboxWindow::close(void) { ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; - XSendEvent(blackbox->getXDisplay(), client.window, False, NoEventMask, &ce); - XFlush(blackbox->getXDisplay()); + XSendEvent(otk::OBDisplay::display, client.window, False, NoEventMask, &ce); + XFlush(otk::OBDisplay::display); } @@ -1866,18 +1869,18 @@ void BlackboxWindow::withdraw(void) { setState(current_state); - XUnmapWindow(blackbox->getXDisplay(), frame.window); + XUnmapWindow(otk::OBDisplay::display, frame.window); - XGrabServer(blackbox->getXDisplay()); + XGrabServer(otk::OBDisplay::display); unsigned long event_mask = PropertyChangeMask | FocusChangeMask | StructureNotifyMask; - XSelectInput(blackbox->getXDisplay(), client.window, + XSelectInput(otk::OBDisplay::display, client.window, event_mask & ~StructureNotifyMask); - XUnmapWindow(blackbox->getXDisplay(), client.window); - XSelectInput(blackbox->getXDisplay(), client.window, event_mask); + XUnmapWindow(otk::OBDisplay::display, client.window); + XSelectInput(otk::OBDisplay::display, client.window, event_mask); - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); } @@ -2035,7 +2038,7 @@ void BlackboxWindow::setWorkspace(unsigned int n) { void BlackboxWindow::shade(void) { if (flags.shaded) { - XResizeWindow(blackbox->getXDisplay(), frame.window, + XResizeWindow(otk::OBDisplay::display, frame.window, frame.inside_w, frame.inside_h); flags.shaded = False; blackbox_attrib.flags ^= AttribShaded; @@ -2050,7 +2053,7 @@ void BlackboxWindow::shade(void) { if (! (decorations & Decor_Titlebar)) return; // can't shade it without a titlebar! - XResizeWindow(blackbox->getXDisplay(), frame.window, + XResizeWindow(otk::OBDisplay::display, frame.window, frame.inside_w, frame.title_h); flags.shaded = True; blackbox_attrib.flags |= AttribShaded; @@ -2123,20 +2126,20 @@ void BlackboxWindow::redrawWindowFrame(void) const { if (decorations & Decor_Titlebar) { if (flags.focused) { if (frame.ftitle) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.title, frame.ftitle); else - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.title, frame.ftitle_pixel); } else { if (frame.utitle) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.title, frame.utitle); else - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.title, frame.utitle_pixel); } - XClearWindow(blackbox->getXDisplay(), frame.title); + XClearWindow(otk::OBDisplay::display, frame.title); redrawLabel(); redrawAllButtons(); @@ -2145,54 +2148,54 @@ void BlackboxWindow::redrawWindowFrame(void) const { if (decorations & Decor_Handle) { if (flags.focused) { if (frame.fhandle) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.handle, frame.fhandle); else - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.handle, frame.fhandle_pixel); if (frame.fgrip) { - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.left_grip, frame.fgrip); - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.right_grip, frame.fgrip); } else { - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.left_grip, frame.fgrip_pixel); - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.right_grip, frame.fgrip_pixel); } } else { if (frame.uhandle) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.handle, frame.uhandle); else - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.handle, frame.uhandle_pixel); if (frame.ugrip) { - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.left_grip, frame.ugrip); - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.right_grip, frame.ugrip); } else { - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.left_grip, frame.ugrip_pixel); - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.right_grip, frame.ugrip_pixel); } } - XClearWindow(blackbox->getXDisplay(), frame.handle); - XClearWindow(blackbox->getXDisplay(), frame.left_grip); - XClearWindow(blackbox->getXDisplay(), frame.right_grip); + XClearWindow(otk::OBDisplay::display, frame.handle); + XClearWindow(otk::OBDisplay::display, frame.left_grip); + XClearWindow(otk::OBDisplay::display, frame.right_grip); } if (decorations & Decor_Border) { if (flags.focused) - XSetWindowBorder(blackbox->getXDisplay(), + XSetWindowBorder(otk::OBDisplay::display, frame.plate, frame.fborder_pixel); else - XSetWindowBorder(blackbox->getXDisplay(), + XSetWindowBorder(otk::OBDisplay::display, frame.plate, frame.uborder_pixel); } } @@ -2214,11 +2217,11 @@ void BlackboxWindow::setFocusFlag(bool focus) { void BlackboxWindow::installColormap(bool install) { int i = 0, ncmap = 0; - Colormap *cmaps = XListInstalledColormaps(blackbox->getXDisplay(), + Colormap *cmaps = XListInstalledColormaps(otk::OBDisplay::display, client.window, &ncmap); if (cmaps) { XWindowAttributes wattrib; - if (XGetWindowAttributes(blackbox->getXDisplay(), + if (XGetWindowAttributes(otk::OBDisplay::display, client.window, &wattrib)) { if (install) { // install the window's colormap @@ -2229,13 +2232,13 @@ void BlackboxWindow::installColormap(bool install) { } // otherwise, install the window's colormap if (install) - XInstallColormap(blackbox->getXDisplay(), wattrib.colormap); + XInstallColormap(otk::OBDisplay::display, wattrib.colormap); } else { // uninstall the window's colormap for (i = 0; i < ncmap; i++) { if (*(cmaps + i) == wattrib.colormap) // we found the colormap to uninstall - XUninstallColormap(blackbox->getXDisplay(), wattrib.colormap); + XUninstallColormap(otk::OBDisplay::display, wattrib.colormap); } } } @@ -2409,7 +2412,7 @@ void BlackboxWindow::restoreAttributes(void) { * Positions the Rect r according the the client window position and * window gravity. */ -void BlackboxWindow::applyGravity(Rect &r) { +void BlackboxWindow::applyGravity(otk::Rect &r) { // apply horizontal window gravity switch (client.win_gravity) { default: @@ -2472,7 +2475,7 @@ void BlackboxWindow::applyGravity(Rect &r) { * Positions the Rect r according to the frame window position and * window gravity. */ -void BlackboxWindow::restoreGravity(Rect &r) { +void BlackboxWindow::restoreGravity(otk::Rect &r) { // restore horizontal window gravity switch (client.win_gravity) { default: @@ -2532,20 +2535,20 @@ void BlackboxWindow::restoreGravity(Rect &r) { void BlackboxWindow::redrawLabel(void) const { if (flags.focused) { if (frame.flabel) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.label, frame.flabel); else - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.label, frame.flabel_pixel); } else { if (frame.ulabel) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), + XSetWindowBackgroundPixmap(otk::OBDisplay::display, frame.label, frame.ulabel); else - XSetWindowBackground(blackbox->getXDisplay(), + XSetWindowBackground(otk::OBDisplay::display, frame.label, frame.ulabel_pixel); } - XClearWindow(blackbox->getXDisplay(), frame.label); + XClearWindow(otk::OBDisplay::display, frame.label); WindowStyle *style = screen->getWindowStyle(); @@ -2593,9 +2596,9 @@ void BlackboxWindow::redrawButton(bool pressed, Window win, } if (p) - XSetWindowBackgroundPixmap(blackbox->getXDisplay(), win, p); + XSetWindowBackgroundPixmap(otk::OBDisplay::display, win, p); else - XSetWindowBackground(blackbox->getXDisplay(), win, pix); + XSetWindowBackground(otk::OBDisplay::display, win, pix); } @@ -2606,25 +2609,25 @@ void BlackboxWindow::redrawIconifyButton(bool pressed) const { frame.fbutton, frame.fbutton_pixel, frame.ubutton, frame.ubutton_pixel); - XClearWindow(blackbox->getXDisplay(), frame.iconify_button); - BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : - screen->getWindowStyle()->b_pic_unfocus); + XClearWindow(otk::OBDisplay::display, frame.iconify_button); + otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : + screen->getWindowStyle()->b_pic_unfocus); PixmapMask pm = screen->getWindowStyle()->icon_button; if (screen->getWindowStyle()->icon_button.mask != None) { - XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); - XFillRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(), + XFillRectangle(otk::OBDisplay::display, frame.iconify_button, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); - XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); + XSetClipMask(otk::OBDisplay::display, pen.gc(), None); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0); } else { - XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(), + XDrawRectangle(otk::OBDisplay::display, frame.iconify_button, pen.gc(), 2, (frame.button_w - 5), (frame.button_w - 5), 2); } } @@ -2637,28 +2640,28 @@ void BlackboxWindow::redrawMaximizeButton(bool pressed) const { frame.fbutton, frame.fbutton_pixel, frame.ubutton, frame.ubutton_pixel); - XClearWindow(blackbox->getXDisplay(), frame.maximize_button); + XClearWindow(otk::OBDisplay::display, frame.maximize_button); - BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : - screen->getWindowStyle()->b_pic_unfocus); + otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : + screen->getWindowStyle()->b_pic_unfocus); PixmapMask pm = screen->getWindowStyle()->max_button; if (pm.mask != None) { - XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); - XFillRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), + XFillRectangle(otk::OBDisplay::display, frame.maximize_button, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); - XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0 ); + XSetClipMask( otk::OBDisplay::display, pen.gc(), None ); } else { - XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), + XDrawRectangle(otk::OBDisplay::display, frame.maximize_button, pen.gc(), 2, 2, (frame.button_w - 5), (frame.button_w - 5)); - XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(), + XDrawLine(otk::OBDisplay::display, frame.maximize_button, pen.gc(), 2, 3, (frame.button_w - 3), 3); } } @@ -2671,29 +2674,29 @@ void BlackboxWindow::redrawCloseButton(bool pressed) const { frame.fbutton, frame.fbutton_pixel, frame.ubutton, frame.ubutton_pixel); - XClearWindow(blackbox->getXDisplay(), frame.close_button); + XClearWindow(otk::OBDisplay::display, frame.close_button); - BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : - screen->getWindowStyle()->b_pic_unfocus); + otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : + screen->getWindowStyle()->b_pic_unfocus); PixmapMask pm = screen->getWindowStyle()->close_button; if (pm.mask != None) { - XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); - XFillRectangle(blackbox->getXDisplay(), frame.close_button, pen.gc(), + XFillRectangle(otk::OBDisplay::display, frame.close_button, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); - XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0 ); + XSetClipMask( otk::OBDisplay::display, pen.gc(), None ); } else { - XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), + XDrawLine(otk::OBDisplay::display, frame.close_button, pen.gc(), 2, 2, (frame.button_w - 3), (frame.button_w - 3)); - XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(), + XDrawLine(otk::OBDisplay::display, frame.close_button, pen.gc(), 2, (frame.button_w - 3), (frame.button_w - 3), 2); } } @@ -2705,27 +2708,27 @@ void BlackboxWindow::redrawStickyButton(bool pressed) const { frame.fbutton, frame.fbutton_pixel, frame.ubutton, frame.ubutton_pixel); - XClearWindow(blackbox->getXDisplay(), frame.stick_button); + XClearWindow(otk::OBDisplay::display, frame.stick_button); - BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : - screen->getWindowStyle()->b_pic_unfocus); + otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus : + screen->getWindowStyle()->b_pic_unfocus); PixmapMask pm = screen->getWindowStyle()->stick_button; if (pm.mask != None) { - XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), + XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2); - XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), + XFillRectangle(otk::OBDisplay::display, frame.stick_button, pen.gc(), (frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2, (frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 ); - XSetClipMask( blackbox->getXDisplay(), pen.gc(), None ); + XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0 ); + XSetClipMask( otk::OBDisplay::display, pen.gc(), None ); } else { - XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(), + XFillRectangle(otk::OBDisplay::display, frame.stick_button, pen.gc(), frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 ); } } @@ -2764,8 +2767,8 @@ void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { show(); screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this); if (isNormal()) { - if (! blackbox->isStartup()) { - XSync(blackbox->getXDisplay(), False); // make sure the frame is mapped + if (blackbox->state() != Openbox::State_Starting) { + XSync(otk::OBDisplay::display, False); // make sure the frame is mapped if (screen->doFocusNew() || (isTransient() && getTransientFor() && getTransientFor()->isFocused())) { setInputFocus(); @@ -2774,7 +2777,7 @@ void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) { int x, y, rx, ry; Window c, r; unsigned int m; - XQueryPointer(blackbox->getXDisplay(), screen->getRootWindow(), + XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(), &r, &c, &rx, &ry, &x, &y, &m); beginMove(rx, ry); } @@ -2822,7 +2825,7 @@ void BlackboxWindow::reparentNotifyEvent(const XReparentEvent *re) { XEvent ev; ev.xreparent = *re; - XPutBackEvent(blackbox->getXDisplay(), &ev); + XPutBackEvent(otk::OBDisplay::display, &ev); screen->unmanageWindow(this, True); } @@ -2901,7 +2904,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { setupDecor(); } - Rect old_rect = frame.rect; + otk::Rect old_rect = frame.rect; upsize(); @@ -2919,7 +2922,7 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { createCloseButton(); if (decorations & Decor_Titlebar) { positionButtons(True); - XMapSubwindows(blackbox->getXDisplay(), frame.title); + XMapSubwindows(otk::OBDisplay::display, frame.title); } } } else if (pe->atom == xatom->getAtom(XAtom::net_wm_strut)) { @@ -3044,7 +3047,7 @@ void BlackboxWindow::buttonPressEvent(const XButtonEvent *be) { } else if (frame.plate == be->window) { screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this); - XAllowEvents(blackbox->getXDisplay(), ReplayPointer, be->time); + XAllowEvents(otk::OBDisplay::display, ReplayPointer, be->time); } else { if (frame.title == be->window || frame.label == be->window) { if (((be->time - lastButtonPressTime) <= @@ -3126,7 +3129,7 @@ void BlackboxWindow::buttonReleaseEvent(const XButtonEvent *re) { endResize(); } else if (re->window == frame.window) { if (re->button == 2 && re->state == mod_mask) - XUngrabPointer(blackbox->getXDisplay(), CurrentTime); + XUngrabPointer(otk::OBDisplay::display, CurrentTime); } } @@ -3149,7 +3152,7 @@ void BlackboxWindow::beginMove(int x_root, int y_root) { changing->endResize(); } - XGrabPointer(blackbox->getXDisplay(), frame.window, False, + XGrabPointer(otk::OBDisplay::display, frame.window, False, PointerMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, blackbox->getMoveCursor(), CurrentTime); @@ -3158,12 +3161,12 @@ void BlackboxWindow::beginMove(int x_root, int y_root) { blackbox->setChangingWindow(this); if (! screen->doOpaqueMove()) { - XGrabServer(blackbox->getXDisplay()); + XGrabServer(otk::OBDisplay::display); frame.changing = frame.rect; screen->showPosition(frame.changing.x(), frame.changing.y()); - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), @@ -3192,7 +3195,7 @@ void BlackboxWindow::doMove(int x_root, int y_root) { configure(dx, dy, frame.rect.width(), frame.rect.height()); } else { - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), @@ -3204,7 +3207,7 @@ void BlackboxWindow::doMove(int x_root, int y_root) { frame.changing.setPos(dx, dy); - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), @@ -3251,19 +3254,19 @@ void BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, int &dx) { screen->changeWorkspaceID(dest); if (screen->doOpaqueMove()) - XGrabServer(blackbox->getXDisplay()); + XGrabServer(otk::OBDisplay::display); - XUngrabPointer(blackbox->getXDisplay(), CurrentTime); - XWarpPointer(blackbox->getXDisplay(), None, + XUngrabPointer(otk::OBDisplay::display, CurrentTime); + XWarpPointer(otk::OBDisplay::display, None, screen->getRootWindow(), 0, 0, 0, 0, dest_x, y_root); - XGrabPointer(blackbox->getXDisplay(), frame.window, False, + XGrabPointer(otk::OBDisplay::display, frame.window, False, PointerMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, blackbox->getMoveCursor(), CurrentTime); if (screen->doOpaqueMove()) - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); if (focus) setInputFocus(); @@ -3285,7 +3288,8 @@ void BlackboxWindow::doWindowSnapping(int &dx, int &dy) { const int snap_offset = screen->getSnapOffset(); // find the geomeetery where the moving window currently is - const Rect &moving = screen->doOpaqueMove() ? frame.rect : frame.changing; + const otk::Rect &moving = + screen->doOpaqueMove() ? frame.rect : frame.changing; // window corners const int wleft = dx, @@ -3294,7 +3298,7 @@ void BlackboxWindow::doWindowSnapping(int &dx, int &dy) { wbottom = dy + frame.rect.height() - 1; if (snap_to_windows) { - RectList rectlist; + otk::RectList rectlist; Workspace *w = screen->getWorkspace(getWorkspaceNumber()); assert(w); @@ -3306,11 +3310,11 @@ void BlackboxWindow::doWindowSnapping(int &dx, int &dy) { if (*st_it != this) // don't snap to ourself rectlist.push_back( (*st_it)->frameRect() ); - RectList::const_iterator it, end = rectlist.end(); + otk::RectList::const_iterator it, end = rectlist.end(); for (it = rectlist.begin(); it != end; ++it) { bool snapped = False; - const Rect &winrect = *it; - Rect offsetrect; + const otk::Rect &winrect = *it; + otk::Rect offsetrect; offsetrect.setCoords(winrect.left() - snap_offset, winrect.top() - snap_offset, winrect.right() + snap_offset, @@ -3461,7 +3465,7 @@ void BlackboxWindow::doWindowSnapping(int &dx, int &dy) { } if (snap_to_edges) { - RectList rectlist; + otk::RectList rectlist; // snap to the screen edges (and screen boundaries for xinerama) #ifdef XINERAMA @@ -3473,10 +3477,10 @@ void BlackboxWindow::doWindowSnapping(int &dx, int &dy) { #endif // XINERAMA rectlist.push_back(screen->getRect()); - RectList::const_iterator it, end = rectlist.end(); + otk::RectList::const_iterator it, end = rectlist.end(); for (it = rectlist.begin(); it != end; ++it) { - const Rect &srect = *it; - Rect offsetrect; + const otk::Rect &srect = *it; + otk::Rect offsetrect; offsetrect.setCoords(srect.left() + snap_offset, srect.top() + snap_offset, srect.right() - snap_offset, @@ -3488,8 +3492,8 @@ void BlackboxWindow::doWindowSnapping(int &dx, int &dy) { continue; } else { // BScreen::WindowSnap // if we're not in the rectangle then don't snap to it. - if (! srect.intersects(Rect(wleft, wtop, frame.rect.width(), - frame.rect.height()))) + if (! srect.intersects(otk::Rect(wleft, wtop, frame.rect.width(), + frame.rect.height()))) continue; } @@ -3550,10 +3554,10 @@ void BlackboxWindow::endMove(void) { * so we need to subtract 1 from changing_w/changing_h every where we * draw the rubber band (for both moving and resizing) */ - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), frame.changing.width() - 1, frame.changing.height() - 1); - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); configure(frame.changing.x(), frame.changing.y(), frame.changing.width(), frame.changing.height()); @@ -3563,12 +3567,12 @@ void BlackboxWindow::endMove(void) { } screen->hideGeometry(); - XUngrabPointer(blackbox->getXDisplay(), CurrentTime); + XUngrabPointer(otk::OBDisplay::display, CurrentTime); // if there are any left over motions from the move, drop them now - XSync(blackbox->getXDisplay(), false); // make sure we don't miss any + XSync(otk::OBDisplay::display, false); // make sure we don't miss any XEvent e; - while (XCheckTypedWindowEvent(blackbox->getXDisplay(), frame.window, + while (XCheckTypedWindowEvent(otk::OBDisplay::display, frame.window, MotionNotify, &e)); } @@ -3622,8 +3626,8 @@ void BlackboxWindow::beginResize(int x_root, int y_root, Corner dir) { return; // unreachable, for the compiler } - XGrabServer(blackbox->getXDisplay()); - XGrabPointer(blackbox->getXDisplay(), frame.window, False, + XGrabServer(otk::OBDisplay::display); + XGrabPointer(otk::OBDisplay::display, frame.window, False, PointerMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); @@ -3635,7 +3639,7 @@ void BlackboxWindow::beginResize(int x_root, int y_root, Corner dir) { constrain(anchor, &gw, &gh); - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), frame.changing.width() - 1, frame.changing.height() - 1); @@ -3650,7 +3654,7 @@ void BlackboxWindow::doResize(int x_root, int y_root) { assert(flags.resizing); assert(blackbox->getChangingWindow() == this); - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), frame.changing.width() - 1, frame.changing.height() - 1); @@ -3694,7 +3698,7 @@ void BlackboxWindow::doResize(int x_root, int y_root) { constrain(anchor, &gw, &gh); - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), frame.changing.width() - 1, frame.changing.height() - 1); @@ -3706,10 +3710,10 @@ void BlackboxWindow::endResize(void) { assert(flags.resizing); assert(blackbox->getChangingWindow() == this); - XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(), + XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(), screen->getOpGC(), frame.changing.x(), frame.changing.y(), frame.changing.width() - 1, frame.changing.height() - 1); - XUngrabServer(blackbox->getXDisplay()); + XUngrabServer(otk::OBDisplay::display); // unset maximized state after resized when fully maximized if (flags.maximized == 1) @@ -3722,12 +3726,12 @@ void BlackboxWindow::endResize(void) { frame.changing.width(), frame.changing.height()); screen->hideGeometry(); - XUngrabPointer(blackbox->getXDisplay(), CurrentTime); + XUngrabPointer(otk::OBDisplay::display, CurrentTime); // if there are any left over motions from the resize, drop them now - XSync(blackbox->getXDisplay(), false); // make sure we don't miss any + XSync(otk::OBDisplay::display, false); // make sure we don't miss any XEvent e; - while (XCheckTypedWindowEvent(blackbox->getXDisplay(), frame.window, + while (XCheckTypedWindowEvent(otk::OBDisplay::display, frame.window, MotionNotify, &e)); } @@ -3790,7 +3794,7 @@ void BlackboxWindow::enterNotifyEvent(const XCrossingEvent* ce) { XEvent e; bool leave = False, inferior = False; - while (XCheckTypedWindowEvent(blackbox->getXDisplay(), ce->window, + while (XCheckTypedWindowEvent(otk::OBDisplay::display, ce->window, LeaveNotify, &e)) { if (e.type == LeaveNotify && e.xcrossing.mode == NotifyNormal) { leave = True; @@ -3843,14 +3847,14 @@ void BlackboxWindow::shapeEvent(XShapeEvent *e) { bool BlackboxWindow::validateClient(void) const { - XSync(blackbox->getXDisplay(), False); + XSync(otk::OBDisplay::display, False); XEvent e; - if (XCheckTypedWindowEvent(blackbox->getXDisplay(), client.window, + if (XCheckTypedWindowEvent(otk::OBDisplay::display, client.window, DestroyNotify, &e) || - XCheckTypedWindowEvent(blackbox->getXDisplay(), client.window, + XCheckTypedWindowEvent(otk::OBDisplay::display, client.window, UnmapNotify, &e)) { - XPutBackEvent(blackbox->getXDisplay(), &e); + XPutBackEvent(otk::OBDisplay::display, &e); return False; } @@ -3860,9 +3864,9 @@ bool BlackboxWindow::validateClient(void) const { void BlackboxWindow::restore(bool remap) { - XChangeSaveSet(blackbox->getXDisplay(), client.window, SetModeDelete); - XSelectInput(blackbox->getXDisplay(), client.window, NoEventMask); - XSelectInput(blackbox->getXDisplay(), frame.plate, NoEventMask); + XChangeSaveSet(otk::OBDisplay::display, client.window, SetModeDelete); + XSelectInput(otk::OBDisplay::display, client.window, NoEventMask); + XSelectInput(otk::OBDisplay::display, frame.plate, NoEventMask); // do not leave a shaded window as an icon unless it was an icon if (flags.shaded && ! flags.iconic) @@ -3876,24 +3880,24 @@ void BlackboxWindow::restore(bool remap) { restoreGravity(client.rect); - XUnmapWindow(blackbox->getXDisplay(), frame.window); - XUnmapWindow(blackbox->getXDisplay(), client.window); + XUnmapWindow(otk::OBDisplay::display, frame.window); + XUnmapWindow(otk::OBDisplay::display, client.window); - XSetWindowBorderWidth(blackbox->getXDisplay(), client.window, client.old_bw); + XSetWindowBorderWidth(otk::OBDisplay::display, client.window, client.old_bw); XEvent ev; - if (XCheckTypedWindowEvent(blackbox->getXDisplay(), client.window, + if (XCheckTypedWindowEvent(otk::OBDisplay::display, client.window, ReparentNotify, &ev)) { remap = True; } else { // according to the ICCCM - if the client doesn't reparent to // root, then we have to do it for them - XReparentWindow(blackbox->getXDisplay(), client.window, + XReparentWindow(otk::OBDisplay::display, client.window, screen->getRootWindow(), client.rect.x(), client.rect.y()); } - if (remap) XMapWindow(blackbox->getXDisplay(), client.window); + if (remap) XMapWindow(otk::OBDisplay::display, client.window); } @@ -4168,13 +4172,13 @@ void WindowStyle::doJustify(const std::string &text, int &start_pos, BWindowGroup::BWindowGroup(Blackbox *b, Window _group) : blackbox(b), group(_group) { XWindowAttributes wattrib; - if (! XGetWindowAttributes(blackbox->getXDisplay(), group, &wattrib)) { + if (! XGetWindowAttributes(otk::OBDisplay::display, group, &wattrib)) { // group window doesn't seem to exist anymore delete this; return; } - XSelectInput(blackbox->getXDisplay(), group, + XSelectInput(otk::OBDisplay::display, group, PropertyChangeMask | FocusChangeMask | StructureNotifyMask); blackbox->saveGroupSearch(group, this); @@ -4210,3 +4214,5 @@ BWindowGroup::find(BScreen *screen, bool allow_transients) const { return ret; } + +} diff --git a/src/window.hh b/src/window.hh index 6c84a176..4070cffe 100644 --- a/src/window.hh +++ b/src/window.hh @@ -12,7 +12,7 @@ extern "C" { #include -#include "basedisplay.hh" +#include "blackbox.hh" #include "timer.hh" #include "util.hh" @@ -34,6 +34,8 @@ extern "C" { #define MwmDecorIconify (1l << 5) #define MwmDecorMaximize (1l << 6) +namespace ob { + // this structure only contains 3 elements... the Motif 2.0 structure contains // 5... we only need the first 3... so that is all we will define typedef struct MwmHints { @@ -144,7 +146,7 @@ private: std::string title, icon_title; - Rect rect; + otk::Rect rect; Strut strut; int old_bw; // client's borderwidth @@ -213,9 +215,9 @@ private: * size and location of the box drawn while the window dimensions or * location is being changed, ie. resized or moved */ - Rect changing; + otk::Rect changing; - Rect rect; // frame geometry + otk::Rect rect; // frame geometry Strut margin; // margins between the frame and client int grab_x, grab_y; // where was the window when it was grabbed? @@ -275,8 +277,8 @@ private: void redrawIconifyButton(bool pressed) const; void redrawMaximizeButton(bool pressed) const; void redrawStickyButton(bool pressed) const; - void applyGravity(Rect &r); - void restoreGravity(Rect &r); + void applyGravity(otk::Rect &r); + void restoreGravity(otk::Rect &r); void setAllowedActions(void); void setState(unsigned long new_state); void upsize(void); @@ -338,8 +340,8 @@ public: { return blackbox_attrib.workspace; } inline unsigned int getWindowNumber(void) const { return window_number; } - inline const Rect &frameRect(void) const { return frame.rect; } - inline const Rect &clientRect(void) const { return client.rect; } + inline const otk::Rect &frameRect(void) const { return frame.rect; } + inline const otk::Rect &clientRect(void) const { return client.rect; } inline unsigned int getTitleHeight(void) const { return frame.title_h; } @@ -406,5 +408,6 @@ public: virtual void timeout(void); }; +} #endif // __Window_hh diff --git a/src/workspace.cc b/src/workspace.cc index 727708c6..89134062 100644 --- a/src/workspace.cc +++ b/src/workspace.cc @@ -25,13 +25,15 @@ extern "C" { using std::string; #include "blackbox.hh" -#include "font.hh" +#include "otk/font.hh" +#include "otk/display.hh" #include "screen.hh" #include "util.hh" #include "window.hh" #include "workspace.hh" #include "xatom.hh" +namespace ob { Workspace::Workspace(BScreen *scrn, unsigned int i) { screen = scrn; @@ -99,7 +101,7 @@ void Workspace::removeWindow(BlackboxWindow *w, bool sticky) { // pass focus to the next appropriate window if ((w->isFocused() || w == lastfocus) && - ! screen->getBlackbox()->doShutdown()) { + screen->getBlackbox()->state() != Openbox::State_Exiting) { focusFallback(w); } @@ -188,7 +190,8 @@ void Workspace::showAll(void) { // sticky windows arent unmapped on a workspace change so we don't have ot // map them, but sometimes on a restart, another app can unmap our sticky // windows, so we map on startup always - if (! bw->isStuck() || screen->getBlackbox()->isStartup()) + if (! bw->isStuck() || + screen->getBlackbox()->state() == Openbox::State_Starting) bw->show(); } } @@ -465,13 +468,13 @@ void Workspace::setName(const string& new_name) { /* * Calculate free space available for window placement. */ -Workspace::rectList Workspace::calcSpace(const Rect &win, +Workspace::rectList Workspace::calcSpace(const otk::Rect &win, const rectList &spaces) const { - Rect isect, extra; + otk::Rect isect, extra; rectList result; rectList::const_iterator siter, end = spaces.end(); for (siter = spaces.begin(); siter != end; ++siter) { - const Rect &curr = *siter; + const otk::Rect &curr = *siter; if(! win.intersects(curr)) { result.push_back(curr); @@ -509,56 +512,56 @@ Workspace::rectList Workspace::calcSpace(const Rect &win, } -static bool rowRLBT(const Rect &first, const Rect &second) { +static bool rowRLBT(const otk::Rect &first, const otk::Rect &second) { if (first.bottom() == second.bottom()) return first.right() > second.right(); return first.bottom() > second.bottom(); } -static bool rowRLTB(const Rect &first, const Rect &second) { +static bool rowRLTB(const otk::Rect &first, const otk::Rect &second) { if (first.y() == second.y()) return first.right() > second.right(); return first.y() < second.y(); } -static bool rowLRBT(const Rect &first, const Rect &second) { +static bool rowLRBT(const otk::Rect &first, const otk::Rect &second) { if (first.bottom() == second.bottom()) return first.x() < second.x(); return first.bottom() > second.bottom(); } -static bool rowLRTB(const Rect &first, const Rect &second) { +static bool rowLRTB(const otk::Rect &first, const otk::Rect &second) { if (first.y() == second.y()) return first.x() < second.x(); return first.y() < second.y(); } -static bool colLRTB(const Rect &first, const Rect &second) { +static bool colLRTB(const otk::Rect &first, const otk::Rect &second) { if (first.x() == second.x()) return first.y() < second.y(); return first.x() < second.x(); } -static bool colLRBT(const Rect &first, const Rect &second) { +static bool colLRBT(const otk::Rect &first, const otk::Rect &second) { if (first.x() == second.x()) return first.bottom() > second.bottom(); return first.x() < second.x(); } -static bool colRLTB(const Rect &first, const Rect &second) { +static bool colRLTB(const otk::Rect &first, const otk::Rect &second) { if (first.right() == second.right()) return first.y() < second.y(); return first.right() > second.right(); } -static bool colRLBT(const Rect &first, const Rect &second) { +static bool colRLBT(const otk::Rect &first, const otk::Rect &second) { if (first.right() == second.right()) return first.bottom() > second.bottom(); return first.right() > second.right(); } -bool Workspace::smartPlacement(Rect& win) { +bool Workspace::smartPlacement(otk::Rect& win) { rectList spaces; //initially the entire screen is free @@ -579,7 +582,7 @@ bool Workspace::smartPlacement(Rect& win) { } else #endif // XINERAMA { - Rect r = screen->availableArea(); + otk::Rect r = screen->availableArea(); r.setRect(r.x() + screen->getSnapOffset(), r.y() + screen->getSnapOffset(), r.width() - screen->getSnapOffset(), @@ -590,7 +593,7 @@ bool Workspace::smartPlacement(Rect& win) { //Find Free Spaces BlackboxWindowList::const_iterator wit = windowList.begin(), end = windowList.end(); - Rect tmp; + otk::Rect tmp; for (; wit != end; ++wit) { const BlackboxWindow* const curr = *wit; @@ -644,7 +647,7 @@ bool Workspace::smartPlacement(Rect& win) { return False; //set new position based on the empty space found - const Rect& where = *sit; + const otk::Rect& where = *sit; win.setX(where.x()); win.setY(where.y()); @@ -664,14 +667,14 @@ bool Workspace::smartPlacement(Rect& win) { } -bool Workspace::underMousePlacement(Rect &win) { +bool Workspace::underMousePlacement(otk::Rect &win) { int x, y, rx, ry; Window c, r; unsigned int m; - XQueryPointer(screen->getBlackbox()->getXDisplay(), screen->getRootWindow(), + XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(), &r, &c, &rx, &ry, &x, &y, &m); - Rect area; + otk::Rect area; #ifdef XINERAMA if (screen->isXineramaActive() && screen->getBlackbox()->doXineramaPlacement()) { @@ -705,8 +708,8 @@ bool Workspace::underMousePlacement(Rect &win) { } -bool Workspace::cascadePlacement(Rect &win, const int offset) { - Rect area; +bool Workspace::cascadePlacement(otk::Rect &win, const int offset) { + otk::Rect area; #ifdef XINERAMA if (screen->isXineramaActive() && @@ -745,7 +748,7 @@ bool Workspace::cascadePlacement(Rect &win, const int offset) { void Workspace::placeWindow(BlackboxWindow *win) { - Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height()); + otk::Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height()); bool placed = False; switch (screen->getPlacementPolicy()) { @@ -771,3 +774,5 @@ void Workspace::placeWindow(BlackboxWindow *win) { win->configure(new_win.x(), new_win.y(), new_win.width(), new_win.height()); } + +} diff --git a/src/workspace.hh b/src/workspace.hh index 6c59a3b8..b40de267 100644 --- a/src/workspace.hh +++ b/src/workspace.hh @@ -12,6 +12,8 @@ extern "C" { #include "xatom.hh" +namespace ob { + class BScreen; class Workspace; class BlackboxWindow; @@ -42,13 +44,13 @@ private: void lowerTransients(const BlackboxWindow * const win, StackVector::iterator &stack); - typedef std::vector rectList; - rectList calcSpace(const Rect &win, const rectList &spaces) const; + typedef std::vector rectList; + rectList calcSpace(const otk::Rect &win, const rectList &spaces) const; void placeWindow(BlackboxWindow *win); - bool cascadePlacement(Rect& win, const int offset); - bool smartPlacement(Rect& win); - bool underMousePlacement(Rect& win); + bool cascadePlacement(otk::Rect& win, const int offset); + bool smartPlacement(otk::Rect& win); + bool underMousePlacement(otk::Rect& win); public: Workspace(BScreen *scrn, unsigned int i = 0); @@ -91,6 +93,7 @@ public: void setName(const std::string& new_name); }; +} #endif // __Workspace_hh diff --git a/src/xatom.cc b/src/xatom.cc index 0e92e471..3ed6cdf4 100644 --- a/src/xatom.cc +++ b/src/xatom.cc @@ -12,6 +12,8 @@ extern "C" { #include "screen.hh" #include "util.hh" +namespace ob { + XAtom::XAtom(Display *d) { _display = d; @@ -168,7 +170,7 @@ Atom XAtom::create(const char *name) const { /* * Sets which atoms are supported for NETWM, by Openbox, on the root window. */ -void XAtom::setSupported(const ScreenInfo *screen) { +void XAtom::setSupported(const otk::ScreenInfo *screen) { Window root = screen->getRootWindow(); // create the netwm support window @@ -509,3 +511,5 @@ void XAtom::sendClientMessage(Window target, Atoms type, Window about, SubstructureRedirectMask | SubstructureNotifyMask, &e); } + +} diff --git a/src/xatom.hh b/src/xatom.hh index 3c382114..df9bdf4f 100644 --- a/src/xatom.hh +++ b/src/xatom.hh @@ -2,16 +2,19 @@ #ifndef __XAtom_h #define __XAtom_h +extern "C" { #include #include #include +} #include #include -class Blackbox; -class ScreenInfo; +#include "otk/screeninfo.hh" + +namespace ob { class XAtom { public: @@ -170,7 +173,7 @@ public: // setup support on a screen, each screen should call this once in its // constructor. - void setSupported(const ScreenInfo *screen); + void setSupported(const otk::ScreenInfo *screen); void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const; void setValue(Window win, Atoms atom, Atoms type, @@ -207,4 +210,6 @@ public: assert(ret != 0); return ret; } }; +} + #endif // __XAtom_h