Fix focus order in floating_disable for unfocused windows
Partially fixes issue #2938
This commit is contained in:
parent
60875c7bcb
commit
10a3c1e827
|
@ -17,3 +17,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void tree_move(Con *con, int direction);
|
void tree_move(Con *con, int direction);
|
||||||
|
|
||||||
|
typedef enum { BEFORE,
|
||||||
|
AFTER } position_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function detaches 'con' from its parent and inserts it either before or
|
||||||
|
* after 'target'.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void insert_con_into(Con *con, Con *target, position_t position);
|
||||||
|
|
|
@ -327,43 +327,22 @@ void floating_disable(Con *con, bool automatic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool set_focus = (con == focused);
|
|
||||||
|
|
||||||
Con *ws = con_get_workspace(con);
|
Con *ws = con_get_workspace(con);
|
||||||
Con *parent = con->parent;
|
Con *tiling_focused = con_descend_tiling_focused(ws);
|
||||||
|
|
||||||
/* 1: detach from parent container */
|
if (tiling_focused->type == CT_WORKSPACE) {
|
||||||
con_detach(con);
|
Con *parent = con->parent;
|
||||||
|
con_detach(con);
|
||||||
/* 2: kill parent container */
|
con->parent = NULL;
|
||||||
con_detach(con->parent);
|
tree_close_internal(parent, DONT_KILL_WINDOW, true, false);
|
||||||
/* clear the pointer before calling tree_close_internal in which the memory is freed */
|
con_attach(con, tiling_focused, false);
|
||||||
con->parent = NULL;
|
con->percent = 0.0;
|
||||||
tree_close_internal(parent, DONT_KILL_WINDOW, true, false);
|
con_fix_percent(con->parent);
|
||||||
|
} else {
|
||||||
/* 3: re-attach to the parent of the currently focused con on the workspace
|
insert_con_into(con, tiling_focused, AFTER);
|
||||||
* this floating con was on */
|
}
|
||||||
Con *focused = con_descend_tiling_focused(ws);
|
|
||||||
|
|
||||||
/* if there is no other container on this workspace, focused will be the
|
|
||||||
* workspace itself */
|
|
||||||
if (focused->type == CT_WORKSPACE)
|
|
||||||
con->parent = focused;
|
|
||||||
else
|
|
||||||
con->parent = focused->parent;
|
|
||||||
|
|
||||||
/* con_fix_percent will adjust the percent value */
|
|
||||||
con->percent = 0.0;
|
|
||||||
|
|
||||||
con->floating = FLOATING_USER_OFF;
|
con->floating = FLOATING_USER_OFF;
|
||||||
|
|
||||||
con_attach(con, con->parent, false);
|
|
||||||
|
|
||||||
con_fix_percent(con->parent);
|
|
||||||
|
|
||||||
if (set_focus)
|
|
||||||
con_activate(con);
|
|
||||||
|
|
||||||
floating_set_hint_atom(con, false);
|
floating_set_hint_atom(con, false);
|
||||||
ipc_send_window_event("floating", con);
|
ipc_send_window_event("floating", con);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
*/
|
*/
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
|
||||||
typedef enum { BEFORE,
|
|
||||||
AFTER } position_t;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the lowest container in the tree that has both a and b as descendants.
|
* Returns the lowest container in the tree that has both a and b as descendants.
|
||||||
*
|
*
|
||||||
|
@ -65,7 +62,7 @@ static bool is_focused_descendant(Con *con, Con *ancestor) {
|
||||||
* after 'target'.
|
* after 'target'.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void insert_con_into(Con *con, Con *target, position_t position) {
|
void insert_con_into(Con *con, Con *target, position_t position) {
|
||||||
Con *parent = target->parent;
|
Con *parent = target->parent;
|
||||||
/* We need to preserve the old con->parent. While it might still be used to
|
/* We need to preserve the old con->parent. While it might still be used to
|
||||||
* insert the entry before/after it, we call the on_remove_child callback
|
* insert the entry before/after it, we call the on_remove_child callback
|
||||||
|
|
Loading…
Reference in New Issue