Skip to content

Commit

Permalink
Don't raise floating windows when focused because of focus_follows_mouse
Browse files Browse the repository at this point in the history
Fixes i3#2990
  • Loading branch information
orestisfl committed Sep 25, 2017
1 parent f4f3d64 commit 1612cb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/con.h
Expand Up @@ -37,6 +37,7 @@ void con_free(Con *con);
*
*/
void con_focus(Con *con);
void _con_focus(Con *con, bool raise_floating);

/**
* Closes the given container.
Expand Down
10 changes: 7 additions & 3 deletions src/con.c
Expand Up @@ -220,7 +220,7 @@ void con_detach(Con *con) {
* run of x_push_changes().
*
*/
void con_focus(Con *con) {
void _con_focus(Con *con, bool raise_floating) {
assert(con != NULL);
DLOG("con_focus = %p\n", con);

Expand All @@ -229,7 +229,7 @@ void con_focus(Con *con) {
TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
TAILQ_INSERT_HEAD(&(con->parent->focus_head), con, focused);
if (con->parent->parent != NULL)
con_focus(con->parent);
_con_focus(con->parent, raise_floating);

focused = con;
/* We can't blindly reset non-leaf containers since they might have
Expand All @@ -247,11 +247,15 @@ void con_focus(Con *con) {
/* Focusing a container with a floating parent should raise it to the top. Since
* con_focus is called recursively for each parent we don't need to use
* con_inside_floating(). */
if (con->type == CT_FLOATING_CON) {
if (raise_floating && con->type == CT_FLOATING_CON) {
floating_raise_con(con);
}
}

void con_focus(Con *con) {
_con_focus(con, true);
}

/*
* Closes the given container.
*
Expand Down
6 changes: 3 additions & 3 deletions src/handlers.c
Expand Up @@ -109,7 +109,7 @@ static void check_crossing_screen_boundary(uint32_t x, uint32_t y) {
/* Since we are switching outputs, this *must* be a different workspace, so
* call workspace_show() */
workspace_show(con_get_workspace(next));
con_focus(next);
_con_focus(next, false);

/* If the focus changed, we re-render to get updated decorations */
if (old_focused != focused)
Expand Down Expand Up @@ -182,7 +182,7 @@ static void handle_enter_notify(xcb_enter_notify_event_t *event) {
workspace_show(ws);

focused_id = XCB_NONE;
con_focus(con_descend_focused(con));
_con_focus(con_descend_focused(con), false);
tree_render();

return;
Expand Down Expand Up @@ -225,7 +225,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) {
if (TAILQ_FIRST(&(con->focus_head)) == current)
return;

con_focus(current);
_con_focus(current, false);
x_push_changes(croot);
return;
}
Expand Down

0 comments on commit 1612cb3

Please sign in to comment.