2002-05-25 00:29:44 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-19 22:22:32 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2002-05-28 14:32:42 +00:00
|
|
|
#include "../config.h"
|
2002-07-19 22:22:32 +00:00
|
|
|
#endif // HAVE_CONFIG_H
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
extern "C" {
|
2002-04-11 03:20:38 +00:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
2002-07-21 23:58:09 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
# include <X11/extensions/Xinerama.h>
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#ifdef HAVE_STDLIB_H
|
2002-04-11 03:20:38 +00:00
|
|
|
# include <stdlib.h>
|
2002-04-16 06:25:00 +00:00
|
|
|
#endif // HAVE_STDLIB_H
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2002-04-11 03:20:38 +00:00
|
|
|
# include <string.h>
|
2002-04-16 06:25:00 +00:00
|
|
|
#endif // HAVE_STRING_H
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef HAVE_CTYPE_H
|
|
|
|
# include <ctype.h>
|
|
|
|
#endif // HAVE_CTYPE_H
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
# include <dirent.h>
|
|
|
|
#endif // HAVE_DIRENT_H
|
|
|
|
|
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
# include <locale.h>
|
|
|
|
#endif // HAVE_LOCALE_H
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif // HAVE_SYS_STAT_H
|
|
|
|
|
|
|
|
#ifdef HAVE_STDARG_H
|
|
|
|
# include <stdarg.h>
|
|
|
|
#endif // HAVE_STDARG_H
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-06-01 17:54:32 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
2002-06-01 17:54:32 +00:00
|
|
|
#include <string>
|
2002-05-25 00:29:44 +00:00
|
|
|
using std::string;
|
|
|
|
|
2002-11-10 10:22:47 +00:00
|
|
|
#include "bbscreen.hh"
|
2002-11-03 11:46:05 +00:00
|
|
|
#include "otk/font.hh"
|
|
|
|
#include "otk/gccache.hh"
|
|
|
|
#include "otk/image.hh"
|
|
|
|
#include "otk/assassin.hh"
|
2002-11-06 13:57:54 +00:00
|
|
|
#include "otk/util.hh"
|
2002-11-03 11:46:05 +00:00
|
|
|
#include "openbox.hh"
|
2002-11-04 09:40:56 +00:00
|
|
|
#include "bbwindow.hh"
|
2002-10-31 06:54:56 +00:00
|
|
|
#include "workspace.hh"
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
#ifndef FONT_ELEMENT_SIZE
|
|
|
|
#define FONT_ELEMENT_SIZE 50
|
|
|
|
#endif // FONT_ELEMENT_SIZE
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
namespace ob {
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
static bool running = True;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
static int anotherWMRunning(Display *display, XErrorEvent *) {
|
2002-10-31 08:42:45 +00:00
|
|
|
fprintf(stderr,
|
2002-05-25 00:29:44 +00:00
|
|
|
"BScreen::BScreen: an error occured while querying the X server.\n"
|
2002-10-31 08:42:45 +00:00
|
|
|
" another window manager already running on display %s.\n",
|
2002-04-11 03:20:38 +00:00
|
|
|
DisplayString(display));
|
|
|
|
|
|
|
|
running = False;
|
|
|
|
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
2002-05-25 00:29:44 +00:00
|
|
|
blackbox = bb;
|
2002-11-06 13:57:54 +00:00
|
|
|
screenstr = "session.screen" + otk::itostring(scrn) + '.';
|
2002-05-26 20:25:38 +00:00
|
|
|
config = blackbox->getConfig();
|
2002-05-28 14:32:42 +00:00
|
|
|
xatom = blackbox->getXAtom();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
|
2002-05-25 00:29:44 +00:00
|
|
|
SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
|
2002-11-03 11:46:05 +00:00
|
|
|
XSelectInput(otk::OBDisplay::display, getRootWindow(), event_mask);
|
|
|
|
XSync(otk::OBDisplay::display, False);
|
2002-04-11 03:20:38 +00:00
|
|
|
XSetErrorHandler((XErrorHandler) old);
|
|
|
|
|
|
|
|
managed = running;
|
|
|
|
if (! managed) return;
|
|
|
|
|
2002-10-31 08:42:45 +00:00
|
|
|
fprintf(stderr, "BScreen::BScreen: managing screen %d "
|
|
|
|
"using visual 0x%lx, depth %d\n",
|
2002-05-16 22:35:59 +00:00
|
|
|
getScreenNumber(), XVisualIDFromVisual(getVisual()),
|
2002-04-11 03:20:38 +00:00
|
|
|
getDepth());
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
resource.wstyle.font = (otk::BFont *) 0;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
|
2002-11-05 09:13:46 +00:00
|
|
|
// xatom->setSupported(this); // set-up netwm support
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef HAVE_GETPID
|
2002-11-06 08:06:54 +00:00
|
|
|
xatom->setValue(getRootWindow(), otk::OBProperty::blackbox_pid,
|
|
|
|
otk::OBProperty::Atom_Cardinal,
|
2002-05-28 14:32:42 +00:00
|
|
|
(unsigned long) getpid());
|
2002-04-11 03:20:38 +00:00
|
|
|
#endif // HAVE_GETPID
|
2002-06-21 20:40:14 +00:00
|
|
|
unsigned long geometry[] = { getWidth(),
|
|
|
|
getHeight()};
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_desktop_geometry,
|
|
|
|
otk::OBProperty::Atom_Cardinal, geometry, 2);
|
2002-06-21 20:40:14 +00:00
|
|
|
unsigned long viewport[] = {0,0};
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_desktop_viewport,
|
|
|
|
otk::OBProperty::Atom_Cardinal, viewport, 2);
|
2002-06-21 20:40:14 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XDefineCursor(otk::OBDisplay::display, getRootWindow(),
|
2002-05-25 00:29:44 +00:00
|
|
|
blackbox->getSessionCursor());
|
|
|
|
|
2002-07-21 23:58:09 +00:00
|
|
|
updateAvailableArea();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
image_control =
|
2002-11-03 14:29:34 +00:00
|
|
|
new otk::BImageControl(Openbox::instance->timerManager(),
|
|
|
|
this, True, blackbox->getColorsPerChannel(),
|
2002-11-03 11:46:05 +00:00
|
|
|
blackbox->getCacheLife(), blackbox->getCacheMax());
|
2002-04-11 03:20:38 +00:00
|
|
|
image_control->installRootColormap();
|
|
|
|
root_colormap_installed = True;
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
load_rc();
|
2002-11-06 13:57:54 +00:00
|
|
|
|
|
|
|
// XXX: ugh
|
|
|
|
resource.wstyle.setImageControl(image_control);
|
2002-04-11 03:20:38 +00:00
|
|
|
LoadStyle();
|
|
|
|
|
|
|
|
XGCValues gcv;
|
2002-11-03 11:46:05 +00:00
|
|
|
gcv.foreground = WhitePixel(otk::OBDisplay::display, getScreenNumber())
|
|
|
|
^ BlackPixel(otk::OBDisplay::display, getScreenNumber());
|
2002-04-11 03:20:38 +00:00
|
|
|
gcv.function = GXxor;
|
|
|
|
gcv.subwindow_mode = IncludeInferiors;
|
2002-11-03 11:46:05 +00:00
|
|
|
opGC = XCreateGC(otk::OBDisplay::display, getRootWindow(),
|
2002-04-11 03:20:38 +00:00
|
|
|
GCForeground | GCFunction | GCSubwindowMode, &gcv);
|
|
|
|
|
2002-10-31 08:42:45 +00:00
|
|
|
const char *s = "0: 0000 x 0: 0000";
|
2002-11-06 13:57:54 +00:00
|
|
|
geom_w = resource.wstyle.font->measureString(s) + resource.wstyle.bevel_width * 2;
|
|
|
|
geom_h = resource.wstyle.font->height() + resource.wstyle.bevel_width * 2;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder;
|
2002-05-25 00:29:44 +00:00
|
|
|
attrib.border_pixel = getBorderColor()->pixel();
|
2002-04-11 03:20:38 +00:00
|
|
|
attrib.colormap = getColormap();
|
|
|
|
attrib.save_under = True;
|
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
// XXX -- move this geom_* crap out of here
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
geom_window = XCreateWindow(otk::OBDisplay::display, getRootWindow(),
|
2002-11-06 13:57:54 +00:00
|
|
|
0, 0, geom_w, geom_h, resource.wstyle.border_width,
|
2002-05-25 00:29:44 +00:00
|
|
|
getDepth(), InputOutput, getVisual(),
|
|
|
|
mask, &attrib);
|
2002-04-11 03:20:38 +00:00
|
|
|
geom_visible = False;
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
otk::BTexture* texture = &(resource.wstyle.l_focus);
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
|
2002-05-25 15:46:08 +00:00
|
|
|
if (geom_pixmap == ParentRelative) {
|
|
|
|
texture = &(resource.wstyle.t_focus);
|
|
|
|
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
|
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
if (! geom_pixmap)
|
2002-11-03 11:46:05 +00:00
|
|
|
XSetWindowBackground(otk::OBDisplay::display, geom_window,
|
2002-05-25 00:29:44 +00:00
|
|
|
texture->color().pixel());
|
|
|
|
else
|
2002-11-03 11:46:05 +00:00
|
|
|
XSetWindowBackgroundPixmap(otk::OBDisplay::display,
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_window, geom_pixmap);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-22 16:15:39 +00:00
|
|
|
if (resource.workspaces > 0) {
|
2002-05-25 00:29:44 +00:00
|
|
|
for (unsigned int i = 0; i < resource.workspaces; ++i) {
|
2002-07-14 20:54:03 +00:00
|
|
|
Workspace *wkspc = new Workspace(this, workspacesList.size());
|
2002-05-12 09:15:09 +00:00
|
|
|
workspacesList.push_back(wkspc);
|
2002-07-14 20:54:03 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-07-14 20:54:03 +00:00
|
|
|
Workspace *wkspc = new Workspace(this, workspacesList.size());
|
2002-05-12 09:15:09 +00:00
|
|
|
workspacesList.push_back(wkspc);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-11-06 13:57:54 +00:00
|
|
|
|
|
|
|
// /GEOM_PIXMAP
|
|
|
|
|
2002-05-26 20:51:12 +00:00
|
|
|
saveWorkspaceNames();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-30 06:51:43 +00:00
|
|
|
updateNetizenWorkspaceCount();
|
|
|
|
|
2002-05-12 09:15:09 +00:00
|
|
|
current_workspace = workspacesList.front();
|
2002-05-30 06:51:43 +00:00
|
|
|
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_current_desktop,
|
|
|
|
otk::OBProperty::Atom_Cardinal, 0); //first workspace
|
2002-05-30 06:51:43 +00:00
|
|
|
|
2002-06-21 20:40:14 +00:00
|
|
|
raiseWindows(0, 0); // this also initializes the empty stacking list
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-09 01:22:16 +00:00
|
|
|
updateClientList(); // initialize the client lists, which will be empty
|
2002-05-25 00:29:44 +00:00
|
|
|
updateAvailableArea();
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
changeWorkspaceID(0);
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
unsigned int i, j, nchild;
|
2002-04-11 03:20:38 +00:00
|
|
|
Window r, p, *children;
|
2002-11-03 11:46:05 +00:00
|
|
|
XQueryTree(otk::OBDisplay::display, getRootWindow(), &r, &p,
|
2002-05-16 22:35:59 +00:00
|
|
|
&children, &nchild);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
// preen the window list of all icon windows... for better dockapp support
|
2002-05-25 00:29:44 +00:00
|
|
|
for (i = 0; i < nchild; i++) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (children[i] == None) continue;
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XWMHints *wmhints = XGetWMHints(otk::OBDisplay::display,
|
2002-05-16 22:35:59 +00:00
|
|
|
children[i]);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
if (wmhints) {
|
|
|
|
if ((wmhints->flags & IconWindowHint) &&
|
2002-05-25 00:29:44 +00:00
|
|
|
(wmhints->icon_window != children[i])) {
|
|
|
|
for (j = 0; j < nchild; j++) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (children[j] == wmhints->icon_window) {
|
|
|
|
children[j] = None;
|
|
|
|
break;
|
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XFree(wmhints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// manage shown windows
|
2002-05-25 00:29:44 +00:00
|
|
|
for (i = 0; i < nchild; ++i) {
|
2002-07-26 08:37:15 +00:00
|
|
|
if (children[i] == None || ! blackbox->validateWindow(children[i]))
|
2002-04-11 03:20:38 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
XWindowAttributes attrib;
|
2002-11-03 11:46:05 +00:00
|
|
|
if (XGetWindowAttributes(otk::OBDisplay::display, children[i], &attrib)) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (attrib.override_redirect) continue;
|
|
|
|
|
|
|
|
if (attrib.map_state != IsUnmapped) {
|
2002-05-25 00:29:44 +00:00
|
|
|
manageWindow(children[i]);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(children);
|
2002-05-25 00:29:44 +00:00
|
|
|
|
|
|
|
// call this again just in case a window we found updates the Strut list
|
|
|
|
updateAvailableArea();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BScreen::~BScreen(void) {
|
|
|
|
if (! managed) return;
|
|
|
|
|
|
|
|
if (geom_pixmap != None)
|
|
|
|
image_control->removeImage(geom_pixmap);
|
|
|
|
|
|
|
|
if (geom_window != None)
|
2002-11-03 11:46:05 +00:00
|
|
|
XDestroyWindow(otk::OBDisplay::display, geom_window);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-12 09:15:09 +00:00
|
|
|
std::for_each(workspacesList.begin(), workspacesList.end(),
|
2002-11-03 11:46:05 +00:00
|
|
|
otk::PointerAssassin());
|
2002-05-25 00:29:44 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
std::for_each(iconList.begin(), iconList.end(), otk::PointerAssassin());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-11 00:41:56 +00:00
|
|
|
while (! systrayWindowList.empty())
|
|
|
|
removeSystrayWindow(systrayWindowList[0]);
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
delete image_control;
|
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
// delete style
|
2002-09-14 03:44:44 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XFreeGC(otk::OBDisplay::display, opGC);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-04-27 19:25:20 +00:00
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
void BScreen::saveSloppyFocus(bool s) {
|
|
|
|
resource.sloppy_focus = s;
|
|
|
|
|
|
|
|
string fmodel;
|
|
|
|
if (resource.sloppy_focus) {
|
|
|
|
fmodel = "SloppyFocus";
|
|
|
|
if (resource.auto_raise) fmodel += " AutoRaise";
|
|
|
|
if (resource.click_raise) fmodel += " ClickRaise";
|
|
|
|
} else {
|
|
|
|
fmodel = "ClickToFocus";
|
|
|
|
}
|
|
|
|
config->setValue(screenstr + "focusModel", fmodel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveAutoRaise(bool a) {
|
|
|
|
resource.auto_raise = a;
|
|
|
|
saveSloppyFocus(resource.sloppy_focus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveClickRaise(bool c) {
|
|
|
|
resource.click_raise = c;
|
|
|
|
saveSloppyFocus(resource.sloppy_focus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveImageDither(bool d) {
|
|
|
|
image_control->setDither(d);
|
|
|
|
config->setValue(screenstr + "imageDither", doImageDither());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveOpaqueMove(bool o) {
|
|
|
|
resource.opaque_move = o;
|
|
|
|
config->setValue(screenstr + "opaqueMove", resource.opaque_move);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveFullMax(bool f) {
|
|
|
|
resource.full_max = f;
|
|
|
|
config->setValue(screenstr + "fullMaximization", resource.full_max);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveFocusNew(bool f) {
|
|
|
|
resource.focus_new = f;
|
|
|
|
config->setValue(screenstr + "focusNewWindows", resource.focus_new);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveFocusLast(bool f) {
|
|
|
|
resource.focus_last = f;
|
|
|
|
config->setValue(screenstr + "focusLastWindow", resource.focus_last);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-08 04:40:34 +00:00
|
|
|
void BScreen::saveAAFonts(bool f) {
|
|
|
|
resource.aa_fonts = f;
|
|
|
|
config->setValue(screenstr + "antialiasFonts", resource.aa_fonts);
|
2002-10-01 01:59:09 +00:00
|
|
|
reconfigure();
|
2002-07-08 04:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-06 16:14:55 +00:00
|
|
|
void BScreen::saveShadowFonts(bool f) {
|
|
|
|
resource.shadow_fonts = f;
|
|
|
|
config->setValue(screenstr + "dropShadowFonts", resource.shadow_fonts);
|
2002-10-01 01:59:09 +00:00
|
|
|
reconfigure();
|
2002-09-06 16:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 19:02:47 +00:00
|
|
|
void BScreen::saveWindowToEdgeSnap(int s) {
|
|
|
|
resource.snap_to_edges = s;
|
|
|
|
|
|
|
|
const char *snap;
|
|
|
|
switch (resource.snap_to_edges) {
|
|
|
|
case WindowNoSnap: snap = "NoSnap"; break;
|
|
|
|
case WindowResistance: snap = "Resistance"; break;
|
|
|
|
case WindowSnap: default: snap = "Snap"; break;
|
|
|
|
}
|
|
|
|
config->setValue(screenstr + "windowToEdgeSnap", snap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveWindowToWindowSnap(int s) {
|
|
|
|
resource.snap_to_windows = s;
|
|
|
|
|
|
|
|
const char *snap;
|
2002-08-02 20:56:25 +00:00
|
|
|
switch (resource.snap_to_windows) {
|
2002-08-02 19:02:47 +00:00
|
|
|
case WindowNoSnap: snap = "NoSnap"; break;
|
|
|
|
case WindowResistance: snap = "Resistance"; break;
|
|
|
|
case WindowSnap: default: snap = "Snap"; break;
|
|
|
|
}
|
|
|
|
config->setValue(screenstr + "windowToWindowSnap", snap);
|
2002-06-07 00:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-09 06:09:10 +00:00
|
|
|
void BScreen::saveResizeZones(unsigned int z) {
|
|
|
|
resource.resize_zones = z;
|
|
|
|
config->setValue(screenstr + "resizeZones", resource.resize_zones);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-07 00:24:02 +00:00
|
|
|
void BScreen::saveWindowCornerSnap(bool s) {
|
|
|
|
resource.window_corner_snap = s;
|
|
|
|
config->setValue(screenstr + "windowCornerSnap",
|
|
|
|
resource.window_corner_snap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
void BScreen::saveWorkspaces(unsigned int w) {
|
|
|
|
resource.workspaces = w;
|
|
|
|
config->setValue(screenstr + "workspaces", resource.workspaces);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::savePlacementPolicy(int p) {
|
|
|
|
resource.placement_policy = p;
|
|
|
|
const char *placement;
|
|
|
|
switch (resource.placement_policy) {
|
|
|
|
case CascadePlacement: placement = "CascadePlacement"; break;
|
2002-07-16 05:00:09 +00:00
|
|
|
case UnderMousePlacement: placement = "UnderMousePlacement"; break;
|
|
|
|
case ClickMousePlacement: placement = "ClickMousePlacement"; break;
|
2002-05-26 20:25:38 +00:00
|
|
|
case ColSmartPlacement: placement = "ColSmartPlacement"; break;
|
|
|
|
case RowSmartPlacement: default: placement = "RowSmartPlacement"; break;
|
|
|
|
}
|
|
|
|
config->setValue(screenstr + "windowPlacement", placement);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 19:02:47 +00:00
|
|
|
void BScreen::saveResistanceSize(int s) {
|
|
|
|
resource.resistance_size = s;
|
|
|
|
config->setValue(screenstr + "resistanceSize",
|
|
|
|
resource.resistance_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveSnapThreshold(int t) {
|
|
|
|
resource.snap_threshold = t;
|
2002-05-26 20:25:38 +00:00
|
|
|
config->setValue(screenstr + "edgeSnapThreshold",
|
2002-08-02 19:02:47 +00:00
|
|
|
resource.snap_threshold);
|
2002-05-26 20:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 21:07:17 +00:00
|
|
|
void BScreen::saveSnapOffset(int t) {
|
|
|
|
resource.snap_offset = t;
|
|
|
|
config->setValue(screenstr + "edgeSnapOffset",
|
|
|
|
resource.snap_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
void BScreen::saveRowPlacementDirection(int d) {
|
|
|
|
resource.row_direction = d;
|
|
|
|
config->setValue(screenstr + "rowPlacementDirection",
|
|
|
|
resource.row_direction == LeftRight ?
|
|
|
|
"LeftToRight" : "RightToLeft");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveColPlacementDirection(int d) {
|
|
|
|
resource.col_direction = d;
|
|
|
|
config->setValue(screenstr + "colPlacementDirection",
|
|
|
|
resource.col_direction == TopBottom ?
|
|
|
|
"TopToBottom" : "BottomToTop");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveStrftimeFormat(const std::string& format) {
|
|
|
|
resource.strftime_format = format;
|
|
|
|
config->setValue(screenstr + "strftimeFormat", resource.strftime_format);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::saveWorkspaceNames() {
|
2002-05-26 20:51:12 +00:00
|
|
|
string names;
|
2002-06-28 01:44:47 +00:00
|
|
|
|
2002-07-14 20:54:03 +00:00
|
|
|
for (unsigned int i = 0; i < workspacesList.size(); ++i) {
|
|
|
|
names += workspacesList[i]->getName();
|
|
|
|
if (i < workspacesList.size() - 1)
|
|
|
|
names += ',';
|
2002-05-26 20:51:12 +00:00
|
|
|
}
|
2002-07-14 20:54:03 +00:00
|
|
|
|
2002-05-26 20:51:12 +00:00
|
|
|
config->setValue(screenstr + "workspaceNames", names);
|
2002-05-26 20:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-16 02:18:16 +00:00
|
|
|
void BScreen::savePlaceIgnoreShaded(bool i) {
|
|
|
|
resource.ignore_shaded = i;
|
|
|
|
config->setValue(screenstr + "placementIgnoreShaded",
|
|
|
|
resource.ignore_shaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::savePlaceIgnoreMaximized(bool i) {
|
|
|
|
resource.ignore_maximized = i;
|
|
|
|
config->setValue(screenstr + "placementIgnoreMaximized",
|
|
|
|
resource.ignore_maximized);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-21 09:56:18 +00:00
|
|
|
void BScreen::saveAllowScrollLock(bool a) {
|
|
|
|
resource.allow_scroll_lock = a;
|
|
|
|
config->setValue(screenstr + "disableBindingsWithScrollLock",
|
|
|
|
resource.allow_scroll_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 04:22:42 +00:00
|
|
|
void BScreen::saveWorkspaceWarping(bool w) {
|
|
|
|
resource.workspace_warping = w;
|
|
|
|
config->setValue(screenstr + "workspaceWarping",
|
|
|
|
resource.workspace_warping);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-29 14:49:12 +00:00
|
|
|
void BScreen::saveRootScrollDirection(int d) {
|
|
|
|
resource.root_scroll = d;
|
|
|
|
const char *dir;
|
|
|
|
switch (resource.root_scroll) {
|
|
|
|
case NoScroll: dir = "None"; break;
|
|
|
|
case ReverseScroll: dir = "Reverse"; break;
|
|
|
|
case NormalScroll: default: dir = "Normal"; break;
|
|
|
|
}
|
|
|
|
config->setValue(screenstr + "rootScrollDirection", dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
void BScreen::save_rc(void) {
|
|
|
|
saveSloppyFocus(resource.sloppy_focus);
|
|
|
|
saveAutoRaise(resource.auto_raise);
|
|
|
|
saveImageDither(doImageDither());
|
2002-09-06 16:14:55 +00:00
|
|
|
saveShadowFonts(resource.shadow_fonts);
|
2002-07-08 04:40:34 +00:00
|
|
|
saveAAFonts(resource.aa_fonts);
|
2002-07-09 06:09:10 +00:00
|
|
|
saveResizeZones(resource.resize_zones);
|
2002-05-26 20:25:38 +00:00
|
|
|
saveOpaqueMove(resource.opaque_move);
|
|
|
|
saveFullMax(resource.full_max);
|
|
|
|
saveFocusNew(resource.focus_new);
|
|
|
|
saveFocusLast(resource.focus_last);
|
2002-08-02 19:02:47 +00:00
|
|
|
saveWindowToWindowSnap(resource.snap_to_windows);
|
|
|
|
saveWindowToEdgeSnap(resource.snap_to_edges);
|
2002-06-07 00:24:02 +00:00
|
|
|
saveWindowCornerSnap(resource.window_corner_snap);
|
2002-05-26 20:25:38 +00:00
|
|
|
saveWorkspaces(resource.workspaces);
|
|
|
|
savePlacementPolicy(resource.placement_policy);
|
2002-08-02 19:02:47 +00:00
|
|
|
saveSnapThreshold(resource.snap_threshold);
|
2002-08-02 21:07:17 +00:00
|
|
|
saveSnapOffset(resource.snap_offset);
|
2002-08-02 19:02:47 +00:00
|
|
|
saveResistanceSize(resource.resistance_size);
|
2002-05-26 20:25:38 +00:00
|
|
|
saveRowPlacementDirection(resource.row_direction);
|
|
|
|
saveColPlacementDirection(resource.col_direction);
|
|
|
|
saveStrftimeFormat(resource.strftime_format);
|
2002-07-16 02:18:16 +00:00
|
|
|
savePlaceIgnoreShaded(resource.ignore_shaded);
|
|
|
|
savePlaceIgnoreMaximized(resource.ignore_maximized);
|
2002-07-21 09:56:18 +00:00
|
|
|
saveAllowScrollLock(resource.allow_scroll_lock);
|
2002-07-23 04:22:42 +00:00
|
|
|
saveWorkspaceWarping(resource.workspace_warping);
|
2002-07-29 14:49:12 +00:00
|
|
|
saveRootScrollDirection(resource.root_scroll);
|
2002-05-26 20:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::load_rc(void) {
|
|
|
|
std::string s;
|
|
|
|
bool b;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "fullMaximization", resource.full_max))
|
|
|
|
resource.full_max = false;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "focusNewWindows", resource.focus_new))
|
|
|
|
resource.focus_new = false;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "focusLastWindow", resource.focus_last))
|
|
|
|
resource.focus_last = false;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "workspaces", resource.workspaces))
|
|
|
|
resource.workspaces = 1;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move))
|
|
|
|
resource.opaque_move = false;
|
2002-05-27 05:06:04 +00:00
|
|
|
|
2002-07-08 04:40:34 +00:00
|
|
|
if (! config->getValue(screenstr + "antialiasFonts", resource.aa_fonts))
|
|
|
|
resource.aa_fonts = true;
|
|
|
|
|
2002-10-01 01:59:09 +00:00
|
|
|
if (! resource.aa_fonts ||
|
|
|
|
! config->getValue(screenstr + "dropShadowFonts", resource.shadow_fonts))
|
|
|
|
resource.shadow_fonts = false;
|
|
|
|
|
2002-07-09 06:09:10 +00:00
|
|
|
if (! config->getValue(screenstr + "resizeZones", resource.resize_zones) ||
|
|
|
|
(resource.resize_zones != 1 && resource.resize_zones != 2 &&
|
|
|
|
resource.resize_zones != 4))
|
|
|
|
resource.resize_zones = 4;
|
|
|
|
|
2002-08-02 19:02:47 +00:00
|
|
|
resource.snap_to_windows = WindowResistance;
|
|
|
|
if (config->getValue(screenstr + "windowToWindowSnap", s)) {
|
|
|
|
if (s == "NoSnap")
|
|
|
|
resource.snap_to_windows = WindowNoSnap;
|
|
|
|
else if (s == "Snap")
|
|
|
|
resource.snap_to_windows = WindowSnap;
|
|
|
|
}
|
|
|
|
|
|
|
|
resource.snap_to_edges = WindowResistance;
|
|
|
|
if (config->getValue(screenstr + "windowToEdgeSnap", s)) {
|
|
|
|
if (s == "NoSnap")
|
|
|
|
resource.snap_to_edges = WindowNoSnap;
|
|
|
|
else if (s == "Snap")
|
|
|
|
resource.snap_to_edges = WindowSnap;
|
|
|
|
}
|
2002-06-07 00:24:02 +00:00
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "windowCornerSnap",
|
|
|
|
resource.window_corner_snap))
|
|
|
|
resource.window_corner_snap = true;
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
if (! config->getValue(screenstr + "imageDither", b))
|
|
|
|
b = true;
|
|
|
|
image_control->setDither(b);
|
|
|
|
|
2002-08-02 21:07:17 +00:00
|
|
|
if (! config->getValue(screenstr + "edgeSnapOffset",
|
|
|
|
resource.snap_offset))
|
|
|
|
resource.snap_offset = 0;
|
2002-08-03 17:05:09 +00:00
|
|
|
if (resource.snap_offset > 50) // sanity check, setting this huge would
|
|
|
|
resource.snap_offset = 50; // seriously suck.
|
2002-08-02 21:07:17 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
if (! config->getValue(screenstr + "edgeSnapThreshold",
|
2002-08-02 19:02:47 +00:00
|
|
|
resource.snap_threshold))
|
|
|
|
resource.snap_threshold = 4;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "resistanceSize",
|
|
|
|
resource.resistance_size))
|
2002-08-02 21:41:41 +00:00
|
|
|
resource.resistance_size = 18;
|
2002-05-26 20:25:38 +00:00
|
|
|
|
|
|
|
if (config->getValue(screenstr + "rowPlacementDirection", s) &&
|
|
|
|
s == "RightToLeft")
|
|
|
|
resource.row_direction = RightLeft;
|
|
|
|
else
|
|
|
|
resource.row_direction = LeftRight;
|
|
|
|
|
|
|
|
if (config->getValue(screenstr + "colPlacementDirection", s) &&
|
|
|
|
s == "BottomToTop")
|
|
|
|
resource.col_direction = BottomTop;
|
|
|
|
else
|
|
|
|
resource.col_direction = TopBottom;
|
|
|
|
|
|
|
|
if (config->getValue(screenstr + "workspaceNames", s)) {
|
2002-11-05 09:13:46 +00:00
|
|
|
otk::OBProperty::StringVect workspaceNames;
|
2002-07-19 06:47:27 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
string::const_iterator it = s.begin(), end = s.end();
|
|
|
|
while(1) {
|
|
|
|
string::const_iterator tmp = it; // current string.begin()
|
|
|
|
it = std::find(tmp, end, ','); // look for comma between tmp and end
|
2002-06-28 01:44:47 +00:00
|
|
|
workspaceNames.push_back(string(tmp, it)); // s[tmp:it]
|
2002-05-26 20:25:38 +00:00
|
|
|
if (it == end)
|
|
|
|
break;
|
|
|
|
++it;
|
|
|
|
}
|
2002-07-19 06:47:27 +00:00
|
|
|
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_desktop_names,
|
|
|
|
otk::OBProperty::utf8, workspaceNames);
|
2002-05-26 20:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource.sloppy_focus = true;
|
|
|
|
resource.auto_raise = false;
|
|
|
|
resource.click_raise = false;
|
|
|
|
if (config->getValue(screenstr + "focusModel", s)) {
|
|
|
|
if (s.find("ClickToFocus") != string::npos) {
|
|
|
|
resource.sloppy_focus = false;
|
|
|
|
} else {
|
|
|
|
// must be sloppy
|
|
|
|
if (s.find("AutoRaise") != string::npos)
|
|
|
|
resource.auto_raise = true;
|
|
|
|
if (s.find("ClickRaise") != string::npos)
|
|
|
|
resource.click_raise = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config->getValue(screenstr + "windowPlacement", s)) {
|
|
|
|
if (s == "CascadePlacement")
|
|
|
|
resource.placement_policy = CascadePlacement;
|
2002-07-16 05:00:09 +00:00
|
|
|
else if (s == "UnderMousePlacement")
|
|
|
|
resource.placement_policy = UnderMousePlacement;
|
|
|
|
else if (s == "ClickMousePlacement")
|
2002-07-16 08:00:59 +00:00
|
|
|
resource.placement_policy = ClickMousePlacement;
|
2002-05-26 20:25:38 +00:00
|
|
|
else if (s == "ColSmartPlacement")
|
|
|
|
resource.placement_policy = ColSmartPlacement;
|
|
|
|
else //if (s == "RowSmartPlacement")
|
|
|
|
resource.placement_policy = RowSmartPlacement;
|
|
|
|
} else
|
|
|
|
resource.placement_policy = RowSmartPlacement;
|
|
|
|
|
2002-07-16 02:18:16 +00:00
|
|
|
if (! config->getValue(screenstr + "strftimeFormat",
|
|
|
|
resource.strftime_format))
|
2002-05-26 20:25:38 +00:00
|
|
|
resource.strftime_format = "%I:%M %p";
|
2002-07-16 02:18:16 +00:00
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "placementIgnoreShaded",
|
|
|
|
resource.ignore_shaded))
|
|
|
|
resource.ignore_shaded = true;
|
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "placementIgnoreMaximized",
|
|
|
|
resource.ignore_maximized))
|
|
|
|
resource.ignore_maximized = true;
|
2002-07-21 09:56:18 +00:00
|
|
|
|
2002-07-29 14:49:12 +00:00
|
|
|
if (! config->getValue(screenstr + "disableBindingsWithScrollLock",
|
2002-07-23 04:22:42 +00:00
|
|
|
resource.allow_scroll_lock))
|
2002-07-29 14:49:12 +00:00
|
|
|
resource.allow_scroll_lock = false;
|
2002-07-23 04:22:42 +00:00
|
|
|
|
|
|
|
if (! config->getValue(screenstr + "workspaceWarping",
|
|
|
|
resource.workspace_warping))
|
|
|
|
resource.workspace_warping = false;
|
2002-07-29 14:49:12 +00:00
|
|
|
|
|
|
|
resource.root_scroll = NormalScroll;
|
|
|
|
if (config->getValue(screenstr + "rootScrollDirection", s)) {
|
|
|
|
if (s == "None")
|
|
|
|
resource.root_scroll = NoScroll;
|
|
|
|
else if (s == "Reverse")
|
|
|
|
resource.root_scroll = ReverseScroll;
|
|
|
|
}
|
2002-05-26 20:25:38 +00:00
|
|
|
}
|
2002-04-27 19:25:20 +00:00
|
|
|
|
|
|
|
|
2002-07-19 14:38:10 +00:00
|
|
|
void BScreen::changeWorkspaceCount(unsigned int new_count) {
|
|
|
|
assert(new_count > 0);
|
|
|
|
|
|
|
|
if (new_count < workspacesList.size()) {
|
|
|
|
// shrink
|
|
|
|
for (unsigned int i = workspacesList.size(); i > new_count; --i)
|
|
|
|
removeLastWorkspace();
|
|
|
|
// removeLast already sets the current workspace to the
|
|
|
|
// last available one.
|
|
|
|
} else if (new_count > workspacesList.size()) {
|
|
|
|
// grow
|
|
|
|
for(unsigned int i = workspacesList.size(); i < new_count; ++i)
|
|
|
|
addWorkspace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::reconfigure(void) {
|
2002-07-19 06:47:27 +00:00
|
|
|
// don't reconfigure while saving the initial rc file, it's a waste and it
|
|
|
|
// breaks somethings (workspace names)
|
2002-11-03 11:46:05 +00:00
|
|
|
if (blackbox->state() == Openbox::State_Starting) return;
|
2002-07-19 06:47:27 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
load_rc();
|
2002-05-25 00:29:44 +00:00
|
|
|
LoadStyle();
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-07-19 14:38:10 +00:00
|
|
|
// we need to do this explicitly, because just loading this value from the rc
|
|
|
|
// does nothing
|
|
|
|
changeWorkspaceCount(resource.workspaces);
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XGCValues gcv;
|
2002-11-03 11:46:05 +00:00
|
|
|
gcv.foreground = WhitePixel(otk::OBDisplay::display,
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreenNumber());
|
|
|
|
gcv.function = GXinvert;
|
|
|
|
gcv.subwindow_mode = IncludeInferiors;
|
2002-11-03 11:46:05 +00:00
|
|
|
XChangeGC(otk::OBDisplay::display, opGC,
|
2002-05-25 00:29:44 +00:00
|
|
|
GCForeground | GCFunction | GCSubwindowMode, &gcv);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-10-31 08:42:45 +00:00
|
|
|
const char *s = "0: 0000 x 0: 0000";
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
geom_w = resource.wstyle.font->measureString(s) + resource.wstyle.bevel_width * 2;
|
|
|
|
geom_h = resource.wstyle.font->height() + resource.wstyle.bevel_width * 2;
|
2002-05-25 00:29:44 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
otk::BTexture* texture = &(resource.wstyle.l_focus);
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
|
2002-05-25 15:46:08 +00:00
|
|
|
if (geom_pixmap == ParentRelative) {
|
|
|
|
texture = &(resource.wstyle.t_focus);
|
|
|
|
geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
|
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
if (! geom_pixmap)
|
2002-11-03 11:46:05 +00:00
|
|
|
XSetWindowBackground(otk::OBDisplay::display, geom_window,
|
2002-05-25 00:29:44 +00:00
|
|
|
texture->color().pixel());
|
|
|
|
else
|
2002-11-03 11:46:05 +00:00
|
|
|
XSetWindowBackgroundPixmap(otk::OBDisplay::display,
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_window, geom_pixmap);
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XSetWindowBorderWidth(otk::OBDisplay::display, geom_window,
|
2002-11-06 13:57:54 +00:00
|
|
|
resource.wstyle.border_width);
|
2002-11-03 11:46:05 +00:00
|
|
|
XSetWindowBorder(otk::OBDisplay::display, geom_window,
|
2002-11-06 13:57:54 +00:00
|
|
|
resource.wstyle.border_color.pixel());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-06-01 17:14:32 +00:00
|
|
|
typedef std::vector<int> SubList;
|
|
|
|
SubList remember_subs;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
raiseWindows(0, 0);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
std::for_each(workspacesList.begin(), workspacesList.end(),
|
|
|
|
std::mem_fun(&Workspace::reconfigure));
|
|
|
|
|
|
|
|
BlackboxWindowList::iterator iit = iconList.begin();
|
|
|
|
for (; iit != iconList.end(); ++iit) {
|
|
|
|
BlackboxWindow *bw = *iit;
|
|
|
|
if (bw->validateClient())
|
|
|
|
bw->reconfigure();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
|
2002-11-03 14:29:34 +00:00
|
|
|
otk::BImageControl::timeout(image_control);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::addIcon(BlackboxWindow *w) {
|
|
|
|
if (! w) return;
|
2002-04-17 08:30:55 +00:00
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
w->setWorkspace(otk::BSENTINEL);
|
2002-05-25 00:29:44 +00:00
|
|
|
w->setWindowNumber(iconList.size());
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
iconList.push_back(w);
|
2002-04-17 08:30:55 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::removeIcon(BlackboxWindow *w) {
|
|
|
|
if (! w) return;
|
2002-04-17 08:30:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
iconList.remove(w);
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
BlackboxWindowList::iterator it = iconList.begin(),
|
|
|
|
end = iconList.end();
|
|
|
|
for (int i = 0; it != end; ++it)
|
|
|
|
(*it)->setWindowNumber(i++);
|
2002-04-17 08:30:55 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
BlackboxWindow *BScreen::getIcon(unsigned int index) {
|
|
|
|
if (index < iconList.size()) {
|
|
|
|
BlackboxWindowList::iterator it = iconList.begin();
|
2002-08-07 00:24:58 +00:00
|
|
|
while (index-- > 0) // increment to index
|
|
|
|
++it;
|
2002-05-25 00:29:44 +00:00
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (BlackboxWindow *) 0;
|
2002-04-17 08:30:55 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
unsigned int BScreen::addWorkspace(void) {
|
|
|
|
Workspace *wkspc = new Workspace(this, workspacesList.size());
|
|
|
|
workspacesList.push_back(wkspc);
|
2002-05-29 09:11:41 +00:00
|
|
|
saveWorkspaces(getWorkspaceCount());
|
2002-07-14 20:54:03 +00:00
|
|
|
saveWorkspaceNames();
|
2002-04-17 08:30:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
return workspacesList.size();
|
2002-04-17 08:30:55 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
unsigned int BScreen::removeLastWorkspace(void) {
|
|
|
|
if (workspacesList.size() == 1)
|
|
|
|
return 1;
|
2002-04-17 08:30:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Workspace *wkspc = workspacesList.back();
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (current_workspace->getID() == wkspc->getID())
|
|
|
|
changeWorkspaceID(current_workspace->getID() - 1);
|
2002-04-17 08:30:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
wkspc->removeAll();
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
workspacesList.pop_back();
|
|
|
|
delete wkspc;
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-29 09:11:41 +00:00
|
|
|
saveWorkspaces(getWorkspaceCount());
|
2002-07-14 20:54:03 +00:00
|
|
|
saveWorkspaceNames();
|
2002-05-26 20:25:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
updateNetizenWorkspaceCount();
|
2002-04-20 18:13:55 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
return workspacesList.size();
|
2002-04-17 08:30:55 +00:00
|
|
|
}
|
|
|
|
|
2002-05-12 09:15:09 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::changeWorkspaceID(unsigned int id) {
|
2002-07-10 22:24:48 +00:00
|
|
|
if (! current_workspace || id == current_workspace->getID()) return;
|
|
|
|
|
2002-08-20 15:38:51 +00:00
|
|
|
BlackboxWindow *focused = blackbox->getFocusedWindow();
|
|
|
|
if (focused && focused->getScreen() == this) {
|
|
|
|
assert(focused->isStuck() ||
|
|
|
|
focused->getWorkspaceNumber() == current_workspace->getID());
|
2002-07-10 22:24:48 +00:00
|
|
|
|
2002-08-20 15:38:51 +00:00
|
|
|
current_workspace->setLastFocusedWindow(focused);
|
|
|
|
} else {
|
|
|
|
// if no window had focus, no need to store a last focus
|
|
|
|
current_workspace->setLastFocusedWindow((BlackboxWindow *) 0);
|
|
|
|
}
|
|
|
|
|
2002-08-24 08:09:35 +00:00
|
|
|
// when we switch workspaces, unfocus whatever was focused if it is going
|
|
|
|
// to be unmapped
|
|
|
|
if (focused && ! focused->isStuck())
|
|
|
|
blackbox->setFocusedWindow((BlackboxWindow *) 0);
|
2002-08-20 15:38:51 +00:00
|
|
|
|
|
|
|
current_workspace->hideAll();
|
2002-05-12 09:15:09 +00:00
|
|
|
|
2002-07-10 22:24:48 +00:00
|
|
|
current_workspace = getWorkspace(id);
|
2002-04-17 08:30:55 +00:00
|
|
|
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_current_desktop,
|
|
|
|
otk::OBProperty::Atom_Cardinal, id);
|
2002-05-30 06:51:43 +00:00
|
|
|
|
2002-08-20 15:38:51 +00:00
|
|
|
current_workspace->showAll();
|
|
|
|
|
2002-08-24 08:09:35 +00:00
|
|
|
int x, y, rx, ry;
|
|
|
|
Window c, r;
|
|
|
|
unsigned int m;
|
|
|
|
BlackboxWindow *win = (BlackboxWindow *) 0;
|
|
|
|
bool f = False;
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XSync(otk::OBDisplay::display, False);
|
2002-08-24 08:09:35 +00:00
|
|
|
|
|
|
|
// If sloppy focus and we can find the client window under the pointer,
|
|
|
|
// try to focus it.
|
|
|
|
if (resource.sloppy_focus &&
|
2002-11-03 11:46:05 +00:00
|
|
|
XQueryPointer(otk::OBDisplay::display, getRootWindow(), &r, &c,
|
2002-08-24 08:09:35 +00:00
|
|
|
&rx, &ry, &x, &y, &m) &&
|
|
|
|
c != None) {
|
2002-08-25 08:41:18 +00:00
|
|
|
if ( (win = blackbox->searchWindow(c)) )
|
2002-08-24 08:09:35 +00:00
|
|
|
f = win->setInputFocus();
|
2002-08-20 15:38:51 +00:00
|
|
|
}
|
|
|
|
|
2002-08-25 08:11:43 +00:00
|
|
|
// If that fails, and we're doing focus_last, try to focus the last window.
|
|
|
|
if (! f && resource.focus_last &&
|
2002-08-25 08:41:18 +00:00
|
|
|
(win = current_workspace->getLastFocusedWindow()))
|
2002-08-25 08:11:43 +00:00
|
|
|
f = win->setInputFocus();
|
2002-08-24 08:09:35 +00:00
|
|
|
|
2002-08-25 08:41:18 +00:00
|
|
|
/*
|
|
|
|
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);
|
2002-04-17 08:30:55 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-06-21 20:40:14 +00:00
|
|
|
/*
|
|
|
|
* 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();
|
|
|
|
for (; it != end; ++it, ++win_it)
|
|
|
|
*win_it = (*it)->getClientWindow();
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_client_list,
|
|
|
|
otk::OBProperty::Atom_Window, windows, windowList.size());
|
2002-06-21 20:40:14 +00:00
|
|
|
delete [] windows;
|
|
|
|
} else
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_client_list,
|
|
|
|
otk::OBProperty::Atom_Window, 0, 0);
|
2002-07-09 01:22:16 +00:00
|
|
|
|
|
|
|
updateStackingList();
|
2002-06-21 20:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the _NET_CLIENT_LIST_STACKING root window property.
|
|
|
|
*/
|
|
|
|
void BScreen::updateStackingList(void) {
|
|
|
|
|
|
|
|
BlackboxWindowList stack_order;
|
|
|
|
|
|
|
|
/*
|
2002-07-09 01:22:16 +00:00
|
|
|
* Get the stacking order from all of the workspaces.
|
2002-06-21 20:40:14 +00:00
|
|
|
* We start with the current workspace so that the sticky windows will be
|
|
|
|
* in the right order on the current workspace.
|
|
|
|
* XXX: Do we need to have sticky windows in the list once for each workspace?
|
|
|
|
*/
|
|
|
|
getCurrentWorkspace()->appendStackOrder(stack_order);
|
|
|
|
for (unsigned int i = 0; i < getWorkspaceCount(); ++i)
|
|
|
|
if (i != getCurrentWorkspaceID())
|
|
|
|
getWorkspace(i)->appendStackOrder(stack_order);
|
2002-07-09 01:22:16 +00:00
|
|
|
|
2002-06-21 20:40:14 +00:00
|
|
|
if (stack_order.size() > 0) {
|
|
|
|
// set the client list atoms
|
|
|
|
Window *windows = new Window[stack_order.size()];
|
|
|
|
Window *win_it = windows;
|
2002-07-09 01:22:16 +00:00
|
|
|
BlackboxWindowList::iterator it = stack_order.begin(),
|
|
|
|
end = stack_order.end();
|
2002-06-21 20:40:14 +00:00
|
|
|
for (; it != end; ++it, ++win_it)
|
|
|
|
*win_it = (*it)->getClientWindow();
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_client_list_stacking,
|
|
|
|
otk::OBProperty::Atom_Window, windows, stack_order.size());
|
2002-06-21 20:40:14 +00:00
|
|
|
delete [] windows;
|
|
|
|
} else
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_client_list_stacking,
|
|
|
|
otk::OBProperty::Atom_Window, 0, 0);
|
2002-06-21 20:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::addSystrayWindow(Window window) {
|
2002-11-03 11:46:05 +00:00
|
|
|
XGrabServer(otk::OBDisplay::display);
|
2002-08-24 05:49:22 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XSelectInput(otk::OBDisplay::display, window, StructureNotifyMask);
|
2002-06-21 20:40:14 +00:00
|
|
|
systrayWindowList.push_back(window);
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::kde_net_system_tray_windows,
|
|
|
|
otk::OBProperty::Atom_Window,
|
|
|
|
&systrayWindowList[0], systrayWindowList.size());
|
2002-06-21 20:40:14 +00:00
|
|
|
blackbox->saveSystrayWindowSearch(window, this);
|
2002-08-24 05:49:22 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XUngrabServer(otk::OBDisplay::display);
|
2002-06-21 20:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::removeSystrayWindow(Window window) {
|
2002-11-03 11:46:05 +00:00
|
|
|
XGrabServer(otk::OBDisplay::display);
|
2002-08-24 05:49:22 +00:00
|
|
|
|
2002-06-21 20:40:14 +00:00
|
|
|
WindowList::iterator it = systrayWindowList.begin();
|
|
|
|
const WindowList::iterator end = systrayWindowList.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
if (*it == window) {
|
|
|
|
systrayWindowList.erase(it);
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(),
|
|
|
|
otk::OBProperty::kde_net_system_tray_windows,
|
|
|
|
otk::OBProperty::Atom_Window,
|
|
|
|
&systrayWindowList[0], systrayWindowList.size());
|
2002-06-21 20:40:14 +00:00
|
|
|
blackbox->removeSystrayWindowSearch(window);
|
2002-11-03 11:46:05 +00:00
|
|
|
XSelectInput(otk::OBDisplay::display, window, NoEventMask);
|
2002-06-21 20:40:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-08-24 05:49:22 +00:00
|
|
|
|
|
|
|
assert(it != end); // not a systray window
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XUngrabServer(otk::OBDisplay::display);
|
2002-06-21 20:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::manageWindow(Window w) {
|
2002-07-16 08:00:59 +00:00
|
|
|
// is the window a KDE systray window?
|
|
|
|
Window systray;
|
2002-11-05 09:13:46 +00:00
|
|
|
if (xatom->get(w, otk::OBProperty::kde_net_wm_system_tray_window_for,
|
|
|
|
otk::OBProperty::Atom_Window, &systray) &&
|
|
|
|
systray != None)
|
|
|
|
{
|
2002-07-16 08:00:59 +00:00
|
|
|
addSystrayWindow(w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-07-26 08:37:15 +00:00
|
|
|
// is the window a docking app
|
2002-11-03 11:46:05 +00:00
|
|
|
XWMHints *wmhint = XGetWMHints(otk::OBDisplay::display, w);
|
2002-07-26 08:37:15 +00:00
|
|
|
if (wmhint && (wmhint->flags & StateHint) &&
|
|
|
|
wmhint->initial_state == WithdrawnState) {
|
2002-10-31 08:42:45 +00:00
|
|
|
//slit->addClient(w);
|
2002-07-26 08:37:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
new BlackboxWindow(blackbox, w, this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
BlackboxWindow *win = blackbox->searchWindow(w);
|
|
|
|
if (! win)
|
|
|
|
return;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-08-24 05:49:22 +00:00
|
|
|
if (win->isDesktop()) {
|
|
|
|
desktopWindowList.push_back(win->getFrameWindow());
|
2002-08-24 20:54:24 +00:00
|
|
|
} else { // if (win->isNormal()) {
|
2002-08-24 05:49:22 +00:00
|
|
|
// don't list desktop windows as managed windows
|
2002-07-16 08:00:59 +00:00
|
|
|
windowList.push_back(win);
|
|
|
|
updateClientList();
|
2002-08-09 00:44:35 +00:00
|
|
|
|
|
|
|
if (win->isTopmost())
|
|
|
|
specialWindowList.push_back(win->getFrameWindow());
|
2002-07-16 08:00:59 +00:00
|
|
|
}
|
2002-08-24 05:49:22 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XMapRequestEvent mre;
|
|
|
|
mre.window = w;
|
2002-11-03 11:46:05 +00:00
|
|
|
if (blackbox->state() == Openbox::State_Starting &&
|
|
|
|
win->isNormal())
|
|
|
|
win->restoreAttributes();
|
2002-05-25 00:29:44 +00:00
|
|
|
win->mapRequestEvent(&mre);
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {
|
2002-08-24 04:41:22 +00:00
|
|
|
// is the window a KDE systray window?
|
|
|
|
Window systray;
|
2002-11-05 09:13:46 +00:00
|
|
|
if (xatom->get(w->getClientWindow(),
|
|
|
|
otk::OBProperty::kde_net_wm_system_tray_window_for,
|
|
|
|
otk::OBProperty::Atom_Window, &systray) &&
|
|
|
|
systray != None)
|
|
|
|
{
|
2002-08-24 04:41:22 +00:00
|
|
|
removeSystrayWindow(w->getClientWindow());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
w->restore(remap);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-23 16:17:28 +00:00
|
|
|
// Remove the modality so that its parent won't try to re-focus the window
|
|
|
|
if (w->isModal()) w->setModal(False);
|
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
if (w->getWorkspaceNumber() != otk::BSENTINEL &&
|
|
|
|
w->getWindowNumber() != otk::BSENTINEL) {
|
2002-07-23 16:17:28 +00:00
|
|
|
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
|
2002-07-29 06:21:31 +00:00
|
|
|
if (w->isStuck()) {
|
|
|
|
for (unsigned int i = 0; i < getNumberOfWorkspaces(); ++i)
|
|
|
|
if (i != w->getWorkspaceNumber())
|
|
|
|
getWorkspace(i)->removeWindow(w, True);
|
|
|
|
}
|
|
|
|
} else if (w->isIconic())
|
2002-07-23 16:17:28 +00:00
|
|
|
removeIcon(w);
|
|
|
|
|
2002-08-24 05:49:22 +00:00
|
|
|
if (w->isDesktop()) {
|
|
|
|
WindowList::iterator it = desktopWindowList.begin();
|
|
|
|
const WindowList::iterator end = desktopWindowList.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
if (*it == w->getFrameWindow()) {
|
|
|
|
desktopWindowList.erase(it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert(it != end); // the window wasnt a desktop window?
|
2002-08-24 20:54:24 +00:00
|
|
|
} else { // if (w->isNormal()) {
|
2002-08-24 05:49:22 +00:00
|
|
|
// we don't list desktop windows as managed windows
|
2002-07-16 08:00:59 +00:00
|
|
|
windowList.remove(w);
|
|
|
|
updateClientList();
|
2002-08-09 00:44:35 +00:00
|
|
|
|
|
|
|
if (w->isTopmost()) {
|
|
|
|
WindowList::iterator it = specialWindowList.begin();
|
|
|
|
const WindowList::iterator end = specialWindowList.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
if (*it == w->getFrameWindow()) {
|
|
|
|
specialWindowList.erase(it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert(it != end); // the window wasnt a special window?
|
|
|
|
}
|
2002-07-16 08:00:59 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-23 16:17:28 +00:00
|
|
|
if (blackbox->getFocusedWindow() == w)
|
|
|
|
blackbox->setFocusedWindow((BlackboxWindow *) 0);
|
|
|
|
|
2002-05-28 09:53:11 +00:00
|
|
|
/*
|
|
|
|
some managed windows can also be window group controllers. when
|
|
|
|
unmanaging such windows, we should also delete the window group.
|
|
|
|
*/
|
|
|
|
BWindowGroup *group = blackbox->searchGroup(w->getClientWindow());
|
|
|
|
delete group;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
delete w;
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-06-21 20:40:14 +00:00
|
|
|
void BScreen::updateWorkArea(void) {
|
|
|
|
if (workspacesList.size() > 0) {
|
|
|
|
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
|
2002-11-03 11:46:05 +00:00
|
|
|
const otk::Rect &area = availableArea();
|
2002-06-21 20:40:14 +00:00
|
|
|
dims[(i * 4) + 0] = area.x();
|
|
|
|
dims[(i * 4) + 1] = area.y();
|
|
|
|
dims[(i * 4) + 2] = area.width();
|
|
|
|
dims[(i * 4) + 3] = area.height();
|
|
|
|
}
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_workarea,
|
|
|
|
otk::OBProperty::Atom_Cardinal,
|
|
|
|
dims, 4 * workspacesList.size());
|
2002-07-03 05:26:11 +00:00
|
|
|
delete [] dims;
|
2002-06-21 20:40:14 +00:00
|
|
|
} else
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_workarea,
|
|
|
|
otk::OBProperty::Atom_Cardinal, 0, 0);
|
2002-06-21 20:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::updateNetizenWorkspaceCount(void) {
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_number_of_desktops,
|
|
|
|
otk::OBProperty::Atom_Cardinal, workspacesList.size());
|
2002-05-30 07:14:43 +00:00
|
|
|
|
2002-06-21 20:40:14 +00:00
|
|
|
updateWorkArea();
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::updateNetizenWindowFocus(void) {
|
|
|
|
Window f = ((blackbox->getFocusedWindow()) ?
|
|
|
|
blackbox->getFocusedWindow()->getClientWindow() : None);
|
2002-06-21 20:40:14 +00:00
|
|
|
|
2002-11-05 09:13:46 +00:00
|
|
|
xatom->set(getRootWindow(), otk::OBProperty::net_active_window,
|
|
|
|
otk::OBProperty::Atom_Window, f);
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
|
2002-06-21 01:06:29 +00:00
|
|
|
// the 13 represents the number of blackbox windows such as menus
|
2002-08-02 19:58:18 +00:00
|
|
|
int bbwins = 15;
|
2002-07-22 08:09:34 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
++bbwins;
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Window *session_stack = new
|
2002-10-31 08:42:45 +00:00
|
|
|
Window[(num + specialWindowList.size() + bbwins)];
|
2002-05-25 00:29:44 +00:00
|
|
|
unsigned int i = 0, k = num;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-08-09 00:44:35 +00:00
|
|
|
WindowList::iterator sit, send = specialWindowList.end();
|
|
|
|
for (sit = specialWindowList.begin(); sit != send; ++sit)
|
|
|
|
*(session_stack + i++) = *sit;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
while (k--)
|
|
|
|
*(session_stack + i++) = *(workspace_stack + k);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XRestackWindows(otk::OBDisplay::display, session_stack, i);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
delete [] session_stack;
|
2002-06-21 20:40:14 +00:00
|
|
|
|
|
|
|
updateStackingList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-13 21:25:19 +00:00
|
|
|
void BScreen::lowerWindows(Window *workspace_stack, unsigned int num) {
|
|
|
|
assert(num > 0); // this would cause trouble in the XRaiseWindow call
|
2002-06-22 04:48:33 +00:00
|
|
|
|
2002-07-13 21:25:19 +00:00
|
|
|
Window *session_stack = new Window[(num + desktopWindowList.size())];
|
|
|
|
unsigned int i = 0, k = num;
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XLowerWindow(otk::OBDisplay::display, workspace_stack[0]);
|
2002-07-13 21:25:19 +00:00
|
|
|
|
|
|
|
while (k--)
|
|
|
|
*(session_stack + i++) = *(workspace_stack + k);
|
|
|
|
|
|
|
|
WindowList::iterator dit = desktopWindowList.begin();
|
|
|
|
const WindowList::iterator d_end = desktopWindowList.end();
|
|
|
|
for (; dit != d_end; ++dit)
|
|
|
|
*(session_stack + i++) = *dit;
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XRestackWindows(otk::OBDisplay::display, session_stack, i);
|
2002-07-13 21:25:19 +00:00
|
|
|
|
|
|
|
delete [] session_stack;
|
|
|
|
|
|
|
|
updateStackingList();
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
|
|
|
|
bool ignore_sticky) {
|
|
|
|
if (! w) return;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-11-06 13:57:54 +00:00
|
|
|
if (wkspc_id == otk::BSENTINEL)
|
2002-05-25 00:29:44 +00:00
|
|
|
wkspc_id = current_workspace->getID();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (w->getWorkspaceNumber() == wkspc_id)
|
|
|
|
return;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (w->isIconic()) {
|
|
|
|
removeIcon(w);
|
|
|
|
getWorkspace(wkspc_id)->addWindow(w);
|
2002-07-29 06:21:31 +00:00
|
|
|
if (w->isStuck())
|
|
|
|
for (unsigned int i = 0; i < getNumberOfWorkspaces(); ++i)
|
|
|
|
if (i != w->getWorkspaceNumber())
|
|
|
|
getWorkspace(i)->addWindow(w, True);
|
2002-05-25 00:29:44 +00:00
|
|
|
} else if (ignore_sticky || ! w->isStuck()) {
|
2002-07-27 18:17:45 +00:00
|
|
|
if (w->isStuck())
|
|
|
|
w->stick();
|
2002-05-25 00:29:44 +00:00
|
|
|
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
|
|
|
|
getWorkspace(wkspc_id)->addWindow(w);
|
2002-05-16 22:35:59 +00:00
|
|
|
}
|
2002-07-09 01:22:16 +00:00
|
|
|
updateStackingList();
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::propagateWindowName(const BlackboxWindow *bw) {
|
|
|
|
if (bw->isIconic()) {
|
2002-10-01 01:59:09 +00:00
|
|
|
} else {
|
2002-05-16 22:35:59 +00:00
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-10-01 01:59:09 +00:00
|
|
|
void BScreen::nextFocus(void) const {
|
2002-05-25 00:29:44 +00:00
|
|
|
BlackboxWindow *focused = blackbox->getFocusedWindow(),
|
|
|
|
*next = focused;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-10-01 01:59:09 +00:00
|
|
|
if (focused &&
|
|
|
|
focused->getScreen()->getScreenNumber() == getScreenNumber() &&
|
|
|
|
current_workspace->getCount() > 1) {
|
2002-05-25 00:29:44 +00:00
|
|
|
do {
|
2002-10-01 01:59:09 +00:00
|
|
|
next = current_workspace->getNextWindowInList(next);
|
|
|
|
} while (next != focused && ! next->setInputFocus());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (next != focused)
|
|
|
|
current_workspace->raiseWindow(next);
|
2002-10-01 01:59:09 +00:00
|
|
|
} else if (current_workspace->getCount() > 0) {
|
2002-05-25 00:29:44 +00:00
|
|
|
next = current_workspace->getTopWindowOnStack();
|
|
|
|
next->setInputFocus();
|
2002-10-01 01:59:09 +00:00
|
|
|
current_workspace->raiseWindow(next);
|
2002-05-16 22:35:59 +00:00
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-10-01 01:59:09 +00:00
|
|
|
void BScreen::prevFocus(void) const {
|
2002-05-25 00:29:44 +00:00
|
|
|
BlackboxWindow *focused = blackbox->getFocusedWindow(),
|
|
|
|
*next = focused;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (focused) {
|
|
|
|
// if window is not on this screen, ignore it
|
|
|
|
if (focused->getScreen()->getScreenNumber() != getScreenNumber())
|
|
|
|
focused = (BlackboxWindow*) 0;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-10-01 01:59:09 +00:00
|
|
|
|
|
|
|
if (focused &&
|
|
|
|
focused->getScreen()->getScreenNumber() == getScreenNumber() &&
|
|
|
|
current_workspace->getCount() > 1) {
|
|
|
|
// next is the next window to receive focus, current is a place holder
|
2002-05-25 00:29:44 +00:00
|
|
|
do {
|
2002-10-01 01:59:09 +00:00
|
|
|
next = current_workspace->getPrevWindowInList(next);
|
|
|
|
} while (next != focused && ! next->setInputFocus());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (next != focused)
|
2002-05-16 22:35:59 +00:00
|
|
|
current_workspace->raiseWindow(next);
|
2002-10-01 01:59:09 +00:00
|
|
|
} else if (current_workspace->getCount() > 0) {
|
2002-05-25 00:29:44 +00:00
|
|
|
next = current_workspace->getTopWindowOnStack();
|
|
|
|
next->setInputFocus();
|
2002-10-01 01:59:09 +00:00
|
|
|
current_workspace->raiseWindow(next);
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-10-01 01:59:09 +00:00
|
|
|
void BScreen::raiseFocus(void) const {
|
2002-05-25 00:29:44 +00:00
|
|
|
BlackboxWindow *focused = blackbox->getFocusedWindow();
|
|
|
|
if (! focused)
|
|
|
|
return;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
// if on this Screen, raise it
|
|
|
|
if (focused->getScreen()->getScreenNumber() == getScreenNumber()) {
|
|
|
|
Workspace *workspace = getWorkspace(focused->getWorkspaceNumber());
|
|
|
|
workspace->raiseWindow(focused);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::shutdown(void) {
|
2002-11-03 11:46:05 +00:00
|
|
|
XSelectInput(otk::OBDisplay::display, getRootWindow(), NoEventMask);
|
|
|
|
XSync(otk::OBDisplay::display, False);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
while(! windowList.empty())
|
|
|
|
unmanageWindow(windowList.front(), True);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-08-26 00:25:08 +00:00
|
|
|
while(! desktopWindowList.empty()) {
|
|
|
|
BlackboxWindow *win = blackbox->searchWindow(desktopWindowList.front());
|
|
|
|
assert(win);
|
|
|
|
unmanageWindow(win, True);
|
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::showPosition(int x, int y) {
|
|
|
|
if (! geom_visible) {
|
2002-11-03 11:46:05 +00:00
|
|
|
XMoveResizeWindow(otk::OBDisplay::display, geom_window,
|
2002-05-25 00:29:44 +00:00
|
|
|
(getWidth() - geom_w) / 2,
|
|
|
|
(getHeight() - geom_h) / 2, geom_w, geom_h);
|
2002-11-03 11:46:05 +00:00
|
|
|
XMapWindow(otk::OBDisplay::display, geom_window);
|
|
|
|
XRaiseWindow(otk::OBDisplay::display, geom_window);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_visible = True;
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
char label[1024];
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-10-31 08:42:45 +00:00
|
|
|
sprintf(label, "X: %4d x Y: %4d", x, y);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XClearWindow(otk::OBDisplay::display, geom_window);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-07-03 06:34:25 +00:00
|
|
|
resource.wstyle.font->drawString(geom_window,
|
2002-11-06 13:57:54 +00:00
|
|
|
resource.wstyle.bevel_width, resource.wstyle.bevel_width,
|
2002-07-03 06:34:25 +00:00
|
|
|
resource.wstyle.l_text_focus,
|
|
|
|
label);
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
|
|
|
|
if (! geom_visible) {
|
2002-11-03 11:46:05 +00:00
|
|
|
XMoveResizeWindow(otk::OBDisplay::display, geom_window,
|
2002-05-25 00:29:44 +00:00
|
|
|
(getWidth() - geom_w) / 2,
|
|
|
|
(getHeight() - geom_h) / 2, geom_w, geom_h);
|
2002-11-03 11:46:05 +00:00
|
|
|
XMapWindow(otk::OBDisplay::display, geom_window);
|
|
|
|
XRaiseWindow(otk::OBDisplay::display, geom_window);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_visible = True;
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
char label[1024];
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-10-31 08:42:45 +00:00
|
|
|
sprintf(label, "W: %4d x H: %4d", gx, gy);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
XClearWindow(otk::OBDisplay::display, geom_window);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-07-03 06:34:25 +00:00
|
|
|
resource.wstyle.font->drawString(geom_window,
|
2002-11-06 13:57:54 +00:00
|
|
|
resource.wstyle.bevel_width, resource.wstyle.bevel_width,
|
2002-07-03 06:34:25 +00:00
|
|
|
resource.wstyle.l_text_focus,
|
|
|
|
label);
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::hideGeometry(void) {
|
|
|
|
if (geom_visible) {
|
2002-11-03 11:46:05 +00:00
|
|
|
XUnmapWindow(otk::OBDisplay::display, geom_window);
|
2002-05-25 00:29:44 +00:00
|
|
|
geom_visible = False;
|
|
|
|
}
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-11-06 08:06:54 +00:00
|
|
|
void BScreen::addStrut(otk::Strut *strut) {
|
2002-05-25 00:29:44 +00:00
|
|
|
strutList.push_back(strut);
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-11-06 08:06:54 +00:00
|
|
|
void BScreen::removeStrut(otk::Strut *strut) {
|
2002-05-25 00:29:44 +00:00
|
|
|
strutList.remove(strut);
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
const otk::Rect& BScreen::availableArea(void) const {
|
2002-05-25 00:29:44 +00:00
|
|
|
if (doFullMax())
|
|
|
|
return getRect(); // return the full screen
|
|
|
|
return usableArea;
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-07-21 23:58:09 +00:00
|
|
|
#ifdef XINERAMA
|
2002-07-22 07:31:07 +00:00
|
|
|
const RectList& BScreen::allAvailableAreas(void) const {
|
2002-07-22 04:29:40 +00:00
|
|
|
assert(isXineramaActive());
|
2002-07-22 04:39:32 +00:00
|
|
|
assert(xineramaUsableArea.size() > 0);
|
2002-07-22 07:31:07 +00:00
|
|
|
fprintf(stderr, "1found x %d y %d w %d h %d\n",
|
|
|
|
xineramaUsableArea[0].x(), xineramaUsableArea[0].y(),
|
|
|
|
xineramaUsableArea[0].width(), xineramaUsableArea[0].height());
|
2002-07-22 04:29:40 +00:00
|
|
|
return xineramaUsableArea;
|
2002-07-21 23:58:09 +00:00
|
|
|
}
|
2002-07-22 04:29:40 +00:00
|
|
|
#endif // XINERAMA
|
2002-07-21 23:58:09 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::updateAvailableArea(void) {
|
2002-11-03 11:46:05 +00:00
|
|
|
otk::Rect old_area = usableArea;
|
2002-05-25 00:29:44 +00:00
|
|
|
usableArea = getRect(); // reset to full screen
|
|
|
|
|
2002-07-21 23:58:09 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
// reset to the full areas
|
|
|
|
if (isXineramaActive())
|
2002-07-22 02:07:36 +00:00
|
|
|
xineramaUsableArea = getXineramaAreas();
|
2002-07-21 23:58:09 +00:00
|
|
|
#endif // XINERAMA
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
/* these values represent offsets from the screen edge
|
|
|
|
* we look for the biggest offset on each edge and then apply them
|
|
|
|
* all at once
|
|
|
|
* do not be confused by the similarity to the names of Rect's members
|
|
|
|
*/
|
|
|
|
unsigned int current_left = 0, current_right = 0, current_top = 0,
|
|
|
|
current_bottom = 0;
|
|
|
|
|
|
|
|
StrutList::const_iterator it = strutList.begin(), end = strutList.end();
|
|
|
|
|
|
|
|
for(; it != end; ++it) {
|
2002-11-06 08:06:54 +00:00
|
|
|
otk::Strut *strut = *it;
|
2002-05-25 00:29:44 +00:00
|
|
|
if (strut->left > current_left)
|
|
|
|
current_left = strut->left;
|
|
|
|
if (strut->top > current_top)
|
|
|
|
current_top = strut->top;
|
|
|
|
if (strut->right > current_right)
|
|
|
|
current_right = strut->right;
|
|
|
|
if (strut->bottom > current_bottom)
|
|
|
|
current_bottom = strut->bottom;
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
usableArea.setPos(current_left, current_top);
|
|
|
|
usableArea.setSize(usableArea.width() - (current_left + current_right),
|
|
|
|
usableArea.height() - (current_top + current_bottom));
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-07-21 23:58:09 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (isXineramaActive()) {
|
|
|
|
// keep each of the ximerama-defined areas inside the strut
|
|
|
|
RectList::iterator xit, xend = xineramaUsableArea.end();
|
|
|
|
for (xit = xineramaUsableArea.begin(); xit != xend; ++xit) {
|
|
|
|
if (xit->x() < usableArea.x()) {
|
|
|
|
xit->setX(usableArea.x());
|
|
|
|
xit->setWidth(xit->width() - usableArea.x());
|
|
|
|
}
|
|
|
|
if (xit->y() < usableArea.y()) {
|
|
|
|
xit->setY(usableArea.y());
|
|
|
|
xit->setHeight(xit->height() - usableArea.y());
|
|
|
|
}
|
|
|
|
if (xit->x() + xit->width() > usableArea.width())
|
|
|
|
xit->setWidth(usableArea.width() - xit->x());
|
|
|
|
if (xit->y() + xit->height() > usableArea.height())
|
|
|
|
xit->setHeight(usableArea.height() - xit->y());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (old_area != usableArea) {
|
|
|
|
BlackboxWindowList::iterator it = windowList.begin(),
|
|
|
|
end = windowList.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
if ((*it)->isMaximized()) (*it)->remaximize();
|
|
|
|
}
|
2002-06-21 20:40:14 +00:00
|
|
|
|
|
|
|
updateWorkArea();
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-10-01 01:59:09 +00:00
|
|
|
Workspace* BScreen::getWorkspace(unsigned int index) const {
|
2002-05-25 00:29:44 +00:00
|
|
|
assert(index < workspacesList.size());
|
|
|
|
return workspacesList[index];
|
|
|
|
}
|
2002-05-16 22:35:59 +00:00
|
|
|
|
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
void BScreen::buttonPressEvent(const XButtonEvent *xbutton) {
|
2002-05-25 00:29:44 +00:00
|
|
|
if (xbutton->button == 1) {
|
|
|
|
if (! isRootColormapInstalled())
|
|
|
|
image_control->installRootColormap();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-27 03:12:21 +00:00
|
|
|
// mouse wheel up
|
2002-07-29 14:49:12 +00:00
|
|
|
} else if ((xbutton->button == 4 && resource.root_scroll == NormalScroll) ||
|
|
|
|
(xbutton->button == 5 && resource.root_scroll == ReverseScroll)) {
|
2002-05-27 03:12:21 +00:00
|
|
|
if (getCurrentWorkspaceID() >= getWorkspaceCount() - 1)
|
|
|
|
changeWorkspaceID(0);
|
|
|
|
else
|
|
|
|
changeWorkspaceID(getCurrentWorkspaceID() + 1);
|
|
|
|
// mouse wheel down
|
2002-07-29 14:49:12 +00:00
|
|
|
} else if ((xbutton->button == 5 && resource.root_scroll == NormalScroll) ||
|
|
|
|
(xbutton->button == 4 && resource.root_scroll == ReverseScroll)) {
|
2002-05-27 03:12:21 +00:00
|
|
|
if (getCurrentWorkspaceID() == 0)
|
|
|
|
changeWorkspaceID(getWorkspaceCount() - 1);
|
|
|
|
else
|
|
|
|
changeWorkspaceID(getCurrentWorkspaceID() - 1);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-08-22 00:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-14 20:54:03 +00:00
|
|
|
void BScreen::propertyNotifyEvent(const XPropertyEvent *pe) {
|
2002-11-05 09:13:46 +00:00
|
|
|
if (pe->atom == xatom->atom(otk::OBProperty::net_desktop_names)) {
|
2002-07-14 20:54:03 +00:00
|
|
|
// _NET_WM_DESKTOP_NAMES
|
|
|
|
WorkspaceList::iterator it = workspacesList.begin();
|
|
|
|
const WorkspaceList::iterator end = workspacesList.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
(*it)->readName(); // re-read its name from the window property
|
2002-10-31 08:42:45 +00:00
|
|
|
//workspacemenu->changeWorkspaceLabel((*it)->getID(), (*it)->getName());
|
2002-07-14 20:54:03 +00:00
|
|
|
}
|
2002-10-31 08:42:45 +00:00
|
|
|
//workspacemenu->update();
|
2002-07-14 20:54:03 +00:00
|
|
|
saveWorkspaceNames();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void BScreen::toggleFocusModel(FocusModel model) {
|
2002-07-05 01:24:32 +00:00
|
|
|
std::for_each(windowList.begin(), windowList.end(),
|
|
|
|
std::mem_fun(&BlackboxWindow::ungrabButtons));
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (model == SloppyFocus) {
|
|
|
|
saveSloppyFocus(True);
|
|
|
|
} else {
|
2002-06-29 23:50:04 +00:00
|
|
|
// we're cheating here to save writing the config file 3 times
|
|
|
|
resource.auto_raise = False;
|
|
|
|
resource.click_raise = False;
|
2002-05-25 00:29:44 +00:00
|
|
|
saveSloppyFocus(False);
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
std::for_each(windowList.begin(), windowList.end(),
|
|
|
|
std::mem_fun(&BlackboxWindow::grabButtons));
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-11-03 11:46:05 +00:00
|
|
|
}
|