- 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);
-
- // we create the window.frame texture by hand because it exists only to
- // make the code cleaner and is not actually used for display
- 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 = otk::BTexture("solid flat", 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() == otk::BTexture::Parent_Relative)
- resource.wstyle.t_focus = resource.wstyle.f_focus;
- if (resource.wstyle.t_unfocus.texture() == otk::BTexture::Parent_Relative)
- resource.wstyle.t_unfocus = resource.wstyle.f_unfocus;
- if (resource.wstyle.h_focus.texture() == otk::BTexture::Parent_Relative)
- resource.wstyle.h_focus = resource.wstyle.f_focus;
- if (resource.wstyle.h_unfocus.texture() == otk::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->setWindowNumber(iconList.size());
-
- iconList.push_back(w);
-}
-
-
-void BScreen::removeIcon(BlackboxWindow *w) {
- if (! w) return;
-
- iconList.remove(w);
-
- BlackboxWindowList::iterator it = iconList.begin(),
- end = iconList.end();
- for (int i = 0; it != end; ++it)
- (*it)->setWindowNumber(i++);
-}
-
-
-BlackboxWindow *BScreen::getIcon(unsigned int index) {
- if (index < iconList.size()) {
- BlackboxWindowList::iterator it = iconList.begin();
- while (index-- > 0) // increment to index
- ++it;
- return *it;
- }
-
- return (BlackboxWindow *) 0;
-}
-
-
-unsigned int BScreen::addWorkspace(void) {
- Workspace *wkspc = new Workspace(this, workspacesList.size());
- workspacesList.push_back(wkspc);
- saveWorkspaces(getWorkspaceCount());
- saveWorkspaceNames();
-
- return workspacesList.size();
-}
-
-
-unsigned int BScreen::removeLastWorkspace(void) {
- if (workspacesList.size() == 1)
- return 1;
-
- Workspace *wkspc = workspacesList.back();
-
- if (current_workspace->getID() == wkspc->getID())
- changeWorkspaceID(current_workspace->getID() - 1);
-
- wkspc->removeAll();
-
- workspacesList.pop_back();
- delete wkspc;
-
- saveWorkspaces(getWorkspaceCount());
- saveWorkspaceNames();
-
- updateNetizenWorkspaceCount();
-
- return workspacesList.size();
-}
-
-
-void BScreen::changeWorkspaceID(unsigned int id) {
- if (! current_workspace || id == current_workspace->getID()) return;
-
- BlackboxWindow *focused = blackbox->getFocusedWindow();
- if (focused && focused->getScreen() == this) {
- assert(focused->isStuck() ||
- focused->getWorkspaceNumber() == current_workspace->getID());
-
- current_workspace->setLastFocusedWindow(focused);
- } else {
- // if no window had focus, no need to store a last focus
- current_workspace->setLastFocusedWindow((BlackboxWindow *) 0);
- }
-
- // when we switch workspaces, unfocus whatever was focused if it is going
- // to be unmapped
- if (focused && ! focused->isStuck())
- blackbox->setFocusedWindow((BlackboxWindow *) 0);
-
- current_workspace->hideAll();
-
- current_workspace = getWorkspace(id);
-
- xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
- XAtom::cardinal, id);
-
- current_workspace->showAll();
-
- int x, y, rx, ry;
- Window c, r;
- unsigned int m;
- BlackboxWindow *win = (BlackboxWindow *) 0;
- bool f = 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(otk::OBDisplay::display, getRootWindow(), &r, &c,
- &rx, &ry, &x, &y, &m) &&
- c != None) {
- if ( (win = blackbox->searchWindow(c)) )
- f = win->setInputFocus();
- }
-
- // If that fails, and we're doing focus_last, try to focus the last window.
- if (! f && resource.focus_last &&
- (win = current_workspace->getLastFocusedWindow()))
- f = win->setInputFocus();
-
- /*
- if we found a focus target, then we set the focused window explicitly
- because it is possible to switch off this workspace before the x server
- generates the FocusIn event for the window. if that happens, openbox would
- lose track of what window was the 'LastFocused' window on the workspace.
-
- if we did not find a focus target, then set the current focused window to
- nothing.
- */
- if (f)
- blackbox->setFocusedWindow(win);
- else
- blackbox->setFocusedWindow((BlackboxWindow *) 0);
-}
-
-
-/*
- * Set the _NET_CLIENT_LIST root window property.
- */
-void BScreen::updateClientList(void) {
- if (windowList.size() > 0) {
- Window *windows = new Window[windowList.size()];
- Window *win_it = windows;
- BlackboxWindowList::iterator it = windowList.begin();
- const BlackboxWindowList::iterator end = windowList.end();