summaryrefslogtreecommitdiff
path: root/obt
diff options
context:
space:
mode:
Diffstat (limited to 'obt')
-rw-r--r--obt/display.c70
-rw-r--r--obt/display.h37
-rw-r--r--obt/obt.h25
3 files changed, 95 insertions, 37 deletions
diff --git a/obt/display.c b/obt/display.c
index b638f9cd..d9966780 100644
--- a/obt/display.c
+++ b/obt/display.c
@@ -28,10 +28,22 @@
# include <unistd.h>
#endif
+gboolean obt_display_error_occured = FALSE;
+
+gboolean obt_display_extension_xkb = FALSE;
+gint obt_display_extension_xkb_basep;
+gboolean obt_display_extension_shape = FALSE;
+gint obt_display_extension_shape_basep;
+gboolean obt_display_extension_xinerama = FALSE;
+gint obt_display_extension_xinerama_basep;
+gboolean obt_display_extension_randr = FALSE;
+gint obt_display_extension_randr_basep;
+gboolean obt_display_extension_sync = FALSE;
+gint obt_display_extension_sync_basep;
+
static gint xerror_handler(Display *d, XErrorEvent *e);
static gboolean xerror_ignore = FALSE;
-static gboolean xerror_occured = FALSE;
Display* obt_display_open(const char *display_name)
{
@@ -41,9 +53,56 @@ Display* obt_display_open(const char *display_name)
n = display_name ? g_strdup(display_name) : NULL;
d = XOpenDisplay(n);
if (d) {
+ gint junk;
+ (void)junk;
+
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
g_message("Failed to set display as close-on-exec");
XSetErrorHandler(xerror_handler);
+
+ /* read what extensions are present */
+#ifdef XKB
+ obt_display_extension_xkb =
+ XkbQueryExtension(d, &junk,
+ &obt_display_extension_xkb_basep, &junk,
+ NULL, NULL);
+ if (!obt_display_extension_xkb)
+ g_message("XKB extension is not present on the server");
+#endif
+
+#ifdef SHAPE
+ obt_display_extension_shape =
+ XShapeQueryExtension(d, &obt_display_extension_shape_basep,
+ &junk);
+ if (!obt_display_extension_shape)
+ g_message("X Shape extension is not present on the server");
+#endif
+
+#ifdef XINERAMA
+ obt_display_extension_xinerama =
+ XineramaQueryExtension(d,
+ &obt_display_extension_xinerama_basep,
+ &junk) && XineramaIsActive(d);
+ if (!obt_display_extension_xinerama)
+ g_message("Xinerama extension is not present on the server");
+#endif
+
+#ifdef XRANDR
+ obt_display_extension_randr =
+ XRRQueryExtension(d, &obt_display_extension_randr_basep,
+ &junk);
+ if (!obt_display_extension_randr)
+ g_message("XRandR extension is not present on the server");
+#endif
+
+#ifdef SYNC
+ obt_display_extension_sync =
+ XSyncQueryExtension(d, &obt_display_extension_sync_basep,
+ &junk) && XSyncInitialize(d, &junk, &junk);
+ if (!obt_display_extension_sync)
+ g_message("X Sync extension is not present on the server or is an "
+ "incompatible version");
+#endif
}
g_free(n);
@@ -72,7 +131,7 @@ static gint xerror_handler(Display *d, XErrorEvent *e)
(void)d; (void)e;
#endif
- xerror_occured = TRUE;
+ obt_display_error_occured = TRUE;
return 0;
}
@@ -80,10 +139,5 @@ void obt_display_ignore_errors(Display *d, gboolean ignore)
{
XSync(d, FALSE);
xerror_ignore = ignore;
- if (ignore) xerror_occured = FALSE;
-}
-
-gboolean obt_display_error_occured()
-{
- return xerror_occured;
+ if (ignore) obt_display_error_occured = FALSE;
}
diff --git a/obt/display.h b/obt/display.h
index aafa0fcd..b4a13c7c 100644
--- a/obt/display.h
+++ b/obt/display.h
@@ -16,20 +16,49 @@
See the COPYING file for a copy of the GNU General Public License.
*/
-#ifndef __obt_instance_h
-#define __obt_instance_h
+#ifndef __obt_display_h
+#define __obt_display_h
#include <X11/Xlib.h>
#include <glib.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
+
G_BEGIN_DECLS
+extern gboolean obt_display_error_occured;
+
+extern gboolean obt_display_extension_xkb;
+extern gint obt_display_extension_xkb_basep;
+extern gboolean obt_display_extension_shape;
+extern gint obt_display_extension_shape_basep;
+extern gboolean obt_display_extension_xinerama;
+extern gint obt_display_extension_xinerama_basep;
+extern gboolean obt_display_extension_randr;
+extern gint obt_display_extension_randr_basep;
+extern gboolean obt_display_extension_sync;
+extern gint obt_display_extension_sync_basep;
+
Display* obt_display_open(const char *display_name);
void obt_display_close(Display *d);
void obt_display_ignore_errors(Display *d, gboolean ignore);
-gboolean obt_display_error_occured();
G_END_DECLS
-#endif /*__obt_instance_h*/
+#endif /*__obt_display_h*/
diff --git a/obt/obt.h b/obt/obt.h
deleted file mode 100644
index 0343a6a7..00000000
--- a/obt/obt.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
- obt.h for the Openbox window manager
- Copyright (c) 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 __obt_h
-#define __obt_h
-
-#include "obt/instance.h"
-#include "obt/util.h"
-
-#endif /*__obt_h*/