From 5a25eaeff5e41846264904721b8f74ed15c84725 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Mon, 16 Nov 2009 19:40:33 +0100 Subject: [PATCH 01/11] Ewmh/Event: Fix _WMFS_STATUSTEXT_x mistake --- src/event.c | 2 +- src/ewmh.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/event.c b/src/event.c index 96465e1..e2cec25 100644 --- a/src/event.c +++ b/src/event.c @@ -151,7 +151,7 @@ clientmessageevent(XClientMessageEvent *ev) if(ev->format != 32) return; - for(i = 0; i < net_last; ++i) + for(i = 0; i < net_last + screen_count(); ++i) if(net_atom[i] == ev->message_type) mess_t = i; diff --git a/src/ewmh.c b/src/ewmh.c index ff5ccac..00bcb5d 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -47,7 +47,7 @@ ewmh_init_hints(void) char class[] = "wmfs", st[64]; long pid = (long)getpid(); - net_atom = emalloc(net_last + screen_count() + 1, sizeof(Atom)); + net_atom = emalloc(net_last + screen_count(), sizeof(Atom)); /* EWMH hints */ net_atom[net_supported] = ATOM("_NET_SUPPORTED"); @@ -98,9 +98,8 @@ ewmh_init_hints(void) net_atom[wmfs_statustext + j] = ATOM(st); } - XChangeProperty(dpy, ROOT, net_atom[net_supported], XA_ATOM, 32, - PropModeReplace, (uchar*)net_atom, net_last); + PropModeReplace, (uchar*)net_atom, net_last + screen_count()); XChangeProperty(dpy, ROOT, net_atom[wmfs_running], XA_CARDINAL, 32, PropModeReplace, (uchar*)&i, 1); From 3bb9ed108caec7425c0d7b99253dc13c7a64cc55 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 17 Nov 2009 20:00:05 +0100 Subject: [PATCH 02/11] Set new version... --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f47316c..68177e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ set(wmfs_src add_executable(wmfs ${wmfs_src}) # Set the version -set(VERSION "WMFS-200910") +set(VERSION "WMFS-200911") # FLAGS set(CFLAGS "-g -Wall -ansi") From 4beaeb7a14db83a4e99b3faf9a1cd547c7272d85 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 21 Nov 2009 22:11:06 +0100 Subject: [PATCH 03/11] Client/Conf: Fix the mistake of the autistic linkdd.. --- src/client.c | 2 +- src/config.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index 34d5254..8d54598 100644 --- a/src/client.c +++ b/src/client.c @@ -558,7 +558,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar) if(ar) arrange(c->screen, True); - if(conf.client.set_new_win_master) + if(!conf.client.set_new_win_master) layout_set_client_master(c); return c; diff --git a/src/config.c b/src/config.c index 5829cec..01fa157 100644 --- a/src/config.c +++ b/src/config.c @@ -206,7 +206,7 @@ conf_client_section(char *src) conf.client.resizecorner_normal = getcolor(get_opt(src, "#222222", "resize_corner_normal").str); conf.client.resizecorner_focus = getcolor(get_opt(src, "#DDDDDD", "resize_corner_focus").str); conf.client.mod |= char_to_modkey(get_opt(src, "Alt", "modifier").str, key_list); - conf.client.set_new_win_master = get_opt(src, "false", "set_new_win_master").bool; + conf.client.set_new_win_master = get_opt(src, "true", "set_new_win_master").bool; if((conf.client.nmouse = get_size_sec(src, "mouse"))) { From f916b8e0cbb62f31692781ca286954b106f60d1a Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 22 Nov 2009 20:29:43 +0100 Subject: [PATCH 04/11] Init: Load ~/.config/wmfs/status.sh at startup (if status.sh is +x) --- rc/status.sh | 20 ++++++++++++++++++++ src/event.c | 5 +++-- src/init.c | 34 ++++++++++++++++++++++++++++++++++ src/wmfs.c | 2 +- src/wmfs.h | 2 ++ 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100755 rc/status.sh diff --git a/rc/status.sh b/rc/status.sh new file mode 100755 index 0000000..6f885ed --- /dev/null +++ b/rc/status.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Print + +TIMING=1 +RET=0 + +statustext() +{ + local DATE=`date` + + wmfs -s "$DATE" + + RET=$? +} + +while [[ $RET == "0" ]]; +do + statustext + sleep $TIMING +done diff --git a/src/event.c b/src/event.c index e2cec25..a222d5f 100644 --- a/src/event.c +++ b/src/event.c @@ -253,7 +253,7 @@ configureevent(XConfigureRequestEvent *ev) CHECK(!(c->flags & FSSFlag)); } - if((c= client_gb_win(ev->window))) + if((c = client_gb_win(ev->window))) { if(ev->value_mask & CWX) c->geo.x = ev->x + BORDH; @@ -264,7 +264,8 @@ configureevent(XConfigureRequestEvent *ev) if(ev->value_mask & CWHeight) c->geo.height = ev->height; - client_moveresize(c, c->geo, False); + if(c->flags & FreeFlag) + client_moveresize(c, c->geo, False); } else { diff --git a/src/init.c b/src/init.c index e88f768..c62cd6a 100644 --- a/src/init.c +++ b/src/init.c @@ -48,6 +48,7 @@ init(void) init_root(); screen_init_geo(); infobar_init(); + init_status(); ewmh_update_current_tag_prop(); grabkeys(); @@ -189,4 +190,37 @@ init_layout(void) return; } +/** Init statustext shell script + */ +void +init_status(void) +{ + char *path; + int fd; + struct stat st; + + path = emalloc(strlen(getenv("HOME")) + strlen(DEF_STATUS) + 2, sizeof(char)); + + sprintf(path, "%s/"DEF_STATUS, getenv("HOME")); + + if(!(fd = open(path, O_RDONLY))) + { + free(path); + + return; + } + + stat(path, &st); + + if(st.st_mode & S_IXUSR) + spawn(path); + else + warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.", path); + + close(fd); + + free(path); + + return; +} diff --git a/src/wmfs.c b/src/wmfs.c index 134f900..0a7f78e 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -402,7 +402,7 @@ main(int argc, char **argv) break; case 'v': - printf("WMFS version : "WMFS_VERSION".\n" + printf("WMFS version : "WMFS_VERSION"\n" " Compilation settings :\n" " - Flags : "WMFS_COMPILE_FLAGS"\n" " - Linked Libs : "WMFS_LINKED_LIBS"\n" diff --git a/src/wmfs.h b/src/wmfs.h index 5b75d91..73b89d0 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -84,6 +84,7 @@ #define RESHW (6 * BORDH) #define BUTTONWH (TBARH / 2) #define DEF_CONF ".config/wmfs/wmfsrc" +#define DEF_STATUS ".config/wmfs/status.sh" #define PAD conf.pad #define CWIN(win, parent, x, y, w, h, b, mask, col, at) \ @@ -314,6 +315,7 @@ void init_gc(void); void init_cursor(void); void init_key(void); void init_geometry(void); +void init_status(void); /* getinfo.c */ void getinfo_tag(void); From 5d0b9229075d1bb49360b4c11de7555ba0d244ba Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 25 Dec 2009 21:25:20 +0100 Subject: [PATCH 05/11] Client/Layout: Add abovefc option and toggle uicb fonction. Requested by Arpinux. --- CMakeLists.txt | 2 +- src/client.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- src/config.c | 4 +++- src/event.c | 7 ++++--- src/layout.c | 16 ++++++++++++++++ src/structs.h | 2 ++ src/wmfs.h | 2 ++ 7 files changed, 73 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68177e4..ebf1c81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ set(wmfs_src add_executable(wmfs ${wmfs_src}) # Set the version -set(VERSION "WMFS-200911") +set(VERSION "WMFS-200912") # FLAGS set(CFLAGS "-g -Wall -ansi") diff --git a/src/client.c b/src/client.c index 8d54598..bbe8a88 100644 --- a/src/client.c +++ b/src/client.c @@ -193,6 +193,33 @@ uicb_client_swap_prev(uicb_t cmd) return; } +/** Set the client c above + *\param c Client pointer +*/ +void +client_above(Client *c) +{ + XRectangle geo = { 0 }; + + if(c->flags & AboveFlag) + return; + + c->flags |= AboveFlag; + + geo.height = sgeo[c->screen].height * 0.75; + geo.width = sgeo[c->screen].width * 0.75; + + geo.x = (sgeo[c->screen].height - geo.height) / 2; + geo.y = (sgeo[c->screen].width - geo.width) / 2; + + client_moveresize(c, geo, True); + client_raise(c); + + tags[c->screen][c->tag].layout.func(c->screen); + + return; +} + /** Set the focus to a client * \param c Client pointer */ @@ -207,15 +234,18 @@ client_focus(Client *c) sel->colors.frame = conf.client.bordernormal; sel->colors.fg = conf.titlebar.fg_normal; sel->colors.resizecorner = conf.client.resizecorner_normal; + if(TBARH - BORDH && sel->titlebar->stipple) sel->titlebar->stipple_color = conf.titlebar.stipple.colors.normal; + + if(sel->flags & AboveFlag) + sel->flags &= ~AboveFlag; + frame_update(sel); mouse_grabbuttons(sel, False); } - sel = c; - - if(c) + if((sel = c)) { c->colors.frame = conf.client.borderfocus; c->colors.fg = conf.titlebar.fg_focus; @@ -235,6 +265,10 @@ client_focus(Client *c) client_raise(c); } + if(tags[sel->screen][sel->tag].abovefc + && !conf.focus_fmouse) + client_above(sel); + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); } else @@ -842,7 +876,7 @@ client_update_attributes(Client *c) void client_raise(Client *c) { - if(!c || (c->flags & TileFlag)) + if(!c || ((c->flags & TileFlag) && !(c->flags & AboveFlag))) return; XRaiseWindow(dpy, c->frame); @@ -883,6 +917,8 @@ void client_unmanage(Client *c) { Client *c_next = NULL; + Bool b = False; + int i; XGrabServer(dpy); XSetErrorHandler(errorhandlerdummy); @@ -900,7 +936,11 @@ client_unmanage(Client *c) ewmh_get_client_list(); /* Arrange */ - if(c->tag == seltag[selscreen] && c->screen == selscreen) + for(i = 0; i < screen_count() && !b; ++i) + if(c->tag == seltag[i]) + b = True; + + if(b) tags[c->screen][c->tag].layout.func(c->screen); else { diff --git a/src/config.c b/src/config.c index 01fa157..2a1bcba 100644 --- a/src/config.c +++ b/src/config.c @@ -63,6 +63,7 @@ func_name_list_t tmp_func_list[] = {"mouse_resize", uicb_mouse_resize }, {"client_raise", uicb_client_raise }, {"toggle_free", uicb_togglefree }, + {"toggle_abovefc", uicb_toggle_abovefc }, {"screen_select", uicb_screen_select }, {"screen_next", uicb_screen_next }, {"screen_prev", uicb_screen_prev }, @@ -369,7 +370,7 @@ conf_tag_section(char *src) * MAXTAG (32) print an error and create only one. */ Tag default_tag = { "WMFS", NULL, 0, 1, - 0.50, 1, False, False, IB_Top, + 0.50, 1, False, False, False, IB_Top, layout_name_to_struct(conf.layout, "tile_right", conf.nlayout, layout_list) }; cfg_set_sauv(src); @@ -413,6 +414,7 @@ conf_tag_section(char *src) tags[k][conf.ntag[k]].mwfact = get_opt(cfgtmp, "0.65", "mwfact").fnum; tags[k][conf.ntag[k]].nmaster = get_opt(cfgtmp, "1", "nmaster").num; tags[k][conf.ntag[k]].resizehint = get_opt(cfgtmp, "false", "resizehint").bool; + tags[k][conf.ntag[k]].abovefc = get_opt(cfgtmp, "false", "abovefc").bool; tags[k][conf.ntag[k]].layers = 1; tmp = _strdup(get_opt(cfgtmp, "top", "infobar_position").str); diff --git a/src/event.c b/src/event.c index a222d5f..f879e4b 100644 --- a/src/event.c +++ b/src/event.c @@ -317,14 +317,15 @@ enternotify(XCrossingEvent *ev) if(conf.focus_fmouse) { if((c = client_gb_win(ev->window)) - || (c = client_gb_frame(ev->window)) - || (c = client_gb_titlebar(ev->window)) - || (c = client_gb_button(ev->window, &n))) + || (c = client_gb_frame(ev->window)) + || (c = client_gb_titlebar(ev->window)) + || (c = client_gb_button(ev->window, &n))) client_focus(c); else client_focus(NULL); } + return; } diff --git a/src/layout.c b/src/layout.c index 3bd7316..78d7f74 100644 --- a/src/layout.c +++ b/src/layout.c @@ -168,6 +168,7 @@ tiled_client(int screen, Client *c) for(;c && ((c->flags & MaxFlag) || (c->flags & FreeFlag) || (c->flags & FSSFlag) + || (c->flags & AboveFlag) || c->screen != screen || ishide(c, screen)); c = c->next); @@ -830,6 +831,21 @@ uicb_toggle_resizehint(uicb_t cmd) return; } +/** Toggle abovefc option + *\param cmd uicb_t type + */ +void +uicb_toggle_abovefc(uicb_t cmd) +{ + screen_get_sel(); + + tags[selscreen][seltag[selscreen]].abovefc = !tags[selscreen][seltag[selscreen]].abovefc; + + client_focus(sel); + + return; +} + /** Set the layout * \param cmd uicb_t type */ diff --git a/src/structs.h b/src/structs.h index 150e2b5..23db925 100644 --- a/src/structs.h +++ b/src/structs.h @@ -48,6 +48,7 @@ #define UnmapFlag (1 << 6) #define HintFlag (1 << 7) #define FSSFlag (1 << 8) +#define AboveFlag (1 << 9) /* XEMBED messages */ #define XEMBED_MAPPED (1 << 0) @@ -248,6 +249,7 @@ typedef struct int nmaster; Bool resizehint; Bool request_update; + Bool abovefc; int barpos; Layout layout; } Tag; diff --git a/src/wmfs.h b/src/wmfs.h index 73b89d0..2db66b3 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -141,6 +141,7 @@ void uicb_infobar_togglepos(uicb_t); void client_attach(Client *c); void client_configure(Client *c); void client_detach(Client *c); +void client_above(Client *c); void client_focus(Client *c); Client* client_get_next(void); Client* client_get_prev(void); @@ -302,6 +303,7 @@ void uicb_set_mwfact(uicb_t); void uicb_set_nmaster(uicb_t); void uicb_set_layout(uicb_t); void uicb_toggle_resizehint(uicb_t); +void uicb_toggle_abovefc(uicb_t cmd); void uicb_set_layer(uicb_t cmd); void uicb_set_client_layer(uicb_t cmd); void layout_set_client_master(Client *c); From 8c4641f7e5bde886d8c71f71fc67f6449cae60fc Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 26 Dec 2009 00:49:27 +0100 Subject: [PATCH 06/11] Client: Abovefc option improved, better management of multi-head --- src/client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client.c b/src/client.c index bbe8a88..1463c43 100644 --- a/src/client.c +++ b/src/client.c @@ -206,13 +206,13 @@ client_above(Client *c) c->flags |= AboveFlag; - geo.height = sgeo[c->screen].height * 0.75; - geo.width = sgeo[c->screen].width * 0.75; + geo.height = spgeo[c->screen].height * 0.75; + geo.width = spgeo[c->screen].width * 0.75; - geo.x = (sgeo[c->screen].height - geo.height) / 2; - geo.y = (sgeo[c->screen].width - geo.width) / 2; + geo.x = ((spgeo[c->screen].y + spgeo[c->screen].height) / 2) - (geo.height / 2); + geo.y = ((spgeo[c->screen].x + spgeo[c->screen].width) / 2)- (geo.width / 2); - client_moveresize(c, geo, True); + client_moveresize(c, geo, tags[c->screen][c->tag].resizehint); client_raise(c); tags[c->screen][c->tag].layout.func(c->screen); From 0a09838b80a8478437f9232f8f26e1ceddd00797 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 26 Dec 2009 15:25:29 +0100 Subject: [PATCH 07/11] Layout: Fix mistake when toggle of abovecf (arrangement) --- src/layout.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/layout.c b/src/layout.c index 78d7f74..e573538 100644 --- a/src/layout.c +++ b/src/layout.c @@ -837,9 +837,21 @@ uicb_toggle_resizehint(uicb_t cmd) void uicb_toggle_abovefc(uicb_t cmd) { + Client *c; + screen_get_sel(); - tags[selscreen][seltag[selscreen]].abovefc = !tags[selscreen][seltag[selscreen]].abovefc; + if(!(tags[selscreen][seltag[selscreen]].abovefc = !tags[selscreen][seltag[selscreen]].abovefc)) + { + for(c = clients; c; c = c->next) + if(c->flags & AboveFlag) + { + c->flags &= ~AboveFlag; + break; + } + + tags[selscreen][seltag[selscreen]].layout.func(selscreen); + } client_focus(sel); From 436d28d248c251f28361d6794d6bb5aff622ed80 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 26 Dec 2009 15:26:42 +0100 Subject: [PATCH 08/11] Layout: Fix mistake when toggle of abovecf (arragement per tag) --- src/layout.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/layout.c b/src/layout.c index e573538..7704029 100644 --- a/src/layout.c +++ b/src/layout.c @@ -844,7 +844,9 @@ uicb_toggle_abovefc(uicb_t cmd) if(!(tags[selscreen][seltag[selscreen]].abovefc = !tags[selscreen][seltag[selscreen]].abovefc)) { for(c = clients; c; c = c->next) - if(c->flags & AboveFlag) + if(c->flags & AboveFlag + && c->screen == selscreen + && c->tag == seltag[selscreen]) { c->flags &= ~AboveFlag; break; From f62e59117f4ec78b7a5feb2c216e4a36f4c47fa2 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 27 Dec 2009 11:19:15 +0100 Subject: [PATCH 09/11] Client: Fix client_above function (multi-head placement) --- src/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index 1463c43..9bed5d0 100644 --- a/src/client.c +++ b/src/client.c @@ -209,8 +209,8 @@ client_above(Client *c) geo.height = spgeo[c->screen].height * 0.75; geo.width = spgeo[c->screen].width * 0.75; - geo.x = ((spgeo[c->screen].y + spgeo[c->screen].height) / 2) - (geo.height / 2); - geo.y = ((spgeo[c->screen].x + spgeo[c->screen].width) / 2)- (geo.width / 2); + geo.y = spgeo[c->screen].y + (spgeo[c->screen].height / 2) - (geo.height / 2); + geo.x = spgeo[c->screen].x + (spgeo[c->screen].width / 2)- (geo.width / 2); client_moveresize(c, geo, tags[c->screen][c->tag].resizehint); client_raise(c); From 796a72ecb89029e0d4a29a72e058115a06f1d726 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 1 Jan 2010 23:24:01 +0100 Subject: [PATCH 10/11] Wmfs: Thread WMFS if status.sh is present, So update status.sh by itself each status_timing second, and add wmfs -S to update status.sh. !REPLACE YOUR STATUS.SH! (no loop anymore in the script) Requested by Matrhack. --- CMakeLists.txt | 2 +- rc/status.sh | 15 +++-------- src/config.c | 17 ++++++++---- src/event.c | 4 +++ src/ewmh.c | 1 + src/init.c | 21 ++++++++------- src/structs.h | 2 ++ src/wmfs.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++---- src/wmfs.h | 8 ++++-- wmfs.1 | 7 ++++- 10 files changed, 114 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebf1c81..3ddc626 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ add_executable(wmfs ${wmfs_src}) set(VERSION "WMFS-200912") # FLAGS -set(CFLAGS "-g -Wall -ansi") +set(CFLAGS "-g -Wall -lpthread -ansi") set(CMAKE_C_FLAGS ${CFLAGS}) # Linker FLAGS diff --git a/rc/status.sh b/rc/status.sh index 6f885ed..bd07953 100755 --- a/rc/status.sh +++ b/rc/status.sh @@ -1,20 +1,13 @@ #!/bin/sh -# Print - -TIMING=1 -RET=0 +#WMFS status.sh example file +#Will be executed if put in ~/.config/wmfs/ +#Timing adjustable in wmfsrc (misc -> status_timing) statustext() { local DATE=`date` wmfs -s "$DATE" - - RET=$? } -while [[ $RET == "0" ]]; -do - statustext - sleep $TIMING -done +statustext diff --git a/src/config.c b/src/config.c index 2a1bcba..d59b6fe 100644 --- a/src/config.c +++ b/src/config.c @@ -136,11 +136,12 @@ conf_misc_section(char *src) cfg_set_sauv(src); - conf.font = get_opt(src, "sans-9", "font").str; - conf.raisefocus = get_opt(src, "false", "raisefocus").bool; - conf.raiseswitch = get_opt(src, "false", "raiseswitch").bool; - conf.focus_fmouse = get_opt(src, "true", "focus_follow_mouse").bool; - pad = get_opt(src, "12", "pad").num; + conf.font = get_opt(src, "sans-9", "font").str; + conf.raisefocus = get_opt(src, "false", "raisefocus").bool; + conf.raiseswitch = get_opt(src, "false", "raiseswitch").bool; + conf.focus_fmouse = get_opt(src, "true", "focus_follow_mouse").bool; + conf.status_timing = get_opt(src, "1", "status_timing").num; + pad = get_opt(src, "12", "pad").num; if(pad > 24 || pad < 1) { @@ -151,6 +152,12 @@ conf_misc_section(char *src) conf.pad = pad; + if(conf.status_timing <= 0) + { + warnx("configuration : status_timing value (%d) incorrect.", conf.status_timing); + conf.status_timing = 1; + } + return; } diff --git a/src/event.c b/src/event.c index f879e4b..ddc0566 100644 --- a/src/event.c +++ b/src/event.c @@ -231,6 +231,10 @@ clientmessageevent(XClientMessageEvent *ev) screen_get_sel(); } + if(mess_t == wmfs_update_status + && estatus) + spawn(status_path); + return; } diff --git a/src/ewmh.c b/src/ewmh.c index 00bcb5d..e4178ac 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -80,6 +80,7 @@ ewmh_init_hints(void) /* WMFS hints */ net_atom[wmfs_running] = ATOM("_WMFS_RUNNING"); net_atom[wmfs_update_hints] = ATOM("_WMFS_UPDATE_HINTS"); + net_atom[wmfs_update_status] = ATOM("_WMFS_UPDATE_STATUS"); net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN"); net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT"); net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG"); diff --git a/src/init.c b/src/init.c index c62cd6a..ae58bb4 100644 --- a/src/init.c +++ b/src/init.c @@ -195,32 +195,33 @@ init_layout(void) void init_status(void) { - char *path; int fd; struct stat st; - path = emalloc(strlen(getenv("HOME")) + strlen(DEF_STATUS) + 2, sizeof(char)); + status_path = emalloc(strlen(getenv("HOME")) + strlen(DEF_STATUS) + 2, sizeof(char)); - sprintf(path, "%s/"DEF_STATUS, getenv("HOME")); + sprintf(status_path, "%s/"DEF_STATUS, getenv("HOME")); - if(!(fd = open(path, O_RDONLY))) + if(!(fd = open(status_path, O_RDONLY))) { - free(path); + free(status_path); return; } - stat(path, &st); + stat(status_path, &st); if(st.st_mode & S_IXUSR) - spawn(path); + { + estatus = True; + system(status_path); + } else - warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.", path); + warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.", + status_path); close(fd); - free(path); - return; } diff --git a/src/structs.h b/src/structs.h index 23db925..e5190f3 100644 --- a/src/structs.h +++ b/src/structs.h @@ -120,6 +120,7 @@ enum /* WMFS HINTS */ wmfs_running, wmfs_update_hints, + wmfs_update_status, wmfs_current_tag, wmfs_current_screen, wmfs_current_layout, @@ -321,6 +322,7 @@ typedef struct Bool raiseswitch; Bool focus_fmouse; uint pad; + int status_timing; struct { /* diff --git a/src/wmfs.c b/src/wmfs.c index 0a7f78e..1b768b6 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -136,15 +136,53 @@ quit(void) return; } +void * +thread_process(void *arg) +{ + XEvent ev; + + /* X event loop */ + if(!(int*)arg) + { + while(!exiting && !XNextEvent(dpy, &ev)) + getevent(ev); + + pthread_exit(0); + } + + /* Status checking loop with timing */ + else + { + while(!exiting) + { + spawn(status_path); + sleep(conf.status_timing); + } + + pthread_exit(0); + } +} + /** WMFS main loop. */ void mainloop(void) { XEvent ev; + pthread_t evloop, evstatus; + void *ret; - while(!exiting && !XNextEvent(dpy, &ev)) - getevent(ev); + if(!estatus) + while(!exiting && !XNextEvent(dpy, &ev)) + getevent(ev); + else + { + pthread_create(&evloop, NULL, thread_process, "1"); + pthread_create(&evstatus, NULL, thread_process, NULL); + + (void)pthread_join(evloop, &ret); + (void)pthread_join(evstatus, &ret); + } return; } @@ -347,6 +385,23 @@ set_statustext(int s, char *str) return; } +/** Update status script by ewmh hint + */ +void +update_status(void) +{ + long data[5]; + + if(!check_wmfs_running()) + return; + + data[4] = True; + + send_client_event(data, "_WMFS_UPDATE_STATUS"); + + return; +} + /** Signal handle function */ void @@ -368,12 +423,12 @@ int main(int argc, char **argv) { int i; - char *ol = "csgV"; + char *ol = "csgVS"; argv_global = _strdup(argv[0]); sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME")); - while((i = getopt(argc, argv, "hvic:s:g:C:V:")) != -1) + while((i = getopt(argc, argv, "hviSc:s:g:C:V:")) != -1) { /* For options who need WMFS running */ @@ -384,12 +439,13 @@ main(int argc, char **argv) { case 'h': default: - printf("usage: %s [-ihv] [-C ] [-c ] [-g ] [-s ] [-V ] [-c ] [-g ] [-s ] [-V Load a configuration file\n" " -c Execute an uicb function to control WMFS\n" " -g Show information about wmfs status\n" " -s Set the bar(s) statustext\n" " -V Manage WMFS with vi-like command\n" + " -S Update status script\n" " -h Show this page\n" " -i Show informations\n" " -v Show WMFS version\n", argv[0]); @@ -410,6 +466,12 @@ main(int argc, char **argv) exit(EXIT_SUCCESS); break; + case 'S': + update_status(); + XCloseDisplay(dpy); + exit(EXIT_SUCCESS); + break; + case 'C': strcpy(conf.confpath, optarg); break; diff --git a/src/wmfs.h b/src/wmfs.h index 2db66b3..d3bbc35 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -334,11 +335,13 @@ void viwmfs(int argc, char **argv); int errorhandler(Display *d, XErrorEvent *event); int errorhandlerdummy(Display *d, XErrorEvent *event); void quit(void); +void *thread_process(void *arg); void mainloop(void); void scan(void); Bool check_wmfs_running(void); void exec_uicb_function(char *func, char *cmd); void set_statustext(int s, char *str); +void update_status(void); void handle_signal(int signum); void uicb_quit(uicb_t); void uicb_reload(uicb_t); @@ -351,12 +354,13 @@ GC gc, gc_stipple; int selscreen; Conf conf; Key *keys; -Bool exiting; +Bool exiting, estatus; XRectangle *sgeo; XRectangle *spgeo; Cursor cursor[CurLast]; -char *argv_global; +char *argv_global, *status_path; int xrandr_event; +uint timing; /* Fonts */ XftFont *font; diff --git a/wmfs.1 b/wmfs.1 index 7f0a3f9..5721d96 100644 --- a/wmfs.1 +++ b/wmfs.1 @@ -13,7 +13,7 @@ .SH "NAME" wmfs \- Window Manager From Scratch .SH "SYNOPSIS" -\fBwmfs\fR [\fB\-ihv\fR] [\fB\-C \fR] [\fB\-c \fR] [\fB\-g \fR] [\fB\-s \fR] [\fB\-V \fR] +\fBwmfs\fR [\fB\-ihvS\fR] [\fB\-C \fR] [\fB\-c \fR] [\fB\-g \fR] [\fB\-s \fR] [\fB\-V \fR] .sp .SH "DESCRIPTION" \fBWMFS\fR is a basic, lightweight and dynamic tiling windows manager for X\&. @@ -45,6 +45,11 @@ Set the bar(s) statustext. If the screen number is not specified, the string wil Manage WMFS with vi-like command\&. .RE .PP +\fB\-S\fR +.RS 4 +Update status script\&. +.RE +.PP \fB\-v\fR .RS 4 Print version information to standard output, then exit\&. From 119996ff47146991d2ba901cc5d8fc91bbad70a2 Mon Sep 17 00:00:00 2001 From: Philippe Pepiot Date: Sat, 2 Jan 2010 01:34:55 +0100 Subject: [PATCH 11/11] Tag 201001 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ddc626..21345e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ set(wmfs_src add_executable(wmfs ${wmfs_src}) # Set the version -set(VERSION "WMFS-200912") +set(VERSION "WMFS-201001") # FLAGS set(CFLAGS "-g -Wall -lpthread -ansi")