aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-06 11:43:55 -0400
committerLibravatar GitHub <noreply@github.com>2018-04-06 11:43:55 -0400
commitd447460c0153a76a0bc484bb9866cef658b3102f (patch)
tree4323a9130346ca4d836b0ae70c03877e13310bfc
parentAvoid arranging windows while reloading config (diff)
parentSend surface enter/leave events to view children (diff)
downloadsway-d447460c0153a76a0bc484bb9866cef658b3102f.tar.gz
sway-d447460c0153a76a0bc484bb9866cef658b3102f.tar.zst
sway-d447460c0153a76a0bc484bb9866cef658b3102f.zip
Merge pull request #1755 from emersion/view-child-hidpi
Send surface enter/leave events to view children
-rw-r--r--include/sway/tree/view.h5
-rw-r--r--sway/desktop/xdg_shell_v6.c10
-rw-r--r--sway/desktop/xwayland.c3
-rw-r--r--sway/tree/view.c33
4 files changed, 49 insertions, 2 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 6b2d279e..611c4f0b 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -28,6 +28,8 @@ struct sway_view_impl {
28 void (*configure)(struct sway_view *view, double ox, double oy, int width, 28 void (*configure)(struct sway_view *view, double ox, double oy, int width,
29 int height); 29 int height);
30 void (*set_activated)(struct sway_view *view, bool activated); 30 void (*set_activated)(struct sway_view *view, bool activated);
31 void (*for_each_surface)(struct sway_view *view,
32 wlr_surface_iterator_func_t iterator, void *user_data);
31 void (*close)(struct sway_view *view); 33 void (*close)(struct sway_view *view);
32 void (*destroy)(struct sway_view *view); 34 void (*destroy)(struct sway_view *view);
33}; 35};
@@ -159,6 +161,9 @@ void view_damage_whole(struct sway_view *view);
159 161
160void view_damage_from(struct sway_view *view); 162void view_damage_from(struct sway_view *view);
161 163
164void view_for_each_surface(struct sway_view *view,
165 wlr_surface_iterator_func_t iterator, void *user_data);
166
162// view implementation 167// view implementation
163 168
164void view_init(struct sway_view *view, enum sway_view_type type, 169void view_init(struct sway_view *view, enum sway_view_type type,
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index c66cc39a..8361aab3 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -118,6 +118,15 @@ static void set_activated(struct sway_view *view, bool activated) {
118 } 118 }
119} 119}
120 120
121static void for_each_surface(struct sway_view *view,
122 wlr_surface_iterator_func_t iterator, void *user_data) {
123 if (xdg_shell_v6_view_from_view(view) == NULL) {
124 return;
125 }
126 wlr_xdg_surface_v6_for_each_surface(view->wlr_xdg_surface_v6, iterator,
127 user_data);
128}
129
121static void _close(struct sway_view *view) { 130static void _close(struct sway_view *view) {
122 if (xdg_shell_v6_view_from_view(view) == NULL) { 131 if (xdg_shell_v6_view_from_view(view) == NULL) {
123 return; 132 return;
@@ -146,6 +155,7 @@ static const struct sway_view_impl view_impl = {
146 .get_prop = get_prop, 155 .get_prop = get_prop,
147 .configure = configure, 156 .configure = configure,
148 .set_activated = set_activated, 157 .set_activated = set_activated,
158 .for_each_surface = for_each_surface,
149 .close = _close, 159 .close = _close,
150 .destroy = destroy, 160 .destroy = destroy,
151}; 161};
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index e3da1da7..10bfcc89 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -58,6 +58,9 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
58 surface->lx = xsurface->x; 58 surface->lx = xsurface->x;
59 surface->ly = xsurface->y; 59 surface->ly = xsurface->y;
60 desktop_damage_whole_surface(xsurface->surface, surface->lx, surface->ly); 60 desktop_damage_whole_surface(xsurface->surface, surface->lx, surface->ly);
61
62 // TODO: we don't send surface enter/leave events to xwayland unmanaged
63 // surfaces, but xwayland doesn't support HiDPI anyway
61} 64}
62 65
63static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { 66static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 16d48cc9..9855c5e1 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -102,6 +102,15 @@ static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) {
102 box->height = view->height; 102 box->height = view->height;
103} 103}
104 104
105void view_for_each_surface(struct sway_view *view,
106 wlr_surface_iterator_func_t iterator, void *user_data) {
107 if (view->impl->for_each_surface) {
108 view->impl->for_each_surface(view, iterator, user_data);
109 } else {
110 wlr_surface_for_each_surface(view->surface, iterator, user_data);
111 }
112}
113
105static void view_subsurface_create(struct sway_view *view, 114static void view_subsurface_create(struct sway_view *view,
106 struct wlr_subsurface *subsurface); 115 struct wlr_subsurface *subsurface);
107 116
@@ -116,6 +125,18 @@ static void view_handle_surface_new_subsurface(struct wl_listener *listener,
116 view_subsurface_create(view, subsurface); 125 view_subsurface_create(view, subsurface);
117} 126}
118 127
128static void surface_send_enter_iterator(struct wlr_surface *surface,
129 int x, int y, void *data) {
130 struct wlr_output *wlr_output = data;
131 wlr_surface_send_enter(surface, wlr_output);
132}
133
134static void surface_send_leave_iterator(struct wlr_surface *surface,
135 int x, int y, void *data) {
136 struct wlr_output *wlr_output = data;
137 wlr_surface_send_leave(surface, wlr_output);
138}
139
119static void view_handle_container_reparent(struct wl_listener *listener, 140static void view_handle_container_reparent(struct wl_listener *listener,
120 void *data) { 141 void *data) {
121 struct sway_view *view = 142 struct sway_view *view =
@@ -137,11 +158,11 @@ static void view_handle_container_reparent(struct wl_listener *listener,
137 } 158 }
138 159
139 if (old_output != NULL) { 160 if (old_output != NULL) {
140 wlr_surface_send_leave(view->surface, 161 view_for_each_surface(view, surface_send_leave_iterator,
141 old_output->sway_output->wlr_output); 162 old_output->sway_output->wlr_output);
142 } 163 }
143 if (new_output != NULL) { 164 if (new_output != NULL) {
144 wlr_surface_send_enter(view->surface, 165 view_for_each_surface(view, surface_send_enter_iterator,
145 new_output->sway_output->wlr_output); 166 new_output->sway_output->wlr_output);
146 } 167 }
147} 168}
@@ -283,6 +304,14 @@ void view_child_init(struct sway_view_child *child,
283 wl_signal_add(&view->events.unmap, &child->view_unmap); 304 wl_signal_add(&view->events.unmap, &child->view_unmap);
284 child->view_unmap.notify = view_child_handle_view_unmap; 305 child->view_unmap.notify = view_child_handle_view_unmap;
285 306
307 struct sway_container *output = child->view->swayc->parent;
308 if (output != NULL) {
309 if (output->type != C_OUTPUT) {
310 output = container_parent(output, C_OUTPUT);
311 }
312 wlr_surface_send_enter(child->surface, output->sway_output->wlr_output);
313 }
314
286 view_init_subsurfaces(child->view, surface); 315 view_init_subsurfaces(child->view, surface);
287 316
288 // TODO: only damage the whole child 317 // TODO: only damage the whole child