diff options
author | Simon Ser <contact@emersion.fr> | 2021-03-23 11:31:18 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-06-02 19:39:40 +0200 |
commit | 9755684fb0fd665a65be2a3cbabc5d502244c459 (patch) | |
tree | 7fbe0b1149314b9d902d328c74bbc7cba6c05004 | |
parent | details-gackground typo fix (diff) | |
download | sway-9755684fb0fd665a65be2a3cbabc5d502244c459.tar.gz sway-9755684fb0fd665a65be2a3cbabc5d502244c459.tar.zst sway-9755684fb0fd665a65be2a3cbabc5d502244c459.zip |
Implement xdg-activation-v1
See https://github.com/swaywm/wlroots/pull/2718.
-rw-r--r-- | include/sway/server.h | 5 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/server.c | 7 | ||||
-rw-r--r-- | sway/xdg_activation_v1.c | 20 |
4 files changed, 33 insertions, 0 deletions
diff --git a/include/sway/server.h b/include/sway/server.h index 5a2562b3..3a5670d9 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -87,6 +87,9 @@ struct sway_server { | |||
87 | struct wlr_text_input_manager_v3 *text_input; | 87 | struct wlr_text_input_manager_v3 *text_input; |
88 | struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; | 88 | struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; |
89 | 89 | ||
90 | struct wlr_xdg_activation_v1 *xdg_activation_v1; | ||
91 | struct wl_listener xdg_activation_v1_request_activate; | ||
92 | |||
90 | // The timeout for transactions, after which a transaction is applied | 93 | // The timeout for transactions, after which a transaction is applied |
91 | // regardless of readiness. | 94 | // regardless of readiness. |
92 | size_t txn_timeout_ms; | 95 | size_t txn_timeout_ms; |
@@ -141,5 +144,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data); | |||
141 | void handle_server_decoration(struct wl_listener *listener, void *data); | 144 | void handle_server_decoration(struct wl_listener *listener, void *data); |
142 | void handle_xdg_decoration(struct wl_listener *listener, void *data); | 145 | void handle_xdg_decoration(struct wl_listener *listener, void *data); |
143 | void handle_pointer_constraint(struct wl_listener *listener, void *data); | 146 | void handle_pointer_constraint(struct wl_listener *listener, void *data); |
147 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | ||
148 | void *data); | ||
144 | 149 | ||
145 | #endif | 150 | #endif |
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( | |||
8 | 'main.c', | 8 | 'main.c', |
9 | 'server.c', | 9 | 'server.c', |
10 | 'swaynag.c', | 10 | 'swaynag.c', |
11 | 'xdg_activation_v1.c', | ||
11 | 'xdg_decoration.c', | 12 | 'xdg_decoration.c', |
12 | 13 | ||
13 | 'desktop/desktop.c', | 14 | '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 @@ | |||
25 | #include <wlr/types/wlr_tablet_v2.h> | 25 | #include <wlr/types/wlr_tablet_v2.h> |
26 | #include <wlr/types/wlr_viewporter.h> | 26 | #include <wlr/types/wlr_viewporter.h> |
27 | #include <wlr/types/wlr_xcursor_manager.h> | 27 | #include <wlr/types/wlr_xcursor_manager.h> |
28 | #include <wlr/types/wlr_xdg_activation_v1.h> | ||
28 | #include <wlr/types/wlr_xdg_decoration_v1.h> | 29 | #include <wlr/types/wlr_xdg_decoration_v1.h> |
29 | #include <wlr/types/wlr_xdg_foreign_registry.h> | 30 | #include <wlr/types/wlr_xdg_foreign_registry.h> |
30 | #include <wlr/types/wlr_xdg_foreign_v1.h> | 31 | #include <wlr/types/wlr_xdg_foreign_v1.h> |
@@ -159,6 +160,12 @@ bool server_init(struct sway_server *server) { | |||
159 | wlr_xdg_foreign_v1_create(server->wl_display, foreign_registry); | 160 | wlr_xdg_foreign_v1_create(server->wl_display, foreign_registry); |
160 | wlr_xdg_foreign_v2_create(server->wl_display, foreign_registry); | 161 | wlr_xdg_foreign_v2_create(server->wl_display, foreign_registry); |
161 | 162 | ||
163 | server->xdg_activation_v1 = wlr_xdg_activation_v1_create(server->wl_display); | ||
164 | server->xdg_activation_v1_request_activate.notify = | ||
165 | xdg_activation_v1_handle_request_activate; | ||
166 | wl_signal_add(&server->xdg_activation_v1->events.request_activate, | ||
167 | &server->xdg_activation_v1_request_activate); | ||
168 | |||
162 | // Avoid using "wayland-0" as display socket | 169 | // Avoid using "wayland-0" as display socket |
163 | char name_candidate[16]; | 170 | char name_candidate[16]; |
164 | for (int i = 1; i <= 32; ++i) { | 171 | 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 @@ | |||
1 | #include <wlr/types/wlr_xdg_activation_v1.h> | ||
2 | #include "sway/tree/view.h" | ||
3 | |||
4 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | ||
5 | void *data) { | ||
6 | const struct wlr_xdg_activation_v1_request_activate_event *event = data; | ||
7 | |||
8 | if (!wlr_surface_is_xdg_surface(event->surface)) { | ||
9 | return; | ||
10 | } | ||
11 | |||
12 | struct wlr_xdg_surface *xdg_surface = | ||
13 | wlr_xdg_surface_from_wlr_surface(event->surface); | ||
14 | struct sway_view *view = xdg_surface->data; | ||
15 | if (!xdg_surface->mapped || view == NULL) { | ||
16 | return; | ||
17 | } | ||
18 | |||
19 | view_request_activate(view); | ||
20 | } | ||