[vlc-commits] [Git][videolan/vlc][master] qt: do not use viewporter protocol if Qt does not use fractional scaling

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jan 5 16:22:57 UTC 2025



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
3afeac5c by Fatih Uzunoglu at 2025-01-05T16:09:02+00:00
qt: do not use viewporter protocol if Qt does not use fractional scaling

Viewporter protocol is used for fractional scaling, and currently we do
not use the fractional scaling protocol ourselves because Qt uses it and
provides scale through the interface window.

However, Qt starts supporting fractional scale on Wayland starting with
6.5.0. If Qt version is lower than 6.5.0, it is not necessary to use the
viewporter protocol because Qt is not going to provide the fractional
scale anyway.

I don't think it is a good idea to start using the fractional protocol
ourselves to get the fractional scale, instead of Qt providing that. The
reason is the video window should use the same scale as the interface
window for video integration, and it complicates the code unnecessarily.

I have not realized this before, because I test Qt code with Qt 6.2 and
Qt 6.8, and I can not test Wayland changes on Qt 6.2 because it has never
been working for me on Wayland.

- - - - -


2 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/compositor_wayland_module.c


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -645,12 +645,14 @@ libqt_wayland_plugin_la_SOURCES += \
 	util/csdmenu_module.h
 
 nodist_libqt_wayland_plugin_la_SOURCES = \
-	maininterface/viewporter-client-protocol.h \
-	maininterface/viewporter-protocol.c \
 	maininterface/xdg-shell-client-protocol.h \
 	maininterface/xdg-shell-protocol.c
 
-BUILT_SOURCES += $(nodist_libqt_wayland_plugin_la_SOURCES)
+if HAVE_QT65
+libqt_wayland_plugin_la_CFLAGS += -DQT_HAS_WAYLAND_FRACTIONAL_SCALING
+nodist_libqt_wayland_plugin_la_SOURCES += \
+	maininterface/viewporter-client-protocol.h \
+	maininterface/viewporter-protocol.c
 
 maininterface/viewporter-client-protocol.h: \
 		$(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml
@@ -660,6 +662,9 @@ maininterface/viewporter-protocol.c: \
 		$(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml \
 		maininterface/viewporter-client-protocol.h
 	$(AM_V_GEN)$(WAYLAND_SCANNER) private-code $< $@
+endif
+
+BUILT_SOURCES += $(nodist_libqt_wayland_plugin_la_SOURCES)
 
 maininterface/xdg-shell-client-protocol.h: $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml Makefile.am
 	$(AM_V_GEN)$(WAYLAND_SCANNER) client-header $< $@


=====================================
modules/gui/qt/maininterface/compositor_wayland_module.c
=====================================
@@ -25,7 +25,7 @@
 #include <vlc_plugin.h>
 #include <wayland-client.h>
 
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
 #include "viewporter-client-protocol.h"
 #endif
 
@@ -38,7 +38,7 @@ typedef struct
     struct wl_compositor* compositor;
     struct wl_subcompositor* subcompositor;
 
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     struct wp_viewport* viewport;
     struct wp_viewporter* viewporter;
 #endif
@@ -66,7 +66,7 @@ static void registry_global_cb(void* data, struct wl_registry* registry,
         sys->compositor_interface_version = version;
         sys->compositor = (struct wl_compositor*)wl_registry_bind(registry, id, &wl_compositor_interface, version);
     }
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     if (!strcmp(iface, "wp_viewporter"))
         sys->viewporter = (struct wp_viewporter*)wl_registry_bind(registry, id, &wp_viewporter_interface, version);
 #endif
@@ -106,7 +106,7 @@ static int SetupVoutWindow(qtwayland_t* obj, vlc_window_t* wnd)
     if (!sys->video_surface)
         return VLC_EGENERIC;
 
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     if (sys->viewporter)
         sys->viewport = wp_viewporter_get_viewport(sys->viewporter, sys->video_surface);
     else
@@ -115,8 +115,8 @@ static int SetupVoutWindow(qtwayland_t* obj, vlc_window_t* wnd)
         // The buffer scale must remain 1 when fractional scaling is used
         if (sys->buffer_scale != 1)
         {
-            msg_Dbg(obj, "Viewporter protocol is not available, and scale is not 1." \
-                         "Only integer scaling may be possible.");
+            msg_Dbg(obj, "Viewporter protocol is not available or Qt version is less than " \
+                         "6.5.0, and scale is not 1. Only integer scaling may be possible.");
 
             if (sys->compositor_interface_version >= 3)
             {
@@ -155,7 +155,7 @@ static void TeardownVoutWindow(struct qtwayland_t* obj)
 {
     qtwayland_priv_t* sys = (qtwayland_priv_t*)obj->p_sys;
 
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     if (sys->viewport)
     {
         wp_viewport_destroy(sys->viewport);
@@ -205,7 +205,7 @@ static void Move(struct qtwayland_t* obj, int x, int y)
 
 static void Resize(struct qtwayland_t* obj, size_t width, size_t height)
 {
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     qtwayland_priv_t* sys = (qtwayland_priv_t*)obj->p_sys;
     assert(sys);
     if (!sys->video_surface)
@@ -228,7 +228,7 @@ static void Close(qtwayland_t* obj)
     qtwayland_priv_t* sys = (qtwayland_priv_t*)(obj->p_sys);
     wl_display_flush(sys->display);
 
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     if (sys->viewporter)
         wp_viewporter_destroy(sys->viewporter);
 #endif
@@ -254,7 +254,7 @@ static bool Init(qtwayland_t* obj, void* qpni_display)
     void* wrapper = wl_proxy_create_wrapper(display);
     wl_proxy_set_queue((struct wl_proxy*)wrapper, sys->queue);
 
-#ifdef QT_HAS_WAYLAND_PROTOCOLS
+#ifdef QT_HAS_WAYLAND_FRACTIONAL_SCALING
     sys->viewporter = NULL;
     sys->viewport = NULL;
 #endif



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3afeac5c1ee76921fb528932ad01bd1436f9a2bf

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3afeac5c1ee76921fb528932ad01bd1436f9a2bf
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list