From 287d7f9527838dc3fa4720af2cf1e3069e1f6e54 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 6 Mar 2011 23:26:02 +0100 Subject: [PATCH] =?utf8?q?Bugfix:=20Don=E2=80=99t=20focus=20new=20cons=20w?= =?utf8?q?hen=20there=20is=20a=20fullscreen=20con=20(Thanks=20dothebart)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also, remove the focus_it parameter from tree_open_con, it makes more sense to call con_focus outside of the function. --- include/tree.h | 2 +- src/cmdparse.y | 3 ++- src/manage.c | 29 +++++++++++++++++++---------- src/tree.c | 6 +----- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/tree.h b/include/tree.h index cdcb4878..40d9a541 100644 --- a/include/tree.h +++ b/include/tree.h @@ -24,7 +24,7 @@ void tree_init(); * Opens an empty container in the current container * */ -Con *tree_open_con(Con *con, bool focus_it); +Con *tree_open_con(Con *con); /** * Splits (horizontally or vertically) the given container by creating a new diff --git a/src/cmdparse.y b/src/cmdparse.y index 33724264..0abcab08 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -403,7 +403,8 @@ open: TOK_OPEN { printf("opening new container\n"); - Con *con = tree_open_con(NULL, true); + Con *con = tree_open_con(NULL); + con_focus(con); asprintf(&json_output, "{\"success\":true, \"id\":%ld}", (long int)con); } ; diff --git a/src/manage.c b/src/manage.c index 192bcbf3..789bd8a9 100644 --- a/src/manage.c +++ b/src/manage.c @@ -201,7 +201,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki LOG("using current container, focused = %p, focused->name = %s\n", focused, focused->name); nc = focused; - } else nc = tree_open_con(NULL, true); + } else nc = tree_open_con(NULL); } else { /* M_ACTIVE are assignments */ if (match != NULL && match->insert_where == M_ACTIVE) { @@ -213,13 +213,13 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki /* We need to open a new con */ /* TODO: make a difference between match-once containers (directly assign * cwindow) and match-multiple (tree_open_con first) */ - nc = tree_open_con(nc->parent, true); + nc = tree_open_con(nc->parent); } /* M_BELOW inserts the new window as a child of the one which was * matched (e.g. dock areas) */ else if (match != NULL && match->insert_where == M_BELOW) { - nc = tree_open_con(nc, !cwindow->dock); + nc = tree_open_con(nc); } } @@ -234,6 +234,18 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki x_set_name(nc, name); free(name); + Con *ws = con_get_workspace(nc); + Con *fs = (ws ? con_get_fullscreen_con(ws) : NULL); + + if (fs == NULL) { + DLOG("Not in fullscreen mode, focusing\n"); + if (!cwindow->dock) + con_focus(nc); + else DLOG("dock, not focusing\n"); + } else { + DLOG("fs = %p, ws = %p, not focusing\n", fs, ws); + } + /* set floating if necessary */ bool want_floating = false; if (xcb_reply_contains_atom(reply, atoms[_NET_WM_WINDOW_TYPE_DIALOG]) || @@ -251,13 +263,10 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki LOG("This window is transiert for another window, setting floating\n"); want_floating = true; - if (config.popup_during_fullscreen == PDF_LEAVE_FULLSCREEN) { - Con *ws, *fs; - if ((ws = con_get_workspace(nc)) && - (fs = con_get_fullscreen_con(ws))) { - LOG("There is a fullscreen window, leaving fullscreen mode\n"); - con_toggle_fullscreen(fs); - } + if (config.popup_during_fullscreen == PDF_LEAVE_FULLSCREEN && + fs != NULL) { + LOG("There is a fullscreen window, leaving fullscreen mode\n"); + con_toggle_fullscreen(fs); } } diff --git a/src/tree.c b/src/tree.c index 3c209fbc..ef254a8f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -55,7 +55,7 @@ void tree_init() { * Opens an empty container in the current container * */ -Con *tree_open_con(Con *con, bool focus_it) { +Con *tree_open_con(Con *con) { if (con == NULL) { /* every focusable Con has a parent (outputs have parent root) */ con = focused->parent; @@ -80,10 +80,6 @@ Con *tree_open_con(Con *con, bool focus_it) { /* 4: re-calculate child->percent for each child */ con_fix_percent(con); - /* 5: focus the new container */ - if (focus_it) - con_focus(new); - return new; } -- 2.39.2