aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/view.h1
-rw-r--r--sway/commands/exec_always.c11
-rw-r--r--sway/desktop/xwayland.c32
3 files changed, 43 insertions, 1 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index ca099431..1b033ee5 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -156,6 +156,7 @@ struct sway_xwayland_view {
struct wl_listener set_title;
struct wl_listener set_class;
struct wl_listener set_role;
+ struct wl_listener set_startup_id;
struct wl_listener set_window_type;
struct wl_listener set_hints;
struct wl_listener set_decorations;
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c
index 2dfba7ff..e6b09e64 100644
--- a/sway/commands/exec_always.c
+++ b/sway/commands/exec_always.c
@@ -32,11 +32,17 @@ static void export_xdga_token(struct launcher_ctx *ctx) {
setenv("XDG_ACTIVATION_TOKEN", token, 1);
}
+static void export_startup_id(struct launcher_ctx *ctx) {
+ const char *token = launcher_ctx_get_token_name(ctx);
+ setenv("DESKTOP_STARTUP_ID", token, 1);
+}
+
struct cmd_results *cmd_exec_process(int argc, char **argv) {
struct cmd_results *error = NULL;
char *cmd = NULL;
+ bool no_startup_id = false;
if (strcmp(argv[0], "--no-startup-id") == 0) {
- sway_log(SWAY_INFO, "exec switch '--no-startup-id' not supported, ignored.");
+ no_startup_id = true;
--argc; ++argv;
if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
return error;
@@ -74,6 +80,9 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) {
if (ctx) {
export_xdga_token(ctx);
}
+ if (ctx && !no_startup_id) {
+ export_startup_id(ctx);
+ }
execlp("sh", "sh", "-c", cmd, (void *)NULL);
sway_log_errno(SWAY_ERROR, "execlp failed");
_exit(1);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 7c5dde53..e15a3341 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -5,6 +5,7 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
+#include <wlr/types/wlr_xdg_activation_v1.h>
#include <wlr/xwayland.h>
#include <xcb/xcb_icccm.h>
#include "log.h"
@@ -16,6 +17,7 @@
#include "sway/output.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
+#include "sway/server.h"
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
@@ -466,6 +468,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&xwayland_view->set_title.link);
wl_list_remove(&xwayland_view->set_class.link);
wl_list_remove(&xwayland_view->set_role.link);
+ wl_list_remove(&xwayland_view->set_startup_id.link);
wl_list_remove(&xwayland_view->set_window_type.link);
wl_list_remove(&xwayland_view->set_hints.link);
wl_list_remove(&xwayland_view->set_decorations.link);
@@ -666,6 +669,31 @@ static void handle_set_role(struct wl_listener *listener, void *data) {
view_execute_criteria(view);
}
+static void handle_set_startup_id(struct wl_listener *listener, void *data) {
+ struct sway_xwayland_view *xwayland_view =
+ wl_container_of(listener, xwayland_view, set_startup_id);
+ struct sway_view *view = &xwayland_view->view;
+ struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
+ if (xsurface->startup_id == NULL) {
+ return;
+ }
+
+ struct wlr_xdg_activation_token_v1 *token =
+ wlr_xdg_activation_v1_find_token(
+ server.xdg_activation_v1, xsurface->startup_id);
+ if (token == NULL) {
+ // Tried to activate with an unknown or expired token
+ return;
+ }
+
+ struct launcher_ctx *ctx = token->data;
+ if (token->data == NULL) {
+ // TODO: support external launchers in X
+ return;
+ }
+ view_assign_ctx(view, ctx);
+}
+
static void handle_set_window_type(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, set_window_type);
@@ -751,6 +779,10 @@ struct sway_xwayland_view *create_xwayland_view(struct wlr_xwayland_surface *xsu
wl_signal_add(&xsurface->events.set_role, &xwayland_view->set_role);
xwayland_view->set_role.notify = handle_set_role;
+ wl_signal_add(&xsurface->events.set_startup_id,
+ &xwayland_view->set_startup_id);
+ xwayland_view->set_startup_id.notify = handle_set_startup_id;
+
wl_signal_add(&xsurface->events.set_window_type,
&xwayland_view->set_window_type);
xwayland_view->set_window_type.notify = handle_set_window_type;