diff options
author | Ivan Chebykin <ivan@chebykin.org> | 2018-05-25 16:41:16 +0300 |
---|---|---|
committer | Ivan Chebykin <ivan@chebykin.org> | 2018-05-25 16:54:43 +0300 |
commit | e19fe56e2f6bd0bf6cc9c8d608941116ebd06c49 (patch) | |
tree | 6e5708fb37cfb8ee054d4027643b59ee6430ec0c | |
parent | Skip all nested containers (diff) | |
download | sway-e19fe56e2f6bd0bf6cc9c8d608941116ebd06c49.tar.gz sway-e19fe56e2f6bd0bf6cc9c8d608941116ebd06c49.tar.zst sway-e19fe56e2f6bd0bf6cc9c8d608941116ebd06c49.zip |
Focus inactive container instead of checking cursor position
-rw-r--r-- | sway/input/cursor.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 4b15e0e2..36247416 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -162,27 +162,27 @@ 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 | // Get container-local cursor position | ||
166 | double c_local_y = cursor->cursor->y - c->y; | ||
167 | bool is_below_title = | ||
168 | c_local_y - container_titlebar_height() > 0.001; | ||
169 | |||
170 | // Don't switch focus on title mouseover for | 165 | // Don't switch focus on title mouseover for |
171 | // stacked and tabbed layouts | 166 | // stacked and tabbed layouts |
172 | // If pointed container is in nested containers which are | 167 | // If pointed container is in nested containers which are |
173 | // inside tabbed/stacked layout we should skip them | 168 | // inside tabbed/stacked layout we should skip them |
174 | bool do_mouse_focus = true; | 169 | bool do_mouse_focus = true; |
175 | struct sway_container *p = c->parent; | 170 | struct sway_container *p = c->parent; |
171 | struct sway_container *first_tabbed_parent = c->parent; | ||
176 | while(p) { | 172 | while(p) { |
177 | if((p->layout == L_TABBED || p->layout == L_STACKED) | 173 | if(p->layout == L_TABBED || p->layout == L_STACKED) { |
178 | && !is_below_title) { | ||
179 | do_mouse_focus = false; | 174 | do_mouse_focus = false; |
180 | break; | 175 | first_tabbed_parent = p; |
181 | } | 176 | } |
182 | p = p->parent; | 177 | p = p->parent; |
183 | } | 178 | } |
184 | 179 | if(!do_mouse_focus) { | |
185 | if(do_mouse_focus) { | 180 | struct sway_container *next_focus = seat_get_focus_inactive( |
181 | cursor->seat, first_tabbed_parent); | ||
182 | if(next_focus) { | ||
183 | seat_set_focus_warp(cursor->seat, next_focus, false); | ||
184 | } | ||
185 | } else { | ||
186 | seat_set_focus_warp(cursor->seat, c, false); | 186 | seat_set_focus_warp(cursor->seat, c, false); |
187 | } | 187 | } |
188 | } | 188 | } |