aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_data_device.h3
-rw-r--r--types/data_device/wlr_drag.c20
-rw-r--r--types/scene/drag_icon.c26
3 files changed, 17 insertions, 32 deletions
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index 697987b2..0b425e88 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -93,11 +93,8 @@ struct wlr_drag;
struct wlr_drag_icon {
struct wlr_drag *drag;
struct wlr_surface *surface;
- bool mapped;
struct {
- struct wl_signal map;
- struct wl_signal unmap;
struct wl_signal destroy;
} events;
diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c
index d81972ab..0393f283 100644
--- a/types/data_device/wlr_drag.c
+++ b/types/data_device/wlr_drag.c
@@ -106,16 +106,6 @@ out:
wl_signal_emit_mutable(&drag->events.focus, drag);
}
-static void drag_icon_set_mapped(struct wlr_drag_icon *icon, bool mapped) {
- if (mapped && !icon->mapped) {
- icon->mapped = true;
- wl_signal_emit_mutable(&icon->events.map, icon);
- } else if (!mapped && icon->mapped) {
- icon->mapped = false;
- wl_signal_emit_mutable(&icon->events.unmap, icon);
- }
-}
-
static void drag_destroy(struct wlr_drag *drag) {
if (drag->cancelling) {
return;
@@ -359,16 +349,16 @@ static void drag_handle_drag_source_destroy(struct wl_listener *listener,
static void drag_icon_surface_role_commit(struct wlr_surface *surface) {
assert(surface->role == &drag_icon_surface_role);
- struct wlr_drag_icon *icon = surface->role_data;
- drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
+ if (wlr_surface_has_buffer(surface)) {
+ wlr_surface_map(surface);
+ }
}
static void drag_icon_surface_role_destroy(struct wlr_surface *surface) {
assert(surface->role == &drag_icon_surface_role);
struct wlr_drag_icon *icon = surface->role_data;
- drag_icon_set_mapped(icon, false);
wl_signal_emit_mutable(&icon->events.destroy, icon);
free(icon);
}
@@ -389,14 +379,12 @@ static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag,
icon->drag = drag;
icon->surface = surface;
- wl_signal_init(&icon->events.map);
- wl_signal_init(&icon->events.unmap);
wl_signal_init(&icon->events.destroy);
icon->surface->role_data = icon;
if (wlr_surface_has_buffer(surface)) {
- drag_icon_set_mapped(icon, true);
+ wlr_surface_map(surface);
}
return icon;
diff --git a/types/scene/drag_icon.c b/types/scene/drag_icon.c
index 220d2c80..b508487e 100644
--- a/types/scene/drag_icon.c
+++ b/types/scene/drag_icon.c
@@ -10,8 +10,8 @@ struct wlr_scene_drag_icon {
struct wl_listener tree_destroy;
struct wl_listener drag_icon_surface_commit;
- struct wl_listener drag_icon_map;
- struct wl_listener drag_icon_unmap;
+ struct wl_listener drag_icon_surface_map;
+ struct wl_listener drag_icon_surface_unmap;
struct wl_listener drag_icon_destroy;
};
@@ -24,15 +24,15 @@ static void drag_icon_handle_surface_commit(struct wl_listener *listener, void *
node->x + surface->current.dx, node->y + surface->current.dy);
}
-static void drag_icon_handle_map(struct wl_listener *listener, void *data) {
+static void drag_icon_handle_surface_map(struct wl_listener *listener, void *data) {
struct wlr_scene_drag_icon *icon =
- wl_container_of(listener, icon, drag_icon_map);
+ wl_container_of(listener, icon, drag_icon_surface_map);
wlr_scene_node_set_enabled(&icon->tree->node, true);
}
-static void drag_icon_handle_unmap(struct wl_listener *listener, void *data) {
+static void drag_icon_handle_surface_unmap(struct wl_listener *listener, void *data) {
struct wlr_scene_drag_icon *icon =
- wl_container_of(listener, icon, drag_icon_unmap);
+ wl_container_of(listener, icon, drag_icon_surface_unmap);
wlr_scene_node_set_enabled(&icon->tree->node, false);
}
@@ -41,8 +41,8 @@ static void drag_icon_handle_tree_destroy(struct wl_listener *listener, void *da
wl_container_of(listener, icon, tree_destroy);
wl_list_remove(&icon->tree_destroy.link);
wl_list_remove(&icon->drag_icon_surface_commit.link);
- wl_list_remove(&icon->drag_icon_map.link);
- wl_list_remove(&icon->drag_icon_unmap.link);
+ wl_list_remove(&icon->drag_icon_surface_map.link);
+ wl_list_remove(&icon->drag_icon_surface_unmap.link);
wl_list_remove(&icon->drag_icon_destroy.link);
free(icon);
}
@@ -76,16 +76,16 @@ struct wlr_scene_tree *wlr_scene_drag_icon_create(
return NULL;
}
- wlr_scene_node_set_enabled(&icon->tree->node, drag_icon->mapped);
+ wlr_scene_node_set_enabled(&icon->tree->node, drag_icon->surface->mapped);
icon->tree_destroy.notify = drag_icon_handle_tree_destroy;
wl_signal_add(&icon->tree->node.events.destroy, &icon->tree_destroy);
icon->drag_icon_surface_commit.notify = drag_icon_handle_surface_commit;
wl_signal_add(&drag_icon->surface->events.commit, &icon->drag_icon_surface_commit);
- icon->drag_icon_map.notify = drag_icon_handle_map;
- wl_signal_add(&drag_icon->events.map, &icon->drag_icon_map);
- icon->drag_icon_unmap.notify = drag_icon_handle_unmap;
- wl_signal_add(&drag_icon->events.unmap, &icon->drag_icon_unmap);
+ icon->drag_icon_surface_map.notify = drag_icon_handle_surface_map;
+ wl_signal_add(&drag_icon->surface->events.map, &icon->drag_icon_surface_map);
+ icon->drag_icon_surface_unmap.notify = drag_icon_handle_surface_unmap;
+ wl_signal_add(&drag_icon->surface->events.unmap, &icon->drag_icon_surface_unmap);
icon->drag_icon_destroy.notify = drag_icon_handle_destroy;
wl_signal_add(&drag_icon->events.destroy, &icon->drag_icon_destroy);