X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fblackbox.cc;h=6d267b53017e8fd3b603496746493644cc35cef8;hb=9259ec5732851dd66f7c598d629e3808ac7ab3d8;hp=e0240e81095bccfe1b30d85c65c55ed78f4ce9bc;hpb=7bf96a9123a9f6b29a4c6168f7391db72f374f8a;p=chaz%2Fopenbox diff --git a/src/blackbox.cc b/src/blackbox.cc index e0240e81..6d267b53 100644 --- a/src/blackbox.cc +++ b/src/blackbox.cc @@ -1,25 +1,4 @@ // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -// blackbox.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. #ifdef HAVE_CONFIG_H # include "../config.h" @@ -97,26 +76,30 @@ 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"); 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 @@ -124,7 +107,7 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH); - if (! rc) rc = "~/.openbox/rc"; + if (! rc) rc = "~/.openbox/rc3"; rc_file = expandTilde(rc); config.setFile(rc_file); @@ -137,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()) { @@ -170,18 +153,20 @@ 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; - timer = new BTimer(this, this); + timer = new otk::OBTimer(Openbox::instance->timerManager(), + (otk::OBTimeoutHandler)timeout, + this); timer->setTimeout(0l); } Blackbox::~Blackbox(void) { - std::for_each(screenList.begin(), screenList.end(), PointerAssassin()); + std::for_each(screenList.begin(), screenList.end(), otk::PointerAssassin()); delete xatom; @@ -193,7 +178,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; @@ -221,7 +206,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; @@ -250,7 +235,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); } } @@ -296,7 +281,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? @@ -359,7 +344,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++; } @@ -373,7 +358,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; @@ -435,7 +420,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++; @@ -535,7 +520,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) { @@ -552,7 +537,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) { /* @@ -890,8 +875,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; } @@ -981,20 +966,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); } @@ -1003,9 +988,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; @@ -1145,7 +1128,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; @@ -1156,7 +1139,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)); @@ -1170,11 +1153,11 @@ void Blackbox::saveStyleFilename(const string& filename) { } -void Blackbox::timeout(void) { - if (reconfigure_wait) - real_reconfigure(); +void Blackbox::timeout(Blackbox *t) { + if (t->reconfigure_wait) + t->real_reconfigure(); - reconfigure_wait = False; + t->reconfigure_wait = False; } @@ -1208,18 +1191,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); } } @@ -1232,3 +1215,6 @@ void Blackbox::setFocusedWindow(BlackboxWindow *win) { old_screen->updateNetizenWindowFocus(); } } + + +}