move the code for tracking what extensions are available on the display into the libobt
This commit is contained in:
parent
27274cff9c
commit
32a92abf75
13 changed files with 180 additions and 288 deletions
28
Makefile.am
28
Makefile.am
|
@ -113,8 +113,12 @@ parser_libobparser_la_SOURCES = \
|
||||||
## obt ##
|
## obt ##
|
||||||
|
|
||||||
obt_libobt_la_CPPFLAGS = \
|
obt_libobt_la_CPPFLAGS = \
|
||||||
|
$(XINERAMA_CFLAGS) \
|
||||||
|
$(XKB_CFLAGS) \
|
||||||
|
$(XRANDR_CFLAGS) \
|
||||||
|
$(XSHAPE_CFLAGS) \
|
||||||
|
$(XSYNC_CFLAGS) \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
$(XML_CFLAGS) \
|
|
||||||
-DG_LOG_DOMAIN=\"Obt\" \
|
-DG_LOG_DOMAIN=\"Obt\" \
|
||||||
-DLOCALEDIR=\"$(localedir)\" \
|
-DLOCALEDIR=\"$(localedir)\" \
|
||||||
-DDATADIR=\"$(datadir)\" \
|
-DDATADIR=\"$(datadir)\" \
|
||||||
|
@ -122,10 +126,13 @@ obt_libobt_la_CPPFLAGS = \
|
||||||
obt_libobt_la_LDFLAGS = \
|
obt_libobt_la_LDFLAGS = \
|
||||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
||||||
obt_libobt_la_LIBADD = \
|
obt_libobt_la_LIBADD = \
|
||||||
$(GLIB_LIBS) \
|
$(XINERAMA_LIBS) \
|
||||||
$(XML_LIBS)
|
$(XKB_LIBS) \
|
||||||
|
$(XRANDR_LIBS) \
|
||||||
|
$(XSHAPE_LIBS) \
|
||||||
|
$(XSYNC_LIBS) \
|
||||||
|
$(GLIB_LIBS)
|
||||||
obt_libobt_la_SOURCES = \
|
obt_libobt_la_SOURCES = \
|
||||||
obt/obt.h \
|
|
||||||
obt/display.h \
|
obt/display.h \
|
||||||
obt/display.c \
|
obt/display.c \
|
||||||
obt/mainloop.h \
|
obt/mainloop.h \
|
||||||
|
@ -136,11 +143,6 @@ obt_libobt_la_SOURCES = \
|
||||||
|
|
||||||
openbox_openbox_CPPFLAGS = \
|
openbox_openbox_CPPFLAGS = \
|
||||||
$(SM_CFLAGS) \
|
$(SM_CFLAGS) \
|
||||||
$(XINERAMA_CFLAGS) \
|
|
||||||
$(XKB_CFLAGS) \
|
|
||||||
$(XRANDR_CFLAGS) \
|
|
||||||
$(XSHAPE_CFLAGS) \
|
|
||||||
$(XSYNC_CFLAGS) \
|
|
||||||
$(X_CFLAGS) \
|
$(X_CFLAGS) \
|
||||||
$(XCURSOR_CFLAGS) \
|
$(XCURSOR_CFLAGS) \
|
||||||
$(SM_CFLAGS) \
|
$(SM_CFLAGS) \
|
||||||
|
@ -154,11 +156,6 @@ openbox_openbox_CPPFLAGS = \
|
||||||
-DG_LOG_DOMAIN=\"Openbox\"
|
-DG_LOG_DOMAIN=\"Openbox\"
|
||||||
openbox_openbox_LDADD = \
|
openbox_openbox_LDADD = \
|
||||||
$(SM_LIBS) \
|
$(SM_LIBS) \
|
||||||
$(XINERAMA_LIBS) \
|
|
||||||
$(XKB_LIBS) \
|
|
||||||
$(XRANDR_LIBS) \
|
|
||||||
$(XSHAPE_LIBS) \
|
|
||||||
$(XSYNC_LIBS) \
|
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(X_LIBS) \
|
$(X_LIBS) \
|
||||||
$(XCURSOR_LIBS) \
|
$(XCURSOR_LIBS) \
|
||||||
|
@ -228,8 +225,6 @@ openbox_openbox_SOURCES = \
|
||||||
openbox/dock.h \
|
openbox/dock.h \
|
||||||
openbox/event.c \
|
openbox/event.c \
|
||||||
openbox/event.h \
|
openbox/event.h \
|
||||||
openbox/extensions.c \
|
|
||||||
openbox/extensions.h \
|
|
||||||
openbox/focus.c \
|
openbox/focus.c \
|
||||||
openbox/focus.h \
|
openbox/focus.h \
|
||||||
openbox/focus_cycle.c \
|
openbox/focus_cycle.c \
|
||||||
|
@ -399,7 +394,6 @@ pubinclude_HEADERS = \
|
||||||
render/render.h \
|
render/render.h \
|
||||||
render/theme.h \
|
render/theme.h \
|
||||||
parser/parse.h \
|
parser/parse.h \
|
||||||
obt/obt.h \
|
|
||||||
obt/display.h \
|
obt/display.h \
|
||||||
obt/mainloop.h \
|
obt/mainloop.h \
|
||||||
obt/util.h
|
obt/util.h
|
||||||
|
|
|
@ -28,10 +28,22 @@
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#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 gint xerror_handler(Display *d, XErrorEvent *e);
|
||||||
|
|
||||||
static gboolean xerror_ignore = FALSE;
|
static gboolean xerror_ignore = FALSE;
|
||||||
static gboolean xerror_occured = FALSE;
|
|
||||||
|
|
||||||
Display* obt_display_open(const char *display_name)
|
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;
|
n = display_name ? g_strdup(display_name) : NULL;
|
||||||
d = XOpenDisplay(n);
|
d = XOpenDisplay(n);
|
||||||
if (d) {
|
if (d) {
|
||||||
|
gint junk;
|
||||||
|
(void)junk;
|
||||||
|
|
||||||
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
|
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
|
||||||
g_message("Failed to set display as close-on-exec");
|
g_message("Failed to set display as close-on-exec");
|
||||||
XSetErrorHandler(xerror_handler);
|
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);
|
g_free(n);
|
||||||
|
|
||||||
|
@ -72,7 +131,7 @@ static gint xerror_handler(Display *d, XErrorEvent *e)
|
||||||
(void)d; (void)e;
|
(void)d; (void)e;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xerror_occured = TRUE;
|
obt_display_error_occured = TRUE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,10 +139,5 @@ void obt_display_ignore_errors(Display *d, gboolean ignore)
|
||||||
{
|
{
|
||||||
XSync(d, FALSE);
|
XSync(d, FALSE);
|
||||||
xerror_ignore = ignore;
|
xerror_ignore = ignore;
|
||||||
if (ignore) xerror_occured = FALSE;
|
if (ignore) obt_display_error_occured = FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
gboolean obt_display_error_occured()
|
|
||||||
{
|
|
||||||
return xerror_occured;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,20 +16,49 @@
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
See the COPYING file for a copy of the GNU General Public License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __obt_instance_h
|
#ifndef __obt_display_h
|
||||||
#define __obt_instance_h
|
#define __obt_display_h
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <glib.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
|
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);
|
Display* obt_display_open(const char *display_name);
|
||||||
void obt_display_close(Display *d);
|
void obt_display_close(Display *d);
|
||||||
|
|
||||||
void obt_display_ignore_errors(Display *d, gboolean ignore);
|
void obt_display_ignore_errors(Display *d, gboolean ignore);
|
||||||
gboolean obt_display_error_occured();
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /*__obt_instance_h*/
|
#endif /*__obt_display_h*/
|
||||||
|
|
25
obt/obt.h
25
obt/obt.h
|
@ -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*/
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "ping.h"
|
#include "ping.h"
|
||||||
#include "place.h"
|
#include "place.h"
|
||||||
#include "prop.h"
|
#include "prop.h"
|
||||||
#include "extensions.h"
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
@ -1262,7 +1261,7 @@ static void client_get_shaped(ObClient *self)
|
||||||
{
|
{
|
||||||
self->shaped = FALSE;
|
self->shaped = FALSE;
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
if (extensions_shape) {
|
if (obt_display_extension_shape) {
|
||||||
gint foo;
|
gint foo;
|
||||||
guint ufoo;
|
guint ufoo;
|
||||||
gint s;
|
gint s;
|
||||||
|
@ -3639,8 +3638,8 @@ gboolean client_focus(ObClient *self)
|
||||||
obt_display_ignore_errors(ob_display, FALSE);
|
obt_display_ignore_errors(ob_display, FALSE);
|
||||||
|
|
||||||
ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n",
|
ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n",
|
||||||
obt_display_error_occured());
|
obt_display_error_occured);
|
||||||
return !obt_display_error_occured();
|
return !obt_display_error_occured;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void client_present(ObClient *self, gboolean here, gboolean raise,
|
static void client_present(ObClient *self, gboolean here, gboolean raise,
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "moveresize.h"
|
#include "moveresize.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "stacking.h"
|
#include "stacking.h"
|
||||||
#include "extensions.h"
|
|
||||||
#include "translate.h"
|
#include "translate.h"
|
||||||
#include "ping.h"
|
#include "ping.h"
|
||||||
#include "obt/display.h"
|
#include "obt/display.h"
|
||||||
|
@ -180,7 +179,9 @@ static Window event_get_window(XEvent *e)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#ifdef XKB
|
#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) {
|
switch (((XkbAnyEvent*)e)->xkb_type) {
|
||||||
case XkbBellNotify:
|
case XkbBellNotify:
|
||||||
window = ((XkbBellNotifyEvent*)e)->window;
|
window = ((XkbBellNotifyEvent*)e)->window;
|
||||||
|
@ -190,8 +191,8 @@ static Window event_get_window(XEvent *e)
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#ifdef SYNC
|
#ifdef SYNC
|
||||||
if (extensions_sync &&
|
if (obt_display_extension_sync &&
|
||||||
e->type == extensions_sync_event_basep + XSyncAlarmNotify)
|
e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
|
||||||
{
|
{
|
||||||
window = None;
|
window = None;
|
||||||
} else
|
} else
|
||||||
|
@ -229,8 +230,8 @@ static void event_set_curtime(XEvent *e)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#ifdef SYNC
|
#ifdef SYNC
|
||||||
if (extensions_sync &&
|
if (obt_display_extension_sync &&
|
||||||
e->type == extensions_sync_event_basep + XSyncAlarmNotify)
|
e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
|
||||||
{
|
{
|
||||||
t = ((XSyncAlarmNotifyEvent*)e)->time;
|
t = ((XSyncAlarmNotifyEvent*)e)->time;
|
||||||
}
|
}
|
||||||
|
@ -690,8 +691,8 @@ static void event_process(const XEvent *ec, gpointer data)
|
||||||
obt_display_ignore_errors(ob_display, FALSE);
|
obt_display_ignore_errors(ob_display, FALSE);
|
||||||
}
|
}
|
||||||
#ifdef SYNC
|
#ifdef SYNC
|
||||||
else if (extensions_sync &&
|
else if (obt_display_extension_sync &&
|
||||||
e->type == extensions_sync_event_basep + XSyncAlarmNotify)
|
e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
|
||||||
{
|
{
|
||||||
XSyncAlarmNotifyEvent *se = (XSyncAlarmNotifyEvent*)e;
|
XSyncAlarmNotifyEvent *se = (XSyncAlarmNotifyEvent*)e;
|
||||||
if (se->alarm == moveresize_alarm && moveresize_in_progress)
|
if (se->alarm == moveresize_alarm && moveresize_in_progress)
|
||||||
|
@ -1585,7 +1586,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
#ifdef SHAPE
|
#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;
|
client->shaped = ((XShapeEvent*)e)->shaped;
|
||||||
frame_adjust_shape(client->frame);
|
frame_adjust_shape(client->frame);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -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
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "extensions.h"
|
|
||||||
#include "prop.h"
|
#include "prop.h"
|
||||||
#include "grab.h"
|
#include "grab.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -30,6 +29,7 @@
|
||||||
#include "moveresize.h"
|
#include "moveresize.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
|
#include "obt/display.h"
|
||||||
|
|
||||||
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
|
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
|
||||||
ButtonPressMask | ButtonReleaseMask | \
|
ButtonPressMask | ButtonReleaseMask | \
|
||||||
|
|
|
@ -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,
|
XGrabButton(ob_display, button, state | mask_list[i], win, False, mask,
|
||||||
pointer_mode, GrabModeAsync, None, ob_cursor(cur));
|
pointer_mode, GrabModeAsync, None, ob_cursor(cur));
|
||||||
obt_display_ignore_errors(ob_display, FALSE);
|
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);
|
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,
|
XGrabKey(ob_display, keycode, state | mask_list[i], win, FALSE,
|
||||||
GrabModeAsync, keyboard_mode);
|
GrabModeAsync, keyboard_mode);
|
||||||
obt_display_ignore_errors(ob_display, FALSE);
|
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);
|
ob_debug("Failed to grab keycode %d modifiers %d", keycode, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "extensions.h"
|
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
|
#include "obt/display.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <glib.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;
|
moveresize_in_progress = TRUE;
|
||||||
|
|
||||||
#ifdef SYNC
|
#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)
|
moveresize_client->sync_request && moveresize_client->sync_counter)
|
||||||
{
|
{
|
||||||
/* Initialize values for the resize syncing, and create an alarm for
|
/* Initialize values for the resize syncing, and create an alarm for
|
||||||
|
@ -365,7 +365,7 @@ static void do_resize(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SYNC
|
#ifdef SYNC
|
||||||
if (config_resize_redraw && extensions_sync &&
|
if (config_resize_redraw && obt_display_extension_sync &&
|
||||||
moveresize_client->sync_request && moveresize_client->sync_counter)
|
moveresize_client->sync_request && moveresize_client->sync_counter)
|
||||||
{
|
{
|
||||||
XEvent ce;
|
XEvent ce;
|
||||||
|
@ -923,7 +923,7 @@ gboolean moveresize_event(XEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SYNC
|
#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... */
|
waiting_for_sync = FALSE; /* we got our sync... */
|
||||||
do_resize(); /* ...so try resize if there is more change pending */
|
do_resize(); /* ...so try resize if there is more change pending */
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "extensions.h"
|
|
||||||
#include "menuframe.h"
|
#include "menuframe.h"
|
||||||
#include "grab.h"
|
#include "grab.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
|
@ -207,9 +206,7 @@ gint main(gint argc, gchar **argv)
|
||||||
cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner",
|
cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner",
|
||||||
XC_top_left_corner);
|
XC_top_left_corner);
|
||||||
|
|
||||||
|
|
||||||
prop_startup(); /* get atoms values for the display */
|
prop_startup(); /* get atoms values for the display */
|
||||||
extensions_query_all(); /* find which extensions are present */
|
|
||||||
|
|
||||||
if (screen_annex()) { /* it will be ours! */
|
if (screen_annex()) { /* it will be ours! */
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "popup.h"
|
#include "popup.h"
|
||||||
#include "extensions.h"
|
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "obt/display.h"
|
#include "obt/display.h"
|
||||||
|
@ -110,7 +109,7 @@ static gboolean replace_wm(void)
|
||||||
XSync(ob_display, FALSE);
|
XSync(ob_display, FALSE);
|
||||||
|
|
||||||
obt_display_ignore_errors(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;
|
current_wm_sn_owner = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ gboolean screen_annex(void)
|
||||||
XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
|
XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
|
||||||
ROOT_EVENTMASK);
|
ROOT_EVENTMASK);
|
||||||
obt_display_ignore_errors(ob_display, FALSE);
|
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"),
|
g_message(_("A window manager is already running on screen %d"),
|
||||||
ob_screen);
|
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)
|
void screen_update_areas(void)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
|
@ -1299,7 +1347,7 @@ void screen_update_areas(void)
|
||||||
GSList *sit;
|
GSList *sit;
|
||||||
|
|
||||||
g_free(monitor_area);
|
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 */
|
/* set up the user-specified margins */
|
||||||
config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
|
config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
|
||||||
|
|
Loading…
Reference in a new issue