diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-02-25 17:23:36 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-02-25 17:23:36 -0500 |
commit | 8ad26c8afd2aed460ea70088b0aa98f65bf21de7 (patch) | |
tree | 1b6dbcc5e7d9cdf88c56af6a1f3267bc0febf74b /sway | |
parent | Use focus for new windows xwayland/wl_shell (diff) | |
download | sway-8ad26c8afd2aed460ea70088b0aa98f65bf21de7.tar.gz sway-8ad26c8afd2aed460ea70088b0aa98f65bf21de7.tar.zst sway-8ad26c8afd2aed460ea70088b0aa98f65bf21de7.zip |
Send surface enter/leave events
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 1 | ||||
-rw-r--r-- | sway/tree/view.c | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index b44d9e54..7371b829 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -72,6 +72,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
72 | wl_container_of(listener, sway_surface, commit); | 72 | wl_container_of(listener, sway_surface, commit); |
73 | struct sway_view *view = sway_surface->view; | 73 | struct sway_view *view = sway_surface->view; |
74 | // NOTE: We intentionally discard the view's desired width here | 74 | // NOTE: We intentionally discard the view's desired width here |
75 | // TODO: Store this for restoration when moving to floating plane | ||
75 | // TODO: Let floating views do whatever | 76 | // TODO: Let floating views do whatever |
76 | view->width = sway_surface->pending_width; | 77 | view->width = sway_surface->pending_width; |
77 | view->height = sway_surface->pending_height; | 78 | view->height = sway_surface->pending_height; |
diff --git a/sway/tree/view.c b/sway/tree/view.c index b46c3b17..9499adca 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -1,3 +1,7 @@ | |||
1 | #include <wayland-server.h> | ||
2 | #include <wlr/types/wlr_output_layout.h> | ||
3 | #include "sway/container.h" | ||
4 | #include "sway/layout.h" | ||
1 | #include "sway/view.h" | 5 | #include "sway/view.h" |
2 | 6 | ||
3 | const char *view_get_title(struct sway_view *view) { | 7 | const char *view_get_title(struct sway_view *view) { |
@@ -30,13 +34,27 @@ const char *view_get_instance(struct sway_view *view) { | |||
30 | 34 | ||
31 | void view_set_size(struct sway_view *view, int width, int height) { | 35 | void view_set_size(struct sway_view *view, int width, int height) { |
32 | if (view->iface.set_size) { | 36 | if (view->iface.set_size) { |
37 | struct wlr_box box = { | ||
38 | .x = view->swayc->x, | ||
39 | .y = view->swayc->y, | ||
40 | .width = view->width, | ||
41 | .height = view->height, | ||
42 | }; | ||
33 | view->iface.set_size(view, width, height); | 43 | view->iface.set_size(view, width, height); |
44 | view_update_outputs(view, &box); | ||
34 | } | 45 | } |
35 | } | 46 | } |
36 | 47 | ||
37 | void view_set_position(struct sway_view *view, double ox, double oy) { | 48 | void view_set_position(struct sway_view *view, double ox, double oy) { |
38 | if (view->iface.set_position) { | 49 | if (view->iface.set_position) { |
50 | struct wlr_box box = { | ||
51 | .x = view->swayc->x, | ||
52 | .y = view->swayc->y, | ||
53 | .width = view->width, | ||
54 | .height = view->height, | ||
55 | }; | ||
39 | view->iface.set_position(view, ox, oy); | 56 | view->iface.set_position(view, ox, oy); |
57 | view_update_outputs(view, &box); | ||
40 | } | 58 | } |
41 | } | 59 | } |
42 | 60 | ||
@@ -51,3 +69,27 @@ void view_close(struct sway_view *view) { | |||
51 | view->iface.close(view); | 69 | view->iface.close(view); |
52 | } | 70 | } |
53 | } | 71 | } |
72 | |||
73 | void view_update_outputs(struct sway_view *view, const struct wlr_box *before) { | ||
74 | struct wlr_output_layout *output_layout = | ||
75 | root_container.sway_root->output_layout; | ||
76 | struct wlr_box box = { | ||
77 | .x = view->swayc->x, | ||
78 | .y = view->swayc->y, | ||
79 | .width = view->width, | ||
80 | .height = view->height, | ||
81 | }; | ||
82 | struct wlr_output_layout_output *layout_output; | ||
83 | wl_list_for_each(layout_output, &output_layout->outputs, link) { | ||
84 | bool intersected = before != NULL && wlr_output_layout_intersects( | ||
85 | output_layout, layout_output->output, before); | ||
86 | bool intersects = wlr_output_layout_intersects(output_layout, | ||
87 | layout_output->output, &box); | ||
88 | if (intersected && !intersects) { | ||
89 | wlr_surface_send_leave(view->surface, layout_output->output); | ||
90 | } | ||
91 | if (!intersected && intersects) { | ||
92 | wlr_surface_send_enter(view->surface, layout_output->output); | ||
93 | } | ||
94 | } | ||
95 | } | ||