diff options
author | Kenny Levinsen <kl@kl.wtf> | 2021-03-03 16:17:45 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-03-10 17:50:57 +0100 |
commit | 2e06403548fa5e940e01b810e538fd46d61c89c7 (patch) | |
tree | 72a0997b3e443a894ed91d247b26ee1bec9c3bed | |
parent | swaybar: use text subpixel antialias only where it would look good (diff) | |
download | sway-2e06403548fa5e940e01b810e538fd46d61c89c7.tar.gz sway-2e06403548fa5e940e01b810e538fd46d61c89c7.tar.zst sway-2e06403548fa5e940e01b810e538fd46d61c89c7.zip |
container: Add view_container_content_at
container_at checks if the position provided matches the currently
focused container with view_container_at as a fast path.
view_container_at checks using the main container geometry, which
includes the titlebar and border area. If a tabbed container is focused,
then positions over unfocused tabs are incorrectly reported as belonging
to the focused container, breaking focus on click.
Add view_container_content_at for use in the focused container fast path
which only tests container content area, and fall back to full workspace
scans for border and titlebar areas.
Closes: https://github.com/swaywm/sway/issues/6074
-rw-r--r-- | sway/tree/container.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 1b7b9dd0..68fbec2f 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -311,7 +311,30 @@ static struct sway_container *floating_container_at(double lx, double ly, | |||
311 | return NULL; | 311 | return NULL; |
312 | } | 312 | } |
313 | 313 | ||
314 | struct sway_container *view_container_at(struct sway_node *parent, | 314 | static struct sway_container *view_container_content_at(struct sway_node *parent, |
315 | double lx, double ly, | ||
316 | struct wlr_surface **surface, double *sx, double *sy) { | ||
317 | if (!sway_assert(node_is_view(parent), "Expected a view")) { | ||
318 | return NULL; | ||
319 | } | ||
320 | |||
321 | struct sway_container *container = parent->sway_container; | ||
322 | struct wlr_box box = { | ||
323 | .x = container->pending.content_x, | ||
324 | .y = container->pending.content_y, | ||
325 | .width = container->pending.content_width, | ||
326 | .height = container->pending.content_height, | ||
327 | }; | ||
328 | |||
329 | if (wlr_box_contains_point(&box, lx, ly)) { | ||
330 | surface_at_view(parent->sway_container, lx, ly, surface, sx, sy); | ||
331 | return container; | ||
332 | } | ||
333 | |||
334 | return NULL; | ||
335 | } | ||
336 | |||
337 | static struct sway_container *view_container_at(struct sway_node *parent, | ||
315 | double lx, double ly, | 338 | double lx, double ly, |
316 | struct wlr_surface **surface, double *sx, double *sy) { | 339 | struct wlr_surface **surface, double *sx, double *sy) { |
317 | if (!sway_assert(node_is_view(parent), "Expected a view")) { | 340 | if (!sway_assert(node_is_view(parent), "Expected a view")) { |
@@ -395,7 +418,7 @@ struct sway_container *container_at(struct sway_workspace *workspace, | |||
395 | } | 418 | } |
396 | // Tiling (focused) | 419 | // Tiling (focused) |
397 | if (focus && focus->view && !is_floating) { | 420 | if (focus && focus->view && !is_floating) { |
398 | if ((c = view_container_at(&focus->node, lx, ly, surface, sx, sy))) { | 421 | if ((c = view_container_content_at(&focus->node, lx, ly, surface, sx, sy))) { |
399 | return c; | 422 | return c; |
400 | } | 423 | } |
401 | } | 424 | } |