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 | |
parent | Fix focusing from other containers (diff) | |
download | sway-c62efbb5cea36300706e0b366a271697da70d201.tar.gz sway-c62efbb5cea36300706e0b366a271697da70d201.tar.zst sway-c62efbb5cea36300706e0b366a271697da70d201.zip |
Implement correct focusing for tabbed containers
-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, | |||
162 | seat_set_focus_warp(cursor->seat, c, false); | 162 | seat_set_focus_warp(cursor->seat, c, false); |
163 | } | 163 | } |
164 | } else { | 164 | } else { |
165 | // Don't switch focus on mouseover for stacked and tabbed layouts | 165 | // Get container-local cursor position |
166 | if(focus->parent == c->parent && | 166 | double c_local_y = cursor->cursor->y - c->y; |
167 | (c->parent->layout != L_STACKED | 167 | bool is_below_title = |
168 | || c->parent->layout != L_TABBED)) { | 168 | c_local_y - container_titlebar_height() > 0.001; |
169 | |||
170 | bool do_mouse_focus = true; | ||
171 | |||
172 | // Don't switch focus on title mouseover for stacked and tabbed | ||
173 | // layouts | ||
174 | if(c->parent && (c->parent->layout == L_STACKED | ||
175 | || c->parent->layout == L_TABBED) | ||
176 | && !is_below_title) { | ||
177 | do_mouse_focus = false; | ||
178 | } | ||
179 | |||
180 | // If pointed container is in nested container | ||
181 | // inside tabbed/stacked layout we should skip this nested container | ||
182 | if(c->parent && c->parent->parent && | ||
183 | (c->parent->parent->layout == L_STACKED | ||
184 | || c->parent->parent->layout == L_TABBED) | ||
185 | && !is_below_title) { | ||
186 | do_mouse_focus = false; | ||
187 | } | ||
188 | |||
189 | if(do_mouse_focus) { | ||
169 | seat_set_focus_warp(cursor->seat, c, false); | 190 | seat_set_focus_warp(cursor->seat, c, false); |
170 | } | 191 | } |
171 | } | 192 | } |