[sawfish] added randr-changed-notify-hook & stub
- From: Christopher Bratusek <chrisb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sawfish] added randr-changed-notify-hook & stub
- Date: Tue, 27 Apr 2010 14:51:24 +0000 (UTC)
commit 071c443cc19b222ebc95dd91ff3ffcc247a57cdf
Author: Christopher Roy Bratusek <zanghar freenet de>
Date: Tue Apr 27 16:50:31 2010 +0200
added randr-changed-notify-hook & stub
ChangeLog | 6 +++++
man/news.texi | 3 ++
src/Makefile.in | 8 +++---
src/display.c | 2 +-
src/events.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 76 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b93a28f..6f1e70e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,12 @@
line is not [Desktop Entry].
-- [Matthew Love/Teika Kazura]
+ * src/Makefile.in
+ * src/display.c
+ * src/events.c: add a way to response to XRandR changed events
+ eg resolution changes via randr-change-notify-hook
+ -- [Daniel M. German]
+
2010-04-06 Teika Kazura <teika lavabit com>
* lisp/sawfish/wm/autoload.jl
* lisp/sawfish/wm/commands.jl
diff --git a/man/news.texi b/man/news.texi
index 8ee28c9..e2ba0fc 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -36,6 +36,9 @@ the file, if the first valid line is not [Desktop Entry].
@item New Features
@itemize @minus
+ item Added a way to response to XRandR changed events (eg resolution changes)
+via @code{randr-changed-notify-hook} [Daniel M. German]
+
@item Tabbed windowing system improvements [Fuchur]
@itemize +
@item Support for transient tab-frames
diff --git a/src/Makefile.in b/src/Makefile.in
index c19f13c..04dfdd2 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -39,14 +39,14 @@ DL_DIRS = sawfish/wm/util
INSTALL_HDRS = sawfish.h sawfish_subrs.h libclient.h server.h keys.h build.h
-override CFLAGS := $(CFLAGS) $(REP_CFLAGS) $(IMAGE_CFLAGS) $(X11_CFLAGS) $(PANGO_CFLAGS)
+override CFLAGS := $(CFLAGS) $(REP_CFLAGS) $(IMAGE_CFLAGS) $(X11_CFLAGS) $(PANGO_CFLAGS)
all : sawfish libclient.o $(DL_OBJS) .libexec gtk-style
sawfish : $(OBJS) $(LIBOBJS)
$(rep_LIBTOOL) --mode=link --tag=CC $(CC) -export-dynamic $(LDFLAGS) \
-o sawfish $(OBJS) $(LIBOBJS) $(REP_LIBS) $(PANGO_LIBS) \
- $(IMAGE_LIBS) $(X11_LIBS) $(EXTRA_X11_LIBS) $(LIBS)
+ $(IMAGE_LIBS) $(X11_LIBS) $(EXTRA_X11_LIBS) $(LIBS) $(XRANDR_LIBS)
%.la : %.lo
$(rep_DL_LD) $(LDFLAGS) -o $@ $<
@@ -55,10 +55,10 @@ libclient_.lo : libclient.c
$(rep_LIBTOOL) --mode=compile --tag=CC $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
client.la : client.lo libclient_.lo
- $(rep_DL_LD) $(LDFLAGS) -o $@ $^ $(X11_LIBS) $(REP_LIBS) $(LIBS)
+ $(rep_DL_LD) $(LDFLAGS) -o $@ $^ $(X11_LIBS) $(REP_LIBS) $(LIBS) $(XRANDR_LIBS)
gtk-style : gtk-style.c
- $(CC) $(CFLAGS) $(CPPFLAGS) $(GTK_CFLAGS) $(LDFLAGS) -o $@ $< $(GTK_LIBS) $(LIBS)
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(GTK_CFLAGS) $(LDFLAGS) -o $@ $< $(GTK_LIBS) $(LIBS) $(XRANDR_LIBS)
install : all installdirs
for p in sawfish; do \
diff --git a/src/display.c b/src/display.c
index d1378b0..24d622c 100644
--- a/src/display.c
+++ b/src/display.c
@@ -45,7 +45,7 @@
#endif
char *visual_name;
-Display *dpy;
+Display *dpy = NULL;
int screen_num, screen_width, screen_height;
Window root_window, no_focus_window;
int shape_event_base, shape_error_base;
diff --git a/src/events.c b/src/events.c
index 629799c..dec7716 100644
--- a/src/events.c
+++ b/src/events.c
@@ -31,6 +31,7 @@
#include <X11/Xresource.h>
#include <X11/Xatom.h>
#include <glib.h>
+#include <stdio.h>
/* Lookup table of event handlers */
void (*event_handlers[LASTEvent])(XEvent *ev);
@@ -69,6 +70,13 @@ static XID event_handler_context;
static Atom xa_sawfish_timestamp;
+/* is there xrand support? */
+static int has_randr = FALSE;
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+static int randr_event_base; /* Will give us the offset for the xrandr events */
+#endif
+
+
DEFSYM(visibility_notify_hook, "visibility-notify-hook");
DEFSYM(destroy_notify_hook, "destroy-notify-hook");
DEFSYM(map_notify_hook, "map-notify-hook");
@@ -89,6 +97,11 @@ DEFSYM(enter_frame_part_hook, "enter-frame-part-hook");
DEFSYM(leave_frame_part_hook, "leave-frame-part-hook");
DEFSYM(configure_request_hook, "configure-request-hook");
DEFSYM(configure_notify_hook, "configure-notify-hook");
+
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+DEFSYM(randr_change_notify_hook, "randr-change-notify-hook");
+#endif
+
DEFSYM(window_state_change_hook, "window-state-change-hook");
DEFSYM(pointer_motion_threshold, "pointer-motion-threshold");
@@ -1265,6 +1278,20 @@ shape_notify (XEvent *ev)
}
}
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+static void
+randr_screen_change_notify (XEvent *ev)
+{
+ // Only do it if we are sure we are handling the event
+ if (has_randr) {
+ fprintf(stderr, "Yes, we are handling the screen change event\n");
+ // We should add the call to the hook
+ XRRUpdateConfiguration( ev );
+ // Call the hook
+ Fcall_hook(Qrandr_change_notify_hook, Qnil, Qnil);
+ }
+}
+#endif
static int synthetic_configure_mutex;
@@ -1407,7 +1434,11 @@ inner_handle_input (repv arg)
event_handlers[ev->type] (ev);
else if (ev->type == shape_event_base + ShapeNotify)
shape_notify (ev);
- else
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+ else if (ev->type == randr_event_base + RRScreenChangeNotify)
+ randr_screen_change_notify(ev);
+#endif
+ else
fprintf (stderr, "warning: unhandled event: %d\n", ev->type);
return Qnil;
}
@@ -1676,7 +1707,27 @@ void
events_init (void)
{
repv tem;
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+ int dummy;
+#endif
+ has_randr = FALSE;
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+ // This code is executed even in batch mode, in
+ // which case dpy is not set
+ if (dpy != NULL) {
+ has_randr = XRRQueryExtension( dpy, &randr_event_base, &dummy );
+ if( has_randr )
+ {
+ int major, minor;
+ XRRQueryVersion( dpy, &major, &minor );
+ has_randr = ( major > 1 || ( major == 1 && minor >= 1 ) );
+ fprintf(stderr, "it Has randr %d\n", has_randr);
+ XRRSelectInput( dpy, root_window, RRScreenChangeNotifyMask );
+ }
+ }
+
+#endif
event_handlers[VisibilityNotify] = visibility_notify;
event_handlers[ColormapNotify] = colormap_notify;
event_handlers[KeyPress] = key_press;
@@ -1703,6 +1754,16 @@ events_init (void)
event_handlers[CirculateNotify] = circulate_notify;
event_handlers[MappingNotify] = mapping_notify;
+#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
+ if (has_randr)
+ {
+ fprintf(stderr, "Setting handler at event %d\n", randr_event_base + RRScreenChangeNotify);
+ // we can't handle the event in the usual manner because the sizes of the
+ // arrays event_handler and event_names are defined at compile time.
+ rep_INTERN_SPECIAL(randr_change_notify_hook);
+ }
+#endif
+
event_names[KeyPress] = "KeyPress";
event_names[KeyRelease] = "KeyRelease";
event_names[ButtonPress] = "ButtonPress";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]