From 8a3daf319427bdcbd40924384ef8248c6864fe75 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 2 Mar 2014 12:53:06 +0100 Subject: [PATCH] Make things behave nice again in i3. --- config/config.c | 2 ++ include/simpleswitcher.h | 2 ++ source/simpleswitcher.c | 33 ++++++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/config/config.c b/config/config.c index 854cebff..1da77b5e 100644 --- a/config/config.c +++ b/config/config.c @@ -53,8 +53,10 @@ Settings config = { .zeltak_mode = 0, // Terminal to use. (for ssh and open in terminal) .terminal_emulator = "x-terminal-emulator", +#ifdef I3 // Auto-detected. no longer used. .i3_mode = 0, +#endif // Key binding .window_key = "F12", .run_key = "mod1+F2", diff --git a/include/simpleswitcher.h b/include/simpleswitcher.h index 1750657e..1947804b 100644 --- a/include/simpleswitcher.h +++ b/include/simpleswitcher.h @@ -90,7 +90,9 @@ typedef struct _Settings { // Behavior unsigned int zeltak_mode; char * terminal_emulator; +#ifdef I3 unsigned int i3_mode; +#endif // Key bindings char * window_key; char * run_key; diff --git a/source/simpleswitcher.c b/source/simpleswitcher.c index aa56dea8..5488d4b8 100644 --- a/source/simpleswitcher.c +++ b/source/simpleswitcher.c @@ -1201,7 +1201,15 @@ SwitcherMode run_switcher_window ( char **input ) // Create pattern for printing the line. if (!window_get_cardinal_prop(root, netatoms[_NET_NUMBER_OF_DESKTOPS], &desktops, 1)) desktops = 1; - sprintf(pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2, MAX(5, classfield)); +#ifdef I3 + if(config.i3_mode) { + sprintf(pattern, "%%-%ds %%s", MAX(5, classfield)); + }else { +#endif + sprintf(pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2, MAX(5, classfield)); +#ifdef I3 + } +#endif char **list = allocate_clear( sizeof( char* ) * ( ids->len+1 ) ); int lines = 0; @@ -1216,16 +1224,23 @@ SwitcherMode run_switcher_window ( char **input ) char desktop[5]; desktop[0] = 0; char *line = allocate( strlen( c->title ) + strlen( c->class ) + classfield + 50 ); +#ifdef I3 + if(!config.i3_mode) { +#endif + // find client's desktop. this is zero-based, so we adjust by since most + // normal people don't think like this :-) + if (!window_get_cardinal_prop(c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1)) + wmdesktop = 0xFFFFFFFF; - // find client's desktop. this is zero-based, so we adjust by since most - // normal people don't think like this :-) - if (!window_get_cardinal_prop(c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1)) - wmdesktop = 0xFFFFFFFF; + if (wmdesktop < 0xFFFFFFFF) + sprintf(desktop, "%d", (int)wmdesktop+1); - if (wmdesktop < 0xFFFFFFFF) - sprintf(desktop, "%d", (int)wmdesktop+1); - - sprintf(line, pattern, desktop, c->class, c->title); + sprintf(line, pattern, desktop, c->class, c->title); +#ifdef I3 + }else{ + sprintf(line, pattern, c->class, c->title); + } +#endif list[lines++] = line; }