Merge pull request #7717 from Sunderland93/master

Implement support for xdg-decoration
This commit is contained in:
Twinaphex 2018-12-09 22:11:43 +01:00 committed by GitHub
commit 7e49146c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 16 deletions

6
.gitignore vendored
View File

@ -167,7 +167,9 @@ retroarch_switch.nso
# Wayland
gfx/common/wayland/idle-inhibit-unstable-v1.c
gfx/common/wayland/idle-inhibit-unstable-v1.h
gfx/common/wayland/idle-inhibit-unstable-v6.c
gfx/common/wayland/idle-inhibit-unstable-v6.h
gfx/common/wayland/xdg-shell-unstable-v6.c
gfx/common/wayland/xdg-shell-unstable-v6.h
gfx/common/wayland/xdg-decoration-unstable-v1.h
gfx/common/wayland/xdg-decoration-unstable-v1.c
gfx/common/wayland/xdg-shell.c
gfx/common/wayland/xdg-shell.h

View File

@ -867,7 +867,8 @@ ifeq ($(HAVE_WAYLAND), 1)
input/drivers/wayland_input.o \
gfx/common/wayland/xdg-shell.o \
gfx/common/wayland/xdg-shell-unstable-v6.o \
gfx/common/wayland/idle-inhibit-unstable-v1.o
gfx/common/wayland/idle-inhibit-unstable-v1.o \
gfx/common/wayland/xdg-decoration-unstable-v1.o
ifeq ($(HAVE_EGL), 1)
LIBS += $(EGL_LIBS)
endif

View File

@ -9,12 +9,16 @@ fi
#Generate xdg-shell_v6 header and .c files
$WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.h
$WAYSCAN code $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.c
$WAYSCAN private-code $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.c
#Generate xdg-shell header and .c files
$WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h
$WAYSCAN code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c
$WAYSCAN private-code $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c
#Generate idle-inhibit header and .c files
$WAYSCAN client-header $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.h
$WAYSCAN code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c
$WAYSCAN private-code $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c
#Generate xdg-decoration header and .c files
$WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.h
$WAYSCAN private-code $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.c

View File

@ -56,6 +56,9 @@
/* Generated from xdg-shell.xml */
#include "../common/wayland/xdg-shell.h"
/* Generated from xdg-decoration-unstable-v1.h */
#include "../common/wayland/xdg-decoration-unstable-v1.h"
typedef struct touch_pos
{
@ -103,6 +106,8 @@ typedef struct gfx_ctx_wayland_data
struct wl_touch *wl_touch;
struct wl_seat *seat;
struct wl_shm *shm;
struct zxdg_decoration_manager_v1 *deco_manager;
struct zxdg_toplevel_decoration_v1 *deco;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
int swap_interval;
@ -842,6 +847,9 @@ static void registry_handle_global(void *data, struct wl_registry *reg,
else if (string_is_equal(interface, "zwp_idle_inhibit_manager_v1"))
wl->idle_inhibit_manager = (struct zwp_idle_inhibit_manager_v1*)wl_registry_bind(
reg, id, &zwp_idle_inhibit_manager_v1_interface, 1);
else if (string_is_equal(interface, "zxdg_decoration_manager_v1"))
wl->deco_manager = (struct zxdg_decoration_manager_v1*)wl_registry_bind(
reg, id, &zxdg_decoration_manager_v1_interface, 1);
}
static void registry_handle_global_remove(void *data,
@ -938,6 +946,10 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl)
wl_shell_surface_destroy(wl->shell_surf);
if (wl->idle_inhibit_manager)
zwp_idle_inhibit_manager_v1_destroy(wl->idle_inhibit_manager);
if (wl->deco)
zxdg_toplevel_decoration_v1_destroy(wl->deco);
if (wl->deco_manager)
zxdg_decoration_manager_v1_destroy(wl->deco_manager);
if (wl->idle_inhibitor)
zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor);
@ -1082,10 +1094,18 @@ static void gfx_ctx_wl_update_title(void *data, void *data2)
video_driver_get_window_title(title, sizeof(title));
if (wl && title[0]) {
if (wl->xdg_toplevel)
xdg_toplevel_set_title(wl->xdg_toplevel, title);
else if (wl->zxdg_toplevel)
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title);
if (wl->xdg_toplevel) {
if (wl->deco) {
zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
xdg_toplevel_set_title(wl->xdg_toplevel, title);
}
else if (wl->zxdg_toplevel) {
if (wl->deco) {
zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title);
}
else if (wl->shell_surf)
wl_shell_surface_set_title(wl->shell_surf, title);
}
@ -1268,6 +1288,11 @@ static void *gfx_ctx_wl_init(video_frame_info_t *video_info, void *video_driver)
{
RARCH_WARN("[Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol!\n");
}
if (!wl->deco_manager)
{
RARCH_WARN("[Wayland]: Compositor doesn't support zxdg_decoration_manager_v1 protocol!\n");
}
wl->input.fd = wl_display_get_fd(wl->input.dpy);
@ -1500,7 +1525,13 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
xdg_toplevel_set_app_id(wl->xdg_toplevel, "RetroArch");
xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch");
if (wl->deco_manager) {
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
wl->deco_manager, wl->xdg_toplevel);
}
/* Waiting for xdg_toplevel to be configured before starting to draw */
wl_surface_commit(wl->surface);
wl->configured = true;
@ -1518,7 +1549,13 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "RetroArch");
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch");
if (wl->deco_manager) {
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
wl->deco_manager, wl->xdg_toplevel);
}
/* Waiting for xdg_toplevel to be configured before starting to draw */
wl_surface_commit(wl->surface);
wl->configured = true;

View File

@ -455,9 +455,9 @@ check_pkgconf V4L2 libv4l2
check_pkgconf FREETYPE freetype2
check_pkgconf X11 x11
check_pkgconf XCB xcb
check_pkgconf WAYLAND wayland-egl 1.14
check_pkgconf WAYLAND_CURSOR wayland-cursor 1.14
check_pkgconf WAYLAND_PROTOS wayland-protocols 1.13
check_pkgconf WAYLAND wayland-egl 1.15
check_pkgconf WAYLAND_CURSOR wayland-cursor 1.15
check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15
check_pkgconf XKBCOMMON xkbcommon 0.3.2
check_pkgconf DBUS dbus-1
check_pkgconf XEXT xext
@ -474,7 +474,7 @@ check_val '' XEXT -lXext
check_val '' XF86VM -lXxf86vm
if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then
check_pkgconf WAYLAND_SCANNER wayland-scanner 1.13
check_pkgconf WAYLAND_SCANNER wayland-scanner 1.15
./gfx/common/wayland/generate_wayland_protos.sh
else
die : 'Notice: wayland-egl or wayland-protocols not present. Skiping Wayland code paths.'