summaryrefslogtreecommitdiff
path: root/sway/xdg_activation_v1.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/xdg_activation_v1.c')
-rw-r--r--sway/xdg_activation_v1.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c
index 6c70c785..2b94136c 100644
--- a/sway/xdg_activation_v1.c
+++ b/sway/xdg_activation_v1.c
@@ -1,4 +1,5 @@
#include <wlr/types/wlr_xdg_activation_v1.h>
+#include "sway/desktop/launcher.h"
#include "sway/tree/view.h"
void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
@@ -11,8 +12,26 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_from_wlr_surface(event->surface);
+ if (xdg_surface == NULL) {
+ return;
+ }
struct sway_view *view = xdg_surface->data;
- if (!xdg_surface->mapped || view == NULL) {
+ if (view == NULL) {
+ return;
+ }
+
+ if (!xdg_surface->mapped) {
+ // This is a startup notification. If we are tracking it, the data
+ // field is a launcher_ctx.
+ struct launcher_ctx *ctx = event->token->data;
+ if (!ctx || ctx->activated) {
+ // This ctx has already been activated and cannot be used again
+ // for a startup notification. It will be destroyed
+ return;
+ } else {
+ ctx->activated = true;
+ view_assign_ctx(view, ctx);
+ }
return;
}