From 4c01dbd7262b8090f34f39fa945c92581fa112b3 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 27 Aug 2011 13:02:44 +0200 Subject: [PATCH] =?utf8?q?Bugfix:=20Don=E2=80=99t=20always=20focus=20float?= =?utf8?q?ing=20windows=20(fixes=20focus=20stealing=20with=20assignments)?= =?utf8?q?=20(+test)=20(Thanks=20aksr)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/floating.c | 3 +-- testcases/t/73-regress-focus-assign.t | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/floating.c b/src/floating.c index 8718ee01..343b4338 100644 --- a/src/floating.c +++ b/src/floating.c @@ -17,7 +17,7 @@ extern xcb_connection_t *conn; void floating_enable(Con *con, bool automatic) { - bool set_focus = true; + bool set_focus = (con == focused); if (con_is_floating(con)) { LOG("Container is already in floating mode, not doing anything.\n"); @@ -170,7 +170,6 @@ void floating_enable(Con *con, bool automatic) { render_con(nc, false); render_con(con, false); - // TODO: don’t influence focus handling when Con was not focused before. if (set_focus) con_focus(con); diff --git a/testcases/t/73-regress-focus-assign.t b/testcases/t/73-regress-focus-assign.t index 7ad87103..bab7c9ae 100644 --- a/testcases/t/73-regress-focus-assign.t +++ b/testcases/t/73-regress-focus-assign.t @@ -62,6 +62,28 @@ $window->map; sleep 0.25; +ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace'); +ok(@{get_ws_content('targetws')} == 1, 'special window on targetws'); +ok(get_ws($tmp)->{focused}, 'current workspace still focused'); + +##################################################################### +# the same test, but with a floating window +##################################################################### + +$window = $x->root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30 ], + background_color => '#0000ff', + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), +); + +$window->_create; +set_wm_class($window->id, 'special', 'special'); +$window->name('special window'); +$window->map; +sleep 0.25; + + ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace'); ok(@{get_ws_content('targetws')} == 1, 'special window on targetws'); ok(get_ws($tmp)->{focused}, 'current workspace still focused'); -- 2.39.5