noinst_LIBRARIES=libotk.a
libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
- imagecontrol.cc rect.cc texture.cc
+ imagecontrol.cc rect.cc screeninfo.cc texture.cc
MAINTAINERCLEANFILES= Makefile.in
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)
// find the availability of X extensions we like to use
#ifdef SHAPE
_shape = XShapeQueryExtension(display, &_shape_event_basep, &junk);
-#else
- _shape = false;
#endif
#ifdef XINERAMA
_xinerama = XineramaQueryExtension(display, &_xinerama_event_basep, &junk);
-#else
- _xinerama = false;
#endif // XINERAMA
// get lock masks that are defined by the display (not constant)
}
+
+
+
+
+
+
+
+
+
+/*
+ * 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);
+}
+
+
}
inline static int shapeEventBase() { return _shape_event_basep; }
//! Returns if the display has the xinerama extention available
inline static bool xinerama() { return _xinerama; }
+
+
+
+
+
+ /* TEMPORARY */
+ static void grabButton(unsigned int button, unsigned int modifiers,
+ Window grab_window, bool owner_events,
+ unsigned int event_mask, int pointer_mode,
+ int keyboard_mode, Window confine_to, Cursor cursor,
+ bool allow_scroll_lock);
+ static void ungrabButton(unsigned int button, unsigned int modifiers,
+ Window grab_window);
};
}
# include "../config.h"
#endif // HAVE_CONFIG_H
+extern "C" {
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+}
+
#include "screeninfo.hh"
#include "display.hh"
+#include "src/util.hh"
using std::string;
ScreenInfo::ScreenInfo(unsigned int num) {
screen_number = num;
- root_window = RootWindow(ob::OBDisplay::display, screen_number);
+ root_window = RootWindow(OBDisplay::display, screen_number);
rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display,
screen_number)),
default_string.resize(pos);
display_string = string("DISPLAY=") + default_string + '.' +
- itostring(static_cast<unsigned long>(screen_number));
+ ob::itostring(static_cast<unsigned long>(screen_number));
#ifdef XINERAMA
xinerama_active = False;
# List of source files containing translatable strings.
-src/main.cc
\ No newline at end of file
+src/openbox.cc
+src/display.cc
\ No newline at end of file
openbox_LDADD=../otk/libotk.a @LIBINTL@
-openbox_SOURCES= basedisplay.cc configuration.cc screen.cc screeninfo.cc \
+openbox_SOURCES= configuration.cc screen.cc openbox.cc \
timer.cc util.cc window.cc workspace.cc xatom.cc blackbox.cc \
main.cc
#include <vector>
// forward declaration
-class BaseDisplay;
class BGCCache;
class BaseDisplay: public TimerQueueManager {
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
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()) {
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;
Blackbox::~Blackbox(void) {
- std::for_each(screenList.begin(), screenList.end(), PointerAssassin());
+ std::for_each(screenList.begin(), screenList.end(), otk::PointerAssassin());
delete xatom;
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;
case ButtonRelease: {
// strip the lock key modifiers
- e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
+ //e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
last_time = e->xbutton.time;
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);
}
}
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?
// 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++;
}
break;
// strip the lock key modifiers
- e->xmotion.state &= ~(NumLockMask | ScrollLockMask | LockMask);
+ //e->xmotion.state &= ~(NumLockMask | ScrollLockMask | LockMask);
last_time = e->xmotion.time;
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++;
(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) {
BlackboxWindow *focus;
Window w;
int revert;
- XGetInputFocus(getXDisplay(), &w, &revert);
+ XGetInputFocus(otk::OBDisplay::display, &w, &revert);
focus = searchWindow(w);
if (focus) {
/*
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;
}
// 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);
}
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;
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;
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));
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);
}
}
old_screen->updateNetizenWindowFocus();
}
}
+
+
+void Blackbox::addTimer(BTimer *timer) {
+ (void)timer;
+}
+
+
+void Blackbox::removeTimer(BTimer *timer) {
+ (void)timer;
+}
+
+
+}
#include <map>
#include <string>
-#include "basedisplay.hh"
+#include "openbox.hh"
#include "configuration.hh"
#include "timer.hh"
#include "xatom.hh"
#define DecorTiny (2)
#define DecorTool (3)
+namespace ob {
+
struct BlackboxHints {
unsigned long flags, attrib, workspace, stack, decoration;
};
class BlackboxWindow;
class BWindowGroup;
-class Blackbox : public BaseDisplay, public TimeoutHandler {
+class Blackbox : public Openbox, public TimeoutHandler, public TimerQueueManager {
private:
struct BCursor {
Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
std::string style_file;
int colors_per_channel;
- timeval auto_raise_delay;
+ ::timeval auto_raise_delay;
unsigned long cache_life, cache_max;
std::string titlebar_layout;
unsigned int mod_mask; // modifier mask used for window-mouse interaction
public:
- Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0);
+ Blackbox(int argc, char **m_argv, char *rc = 0);
virtual ~Blackbox(void);
BWindowGroup *searchGroup(Window window);
inline std::string getTitlebarLayout(void) const
{ return resource.titlebar_layout; }
- inline const timeval &getAutoRaiseDelay(void) const
+ inline const ::timeval &getAutoRaiseDelay(void) const
{ return resource.auto_raise_delay; }
inline unsigned long getCacheLife(void) const
virtual void timeout(void);
enum { B_AmericanDate = 1, B_EuropeanDate };
+
+ virtual void addTimer(BTimer *timer);
+ virtual void removeTimer(BTimer *timer);
};
+}
#endif // __blackbox_hh
using std::string;
+namespace ob {
+
bool Configuration::_initialized = False;
Configuration::Configuration(const string &file, bool autosave) {
return c - 'a' + 'A';
return c;
}
+
+}
#include <X11/Xresource.h>
#include <string>
+namespace ob {
+
/*
* The Configuration class is a generic wrapper for configuration settings.
*
XrmDatabase _database;
};
+}
+
#endif // __Configuration_hh
// -*- mode: C++; indent-tabs-mode: nil; -*-
-#include "../version.h"
-
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif // HAVE_CONFIG_H
extern "C" {
-#ifdef HAVE_STDIO_H
-# include <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"
-#define _(str) gettext(str)
+}
#include <string>
using std::string;
#include "blackbox.hh"
-
-
-static void showHelp(int exitval) {
- // print program usage and command line options
- printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"),
- OPENBOX_VERSION);
- printf(_(" -display <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);
-}
+#include "openbox.hh"
int main(int argc, char **argv) {
- char *session_display = (char *) 0;
- char *rc_file = (char *) 0;
- char *menu_file = (char *) 0;
-
// initialize the locale
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
-
- for (int i = 1; i < argc; ++i) {
- if (! strcmp(argv[i], "-rc")) {
- // look for alternative rc file to use
-
- if ((++i) >= argc) {
- fprintf(stderr, _("error: '-rc' requires and argument\n"));
-
- ::exit(1);
- }
-
- rc_file = argv[i];
- } else if (! strcmp(argv[i], "-menu")) {
- // look for alternative menu file to use
-
- if ((++i) >= argc) {
- fprintf(stderr, _("error: '-menu' requires and argument\n"));
-
- ::exit(1);
- }
- menu_file = argv[i];
- } else if (! strcmp(argv[i], "-display")) {
- // check for -display option... to run on a display other than the one
- // set by the environment variable DISPLAY
-
- if ((++i) >= argc) {
- fprintf(stderr, _("error: '-display' requires an argument\n"));
-
- ::exit(1);
- }
-
- session_display = argv[i];
- string dtmp = "DISPLAY=";
- dtmp += session_display;
-
- if (putenv(const_cast<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);
+ //ob::Openbox openbox(argc, argv);
+ ob::Blackbox blackbox(argc, argv, 0);
+
+ //Blackbox blackbox(argv, session_display, rc_file);
blackbox.eventLoop();
return(0);
--- /dev/null
+// -*- 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();
+ }*/
+ }
+ }
+}
+
+
+}
+
--- /dev/null
+// -*- 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
#include <string>
using std::string;
-#include "blackbox.hh"
-#include "font.hh"
-#include "gccache.hh"
-#include "image.hh"
#include "screen.hh"
+#include "otk/font.hh"
+#include "otk/gccache.hh"
+#include "otk/image.hh"
+#include "otk/assassin.hh"
+#include "openbox.hh"
#include "util.hh"
#include "window.hh"
#include "workspace.hh"
#define FONT_ELEMENT_SIZE 50
#endif // FONT_ELEMENT_SIZE
+namespace ob {
static bool running = True;
}
-BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
+BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
blackbox = bb;
screenstr = "session.screen" + itostring(scrn) + '.';
config = blackbox->getConfig();
SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask;
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
- XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask);
- XSync(getBaseDisplay()->getXDisplay(), False);
+ XSelectInput(otk::OBDisplay::display, getRootWindow(), event_mask);
+ XSync(otk::OBDisplay::display, False);
XSetErrorHandler((XErrorHandler) old);
managed = running;
getScreenNumber(), XVisualIDFromVisual(getVisual()),
getDepth());
- resource.wstyle.font = (BFont *) 0;
+ resource.wstyle.font = (otk::BFont *) 0;
geom_pixmap = None;
XAtom::cardinal, viewport, 2);
- XDefineCursor(blackbox->getXDisplay(), getRootWindow(),
+ XDefineCursor(otk::OBDisplay::display, getRootWindow(),
blackbox->getSessionCursor());
updateAvailableArea();
image_control =
- new BImageControl(blackbox, this, True, blackbox->getColorsPerChannel(),
- blackbox->getCacheLife(), blackbox->getCacheMax());
+ new otk::BImageControl(this, True, blackbox->getColorsPerChannel(),
+ blackbox->getCacheLife(), blackbox->getCacheMax());
image_control->installRootColormap();
root_colormap_installed = True;
LoadStyle();
XGCValues gcv;
- gcv.foreground = WhitePixel(blackbox->getXDisplay(), getScreenNumber())
- ^ BlackPixel(blackbox->getXDisplay(), getScreenNumber());
+ gcv.foreground = WhitePixel(otk::OBDisplay::display, getScreenNumber())
+ ^ BlackPixel(otk::OBDisplay::display, getScreenNumber());
gcv.function = GXxor;
gcv.subwindow_mode = IncludeInferiors;
- opGC = XCreateGC(blackbox->getXDisplay(), getRootWindow(),
+ opGC = XCreateGC(otk::OBDisplay::display, getRootWindow(),
GCForeground | GCFunction | GCSubwindowMode, &gcv);
const char *s = "0: 0000 x 0: 0000";
attrib.colormap = getColormap();
attrib.save_under = True;
- geom_window = XCreateWindow(blackbox->getXDisplay(), getRootWindow(),
+ geom_window = XCreateWindow(otk::OBDisplay::display, getRootWindow(),
0, 0, geom_w, geom_h, resource.border_width,
getDepth(), InputOutput, getVisual(),
mask, &attrib);
geom_visible = False;
- BTexture* texture = &(resource.wstyle.l_focus);
+ otk::BTexture* texture = &(resource.wstyle.l_focus);
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
if (geom_pixmap == ParentRelative) {
texture = &(resource.wstyle.t_focus);
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
}
if (! geom_pixmap)
- XSetWindowBackground(blackbox->getXDisplay(), geom_window,
+ XSetWindowBackground(otk::OBDisplay::display, geom_window,
texture->color().pixel());
else
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
geom_window, geom_pixmap);
if (resource.workspaces > 0) {
unsigned int i, j, nchild;
Window r, p, *children;
- XQueryTree(blackbox->getXDisplay(), getRootWindow(), &r, &p,
+ XQueryTree(otk::OBDisplay::display, getRootWindow(), &r, &p,
&children, &nchild);
// preen the window list of all icon windows... for better dockapp support
for (i = 0; i < nchild; i++) {
if (children[i] == None) continue;
- XWMHints *wmhints = XGetWMHints(blackbox->getXDisplay(),
+ XWMHints *wmhints = XGetWMHints(otk::OBDisplay::display,
children[i]);
if (wmhints) {
continue;
XWindowAttributes attrib;
- if (XGetWindowAttributes(blackbox->getXDisplay(), children[i], &attrib)) {
+ if (XGetWindowAttributes(otk::OBDisplay::display, children[i], &attrib)) {
if (attrib.override_redirect) continue;
if (attrib.map_state != IsUnmapped) {
image_control->removeImage(geom_pixmap);
if (geom_window != None)
- XDestroyWindow(blackbox->getXDisplay(), geom_window);
+ XDestroyWindow(otk::OBDisplay::display, geom_window);
std::for_each(workspacesList.begin(), workspacesList.end(),
- PointerAssassin());
+ otk::PointerAssassin());
- std::for_each(iconList.begin(), iconList.end(), PointerAssassin());
+ std::for_each(iconList.begin(), iconList.end(), otk::PointerAssassin());
while (! systrayWindowList.empty())
removeSystrayWindow(systrayWindowList[0]);
delete resource.wstyle.font;
if (resource.wstyle.close_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask);
if (resource.wstyle.max_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask);
if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask);
if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask);
resource.wstyle.max_button.mask = resource.wstyle.close_button.mask =
resource.wstyle.icon_button.mask =
resource.wstyle.stick_button.mask = None;
- XFreeGC(blackbox->getXDisplay(), opGC);
+ XFreeGC(otk::OBDisplay::display, opGC);
}
void BScreen::reconfigure(void) {
// don't reconfigure while saving the initial rc file, it's a waste and it
// breaks somethings (workspace names)
- if (blackbox->isStartup()) return;
+ if (blackbox->state() == Openbox::State_Starting) return;
load_rc();
LoadStyle();
changeWorkspaceCount(resource.workspaces);
XGCValues gcv;
- gcv.foreground = WhitePixel(blackbox->getXDisplay(),
+ gcv.foreground = WhitePixel(otk::OBDisplay::display,
getScreenNumber());
gcv.function = GXinvert;
gcv.subwindow_mode = IncludeInferiors;
- XChangeGC(blackbox->getXDisplay(), opGC,
+ XChangeGC(otk::OBDisplay::display, opGC,
GCForeground | GCFunction | GCSubwindowMode, &gcv);
const char *s = "0: 0000 x 0: 0000";
geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
- BTexture* texture = &(resource.wstyle.l_focus);
+ otk::BTexture* texture = &(resource.wstyle.l_focus);
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
if (geom_pixmap == ParentRelative) {
texture = &(resource.wstyle.t_focus);
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
}
if (! geom_pixmap)
- XSetWindowBackground(blackbox->getXDisplay(), geom_window,
+ XSetWindowBackground(otk::OBDisplay::display, geom_window,
texture->color().pixel());
else
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
geom_window, geom_pixmap);
- XSetWindowBorderWidth(blackbox->getXDisplay(), geom_window,
+ XSetWindowBorderWidth(otk::OBDisplay::display, geom_window,
resource.border_width);
- XSetWindowBorder(blackbox->getXDisplay(), geom_window,
+ XSetWindowBorder(otk::OBDisplay::display, geom_window,
resource.border_color.pixel());
typedef std::vector<int> SubList;
readDatabaseTexture("window.button.pressed.unfocus", "black", style, true);
if (resource.wstyle.close_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask);
if (resource.wstyle.max_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask);
if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask);
if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask);
+ XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask);
resource.wstyle.close_button.mask = resource.wstyle.max_button.mask =
resource.wstyle.icon_button.mask =
// we create the window.frame texture by hand because it exists only to
// make the code cleaner and is not actually used for display
- BColor color = readDatabaseColor("window.frame.focusColor", "white", style);
- resource.wstyle.f_focus = BTexture("solid flat", getBaseDisplay(),
- getScreenNumber(), image_control);
+ otk::BColor color = readDatabaseColor("window.frame.focusColor", "white",
+ style);
+ resource.wstyle.f_focus = otk::BTexture("solid flat", getScreenNumber(),
+ image_control);
resource.wstyle.f_focus.setColor(color);
color = readDatabaseColor("window.frame.unfocusColor", "white", style);
- resource.wstyle.f_unfocus = BTexture("solid flat", getBaseDisplay(),
- getScreenNumber(), image_control);
+ resource.wstyle.f_unfocus = otk::BTexture("solid flat", getScreenNumber(),
+ image_control);
resource.wstyle.f_unfocus.setColor(color);
resource.wstyle.l_text_focus =
}
// sanity checks
- if (resource.wstyle.t_focus.texture() == BTexture::Parent_Relative)
+ if (resource.wstyle.t_focus.texture() == otk::BTexture::Parent_Relative)
resource.wstyle.t_focus = resource.wstyle.f_focus;
- if (resource.wstyle.t_unfocus.texture() == BTexture::Parent_Relative)
+ if (resource.wstyle.t_unfocus.texture() == otk::BTexture::Parent_Relative)
resource.wstyle.t_unfocus = resource.wstyle.f_unfocus;
- if (resource.wstyle.h_focus.texture() == BTexture::Parent_Relative)
+ if (resource.wstyle.h_focus.texture() == otk::BTexture::Parent_Relative)
resource.wstyle.h_focus = resource.wstyle.f_focus;
- if (resource.wstyle.h_unfocus.texture() == BTexture::Parent_Relative)
+ if (resource.wstyle.h_unfocus.texture() == otk::BTexture::Parent_Relative)
resource.wstyle.h_unfocus = resource.wstyle.f_unfocus;
resource.border_color =
BlackboxWindow *win = (BlackboxWindow *) 0;
bool f = False;
- XSync(blackbox->getXDisplay(), False);
+ XSync(otk::OBDisplay::display, False);
// If sloppy focus and we can find the client window under the pointer,
// try to focus it.
if (resource.sloppy_focus &&
- XQueryPointer(blackbox->getXDisplay(), getRootWindow(), &r, &c,
+ XQueryPointer(otk::OBDisplay::display, getRootWindow(), &r, &c,
&rx, &ry, &x, &y, &m) &&
c != None) {
if ( (win = blackbox->searchWindow(c)) )
void BScreen::addSystrayWindow(Window window) {
- XGrabServer(blackbox->getXDisplay());
+ XGrabServer(otk::OBDisplay::display);
- XSelectInput(blackbox->getXDisplay(), window, StructureNotifyMask);
+ XSelectInput(otk::OBDisplay::display, window, StructureNotifyMask);
systrayWindowList.push_back(window);
xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows,
XAtom::window,
&systrayWindowList[0], systrayWindowList.size());
blackbox->saveSystrayWindowSearch(window, this);
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
}
void BScreen::removeSystrayWindow(Window window) {
- XGrabServer(blackbox->getXDisplay());
+ XGrabServer(otk::OBDisplay::display);
WindowList::iterator it = systrayWindowList.begin();
const WindowList::iterator end = systrayWindowList.end();
XAtom::window,
&systrayWindowList[0], systrayWindowList.size());
blackbox->removeSystrayWindowSearch(window);
- XSelectInput(blackbox->getXDisplay(), window, NoEventMask);
+ XSelectInput(otk::OBDisplay::display, window, NoEventMask);
break;
}
assert(it != end); // not a systray window
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
}
}
// is the window a docking app
- XWMHints *wmhint = XGetWMHints(blackbox->getXDisplay(), w);
+ XWMHints *wmhint = XGetWMHints(otk::OBDisplay::display, w);
if (wmhint && (wmhint->flags & StateHint) &&
wmhint->initial_state == WithdrawnState) {
//slit->addClient(w);
XMapRequestEvent mre;
mre.window = w;
- if (blackbox->isStartup() && win->isNormal()) win->restoreAttributes();
+ if (blackbox->state() == Openbox::State_Starting &&
+ win->isNormal())
+ win->restoreAttributes();
win->mapRequestEvent(&mre);
}
unsigned long *dims = new unsigned long[4 * workspacesList.size()];
for (unsigned int i = 0, m = workspacesList.size(); i < m; ++i) {
// XXX: this could be different for each workspace
- const Rect &area = availableArea();
+ const otk::Rect &area = availableArea();
dims[(i * 4) + 0] = area.x();
dims[(i * 4) + 1] = area.y();
dims[(i * 4) + 2] = area.width();
while (k--)
*(session_stack + i++) = *(workspace_stack + k);
- XRestackWindows(blackbox->getXDisplay(), session_stack, i);
+ XRestackWindows(otk::OBDisplay::display, session_stack, i);
delete [] session_stack;
Window *session_stack = new Window[(num + desktopWindowList.size())];
unsigned int i = 0, k = num;
- XLowerWindow(blackbox->getXDisplay(), workspace_stack[0]);
+ XLowerWindow(otk::OBDisplay::display, workspace_stack[0]);
while (k--)
*(session_stack + i++) = *(workspace_stack + k);
for (; dit != d_end; ++dit)
*(session_stack + i++) = *dit;
- XRestackWindows(blackbox->getXDisplay(), session_stack, i);
+ XRestackWindows(otk::OBDisplay::display, session_stack, i);
delete [] session_stack;
void BScreen::shutdown(void) {
- XSelectInput(blackbox->getXDisplay(), getRootWindow(), NoEventMask);
- XSync(blackbox->getXDisplay(), False);
+ XSelectInput(otk::OBDisplay::display, getRootWindow(), NoEventMask);
+ XSync(otk::OBDisplay::display, False);
while(! windowList.empty())
unmanageWindow(windowList.front(), True);
void BScreen::showPosition(int x, int y) {
if (! geom_visible) {
- XMoveResizeWindow(blackbox->getXDisplay(), geom_window,
+ XMoveResizeWindow(otk::OBDisplay::display, geom_window,
(getWidth() - geom_w) / 2,
(getHeight() - geom_h) / 2, geom_w, geom_h);
- XMapWindow(blackbox->getXDisplay(), geom_window);
- XRaiseWindow(blackbox->getXDisplay(), geom_window);
+ XMapWindow(otk::OBDisplay::display, geom_window);
+ XRaiseWindow(otk::OBDisplay::display, geom_window);
geom_visible = True;
}
sprintf(label, "X: %4d x Y: %4d", x, y);
- XClearWindow(blackbox->getXDisplay(), geom_window);
+ XClearWindow(otk::OBDisplay::display, geom_window);
resource.wstyle.font->drawString(geom_window,
resource.bevel_width, resource.bevel_width,
void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
if (! geom_visible) {
- XMoveResizeWindow(blackbox->getXDisplay(), geom_window,
+ XMoveResizeWindow(otk::OBDisplay::display, geom_window,
(getWidth() - geom_w) / 2,
(getHeight() - geom_h) / 2, geom_w, geom_h);
- XMapWindow(blackbox->getXDisplay(), geom_window);
- XRaiseWindow(blackbox->getXDisplay(), geom_window);
+ XMapWindow(otk::OBDisplay::display, geom_window);
+ XRaiseWindow(otk::OBDisplay::display, geom_window);
geom_visible = True;
}
sprintf(label, "W: %4d x H: %4d", gx, gy);
- XClearWindow(blackbox->getXDisplay(), geom_window);
+ XClearWindow(otk::OBDisplay::display, geom_window);
resource.wstyle.font->drawString(geom_window,
resource.bevel_width, resource.bevel_width,
void BScreen::hideGeometry(void) {
if (geom_visible) {
- XUnmapWindow(blackbox->getXDisplay(), geom_window);
+ XUnmapWindow(otk::OBDisplay::display, geom_window);
geom_visible = False;
}
}
}
-const Rect& BScreen::availableArea(void) const {
+const otk::Rect& BScreen::availableArea(void) const {
if (doFullMax())
return getRect(); // return the full screen
return usableArea;
void BScreen::updateAvailableArea(void) {
- Rect old_area = usableArea;
+ otk::Rect old_area = usableArea;
usableArea = getRect(); // reset to full screen
#ifdef XINERAMA
if (s[0] != '/' && s[0] != '~')
{
std::string xbmFile = std::string("~/.openbox/buttons/") + s;
- ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(),
+ ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(),
expandTilde(xbmFile).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
} else
- ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(),
+ ret = XReadBitmapFile(otk::OBDisplay::display, getRootWindow(),
expandTilde(s).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy);
pixmapMask.w = pixmapMask.h = 0;
}
-BTexture BScreen::readDatabaseTexture(const string &rname,
- const string &default_color,
- const Configuration &style,
- bool allowNoTexture) {
- BTexture texture;
+otk::BTexture BScreen::readDatabaseTexture(const string &rname,
+ const string &default_color,
+ const Configuration &style,
+ bool allowNoTexture) {
+ otk::BTexture texture;
string s;
if (style.getValue(rname, s))
- texture = BTexture(s);
+ texture = otk::BTexture(s);
else if (allowNoTexture) //no default
- texture.setTexture(BTexture::NoTexture);
+ texture.setTexture(otk::BTexture::NoTexture);
else
- texture.setTexture(BTexture::Solid | BTexture::Flat);
+ texture.setTexture(otk::BTexture::Solid | otk::BTexture::Flat);
// associate this texture with this screen
- texture.setDisplay(getBaseDisplay(), getScreenNumber());
+ texture.setScreen(getScreenNumber());
texture.setImageControl(image_control);
- if (texture.texture() != BTexture::NoTexture) {
+ if (texture.texture() != otk::BTexture::NoTexture) {
texture.setColor(readDatabaseColor(rname + ".color", default_color,
style));
texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color,
}
-BColor BScreen::readDatabaseColor(const string &rname,
- const string &default_color,
- const Configuration &style) {
- BColor color;
+otk::BColor BScreen::readDatabaseColor(const string &rname,
+ const string &default_color,
+ const Configuration &style) {
+ otk::BColor color;
string s;
if (style.getValue(rname, s))
- color = BColor(s, getBaseDisplay(), getScreenNumber());
+ color = otk::BColor(s, getScreenNumber());
else
- color = BColor(default_color, getBaseDisplay(), getScreenNumber());
+ color = otk::BColor(default_color, getScreenNumber());
return color;
}
-BFont *BScreen::readDatabaseFont(const string &rbasename,
- const Configuration &style) {
+otk::BFont *BScreen::readDatabaseFont(const string &rbasename,
+ const Configuration &style) {
string fontname;
string s;
}
- BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold,
- italic, dropShadow && resource.shadow_fonts, offset,
- tint, resource.aa_fonts);
+ otk::BFont *b = new otk::BFont(getScreenNumber(), family, i, bold, italic,
+ dropShadow && resource.shadow_fonts,
+ offset, tint, resource.aa_fonts);
if (b->valid())
return b;
delete b;
exit(2); // can't continue without a font
}
+
+}
#include <list>
#include <vector>
-#include "color.hh"
-#include "texture.hh"
-#include "image.hh"
+#include "otk/color.hh"
+#include "otk/font.hh"
+#include "otk/texture.hh"
+#include "otk/image.hh"
#include "timer.hh"
#include "workspace.hh"
#include "blackbox.hh"
-class Slit; // forward reference
-class BFont;
+namespace ob {
+
class XAtom;
struct Strut;
};
struct WindowStyle {
- BColor l_text_focus, l_text_unfocus, b_pic_focus,
+ otk::BColor l_text_focus, l_text_unfocus, b_pic_focus,
b_pic_unfocus;
- BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus,
+ otk::BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus,
h_focus, h_unfocus, b_focus, b_unfocus, b_pressed, b_pressed_focus,
b_pressed_unfocus, g_focus, g_unfocus;
PixmapMask close_button, max_button, icon_button, stick_button;
- BFont *font;
+ otk::BFont *font;
TextJustify justify;
unsigned int max_length, unsigned int modifier) const;
};
-class BScreen : public ScreenInfo {
+class BScreen : public otk::ScreenInfo {
private:
bool root_colormap_installed, managed, geom_visible;
GC opGC;
Window geom_window;
Blackbox *blackbox;
- BImageControl *image_control;
+ otk::BImageControl *image_control;
Configuration *config;
XAtom *xatom;
unsigned int geom_w, geom_h;
unsigned long event_mask;
- Rect usableArea;
+ otk::Rect usableArea;
#ifdef XINERAMA
RectList xineramaUsableArea;
#endif // XINERAMA
int snap_to_windows, snap_to_edges;
unsigned int snap_offset;
- BColor border_color;
+ otk::BColor border_color;
unsigned int workspaces;
int placement_policy,
PixmapMask &pixmapMask,
const Configuration &style);
- BTexture readDatabaseTexture(const std::string &rname,
+ otk::BTexture readDatabaseTexture(const std::string &rname,
const std::string &default_color,
const Configuration &style,
bool allowNoTexture = false);
- BColor readDatabaseColor(const std::string &rname,
+ otk::BColor readDatabaseColor(const std::string &rname,
const std::string &default_color,
const Configuration &style);
- BFont *readDatabaseFont(const std::string &rbasename,
- const Configuration &style);
+ otk::BFont *readDatabaseFont(const std::string &rbasename,
+ const Configuration &style);
void LoadStyle(void);
inline const GC &getOpGC(void) const { return opGC; }
inline Blackbox *getBlackbox(void) { return blackbox; }
- inline BColor *getBorderColor(void) { return &resource.border_color; }
- inline BImageControl *getImageControl(void) { return image_control; }
+ inline otk::BColor *getBorderColor(void) { return &resource.border_color; }
+ inline otk::BImageControl *getImageControl(void) { return image_control; }
Workspace *getWorkspace(unsigned int index) const;
// allAvailableAreas should be used whenever possible instead of this function
// as then Xinerama will work correctly.
- const Rect& availableArea(void) const;
+ const otk::Rect& availableArea(void) const;
#ifdef XINERAMA
const RectList& allAvailableAreas(void) const;
#endif // XINERAMA
void propertyNotifyEvent(const XPropertyEvent *pe);
};
+}
#endif // __Screen_hh
+++ /dev/null
-// -*- 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
-}
+++ /dev/null
-// -*- 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
# include "../config.h"
#endif // HAVE_CONFIG_H
-#include "basedisplay.hh"
#include "timer.hh"
#include "util.hh"
+namespace ob {
+
BTimer::BTimer(TimerQueueManager *m, TimeoutHandler *h) {
manager = m;
handler = h;
return ! ((tm.tv_sec < end.tv_sec) ||
(tm.tv_sec == end.tv_sec && tm.tv_usec < end.tv_usec));
}
+
+}
#endif // TIME_WITH_SYS_TIME
}
+#include <queue>
+#include <algorithm>
+#include <vector>
+
+namespace ob {
+
// forward declaration
class TimerQueueManager;
};
-#include <queue>
-#include <algorithm>
-
template <class _Tp, class _Sequence, class _Compare>
class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> {
public:
}
};
-#include <vector>
typedef _timer_queue<BTimer*, std::vector<BTimer*>, TimerLessThan> TimerQueue;
class TimerQueueManager {
virtual void removeTimer(BTimer* timer) = 0;
};
+}
+
#endif // _BLACKBOX_Timer_hh
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#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
#include <unistd.h>
#endif // HAVE_UNISTD_H
+
#if defined(HAVE_PROCESS_H) && defined(__EMX__)
# include <process.h>
#endif // HAVE_PROCESS_H __EMX__
using std::string;
-
-void Rect::setX(int x) {
- _x2 += x - _x1;
- _x1 = x;
-}
-
-
-void Rect::setY(int y)
-{
- _y2 += y - _y1;
- _y1 = y;
-}
-
-
-void Rect::setPos(int x, int y) {
- _x2 += x - _x1;
- _x1 = x;
- _y2 += y - _y1;
- _y1 = y;
-}
-
-
-void Rect::setWidth(unsigned int w) {
- _x2 = w + _x1 - 1;
-}
-
-
-void Rect::setHeight(unsigned int h) {
- _y2 = h + _y1 - 1;
-}
-
-
-void Rect::setSize(unsigned int w, unsigned int h) {
- _x2 = w + _x1 - 1;
- _y2 = h + _y1 - 1;
-}
-
-
-void Rect::setRect(int x, int y, unsigned int w, unsigned int h) {
- *this = Rect(x, y, w, h);
-}
-
-
-void Rect::setCoords(int l, int t, int r, int b) {
- _x1 = l;
- _y1 = t;
- _x2 = r;
- _y2 = b;
-}
-
-
-Rect Rect::operator|(const Rect &a) const {
- Rect b;
-
- b._x1 = std::min(_x1, a._x1);
- b._y1 = std::min(_y1, a._y1);
- b._x2 = std::max(_x2, a._x2);
- b._y2 = std::max(_y2, a._y2);
-
- return b;
-}
-
-
-Rect Rect::operator&(const Rect &a) const {
- Rect b;
-
- b._x1 = std::max(_x1, a._x1);
- b._y1 = std::max(_y1, a._y1);
- b._x2 = std::min(_x2, a._x2);
- b._y2 = std::min(_y2, a._y2);
-
- return b;
-}
-
-
-bool Rect::intersects(const Rect &a) const {
- return std::max(_x1, a._x1) <= std::min(_x2, a._x2) &&
- std::max(_y1, a._y1) <= std::min(_y2, a._y2);
-}
-
-
-bool Rect::contains(int x, int y) const {
- return x >= _x1 && x <= _x2 &&
- y >= _y1 && y <= _y2;
-}
-
-
-bool Rect::contains(const Rect& a) const {
- return a._x1 >= _x1 && a._x2 <= _x2 &&
- a._y1 >= _y1 && a._y2 <= _y2;
-}
-
+namespace ob {
string expandTilde(const string& s) {
if (s[0] != '~') return s;
}
-#ifndef HAVE_BASENAME
-string basename (const string& path) {
- string::size_type slash = path.rfind('/');
- if (slash == string::npos)
- return path;
- return path.substr(slash+1);
-}
-#endif // HAVE_BASENAME
-
-
string textPropertyToString(Display *display, XTextProperty& text_prop) {
string ret;
tmp.insert(tmp.begin(), '-');
return tmp;
}
+
+}
+
+#ifndef HAVE_BASENAME
+string basename (const string& path) {
+ string::size_type slash = path.rfind('/');
+ if (slash == string::npos)
+ return path;
+ return path.substr(slash+1);
+}
+#endif // HAVE_BASENAME
+
#ifndef _BLACKBOX_UTIL_HH
#define _BLACKBOX_UTIL_HH
+extern "C" {
#include <X11/Xlib.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 <vector>
-class Rect {
-public:
- inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { }
- inline Rect(int __x, int __y, unsigned int __w, unsigned int __h)
- : _x1(__x), _y1(__y), _x2(__w + __x - 1), _y2(__h + __y - 1) { }
- inline explicit Rect(const XRectangle& xrect)
- : _x1(xrect.x), _y1(xrect.y), _x2(xrect.width + xrect.x - 1),
- _y2(xrect.height + xrect.y - 1) { }
-
- inline int left(void) const { return _x1; }
- inline int top(void) const { return _y1; }
- inline int right(void) const { return _x2; }
- inline int bottom(void) const { return _y2; }
-
- inline int x(void) const { return _x1; }
- inline int y(void) const { return _y1; }
- void setX(int __x);
- void setY(int __y);
- void setPos(int __x, int __y);
-
- inline unsigned int width(void) const { return _x2 - _x1 + 1; }
- inline unsigned int height(void) const { return _y2 - _y1 + 1; }
- void setWidth(unsigned int __w);
- void setHeight(unsigned int __h);
- void setSize(unsigned int __w, unsigned int __h);
-
- void setRect(int __x, int __y, unsigned int __w, unsigned int __h);
-
- void setCoords(int __l, int __t, int __r, int __b);
-
- inline bool operator==(const Rect &a)
- { return _x1 == a._x1 && _y1 == a._y1 && _x2 == a._x2 && _y2 == a._y2; }
- inline bool operator!=(const Rect &a) { return ! operator==(a); }
-
- Rect operator|(const Rect &a) const;
- Rect operator&(const Rect &a) const;
- inline Rect &operator|=(const Rect &a) { *this = *this | a; return *this; }
- inline Rect &operator&=(const Rect &a) { *this = *this & a; return *this; }
-
- inline bool valid(void) const { return _x2 > _x1 && _y2 > _y1; }
-
- bool intersects(const Rect &a) const;
- bool contains(int __x, int __y) const;
- bool contains(const Rect &a) const;
-
-private:
- int _x1, _y1, _x2, _y2;
-};
-
-typedef std::vector<Rect> RectList;
+namespace ob {
struct Strut {
unsigned int top, bottom, left, right;
void bexec(const std::string& command, const std::string& displaystring);
-#ifndef HAVE_BASENAME
-std::string basename(const std::string& path);
-#endif
-
std::string textPropertyToString(Display *display, XTextProperty& text_prop);
-struct timeval; // forward declare to avoid the header
timeval normalizeTimeval(const timeval &tm);
-struct PointerAssassin {
- template<typename T>
- inline void operator()(const T ptr) const {
- delete ptr;
- }
-};
-
std::string itostring(unsigned long i);
std::string itostring(long i);
inline std::string itostring(unsigned int i)
{ return itostring((unsigned long) i); }
inline std::string itostring(int i)
{ return itostring((long) i); }
-
+
+}
+
+#ifndef HAVE_BASENAME
+std::string basename(const std::string& path);
+#endif
+
#endif
using std::string;
using std::abs;
+namespace ob {
+
/*
* Initializes the class with default values/the window's set initial values.
*/
// fetch client size and placement
XWindowAttributes wattrib;
- if (! XGetWindowAttributes(blackbox->getXDisplay(),
+ if (! XGetWindowAttributes(otk::OBDisplay::display,
client.window, &wattrib) ||
! wattrib.screen || wattrib.override_redirect) {
#ifdef DEBUG
StructureNotifyMask;
attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask;
- XChangeWindowAttributes(blackbox->getXDisplay(), client.window,
+ XChangeWindowAttributes(otk::OBDisplay::display, client.window,
CWEventMask|CWDontPropagate, &attrib_set);
flags.moving = flags.resizing = flags.shaded = flags.visible =
upsize();
bool place_window = True;
- if (blackbox->isStartup() || isTransient() ||
+ if (blackbox->state() == Openbox::State_Starting || isTransient() ||
client.normal_hint_flags & (PPosition|USPosition)) {
applyGravity(frame.rect);
- if (blackbox->isStartup() || client.rect.intersects(screen->getRect()))
+ if (blackbox->state() == Openbox::State_Starting ||
+ client.rect.intersects(screen->getRect()))
place_window = False;
}
We hold the grab until after we are done moving the window around.
*/
- XGrabServer(blackbox->getXDisplay());
+ XGrabServer(otk::OBDisplay::display);
associateClientWindow();
positionWindows();
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
#ifdef SHAPE
if (blackbox->hasShapeExtensions() && flags.shaped)
grabButtons();
- XMapSubwindows(blackbox->getXDisplay(), frame.window);
+ XMapSubwindows(otk::OBDisplay::display, frame.window);
// this ensures the title, buttons, and other decor are properly displayed
redrawWindowFrame();
if (frame.plate) {
blackbox->removeWindowSearch(frame.plate);
- XDestroyWindow(blackbox->getXDisplay(), frame.plate);
+ XDestroyWindow(otk::OBDisplay::display, frame.plate);
}
if (frame.window) {
blackbox->removeWindowSearch(frame.window);
- XDestroyWindow(blackbox->getXDisplay(), frame.window);
+ XDestroyWindow(otk::OBDisplay::display, frame.window);
}
blackbox->removeWindowSearch(client.window);
shade();
if (flags.visible && frame.window) {
- XMapSubwindows(blackbox->getXDisplay(), frame.window);
- XMapWindow(blackbox->getXDisplay(), frame.window);
+ XMapSubwindows(otk::OBDisplay::display, frame.window);
+ XMapWindow(otk::OBDisplay::display, frame.window);
}
reconfigure();
window's frame.
*/
- return XCreateWindow(blackbox->getXDisplay(), screen->getRootWindow(),
+ return XCreateWindow(otk::OBDisplay::display, screen->getRootWindow(),
0, 0, 1, 1, frame.border_w, screen->getDepth(),
InputOutput, screen->getVisual(), create_mask,
&attrib_create);
attrib_create.cursor = cursor;
}
- return XCreateWindow(blackbox->getXDisplay(), parent, 0, 0, 1, 1, 0,
+ return XCreateWindow(otk::OBDisplay::display, parent, 0, 0, 1, 1, 0,
screen->getDepth(), InputOutput, screen->getVisual(),
create_mask, &attrib_create);
}
void BlackboxWindow::associateClientWindow(void) {
- XSetWindowBorderWidth(blackbox->getXDisplay(), client.window, 0);
+ XSetWindowBorderWidth(otk::OBDisplay::display, client.window, 0);
getWMName();
getWMIconName();
- XChangeSaveSet(blackbox->getXDisplay(), client.window, SetModeInsert);
+ XChangeSaveSet(otk::OBDisplay::display, client.window, SetModeInsert);
- XSelectInput(blackbox->getXDisplay(), frame.plate, SubstructureRedirectMask);
+ XSelectInput(otk::OBDisplay::display, frame.plate, SubstructureRedirectMask);
/*
note we used to grab around this call to XReparentWindow however the
*/
unsigned long event_mask = PropertyChangeMask | FocusChangeMask |
StructureNotifyMask;
- XSelectInput(blackbox->getXDisplay(), client.window,
+ XSelectInput(otk::OBDisplay::display, client.window,
event_mask & ~StructureNotifyMask);
- XReparentWindow(blackbox->getXDisplay(), client.window, frame.plate, 0, 0);
- XSelectInput(blackbox->getXDisplay(), client.window, event_mask);
+ XReparentWindow(otk::OBDisplay::display, client.window, frame.plate, 0, 0);
+ XSelectInput(otk::OBDisplay::display, client.window, event_mask);
- XRaiseWindow(blackbox->getXDisplay(), frame.plate);
- XMapSubwindows(blackbox->getXDisplay(), frame.plate);
+ XRaiseWindow(otk::OBDisplay::display, frame.plate);
+ XMapSubwindows(otk::OBDisplay::display, frame.plate);
#ifdef SHAPE
if (blackbox->hasShapeExtensions()) {
- XShapeSelectInput(blackbox->getXDisplay(), client.window,
+ XShapeSelectInput(otk::OBDisplay::display, client.window,
ShapeNotifyMask);
Bool shaped = False;
int foo;
unsigned int ufoo;
- XShapeQueryExtents(blackbox->getXDisplay(), client.window, &shaped,
+ XShapeQueryExtents(otk::OBDisplay::display, client.window, &shaped,
&foo, &foo, &ufoo, &ufoo, &foo, &foo, &foo,
&ufoo, &ufoo);
flags.shaped = shaped;
void BlackboxWindow::decorate(void) {
- BTexture* texture;
+ otk::BTexture* texture;
texture = &(screen->getWindowStyle()->b_focus);
frame.fbutton = texture->render(frame.button_w, frame.button_w,
texture = &(screen->getWindowStyle()->b_pressed_focus);
- if (texture->texture() != BTexture::NoTexture) {
+ if (texture->texture() != otk::BTexture::NoTexture) {
frame.pfbutton = texture->render(frame.button_w, frame.button_w,
frame.pfbutton);
if (! frame.pfbutton)
texture = &(screen->getWindowStyle()->b_pressed_unfocus);
- if (texture->texture() != BTexture::NoTexture) {
+ if (texture->texture() != otk::BTexture::NoTexture) {
frame.pubutton = texture->render(frame.button_w, frame.button_w,
frame.pubutton);
if (! frame.pubutton)
if (! frame.utitle)
frame.utitle_pixel = texture->color().pixel();
- XSetWindowBorder(blackbox->getXDisplay(), frame.title,
+ XSetWindowBorder(otk::OBDisplay::display, frame.title,
screen->getBorderColor()->pixel());
decorateLabel();
if (! frame.ugrip)
frame.ugrip_pixel = texture->color().pixel();
- XSetWindowBorder(blackbox->getXDisplay(), frame.handle,
+ XSetWindowBorder(otk::OBDisplay::display, frame.handle,
screen->getBorderColor()->pixel());
- XSetWindowBorder(blackbox->getXDisplay(), frame.left_grip,
+ XSetWindowBorder(otk::OBDisplay::display, frame.left_grip,
screen->getBorderColor()->pixel());
- XSetWindowBorder(blackbox->getXDisplay(), frame.right_grip,
+ XSetWindowBorder(otk::OBDisplay::display, frame.right_grip,
screen->getBorderColor()->pixel());
}
- XSetWindowBorder(blackbox->getXDisplay(), frame.window,
+ XSetWindowBorder(otk::OBDisplay::display, frame.window,
screen->getBorderColor()->pixel());
}
void BlackboxWindow::decorateLabel(void) {
- BTexture *texture;
+ otk::BTexture *texture;
texture = &(screen->getWindowStyle()->l_focus);
frame.flabel = texture->render(frame.label_w, frame.label_h, frame.flabel);
blackbox->removeWindowSearch(frame.left_grip);
blackbox->removeWindowSearch(frame.right_grip);
- XDestroyWindow(blackbox->getXDisplay(), frame.left_grip);
- XDestroyWindow(blackbox->getXDisplay(), frame.right_grip);
+ XDestroyWindow(otk::OBDisplay::display, frame.left_grip);
+ XDestroyWindow(otk::OBDisplay::display, frame.right_grip);
frame.left_grip = frame.right_grip = None;
blackbox->removeWindowSearch(frame.handle);
- XDestroyWindow(blackbox->getXDisplay(), frame.handle);
+ XDestroyWindow(otk::OBDisplay::display, frame.handle);
frame.handle = None;
}
blackbox->removeWindowSearch(frame.title);
blackbox->removeWindowSearch(frame.label);
- XDestroyWindow(blackbox->getXDisplay(), frame.label);
- XDestroyWindow(blackbox->getXDisplay(), frame.title);
+ XDestroyWindow(otk::OBDisplay::display, frame.label);
+ XDestroyWindow(otk::OBDisplay::display, frame.title);
frame.title = frame.label = None;
}
void BlackboxWindow::destroyCloseButton(void) {
blackbox->removeWindowSearch(frame.close_button);
- XDestroyWindow(blackbox->getXDisplay(), frame.close_button);
+ XDestroyWindow(otk::OBDisplay::display, frame.close_button);
frame.close_button = None;
}
void BlackboxWindow::destroyIconifyButton(void) {
blackbox->removeWindowSearch(frame.iconify_button);
- XDestroyWindow(blackbox->getXDisplay(), frame.iconify_button);
+ XDestroyWindow(otk::OBDisplay::display, frame.iconify_button);
frame.iconify_button = None;
}
void BlackboxWindow::destroyMaximizeButton(void) {
blackbox->removeWindowSearch(frame.maximize_button);
- XDestroyWindow(blackbox->getXDisplay(), frame.maximize_button);
+ XDestroyWindow(otk::OBDisplay::display, frame.maximize_button);
frame.maximize_button = None;
}
void BlackboxWindow::destroyStickyButton(void) {
blackbox->removeWindowSearch(frame.stick_button);
- XDestroyWindow(blackbox->getXDisplay(), frame.stick_button);
+ XDestroyWindow(otk::OBDisplay::display, frame.stick_button);
frame.stick_button = None;
}
switch(*it) {
case 'C':
if (! frame.close_button) createCloseButton();
- XMoveResizeWindow(blackbox->getXDisplay(), frame.close_button, x, by,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.close_button, x, by,
frame.button_w, frame.button_w);
x += frame.button_w + bsep;
break;
case 'I':
if (! frame.iconify_button) createIconifyButton();
- XMoveResizeWindow(blackbox->getXDisplay(), frame.iconify_button, x, by,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.iconify_button, x, by,
frame.button_w, frame.button_w);
x += frame.button_w + bsep;
break;
case 'S':
if (! frame.stick_button) createStickyButton();
- XMoveResizeWindow(blackbox->getXDisplay(), frame.stick_button, x, by,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.stick_button, x, by,
frame.button_w, frame.button_w);
x += frame.button_w + bsep;
break;
case 'M':
if (! frame.maximize_button) createMaximizeButton();
- XMoveResizeWindow(blackbox->getXDisplay(), frame.maximize_button, x, by,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.maximize_button, x, by,
frame.button_w, frame.button_w);
x += frame.button_w + bsep;
break;
case 'L':
- XMoveResizeWindow(blackbox->getXDisplay(), frame.label, x, ty,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.label, x, ty,
frame.label_w, frame.label_h);
x += frame.label_w + bsep;
break;
if (! screen->isSloppyFocus() || screen->doClickRaise())
// grab button 1 for changing focus/raising
- blackbox->grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
- GrabModeSync, GrabModeSync, frame.plate, None,
- screen->allowScrollLock());
+ otk::OBDisplay::grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
+ GrabModeSync, GrabModeSync, frame.plate, None,
+ screen->allowScrollLock());
if (functions & Func_Move)
- blackbox->grabButton(Button1, mod_mask, frame.window, True,
+ otk::OBDisplay::grabButton(Button1, mod_mask, frame.window, True,
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
GrabModeAsync, frame.window, None,
screen->allowScrollLock());
if (functions & Func_Resize)
- blackbox->grabButton(Button3, mod_mask, frame.window, True,
+ otk::OBDisplay::grabButton(Button3, mod_mask, frame.window, True,
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
GrabModeAsync, frame.window, None,
screen->allowScrollLock());
// alt+middle lowers the window
- blackbox->grabButton(Button2, mod_mask, frame.window, True,
+ otk::OBDisplay::grabButton(Button2, mod_mask, frame.window, True,
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
frame.window, None, screen->allowScrollLock());
}
void BlackboxWindow::ungrabButtons(void) {
- blackbox->ungrabButton(Button1, 0, frame.plate);
- blackbox->ungrabButton(Button1, mod_mask, frame.window);
- blackbox->ungrabButton(Button2, mod_mask, frame.window);
- blackbox->ungrabButton(Button3, mod_mask, frame.window);
+ otk::OBDisplay::ungrabButton(Button1, 0, frame.plate);
+ otk::OBDisplay::ungrabButton(Button1, mod_mask, frame.window);
+ otk::OBDisplay::ungrabButton(Button2, mod_mask, frame.window);
+ otk::OBDisplay::ungrabButton(Button3, mod_mask, frame.window);
}
void BlackboxWindow::positionWindows(void) {
- XMoveResizeWindow(blackbox->getXDisplay(), frame.window,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.window,
frame.rect.x(), frame.rect.y(), frame.inside_w,
(flags.shaded) ? frame.title_h : frame.inside_h);
- XSetWindowBorderWidth(blackbox->getXDisplay(), frame.window,
+ XSetWindowBorderWidth(otk::OBDisplay::display, frame.window,
frame.border_w);
- XSetWindowBorderWidth(blackbox->getXDisplay(), frame.plate,
+ XSetWindowBorderWidth(otk::OBDisplay::display, frame.plate,
frame.mwm_border_w);
- XMoveResizeWindow(blackbox->getXDisplay(), frame.plate,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.plate,
frame.margin.left - frame.mwm_border_w - frame.border_w,
frame.margin.top - frame.mwm_border_w - frame.border_w,
client.rect.width(), client.rect.height());
- XMoveResizeWindow(blackbox->getXDisplay(), client.window,
+ XMoveResizeWindow(otk::OBDisplay::display, client.window,
0, 0, client.rect.width(), client.rect.height());
// ensure client.rect contains the real location
client.rect.setPos(frame.rect.left() + frame.margin.left,
if (decorations & Decor_Titlebar) {
if (frame.title == None) createTitlebar();
- XSetWindowBorderWidth(blackbox->getXDisplay(), frame.title,
+ XSetWindowBorderWidth(otk::OBDisplay::display, frame.title,
frame.border_w);
- XMoveResizeWindow(blackbox->getXDisplay(), frame.title, -frame.border_w,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.title, -frame.border_w,
-frame.border_w, frame.inside_w, frame.title_h);
positionButtons();
- XMapSubwindows(blackbox->getXDisplay(), frame.title);
- XMapWindow(blackbox->getXDisplay(), frame.title);
+ XMapSubwindows(otk::OBDisplay::display, frame.title);
+ XMapWindow(otk::OBDisplay::display, frame.title);
} else if (frame.title) {
destroyTitlebar();
}
if (decorations & Decor_Handle) {
if (frame.handle == None) createHandle();
- XSetWindowBorderWidth(blackbox->getXDisplay(), frame.handle,
+ XSetWindowBorderWidth(otk::OBDisplay::display, frame.handle,
frame.border_w);
- XSetWindowBorderWidth(blackbox->getXDisplay(), frame.left_grip,
+ XSetWindowBorderWidth(otk::OBDisplay::display, frame.left_grip,
frame.border_w);
- XSetWindowBorderWidth(blackbox->getXDisplay(), frame.right_grip,
+ XSetWindowBorderWidth(otk::OBDisplay::display, frame.right_grip,
frame.border_w);
// use client.rect here so the value is correct even if shaded
- XMoveResizeWindow(blackbox->getXDisplay(), frame.handle,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.handle,
-frame.border_w,
client.rect.height() + frame.margin.top +
frame.mwm_border_w - frame.border_w,
frame.inside_w, frame.handle_h);
- XMoveResizeWindow(blackbox->getXDisplay(), frame.left_grip,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.left_grip,
-frame.border_w, -frame.border_w,
frame.grip_w, frame.handle_h);
- XMoveResizeWindow(blackbox->getXDisplay(), frame.right_grip,
+ XMoveResizeWindow(otk::OBDisplay::display, frame.right_grip,
frame.inside_w - frame.grip_w - frame.border_w,
-frame.border_w, frame.grip_w, frame.handle_h);
- XMapSubwindows(blackbox->getXDisplay(), frame.handle);
- XMapWindow(blackbox->getXDisplay(), frame.handle);
+ XMapSubwindows(otk::OBDisplay::display, frame.handle);
+ XMapWindow(otk::OBDisplay::display, frame.handle);
} else if (frame.handle) {
destroyHandle();
}
- XSync(blackbox->getXDisplay(), False);
+ XSync(otk::OBDisplay::display, False);
}
Atom *proto;
int num_return = 0;
- if (XGetWMProtocols(blackbox->getXDisplay(), client.window,
+ if (XGetWMProtocols(otk::OBDisplay::display, client.window,
&proto, &num_return)) {
for (int i = 0; i < num_return; ++i) {
if (proto[i] == xatom->getAtom(XAtom::wm_delete_window)) {
}
client.window_group = None;
- XWMHints *wmhint = XGetWMHints(blackbox->getXDisplay(), client.window);
+ XWMHints *wmhint = XGetWMHints(otk::OBDisplay::display, client.window);
if (! wmhint) {
return;
}
client.max_height = (unsigned) -1;
- if (! XGetWMNormalHints(blackbox->getXDisplay(), client.window,
+ if (! XGetWMNormalHints(otk::OBDisplay::display, client.window,
&sizehint, &icccm_mask))
return;
client.transient_for = (BlackboxWindow *) 0;
Window trans_for;
- if (! XGetTransientForHint(blackbox->getXDisplay(), client.window,
+ if (! XGetTransientForHint(otk::OBDisplay::display, client.window,
&trans_for)) {
// transient_for hint not set
return;
} else {
frame.rect.setPos(dx, dy);
- XMoveWindow(blackbox->getXDisplay(), frame.window,
+ XMoveWindow(otk::OBDisplay::display, frame.window,
frame.rect.x(), frame.rect.y());
/*
we may have been called just after an opaque window move, so even though
XEvent event;
event.type = ConfigureNotify;
- event.xconfigure.display = blackbox->getXDisplay();
+ event.xconfigure.display = otk::OBDisplay::display;
event.xconfigure.event = client.window;
event.xconfigure.window = client.window;
event.xconfigure.x = client.rect.x();
event.xconfigure.above = frame.window;
event.xconfigure.override_redirect = False;
- XSendEvent(blackbox->getXDisplay(), client.window, False,
+ XSendEvent(otk::OBDisplay::display, client.window, False,
StructureNotifyMask, &event);
- XFlush(blackbox->getXDisplay());
+ XFlush(otk::OBDisplay::display);
}
}
#ifdef SHAPE
void BlackboxWindow::configureShape(void) {
- XShapeCombineShape(blackbox->getXDisplay(), frame.window, ShapeBounding,
+ XShapeCombineShape(otk::OBDisplay::display, frame.window, ShapeBounding,
frame.margin.left - frame.border_w,
frame.margin.top - frame.border_w,
client.window, ShapeBounding, ShapeSet);
++num;
}
- XShapeCombineRectangles(blackbox->getXDisplay(), frame.window,
+ XShapeCombineRectangles(otk::OBDisplay::display, frame.window,
ShapeBounding, 0, 0, xrect, num,
ShapeUnion, Unsorted);
}
void BlackboxWindow::clearShape(void) {
- XShapeCombineMask(blackbox->getXDisplay(), frame.window, ShapeBounding,
+ XShapeCombineMask(otk::OBDisplay::display, frame.window, ShapeBounding,
frame.margin.left - frame.border_w,
frame.margin.top - frame.border_w,
None, ShapeSet);
bool ret = True;
if (focus_mode == F_LocallyActive || focus_mode == F_Passive) {
- XSetInputFocus(blackbox->getXDisplay(), client.window,
+ XSetInputFocus(otk::OBDisplay::display, client.window,
RevertToPointerRoot, CurrentTime);
} else {
/* we could set the focus to none, since the window doesn't accept focus,
XEvent ce;
ce.xclient.type = ClientMessage;
ce.xclient.message_type = xatom->getAtom(XAtom::wm_protocols);
- ce.xclient.display = blackbox->getXDisplay();
+ ce.xclient.display = otk::OBDisplay::display;
ce.xclient.window = client.window;
ce.xclient.format = 32;
ce.xclient.data.l[0] = xatom->getAtom(XAtom::wm_take_focus);
ce.xclient.data.l[2] = 0l;
ce.xclient.data.l[3] = 0l;
ce.xclient.data.l[4] = 0l;
- XSendEvent(blackbox->getXDisplay(), client.window, False,
+ XSendEvent(otk::OBDisplay::display, client.window, False,
NoEventMask, &ce);
- XFlush(blackbox->getXDisplay());
+ XFlush(otk::OBDisplay::display);
}
return ret;
*/
unsigned long event_mask = PropertyChangeMask | FocusChangeMask |
StructureNotifyMask;
- XGrabServer(blackbox->getXDisplay());
- XSelectInput(blackbox->getXDisplay(), client.window,
+ XGrabServer(otk::OBDisplay::display);
+ XSelectInput(otk::OBDisplay::display, client.window,
event_mask & ~StructureNotifyMask);
- XUnmapWindow(blackbox->getXDisplay(), client.window);
- XSelectInput(blackbox->getXDisplay(), client.window, event_mask);
- XUngrabServer(blackbox->getXDisplay());
+ XUnmapWindow(otk::OBDisplay::display, client.window);
+ XSelectInput(otk::OBDisplay::display, client.window, event_mask);
+ XUngrabServer(otk::OBDisplay::display);
- XUnmapWindow(blackbox->getXDisplay(), frame.window);
+ XUnmapWindow(otk::OBDisplay::display, frame.window);
flags.visible = False;
flags.iconic = True;
current_state = (flags.shaded) ? IconicState : NormalState;
setState(current_state);
- XMapWindow(blackbox->getXDisplay(), client.window);
- XMapSubwindows(blackbox->getXDisplay(), frame.window);
- XMapWindow(blackbox->getXDisplay(), frame.window);
+ XMapWindow(otk::OBDisplay::display, client.window);
+ XMapSubwindows(otk::OBDisplay::display, frame.window);
+ XMapWindow(otk::OBDisplay::display, frame.window);
#if 0
int real_x, real_y;
Window child;
- XTranslateCoordinates(blackbox->getXDisplay(), client.window,
+ XTranslateCoordinates(otk::OBDisplay::display, client.window,
screen->getRootWindow(),
0, 0, &real_x, &real_y, &child);
fprintf(stderr, "%s -- assumed: (%d, %d), real: (%d, %d)\n", getTitle(),
XEvent ce;
ce.xclient.type = ClientMessage;
ce.xclient.message_type = xatom->getAtom(XAtom::wm_protocols);
- ce.xclient.display = blackbox->getXDisplay();
+ ce.xclient.display = otk::OBDisplay::display;
ce.xclient.window = client.window;
ce.xclient.format = 32;
ce.xclient.data.l[0] = xatom->getAtom(XAtom::wm_delete_window);
ce.xclient.data.l[2] = 0l;
ce.xclient.data.l[3] = 0l;
ce.xclient.data.l[4] = 0l;
- XSendEvent(blackbox->getXDisplay(), client.window, False, NoEventMask, &ce);
- XFlush(blackbox->getXDisplay());
+ XSendEvent(otk::OBDisplay::display, client.window, False, NoEventMask, &ce);
+ XFlush(otk::OBDisplay::display);
}
setState(current_state);
- XUnmapWindow(blackbox->getXDisplay(), frame.window);
+ XUnmapWindow(otk::OBDisplay::display, frame.window);
- XGrabServer(blackbox->getXDisplay());
+ XGrabServer(otk::OBDisplay::display);
unsigned long event_mask = PropertyChangeMask | FocusChangeMask |
StructureNotifyMask;
- XSelectInput(blackbox->getXDisplay(), client.window,
+ XSelectInput(otk::OBDisplay::display, client.window,
event_mask & ~StructureNotifyMask);
- XUnmapWindow(blackbox->getXDisplay(), client.window);
- XSelectInput(blackbox->getXDisplay(), client.window, event_mask);
+ XUnmapWindow(otk::OBDisplay::display, client.window);
+ XSelectInput(otk::OBDisplay::display, client.window, event_mask);
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
}
void BlackboxWindow::shade(void) {
if (flags.shaded) {
- XResizeWindow(blackbox->getXDisplay(), frame.window,
+ XResizeWindow(otk::OBDisplay::display, frame.window,
frame.inside_w, frame.inside_h);
flags.shaded = False;
blackbox_attrib.flags ^= AttribShaded;
if (! (decorations & Decor_Titlebar))
return; // can't shade it without a titlebar!
- XResizeWindow(blackbox->getXDisplay(), frame.window,
+ XResizeWindow(otk::OBDisplay::display, frame.window,
frame.inside_w, frame.title_h);
flags.shaded = True;
blackbox_attrib.flags |= AttribShaded;
if (decorations & Decor_Titlebar) {
if (flags.focused) {
if (frame.ftitle)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.title, frame.ftitle);
else
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.title, frame.ftitle_pixel);
} else {
if (frame.utitle)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.title, frame.utitle);
else
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.title, frame.utitle_pixel);
}
- XClearWindow(blackbox->getXDisplay(), frame.title);
+ XClearWindow(otk::OBDisplay::display, frame.title);
redrawLabel();
redrawAllButtons();
if (decorations & Decor_Handle) {
if (flags.focused) {
if (frame.fhandle)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.handle, frame.fhandle);
else
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.handle, frame.fhandle_pixel);
if (frame.fgrip) {
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.left_grip, frame.fgrip);
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.right_grip, frame.fgrip);
} else {
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.left_grip, frame.fgrip_pixel);
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.right_grip, frame.fgrip_pixel);
}
} else {
if (frame.uhandle)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.handle, frame.uhandle);
else
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.handle, frame.uhandle_pixel);
if (frame.ugrip) {
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.left_grip, frame.ugrip);
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.right_grip, frame.ugrip);
} else {
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.left_grip, frame.ugrip_pixel);
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.right_grip, frame.ugrip_pixel);
}
}
- XClearWindow(blackbox->getXDisplay(), frame.handle);
- XClearWindow(blackbox->getXDisplay(), frame.left_grip);
- XClearWindow(blackbox->getXDisplay(), frame.right_grip);
+ XClearWindow(otk::OBDisplay::display, frame.handle);
+ XClearWindow(otk::OBDisplay::display, frame.left_grip);
+ XClearWindow(otk::OBDisplay::display, frame.right_grip);
}
if (decorations & Decor_Border) {
if (flags.focused)
- XSetWindowBorder(blackbox->getXDisplay(),
+ XSetWindowBorder(otk::OBDisplay::display,
frame.plate, frame.fborder_pixel);
else
- XSetWindowBorder(blackbox->getXDisplay(),
+ XSetWindowBorder(otk::OBDisplay::display,
frame.plate, frame.uborder_pixel);
}
}
void BlackboxWindow::installColormap(bool install) {
int i = 0, ncmap = 0;
- Colormap *cmaps = XListInstalledColormaps(blackbox->getXDisplay(),
+ Colormap *cmaps = XListInstalledColormaps(otk::OBDisplay::display,
client.window, &ncmap);
if (cmaps) {
XWindowAttributes wattrib;
- if (XGetWindowAttributes(blackbox->getXDisplay(),
+ if (XGetWindowAttributes(otk::OBDisplay::display,
client.window, &wattrib)) {
if (install) {
// install the window's colormap
}
// otherwise, install the window's colormap
if (install)
- XInstallColormap(blackbox->getXDisplay(), wattrib.colormap);
+ XInstallColormap(otk::OBDisplay::display, wattrib.colormap);
} else {
// uninstall the window's colormap
for (i = 0; i < ncmap; i++) {
if (*(cmaps + i) == wattrib.colormap)
// we found the colormap to uninstall
- XUninstallColormap(blackbox->getXDisplay(), wattrib.colormap);
+ XUninstallColormap(otk::OBDisplay::display, wattrib.colormap);
}
}
}
* Positions the Rect r according the the client window position and
* window gravity.
*/
-void BlackboxWindow::applyGravity(Rect &r) {
+void BlackboxWindow::applyGravity(otk::Rect &r) {
// apply horizontal window gravity
switch (client.win_gravity) {
default:
* Positions the Rect r according to the frame window position and
* window gravity.
*/
-void BlackboxWindow::restoreGravity(Rect &r) {
+void BlackboxWindow::restoreGravity(otk::Rect &r) {
// restore horizontal window gravity
switch (client.win_gravity) {
default:
void BlackboxWindow::redrawLabel(void) const {
if (flags.focused) {
if (frame.flabel)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.label, frame.flabel);
else
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.label, frame.flabel_pixel);
} else {
if (frame.ulabel)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display,
frame.label, frame.ulabel);
else
- XSetWindowBackground(blackbox->getXDisplay(),
+ XSetWindowBackground(otk::OBDisplay::display,
frame.label, frame.ulabel_pixel);
}
- XClearWindow(blackbox->getXDisplay(), frame.label);
+ XClearWindow(otk::OBDisplay::display, frame.label);
WindowStyle *style = screen->getWindowStyle();
}
if (p)
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(), win, p);
+ XSetWindowBackgroundPixmap(otk::OBDisplay::display, win, p);
else
- XSetWindowBackground(blackbox->getXDisplay(), win, pix);
+ XSetWindowBackground(otk::OBDisplay::display, win, pix);
}
frame.fbutton, frame.fbutton_pixel,
frame.ubutton, frame.ubutton_pixel);
- XClearWindow(blackbox->getXDisplay(), frame.iconify_button);
- BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
- screen->getWindowStyle()->b_pic_unfocus);
+ XClearWindow(otk::OBDisplay::display, frame.iconify_button);
+ otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
+ screen->getWindowStyle()->b_pic_unfocus);
PixmapMask pm = screen->getWindowStyle()->icon_button;
if (screen->getWindowStyle()->icon_button.mask != None) {
- XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
- XFillRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(),
+ XFillRectangle(otk::OBDisplay::display, frame.iconify_button, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
(frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
- XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0);
+ XSetClipMask(otk::OBDisplay::display, pen.gc(), None);
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0);
} else {
- XDrawRectangle(blackbox->getXDisplay(), frame.iconify_button, pen.gc(),
+ XDrawRectangle(otk::OBDisplay::display, frame.iconify_button, pen.gc(),
2, (frame.button_w - 5), (frame.button_w - 5), 2);
}
}
frame.fbutton, frame.fbutton_pixel,
frame.ubutton, frame.ubutton_pixel);
- XClearWindow(blackbox->getXDisplay(), frame.maximize_button);
+ XClearWindow(otk::OBDisplay::display, frame.maximize_button);
- BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
- screen->getWindowStyle()->b_pic_unfocus);
+ otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
+ screen->getWindowStyle()->b_pic_unfocus);
PixmapMask pm = screen->getWindowStyle()->max_button;
if (pm.mask != None) {
- XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
- XFillRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
+ XFillRectangle(otk::OBDisplay::display, frame.maximize_button, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
(frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
- XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0 );
+ XSetClipMask( otk::OBDisplay::display, pen.gc(), None );
} else {
- XDrawRectangle(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
+ XDrawRectangle(otk::OBDisplay::display, frame.maximize_button, pen.gc(),
2, 2, (frame.button_w - 5), (frame.button_w - 5));
- XDrawLine(blackbox->getXDisplay(), frame.maximize_button, pen.gc(),
+ XDrawLine(otk::OBDisplay::display, frame.maximize_button, pen.gc(),
2, 3, (frame.button_w - 3), 3);
}
}
frame.fbutton, frame.fbutton_pixel,
frame.ubutton, frame.ubutton_pixel);
- XClearWindow(blackbox->getXDisplay(), frame.close_button);
+ XClearWindow(otk::OBDisplay::display, frame.close_button);
- BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
- screen->getWindowStyle()->b_pic_unfocus);
+ otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
+ screen->getWindowStyle()->b_pic_unfocus);
PixmapMask pm = screen->getWindowStyle()->close_button;
if (pm.mask != None) {
- XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
- XFillRectangle(blackbox->getXDisplay(), frame.close_button, pen.gc(),
+ XFillRectangle(otk::OBDisplay::display, frame.close_button, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
(frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
- XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0 );
+ XSetClipMask( otk::OBDisplay::display, pen.gc(), None );
} else {
- XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(),
+ XDrawLine(otk::OBDisplay::display, frame.close_button, pen.gc(),
2, 2, (frame.button_w - 3), (frame.button_w - 3));
- XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(),
+ XDrawLine(otk::OBDisplay::display, frame.close_button, pen.gc(),
2, (frame.button_w - 3), (frame.button_w - 3), 2);
}
}
frame.fbutton, frame.fbutton_pixel,
frame.ubutton, frame.ubutton_pixel);
- XClearWindow(blackbox->getXDisplay(), frame.stick_button);
+ XClearWindow(otk::OBDisplay::display, frame.stick_button);
- BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
- screen->getWindowStyle()->b_pic_unfocus);
+ otk::BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
+ screen->getWindowStyle()->b_pic_unfocus);
PixmapMask pm = screen->getWindowStyle()->stick_button;
if (pm.mask != None) {
- XSetClipMask(blackbox->getXDisplay(), pen.gc(), pm.mask);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+ XSetClipMask(otk::OBDisplay::display, pen.gc(), pm.mask);
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2);
- XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(),
+ XFillRectangle(otk::OBDisplay::display, frame.stick_button, pen.gc(),
(frame.button_w - pm.w)/2, (frame.button_w - pm.h)/2,
(frame.button_w + pm.w)/2, (frame.button_w + pm.h)/2);
- XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0 );
- XSetClipMask( blackbox->getXDisplay(), pen.gc(), None );
+ XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0 );
+ XSetClipMask( otk::OBDisplay::display, pen.gc(), None );
} else {
- XFillRectangle(blackbox->getXDisplay(), frame.stick_button, pen.gc(),
+ XFillRectangle(otk::OBDisplay::display, frame.stick_button, pen.gc(),
frame.button_w/2 - 1, frame.button_w/2 -1, 2, 2 );
}
}
show();
screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
if (isNormal()) {
- if (! blackbox->isStartup()) {
- XSync(blackbox->getXDisplay(), False); // make sure the frame is mapped
+ if (blackbox->state() != Openbox::State_Starting) {
+ XSync(otk::OBDisplay::display, False); // make sure the frame is mapped
if (screen->doFocusNew() || (isTransient() && getTransientFor() &&
getTransientFor()->isFocused())) {
setInputFocus();
int x, y, rx, ry;
Window c, r;
unsigned int m;
- XQueryPointer(blackbox->getXDisplay(), screen->getRootWindow(),
+ XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(),
&r, &c, &rx, &ry, &x, &y, &m);
beginMove(rx, ry);
}
XEvent ev;
ev.xreparent = *re;
- XPutBackEvent(blackbox->getXDisplay(), &ev);
+ XPutBackEvent(otk::OBDisplay::display, &ev);
screen->unmanageWindow(this, True);
}
setupDecor();
}
- Rect old_rect = frame.rect;
+ otk::Rect old_rect = frame.rect;
upsize();
createCloseButton();
if (decorations & Decor_Titlebar) {
positionButtons(True);
- XMapSubwindows(blackbox->getXDisplay(), frame.title);
+ XMapSubwindows(otk::OBDisplay::display, frame.title);
}
}
} else if (pe->atom == xatom->getAtom(XAtom::net_wm_strut)) {
} else if (frame.plate == be->window) {
screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
- XAllowEvents(blackbox->getXDisplay(), ReplayPointer, be->time);
+ XAllowEvents(otk::OBDisplay::display, ReplayPointer, be->time);
} else {
if (frame.title == be->window || frame.label == be->window) {
if (((be->time - lastButtonPressTime) <=
endResize();
} else if (re->window == frame.window) {
if (re->button == 2 && re->state == mod_mask)
- XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
+ XUngrabPointer(otk::OBDisplay::display, CurrentTime);
}
}
changing->endResize();
}
- XGrabPointer(blackbox->getXDisplay(), frame.window, False,
+ XGrabPointer(otk::OBDisplay::display, frame.window, False,
PointerMotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync,
None, blackbox->getMoveCursor(), CurrentTime);
blackbox->setChangingWindow(this);
if (! screen->doOpaqueMove()) {
- XGrabServer(blackbox->getXDisplay());
+ XGrabServer(otk::OBDisplay::display);
frame.changing = frame.rect;
screen->showPosition(frame.changing.x(), frame.changing.y());
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(),
frame.changing.x(),
frame.changing.y(),
configure(dx, dy, frame.rect.width(), frame.rect.height());
} else {
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(),
frame.changing.x(),
frame.changing.y(),
frame.changing.setPos(dx, dy);
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(),
frame.changing.x(),
frame.changing.y(),
screen->changeWorkspaceID(dest);
if (screen->doOpaqueMove())
- XGrabServer(blackbox->getXDisplay());
+ XGrabServer(otk::OBDisplay::display);
- XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
- XWarpPointer(blackbox->getXDisplay(), None,
+ XUngrabPointer(otk::OBDisplay::display, CurrentTime);
+ XWarpPointer(otk::OBDisplay::display, None,
screen->getRootWindow(), 0, 0, 0, 0,
dest_x, y_root);
- XGrabPointer(blackbox->getXDisplay(), frame.window, False,
+ XGrabPointer(otk::OBDisplay::display, frame.window, False,
PointerMotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync,
None, blackbox->getMoveCursor(), CurrentTime);
if (screen->doOpaqueMove())
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
if (focus)
setInputFocus();
const int snap_offset = screen->getSnapOffset();
// find the geomeetery where the moving window currently is
- const Rect &moving = screen->doOpaqueMove() ? frame.rect : frame.changing;
+ const otk::Rect &moving =
+ screen->doOpaqueMove() ? frame.rect : frame.changing;
// window corners
const int wleft = dx,
wbottom = dy + frame.rect.height() - 1;
if (snap_to_windows) {
- RectList rectlist;
+ otk::RectList rectlist;
Workspace *w = screen->getWorkspace(getWorkspaceNumber());
assert(w);
if (*st_it != this) // don't snap to ourself
rectlist.push_back( (*st_it)->frameRect() );
- RectList::const_iterator it, end = rectlist.end();
+ otk::RectList::const_iterator it, end = rectlist.end();
for (it = rectlist.begin(); it != end; ++it) {
bool snapped = False;
- const Rect &winrect = *it;
- Rect offsetrect;
+ const otk::Rect &winrect = *it;
+ otk::Rect offsetrect;
offsetrect.setCoords(winrect.left() - snap_offset,
winrect.top() - snap_offset,
winrect.right() + snap_offset,
}
if (snap_to_edges) {
- RectList rectlist;
+ otk::RectList rectlist;
// snap to the screen edges (and screen boundaries for xinerama)
#ifdef XINERAMA
#endif // XINERAMA
rectlist.push_back(screen->getRect());
- RectList::const_iterator it, end = rectlist.end();
+ otk::RectList::const_iterator it, end = rectlist.end();
for (it = rectlist.begin(); it != end; ++it) {
- const Rect &srect = *it;
- Rect offsetrect;
+ const otk::Rect &srect = *it;
+ otk::Rect offsetrect;
offsetrect.setCoords(srect.left() + snap_offset,
srect.top() + snap_offset,
srect.right() - snap_offset,
continue;
} else { // BScreen::WindowSnap
// if we're not in the rectangle then don't snap to it.
- if (! srect.intersects(Rect(wleft, wtop, frame.rect.width(),
- frame.rect.height())))
+ if (! srect.intersects(otk::Rect(wleft, wtop, frame.rect.width(),
+ frame.rect.height())))
continue;
}
* so we need to subtract 1 from changing_w/changing_h every where we
* draw the rubber band (for both moving and resizing)
*/
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(), frame.changing.x(), frame.changing.y(),
frame.changing.width() - 1, frame.changing.height() - 1);
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
configure(frame.changing.x(), frame.changing.y(),
frame.changing.width(), frame.changing.height());
}
screen->hideGeometry();
- XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
+ XUngrabPointer(otk::OBDisplay::display, CurrentTime);
// if there are any left over motions from the move, drop them now
- XSync(blackbox->getXDisplay(), false); // make sure we don't miss any
+ XSync(otk::OBDisplay::display, false); // make sure we don't miss any
XEvent e;
- while (XCheckTypedWindowEvent(blackbox->getXDisplay(), frame.window,
+ while (XCheckTypedWindowEvent(otk::OBDisplay::display, frame.window,
MotionNotify, &e));
}
return; // unreachable, for the compiler
}
- XGrabServer(blackbox->getXDisplay());
- XGrabPointer(blackbox->getXDisplay(), frame.window, False,
+ XGrabServer(otk::OBDisplay::display);
+ XGrabPointer(otk::OBDisplay::display, frame.window, False,
PointerMotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
constrain(anchor, &gw, &gh);
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(), frame.changing.x(), frame.changing.y(),
frame.changing.width() - 1, frame.changing.height() - 1);
assert(flags.resizing);
assert(blackbox->getChangingWindow() == this);
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(), frame.changing.x(), frame.changing.y(),
frame.changing.width() - 1, frame.changing.height() - 1);
constrain(anchor, &gw, &gh);
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(), frame.changing.x(), frame.changing.y(),
frame.changing.width() - 1, frame.changing.height() - 1);
assert(flags.resizing);
assert(blackbox->getChangingWindow() == this);
- XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ XDrawRectangle(otk::OBDisplay::display, screen->getRootWindow(),
screen->getOpGC(), frame.changing.x(), frame.changing.y(),
frame.changing.width() - 1, frame.changing.height() - 1);
- XUngrabServer(blackbox->getXDisplay());
+ XUngrabServer(otk::OBDisplay::display);
// unset maximized state after resized when fully maximized
if (flags.maximized == 1)
frame.changing.width(), frame.changing.height());
screen->hideGeometry();
- XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
+ XUngrabPointer(otk::OBDisplay::display, CurrentTime);
// if there are any left over motions from the resize, drop them now
- XSync(blackbox->getXDisplay(), false); // make sure we don't miss any
+ XSync(otk::OBDisplay::display, false); // make sure we don't miss any
XEvent e;
- while (XCheckTypedWindowEvent(blackbox->getXDisplay(), frame.window,
+ while (XCheckTypedWindowEvent(otk::OBDisplay::display, frame.window,
MotionNotify, &e));
}
XEvent e;
bool leave = False, inferior = False;
- while (XCheckTypedWindowEvent(blackbox->getXDisplay(), ce->window,
+ while (XCheckTypedWindowEvent(otk::OBDisplay::display, ce->window,
LeaveNotify, &e)) {
if (e.type == LeaveNotify && e.xcrossing.mode == NotifyNormal) {
leave = True;
bool BlackboxWindow::validateClient(void) const {
- XSync(blackbox->getXDisplay(), False);
+ XSync(otk::OBDisplay::display, False);
XEvent e;
- if (XCheckTypedWindowEvent(blackbox->getXDisplay(), client.window,
+ if (XCheckTypedWindowEvent(otk::OBDisplay::display, client.window,
DestroyNotify, &e) ||
- XCheckTypedWindowEvent(blackbox->getXDisplay(), client.window,
+ XCheckTypedWindowEvent(otk::OBDisplay::display, client.window,
UnmapNotify, &e)) {
- XPutBackEvent(blackbox->getXDisplay(), &e);
+ XPutBackEvent(otk::OBDisplay::display, &e);
return False;
}
void BlackboxWindow::restore(bool remap) {
- XChangeSaveSet(blackbox->getXDisplay(), client.window, SetModeDelete);
- XSelectInput(blackbox->getXDisplay(), client.window, NoEventMask);
- XSelectInput(blackbox->getXDisplay(), frame.plate, NoEventMask);
+ XChangeSaveSet(otk::OBDisplay::display, client.window, SetModeDelete);
+ XSelectInput(otk::OBDisplay::display, client.window, NoEventMask);
+ XSelectInput(otk::OBDisplay::display, frame.plate, NoEventMask);
// do not leave a shaded window as an icon unless it was an icon
if (flags.shaded && ! flags.iconic)
restoreGravity(client.rect);
- XUnmapWindow(blackbox->getXDisplay(), frame.window);
- XUnmapWindow(blackbox->getXDisplay(), client.window);
+ XUnmapWindow(otk::OBDisplay::display, frame.window);
+ XUnmapWindow(otk::OBDisplay::display, client.window);
- XSetWindowBorderWidth(blackbox->getXDisplay(), client.window, client.old_bw);
+ XSetWindowBorderWidth(otk::OBDisplay::display, client.window, client.old_bw);
XEvent ev;
- if (XCheckTypedWindowEvent(blackbox->getXDisplay(), client.window,
+ if (XCheckTypedWindowEvent(otk::OBDisplay::display, client.window,
ReparentNotify, &ev)) {
remap = True;
} else {
// according to the ICCCM - if the client doesn't reparent to
// root, then we have to do it for them
- XReparentWindow(blackbox->getXDisplay(), client.window,
+ XReparentWindow(otk::OBDisplay::display, client.window,
screen->getRootWindow(),
client.rect.x(), client.rect.y());
}
- if (remap) XMapWindow(blackbox->getXDisplay(), client.window);
+ if (remap) XMapWindow(otk::OBDisplay::display, client.window);
}
BWindowGroup::BWindowGroup(Blackbox *b, Window _group)
: blackbox(b), group(_group) {
XWindowAttributes wattrib;
- if (! XGetWindowAttributes(blackbox->getXDisplay(), group, &wattrib)) {
+ if (! XGetWindowAttributes(otk::OBDisplay::display, group, &wattrib)) {
// group window doesn't seem to exist anymore
delete this;
return;
}
- XSelectInput(blackbox->getXDisplay(), group,
+ XSelectInput(otk::OBDisplay::display, group,
PropertyChangeMask | FocusChangeMask | StructureNotifyMask);
blackbox->saveGroupSearch(group, this);
return ret;
}
+
+}
#include <string>
-#include "basedisplay.hh"
+#include "blackbox.hh"
#include "timer.hh"
#include "util.hh"
#define MwmDecorIconify (1l << 5)
#define MwmDecorMaximize (1l << 6)
+namespace ob {
+
// this structure only contains 3 elements... the Motif 2.0 structure contains
// 5... we only need the first 3... so that is all we will define
typedef struct MwmHints {
std::string title, icon_title;
- Rect rect;
+ otk::Rect rect;
Strut strut;
int old_bw; // client's borderwidth
* size and location of the box drawn while the window dimensions or
* location is being changed, ie. resized or moved
*/
- Rect changing;
+ otk::Rect changing;
- Rect rect; // frame geometry
+ otk::Rect rect; // frame geometry
Strut margin; // margins between the frame and client
int grab_x, grab_y; // where was the window when it was grabbed?
void redrawIconifyButton(bool pressed) const;
void redrawMaximizeButton(bool pressed) const;
void redrawStickyButton(bool pressed) const;
- void applyGravity(Rect &r);
- void restoreGravity(Rect &r);
+ void applyGravity(otk::Rect &r);
+ void restoreGravity(otk::Rect &r);
void setAllowedActions(void);
void setState(unsigned long new_state);
void upsize(void);
{ return blackbox_attrib.workspace; }
inline unsigned int getWindowNumber(void) const { return window_number; }
- inline const Rect &frameRect(void) const { return frame.rect; }
- inline const Rect &clientRect(void) const { return client.rect; }
+ inline const otk::Rect &frameRect(void) const { return frame.rect; }
+ inline const otk::Rect &clientRect(void) const { return client.rect; }
inline unsigned int getTitleHeight(void) const
{ return frame.title_h; }
virtual void timeout(void);
};
+}
#endif // __Window_hh
using std::string;
#include "blackbox.hh"
-#include "font.hh"
+#include "otk/font.hh"
+#include "otk/display.hh"
#include "screen.hh"
#include "util.hh"
#include "window.hh"
#include "workspace.hh"
#include "xatom.hh"
+namespace ob {
Workspace::Workspace(BScreen *scrn, unsigned int i) {
screen = scrn;
// pass focus to the next appropriate window
if ((w->isFocused() || w == lastfocus) &&
- ! screen->getBlackbox()->doShutdown()) {
+ screen->getBlackbox()->state() != Openbox::State_Exiting) {
focusFallback(w);
}
// sticky windows arent unmapped on a workspace change so we don't have ot
// map them, but sometimes on a restart, another app can unmap our sticky
// windows, so we map on startup always
- if (! bw->isStuck() || screen->getBlackbox()->isStartup())
+ if (! bw->isStuck() ||
+ screen->getBlackbox()->state() == Openbox::State_Starting)
bw->show();
}
}
/*
* Calculate free space available for window placement.
*/
-Workspace::rectList Workspace::calcSpace(const Rect &win,
+Workspace::rectList Workspace::calcSpace(const otk::Rect &win,
const rectList &spaces) const {
- Rect isect, extra;
+ otk::Rect isect, extra;
rectList result;
rectList::const_iterator siter, end = spaces.end();
for (siter = spaces.begin(); siter != end; ++siter) {
- const Rect &curr = *siter;
+ const otk::Rect &curr = *siter;
if(! win.intersects(curr)) {
result.push_back(curr);
}
-static bool rowRLBT(const Rect &first, const Rect &second) {
+static bool rowRLBT(const otk::Rect &first, const otk::Rect &second) {
if (first.bottom() == second.bottom())
return first.right() > second.right();
return first.bottom() > second.bottom();
}
-static bool rowRLTB(const Rect &first, const Rect &second) {
+static bool rowRLTB(const otk::Rect &first, const otk::Rect &second) {
if (first.y() == second.y())
return first.right() > second.right();
return first.y() < second.y();
}
-static bool rowLRBT(const Rect &first, const Rect &second) {
+static bool rowLRBT(const otk::Rect &first, const otk::Rect &second) {
if (first.bottom() == second.bottom())
return first.x() < second.x();
return first.bottom() > second.bottom();
}
-static bool rowLRTB(const Rect &first, const Rect &second) {
+static bool rowLRTB(const otk::Rect &first, const otk::Rect &second) {
if (first.y() == second.y())
return first.x() < second.x();
return first.y() < second.y();
}
-static bool colLRTB(const Rect &first, const Rect &second) {
+static bool colLRTB(const otk::Rect &first, const otk::Rect &second) {
if (first.x() == second.x())
return first.y() < second.y();
return first.x() < second.x();
}
-static bool colLRBT(const Rect &first, const Rect &second) {
+static bool colLRBT(const otk::Rect &first, const otk::Rect &second) {
if (first.x() == second.x())
return first.bottom() > second.bottom();
return first.x() < second.x();
}
-static bool colRLTB(const Rect &first, const Rect &second) {
+static bool colRLTB(const otk::Rect &first, const otk::Rect &second) {
if (first.right() == second.right())
return first.y() < second.y();
return first.right() > second.right();
}
-static bool colRLBT(const Rect &first, const Rect &second) {
+static bool colRLBT(const otk::Rect &first, const otk::Rect &second) {
if (first.right() == second.right())
return first.bottom() > second.bottom();
return first.right() > second.right();
}
-bool Workspace::smartPlacement(Rect& win) {
+bool Workspace::smartPlacement(otk::Rect& win) {
rectList spaces;
//initially the entire screen is free
} else
#endif // XINERAMA
{
- Rect r = screen->availableArea();
+ otk::Rect r = screen->availableArea();
r.setRect(r.x() + screen->getSnapOffset(),
r.y() + screen->getSnapOffset(),
r.width() - screen->getSnapOffset(),
//Find Free Spaces
BlackboxWindowList::const_iterator wit = windowList.begin(),
end = windowList.end();
- Rect tmp;
+ otk::Rect tmp;
for (; wit != end; ++wit) {
const BlackboxWindow* const curr = *wit;
return False;
//set new position based on the empty space found
- const Rect& where = *sit;
+ const otk::Rect& where = *sit;
win.setX(where.x());
win.setY(where.y());
}
-bool Workspace::underMousePlacement(Rect &win) {
+bool Workspace::underMousePlacement(otk::Rect &win) {
int x, y, rx, ry;
Window c, r;
unsigned int m;
- XQueryPointer(screen->getBlackbox()->getXDisplay(), screen->getRootWindow(),
+ XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(),
&r, &c, &rx, &ry, &x, &y, &m);
- Rect area;
+ otk::Rect area;
#ifdef XINERAMA
if (screen->isXineramaActive() &&
screen->getBlackbox()->doXineramaPlacement()) {
}
-bool Workspace::cascadePlacement(Rect &win, const int offset) {
- Rect area;
+bool Workspace::cascadePlacement(otk::Rect &win, const int offset) {
+ otk::Rect area;
#ifdef XINERAMA
if (screen->isXineramaActive() &&
void Workspace::placeWindow(BlackboxWindow *win) {
- Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height());
+ otk::Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height());
bool placed = False;
switch (screen->getPlacementPolicy()) {
win->configure(new_win.x(), new_win.y(), new_win.width(), new_win.height());
}
+
+}
#include "xatom.hh"
+namespace ob {
+
class BScreen;
class Workspace;
class BlackboxWindow;
void lowerTransients(const BlackboxWindow * const win,
StackVector::iterator &stack);
- typedef std::vector<Rect> rectList;
- rectList calcSpace(const Rect &win, const rectList &spaces) const;
+ typedef std::vector<otk::Rect> rectList;
+ rectList calcSpace(const otk::Rect &win, const rectList &spaces) const;
void placeWindow(BlackboxWindow *win);
- bool cascadePlacement(Rect& win, const int offset);
- bool smartPlacement(Rect& win);
- bool underMousePlacement(Rect& win);
+ bool cascadePlacement(otk::Rect& win, const int offset);
+ bool smartPlacement(otk::Rect& win);
+ bool underMousePlacement(otk::Rect& win);
public:
Workspace(BScreen *scrn, unsigned int i = 0);
void setName(const std::string& new_name);
};
+}
#endif // __Workspace_hh
#include "screen.hh"
#include "util.hh"
+namespace ob {
+
XAtom::XAtom(Display *d) {
_display = d;
/*
* Sets which atoms are supported for NETWM, by Openbox, on the root window.
*/
-void XAtom::setSupported(const ScreenInfo *screen) {
+void XAtom::setSupported(const otk::ScreenInfo *screen) {
Window root = screen->getRootWindow();
// create the netwm support window
SubstructureRedirectMask | SubstructureNotifyMask,
&e);
}
+
+}
#ifndef __XAtom_h
#define __XAtom_h
+extern "C" {
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <assert.h>
+}
#include <vector>
#include <string>
-class Blackbox;
-class ScreenInfo;
+#include "otk/screeninfo.hh"
+
+namespace ob {
class XAtom {
public:
// setup support on a screen, each screen should call this once in its
// constructor.
- void setSupported(const ScreenInfo *screen);
+ void setSupported(const otk::ScreenInfo *screen);
void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const;
void setValue(Window win, Atoms atom, Atoms type,
assert(ret != 0); return ret; }
};
+}
+
#endif // __XAtom_h