From 28546a6982fa1b20f4b28ff05fc294f8ecca1e3b Mon Sep 17 00:00:00 2001 From: moetunes Date: Sat, 15 Oct 2011 10:05:37 +1000 Subject: Added having applications open on a specified desktop --- src/ChangeLog | 3 +++ src/README | 7 ++++--- src/config.h | 12 +++++++++++- src/dminiwm.c | 39 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 56 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index c9c0fbd..4794cb4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,6 @@ +15/10/11 + Added having applications start on specified desktop + 13/10/11 Added ability to use grow_window/shrink_window in grid mode with 3 or 4 windows diff --git a/src/README b/src/README index a97d91c..1159c93 100644 --- a/src/README +++ b/src/README @@ -59,8 +59,8 @@ It allows the "normal" method of tiling window managers(with the new window as t ###Recent Changes -------------- -13/9/11 - Added the ability to resize the window on the top of the stack +15/10/11 + Added having applications open on specified desktop ###Status @@ -74,6 +74,7 @@ There are more options in the config file than the original catwm. * Added an option to focus the window the mouse just moved to. * Fixed a window being destroyed on another desktop creating ghost windows. * Added ability to resize the window on the top of the stack + * Added having applications open on specified desktop ###Installation @@ -95,5 +96,5 @@ Need Xlib, then: ###Todo ---- - * Have option for apps to start on set desktops + * I'll think of something diff --git a/src/config.h b/src/config.h index c3ab1b0..d0c58f1 100755 --- a/src/config.h +++ b/src/config.h @@ -1,4 +1,4 @@ - /* config.h for dminiwm.c [ 0.1.2 ] + /* config.h for dminiwm.c [ 0.1.3 ] * * Started from catwm 31/12/10 * Bad window error checking and numlock checking used from @@ -40,6 +40,16 @@ #define FOCUS "#664422" // dkorange #define UNFOCUS "#004050" // blueish +// Applications to a set desktop +static const Convenience convenience[] = { \ + /* class desktop follow */ + { "Thunar", 2, 1 }, + { "Leafpad", 2, 1 }, + { "Firefox", 3, 0 }, + { "Thunderbird", 5, 0 }, + { "Pysol", 6, 0 }, +}; + const char* dmenucmd[] = {"dmenu_run","-i","-nb","#666622","-nf","white",NULL}; const char* urxvtcmd[] = {"urxvtc",NULL}; const char* terminalcmd[] = {"Terminal",NULL}; diff --git a/src/dminiwm.c b/src/dminiwm.c index 321b3c7..4029cf1 100644 --- a/src/dminiwm.c +++ b/src/dminiwm.c @@ -1,4 +1,4 @@ -/* dminiwm.c [ 0.1.2 ] +/* dminiwm.c [ 0.1.3 ] * * I started this from catwm 31/12/10 * Bad window error checking and numlock checking used from @@ -20,11 +20,13 @@ #include //#include #include +#include #include #include #include #include #include +#include #define TABLENGTH(X) (sizeof(X)/sizeof(*X)) @@ -60,6 +62,12 @@ struct desktop{ client *current; }; +typedef struct { + const char *class; + int preferredd; + int followwin; +} Convenience; + // Functions static void add_window(Window w); static void change_desktop(const Arg arg); @@ -682,6 +690,35 @@ void maprequest(XEvent *e) { return; } + XClassHint ch = {0}; + static unsigned int len = sizeof convenience / sizeof convenience[0]; + int i = 0; + int tmp = current_desktop; + if(XGetClassHint(dis, ev->window, &ch)) + for(i=0;iwindow); + if(tmp == convenience[i].preferredd-1) { + XMapWindow(dis, ev->window); + tile(); + update_current(); + } else { + select_desktop(tmp); + } + if(convenience[i].followwin != 0) { + Arg a = {.i = convenience[i].preferredd-1}; + change_desktop(a); + } + if(ch.res_class) + XFree(ch.res_class); + if(ch.res_name) + XFree(ch.res_name); + return; + } + add_window(ev->window); XMapWindow(dis,ev->window); tile(); -- cgit v1.3.1