diff --git a/awesome.c b/awesome.c index 2337e3282..fd13f3e79 100644 --- a/awesome.c +++ b/awesome.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "awesome.h" #include "event.h" @@ -277,7 +278,7 @@ main(int argc, char *argv[]) Display * dpy; Window root; awesome_config awesomeconf; - int shape_event; + int shape_event, randr_event_base; if(argc == 2 && !strcmp("-v", argv[1])) eprint("awesome-" VERSION " © 2007 Julien Danjou\n"); @@ -324,6 +325,10 @@ main(int argc, char *argv[]) if((awesomeconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy))) handler[shape_event] = handle_event_shape; + /* check for randr extension */ + if((awesomeconf.have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy))) + handler[randr_event_base + RRScreenChangeNotify] = handle_event_randr_screen_change_notify; + scan(dpy, &dc, &awesomeconf); XSync(dpy, False); diff --git a/config.h b/config.h index a21f4bb13..617605eb0 100644 --- a/config.h +++ b/config.h @@ -141,6 +141,8 @@ struct awesome_config Statusbar statusbar; /** Check for XShape extension */ Bool have_shape; + /** Check for XRandR extension */ + Bool have_randr; }; void parse_config(Display *, int, DC *, awesome_config *); /* parse configuration file */ diff --git a/config.mk b/config.mk index 7e9d7a853..c30f267e6 100644 --- a/config.mk +++ b/config.mk @@ -15,7 +15,7 @@ X11LIB = /usr/lib/X11 # includes and libs INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig` -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext -lXrandr # flags CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O2 ${INCS} -DVERSION=\"${VERSION}\" diff --git a/event.c b/event.c index 26679077a..a6a6765bd 100644 --- a/event.c +++ b/event.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "awesome.h" #include "event.h" @@ -401,6 +402,13 @@ handle_event_shape(XEvent * e, set_shape(c); } +void +handle_event_randr_screen_change_notify(XEvent *e, + awesome_config *awesomeconf __attribute__ ((unused))) +{ + XRRUpdateConfiguration(e); +} + void grabkeys(Display *disp, awesome_config *awesomeconf) { diff --git a/event.h b/event.h index fe906462e..c1fd1091a 100644 --- a/event.h +++ b/event.h @@ -39,5 +39,6 @@ void handle_event_maprequest(XEvent *, awesome_config *); void handle_event_propertynotify(XEvent *, awesome_config *); void handle_event_unmapnotify(XEvent *, awesome_config *); void handle_event_shape(XEvent *, awesome_config *); +void handle_event_randr_screen_change_notify(XEvent *, awesome_config *); #endif