diff options
author | Ivan Chebykin <ivan@chebykin.org> | 2018-05-25 14:12:09 +0300 |
---|---|---|
committer | Ivan Chebykin <ivan@chebykin.org> | 2018-05-25 16:54:43 +0300 |
commit | c62efbb5cea36300706e0b366a271697da70d201 (patch) | |
tree | 6490b70daa232f54d049f6077b93c7c46467c783 /sway/input | |
parent | c1be4b0153fc18b130ce795e71c8600c2dd31fc0 (diff) |
Implement correct focusing for tabbed containers
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/cursor.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 72dc8700..564c7763 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -162,10 +162,31 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, seat_set_focus_warp(cursor->seat, c, false); } } else { - // Don't switch focus on mouseover for stacked and tabbed layouts - if(focus->parent == c->parent && - (c->parent->layout != L_STACKED - || c->parent->layout != L_TABBED)) { + // Get container-local cursor position + double c_local_y = cursor->cursor->y - c->y; + bool is_below_title = + c_local_y - container_titlebar_height() > 0.001; + + bool do_mouse_focus = true; + + // Don't switch focus on title mouseover for stacked and tabbed + // layouts + if(c->parent && (c->parent->layout == L_STACKED + || c->parent->layout == L_TABBED) + && !is_below_title) { + do_mouse_focus = false; + } + + // If pointed container is in nested container + // inside tabbed/stacked layout we should skip this nested container + if(c->parent && c->parent->parent && + (c->parent->parent->layout == L_STACKED + || c->parent->parent->layout == L_TABBED) + && !is_below_title) { + do_mouse_focus = false; + } + + if(do_mouse_focus) { seat_set_focus_warp(cursor->seat, c, false); } } |