Skip to content

Commit 17a1388

Browse files
bbb651Dudemanguy
authored andcommitted
wayland: support xdg-activation
1 parent bbac628 commit 17a1388

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

video/out/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ protocols = [[wl_protocol_dir, 'stable/presentation-time/presentation-time.xml']
99
[wl_protocol_dir, 'staging/content-type/content-type-v1.xml'],
1010
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
1111
[wl_protocol_dir, 'staging/single-pixel-buffer/single-pixel-buffer-v1.xml'],
12+
[wl_protocol_dir, 'staging/xdg-activation/xdg-activation-v1.xml'],
1213
['protocols', 'xx-color-management-v4.xml']]
1314
wl_protocols_source = []
1415
wl_protocols_headers = []

video/out/wayland_common.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "text-input-unstable-v3.h"
4141
#include "linux-dmabuf-unstable-v1.h"
4242
#include "presentation-time.h"
43+
#include "xdg-activation-v1.h"
4344
#include "xdg-decoration-unstable-v1.h"
4445
#include "xdg-shell.h"
4546
#include "viewporter.h"
@@ -1897,6 +1898,11 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id
18971898
xx_color_manager_v4_add_listener(wl->color_manager, &color_manager_listener, wl);
18981899
}
18991900

1901+
if (!strcmp(interface, xdg_activation_v1_interface.name) && found++) {
1902+
ver = 1;
1903+
wl->xdg_activation = wl_registry_bind(reg, id, &xdg_activation_v1_interface, ver);
1904+
}
1905+
19001906
if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name) && found++) {
19011907
ver = 1;
19021908
wl->xdg_decoration_manager = wl_registry_bind(reg, id, &zxdg_decoration_manager_v1_interface, ver);
@@ -2087,6 +2093,16 @@ static bool create_input(struct vo_wayland_state *wl)
20872093
return 0;
20882094
}
20892095

2096+
static void xdg_activate(struct vo_wayland_state *wl)
2097+
{
2098+
const char *token = getenv("XDG_ACTIVATION_TOKEN");
2099+
if (token) {
2100+
MP_VERBOSE(wl, "Activating window with token: '%s'\n", token);
2101+
xdg_activation_v1_activate(wl->xdg_activation, token, wl->surface);
2102+
unsetenv("XDG_ACTIVATION_TOKEN");
2103+
}
2104+
}
2105+
20902106
static int create_viewports(struct vo_wayland_state *wl)
20912107
{
20922108
wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
@@ -3173,6 +3189,13 @@ bool vo_wayland_init(struct vo *vo)
31733189
if (create_xdg_surface(wl))
31743190
goto err;
31753191

3192+
if (wl->xdg_activation) {
3193+
xdg_activate(wl);
3194+
} else {
3195+
MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n",
3196+
xdg_activation_v1_interface.name);
3197+
}
3198+
31763199
if (wl->subcompositor) {
31773200
wl->osd_subsurface = wl_subcompositor_get_subsurface(wl->subcompositor, wl->osd_surface, wl->video_surface);
31783201
wl->video_subsurface = wl_subcompositor_get_subsurface(wl->subcompositor, wl->video_surface, wl->surface);
@@ -3472,6 +3495,9 @@ void vo_wayland_uninit(struct vo *vo)
34723495
if (wl->wm_base)
34733496
xdg_wm_base_destroy(wl->wm_base);
34743497

3498+
if (wl->xdg_activation)
3499+
xdg_activation_v1_destroy(wl->xdg_activation);
3500+
34753501
if (wl->xdg_decoration_manager)
34763502
zxdg_decoration_manager_v1_destroy(wl->xdg_decoration_manager);
34773503

video/out/wayland_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "input/event.h"
2424
#include "video/mp_image.h"
2525
#include "vo.h"
26+
#include "xdg-activation-v1.h"
2627

2728
struct compositor_format;
2829
struct vo_wayland_seat;
@@ -143,6 +144,9 @@ struct vo_wayland_state {
143144
/* single-pixel-buffer */
144145
struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;
145146

147+
/* xdg-activation */
148+
struct xdg_activation_v1 *xdg_activation;
149+
146150
/* xdg-decoration */
147151
struct zxdg_decoration_manager_v1 *xdg_decoration_manager;
148152
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;

0 commit comments

Comments
 (0)