diff --git a/CMakeLists.txt b/CMakeLists.txt index a125157..b1658aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,8 @@ set(LIBRARIES_TO_LINK ${X11_LIBRARIES} confuse Xft - Xinerama) + Xinerama + Xrandr) target_link_libraries(wmfs ${LIBRARIES_TO_LINK}) diff --git a/src/event.c b/src/event.c index 0a95e00..faa72e9 100644 --- a/src/event.c +++ b/src/event.c @@ -497,6 +497,22 @@ unmapnotify(XUnmapEvent *ev) return; } +/** Xrandr screen change notify handle event + *\ param ev XEvent pointer + */ +void +xrandrnotify(XEvent *ev) +{ + XRRUpdateConfiguration(ev); + + /* Reload WMFS to update the screen(s) geometry changement */ + quit(); + for(; argv_global[0] && argv_global[0] == ' '; ++argv_global); + execlp(argv_global, argv_global, NULL); + + return; +} + /** Send a client event *\param data Event data *\param atom_name Event atom name @@ -548,6 +564,10 @@ getevent(XEvent ev) case UnmapNotify: unmapnotify(&ev.xunmap); break; } + /* Check Xrandr event */ + if(ev.type == xrandr_event) + xrandrnotify(&ev); + wait(&st); return; diff --git a/src/init.c b/src/init.c index 81451d0..74854a4 100644 --- a/src/init.c +++ b/src/init.c @@ -60,11 +60,14 @@ void init_font(void) { font = XftFontOpenName(dpy, SCREEN, conf.font); + if(!font) { fprintf(stderr, "WMFS Error: Cannot initialize font\n"); font = XftFontOpenName(dpy, SCREEN, "sans-10"); } + + return; } /** Init the graphic context @@ -99,11 +102,11 @@ init_gc(void) void init_cursor(void) { - cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); - cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); + cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); + cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurRightResize] = XCreateFontCursor(dpy, XC_lr_angle); - cursor[CurLeftResize] = XCreateFontCursor(dpy, XC_ll_angle); - cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); + cursor[CurLeftResize] = XCreateFontCursor(dpy, XC_ll_angle); + cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); return; } @@ -159,6 +162,7 @@ init_layout(void) const func_name_list_t layout_list_tmp[] = { + {"tile", tile }, {"tile_right", tile }, {"tile_left", tile_left }, {"tile_top", tile_top }, diff --git a/src/screen.c b/src/screen.c index 3a2d1fc..6b7dda4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -63,7 +63,6 @@ screen_get_geo(int s) int barpos = tags[selscreen][seltag[selscreen]].barpos; XRectangle geo; - if(XineramaIsActive(dpy)) { XineramaScreenInfo *xsi; @@ -159,7 +158,7 @@ screen_get_sel(void) void screen_init_geo(void) { - int i, n; + int i, n, randr_e, d; XineramaScreenInfo *xsi; sgeo = emalloc(screen_count(), sizeof(XRectangle)); @@ -188,6 +187,12 @@ screen_init_geo(void) spgeo[0].height = MAXH; } + /* Init Xrandr stuff for event */ + if(XRRQueryExtension(dpy, &randr_e, &d)) + xrandr_event = randr_e + RRScreenChangeNotify; + else + xrandr_event = -1; + ewmh_set_desktop_geometry(); ewmh_set_workarea(); diff --git a/src/wmfs.h b/src/wmfs.h index e58fc83..25523c7 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -51,6 +51,7 @@ #include #include #include +#include /* Local headers */ #include "config.h" @@ -201,6 +202,8 @@ void keypress(XKeyPressedEvent *ev); void mappingnotify(XMappingEvent *ev); void maprequest(XMapRequestEvent *ev); void propertynotify(XPropertyEvent *ev); +void unmapnotify(XUnmapEvent *ev); +void xrandrnotify(XEvent *ev); void send_client_event(long data[5], char *atom_name); void getevent(XEvent ev); @@ -334,12 +337,15 @@ XRectangle *sgeo; XRectangle *spgeo; Cursor cursor[CurLast]; char *argv_global; +int xrandr_event; /* Fonts */ XftFont *font; + +/* Atoms list */ Atom net_atom[net_last]; -/* InfoBar */ +/* InfoBar/Tags */ InfoBar *infobar; Tag **tags; int *seltag;