dwm-6.1-runorraise.diff (2483B)
1 --- dwm.c.orig 2013-11-29 13:58:49.673588564 +0100 2 +++ dwm.c 2013-11-23 22:56:49.725007370 +0100 3 @@ -193,6 +193,7 @@ 4 static void resizemouse(const Arg *arg); 5 static void restack(Monitor *m); 6 static void run(void); 7 +static void runorraise(const Arg *arg); 8 static void scan(void); 9 static Bool sendevent(Client *c, Atom proto); 10 static void sendmon(Client *c, Monitor *m); 11 @@ -1349,6 +1350,30 @@ 12 } 13 14 void 15 +runorraise(const Arg *arg) { 16 + char *app = ((char **)arg->v)[4]; 17 + Arg a = { .ui = ~0 }; 18 + Monitor *mon; 19 + Client *c; 20 + XClassHint hint = { NULL, NULL }; 21 + /* Tries to find the client */ 22 + for (mon = mons; mon; mon = mon->next) { 23 + for (c = mon->clients; c; c = c->next) { 24 + XGetClassHint(dpy, c->win, &hint); 25 + if (hint.res_class && strcmp(app, hint.res_class) == 0) { 26 + a.ui = c->tags; 27 + view(&a); 28 + focus(c); 29 + XRaiseWindow(dpy, c->win); 30 + return; 31 + } 32 + } 33 + } 34 + /* Client not found: spawn it */ 35 + spawn(arg); 36 +} 37 + 38 +void 39 scan(void) { 40 unsigned int i, num; 41 }