// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-// Screen.cc for Blackbox - an X11 Window manager
-// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
-// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
#ifdef HAVE_CONFIG_H
#include "../config.h"
#include <string>
using std::string;
-#include "blackbox.hh"
-#include "font.hh"
-#include "gccache.hh"
-#include "image.hh"
#include "screen.hh"
-#include "util.hh"
-#include "window.hh"
+#include "otk/font.hh"
+#include "otk/gccache.hh"
+#include "otk/image.hh"
+#include "otk/assassin.hh"
+#include "otk/util.hh"
+#include "openbox.hh"
+#include "bbwindow.hh"
#include "workspace.hh"
-#include "util.hh"
-#include "xatom.hh"
#ifndef FONT_ELEMENT_SIZE
#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) + '.';
+ screenstr = "session.screen" + otk::itostring(scrn) + '.';
config = blackbox->getConfig();
xatom = blackbox->getXAtom();
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->setSupported(this); // set-up netwm support
+// xatom->setSupported(this); // set-up netwm support
#ifdef HAVE_GETPID
- xatom->setValue(getRootWindow(), XAtom::blackbox_pid, XAtom::cardinal,
+ xatom->setValue(getRootWindow(), otk::OBProperty::blackbox_pid,
+ otk::OBProperty::Atom_Cardinal,
(unsigned long) getpid());
#endif // HAVE_GETPID
unsigned long geometry[] = { getWidth(),
getHeight()};
- xatom->setValue(getRootWindow(), XAtom::net_desktop_geometry,
- XAtom::cardinal, geometry, 2);
+ xatom->set(getRootWindow(), otk::OBProperty::net_desktop_geometry,
+ otk::OBProperty::Atom_Cardinal, geometry, 2);
unsigned long viewport[] = {0,0};
- xatom->setValue(getRootWindow(), XAtom::net_desktop_viewport,
- XAtom::cardinal, viewport, 2);
+ xatom->set(getRootWindow(), otk::OBProperty::net_desktop_viewport,
+ otk::OBProperty::Atom_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(Openbox::instance->timerManager(),
+ this, True, blackbox->getColorsPerChannel(),
+ blackbox->getCacheLife(), blackbox->getCacheMax());
image_control->installRootColormap();
root_colormap_installed = True;
load_rc();
+
+ // XXX: ugh
+ resource.wstyle.setImageControl(image_control);
+ resource.wstyle.setScreenNumber(scrn);
LoadStyle();
XGCValues gcv;
- gcv.foreground = WhitePixel(blackbox->getXDisplay(), getScreenNumber())
- ^ BlackPixel(blackbox->getXDisplay(), getScreenNumber());
+ gcv.foreground = WhitePixel(otk::OBDisplay::display, getScreenNumber())
+ ^ BlackPixel(otk::OBDisplay::display, getScreenNumber());
gcv.function = GXxor;
gcv.subwindow_mode = IncludeInferiors;
- opGC = XCreateGC(blackbox->getXDisplay(), getRootWindow(),
+ opGC = XCreateGC(otk::OBDisplay::display, getRootWindow(),
GCForeground | GCFunction | GCSubwindowMode, &gcv);
const char *s = "0: 0000 x 0: 0000";
- geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
- geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
+ geom_w = resource.wstyle.font->measureString(s) + resource.wstyle.bevel_width * 2;
+ geom_h = resource.wstyle.font->height() + resource.wstyle.bevel_width * 2;
XSetWindowAttributes attrib;
unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder;
attrib.colormap = getColormap();
attrib.save_under = True;
- geom_window = XCreateWindow(blackbox->getXDisplay(), getRootWindow(),
- 0, 0, geom_w, geom_h, resource.border_width,
+ // XXX -- move this geom_* crap out of here
+
+ geom_window = XCreateWindow(otk::OBDisplay::display, getRootWindow(),
+ 0, 0, geom_w, geom_h, resource.wstyle.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) {
Workspace *wkspc = new Workspace(this, workspacesList.size());
workspacesList.push_back(wkspc);
}
+
+ // /GEOM_PIXMAP
+
saveWorkspaceNames();
updateNetizenWorkspaceCount();
current_workspace = workspacesList.front();
- xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
- XAtom::cardinal, 0); //first workspace
+ xatom->set(getRootWindow(), otk::OBProperty::net_current_desktop,
+ otk::OBProperty::Atom_Cardinal, 0); //first workspace
raiseWindows(0, 0); // this also initializes the empty stacking list
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 image_control;
- if (resource.wstyle.font)
- delete resource.wstyle.font;
-
-#ifdef BITMAPBUTTONS
- if (resource.wstyle.close_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
- if (resource.wstyle.max_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
- if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
- if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), 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;
-#endif // BITMAPBUTTONS
+ // delete style
- XFreeGC(blackbox->getXDisplay(), opGC);
+ XFreeGC(otk::OBDisplay::display, opGC);
}
+void BScreen::LoadStyle(void) {
+ otk::Configuration style_conf(False);
+
+ const char *sfile = blackbox->getStyleFilename();
+ if (sfile != NULL) {
+ style_conf.setFile(sfile);
+ if (! style_conf.load()) {
+ style_conf.setFile(DEFAULTSTYLE);
+ if (! style_conf.load())
+ style_conf.create(); // hardcoded default values will be used.
+ }
+ }
+
+ // merge in the rc file
+ style_conf.merge(config->file(), True);
+
+ resource.wstyle.load(style_conf);
+}
+
void BScreen::saveSloppyFocus(bool s) {
resource.sloppy_focus = s;
resource.col_direction = TopBottom;
if (config->getValue(screenstr + "workspaceNames", s)) {
- XAtom::StringVect workspaceNames;
+ otk::OBProperty::StringVect workspaceNames;
string::const_iterator it = s.begin(), end = s.end();
while(1) {
++it;
}
- xatom->setValue(getRootWindow(), XAtom::net_desktop_names, XAtom::utf8,
- workspaceNames);
+ xatom->set(getRootWindow(), otk::OBProperty::net_desktop_names,
+ otk::OBProperty::utf8, workspaceNames);
}
resource.sloppy_focus = true;
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;
+ geom_w = resource.wstyle.font->measureString(s) + resource.wstyle.bevel_width * 2;
+ geom_h = resource.wstyle.font->height() + resource.wstyle.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,
- resource.border_width);
- XSetWindowBorder(blackbox->getXDisplay(), geom_window,
- resource.border_color.pixel());
+ XSetWindowBorderWidth(otk::OBDisplay::display, geom_window,
+ resource.wstyle.border_width);
+ XSetWindowBorder(otk::OBDisplay::display, geom_window,
+ resource.wstyle.border_color.pixel());
typedef std::vector<int> SubList;
SubList remember_subs;
bw->reconfigure();
}
- image_control->timeout();
+ otk::BImageControl::timeout(image_control);
}
-void BScreen::LoadStyle(void) {
- Configuration style(False);
-
- const char *sfile = blackbox->getStyleFilename();
- if (sfile != NULL) {
- style.setFile(sfile);
- if (! style.load()) {
- style.setFile(DEFAULTSTYLE);
- if (! style.load())
- style.create(); // hardcoded default values will be used.
- }
- }
-
- // merge in the rc file
- style.merge(config->file(), True);
-
- string s;
-
- // load fonts/fontsets
- if (resource.wstyle.font)
- delete resource.wstyle.font;
-
- resource.wstyle.font = readDatabaseFont("window.", style);
-
- // load window config
- resource.wstyle.t_focus =
- readDatabaseTexture("window.title.focus", "white", style);
- resource.wstyle.t_unfocus =
- readDatabaseTexture("window.title.unfocus", "black", style);
- resource.wstyle.l_focus =
- readDatabaseTexture("window.label.focus", "white", style);
- resource.wstyle.l_unfocus =
- readDatabaseTexture("window.label.unfocus", "black", style);
- resource.wstyle.h_focus =
- readDatabaseTexture("window.handle.focus", "white", style);
- resource.wstyle.h_unfocus =
- readDatabaseTexture("window.handle.unfocus", "black", style);
- resource.wstyle.g_focus =
- readDatabaseTexture("window.grip.focus", "white", style);
- resource.wstyle.g_unfocus =
- readDatabaseTexture("window.grip.unfocus", "black", style);
- resource.wstyle.b_focus =
- readDatabaseTexture("window.button.focus", "white", style);
- resource.wstyle.b_unfocus =
- readDatabaseTexture("window.button.unfocus", "black", style);
- resource.wstyle.b_pressed =
- readDatabaseTexture("window.button.pressed", "black", style);
-
- //if neither of these can be found, we will use the previous resource
- resource.wstyle.b_pressed_focus =
- readDatabaseTexture("window.button.pressed.focus", "black", style, true);
- resource.wstyle.b_pressed_unfocus =
- readDatabaseTexture("window.button.pressed.unfocus", "black", style, true);
-
-#ifdef BITMAPBUTTONS
- if (resource.wstyle.close_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
- if (resource.wstyle.max_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
- if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
- if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.stick_button.mask);
-
- resource.wstyle.close_button.mask = resource.wstyle.max_button.mask =
- resource.wstyle.icon_button.mask =
- resource.wstyle.icon_button.mask = None;
-
- readDatabaseMask("window.button.close.mask", resource.wstyle.close_button,
- style);
- readDatabaseMask("window.button.max.mask", resource.wstyle.max_button,
- style);
- readDatabaseMask("window.button.icon.mask", resource.wstyle.icon_button,
- style);
- readDatabaseMask("window.button.stick.mask", resource.wstyle.stick_button,
- style);
-#endif // BITMAPBUTTONS
-
- // 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);
- 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.setColor(color);
-
- resource.wstyle.l_text_focus =
- readDatabaseColor("window.label.focus.textColor", "black", style);
- resource.wstyle.l_text_unfocus =
- readDatabaseColor("window.label.unfocus.textColor", "white", style);
- resource.wstyle.b_pic_focus =
- readDatabaseColor("window.button.focus.picColor", "black", style);
- resource.wstyle.b_pic_unfocus =
- readDatabaseColor("window.button.unfocus.picColor", "white", style);
-
- resource.wstyle.justify = LeftJustify;
- if (style.getValue("window.justify", s)) {
- if (s == "right" || s == "Right")
- resource.wstyle.justify = RightJustify;
- else if (s == "center" || s == "Center")
- resource.wstyle.justify = CenterJustify;
- }
-
- // sanity checks
- if (resource.wstyle.t_focus.texture() == BTexture::Parent_Relative)
- resource.wstyle.t_focus = resource.wstyle.f_focus;
- if (resource.wstyle.t_unfocus.texture() == BTexture::Parent_Relative)
- resource.wstyle.t_unfocus = resource.wstyle.f_unfocus;
- if (resource.wstyle.h_focus.texture() == BTexture::Parent_Relative)
- resource.wstyle.h_focus = resource.wstyle.f_focus;
- if (resource.wstyle.h_unfocus.texture() == BTexture::Parent_Relative)
- resource.wstyle.h_unfocus = resource.wstyle.f_unfocus;
-
- resource.border_color =
- readDatabaseColor("borderColor", "black", style);
-
- // load bevel, border and handle widths
- if (! style.getValue("handleWidth", resource.handle_width) ||
- resource.handle_width > (getWidth() / 2) || resource.handle_width == 0)
- resource.handle_width = 6;
-
- if (! style.getValue("borderWidth", resource.border_width))
- resource.border_width = 1;
-
- if (! style.getValue("bevelWidth", resource.bevel_width) ||
- resource.bevel_width > (getWidth() / 2) || resource.bevel_width == 0)
- resource.bevel_width = 3;
-
- if (! style.getValue("frameWidth", resource.frame_width) ||
- resource.frame_width > (getWidth() / 2))
- resource.frame_width = resource.bevel_width;
-
- if (style.getValue("rootCommand", s))
- bexec(s, displayString());
-}
-
void BScreen::addIcon(BlackboxWindow *w) {
if (! w) return;
- w->setWorkspace(BSENTINEL);
+ w->setWorkspace(otk::BSENTINEL);
w->setWindowNumber(iconList.size());
iconList.push_back(w);
current_workspace = getWorkspace(id);
- xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
- XAtom::cardinal, id);
+ xatom->set(getRootWindow(), otk::OBProperty::net_current_desktop,
+ otk::OBProperty::Atom_Cardinal, id);
current_workspace->showAll();
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)) )
const BlackboxWindowList::iterator end = windowList.end();
for (; it != end; ++it, ++win_it)
*win_it = (*it)->getClientWindow();
- xatom->setValue(getRootWindow(), XAtom::net_client_list, XAtom::window,
- windows, windowList.size());
+ xatom->set(getRootWindow(), otk::OBProperty::net_client_list,
+ otk::OBProperty::Atom_Window, windows, windowList.size());
delete [] windows;
} else
- xatom->setValue(getRootWindow(), XAtom::net_client_list, XAtom::window,
- 0, 0);
+ xatom->set(getRootWindow(), otk::OBProperty::net_client_list,
+ otk::OBProperty::Atom_Window, 0, 0);
updateStackingList();
}
end = stack_order.end();
for (; it != end; ++it, ++win_it)
*win_it = (*it)->getClientWindow();
- xatom->setValue(getRootWindow(), XAtom::net_client_list_stacking,
- XAtom::window, windows, stack_order.size());
+ xatom->set(getRootWindow(), otk::OBProperty::net_client_list_stacking,
+ otk::OBProperty::Atom_Window, windows, stack_order.size());
delete [] windows;
} else
- xatom->setValue(getRootWindow(), XAtom::net_client_list_stacking,
- XAtom::window, 0, 0);
+ xatom->set(getRootWindow(), otk::OBProperty::net_client_list_stacking,
+ otk::OBProperty::Atom_Window, 0, 0);
}
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());
+ xatom->set(getRootWindow(), otk::OBProperty::kde_net_system_tray_windows,
+ otk::OBProperty::Atom_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();
for (; it != end; ++it)
if (*it == window) {
systrayWindowList.erase(it);
- xatom->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows,
- XAtom::window,
- &systrayWindowList[0], systrayWindowList.size());
+ xatom->set(getRootWindow(),
+ otk::OBProperty::kde_net_system_tray_windows,
+ otk::OBProperty::Atom_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);
}
void BScreen::manageWindow(Window w) {
// is the window a KDE systray window?
Window systray;
- if (xatom->getValue(w, XAtom::kde_net_wm_system_tray_window_for,
- XAtom::window, systray) && systray != None) {
+ if (xatom->get(w, otk::OBProperty::kde_net_wm_system_tray_window_for,
+ otk::OBProperty::Atom_Window, &systray) &&
+ systray != None)
+ {
addSystrayWindow(w);
return;
}
// 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);
}
void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {
// is the window a KDE systray window?
Window systray;
- if (xatom->getValue(w->getClientWindow(),
- XAtom::kde_net_wm_system_tray_window_for,
- XAtom::window, systray) && systray != None) {
+ if (xatom->get(w->getClientWindow(),
+ otk::OBProperty::kde_net_wm_system_tray_window_for,
+ otk::OBProperty::Atom_Window, &systray) &&
+ systray != None)
+ {
removeSystrayWindow(w->getClientWindow());
return;
}
// Remove the modality so that its parent won't try to re-focus the window
if (w->isModal()) w->setModal(False);
- if (w->getWorkspaceNumber() != BSENTINEL &&
- w->getWindowNumber() != BSENTINEL) {
+ if (w->getWorkspaceNumber() != otk::BSENTINEL &&
+ w->getWindowNumber() != otk::BSENTINEL) {
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
if (w->isStuck()) {
for (unsigned int i = 0; i < getNumberOfWorkspaces(); ++i)
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();
dims[(i * 4) + 3] = area.height();
}
- xatom->setValue(getRootWindow(), XAtom::net_workarea, XAtom::cardinal,
- dims, 4 * workspacesList.size());
+ xatom->set(getRootWindow(), otk::OBProperty::net_workarea,
+ otk::OBProperty::Atom_Cardinal,
+ dims, 4 * workspacesList.size());
delete [] dims;
} else
- xatom->setValue(getRootWindow(), XAtom::net_workarea, XAtom::cardinal,
- 0, 0);
+ xatom->set(getRootWindow(), otk::OBProperty::net_workarea,
+ otk::OBProperty::Atom_Cardinal, 0, 0);
}
void BScreen::updateNetizenWorkspaceCount(void) {
- xatom->setValue(getRootWindow(), XAtom::net_number_of_desktops,
- XAtom::cardinal, workspacesList.size());
+ xatom->set(getRootWindow(), otk::OBProperty::net_number_of_desktops,
+ otk::OBProperty::Atom_Cardinal, workspacesList.size());
updateWorkArea();
}
Window f = ((blackbox->getFocusedWindow()) ?
blackbox->getFocusedWindow()->getClientWindow() : None);
- xatom->setValue(getRootWindow(), XAtom::net_active_window,
- XAtom::window, f);
+ xatom->set(getRootWindow(), otk::OBProperty::net_active_window,
+ otk::OBProperty::Atom_Window, f);
}
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;
bool ignore_sticky) {
if (! w) return;
- if (wkspc_id == BSENTINEL)
+ if (wkspc_id == otk::BSENTINEL)
wkspc_id = current_workspace->getID();
if (w->getWorkspaceNumber() == wkspc_id)
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,
+ resource.wstyle.bevel_width, resource.wstyle.bevel_width,
resource.wstyle.l_text_focus,
label);
}
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,
+ resource.wstyle.bevel_width, resource.wstyle.bevel_width,
resource.wstyle.l_text_focus,
label);
}
void BScreen::hideGeometry(void) {
if (geom_visible) {
- XUnmapWindow(blackbox->getXDisplay(), geom_window);
+ XUnmapWindow(otk::OBDisplay::display, geom_window);
geom_visible = False;
}
}
-void BScreen::addStrut(Strut *strut) {
+void BScreen::addStrut(otk::Strut *strut) {
strutList.push_back(strut);
}
-void BScreen::removeStrut(Strut *strut) {
+void BScreen::removeStrut(otk::Strut *strut) {
strutList.remove(strut);
}
-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
StrutList::const_iterator it = strutList.begin(), end = strutList.end();
for(; it != end; ++it) {
- Strut *strut = *it;
+ otk::Strut *strut = *it;
if (strut->left > current_left)
current_left = strut->left;
if (strut->top > current_top)
void BScreen::propertyNotifyEvent(const XPropertyEvent *pe) {
- if (pe->atom == xatom->getAtom(XAtom::net_desktop_names)) {
+ if (pe->atom == xatom->atom(otk::OBProperty::net_desktop_names)) {
// _NET_WM_DESKTOP_NAMES
WorkspaceList::iterator it = workspacesList.begin();
const WorkspaceList::iterator end = workspacesList.end();
std::mem_fun(&BlackboxWindow::grabButtons));
}
-#ifdef BITMAPBUTTONS
-void BScreen::readDatabaseMask(const string &rname, PixmapMask &pixmapMask,
- const Configuration &style) {
- string s;
- int hx, hy; //ignored
- int ret = BitmapOpenFailed; //default to failure.
-
- if (style.getValue(rname, s))
- {
- if (s[0] != '/' && s[0] != '~')
- {
- std::string xbmFile = std::string("~/.openbox/buttons/") + s;
- ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(),
- expandTilde(xbmFile).c_str(), &pixmapMask.w,
- &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
- } else
- ret = XReadBitmapFile(blackbox->getXDisplay(), getRootWindow(),
- expandTilde(s).c_str(), &pixmapMask.w,
- &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
-
- if (ret == BitmapSuccess)
- return;
- }
-
- pixmapMask.mask = None;
- pixmapMask.w = pixmapMask.h = 0;
-}
-#endif // BITMAPSUCCESS
-
-BTexture BScreen::readDatabaseTexture(const string &rname,
- const string &default_color,
- const Configuration &style,
- bool allowNoTexture) {
- BTexture texture;
- string s;
-
- if (style.getValue(rname, s))
- texture = BTexture(s);
- else if (allowNoTexture) //no default
- texture.setTexture(BTexture::NoTexture);
- else
- texture.setTexture(BTexture::Solid | BTexture::Flat);
-
- // associate this texture with this screen
- texture.setDisplay(getBaseDisplay(), getScreenNumber());
- texture.setImageControl(image_control);
-
- if (texture.texture() != BTexture::NoTexture) {
- texture.setColor(readDatabaseColor(rname + ".color", default_color,
- style));
- texture.setColorTo(readDatabaseColor(rname + ".colorTo", default_color,
- style));
- texture.setBorderColor(readDatabaseColor(rname + ".borderColor",
- default_color, style));
- }
-
- return texture;
-}
-
-
-BColor BScreen::readDatabaseColor(const string &rname,
- const string &default_color,
- const Configuration &style) {
- BColor color;
- string s;
- if (style.getValue(rname, s))
- color = BColor(s, getBaseDisplay(), getScreenNumber());
- else
- color = BColor(default_color, getBaseDisplay(), getScreenNumber());
- return color;
-}
-
-
-BFont *BScreen::readDatabaseFont(const string &rbasename,
- const Configuration &style) {
- string fontname;
-
- string s;
-
- int i;
- if (style.getValue(rbasename + "xft.font", s) &&
- style.getValue(rbasename + "xft.size", i)) {
- string family = s;
- bool bold = False;
- bool italic = False;
- bool dropShadow = False;
-
- if (style.getValue(rbasename + "xft.flags", s)) {
- if (s.find("bold") != string::npos)
- bold = True;
- if (s.find("italic") != string::npos)
- italic = True;
- if (s.find("shadow") != string::npos)
- dropShadow = True;
- }
-
- unsigned char offset = 1;
- if (style.getValue(rbasename + "xft.shadow.offset", s)) {
- offset = atoi(s.c_str()); //doesn't detect errors
- if (offset > CHAR_MAX)
- offset = 1;
- }
-
- unsigned char tint = 0x40;
- if (style.getValue(rbasename + "xft.shadow.tint", s)) {
- tint = atoi(s.c_str());
- }
-
-
- BFont *b = new BFont(blackbox->getXDisplay(), this, 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
}