X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=a2116d75f60bb5765f84b271647e172f79c35ceb;hb=a912ad39658bcaef891a3816f9f8d78ef41a82c2;hp=029548f08fb3dcc2da9810cd43cbec145f1c8a66;hpb=ae6a9b20ce19ff7bb595b012b1604fd0a7f0e157;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 029548f..a2116d7 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -48,7 +48,7 @@ * DEALINGS IN THE SOFTWARE. */ -#define SWM_VERSION "0.5" +#define SWM_VERSION "0.6" #include #include @@ -176,8 +176,8 @@ char *bar_fonts[] = { /* terminal + args */ char *spawn_term[] = { "xterm", NULL }; char *spawn_screenshot[] = { "screenshot.sh", NULL, NULL }; -char *spawn_menu[] = { "dmenu_run", "-fn", NULL, - "-nb", NULL, "-nf", NULL, "-sb", NULL, "-sf", NULL, NULL }; +char *spawn_menu[] = { "dmenu_run", "-fn", NULL, "-nb", NULL, + "-nf", NULL, "-sb", NULL, "-sf", NULL, NULL }; #define SWM_MENU_FN (2) #define SWM_MENU_NB (4) @@ -804,6 +804,7 @@ void spawn(struct swm_region *r, union arg *args) { char *ret; + int si; DNPRINTF(SWM_D_MISC, "spawn: %s\n", args->argv[0]); /* @@ -824,6 +825,12 @@ spawn(struct swm_region *r, union arg *args) free(ret); } setsid(); + /* kill stdin, mplayer, ssh-add etc. need that */ + si = open("/dev/null", O_RDONLY, 0); + if (si == -1) + err(1, "open /dev/null"); + if (dup2(si, 0) == -1) + err(1, "dup2 /dev/null"); execvp(args->argv[0], args->argv); fprintf(stderr, "execvp failed\n"); perror(" failed"); @@ -1106,7 +1113,6 @@ cycle_layout(struct swm_region *r, union arg *args) if (ws->cur_layout->l_stack == NULL) ws->cur_layout = &layouts[0]; ignore_enter = 1; - stack(); } @@ -1758,6 +1764,8 @@ manage_window(Window id) unsigned char ws_idx_str[SWM_PROPLEN], *prop = NULL; struct swm_region *r; long mask; + int ws_idx; + const char *errstr; if ((win = find_window(id)) != NULL) return (win); /* already being managed */ @@ -1774,9 +1782,6 @@ manage_window(Window id) r = root_to_region(win->wa.root); /* If the window was managed before, put it in the same workspace */ if (prop) { - int ws_idx; - const char *errstr; - DNPRINTF(SWM_D_PROP, "got property _SWM_WS=%s\n", prop); ws_idx = strtonum(prop, 0, 9, &errstr); if (errstr) @@ -1791,9 +1796,6 @@ manage_window(Window id) win->s = r->s; /* this never changes */ TAILQ_INSERT_TAIL(&ws->winlist, win, entry); - /* make new win focused */ - focus_win(win); - XGetTransientForHint(display, win->id, &trans); if (trans) { win->transient = trans; @@ -1838,6 +1840,10 @@ manage_window(Window id) set_win_state(win, NormalState); + /* make new win focused */ + focus_win(win); + + return (win); } @@ -1930,16 +1936,16 @@ destroynotify(XEvent *e) ws->focus = TAILQ_PREV(win, ws_win_list, entry); if (ws->focus == NULL) ws->focus = TAILQ_FIRST(&ws->winlist); - if (ws->focus == win) + if (ws->focus == NULL || ws->focus == win) { ws->focus = NULL; - if (cur_focus == win) + unfocus_all(); + } else focus_win(ws->focus); - TAILQ_REMOVE(&ws->winlist, win, entry); set_win_state(win, WithdrawnState); free(win); + stack(); } - stack(); } void