Commit 8e5d7550 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

Implement zwp_tearing_control_unstable_v1

parent a50a0e34
Pipeline #312048 failed with stages
in 16 minutes and 17 seconds
......@@ -93,6 +93,8 @@ Xwayland_DEPENDENCIES = $(glamor_lib) $(XWAYLAND_LIBS)
endif
Xwayland_built_sources += \
tearing-control-unstable-v1-client-protocol.h \
tearing-control-unstable-v1-protocol.c \
relative-pointer-unstable-v1-client-protocol.h \
relative-pointer-unstable-v1-protocol.c \
pointer-constraints-unstable-v1-client-protocol.h \
......@@ -131,6 +133,11 @@ $(Xwayland_SOURCES): $(Xwayland_built_sources)
relink:
$(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT)
tearing-control-unstable-v1-protocol.c : ${WAYLAND_PROTOCOLS_DATADIR}/unstable/tearing-control/tearing-control-unstable-v1.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) @SCANNER_ARG@ < $< > $@
tearing-control-unstable-v1-client-protocol.h : ${WAYLAND_PROTOCOLS_DATADIR}/unstable/tearing-control/tearing-control-unstable-v1.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
relative-pointer-unstable-v1-protocol.c : $(WAYLAND_PROTOCOLS_DATADIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) @SCANNER_ARG@ < $< > $@
relative-pointer-unstable-v1-client-protocol.h : $(WAYLAND_PROTOCOLS_DATADIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml
......
......@@ -42,6 +42,7 @@ xdg_output_xml = join_paths(protodir, 'unstable', 'xdg-output', 'xdg-output-unst
dmabuf_xml = join_paths(protodir, 'unstable', 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml')
viewporter_xml = join_paths(protodir, 'stable', 'viewporter', 'viewporter.xml')
xdg_shell_xml = join_paths(protodir, 'stable', 'xdg-shell', 'xdg-shell.xml')
tearing_xml = join_paths(protodir, 'unstable', 'tearing-control', 'tearing-control-unstable-v1.xml')
client_header = generator(scanner,
output : '@BASENAME@-client-protocol.h',
......@@ -66,6 +67,7 @@ srcs += client_header.process(xdg_output_xml)
srcs += client_header.process(dmabuf_xml)
srcs += client_header.process(viewporter_xml)
srcs += client_header.process(xdg_shell_xml)
srcs += client_header.process(tearing_xml)
srcs += code.process(relative_xml)
srcs += code.process(pointer_xml)
srcs += code.process(tablet_xml)
......@@ -74,6 +76,7 @@ srcs += code.process(xdg_output_xml)
srcs += code.process(dmabuf_xml)
srcs += code.process(viewporter_xml)
srcs += code.process(xdg_shell_xml)
srcs += code.process(tearing_xml)
xwayland_glamor = []
eglstream_srcs = []
......
......@@ -33,6 +33,7 @@
#include "xwayland-window.h"
#include "xwayland-pixmap.h"
#include "glamor.h"
#include "tearing-control-unstable-v1-client-protocol.h"
/*
* When not flipping let Present copy with 60fps.
......@@ -488,6 +489,18 @@ xwl_present_flip(WindowPtr present_window,
damage_box->x2 - damage_box->x1,
damage_box->y2 - damage_box->y1);
if (xwl_window->tearing_control) {
uint32_t hint;
if (sync_flip) {
hint = ZWP_SURFACE_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC;
} else if (target_msc > xwl_present_window->msc) {
hint = ZWP_SURFACE_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC_RELAXED;
} else {
hint = ZWP_SURFACE_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
}
zwp_surface_tearing_control_v1_set_presentation_hint(xwl_window->tearing_control, hint);
}
wl_surface_commit(xwl_window->surface);
if (!sync_flip) {
......
......@@ -55,6 +55,7 @@
#include "xdg-output-unstable-v1-client-protocol.h"
#include "viewporter-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "tearing-control-unstable-v1-client-protocol.h"
static DevPrivateKeyRec xwl_screen_private_key;
static DevPrivateKeyRec xwl_client_private_key;
......@@ -391,6 +392,9 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
else if (strcmp(interface, "wp_viewporter") == 0) {
xwl_screen->viewporter = wl_registry_bind(registry, id, &wp_viewporter_interface, 1);
}
else if (strcmp(interface, "zwp_tearing_control_v1") == 0) {
xwl_screen->tearing_control = wl_registry_bind(registry, id, &zwp_tearing_control_v1_interface, 1);
}
#ifdef XWL_HAS_GLAMOR
else if (xwl_screen->glamor) {
xwl_glamor_init_wl_registry(xwl_screen, registry, id, interface,
......
......@@ -86,6 +86,7 @@ struct xwl_screen {
struct zwp_linux_dmabuf_v1 *dmabuf;
struct zxdg_output_manager_v1 *xdg_output_manager;
struct wp_viewporter *viewporter;
struct zwp_tearing_control_v1 *tearing_control;
uint32_t serial;
#define XWL_FORMAT_ARGB8888 (1 << 0)
......
......@@ -45,6 +45,7 @@
#include "viewporter-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "tearing-control-unstable-v1-client-protocol.h"
static DevPrivateKeyRec xwl_window_private_key;
static DevPrivateKeyRec xwl_damage_private_key;
......@@ -448,6 +449,10 @@ ensure_surface_for_window(WindowPtr window)
goto err;
}
if (xwl_screen->tearing_control) {
xwl_window->tearing_control = zwp_tearing_control_v1_get_tearing_control(xwl_screen->tearing_control, xwl_window->surface);
}
if (!xwl_screen->rootless) {
xwl_window->xdg_surface =
xdg_wm_base_get_xdg_surface(xwl_screen->xdg_wm_base, xwl_window->surface);
......@@ -596,6 +601,11 @@ xwl_unrealize_window(WindowPtr window)
if (xwl_window_has_viewport_enabled(xwl_window))
xwl_window_disable_viewport(xwl_window);
if (xwl_window->tearing_control) {
zwp_surface_tearing_control_v1_destroy(xwl_window->tearing_control);
xwl_window->tearing_control = NULL;
}
wl_surface_destroy(xwl_window->surface);
xorg_list_del(&xwl_window->link_damage);
xorg_list_del(&xwl_window->link_window);
......
......@@ -55,6 +55,7 @@ struct xwl_window {
struct xorg_list frame_callback_list;
Bool present_flipped;
#endif
struct zwp_surface_tearing_control_v1 *tearing_control;
};
struct xwl_window *xwl_window_get(WindowPtr window);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment