diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/server.c | 7 | ||||
-rw-r--r-- | sway/xdg_activation_v1.c | 20 |
3 files changed, 28 insertions, 0 deletions
diff --git a/sway/meson.build b/sway/meson.build index b52fada4..1402db15 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -8,6 +8,7 @@ sway_sources = files( 'main.c', 'server.c', 'swaynag.c', + 'xdg_activation_v1.c', 'xdg_decoration.c', 'desktop/desktop.c', diff --git a/sway/server.c b/sway/server.c index 418f3370..2e5ab104 100644 --- a/sway/server.c +++ b/sway/server.c @@ -25,6 +25,7 @@ #include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_viewporter.h> #include <wlr/types/wlr_xcursor_manager.h> +#include <wlr/types/wlr_xdg_activation_v1.h> #include <wlr/types/wlr_xdg_decoration_v1.h> #include <wlr/types/wlr_xdg_foreign_registry.h> #include <wlr/types/wlr_xdg_foreign_v1.h> @@ -159,6 +160,12 @@ bool server_init(struct sway_server *server) { wlr_xdg_foreign_v1_create(server->wl_display, foreign_registry); wlr_xdg_foreign_v2_create(server->wl_display, foreign_registry); + server->xdg_activation_v1 = wlr_xdg_activation_v1_create(server->wl_display); + server->xdg_activation_v1_request_activate.notify = + xdg_activation_v1_handle_request_activate; + wl_signal_add(&server->xdg_activation_v1->events.request_activate, + &server->xdg_activation_v1_request_activate); + // Avoid using "wayland-0" as display socket char name_candidate[16]; for (int i = 1; i <= 32; ++i) { diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c new file mode 100644 index 00000000..6c70c785 --- /dev/null +++ b/sway/xdg_activation_v1.c @@ -0,0 +1,20 @@ +#include <wlr/types/wlr_xdg_activation_v1.h> +#include "sway/tree/view.h" + +void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, + void *data) { + const struct wlr_xdg_activation_v1_request_activate_event *event = data; + + if (!wlr_surface_is_xdg_surface(event->surface)) { + return; + } + + struct wlr_xdg_surface *xdg_surface = + wlr_xdg_surface_from_wlr_surface(event->surface); + struct sway_view *view = xdg_surface->data; + if (!xdg_surface->mapped || view == NULL) { + return; + } + + view_request_activate(view); +} |