Send surface enter/leave events to view children

This commit is contained in:
emersion 2018-04-06 10:26:32 -04:00
parent d77a0119f4
commit 290c916290
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
4 changed files with 49 additions and 2 deletions

View file

@ -102,6 +102,15 @@ static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) {
box->height = view->height;
}
void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (view->impl->for_each_surface) {
view->impl->for_each_surface(view, iterator, user_data);
} else {
wlr_surface_for_each_surface(view->surface, iterator, user_data);
}
}
static void view_subsurface_create(struct sway_view *view,
struct wlr_subsurface *subsurface);
@ -116,6 +125,18 @@ static void view_handle_surface_new_subsurface(struct wl_listener *listener,
view_subsurface_create(view, subsurface);
}
static void surface_send_enter_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
struct wlr_output *wlr_output = data;
wlr_surface_send_enter(surface, wlr_output);
}
static void surface_send_leave_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
struct wlr_output *wlr_output = data;
wlr_surface_send_leave(surface, wlr_output);
}
static void view_handle_container_reparent(struct wl_listener *listener,
void *data) {
struct sway_view *view =
@ -137,11 +158,11 @@ static void view_handle_container_reparent(struct wl_listener *listener,
}
if (old_output != NULL) {
wlr_surface_send_leave(view->surface,
view_for_each_surface(view, surface_send_leave_iterator,
old_output->sway_output->wlr_output);
}
if (new_output != NULL) {
wlr_surface_send_enter(view->surface,
view_for_each_surface(view, surface_send_enter_iterator,
new_output->sway_output->wlr_output);
}
}
@ -283,6 +304,14 @@ void view_child_init(struct sway_view_child *child,
wl_signal_add(&view->events.unmap, &child->view_unmap);
child->view_unmap.notify = view_child_handle_view_unmap;
struct sway_container *output = child->view->swayc->parent;
if (output != NULL) {
if (output->type != C_OUTPUT) {
output = container_parent(output, C_OUTPUT);
}
wlr_surface_send_enter(child->surface, output->sway_output->wlr_output);
}
view_init_subsurfaces(child->view, surface);
// TODO: only damage the whole child