WE DONT USE BASE DISPLAY FOR ANYTHING ANY MORE!!@^!*@*!! YAY

This commit is contained in:
Dana Jansens 2002-11-03 11:46:05 +00:00
parent 37e5600768
commit ace8c8896a
28 changed files with 973 additions and 944 deletions

View file

@ -5,7 +5,7 @@ INCLUDES= -I../src
noinst_LIBRARIES=libotk.a noinst_LIBRARIES=libotk.a
libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \ 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 MAINTAINERCLEANFILES= Makefile.in

View file

@ -39,7 +39,14 @@ extern "C" {
namespace otk { 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) 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 // find the availability of X extensions we like to use
#ifdef SHAPE #ifdef SHAPE
_shape = XShapeQueryExtension(display, &_shape_event_basep, &junk); _shape = XShapeQueryExtension(display, &_shape_event_basep, &junk);
#else
_shape = false;
#endif #endif
#ifdef XINERAMA #ifdef XINERAMA
_xinerama = XineramaQueryExtension(display, &_xinerama_event_basep, &junk); _xinerama = XineramaQueryExtension(display, &_xinerama_event_basep, &junk);
#else
_xinerama = false;
#endif // XINERAMA #endif // XINERAMA
// get lock masks that are defined by the display (not constant) // 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);
}
} }

View file

@ -62,6 +62,19 @@ public:
inline static int shapeEventBase() { return _shape_event_basep; } inline static int shapeEventBase() { return _shape_event_basep; }
//! Returns if the display has the xinerama extention available //! Returns if the display has the xinerama extention available
inline static bool xinerama() { return _xinerama; } 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);
}; };
} }

View file

@ -4,8 +4,14 @@
# include "../config.h" # include "../config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
extern "C" {
#include <X11/Xlib.h>
#include <X11/Xutil.h>
}
#include "screeninfo.hh" #include "screeninfo.hh"
#include "display.hh" #include "display.hh"
#include "src/util.hh"
using std::string; using std::string;
@ -14,7 +20,7 @@ namespace otk {
ScreenInfo::ScreenInfo(unsigned int num) { ScreenInfo::ScreenInfo(unsigned int num) {
screen_number = 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, rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display,
screen_number)), screen_number)),
@ -73,7 +79,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
default_string.resize(pos); default_string.resize(pos);
display_string = string("DISPLAY=") + default_string + '.' + display_string = string("DISPLAY=") + default_string + '.' +
itostring(static_cast<unsigned long>(screen_number)); ob::itostring(static_cast<unsigned long>(screen_number));
#ifdef XINERAMA #ifdef XINERAMA
xinerama_active = False; xinerama_active = False;

View file

@ -1,3 +1,4 @@
# List of source files containing translatable strings. # List of source files containing translatable strings.
src/main.cc src/openbox.cc
src/display.cc

View file

@ -15,7 +15,7 @@ bin_PROGRAMS= openbox
openbox_LDADD=../otk/libotk.a @LIBINTL@ 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 \ timer.cc util.cc window.cc workspace.cc xatom.cc blackbox.cc \
main.cc main.cc

View file

@ -13,7 +13,6 @@ extern "C" {
#include <vector> #include <vector>
// forward declaration // forward declaration
class BaseDisplay;
class BGCCache; class BGCCache;
class BaseDisplay: public TimerQueueManager { class BaseDisplay: public TimerQueueManager {

View file

@ -76,19 +76,22 @@ extern "C" {
using std::string; using std::string;
#include "blackbox.hh" #include "blackbox.hh"
#include "gccache.hh" #include "otk/gccache.hh"
#include "image.hh" #include "otk/image.hh"
#include "otk/assassin.hh"
#include "screen.hh" #include "screen.hh"
#include "util.hh" #include "util.hh"
#include "window.hh" #include "window.hh"
#include "workspace.hh" #include "workspace.hh"
#include "xatom.hh" #include "xatom.hh"
namespace ob {
Blackbox *blackbox; Blackbox *blackbox;
Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc) Blackbox::Blackbox(int argc, char **m_argv, char *rc)
: BaseDisplay(m_argv[0], dpy_name) { : Openbox(argc, m_argv) {
if (! XSupportsLocale()) if (! XSupportsLocale())
fprintf(stderr, "X server does not support locale\n"); 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) if (XSetLocaleModifiers("") == NULL)
fprintf(stderr, "cannot set locale modifiers\n"); fprintf(stderr, "cannot set locale modifiers\n");
::blackbox = this; ob::blackbox = this;
argv = m_argv; argv = m_argv;
// try to make sure the ~/.openbox directory exists // try to make sure the ~/.openbox directory exists
@ -117,16 +120,16 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc)
load_rc(); load_rc();
xatom = new XAtom(getXDisplay()); xatom = new XAtom(otk::OBDisplay::display);
cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr); cursor.session = XCreateFontCursor(otk::OBDisplay::display, XC_left_ptr);
cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur); cursor.move = XCreateFontCursor(otk::OBDisplay::display, XC_fleur);
cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle); cursor.ll_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ll_angle);
cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle); cursor.lr_angle = XCreateFontCursor(otk::OBDisplay::display, XC_lr_angle);
cursor.ul_angle = XCreateFontCursor(getXDisplay(), XC_ul_angle); cursor.ul_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ul_angle);
cursor.ur_angle = XCreateFontCursor(getXDisplay(), XC_ur_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); BScreen *screen = new BScreen(this, i);
if (! screen->isScreenManaged()) { if (! screen->isScreenManaged()) {
@ -150,8 +153,8 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc)
active_screen = screenList.front(); active_screen = screenList.front();
setFocusedWindow(0); setFocusedWindow(0);
XSynchronize(getXDisplay(), False); XSynchronize(otk::OBDisplay::display, False);
XSync(getXDisplay(), False); XSync(otk::OBDisplay::display, False);
reconfigure_wait = False; reconfigure_wait = False;
@ -161,7 +164,7 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc)
Blackbox::~Blackbox(void) { Blackbox::~Blackbox(void) {
std::for_each(screenList.begin(), screenList.end(), PointerAssassin()); std::for_each(screenList.begin(), screenList.end(), otk::PointerAssassin());
delete xatom; delete xatom;
@ -173,7 +176,7 @@ void Blackbox::process_event(XEvent *e) {
switch (e->type) { switch (e->type) {
case ButtonPress: { case ButtonPress: {
// strip the lock key modifiers // strip the lock key modifiers
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask); //e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
last_time = e->xbutton.time; last_time = e->xbutton.time;
@ -201,7 +204,7 @@ void Blackbox::process_event(XEvent *e) {
case ButtonRelease: { case ButtonRelease: {
// strip the lock key modifiers // strip the lock key modifiers
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask); //e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
last_time = e->xbutton.time; last_time = e->xbutton.time;
@ -230,7 +233,7 @@ void Blackbox::process_event(XEvent *e) {
xwc.sibling = e->xconfigurerequest.above; xwc.sibling = e->xconfigurerequest.above;
xwc.stack_mode = e->xconfigurerequest.detail; xwc.stack_mode = e->xconfigurerequest.detail;
XConfigureWindow(getXDisplay(), e->xconfigurerequest.window, XConfigureWindow(otk::OBDisplay::display, e->xconfigurerequest.window,
e->xconfigurerequest.value_mask, &xwc); e->xconfigurerequest.value_mask, &xwc);
} }
} }
@ -276,7 +279,7 @@ void Blackbox::process_event(XEvent *e) {
the window is on the window is on
*/ */
XWindowAttributes wattrib; XWindowAttributes wattrib;
if (! XGetWindowAttributes(getXDisplay(), e->xmaprequest.window, if (! XGetWindowAttributes(otk::OBDisplay::display, e->xmaprequest.window,
&wattrib)) { &wattrib)) {
// failed to get the window attributes, perhaps the window has // failed to get the window attributes, perhaps the window has
// now been destroyed? // now been destroyed?
@ -339,7 +342,7 @@ void Blackbox::process_event(XEvent *e) {
// motion notify compression... // motion notify compression...
XEvent realevent; XEvent realevent;
unsigned int i = 0; unsigned int i = 0;
while (XCheckTypedWindowEvent(getXDisplay(), e->xmotion.window, while (XCheckTypedWindowEvent(otk::OBDisplay::display, e->xmotion.window,
MotionNotify, &realevent)) { MotionNotify, &realevent)) {
i++; i++;
} }
@ -353,7 +356,7 @@ void Blackbox::process_event(XEvent *e) {
break; break;
// strip the lock key modifiers // strip the lock key modifiers
e->xmotion.state &= ~(NumLockMask | ScrollLockMask | LockMask); //e->xmotion.state &= ~(NumLockMask | ScrollLockMask | LockMask);
last_time = e->xmotion.time; last_time = e->xmotion.time;
@ -415,7 +418,7 @@ void Blackbox::process_event(XEvent *e) {
ey1 = e->xexpose.y; ey1 = e->xexpose.y;
ex2 = ex1 + e->xexpose.width - 1; ex2 = ex1 + e->xexpose.width - 1;
ey2 = ey1 + e->xexpose.height - 1; ey2 = ey1 + e->xexpose.height - 1;
while (XCheckTypedWindowEvent(getXDisplay(), e->xexpose.window, while (XCheckTypedWindowEvent(otk::OBDisplay::display, e->xexpose.window,
Expose, &realevent)) { Expose, &realevent)) {
i++; i++;
@ -515,7 +518,7 @@ void Blackbox::process_event(XEvent *e) {
(the FocusIn event handler sets the window in the event (the FocusIn event handler sets the window in the event
structure to None to indicate this). structure to None to indicate this).
*/ */
if (XCheckTypedEvent(getXDisplay(), FocusIn, &event)) { if (XCheckTypedEvent(otk::OBDisplay::display, FocusIn, &event)) {
process_event(&event); process_event(&event);
if (event.xfocus.window == None) { if (event.xfocus.window == None) {
@ -532,7 +535,7 @@ void Blackbox::process_event(XEvent *e) {
BlackboxWindow *focus; BlackboxWindow *focus;
Window w; Window w;
int revert; int revert;
XGetInputFocus(getXDisplay(), &w, &revert); XGetInputFocus(otk::OBDisplay::display, &w, &revert);
focus = searchWindow(w); focus = searchWindow(w);
if (focus) { if (focus) {
/* /*
@ -870,8 +873,8 @@ bool Blackbox::handleSignal(int sig) {
bool Blackbox::validateWindow(Window window) { bool Blackbox::validateWindow(Window window) {
XEvent event; XEvent event;
if (XCheckTypedWindowEvent(getXDisplay(), window, DestroyNotify, &event)) { if (XCheckTypedWindowEvent(otk::OBDisplay::display, window, DestroyNotify, &event)) {
XPutBackEvent(getXDisplay(), &event); XPutBackEvent(otk::OBDisplay::display, &event);
return False; return False;
} }
@ -961,20 +964,20 @@ void Blackbox::restart(const char *prog) {
// fall back in case the above execlp doesn't work // fall back in case the above execlp doesn't work
execvp(argv[0], argv); execvp(argv[0], argv);
string name = basename(argv[0]); string name = ::basename(argv[0]);
execvp(name.c_str(), argv); execvp(name.c_str(), argv);
} }
void Blackbox::shutdown(void) { 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::for_each(screenList.begin(), screenList.end(),
std::mem_fun(&BScreen::shutdown)); 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; resource.xinerama_placement = x;
config.setValue("session.xineramaSupport.windowPlacement", config.setValue("session.xineramaSupport.windowPlacement",
resource.xinerama_placement); resource.xinerama_placement);
reconfigure(); // make sure all screens get this change reconfigure(); // make sure all screens get this
}
void Blackbox::saveXineramaMaximizing(bool x) { void Blackbox::saveXineramaMaximizing(bool x) {
resource.xinerama_maximize = x; resource.xinerama_maximize = x;
@ -1125,7 +1126,7 @@ void Blackbox::load_rc(void) {
void Blackbox::reconfigure(void) { void Blackbox::reconfigure(void) {
// don't reconfigure while saving the initial rc file, it's a waste and it // don't reconfigure while saving the initial rc file, it's a waste and it
// breaks somethings (workspace names) // breaks somethings (workspace names)
if (isStartup()) return; if (state() == Openbox::State_Starting) return;
reconfigure_wait = True; reconfigure_wait = True;
@ -1136,7 +1137,7 @@ void Blackbox::reconfigure(void) {
void Blackbox::real_reconfigure(void) { void Blackbox::real_reconfigure(void) {
load_rc(); load_rc();
gcCache()->purge(); otk::OBDisplay::gcCache()->purge();
std::for_each(screenList.begin(), screenList.end(), std::for_each(screenList.begin(), screenList.end(),
std::mem_fun(&BScreen::reconfigure)); std::mem_fun(&BScreen::reconfigure));
@ -1188,18 +1189,18 @@ void Blackbox::setFocusedWindow(BlackboxWindow *win) {
if (! old_screen) { if (! old_screen) {
if (active_screen) { if (active_screen) {
// set input focus to the toolbar of the screen with mouse // set input focus to the toolbar of the screen with mouse
XSetInputFocus(getXDisplay(), XSetInputFocus(otk::OBDisplay::display,
active_screen->getRootWindow(), active_screen->getRootWindow(),
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
} else { } else {
// set input focus to the toolbar of the first managed screen // set input focus to the toolbar of the first managed screen
XSetInputFocus(getXDisplay(), XSetInputFocus(otk::OBDisplay::display,
screenList.front()->getRootWindow(), screenList.front()->getRootWindow(),
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
} }
} else { } else {
// set input focus to the toolbar of the last screen // set input focus to the toolbar of the last screen
XSetInputFocus(getXDisplay(), old_screen->getRootWindow(), XSetInputFocus(otk::OBDisplay::display, old_screen->getRootWindow(),
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
} }
} }
@ -1212,3 +1213,16 @@ void Blackbox::setFocusedWindow(BlackboxWindow *win) {
old_screen->updateNetizenWindowFocus(); old_screen->updateNetizenWindowFocus();
} }
} }
void Blackbox::addTimer(BTimer *timer) {
(void)timer;
}
void Blackbox::removeTimer(BTimer *timer) {
(void)timer;
}
}

View file

@ -25,7 +25,7 @@ extern "C" {
#include <map> #include <map>
#include <string> #include <string>
#include "basedisplay.hh" #include "openbox.hh"
#include "configuration.hh" #include "configuration.hh"
#include "timer.hh" #include "timer.hh"
#include "xatom.hh" #include "xatom.hh"
@ -47,6 +47,8 @@ extern "C" {
#define DecorTiny (2) #define DecorTiny (2)
#define DecorTool (3) #define DecorTool (3)
namespace ob {
struct BlackboxHints { struct BlackboxHints {
unsigned long flags, attrib, workspace, stack, decoration; unsigned long flags, attrib, workspace, stack, decoration;
}; };
@ -67,7 +69,7 @@ class Blackbox;
class BlackboxWindow; class BlackboxWindow;
class BWindowGroup; class BWindowGroup;
class Blackbox : public BaseDisplay, public TimeoutHandler { class Blackbox : public Openbox, public TimeoutHandler, public TimerQueueManager {
private: private:
struct BCursor { struct BCursor {
Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle; Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
@ -79,7 +81,7 @@ private:
std::string style_file; std::string style_file;
int colors_per_channel; int colors_per_channel;
timeval auto_raise_delay; ::timeval auto_raise_delay;
unsigned long cache_life, cache_max; unsigned long cache_life, cache_max;
std::string titlebar_layout; std::string titlebar_layout;
unsigned int mod_mask; // modifier mask used for window-mouse interaction unsigned int mod_mask; // modifier mask used for window-mouse interaction
@ -127,7 +129,7 @@ private:
public: public:
Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0); Blackbox(int argc, char **m_argv, char *rc = 0);
virtual ~Blackbox(void); virtual ~Blackbox(void);
BWindowGroup *searchGroup(Window window); BWindowGroup *searchGroup(Window window);
@ -174,7 +176,7 @@ public:
inline std::string getTitlebarLayout(void) const inline std::string getTitlebarLayout(void) const
{ return resource.titlebar_layout; } { return resource.titlebar_layout; }
inline const timeval &getAutoRaiseDelay(void) const inline const ::timeval &getAutoRaiseDelay(void) const
{ return resource.auto_raise_delay; } { return resource.auto_raise_delay; }
inline unsigned long getCacheLife(void) const inline unsigned long getCacheLife(void) const
@ -214,7 +216,11 @@ public:
virtual void timeout(void); virtual void timeout(void);
enum { B_AmericanDate = 1, B_EuropeanDate }; enum { B_AmericanDate = 1, B_EuropeanDate };
virtual void addTimer(BTimer *timer);
virtual void removeTimer(BTimer *timer);
}; };
}
#endif // __blackbox_hh #endif // __blackbox_hh

View file

@ -17,6 +17,8 @@ extern "C" {
using std::string; using std::string;
namespace ob {
bool Configuration::_initialized = False; bool Configuration::_initialized = False;
Configuration::Configuration(const string &file, bool autosave) { Configuration::Configuration(const string &file, bool autosave) {
@ -231,3 +233,5 @@ char Configuration::toUpper(char c) const {
return c - 'a' + 'A'; return c - 'a' + 'A';
return c; return c;
} }
}

View file

@ -6,6 +6,8 @@
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <string> #include <string>
namespace ob {
/* /*
* The Configuration class is a generic wrapper for configuration settings. * The Configuration class is a generic wrapper for configuration settings.
* *
@ -74,4 +76,6 @@ private:
XrmDatabase _database; XrmDatabase _database;
}; };
}
#endif // __Configuration_hh #endif // __Configuration_hh

View file

@ -1,163 +1,29 @@
// -*- mode: C++; indent-tabs-mode: nil; -*- // -*- mode: C++; indent-tabs-mode: nil; -*-
#include "../version.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "../config.h" # include "../config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
extern "C" { extern "C" {
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif // HAVE_STDIO_H
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
#ifdef HAVE_STRING_H
# include <string.h>
#endif // HAVE_STRING_H
#ifdef HAVE_UNISTD_H
#include <sys/types.h>
#endif // HAVE_UNISTD_H
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif // HAVE_SYS_PARAM_H
}
#include "gettext.h" #include "gettext.h"
#define _(str) gettext(str) }
#include <string> #include <string>
using std::string; using std::string;
#include "blackbox.hh" #include "blackbox.hh"
#include "openbox.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 <string> use display connection.\n\
-rc <string> use alternate resource file.\n\
-menu <string> 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);
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
char *session_display = (char *) 0;
char *rc_file = (char *) 0;
char *menu_file = (char *) 0;
// initialize the locale // initialize the locale
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR); bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); textdomain(PACKAGE);
//ob::Openbox openbox(argc, argv);
ob::Blackbox blackbox(argc, argv, 0);
for (int i = 1; i < argc; ++i) { //Blackbox blackbox(argv, session_display, rc_file);
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<char*>(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);
blackbox.eventLoop(); blackbox.eventLoop();
return(0); return(0);

261
src/openbox.cc Normal file
View file

@ -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 <stdio.h>
#endif // HAVE_STDIO_H
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif // HAVE_SIGNAL_H
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif // HAVE_FCNTL_H
#ifdef HAVE_UNISTD_H
# include <sys/types.h>
# include <unistd.h>
#endif // HAVE_UNISTD_H
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#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 <string> use display connection.\n\
-rc <string> use alternate resource file.\n\
-menu <string> 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();
}*/
}
}
}
}

71
src/openbox.hh Normal file
View file

@ -0,0 +1,71 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
#ifndef __openbox_hh
#define __openbox_hh
extern "C" {
#include <X11/Xlib.h>
}
#include <string>
#include <vector>
#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<otk::ScreenInfo> 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

View file

@ -54,11 +54,12 @@ extern "C" {
#include <string> #include <string>
using std::string; using std::string;
#include "blackbox.hh"
#include "font.hh"
#include "gccache.hh"
#include "image.hh"
#include "screen.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 "util.hh"
#include "window.hh" #include "window.hh"
#include "workspace.hh" #include "workspace.hh"
@ -69,6 +70,7 @@ using std::string;
#define FONT_ELEMENT_SIZE 50 #define FONT_ELEMENT_SIZE 50
#endif // FONT_ELEMENT_SIZE #endif // FONT_ELEMENT_SIZE
namespace ob {
static bool running = True; 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; blackbox = bb;
screenstr = "session.screen" + itostring(scrn) + '.'; screenstr = "session.screen" + itostring(scrn) + '.';
config = blackbox->getConfig(); config = blackbox->getConfig();
@ -94,8 +96,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask; SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask;
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask); XSelectInput(otk::OBDisplay::display, getRootWindow(), event_mask);
XSync(getBaseDisplay()->getXDisplay(), False); XSync(otk::OBDisplay::display, False);
XSetErrorHandler((XErrorHandler) old); XSetErrorHandler((XErrorHandler) old);
managed = running; managed = running;
@ -106,7 +108,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
getScreenNumber(), XVisualIDFromVisual(getVisual()), getScreenNumber(), XVisualIDFromVisual(getVisual()),
getDepth()); getDepth());
resource.wstyle.font = (BFont *) 0; resource.wstyle.font = (otk::BFont *) 0;
geom_pixmap = None; geom_pixmap = None;
@ -124,14 +126,14 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
XAtom::cardinal, viewport, 2); XAtom::cardinal, viewport, 2);
XDefineCursor(blackbox->getXDisplay(), getRootWindow(), XDefineCursor(otk::OBDisplay::display, getRootWindow(),
blackbox->getSessionCursor()); blackbox->getSessionCursor());
updateAvailableArea(); updateAvailableArea();
image_control = image_control =
new BImageControl(blackbox, this, True, blackbox->getColorsPerChannel(), new otk::BImageControl(this, True, blackbox->getColorsPerChannel(),
blackbox->getCacheLife(), blackbox->getCacheMax()); blackbox->getCacheLife(), blackbox->getCacheMax());
image_control->installRootColormap(); image_control->installRootColormap();
root_colormap_installed = True; root_colormap_installed = True;
@ -139,11 +141,11 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
LoadStyle(); LoadStyle();
XGCValues gcv; XGCValues gcv;
gcv.foreground = WhitePixel(blackbox->getXDisplay(), getScreenNumber()) gcv.foreground = WhitePixel(otk::OBDisplay::display, getScreenNumber())
^ BlackPixel(blackbox->getXDisplay(), getScreenNumber()); ^ BlackPixel(otk::OBDisplay::display, getScreenNumber());
gcv.function = GXxor; gcv.function = GXxor;
gcv.subwindow_mode = IncludeInferiors; gcv.subwindow_mode = IncludeInferiors;
opGC = XCreateGC(blackbox->getXDisplay(), getRootWindow(), opGC = XCreateGC(otk::OBDisplay::display, getRootWindow(),
GCForeground | GCFunction | GCSubwindowMode, &gcv); GCForeground | GCFunction | GCSubwindowMode, &gcv);
const char *s = "0: 0000 x 0: 0000"; 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.colormap = getColormap();
attrib.save_under = True; 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, 0, 0, geom_w, geom_h, resource.border_width,
getDepth(), InputOutput, getVisual(), getDepth(), InputOutput, getVisual(),
mask, &attrib); mask, &attrib);
geom_visible = False; 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); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
if (geom_pixmap == ParentRelative) { if (geom_pixmap == ParentRelative) {
texture = &(resource.wstyle.t_focus); texture = &(resource.wstyle.t_focus);
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
} }
if (! geom_pixmap) if (! geom_pixmap)
XSetWindowBackground(blackbox->getXDisplay(), geom_window, XSetWindowBackground(otk::OBDisplay::display, geom_window,
texture->color().pixel()); texture->color().pixel());
else else
XSetWindowBackgroundPixmap(blackbox->getXDisplay(), XSetWindowBackgroundPixmap(otk::OBDisplay::display,
geom_window, geom_pixmap); geom_window, geom_pixmap);
if (resource.workspaces > 0) { if (resource.workspaces > 0) {
@ -203,14 +205,14 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
unsigned int i, j, nchild; unsigned int i, j, nchild;
Window r, p, *children; Window r, p, *children;
XQueryTree(blackbox->getXDisplay(), getRootWindow(), &r, &p, XQueryTree(otk::OBDisplay::display, getRootWindow(), &r, &p,
&children, &nchild); &children, &nchild);
// preen the window list of all icon windows... for better dockapp support // preen the window list of all icon windows... for better dockapp support
for (i = 0; i < nchild; i++) { for (i = 0; i < nchild; i++) {
if (children[i] == None) continue; if (children[i] == None) continue;
XWMHints *wmhints = XGetWMHints(blackbox->getXDisplay(), XWMHints *wmhints = XGetWMHints(otk::OBDisplay::display,
children[i]); children[i]);
if (wmhints) { if (wmhints) {
@ -234,7 +236,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
continue; continue;
XWindowAttributes attrib; XWindowAttributes attrib;
if (XGetWindowAttributes(blackbox->getXDisplay(), children[i], &attrib)) { if (XGetWindowAttributes(otk::OBDisplay::display, children[i], &attrib)) {
if (attrib.override_redirect) continue; if (attrib.override_redirect) continue;
if (attrib.map_state != IsUnmapped) { if (attrib.map_state != IsUnmapped) {
@ -257,12 +259,12 @@ BScreen::~BScreen(void) {
image_control->removeImage(geom_pixmap); image_control->removeImage(geom_pixmap);
if (geom_window != None) if (geom_window != None)
XDestroyWindow(blackbox->getXDisplay(), geom_window); XDestroyWindow(otk::OBDisplay::display, geom_window);
std::for_each(workspacesList.begin(), workspacesList.end(), 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()) while (! systrayWindowList.empty())
removeSystrayWindow(systrayWindowList[0]); removeSystrayWindow(systrayWindowList[0]);
@ -273,19 +275,19 @@ BScreen::~BScreen(void) {
delete resource.wstyle.font; delete resource.wstyle.font;
if (resource.wstyle.close_button.mask != None) 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) 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) 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) 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.max_button.mask = resource.wstyle.close_button.mask =
resource.wstyle.icon_button.mask = resource.wstyle.icon_button.mask =
resource.wstyle.stick_button.mask = None; 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) { void BScreen::reconfigure(void) {
// don't reconfigure while saving the initial rc file, it's a waste and it // don't reconfigure while saving the initial rc file, it's a waste and it
// breaks somethings (workspace names) // breaks somethings (workspace names)
if (blackbox->isStartup()) return; if (blackbox->state() == Openbox::State_Starting) return;
load_rc(); load_rc();
LoadStyle(); LoadStyle();
@ -732,11 +734,11 @@ void BScreen::reconfigure(void) {
changeWorkspaceCount(resource.workspaces); changeWorkspaceCount(resource.workspaces);
XGCValues gcv; XGCValues gcv;
gcv.foreground = WhitePixel(blackbox->getXDisplay(), gcv.foreground = WhitePixel(otk::OBDisplay::display,
getScreenNumber()); getScreenNumber());
gcv.function = GXinvert; gcv.function = GXinvert;
gcv.subwindow_mode = IncludeInferiors; gcv.subwindow_mode = IncludeInferiors;
XChangeGC(blackbox->getXDisplay(), opGC, XChangeGC(otk::OBDisplay::display, opGC,
GCForeground | GCFunction | GCSubwindowMode, &gcv); GCForeground | GCFunction | GCSubwindowMode, &gcv);
const char *s = "0: 0000 x 0: 0000"; 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_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
geom_h = resource.wstyle.font->height() + 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); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
if (geom_pixmap == ParentRelative) { if (geom_pixmap == ParentRelative) {
texture = &(resource.wstyle.t_focus); texture = &(resource.wstyle.t_focus);
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap); geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
} }
if (! geom_pixmap) if (! geom_pixmap)
XSetWindowBackground(blackbox->getXDisplay(), geom_window, XSetWindowBackground(otk::OBDisplay::display, geom_window,
texture->color().pixel()); texture->color().pixel());
else else
XSetWindowBackgroundPixmap(blackbox->getXDisplay(), XSetWindowBackgroundPixmap(otk::OBDisplay::display,
geom_window, geom_pixmap); geom_window, geom_pixmap);
XSetWindowBorderWidth(blackbox->getXDisplay(), geom_window, XSetWindowBorderWidth(otk::OBDisplay::display, geom_window,
resource.border_width); resource.border_width);
XSetWindowBorder(blackbox->getXDisplay(), geom_window, XSetWindowBorder(otk::OBDisplay::display, geom_window,
resource.border_color.pixel()); resource.border_color.pixel());
typedef std::vector<int> SubList; typedef std::vector<int> SubList;
@ -836,13 +838,13 @@ void BScreen::LoadStyle(void) {
readDatabaseTexture("window.button.pressed.unfocus", "black", style, true); readDatabaseTexture("window.button.pressed.unfocus", "black", style, true);
if (resource.wstyle.close_button.mask != None) 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) 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) 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) 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.close_button.mask = resource.wstyle.max_button.mask =
resource.wstyle.icon_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 // we create the window.frame texture by hand because it exists only to
// make the code cleaner and is not actually used for display // make the code cleaner and is not actually used for display
BColor color = readDatabaseColor("window.frame.focusColor", "white", style); otk::BColor color = readDatabaseColor("window.frame.focusColor", "white",
resource.wstyle.f_focus = BTexture("solid flat", getBaseDisplay(), style);
getScreenNumber(), image_control); resource.wstyle.f_focus = otk::BTexture("solid flat", getScreenNumber(),
image_control);
resource.wstyle.f_focus.setColor(color); resource.wstyle.f_focus.setColor(color);
color = readDatabaseColor("window.frame.unfocusColor", "white", style); color = readDatabaseColor("window.frame.unfocusColor", "white", style);
resource.wstyle.f_unfocus = BTexture("solid flat", getBaseDisplay(), resource.wstyle.f_unfocus = otk::BTexture("solid flat", getScreenNumber(),
getScreenNumber(), image_control); image_control);
resource.wstyle.f_unfocus.setColor(color); resource.wstyle.f_unfocus.setColor(color);
resource.wstyle.l_text_focus = resource.wstyle.l_text_focus =
@ -887,13 +890,13 @@ void BScreen::LoadStyle(void) {
} }
// sanity checks // 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; 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; 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; 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.wstyle.h_unfocus = resource.wstyle.f_unfocus;
resource.border_color = resource.border_color =
@ -1021,12 +1024,12 @@ void BScreen::changeWorkspaceID(unsigned int id) {
BlackboxWindow *win = (BlackboxWindow *) 0; BlackboxWindow *win = (BlackboxWindow *) 0;
bool f = False; 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, // If sloppy focus and we can find the client window under the pointer,
// try to focus it. // try to focus it.
if (resource.sloppy_focus && if (resource.sloppy_focus &&
XQueryPointer(blackbox->getXDisplay(), getRootWindow(), &r, &c, XQueryPointer(otk::OBDisplay::display, getRootWindow(), &r, &c,
&rx, &ry, &x, &y, &m) && &rx, &ry, &x, &y, &m) &&
c != None) { c != None) {
if ( (win = blackbox->searchWindow(c)) ) if ( (win = blackbox->searchWindow(c)) )
@ -1112,21 +1115,21 @@ void BScreen::updateStackingList(void) {
void BScreen::addSystrayWindow(Window window) { 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); systrayWindowList.push_back(window);
xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows, xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows,
XAtom::window, XAtom::window,
&systrayWindowList[0], systrayWindowList.size()); &systrayWindowList[0], systrayWindowList.size());
blackbox->saveSystrayWindowSearch(window, this); blackbox->saveSystrayWindowSearch(window, this);
XUngrabServer(blackbox->getXDisplay()); XUngrabServer(otk::OBDisplay::display);
} }
void BScreen::removeSystrayWindow(Window window) { void BScreen::removeSystrayWindow(Window window) {
XGrabServer(blackbox->getXDisplay()); XGrabServer(otk::OBDisplay::display);
WindowList::iterator it = systrayWindowList.begin(); WindowList::iterator it = systrayWindowList.begin();
const WindowList::iterator end = systrayWindowList.end(); const WindowList::iterator end = systrayWindowList.end();
@ -1137,13 +1140,13 @@ void BScreen::removeSystrayWindow(Window window) {
XAtom::window, XAtom::window,
&systrayWindowList[0], systrayWindowList.size()); &systrayWindowList[0], systrayWindowList.size());
blackbox->removeSystrayWindowSearch(window); blackbox->removeSystrayWindowSearch(window);
XSelectInput(blackbox->getXDisplay(), window, NoEventMask); XSelectInput(otk::OBDisplay::display, window, NoEventMask);
break; break;
} }
assert(it != end); // not a systray window 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 // is the window a docking app
XWMHints *wmhint = XGetWMHints(blackbox->getXDisplay(), w); XWMHints *wmhint = XGetWMHints(otk::OBDisplay::display, w);
if (wmhint && (wmhint->flags & StateHint) && if (wmhint && (wmhint->flags & StateHint) &&
wmhint->initial_state == WithdrawnState) { wmhint->initial_state == WithdrawnState) {
//slit->addClient(w); //slit->addClient(w);
@ -1183,7 +1186,9 @@ void BScreen::manageWindow(Window w) {
XMapRequestEvent mre; XMapRequestEvent mre;
mre.window = w; mre.window = w;
if (blackbox->isStartup() && win->isNormal()) win->restoreAttributes(); if (blackbox->state() == Openbox::State_Starting &&
win->isNormal())
win->restoreAttributes();
win->mapRequestEvent(&mre); win->mapRequestEvent(&mre);
} }
@ -1259,7 +1264,7 @@ void BScreen::updateWorkArea(void) {
unsigned long *dims = new unsigned long[4 * workspacesList.size()]; unsigned long *dims = new unsigned long[4 * workspacesList.size()];
for (unsigned int i = 0, m = workspacesList.size(); i < m; ++i) { for (unsigned int i = 0, m = workspacesList.size(); i < m; ++i) {
// XXX: this could be different for each workspace // 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) + 0] = area.x();
dims[(i * 4) + 1] = area.y(); dims[(i * 4) + 1] = area.y();
dims[(i * 4) + 2] = area.width(); dims[(i * 4) + 2] = area.width();
@ -1309,7 +1314,7 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
while (k--) while (k--)
*(session_stack + i++) = *(workspace_stack + k); *(session_stack + i++) = *(workspace_stack + k);
XRestackWindows(blackbox->getXDisplay(), session_stack, i); XRestackWindows(otk::OBDisplay::display, session_stack, i);
delete [] session_stack; delete [] session_stack;
@ -1323,7 +1328,7 @@ void BScreen::lowerWindows(Window *workspace_stack, unsigned int num) {
Window *session_stack = new Window[(num + desktopWindowList.size())]; Window *session_stack = new Window[(num + desktopWindowList.size())];
unsigned int i = 0, k = num; unsigned int i = 0, k = num;
XLowerWindow(blackbox->getXDisplay(), workspace_stack[0]); XLowerWindow(otk::OBDisplay::display, workspace_stack[0]);
while (k--) while (k--)
*(session_stack + i++) = *(workspace_stack + 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) for (; dit != d_end; ++dit)
*(session_stack + i++) = *dit; *(session_stack + i++) = *dit;
XRestackWindows(blackbox->getXDisplay(), session_stack, i); XRestackWindows(otk::OBDisplay::display, session_stack, i);
delete [] session_stack; delete [] session_stack;
@ -1438,8 +1443,8 @@ void BScreen::raiseFocus(void) const {
void BScreen::shutdown(void) { void BScreen::shutdown(void) {
XSelectInput(blackbox->getXDisplay(), getRootWindow(), NoEventMask); XSelectInput(otk::OBDisplay::display, getRootWindow(), NoEventMask);
XSync(blackbox->getXDisplay(), False); XSync(otk::OBDisplay::display, False);
while(! windowList.empty()) while(! windowList.empty())
unmanageWindow(windowList.front(), True); unmanageWindow(windowList.front(), True);
@ -1454,11 +1459,11 @@ void BScreen::shutdown(void) {
void BScreen::showPosition(int x, int y) { void BScreen::showPosition(int x, int y) {
if (! geom_visible) { if (! geom_visible) {
XMoveResizeWindow(blackbox->getXDisplay(), geom_window, XMoveResizeWindow(otk::OBDisplay::display, geom_window,
(getWidth() - geom_w) / 2, (getWidth() - geom_w) / 2,
(getHeight() - geom_h) / 2, geom_w, geom_h); (getHeight() - geom_h) / 2, geom_w, geom_h);
XMapWindow(blackbox->getXDisplay(), geom_window); XMapWindow(otk::OBDisplay::display, geom_window);
XRaiseWindow(blackbox->getXDisplay(), geom_window); XRaiseWindow(otk::OBDisplay::display, geom_window);
geom_visible = True; geom_visible = True;
} }
@ -1467,7 +1472,7 @@ void BScreen::showPosition(int x, int y) {
sprintf(label, "X: %4d x Y: %4d", x, 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.wstyle.font->drawString(geom_window,
resource.bevel_width, resource.bevel_width, 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) { void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
if (! geom_visible) { if (! geom_visible) {
XMoveResizeWindow(blackbox->getXDisplay(), geom_window, XMoveResizeWindow(otk::OBDisplay::display, geom_window,
(getWidth() - geom_w) / 2, (getWidth() - geom_w) / 2,
(getHeight() - geom_h) / 2, geom_w, geom_h); (getHeight() - geom_h) / 2, geom_w, geom_h);
XMapWindow(blackbox->getXDisplay(), geom_window); XMapWindow(otk::OBDisplay::display, geom_window);
XRaiseWindow(blackbox->getXDisplay(), geom_window); XRaiseWindow(otk::OBDisplay::display, geom_window);
geom_visible = True; 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); 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.wstyle.font->drawString(geom_window,
resource.bevel_width, resource.bevel_width, resource.bevel_width, resource.bevel_width,
@ -1502,7 +1507,7 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
void BScreen::hideGeometry(void) { void BScreen::hideGeometry(void) {
if (geom_visible) { if (geom_visible) {
XUnmapWindow(blackbox->getXDisplay(), geom_window); XUnmapWindow(otk::OBDisplay::display, geom_window);
geom_visible = False; 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()) if (doFullMax())
return getRect(); // return the full screen return getRect(); // return the full screen
return usableArea; return usableArea;
@ -1538,7 +1543,7 @@ const RectList& BScreen::allAvailableAreas(void) const {
void BScreen::updateAvailableArea(void) { void BScreen::updateAvailableArea(void) {
Rect old_area = usableArea; otk::Rect old_area = usableArea;
usableArea = getRect(); // reset to full screen usableArea = getRect(); // reset to full screen
#ifdef XINERAMA #ifdef XINERAMA
@ -1677,11 +1682,11 @@ void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask,
if (s[0] != '/' && s[0] != '~') if (s[0] != '/' && s[0] != '~')
{ {
std::string xbmFile = std::string("~/.openbox/buttons/") + s; 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, expandTilde(xbmFile).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy); &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
} else } else
ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(), ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(),
expandTilde(s).c_str(), &pixmapMask.w, expandTilde(s).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy); &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
@ -1693,25 +1698,25 @@ void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask,
pixmapMask.w = pixmapMask.h = 0; pixmapMask.w = pixmapMask.h = 0;
} }
BTexture BScreen::readDatabaseTexture(const string &rname, otk::BTexture BScreen::readDatabaseTexture(const string &rname,
const string &default_color, const string &default_color,
const Configuration &style, const Configuration &style,
bool allowNoTexture) { bool allowNoTexture) {
BTexture texture; otk::BTexture texture;
string s; string s;
if (style.getValue(rname, s)) if (style.getValue(rname, s))
texture = BTexture(s); texture = otk::BTexture(s);
else if (allowNoTexture) //no default else if (allowNoTexture) //no default
texture.setTexture(BTexture::NoTexture); texture.setTexture(otk::BTexture::NoTexture);
else else
texture.setTexture(BTexture::Solid | BTexture::Flat); texture.setTexture(otk::BTexture::Solid | otk::BTexture::Flat);
// associate this texture with this screen // associate this texture with this screen
texture.setDisplay(getBaseDisplay(), getScreenNumber()); texture.setScreen(getScreenNumber());
texture.setImageControl(image_control); texture.setImageControl(image_control);
if (texture.texture() != BTexture::NoTexture) { if (texture.texture() != otk::BTexture::NoTexture) {
texture.setColor(readDatabaseColor(rname + ".color", default_color, texture.setColor(readDatabaseColor(rname + ".color", default_color,
style)); style));
texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color, texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color,
@ -1724,21 +1729,21 @@ BTexture BScreen::readDatabaseTexture(const string &rname,
} }
BColor BScreen::readDatabaseColor(const string &rname, otk::BColor BScreen::readDatabaseColor(const string &rname,
const string &default_color, const string &default_color,
const Configuration &style) { const Configuration &style) {
BColor color; otk::BColor color;
string s; string s;
if (style.getValue(rname, s)) if (style.getValue(rname, s))
color = BColor(s, getBaseDisplay(), getScreenNumber()); color = otk::BColor(s, getScreenNumber());
else else
color = BColor(default_color, getBaseDisplay(), getScreenNumber()); color = otk::BColor(default_color, getScreenNumber());
return color; return color;
} }
BFont *BScreen::readDatabaseFont(const string &rbasename, otk::BFont *BScreen::readDatabaseFont(const string &rbasename,
const Configuration &style) { const Configuration &style) {
string fontname; string fontname;
string s; string s;
@ -1773,9 +1778,9 @@ BFont *BScreen::readDatabaseFont(const string &rbasename,
} }
BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, otk::BFont *b = new otk::BFont(getScreenNumber(), family, i, bold, italic,
italic, dropShadow && resource.shadow_fonts, offset, dropShadow && resource.shadow_fonts,
tint, resource.aa_fonts); offset, tint, resource.aa_fonts);
if (b->valid()) if (b->valid())
return b; return b;
delete b; delete b;
@ -1783,3 +1788,5 @@ BFont *BScreen::readDatabaseFont(const string &rbasename,
exit(2); // can't continue without a font exit(2); // can't continue without a font
} }
}

View file

@ -20,15 +20,16 @@ extern "C" {
#include <list> #include <list>
#include <vector> #include <vector>
#include "color.hh" #include "otk/color.hh"
#include "texture.hh" #include "otk/font.hh"
#include "image.hh" #include "otk/texture.hh"
#include "otk/image.hh"
#include "timer.hh" #include "timer.hh"
#include "workspace.hh" #include "workspace.hh"
#include "blackbox.hh" #include "blackbox.hh"
class Slit; // forward reference namespace ob {
class BFont;
class XAtom; class XAtom;
struct Strut; struct Strut;
@ -40,14 +41,14 @@ struct PixmapMask {
}; };
struct WindowStyle { 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; 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, h_focus, h_unfocus, b_focus, b_unfocus, b_pressed, b_pressed_focus,
b_pressed_unfocus, g_focus, g_unfocus; b_pressed_unfocus, g_focus, g_unfocus;
PixmapMask close_button, max_button, icon_button, stick_button; PixmapMask close_button, max_button, icon_button, stick_button;
BFont *font; otk::BFont *font;
TextJustify justify; TextJustify justify;
@ -55,7 +56,7 @@ struct WindowStyle {
unsigned int max_length, unsigned int modifier) const; unsigned int max_length, unsigned int modifier) const;
}; };
class BScreen : public ScreenInfo { class BScreen : public otk::ScreenInfo {
private: private:
bool root_colormap_installed, managed, geom_visible; bool root_colormap_installed, managed, geom_visible;
GC opGC; GC opGC;
@ -63,7 +64,7 @@ private:
Window geom_window; Window geom_window;
Blackbox *blackbox; Blackbox *blackbox;
BImageControl *image_control; otk::BImageControl *image_control;
Configuration *config; Configuration *config;
XAtom *xatom; XAtom *xatom;
@ -77,7 +78,7 @@ private:
unsigned int geom_w, geom_h; unsigned int geom_w, geom_h;
unsigned long event_mask; unsigned long event_mask;
Rect usableArea; otk::Rect usableArea;
#ifdef XINERAMA #ifdef XINERAMA
RectList xineramaUsableArea; RectList xineramaUsableArea;
#endif // XINERAMA #endif // XINERAMA
@ -98,7 +99,7 @@ private:
int snap_to_windows, snap_to_edges; int snap_to_windows, snap_to_edges;
unsigned int snap_offset; unsigned int snap_offset;
BColor border_color; otk::BColor border_color;
unsigned int workspaces; unsigned int workspaces;
int placement_policy, int placement_policy,
@ -120,15 +121,15 @@ private:
PixmapMask &pixmapMask, PixmapMask &pixmapMask,
const Configuration &style); const Configuration &style);
BTexture readDatabaseTexture(const std::string &rname, otk::BTexture readDatabaseTexture(const std::string &rname,
const std::string &default_color, const std::string &default_color,
const Configuration &style, const Configuration &style,
bool allowNoTexture = false); bool allowNoTexture = false);
BColor readDatabaseColor(const std::string &rname, otk::BColor readDatabaseColor(const std::string &rname,
const std::string &default_color, const std::string &default_color,
const Configuration &style); const Configuration &style);
BFont *readDatabaseFont(const std::string &rbasename, otk::BFont *readDatabaseFont(const std::string &rbasename,
const Configuration &style); const Configuration &style);
void LoadStyle(void); void LoadStyle(void);
@ -182,8 +183,8 @@ public:
inline const GC &getOpGC(void) const { return opGC; } inline const GC &getOpGC(void) const { return opGC; }
inline Blackbox *getBlackbox(void) { return blackbox; } inline Blackbox *getBlackbox(void) { return blackbox; }
inline BColor *getBorderColor(void) { return &resource.border_color; } inline otk::BColor *getBorderColor(void) { return &resource.border_color; }
inline BImageControl *getImageControl(void) { return image_control; } inline otk::BImageControl *getImageControl(void) { return image_control; }
Workspace *getWorkspace(unsigned int index) const; Workspace *getWorkspace(unsigned int index) const;
@ -264,7 +265,7 @@ public:
// allAvailableAreas should be used whenever possible instead of this function // allAvailableAreas should be used whenever possible instead of this function
// as then Xinerama will work correctly. // as then Xinerama will work correctly.
const Rect& availableArea(void) const; const otk::Rect& availableArea(void) const;
#ifdef XINERAMA #ifdef XINERAMA
const RectList& allAvailableAreas(void) const; const RectList& allAvailableAreas(void) const;
#endif // XINERAMA #endif // XINERAMA
@ -308,5 +309,6 @@ public:
void propertyNotifyEvent(const XPropertyEvent *pe); void propertyNotifyEvent(const XPropertyEvent *pe);
}; };
}
#endif // __Screen_hh #endif // __Screen_hh

View file

@ -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<unsigned long>(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
}

View file

@ -1,52 +0,0 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
#ifndef __screeninfo_hh
#define __screeninfo_hh
#include "util.hh"
extern "C" {
#include <X11/Xlib.h>
}
#include <string>
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

View file

@ -4,10 +4,11 @@
# include "../config.h" # include "../config.h"
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
#include "basedisplay.hh"
#include "timer.hh" #include "timer.hh"
#include "util.hh" #include "util.hh"
namespace ob {
BTimer::BTimer(TimerQueueManager *m, TimeoutHandler *h) { BTimer::BTimer(TimerQueueManager *m, TimeoutHandler *h) {
manager = m; manager = m;
handler = h; handler = h;
@ -88,3 +89,5 @@ bool BTimer::shouldFire(const timeval &tm) const {
return ! ((tm.tv_sec < end.tv_sec) || return ! ((tm.tv_sec < end.tv_sec) ||
(tm.tv_sec == end.tv_sec && tm.tv_usec < end.tv_usec)); (tm.tv_sec == end.tv_sec && tm.tv_usec < end.tv_usec));
} }
}

View file

@ -15,6 +15,12 @@ extern "C" {
#endif // TIME_WITH_SYS_TIME #endif // TIME_WITH_SYS_TIME
} }
#include <queue>
#include <algorithm>
#include <vector>
namespace ob {
// forward declaration // forward declaration
class TimerQueueManager; class TimerQueueManager;
@ -64,9 +70,6 @@ public:
}; };
#include <queue>
#include <algorithm>
template <class _Tp, class _Sequence, class _Compare> template <class _Tp, class _Sequence, class _Compare>
class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> { class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> {
public: public:
@ -97,7 +100,6 @@ struct TimerLessThan {
} }
}; };
#include <vector>
typedef _timer_queue<BTimer*, std::vector<BTimer*>, TimerLessThan> TimerQueue; typedef _timer_queue<BTimer*, std::vector<BTimer*>, TimerLessThan> TimerQueue;
class TimerQueueManager { class TimerQueueManager {
@ -106,4 +108,6 @@ public:
virtual void removeTimer(BTimer* timer) = 0; virtual void removeTimer(BTimer* timer) = 0;
}; };
}
#endif // _BLACKBOX_Timer_hh #endif // _BLACKBOX_Timer_hh

View file

@ -10,22 +10,15 @@ extern "C" {
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
#include <string.h> #include <string.h>
#endif #endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else // !TIME_WITH_SYS_TIME
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else // !HAVE_SYS_TIME_H
# include <time.h>
# endif // HAVE_SYS_TIME_H
#endif // TIME_WITH_SYS_TIME
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif // HAVE_UNISTD_H #endif // HAVE_UNISTD_H
#if defined(HAVE_PROCESS_H) && defined(__EMX__) #if defined(HAVE_PROCESS_H) && defined(__EMX__)
# include <process.h> # include <process.h>
#endif // HAVE_PROCESS_H __EMX__ #endif // HAVE_PROCESS_H __EMX__
@ -39,98 +32,7 @@ extern "C" {
using std::string; using std::string;
namespace ob {
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;
}
string expandTilde(const string& s) { string expandTilde(const string& s) {
if (s[0] != '~') return 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 textPropertyToString(Display *display, XTextProperty& text_prop) {
string ret; string ret;
@ -231,3 +123,15 @@ string itostring(long i) {
tmp.insert(tmp.begin(), '-'); tmp.insert(tmp.begin(), '-');
return tmp; 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

View file

@ -2,62 +2,27 @@
#ifndef _BLACKBOX_UTIL_HH #ifndef _BLACKBOX_UTIL_HH
#define _BLACKBOX_UTIL_HH #define _BLACKBOX_UTIL_HH
extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else // !TIME_WITH_SYS_TIME
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else // !HAVE_SYS_TIME_H
# include <time.h>
# endif // HAVE_SYS_TIME_H
#endif // TIME_WITH_SYS_TIME
}
#include <string> #include <string>
#include <vector> #include <vector>
class Rect { namespace ob {
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<Rect> RectList;
struct Strut { struct Strut {
unsigned int top, bottom, left, right; 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); 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); std::string textPropertyToString(Display *display, XTextProperty& text_prop);
struct timeval; // forward declare to avoid the header
timeval normalizeTimeval(const timeval &tm); timeval normalizeTimeval(const timeval &tm);
struct PointerAssassin {
template<typename T>
inline void operator()(const T ptr) const {
delete ptr;
}
};
std::string itostring(unsigned long i); std::string itostring(unsigned long i);
std::string itostring(long i); std::string itostring(long i);
inline std::string itostring(unsigned int i) inline std::string itostring(unsigned int i)
{ return itostring((unsigned long) i); } { return itostring((unsigned long) i); }
inline std::string itostring(int i) inline std::string itostring(int i)
{ return itostring((long) i); } { return itostring((long) i); }
}
#ifndef HAVE_BASENAME
std::string basename(const std::string& path);
#endif
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ extern "C" {
#include <string> #include <string>
#include "basedisplay.hh" #include "blackbox.hh"
#include "timer.hh" #include "timer.hh"
#include "util.hh" #include "util.hh"
@ -34,6 +34,8 @@ extern "C" {
#define MwmDecorIconify (1l << 5) #define MwmDecorIconify (1l << 5)
#define MwmDecorMaximize (1l << 6) #define MwmDecorMaximize (1l << 6)
namespace ob {
// this structure only contains 3 elements... the Motif 2.0 structure contains // 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 // 5... we only need the first 3... so that is all we will define
typedef struct MwmHints { typedef struct MwmHints {
@ -144,7 +146,7 @@ private:
std::string title, icon_title; std::string title, icon_title;
Rect rect; otk::Rect rect;
Strut strut; Strut strut;
int old_bw; // client's borderwidth int old_bw; // client's borderwidth
@ -213,9 +215,9 @@ private:
* size and location of the box drawn while the window dimensions or * size and location of the box drawn while the window dimensions or
* location is being changed, ie. resized or moved * 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 Strut margin; // margins between the frame and client
int grab_x, grab_y; // where was the window when it was grabbed? int grab_x, grab_y; // where was the window when it was grabbed?
@ -275,8 +277,8 @@ private:
void redrawIconifyButton(bool pressed) const; void redrawIconifyButton(bool pressed) const;
void redrawMaximizeButton(bool pressed) const; void redrawMaximizeButton(bool pressed) const;
void redrawStickyButton(bool pressed) const; void redrawStickyButton(bool pressed) const;
void applyGravity(Rect &r); void applyGravity(otk::Rect &r);
void restoreGravity(Rect &r); void restoreGravity(otk::Rect &r);
void setAllowedActions(void); void setAllowedActions(void);
void setState(unsigned long new_state); void setState(unsigned long new_state);
void upsize(void); void upsize(void);
@ -338,8 +340,8 @@ public:
{ return blackbox_attrib.workspace; } { return blackbox_attrib.workspace; }
inline unsigned int getWindowNumber(void) const { return window_number; } inline unsigned int getWindowNumber(void) const { return window_number; }
inline const Rect &frameRect(void) const { return frame.rect; } inline const otk::Rect &frameRect(void) const { return frame.rect; }
inline const Rect &clientRect(void) const { return client.rect; } inline const otk::Rect &clientRect(void) const { return client.rect; }
inline unsigned int getTitleHeight(void) const inline unsigned int getTitleHeight(void) const
{ return frame.title_h; } { return frame.title_h; }
@ -406,5 +408,6 @@ public:
virtual void timeout(void); virtual void timeout(void);
}; };
}
#endif // __Window_hh #endif // __Window_hh

View file

@ -25,13 +25,15 @@ extern "C" {
using std::string; using std::string;
#include "blackbox.hh" #include "blackbox.hh"
#include "font.hh" #include "otk/font.hh"
#include "otk/display.hh"
#include "screen.hh" #include "screen.hh"
#include "util.hh" #include "util.hh"
#include "window.hh" #include "window.hh"
#include "workspace.hh" #include "workspace.hh"
#include "xatom.hh" #include "xatom.hh"
namespace ob {
Workspace::Workspace(BScreen *scrn, unsigned int i) { Workspace::Workspace(BScreen *scrn, unsigned int i) {
screen = scrn; screen = scrn;
@ -99,7 +101,7 @@ void Workspace::removeWindow(BlackboxWindow *w, bool sticky) {
// pass focus to the next appropriate window // pass focus to the next appropriate window
if ((w->isFocused() || w == lastfocus) && if ((w->isFocused() || w == lastfocus) &&
! screen->getBlackbox()->doShutdown()) { screen->getBlackbox()->state() != Openbox::State_Exiting) {
focusFallback(w); focusFallback(w);
} }
@ -188,7 +190,8 @@ void Workspace::showAll(void) {
// sticky windows arent unmapped on a workspace change so we don't have ot // 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 // map them, but sometimes on a restart, another app can unmap our sticky
// windows, so we map on startup always // windows, so we map on startup always
if (! bw->isStuck() || screen->getBlackbox()->isStartup()) if (! bw->isStuck() ||
screen->getBlackbox()->state() == Openbox::State_Starting)
bw->show(); bw->show();
} }
} }
@ -465,13 +468,13 @@ void Workspace::setName(const string& new_name) {
/* /*
* Calculate free space available for window placement. * 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 { const rectList &spaces) const {
Rect isect, extra; otk::Rect isect, extra;
rectList result; rectList result;
rectList::const_iterator siter, end = spaces.end(); rectList::const_iterator siter, end = spaces.end();
for (siter = spaces.begin(); siter != end; ++siter) { for (siter = spaces.begin(); siter != end; ++siter) {
const Rect &curr = *siter; const otk::Rect &curr = *siter;
if(! win.intersects(curr)) { if(! win.intersects(curr)) {
result.push_back(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()) if (first.bottom() == second.bottom())
return first.right() > second.right(); return first.right() > second.right();
return first.bottom() > second.bottom(); 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()) if (first.y() == second.y())
return first.right() > second.right(); return first.right() > second.right();
return first.y() < second.y(); 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()) if (first.bottom() == second.bottom())
return first.x() < second.x(); return first.x() < second.x();
return first.bottom() > second.bottom(); 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()) if (first.y() == second.y())
return first.x() < second.x(); return first.x() < second.x();
return first.y() < second.y(); 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()) if (first.x() == second.x())
return first.y() < second.y(); return first.y() < second.y();
return first.x() < second.x(); 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()) if (first.x() == second.x())
return first.bottom() > second.bottom(); return first.bottom() > second.bottom();
return first.x() < second.x(); 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()) if (first.right() == second.right())
return first.y() < second.y(); return first.y() < second.y();
return first.right() > second.right(); 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()) if (first.right() == second.right())
return first.bottom() > second.bottom(); return first.bottom() > second.bottom();
return first.right() > second.right(); return first.right() > second.right();
} }
bool Workspace::smartPlacement(Rect& win) { bool Workspace::smartPlacement(otk::Rect& win) {
rectList spaces; rectList spaces;
//initially the entire screen is free //initially the entire screen is free
@ -579,7 +582,7 @@ bool Workspace::smartPlacement(Rect& win) {
} else } else
#endif // XINERAMA #endif // XINERAMA
{ {
Rect r = screen->availableArea(); otk::Rect r = screen->availableArea();
r.setRect(r.x() + screen->getSnapOffset(), r.setRect(r.x() + screen->getSnapOffset(),
r.y() + screen->getSnapOffset(), r.y() + screen->getSnapOffset(),
r.width() - screen->getSnapOffset(), r.width() - screen->getSnapOffset(),
@ -590,7 +593,7 @@ bool Workspace::smartPlacement(Rect& win) {
//Find Free Spaces //Find Free Spaces
BlackboxWindowList::const_iterator wit = windowList.begin(), BlackboxWindowList::const_iterator wit = windowList.begin(),
end = windowList.end(); end = windowList.end();
Rect tmp; otk::Rect tmp;
for (; wit != end; ++wit) { for (; wit != end; ++wit) {
const BlackboxWindow* const curr = *wit; const BlackboxWindow* const curr = *wit;
@ -644,7 +647,7 @@ bool Workspace::smartPlacement(Rect& win) {
return False; return False;
//set new position based on the empty space found //set new position based on the empty space found
const Rect& where = *sit; const otk::Rect& where = *sit;
win.setX(where.x()); win.setX(where.x());
win.setY(where.y()); 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; int x, y, rx, ry;
Window c, r; Window c, r;
unsigned int m; unsigned int m;
XQueryPointer(screen->getBlackbox()->getXDisplay(), screen->getRootWindow(), XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(),
&r, &c, &rx, &ry, &x, &y, &m); &r, &c, &rx, &ry, &x, &y, &m);
Rect area; otk::Rect area;
#ifdef XINERAMA #ifdef XINERAMA
if (screen->isXineramaActive() && if (screen->isXineramaActive() &&
screen->getBlackbox()->doXineramaPlacement()) { screen->getBlackbox()->doXineramaPlacement()) {
@ -705,8 +708,8 @@ bool Workspace::underMousePlacement(Rect &win) {
} }
bool Workspace::cascadePlacement(Rect &win, const int offset) { bool Workspace::cascadePlacement(otk::Rect &win, const int offset) {
Rect area; otk::Rect area;
#ifdef XINERAMA #ifdef XINERAMA
if (screen->isXineramaActive() && if (screen->isXineramaActive() &&
@ -745,7 +748,7 @@ bool Workspace::cascadePlacement(Rect &win, const int offset) {
void Workspace::placeWindow(BlackboxWindow *win) { 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; bool placed = False;
switch (screen->getPlacementPolicy()) { 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()); win->configure(new_win.x(), new_win.y(), new_win.width(), new_win.height());
} }
}

View file

@ -12,6 +12,8 @@ extern "C" {
#include "xatom.hh" #include "xatom.hh"
namespace ob {
class BScreen; class BScreen;
class Workspace; class Workspace;
class BlackboxWindow; class BlackboxWindow;
@ -42,13 +44,13 @@ private:
void lowerTransients(const BlackboxWindow * const win, void lowerTransients(const BlackboxWindow * const win,
StackVector::iterator &stack); StackVector::iterator &stack);
typedef std::vector<Rect> rectList; typedef std::vector<otk::Rect> rectList;
rectList calcSpace(const Rect &win, const rectList &spaces) const; rectList calcSpace(const otk::Rect &win, const rectList &spaces) const;
void placeWindow(BlackboxWindow *win); void placeWindow(BlackboxWindow *win);
bool cascadePlacement(Rect& win, const int offset); bool cascadePlacement(otk::Rect& win, const int offset);
bool smartPlacement(Rect& win); bool smartPlacement(otk::Rect& win);
bool underMousePlacement(Rect& win); bool underMousePlacement(otk::Rect& win);
public: public:
Workspace(BScreen *scrn, unsigned int i = 0); Workspace(BScreen *scrn, unsigned int i = 0);
@ -91,6 +93,7 @@ public:
void setName(const std::string& new_name); void setName(const std::string& new_name);
}; };
}
#endif // __Workspace_hh #endif // __Workspace_hh

View file

@ -12,6 +12,8 @@ extern "C" {
#include "screen.hh" #include "screen.hh"
#include "util.hh" #include "util.hh"
namespace ob {
XAtom::XAtom(Display *d) { XAtom::XAtom(Display *d) {
_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. * 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(); Window root = screen->getRootWindow();
// create the netwm support window // create the netwm support window
@ -509,3 +511,5 @@ void XAtom::sendClientMessage(Window target, Atoms type, Window about,
SubstructureRedirectMask | SubstructureNotifyMask, SubstructureRedirectMask | SubstructureNotifyMask,
&e); &e);
} }
}

View file

@ -2,16 +2,19 @@
#ifndef __XAtom_h #ifndef __XAtom_h
#define __XAtom_h #define __XAtom_h
extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <assert.h> #include <assert.h>
}
#include <vector> #include <vector>
#include <string> #include <string>
class Blackbox; #include "otk/screeninfo.hh"
class ScreenInfo;
namespace ob {
class XAtom { class XAtom {
public: public:
@ -170,7 +173,7 @@ public:
// setup support on a screen, each screen should call this once in its // setup support on a screen, each screen should call this once in its
// constructor. // 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, unsigned long value) const;
void setValue(Window win, Atoms atom, Atoms type, void setValue(Window win, Atoms atom, Atoms type,
@ -207,4 +210,6 @@ public:
assert(ret != 0); return ret; } assert(ret != 0); return ret; }
}; };
}
#endif // __XAtom_h #endif // __XAtom_h