summaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-02-25 17:23:36 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-02-25 17:23:36 -0500
commit8ad26c8afd2aed460ea70088b0aa98f65bf21de7 (patch)
tree1b6dbcc5e7d9cdf88c56af6a1f3267bc0febf74b /sway/tree/view.c
parentUse focus for new windows xwayland/wl_shell (diff)
downloadsway-8ad26c8afd2aed460ea70088b0aa98f65bf21de7.tar.gz
sway-8ad26c8afd2aed460ea70088b0aa98f65bf21de7.tar.zst
sway-8ad26c8afd2aed460ea70088b0aa98f65bf21de7.zip
Send surface enter/leave events
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c42
1 files changed, 42 insertions, 0 deletions
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
3const char *view_get_title(struct sway_view *view) { 7const char *view_get_title(struct sway_view *view) {
@@ -30,13 +34,27 @@ const char *view_get_instance(struct sway_view *view) {
30 34
31void view_set_size(struct sway_view *view, int width, int height) { 35void 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
37void view_set_position(struct sway_view *view, double ox, double oy) { 48void 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
73void 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}