Skip to content

Commit

Permalink
Merge branch 'server-decorations'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunderland93 committed Dec 9, 2018
2 parents 6cf90f7 + 613e3f2 commit 830882e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +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/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
3 changes: 2 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions gfx/common/wayland/generate_wayland_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 43 additions & 6 deletions gfx/drivers_context/wayland_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion qb/config.libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ 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_PROTOS wayland-protocols 1.15
check_pkgconf XKBCOMMON xkbcommon 0.3.2
check_pkgconf DBUS dbus-1
check_pkgconf XEXT xext
Expand Down

0 comments on commit 830882e

Please sign in to comment.