diff --git a/src/event.c b/src/event.c index 6e6e487..9db89b3 100644 --- a/src/event.c +++ b/src/event.c @@ -638,11 +638,12 @@ motionnotify(XEvent *e) /** XRandr handle event */ #ifdef HAVE_XRANDR -static void +void xrandrevent(XEvent *e) { /* Update xrandr configuration */ - XRRUpdateConfiguration(e); + if(!XRRUpdateConfiguration(e)) + return; /* Reload WMFS to update the screen(s) geometry changement */ quit(); @@ -701,10 +702,6 @@ event_make_array(void) event_handle[SelectionClear] = selectionclearevent; event_handle[UnmapNotify] = unmapnotify; -#ifdef HAVE_XRANDR - event_handle[xrandr_event] = xrandrevent; -#endif /* HAVE_XRANDR */ - return; } diff --git a/src/init.c b/src/init.c index b8392f4..a2ee26b 100644 --- a/src/init.c +++ b/src/init.c @@ -201,6 +201,7 @@ void init(void) { /* First init */ + event_make_array(); ewmh_init_hints(); init_conf(); init_gc(); @@ -214,7 +215,6 @@ init(void) init_status(); ewmh_update_current_tag_prop(); grabkeys(); - event_make_array(); return; } diff --git a/src/launcher.c b/src/launcher.c index 2b4e78b..f1f7d99 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -354,7 +354,12 @@ launcher_execute(Launcher *launcher) barwin_draw_text(bw, 1 + textw(launcher->prompt) + textw(" "), FHINFOBAR - 1, buf); barwin_refresh(bw); } - else if(ev.type < LASTEvent) + else +#ifdef HAVE_XRANDR + if(ev.type == xrandr_event + RRScreenChangeNotify) + xrandrevent(&ev); + else +#endif /* HAVE_XRANDR */ HANDLE_EVENT(&ev); XNextEvent(dpy, &ev); diff --git a/src/menu.c b/src/menu.c index e6ba1e2..1c5ad20 100644 --- a/src/menu.c +++ b/src/menu.c @@ -221,6 +221,11 @@ menu_manage_event(XEvent *ev, Menu *menu, BarWindow *winitem[]) break; default: +#ifdef HAVE_XRANDR + if(ev->type == xrandr_event + RRScreenChangeNotify) + xrandrevent(ev); + else +#endif /* HAVE_XRANDR */ if(ev->type < LASTEvent) HANDLE_EVENT(ev); break; diff --git a/src/wmfs.c b/src/wmfs.c index 0e7fdec..21bb5fe 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -200,7 +200,12 @@ mainloop(void) while(!exiting && !XNextEvent(dpy, &ev)) { - HANDLE_EVENT(&ev); +#ifdef HAVE_XRANDR + if(ev.type == xrandr_event + RRScreenChangeNotify) + xrandrevent(&ev); + else +#endif /* HAVE_XRANDR */ + HANDLE_EVENT(&ev); wait_childs_and_status(); } @@ -210,7 +215,6 @@ mainloop(void) return; } - /** Set the exiting variable to True * for stop the main loop * \param cmd unused uicb_t @@ -449,7 +453,7 @@ int main(int argc, char **argv) { int i; - char *ol = "csgVS"; + char *ol = "csVS"; extern char *optarg; extern int optind; struct sigaction sa; diff --git a/src/wmfs.h b/src/wmfs.h index c5e9fb6..e628841 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -261,6 +261,10 @@ uint color_shade(uint, double); void grabkeys(void); void event_make_array(void); +#ifdef HAVE_XRANDR +void xrandrevent(XEvent *e); +#endif /* HAVE_XRANDR */ + /* menu.c */ void menu_init(Menu *menu, char *name, int nitem, uint bg_f, char *fg_f, uint bg_n, char *fg_n); void menu_new_item(MenuItem *mi, char *name, void *func, char *cmd);