mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
wayland: use xdg-decoration if available
This commit is contained in:
parent
ce2253b358
commit
6d2be82094
@ -32,6 +32,9 @@
|
|||||||
// Generated from idle-inhibit-unstable-v1.xml
|
// Generated from idle-inhibit-unstable-v1.xml
|
||||||
#include "video/out/wayland/idle-inhibit-v1.h"
|
#include "video/out/wayland/idle-inhibit-v1.h"
|
||||||
|
|
||||||
|
// Generated from xdg-decoration-unstable-v1.xml
|
||||||
|
#include "video/out/wayland/xdg-decoration-v1.h"
|
||||||
|
|
||||||
// Generated from server-decoration.xml
|
// Generated from server-decoration.xml
|
||||||
#include "video/out/wayland/srv-decor.h"
|
#include "video/out/wayland/srv-decor.h"
|
||||||
|
|
||||||
@ -827,6 +830,10 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id
|
|||||||
wl->server_decoration_manager = wl_registry_bind(reg, id, &org_kde_kwin_server_decoration_manager_interface, 1);
|
wl->server_decoration_manager = wl_registry_bind(reg, id, &org_kde_kwin_server_decoration_manager_interface, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name) && found++) {
|
||||||
|
wl->xdg_decoration_manager = wl_registry_bind(reg, id, &zxdg_decoration_manager_v1_interface, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(interface, zwp_idle_inhibit_manager_v1_interface.name) && found++) {
|
if (!strcmp(interface, zwp_idle_inhibit_manager_v1_interface.name) && found++) {
|
||||||
wl->idle_inhibit_manager = wl_registry_bind(reg, id, &zwp_idle_inhibit_manager_v1_interface, 1);
|
wl->idle_inhibit_manager = wl_registry_bind(reg, id, &zwp_idle_inhibit_manager_v1_interface, 1);
|
||||||
}
|
}
|
||||||
@ -970,18 +977,31 @@ static int create_xdg_surface(struct vo_wayland_state *wl)
|
|||||||
|
|
||||||
static int set_border_decorations(struct vo_wayland_state *wl, int state)
|
static int set_border_decorations(struct vo_wayland_state *wl, int state)
|
||||||
{
|
{
|
||||||
if (!wl->server_decoration)
|
if (wl->xdg_toplevel_decoration) {
|
||||||
return VO_NOTIMPL;
|
enum zxdg_toplevel_decoration_v1_mode mode;
|
||||||
enum org_kde_kwin_server_decoration_mode mode;
|
if (state) {
|
||||||
if (state) {
|
MP_VERBOSE(wl, "Enabling server decorations\n");
|
||||||
MP_VERBOSE(wl, "Enabling server decorations\n");
|
mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
||||||
mode = ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER;
|
} else {
|
||||||
|
MP_VERBOSE(wl, "Disabling server decorations\n");
|
||||||
|
mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
||||||
|
}
|
||||||
|
zxdg_toplevel_decoration_v1_set_mode(wl->xdg_toplevel_decoration, mode);
|
||||||
|
return VO_TRUE;
|
||||||
|
} else if (wl->server_decoration) {
|
||||||
|
enum org_kde_kwin_server_decoration_mode mode;
|
||||||
|
if (state) {
|
||||||
|
MP_VERBOSE(wl, "Enabling server decorations\n");
|
||||||
|
mode = ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER;
|
||||||
|
} else {
|
||||||
|
MP_VERBOSE(wl, "Disabling server decorations\n");
|
||||||
|
mode = ORG_KDE_KWIN_SERVER_DECORATION_MODE_NONE;
|
||||||
|
}
|
||||||
|
org_kde_kwin_server_decoration_request_mode(wl->server_decoration, mode);
|
||||||
|
return VO_TRUE;
|
||||||
} else {
|
} else {
|
||||||
MP_VERBOSE(wl, "Disabling server decorations\n");
|
return VO_NOTIMPL;
|
||||||
mode = ORG_KDE_KWIN_SERVER_DECORATION_MODE_NONE;
|
|
||||||
}
|
}
|
||||||
org_kde_kwin_server_decoration_request_mode(wl->server_decoration, mode);
|
|
||||||
return VO_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int vo_wayland_init(struct vo *vo)
|
int vo_wayland_init(struct vo *vo)
|
||||||
@ -1036,12 +1056,16 @@ int vo_wayland_init(struct vo *vo)
|
|||||||
wl_data_device_manager_interface.name);
|
wl_data_device_manager_interface.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl->server_decoration_manager) {
|
if (wl->xdg_decoration_manager) {
|
||||||
|
wl->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(wl->xdg_decoration_manager, wl->xdg_toplevel);
|
||||||
|
set_border_decorations(wl, vo->opts->border);
|
||||||
|
} else if (wl->server_decoration_manager) {
|
||||||
wl->server_decoration = org_kde_kwin_server_decoration_manager_create(wl->server_decoration_manager, wl->surface);
|
wl->server_decoration = org_kde_kwin_server_decoration_manager_create(wl->server_decoration_manager, wl->surface);
|
||||||
set_border_decorations(wl, vo->opts->border);
|
set_border_decorations(wl, vo->opts->border);
|
||||||
} else {
|
} else {
|
||||||
MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n",
|
MP_VERBOSE(wl, "Compositor doesn't support the %s or %s protocols!\n",
|
||||||
org_kde_kwin_server_decoration_manager_interface.name);
|
org_kde_kwin_server_decoration_manager_interface.name,
|
||||||
|
zxdg_decoration_manager_v1_interface.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wl->idle_inhibit_manager)
|
if (!wl->idle_inhibit_manager)
|
||||||
@ -1092,6 +1116,12 @@ void vo_wayland_uninit(struct vo *vo)
|
|||||||
if (wl->server_decoration_manager)
|
if (wl->server_decoration_manager)
|
||||||
org_kde_kwin_server_decoration_manager_destroy(wl->server_decoration_manager);
|
org_kde_kwin_server_decoration_manager_destroy(wl->server_decoration_manager);
|
||||||
|
|
||||||
|
if (wl->xdg_toplevel_decoration)
|
||||||
|
zxdg_toplevel_decoration_v1_destroy(wl->xdg_toplevel_decoration);
|
||||||
|
|
||||||
|
if (wl->xdg_decoration_manager)
|
||||||
|
zxdg_decoration_manager_v1_destroy(wl->xdg_decoration_manager);
|
||||||
|
|
||||||
if (wl->surface)
|
if (wl->surface)
|
||||||
wl_surface_destroy(wl->surface);
|
wl_surface_destroy(wl->surface);
|
||||||
|
|
||||||
|
@ -75,6 +75,8 @@ struct vo_wayland_state {
|
|||||||
struct xdg_surface *xdg_surface;
|
struct xdg_surface *xdg_surface;
|
||||||
struct org_kde_kwin_server_decoration_manager *server_decoration_manager;
|
struct org_kde_kwin_server_decoration_manager *server_decoration_manager;
|
||||||
struct org_kde_kwin_server_decoration *server_decoration;
|
struct org_kde_kwin_server_decoration *server_decoration;
|
||||||
|
struct zxdg_decoration_manager_v1 *xdg_decoration_manager;
|
||||||
|
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
||||||
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
|
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
|
||||||
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
|
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ def check_lua(ctx, dependency_identifier):
|
|||||||
|
|
||||||
def check_wl_protocols(ctx, dependency_identifier):
|
def check_wl_protocols(ctx, dependency_identifier):
|
||||||
def fn(ctx, dependency_identifier):
|
def fn(ctx, dependency_identifier):
|
||||||
ret = check_pkg_config_datadir("wayland-protocols", ">= 1.14")
|
ret = check_pkg_config_datadir("wayland-protocols", ">= 1.15")
|
||||||
ret = ret(ctx, dependency_identifier)
|
ret = ret(ctx, dependency_identifier)
|
||||||
if ret != None:
|
if ret != None:
|
||||||
ctx.env.WL_PROTO_DIR = ret.split()[0]
|
ctx.env.WL_PROTO_DIR = ret.split()[0]
|
||||||
|
@ -129,6 +129,12 @@ def build(ctx):
|
|||||||
ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR,
|
ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR,
|
||||||
protocol = "unstable/idle-inhibit/idle-inhibit-unstable-v1",
|
protocol = "unstable/idle-inhibit/idle-inhibit-unstable-v1",
|
||||||
target = "video/out/wayland/idle-inhibit-v1.h")
|
target = "video/out/wayland/idle-inhibit-v1.h")
|
||||||
|
ctx.wayland_protocol_code(proto_dir = ctx.env.WL_PROTO_DIR,
|
||||||
|
protocol = "unstable/xdg-decoration/xdg-decoration-unstable-v1",
|
||||||
|
target = "video/out/wayland/xdg-decoration-v1.c")
|
||||||
|
ctx.wayland_protocol_header(proto_dir = ctx.env.WL_PROTO_DIR,
|
||||||
|
protocol = "unstable/xdg-decoration/xdg-decoration-unstable-v1",
|
||||||
|
target = "video/out/wayland/xdg-decoration-v1.h")
|
||||||
ctx.wayland_protocol_code(proto_dir = "video/out/wayland",
|
ctx.wayland_protocol_code(proto_dir = "video/out/wayland",
|
||||||
protocol = "server-decoration",
|
protocol = "server-decoration",
|
||||||
vendored_protocol = True,
|
vendored_protocol = True,
|
||||||
@ -508,6 +514,7 @@ def build(ctx):
|
|||||||
( "video/out/w32_common.c", "win32-desktop" ),
|
( "video/out/w32_common.c", "win32-desktop" ),
|
||||||
( "video/out/wayland/idle-inhibit-v1.c", "wayland" ),
|
( "video/out/wayland/idle-inhibit-v1.c", "wayland" ),
|
||||||
( "video/out/wayland/srv-decor.c", "wayland" ),
|
( "video/out/wayland/srv-decor.c", "wayland" ),
|
||||||
|
( "video/out/wayland/xdg-decoration-v1.c", "wayland" ),
|
||||||
( "video/out/wayland/xdg-shell.c", "wayland" ),
|
( "video/out/wayland/xdg-shell.c", "wayland" ),
|
||||||
( "video/out/wayland_common.c", "wayland" ),
|
( "video/out/wayland_common.c", "wayland" ),
|
||||||
( "video/out/win32/displayconfig.c", "win32-desktop" ),
|
( "video/out/win32/displayconfig.c", "win32-desktop" ),
|
||||||
|
Loading…
Reference in New Issue
Block a user