diff options
-rw-r--r-- | include/sway/tree/view.h | 1 | ||||
-rw-r--r-- | sway/commands/exec_always.c | 11 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 32 |
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 { | |||
156 | struct wl_listener set_title; | 156 | struct wl_listener set_title; |
157 | struct wl_listener set_class; | 157 | struct wl_listener set_class; |
158 | struct wl_listener set_role; | 158 | struct wl_listener set_role; |
159 | struct wl_listener set_startup_id; | ||
159 | struct wl_listener set_window_type; | 160 | struct wl_listener set_window_type; |
160 | struct wl_listener set_hints; | 161 | struct wl_listener set_hints; |
161 | struct wl_listener set_decorations; | 162 | 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) { | |||
32 | setenv("XDG_ACTIVATION_TOKEN", token, 1); | 32 | setenv("XDG_ACTIVATION_TOKEN", token, 1); |
33 | } | 33 | } |
34 | 34 | ||
35 | static void export_startup_id(struct launcher_ctx *ctx) { | ||
36 | const char *token = launcher_ctx_get_token_name(ctx); | ||
37 | setenv("DESKTOP_STARTUP_ID", token, 1); | ||
38 | } | ||
39 | |||
35 | struct cmd_results *cmd_exec_process(int argc, char **argv) { | 40 | struct cmd_results *cmd_exec_process(int argc, char **argv) { |
36 | struct cmd_results *error = NULL; | 41 | struct cmd_results *error = NULL; |
37 | char *cmd = NULL; | 42 | char *cmd = NULL; |
43 | bool no_startup_id = false; | ||
38 | if (strcmp(argv[0], "--no-startup-id") == 0) { | 44 | if (strcmp(argv[0], "--no-startup-id") == 0) { |
39 | sway_log(SWAY_INFO, "exec switch '--no-startup-id' not supported, ignored."); | 45 | no_startup_id = true; |
40 | --argc; ++argv; | 46 | --argc; ++argv; |
41 | if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { | 47 | if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { |
42 | return error; | 48 | return error; |
@@ -74,6 +80,9 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { | |||
74 | if (ctx) { | 80 | if (ctx) { |
75 | export_xdga_token(ctx); | 81 | export_xdga_token(ctx); |
76 | } | 82 | } |
83 | if (ctx && !no_startup_id) { | ||
84 | export_startup_id(ctx); | ||
85 | } | ||
77 | execlp("sh", "sh", "-c", cmd, (void *)NULL); | 86 | execlp("sh", "sh", "-c", cmd, (void *)NULL); |
78 | sway_log_errno(SWAY_ERROR, "execlp failed"); | 87 | sway_log_errno(SWAY_ERROR, "execlp failed"); |
79 | _exit(1); | 88 | _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 @@ | |||
5 | #include <wayland-server-core.h> | 5 | #include <wayland-server-core.h> |
6 | #include <wlr/types/wlr_output_layout.h> | 6 | #include <wlr/types/wlr_output_layout.h> |
7 | #include <wlr/types/wlr_output.h> | 7 | #include <wlr/types/wlr_output.h> |
8 | #include <wlr/types/wlr_xdg_activation_v1.h> | ||
8 | #include <wlr/xwayland.h> | 9 | #include <wlr/xwayland.h> |
9 | #include <xcb/xcb_icccm.h> | 10 | #include <xcb/xcb_icccm.h> |
10 | #include "log.h" | 11 | #include "log.h" |
@@ -16,6 +17,7 @@ | |||
16 | #include "sway/output.h" | 17 | #include "sway/output.h" |
17 | #include "sway/tree/arrange.h" | 18 | #include "sway/tree/arrange.h" |
18 | #include "sway/tree/container.h" | 19 | #include "sway/tree/container.h" |
20 | #include "sway/server.h" | ||
19 | #include "sway/tree/view.h" | 21 | #include "sway/tree/view.h" |
20 | #include "sway/tree/workspace.h" | 22 | #include "sway/tree/workspace.h" |
21 | 23 | ||
@@ -466,6 +468,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
466 | wl_list_remove(&xwayland_view->set_title.link); | 468 | wl_list_remove(&xwayland_view->set_title.link); |
467 | wl_list_remove(&xwayland_view->set_class.link); | 469 | wl_list_remove(&xwayland_view->set_class.link); |
468 | wl_list_remove(&xwayland_view->set_role.link); | 470 | wl_list_remove(&xwayland_view->set_role.link); |
471 | wl_list_remove(&xwayland_view->set_startup_id.link); | ||
469 | wl_list_remove(&xwayland_view->set_window_type.link); | 472 | wl_list_remove(&xwayland_view->set_window_type.link); |
470 | wl_list_remove(&xwayland_view->set_hints.link); | 473 | wl_list_remove(&xwayland_view->set_hints.link); |
471 | wl_list_remove(&xwayland_view->set_decorations.link); | 474 | wl_list_remove(&xwayland_view->set_decorations.link); |
@@ -666,6 +669,31 @@ static void handle_set_role(struct wl_listener *listener, void *data) { | |||
666 | view_execute_criteria(view); | 669 | view_execute_criteria(view); |
667 | } | 670 | } |
668 | 671 | ||
672 | static void handle_set_startup_id(struct wl_listener *listener, void *data) { | ||
673 | struct sway_xwayland_view *xwayland_view = | ||
674 | wl_container_of(listener, xwayland_view, set_startup_id); | ||
675 | struct sway_view *view = &xwayland_view->view; | ||
676 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | ||
677 | if (xsurface->startup_id == NULL) { | ||
678 | return; | ||
679 | } | ||
680 | |||
681 | struct wlr_xdg_activation_token_v1 *token = | ||
682 | wlr_xdg_activation_v1_find_token( | ||
683 | server.xdg_activation_v1, xsurface->startup_id); | ||
684 | if (token == NULL) { | ||
685 | // Tried to activate with an unknown or expired token | ||
686 | return; | ||
687 | } | ||
688 | |||
689 | struct launcher_ctx *ctx = token->data; | ||
690 | if (token->data == NULL) { | ||
691 | // TODO: support external launchers in X | ||
692 | return; | ||
693 | } | ||
694 | view_assign_ctx(view, ctx); | ||
695 | } | ||
696 | |||
669 | static void handle_set_window_type(struct wl_listener *listener, void *data) { | 697 | static void handle_set_window_type(struct wl_listener *listener, void *data) { |
670 | struct sway_xwayland_view *xwayland_view = | 698 | struct sway_xwayland_view *xwayland_view = |
671 | wl_container_of(listener, xwayland_view, set_window_type); | 699 | 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 | |||
751 | wl_signal_add(&xsurface->events.set_role, &xwayland_view->set_role); | 779 | wl_signal_add(&xsurface->events.set_role, &xwayland_view->set_role); |
752 | xwayland_view->set_role.notify = handle_set_role; | 780 | xwayland_view->set_role.notify = handle_set_role; |
753 | 781 | ||
782 | wl_signal_add(&xsurface->events.set_startup_id, | ||
783 | &xwayland_view->set_startup_id); | ||
784 | xwayland_view->set_startup_id.notify = handle_set_startup_id; | ||
785 | |||
754 | wl_signal_add(&xsurface->events.set_window_type, | 786 | wl_signal_add(&xsurface->events.set_window_type, |
755 | &xwayland_view->set_window_type); | 787 | &xwayland_view->set_window_type); |
756 | xwayland_view->set_window_type.notify = handle_set_window_type; | 788 | xwayland_view->set_window_type.notify = handle_set_window_type; |