From b47c4457f22a4ea903a71c45d1b53b37cdfa695a Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 26 Jun 2011 16:36:36 +0200 Subject: [PATCH] ViWMFS(rip)/Conf: Remove viWMFS, add cfactor_enable_split option and code cosmetic --- src/cfactor.c | 8 +++ src/config.c | 1 + src/structs.h | 53 ++++++++++--------- src/viwmfs.c | 143 -------------------------------------------------- src/wmfs.c | 11 +--- src/wmfs.h | 4 -- wmfsrc | 15 ++---- 7 files changed, 41 insertions(+), 194 deletions(-) delete mode 100644 src/viwmfs.c diff --git a/src/cfactor.c b/src/cfactor.c index 80b721d..ced4602 100644 --- a/src/cfactor.c +++ b/src/cfactor.c @@ -247,6 +247,14 @@ cfactor_set(Client *c, Position p, int fac) /* Arrange client and row parents */ cfactor_arrange_row(c, gc, p, fac); + /* Enable split with cfactor_enable_split option */ + if(conf.cfactor_enable_split + && !(tags[c->screen][c->tag].flags & SplitFlag)) + { + tags[c->screen][c->tag].flags |= SplitFlag; + infobar_draw_layout(&infobar[c->screen]); + } + return; } diff --git a/src/config.c b/src/config.c index 8c55c2b..1cd31bb 100644 --- a/src/config.c +++ b/src/config.c @@ -445,6 +445,7 @@ conf_layout_section(void) conf.colors.layout_bg = getcolor((fetch_opt_first(layouts, "#000000", "bg").str)); conf.keep_layout_geo = fetch_opt_first(layouts, "false", "keep_layout_geo").boolean; conf.selected_layout_symbol = fetch_opt_first(layouts, "*", "selected_layout_symbol").str; + conf.cfactor_enable_split = fetch_opt_first(layouts, "false", "cfactor_enable_split").boolean; if((tmp = fetch_opt_first(layouts, "menu", "system").str) && !strcmp(tmp, "menu")) conf.layout_system = True; diff --git a/src/structs.h b/src/structs.h index 136936d..4ecd191 100644 --- a/src/structs.h +++ b/src/structs.h @@ -41,40 +41,40 @@ #define HISTOLEN 128 /* Clients flags definition */ -#define FreeFlag (1 << 1) -#define MaxFlag (1 << 2) -#define TileFlag (1 << 3) -#define HideFlag (1 << 4) -#define LMaxFlag (1 << 5) -#define UnmapFlag (1 << 6) -#define HintFlag (1 << 7) -#define FSSFlag (1 << 8) -#define AboveFlag (1 << 9) -#define UrgentFlag (1 << 10) -#define FLayFlag (1 << 11) -#define DockFlag (1 << 12) +#define FreeFlag 0x01 +#define MaxFlag 0x02 +#define TileFlag 0x04 +#define HideFlag 0x08 +#define LMaxFlag 0x10 +#define UnmapFlag 0x20 +#define HintFlag 0x40 +#define FSSFlag 0x80 +#define AboveFlag 0x100 +#define UrgentFlag 0x200 +#define FLayFlag 0x400 +#define DockFlag 0x800 /* Layout flags definition */ -#define IntegrationFlag (1 << 1) -#define ArrangeFlag (1 << 2) +#define IntegrationFlag 0x01 +#define ArrangeFlag 0x02 /* Tag flags definition */ -#define TagUrgentFlag (1 << 1) -#define ResizeHintFlag (1 << 2) -#define RequestUpdateFlag (1 << 3) -#define AboveFCFlag (1 << 4) -#define CleanFactFlag (1 << 5) -#define StayLastFlag (1 << 6) -#define SplitFlag (1 << 7) -#define FirstArrangeFlag (1 << 8) -#define IgnoreEnterFlag (1 << 9) +#define TagUrgentFlag 0x01 +#define ResizeHintFlag 0x02 +#define RequestUpdateFlag 0x04 +#define AboveFCFlag 0x08 +#define CleanFactFlag 0x10 +#define StayLastFlag 0x20 +#define SplitFlag 0x40 +#define FirstArrangeFlag 0x80 +#define IgnoreEnterFlag 0x100 #define TagFlag(t) (1 << (t)) /* BarWindow flags definition */ -#define MappedFlag (1 << 1) -#define StippleFlag (1 << 2) -#define BordFlag (1 << 3) +#define MappedFlag 0x01 +#define StippleFlag 0x02 +#define BordFlag 0x04 /* XEMBED messages */ #define XEMBED_MAPPED (1 << 0) @@ -523,6 +523,7 @@ typedef struct bool layout_system; /* Switch: False, Menu: True. */ bool layout_placement; /* Right (normal): False, Left: True. */ bool keep_layout_geo; + bool cfactor_enable_split; char *tag_expose_name; char *expose_layout; char *selected_layout_symbol; diff --git a/src/viwmfs.c b/src/viwmfs.c deleted file mode 100644 index 1ef90b4..0000000 --- a/src/viwmfs.c +++ /dev/null @@ -1,143 +0,0 @@ -/* -* viwmfs.c -* Copyright © 2008, 2009 Martin Duquesnoy -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following disclaimer -* in the documentation and/or other materials provided with the -* distribution. -* * Neither the name of the nor the names of its -* contributors may be used to endorse or promote products derived from -* this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "wmfs.h" - -static vicmd_to_uicb vicmd[] = -{ - {"r", "reload"}, - {"q", "quit"}, - {"t", "tag"}, - {"tn", "tag_next"}, - {"tp", "tag_prev"}, - {"l", "set_layout"}, - {"layout", "set_layout"}, - {"ln", "layout_next"}, - {"lp", "layout_prev"}, - {"s", "screen_select"}, - {"screen", "screen_select"}, - {"sn", "screen_next"}, - {"sp", "screen_prev"}, - {"cc", "client_kill"}, - {"ct", "tag_transfert"}, - {"ctn", "tag_transfert_next"}, - {"ctp", "tag_transfert_prev"}, - {"cn", "client_next"}, - {"cp", "client_prev"}, - {"csn", "client_swap_next"}, - {"csp", "client_swap_prev"}, - {"mwf", "set_mwfact"}, - {"mwfact", "set_mwfact"}, - {"nmaster", "set_nmaster"}, - {"tm", "toggle_max"}, - {"tf", "toggle_free"}, -}; - -static void -viwmfs_help(void) -{ - size_t i; - char s[20]; - - printf("ViWMFS commands list:\n"); - - for(i = 0; i < LEN(vicmd); ++i) - { - memset(s, ' ', sizeof(s)); - - s[15 - strlen(vicmd[i].cmd)] = '\0'; - - printf(" :%s%s %s\n", vicmd[i].cmd, s, vicmd[i].uicb); - } - - return; -} - -void -viwmfs(int argc, char **argv) -{ - size_t i; - char *cmd, str[256] = { 0 }; - bool e; - - if(!argc) - return; - - if(argc > 3) - { - for(i = 2; i < (size_t)argc; ++i) - { - strcat(str, argv[i]); - - if(*(str + strlen(str) - 1) != ':') - strcat(str, " "); - } - } - else - strncpy(str, argv[2], sizeof(str)); - - if(!strcmp(str, "help")) - { - viwmfs_help(); - - return; - } - - if(*str == ':') - { - for(i = 0; i < strlen(str); str[i] = str[i + 1], ++i); - - cmd = xstrdup(str); - - for(i = 0; cmd[i] && cmd[i] != ' '; ++i); - cmd[i] = '\0'; - - for(i = 0; i < LEN(vicmd); ++i) - if(!strncmp(cmd, vicmd[i].cmd, strlen(cmd))) - { - exec_uicb_function(vicmd[i].uicb, clean_value(str + strlen(cmd))); - e = True; - break; - } - - /* For uicb function with normal name specified */ - if(!e) - { - if(!strcmp(str, "h") || !strcmp(str, "help")) - viwmfs_help(); - else - exec_uicb_function(cmd, str + strlen(cmd)); - } - } - - return; -} diff --git a/src/wmfs.c b/src/wmfs.c index 418d7db..c09950d 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -456,7 +456,7 @@ int main(int argc, char **argv) { int i; - char *ol = "csVS"; + char *ol = "csS"; extern char *optarg; extern int optind; struct sigaction sa; @@ -465,7 +465,7 @@ main(int argc, char **argv) all_argv = argv; sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME")); - while((i = getopt(argc, argv, "hviSc:s:C:V:")) != -1) + while((i = getopt(argc, argv, "hviSc:s:C:")) != -1) { /* For options who need WMFS running */ @@ -480,7 +480,6 @@ main(int argc, char **argv) " -C Load a configuration file\n" " -c Execute an uicb function to control WMFS\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" @@ -522,12 +521,6 @@ main(int argc, char **argv) XCloseDisplay(dpy); exit(EXIT_SUCCESS); break; - - case 'V': - viwmfs(argc, argv); - XCloseDisplay(dpy); - exit(EXIT_SUCCESS); - break; } } diff --git a/src/wmfs.h b/src/wmfs.h index c4e94ff..0a9d88c 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -422,10 +422,6 @@ void uicb_split_move_Top(uicb_t); void uicb_split_move_Bottom(uicb_t); /* }}} */ - -/* viwmfs.c */ -void viwmfs(int argc, char **argv); - /* wmfs.c */ int errorhandler(Display *d, XErrorEvent *event); int errorhandlerdummy(Display *d, XErrorEvent *event); diff --git a/wmfsrc b/wmfsrc index aad6c93..e207f2a 100644 --- a/wmfsrc +++ b/wmfsrc @@ -73,6 +73,9 @@ # Keep layout geo for free layout keep_layout_geo = false + # Enable split mode with client_resize_ + cfactor_enable_split = true + # Symbol displayed for the selected layout in the list selected_layout_symbol = "*" @@ -308,15 +311,6 @@ prompt = "Exec: " command = "exec" [/set_launcher] - - #ViWMFS : manage wmfs with vi-based command. - [set_launcher] - name = "viwmfs" - prompt = "> " - command = "wmfs -V" - [/set_launcher] -[/launcher] - [keys] # Reload the configuration of wmfs. [key] mod = {"Alt", "Control"} key = "r" func = "reload" [/key] @@ -388,9 +382,6 @@ #Launcher. [key] mod = {"Alt"} key = "p" func = "launcher" cmd = "launcher_exec" [/key] - #ViWMFS - [key] mod = {"Alt"} key = "Escape" func = "launcher" cmd = "viwmfs" [/key] - # Set the tag x. [key] mod = {"Alt"} key = "F1" func = "tag" cmd = "1" [/key] [key] mod = {"Alt"} key = "F2" func = "tag" cmd = "2" [/key]