aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-06-07 11:18:58 +0100
committerGitHub <noreply@github.com>2018-06-07 11:18:58 +0100
commit6f895081e1d05e651543187e11766259e2b4f798 (patch)
tree9ef3692165726c41d7ad3d39dc8880eda21ea0f8
parent211463ba8709e1ac94944deb11b5669f2d3b32e4 (diff)
parent5d3e95f833ae562bf6926ddfb9f1bdb0492c1674 (diff)
Merge pull request #1043 from acrisci/drag-icon-unmap
drag-icon map and unmap fixes
-rw-r--r--include/rootston/seat.h1
-rw-r--r--include/wlr/types/wlr_data_device.h3
-rw-r--r--rootston/seat.c15
-rw-r--r--types/data_device/wlr_drag.c24
4 files changed, 36 insertions, 7 deletions
diff --git a/include/rootston/seat.h b/include/rootston/seat.h
index 7b09f339..0e3043dd 100644
--- a/include/rootston/seat.h
+++ b/include/rootston/seat.h
@@ -59,6 +59,7 @@ struct roots_drag_icon {
struct wl_listener surface_commit;
struct wl_listener map;
+ struct wl_listener unmap;
struct wl_listener destroy;
};
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index 5581373d..4de4d610 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -88,7 +88,8 @@ struct wlr_drag_icon {
int32_t sx, sy;
struct {
- struct wl_signal map; // emitted when mapped or unmapped
+ struct wl_signal map;
+ struct wl_signal unmap;
struct wl_signal destroy;
} events;
diff --git a/rootston/seat.c b/rootston/seat.c
index b137ff11..91561567 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -260,7 +260,7 @@ static void roots_drag_icon_handle_surface_commit(struct wl_listener *listener,
void *data) {
struct roots_drag_icon *icon =
wl_container_of(listener, icon, surface_commit);
- roots_drag_icon_damage_whole(icon);
+ roots_drag_icon_update_position(icon);
}
static void roots_drag_icon_handle_map(struct wl_listener *listener,
@@ -270,6 +270,13 @@ static void roots_drag_icon_handle_map(struct wl_listener *listener,
roots_drag_icon_damage_whole(icon);
}
+static void roots_drag_icon_handle_unmap(struct wl_listener *listener,
+ void *data) {
+ struct roots_drag_icon *icon =
+ wl_container_of(listener, icon, unmap);
+ roots_drag_icon_damage_whole(icon);
+}
+
static void roots_drag_icon_handle_destroy(struct wl_listener *listener,
void *data) {
struct roots_drag_icon *icon =
@@ -278,7 +285,7 @@ static void roots_drag_icon_handle_destroy(struct wl_listener *listener,
wl_list_remove(&icon->link);
wl_list_remove(&icon->surface_commit.link);
- wl_list_remove(&icon->map.link);
+ wl_list_remove(&icon->unmap.link);
wl_list_remove(&icon->destroy.link);
free(icon);
}
@@ -297,12 +304,16 @@ static void roots_seat_handle_new_drag_icon(struct wl_listener *listener,
icon->surface_commit.notify = roots_drag_icon_handle_surface_commit;
wl_signal_add(&wlr_drag_icon->surface->events.commit, &icon->surface_commit);
+ icon->unmap.notify = roots_drag_icon_handle_unmap;
+ wl_signal_add(&wlr_drag_icon->events.unmap, &icon->unmap);
icon->map.notify = roots_drag_icon_handle_map;
wl_signal_add(&wlr_drag_icon->events.map, &icon->map);
icon->destroy.notify = roots_drag_icon_handle_destroy;
wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy);
wl_list_insert(&seat->drag_icons, &icon->link);
+
+ roots_drag_icon_update_position(icon);
}
void roots_drag_icon_update_position(struct roots_drag_icon *icon) {
diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c
index 1429d4dd..4f0b2521 100644
--- a/types/data_device/wlr_drag.c
+++ b/types/data_device/wlr_drag.c
@@ -98,6 +98,16 @@ static void drag_set_focus(struct wlr_drag *drag,
wlr_signal_emit_safe(&drag->events.focus, drag);
}
+static void drag_icon_set_mapped(struct wlr_drag_icon *icon, bool mapped) {
+ if (mapped && !icon->mapped) {
+ icon->mapped = true;
+ wlr_signal_emit_safe(&icon->events.map, icon);
+ } else if (!mapped && icon->mapped) {
+ icon->mapped = false;
+ wlr_signal_emit_safe(&icon->events.unmap, icon);
+ }
+}
+
static void drag_end(struct wlr_drag *drag) {
if (!drag->cancelling) {
drag->cancelling = true;
@@ -115,9 +125,8 @@ static void drag_end(struct wlr_drag *drag) {
drag_set_focus(drag, NULL, 0, 0);
if (drag->icon) {
- drag->icon->mapped = false;
wl_list_remove(&drag->icon_destroy.link);
- wlr_signal_emit_safe(&drag->icon->events.map, drag->icon);
+ drag_icon_set_mapped(drag->icon, false);
}
wlr_signal_emit_safe(&drag->events.destroy, drag);
@@ -310,9 +319,10 @@ static void drag_handle_drag_source_destroy(struct wl_listener *listener,
static void drag_icon_destroy(struct wlr_drag_icon *icon) {
- if (!icon) {
+ if (icon == NULL) {
return;
}
+ drag_icon_set_mapped(icon, false);
wlr_signal_emit_safe(&icon->events.destroy, icon);
wlr_surface_set_role_committed(icon->surface, NULL, NULL);
wl_list_remove(&icon->surface_destroy.link);
@@ -333,6 +343,8 @@ static void drag_icon_handle_surface_commit(struct wlr_surface *surface,
struct wlr_drag_icon *icon = role_data;
icon->sx += icon->surface->current->sx;
icon->sy += icon->surface->current->sy;
+
+ drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
}
static void drag_icon_handle_seat_client_destroy(struct wl_listener *listener,
@@ -355,9 +367,9 @@ static struct wlr_drag_icon *drag_icon_create(
icon->client = client;
icon->is_pointer = is_pointer;
icon->touch_id = touch_id;
- icon->mapped = true;
wl_signal_init(&icon->events.map);
+ wl_signal_init(&icon->events.unmap);
wl_signal_init(&icon->events.destroy);
wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
@@ -372,6 +384,10 @@ static struct wlr_drag_icon *drag_icon_create(
wl_list_insert(&client->seat->drag_icons, &icon->link);
wlr_signal_emit_safe(&client->seat->events.new_drag_icon, icon);
+ if (wlr_surface_has_buffer(icon_surface)) {
+ drag_icon_set_mapped(icon, true);
+ }
+
return icon;
}