summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-07-23 21:32:31 -0400
committerDana Jansens <danakj@orodu.net>2008-01-20 01:36:54 -0500
commit32a92abf7578ea93d85741b7c89a0958082aa9ee (patch)
treef8947a21386d8153350441653c216d3a93d53495 /openbox
parent27274cff9c3ee668be0aa71ff4a72979a13cb4ca (diff)
move the code for tracking what extensions are available on the display into the libobt
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client.c7
-rw-r--r--openbox/event.c21
-rw-r--r--openbox/extensions.c133
-rw-r--r--openbox/extensions.h74
-rw-r--r--openbox/frame.c2
-rw-r--r--openbox/grab.c4
-rw-r--r--openbox/moveresize.c8
-rw-r--r--openbox/openbox.c3
-rw-r--r--openbox/screen.c56
9 files changed, 74 insertions, 234 deletions
diff --git a/openbox/client.c b/openbox/client.c
index 025dd129..20ccfe3d 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -26,7 +26,6 @@
#include "ping.h"
#include "place.h"
#include "prop.h"
-#include "extensions.h"
#include "frame.h"
#include "session.h"
#include "event.h"
@@ -1262,7 +1261,7 @@ static void client_get_shaped(ObClient *self)
{
self->shaped = FALSE;
#ifdef SHAPE
- if (extensions_shape) {
+ if (obt_display_extension_shape) {
gint foo;
guint ufoo;
gint s;
@@ -3639,8 +3638,8 @@ gboolean client_focus(ObClient *self)
obt_display_ignore_errors(ob_display, FALSE);
ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n",
- obt_display_error_occured());
- return !obt_display_error_occured();
+ obt_display_error_occured);
+ return !obt_display_error_occured;
}
static void client_present(ObClient *self, gboolean here, gboolean raise,
diff --git a/openbox/event.c b/openbox/event.c
index 5aa73921..63e27df6 100644
--- a/openbox/event.c
+++ b/openbox/event.c
@@ -39,7 +39,6 @@
#include "moveresize.h"
#include "group.h"
#include "stacking.h"
-#include "extensions.h"
#include "translate.h"
#include "ping.h"
#include "obt/display.h"
@@ -180,7 +179,9 @@ static Window event_get_window(XEvent *e)
break;
default:
#ifdef XKB
- if (extensions_xkb && e->type == extensions_xkb_event_basep) {
+ if (obt_display_extension_xkb &&
+ e->type == obt_display_extension_xkb_basep)
+ {
switch (((XkbAnyEvent*)e)->xkb_type) {
case XkbBellNotify:
window = ((XkbBellNotifyEvent*)e)->window;
@@ -190,8 +191,8 @@ static Window event_get_window(XEvent *e)
} else
#endif
#ifdef SYNC
- if (extensions_sync &&
- e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ if (obt_display_extension_sync &&
+ e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
window = None;
} else
@@ -229,8 +230,8 @@ static void event_set_curtime(XEvent *e)
break;
default:
#ifdef SYNC
- if (extensions_sync &&
- e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ if (obt_display_extension_sync &&
+ e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
t = ((XSyncAlarmNotifyEvent*)e)->time;
}
@@ -690,8 +691,8 @@ static void event_process(const XEvent *ec, gpointer data)
obt_display_ignore_errors(ob_display, FALSE);
}
#ifdef SYNC
- else if (extensions_sync &&
- e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ else if (obt_display_extension_sync &&
+ e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
XSyncAlarmNotifyEvent *se = (XSyncAlarmNotifyEvent*)e;
if (se->alarm == moveresize_alarm && moveresize_in_progress)
@@ -1585,7 +1586,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
default:
;
#ifdef SHAPE
- if (extensions_shape && e->type == extensions_shape_event_basep) {
+ if (obt_display_extension_shape &&
+ e->type == obt_display_extension_shape_basep)
+ {
client->shaped = ((XShapeEvent*)e)->shaped;
frame_adjust_shape(client->frame);
}
diff --git a/openbox/extensions.c b/openbox/extensions.c
deleted file mode 100644
index d1088361..00000000
--- a/openbox/extensions.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- extensions.c for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "openbox.h"
-#include "geom.h"
-#include "extensions.h"
-#include "screen.h"
-#include "debug.h"
-
-gboolean extensions_xkb = FALSE;
-gint extensions_xkb_event_basep;
-gboolean extensions_shape = FALSE;
-gint extensions_shape_event_basep;
-gboolean extensions_xinerama = FALSE;
-gint extensions_xinerama_event_basep;
-gboolean extensions_randr = FALSE;
-gint extensions_randr_event_basep;
-gboolean extensions_sync = FALSE;
-gint extensions_sync_event_basep;
-
-void extensions_query_all(void)
-{
- gint junk;
- (void)junk;
-
-#ifdef XKB
- extensions_xkb =
- XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep,
- &junk, NULL, NULL);
- if (!extensions_xkb)
- ob_debug("XKB extension is not present on the server\n");
-#endif
-
-#ifdef SHAPE
- extensions_shape =
- XShapeQueryExtension(ob_display, &extensions_shape_event_basep,
- &junk);
- if (!extensions_shape)
- ob_debug("X Shape extension is not present on the server\n");
-#endif
-
-#ifdef XINERAMA
- extensions_xinerama =
- XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep,
- &junk) && XineramaIsActive(ob_display);
- if (!extensions_xinerama)
- ob_debug("Xinerama extension is not present on the server\n");
-#endif
-
-#ifdef XRANDR
- extensions_randr =
- XRRQueryExtension(ob_display, &extensions_randr_event_basep,
- &junk);
- if (!extensions_randr)
- ob_debug("XRandR extension is not present on the server\n");
-#endif
-
-#ifdef SYNC
- extensions_sync =
- XSyncQueryExtension(ob_display, &extensions_sync_event_basep,
- &junk) &&
- XSyncInitialize(ob_display, &junk, &junk);
- if (!extensions_sync)
- ob_debug("X Sync extension is not present on the server or is an "
- "incompatible version\n");
-#endif
-}
-
-void extensions_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(ob_display, ob_screen));
- gint h = HeightOfScreen(ScreenOfDisplay(ob_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);
- }
- else
-#ifdef XINERAMA
- if (extensions_xinerama) {
- guint i;
- gint n;
- XineramaScreenInfo *info = XineramaQueryScreens(ob_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);
- }
- else
-#endif
- {
- *nxin = 1;
- *xin_areas = g_new(Rect, *nxin + 1);
- RECT_SET((*xin_areas)[0], 0, 0,
- WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)),
- HeightOfScreen(ScreenOfDisplay(ob_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);
-}
diff --git a/openbox/extensions.h b/openbox/extensions.h
deleted file mode 100644
index 31558740..00000000
--- a/openbox/extensions.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- extensions.h for the Openbox window manager
- Copyright (c) 2006 Mikael Magnusson
- Copyright (c) 2003-2007 Dana Jansens
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __extensions_h
-#define __extensions_h
-
-#include "geom.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h> /* shape.h uses Region which is in here */
-#ifdef XKB
-#include <X11/XKBlib.h>
-#endif
-#ifdef SHAPE
-#include <X11/extensions/shape.h>
-#endif
-#ifdef XINERAMA
-#include <X11/extensions/Xinerama.h>
-#endif
-#ifdef XRANDR
-#include <X11/extensions/Xrandr.h>
-#endif
-#ifdef SYNC
-#include <X11/extensions/sync.h>
-#endif
-
-#include <glib.h>
-
-/*! Does the display have the XKB extension? */
-extern gboolean extensions_xkb;
-/*! Base for events for the XKB extension */
-extern gint extensions_xkb_event_basep;
-
-/*! Does the display have the Shape extension? */
-extern gboolean extensions_shape;
-/*! Base for events for the Shape extension */
-extern gint extensions_shape_event_basep;
-
-/*! Does the display have the Xinerama extension? */
-extern gboolean extensions_xinerama;
-/*! Base for events for the Xinerama extension */
-extern gint extensions_xinerama_event_basep;
-
-/*! Does the display have the RandR extension? */
-extern gboolean extensions_randr;
-/*! Base for events for the Randr extension */
-extern gint extensions_randr_event_basep;
-
-/*! Does the display have the Sync extension? */
-extern gboolean extensions_sync;
-/*! Base for events for the Sync extension */
-extern gint extensions_sync_event_basep;
-
-void extensions_query_all();
-
-void extensions_xinerama_screens(Rect **areas, guint *nxin);
-
-#endif
diff --git a/openbox/frame.c b/openbox/frame.c
index 2952b6c7..be8230c0 100644
--- a/openbox/frame.c
+++ b/openbox/frame.c
@@ -20,7 +20,6 @@
#include "frame.h"
#include "client.h"
#include "openbox.h"
-#include "extensions.h"
#include "prop.h"
#include "grab.h"
#include "config.h"
@@ -30,6 +29,7 @@
#include "moveresize.h"
#include "screen.h"
#include "render/theme.h"
+#include "obt/display.h"
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
ButtonPressMask | ButtonReleaseMask | \
diff --git a/openbox/grab.c b/openbox/grab.c
index d84ef94f..cfbbbe1a 100644
--- a/openbox/grab.c
+++ b/openbox/grab.c
@@ -180,7 +180,7 @@ void grab_button_full(guint button, guint state, Window win, guint mask,
XGrabButton(ob_display, button, state | mask_list[i], win, False, mask,
pointer_mode, GrabModeAsync, None, ob_cursor(cur));
obt_display_ignore_errors(ob_display, FALSE);
- if (obt_display_error_occured())
+ if (obt_display_error_occured)
ob_debug("Failed to grab button %d modifiers %d", button, state);
}
@@ -202,7 +202,7 @@ void grab_key(guint keycode, guint state, Window win, gint keyboard_mode)
XGrabKey(ob_display, keycode, state | mask_list[i], win, FALSE,
GrabModeAsync, keyboard_mode);
obt_display_ignore_errors(ob_display, FALSE);
- if (obt_display_error_occured())
+ if (obt_display_error_occured)
ob_debug("Failed to grab keycode %d modifiers %d", keycode, state);
}
diff --git a/openbox/moveresize.c b/openbox/moveresize.c
index 4349f748..ed70899c 100644
--- a/openbox/moveresize.c
+++ b/openbox/moveresize.c
@@ -31,9 +31,9 @@
#include "config.h"
#include "event.h"
#include "debug.h"
-#include "extensions.h"
#include "render/render.h"
#include "render/theme.h"
+#include "obt/display.h"
#include <X11/Xlib.h>
#include <glib.h>
@@ -250,7 +250,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
moveresize_in_progress = TRUE;
#ifdef SYNC
- if (config_resize_redraw && !moving && extensions_sync &&
+ if (config_resize_redraw && !moving && obt_display_extension_sync &&
moveresize_client->sync_request && moveresize_client->sync_counter)
{
/* Initialize values for the resize syncing, and create an alarm for
@@ -365,7 +365,7 @@ static void do_resize(void)
}
#ifdef SYNC
- if (config_resize_redraw && extensions_sync &&
+ if (config_resize_redraw && obt_display_extension_sync &&
moveresize_client->sync_request && moveresize_client->sync_counter)
{
XEvent ce;
@@ -923,7 +923,7 @@ gboolean moveresize_event(XEvent *e)
}
}
#ifdef SYNC
- else if (e->type == extensions_sync_event_basep + XSyncAlarmNotify)
+ else if (e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
{
waiting_for_sync = FALSE; /* we got our sync... */
do_resize(); /* ...so try resize if there is more change pending */
diff --git a/openbox/openbox.c b/openbox/openbox.c
index f00cd2bd..ec283d5c 100644
--- a/openbox/openbox.c
+++ b/openbox/openbox.c
@@ -37,7 +37,6 @@
#include "frame.h"
#include "keyboard.h"
#include "mouse.h"
-#include "extensions.h"
#include "menuframe.h"
#include "grab.h"
#include "group.h"
@@ -207,9 +206,7 @@ gint main(gint argc, gchar **argv)
cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner",
XC_top_left_corner);
-
prop_startup(); /* get atoms values for the display */
- extensions_query_all(); /* find which extensions are present */
if (screen_annex()) { /* it will be ours! */
do {
diff --git a/openbox/screen.c b/openbox/screen.c
index d287c9fc..0d891630 100644
--- a/openbox/screen.c
+++ b/openbox/screen.c
@@ -33,7 +33,6 @@
#include "event.h"
#include "focus.h"
#include "popup.h"
-#include "extensions.h"
#include "render/render.h"
#include "gettext.h"
#include "obt/display.h"
@@ -110,7 +109,7 @@ static gboolean replace_wm(void)
XSync(ob_display, FALSE);
obt_display_ignore_errors(ob_display, FALSE);
- if (obt_display_error_occured())
+ if (obt_display_error_occured)
current_wm_sn_owner = None;
}
@@ -184,7 +183,7 @@ gboolean screen_annex(void)
XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
ROOT_EVENTMASK);
obt_display_ignore_errors(ob_display, FALSE);
- if (obt_display_error_occured()) {
+ if (obt_display_error_occured) {
g_message(_("A window manager is already running on screen %d"),
ob_screen);
@@ -1291,6 +1290,55 @@ typedef struct {
} \
}
+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(ob_display, ob_screen));
+ gint h = HeightOfScreen(ScreenOfDisplay(ob_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(ob_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(ob_display, ob_screen)),
+ HeightOfScreen(ScreenOfDisplay(ob_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;
@@ -1299,7 +1347,7 @@ void screen_update_areas(void)
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]);