#include "debug.h"
#include "openbox.h"
#include "dock.h"
-#include "xerror.h"
#include "prop.h"
#include "grab.h"
#include "startupnotify.h"
#include "event.h"
#include "focus.h"
#include "popup.h"
-#include "extensions.h"
#include "render/render.h"
#include "gettext.h"
+#include "obt/display.h"
#include <X11/Xlib.h>
#ifdef HAVE_UNISTD_H
guint screen_num_monitors;
guint screen_desktop;
guint screen_last_desktop = 1;
-guint screen_old_desktop;
-gboolean screen_desktop_timeout = TRUE;
-Size screen_physical_size;
gboolean screen_showing_desktop;
ObDesktopLayout screen_desktop_layout;
gchar **screen_desktop_names;
Window screen_support_win;
Time screen_desktop_user_time = CurrentTime;
+static Size screen_physical_size;
+static guint screen_old_desktop;
+static gboolean screen_desktop_timeout = TRUE;
/*! An array of desktops, holding array of areas per monitor */
static Rect *monitor_area = NULL;
/*! An array of desktops, holding an array of struts */
Time timestamp;
wm_sn = g_strdup_printf("WM_S%d", ob_screen);
- wm_sn_atom = XInternAtom(ob_display, wm_sn, FALSE);
+ wm_sn_atom = XInternAtom(obt_display, wm_sn, FALSE);
g_free(wm_sn);
- current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom);
+ current_wm_sn_owner = XGetSelectionOwner(obt_display, wm_sn_atom);
if (current_wm_sn_owner == screen_support_win)
current_wm_sn_owner = None;
if (current_wm_sn_owner) {
ob_screen);
return FALSE;
}
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
+ obt_display_ignore_errors(TRUE);
/* We want to find out when the current selection owner dies */
- XSelectInput(ob_display, current_wm_sn_owner, StructureNotifyMask);
- XSync(ob_display, FALSE);
+ XSelectInput(obt_display, current_wm_sn_owner, StructureNotifyMask);
+ XSync(obt_display, FALSE);
- xerror_set_ignore(FALSE);
- if (xerror_occured)
+ obt_display_ignore_errors(FALSE);
+ if (obt_display_error_occured)
current_wm_sn_owner = None;
}
timestamp = event_get_server_time();
- XSetSelectionOwner(ob_display, wm_sn_atom, screen_support_win,
+ XSetSelectionOwner(obt_display, wm_sn_atom, screen_support_win,
timestamp);
- if (XGetSelectionOwner(ob_display, wm_sn_atom) != screen_support_win) {
+ if (XGetSelectionOwner(obt_display, wm_sn_atom) != screen_support_win) {
g_message(_("Could not acquire window manager selection on screen %d"),
ob_screen);
return FALSE;
const gulong timeout = G_USEC_PER_SEC * 15; /* wait for 15s max */
while (wait < timeout) {
- if (XCheckWindowEvent(ob_display, current_wm_sn_owner,
+ if (XCheckWindowEvent(obt_display, current_wm_sn_owner,
StructureNotifyMask, &event) &&
event.type == DestroyNotify)
break;
}
/* Send client message indicating that we are now the WM */
- prop_message(RootWindow(ob_display, ob_screen), prop_atoms.manager,
+ prop_message(RootWindow(obt_display, ob_screen), prop_atoms.manager,
timestamp, wm_sn_atom, screen_support_win, 0,
SubstructureNotifyMask);
/* create the netwm support window */
attrib.override_redirect = TRUE;
attrib.event_mask = PropertyChangeMask;
- screen_support_win = XCreateWindow(ob_display,
- RootWindow(ob_display, ob_screen),
+ screen_support_win = XCreateWindow(obt_display,
+ RootWindow(obt_display, ob_screen),
-100, -100, 1, 1, 0,
CopyFromParent, InputOutput,
CopyFromParent,
CWEventMask | CWOverrideRedirect,
&attrib);
- XMapWindow(ob_display, screen_support_win);
- XLowerWindow(ob_display, screen_support_win);
+ XMapWindow(obt_display, screen_support_win);
+ XLowerWindow(obt_display, screen_support_win);
if (!replace_wm()) {
- XDestroyWindow(ob_display, screen_support_win);
+ XDestroyWindow(obt_display, screen_support_win);
return FALSE;
}
- xerror_set_ignore(TRUE);
- xerror_occured = FALSE;
- XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
+ obt_display_ignore_errors(TRUE);
+ XSelectInput(obt_display, RootWindow(obt_display, ob_screen),
ROOT_EVENTMASK);
- xerror_set_ignore(FALSE);
- if (xerror_occured) {
+ obt_display_ignore_errors(FALSE);
+ if (obt_display_error_occured) {
g_message(_("A window manager is already running on screen %d"),
ob_screen);
- XDestroyWindow(ob_display, screen_support_win);
+ XDestroyWindow(obt_display, screen_support_win);
return FALSE;
}
/* set the OPENBOX_PID hint */
pid = getpid();
- PROP_SET32(RootWindow(ob_display, ob_screen),
+ PROP_SET32(RootWindow(obt_display, ob_screen),
openbox_pid, cardinal, pid);
/* set supporting window */
- PROP_SET32(RootWindow(ob_display, ob_screen),
+ PROP_SET32(RootWindow(obt_display, ob_screen),
net_supporting_wm_check, window, screen_support_win);
/* set properties on the supporting window */
supported[i++] = prop_atoms.net_wm_sync_request;
supported[i++] = prop_atoms.net_wm_sync_request_counter;
#endif
+ supported[i++] = prop_atoms.net_wm_pid;
+ supported[i++] = prop_atoms.net_wm_ping;
supported[i++] = prop_atoms.kde_wm_change_state;
supported[i++] = prop_atoms.kde_net_wm_frame_strut;
supported[i++] = prop_atoms.ob_control;
g_assert(i == num_support);
- PROP_SETA32(RootWindow(ob_display, ob_screen),
+ PROP_SETA32(RootWindow(obt_display, ob_screen),
net_supported, atom, supported, num_support);
g_free(supported);
hear it anyways. perhaps it is for old ksplash. or new ksplash. or
something. oh well. */
e.xclient.type = ClientMessage;
- e.xclient.display = ob_display;
- e.xclient.window = RootWindow(ob_display, ob_screen);
+ e.xclient.display = obt_display;
+ e.xclient.window = RootWindow(obt_display, ob_screen);
e.xclient.message_type =
- XInternAtom(ob_display, "_KDE_SPLASH_PROGRESS", False );
+ XInternAtom(obt_display, "_KDE_SPLASH_PROGRESS", False );
e.xclient.format = 8;
strcpy(e.xclient.data.b, "wm started");
- XSendEvent(ob_display, RootWindow(ob_display, ob_screen),
+ XSendEvent(obt_display, RootWindow(obt_display, ob_screen),
False, SubstructureNotifyMask, &e );
}
screen_resize();
/* have names already been set for the desktops? */
- if (PROP_GETSS(RootWindow(ob_display, ob_screen),
+ if (PROP_GETSS(RootWindow(obt_display, ob_screen),
net_desktop_names, utf8, &names))
{
g_strfreev(names);
names[i] = g_strdup(it->data);
/* set the root window property */
- PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,names);
+ PROP_SETSS(RootWindow(obt_display, ob_screen),
+ net_desktop_names,names);
g_strfreev(names);
}
this will also set the default names from the config file up for
desktops that don't have names yet */
screen_num_desktops = 0;
- if (PROP_GET32(RootWindow(ob_display, ob_screen),
+ if (PROP_GET32(RootWindow(obt_display, ob_screen),
net_number_of_desktops, cardinal, &d))
screen_set_num_desktops(d);
/* restore from session if possible */
screen_desktop = screen_num_desktops; /* something invalid */
/* start on the current desktop when a wm was already running */
- if (PROP_GET32(RootWindow(ob_display, ob_screen),
+ if (PROP_GET32(RootWindow(obt_display, ob_screen),
net_current_desktop, cardinal, &d) &&
d < screen_num_desktops)
{
/* don't start in showing-desktop mode */
screen_showing_desktop = FALSE;
- PROP_SET32(RootWindow(ob_display, ob_screen),
+ PROP_SET32(RootWindow(obt_display, ob_screen),
net_showing_desktop, cardinal, screen_showing_desktop);
if (session_desktop_layout_present &&
if (reconfig)
return;
- XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
+ XSelectInput(obt_display, RootWindow(obt_display, ob_screen),
NoEventMask);
/* we're not running here no more! */
- PROP_ERASE(RootWindow(ob_display, ob_screen), openbox_pid);
+ PROP_ERASE(RootWindow(obt_display, ob_screen), openbox_pid);
/* not without us */
- PROP_ERASE(RootWindow(ob_display, ob_screen), net_supported);
+ PROP_ERASE(RootWindow(obt_display, ob_screen), net_supported);
/* don't keep this mode */
- PROP_ERASE(RootWindow(ob_display, ob_screen), net_showing_desktop);
+ PROP_ERASE(RootWindow(obt_display, ob_screen), net_showing_desktop);
- XDestroyWindow(ob_display, screen_support_win);
+ XDestroyWindow(obt_display, screen_support_win);
g_strfreev(screen_desktop_names);
screen_desktop_names = NULL;
GList *it;
gulong geometry[2];
- w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
- h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
+ w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
if (w == oldw && h == oldh) return;
/* Set the _NET_DESKTOP_GEOMETRY hint */
screen_physical_size.width = geometry[0] = w;
screen_physical_size.height = geometry[1] = h;
- PROP_SETA32(RootWindow(ob_display, ob_screen),
+ PROP_SETA32(RootWindow(obt_display, ob_screen),
net_desktop_geometry, cardinal, geometry, 2);
if (ob_state() == OB_STATE_STARTING)
old = screen_num_desktops;
screen_num_desktops = num;
- PROP_SET32(RootWindow(ob_display, ob_screen),
+ PROP_SET32(RootWindow(obt_display, ob_screen),
net_number_of_desktops, cardinal, num);
/* set the viewport hint */
viewport = g_new0(gulong, num * 2);
- PROP_SETA32(RootWindow(ob_display, ob_screen),
+ PROP_SETA32(RootWindow(obt_display, ob_screen),
net_desktop_viewport, cardinal, viewport, num * 2);
g_free(viewport);
if (previous == num) return;
- PROP_SET32(RootWindow(ob_display, ob_screen),
+ PROP_SET32(RootWindow(obt_display, ob_screen),
net_current_desktop, cardinal, num);
/* This whole thing decides when/how to save the screen_last_desktop so
screen_desktop_layout.rows = 1;
screen_desktop_layout.columns = screen_num_desktops;
- if (PROP_GETA32(RootWindow(ob_display, ob_screen),
+ if (PROP_GETA32(RootWindow(obt_display, ob_screen),
net_desktop_layout, cardinal, &data, &num)) {
if (num == 3 || num == 4) {
g_strfreev(screen_desktop_names);
screen_desktop_names = NULL;
- if (PROP_GETSS(RootWindow(ob_display, ob_screen),
+ if (PROP_GETSS(RootWindow(obt_display, ob_screen),
net_desktop_names, utf8, &screen_desktop_names))
for (i = 0; screen_desktop_names[i] && i < screen_num_desktops; ++i);
else
/* if we changed any names, then set the root property so we can
all agree on the names */
- PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,
+ PROP_SETSS(RootWindow(obt_display, ob_screen), net_desktop_names,
screen_desktop_names);
}
}
show = !!show; /* make it boolean */
- PROP_SET32(RootWindow(ob_display, ob_screen),
+ PROP_SET32(RootWindow(obt_display, ob_screen),
net_showing_desktop, cardinal, show);
}
{
if (client == NULL || client->colormap == None) {
if (install)
- XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
+ XInstallColormap(obt_display, RrColormap(ob_rr_inst));
else
- XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
+ XUninstallColormap(obt_display, RrColormap(ob_rr_inst));
} else {
- xerror_set_ignore(TRUE);
+ obt_display_ignore_errors(TRUE);
if (install)
- XInstallColormap(RrDisplay(ob_rr_inst), client->colormap);
+ XInstallColormap(obt_display, client->colormap);
else
- XUninstallColormap(RrDisplay(ob_rr_inst), client->colormap);
- xerror_set_ignore(FALSE);
+ XUninstallColormap(obt_display, client->colormap);
+ obt_display_ignore_errors(FALSE);
}
}
} \
}
+static void get_xinerama_screens(Rect **xin_areas, guint *nxin)
+{
+ guint i;
+ gint l, r, t, b;
+
+ if (ob_debug_xinerama) {
+ g_print("Using fake xinerama !\n");
+ gint w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ gint h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ *nxin = 2;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0, w/2, h);
+ RECT_SET((*xin_areas)[1], w/2, 0, w-(w/2), h);
+ }
+#ifdef XINERAMA
+ else if (obt_display_extension_xinerama) {
+ guint i;
+ gint n;
+ XineramaScreenInfo *info = XineramaQueryScreens(obt_display, &n);
+ *nxin = n;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ for (i = 0; i < *nxin; ++i)
+ RECT_SET((*xin_areas)[i], info[i].x_org, info[i].y_org,
+ info[i].width, info[i].height);
+ XFree(info);
+ }
+#endif
+ else {
+ *nxin = 1;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0,
+ WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen)),
+ HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen)));
+ }
+
+ /* returns one extra with the total area in it */
+ l = (*xin_areas)[0].x;
+ t = (*xin_areas)[0].y;
+ r = (*xin_areas)[0].x + (*xin_areas)[0].width - 1;
+ b = (*xin_areas)[0].y + (*xin_areas)[0].height - 1;
+ for (i = 1; i < *nxin; ++i) {
+ l = MIN(l, (*xin_areas)[i].x);
+ t = MIN(l, (*xin_areas)[i].y);
+ r = MAX(r, (*xin_areas)[i].x + (*xin_areas)[i].width - 1);
+ b = MAX(b, (*xin_areas)[i].y + (*xin_areas)[i].height - 1);
+ }
+ RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
+}
+
void screen_update_areas(void)
{
guint i, j;
GSList *sit;
g_free(monitor_area);
- extensions_xinerama_screens(&monitor_area, &screen_num_monitors);
+ get_xinerama_screens(&monitor_area, &screen_num_monitors);
/* set up the user-specified margins */
config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
/* all the work areas are not used here, only the ones for the first
monitor are */
- PROP_SETA32(RootWindow(ob_display, ob_screen), net_workarea, cardinal,
+ PROP_SETA32(RootWindow(obt_display, ob_screen), net_workarea, cardinal,
dims, 4 * screen_num_desktops);
/* the area has changed, adjust all the windows if they need it */
void screen_set_root_cursor(void)
{
if (sn_app_starting())
- XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
+ XDefineCursor(obt_display, RootWindow(obt_display, ob_screen),
ob_cursor(OB_CURSOR_BUSYPOINTER));
else
- XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
+ XDefineCursor(obt_display, RootWindow(obt_display, ob_screen),
ob_cursor(OB_CURSOR_POINTER));
}
guint u;
gboolean ret;
- ret = !!XQueryPointer(ob_display, RootWindow(ob_display, ob_screen),
+ ret = !!XQueryPointer(obt_display, RootWindow(obt_display, ob_screen),
&w, &w, x, y, &i, &i, &u);
if (!ret) {
- for (i = 0; i < ScreenCount(ob_display); ++i)
+ for (i = 0; i < ScreenCount(obt_display); ++i)
if (i != ob_screen)
- if (XQueryPointer(ob_display, RootWindow(ob_display, i),
+ if (XQueryPointer(obt_display, RootWindow(obt_display, i),
&w, &w, x, y, &i, &i, &u))
break;
}