From 876cbf0800634b382b0a99e8cd086f588997f9d8 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 23 Jul 2024 16:06:14 +0200 Subject: [PATCH] Generate better (fake) modelines This is what Xwayland does, so let's try to do the same to avoid any incompatibilites with applications. --- unix/xserver/hw/vnc/Makefile.am | 8 ++++++-- unix/xserver/hw/vnc/xvnc.c | 29 ++++++++++++++++++++++++++++- unix/xserver120.patch | 17 ++++++++++++++++- unix/xserver21.patch | 17 ++++++++++++++++- 4 files changed, 66 insertions(+), 5 deletions(-) diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am index d344c85d5..caf3b9480 100644 --- a/unix/xserver/hw/vnc/Makefile.am +++ b/unix/xserver/hw/vnc/Makefile.am @@ -12,7 +12,7 @@ AM_CPPFLAGS = \ -I$(TIGERVNC_BUILDDIR) \ -I$(TIGERVNC_SRCDIR)/common \ -I$(TIGERVNC_SRCDIR)/unix/common \ - $(DIX_CFLAGS) + $(DIX_CFLAGS) $(LIBXCVT_CFLAGS) AM_CXXFLAGS = -std=gnu++11 @@ -53,7 +53,11 @@ LOCAL_LIBS = \ $(COMMON_LIBS) Xvnc_DEPENDENCIES = $(LOCAL_LIBS) -Xvnc_LDADD = $(LOCAL_LIBS) $(XSERVER_SYS_LIBS) $(XVNC_SYS_LIBS) +Xvnc_LDADD = \ + $(LOCAL_LIBS) \ + $(XSERVER_SYS_LIBS) \ + $(XVNC_SYS_LIBS) \ + $(LIBXCVT_LIBS) Xvnc_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 092b99b10..0165d5989 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -41,6 +41,9 @@ from the X Consortium. #include "xorg-version.h" #include +#ifdef HAVE_LIBXCVT +#include +#endif #include #include #include @@ -764,13 +767,37 @@ vncRandRModeGet(int width, int height) RRModePtr mode; memset(&modeInfo, 0, sizeof(modeInfo)); - sprintf(name, "%dx%d", width, height); +#ifdef HAVE_LIBXCVT + struct libxcvt_mode_info *cvtMode; + + cvtMode = libxcvt_gen_mode_info(width, height, 60.0, false, false); + + modeInfo.width = cvtMode->hdisplay; + modeInfo.height = cvtMode->vdisplay; + modeInfo.dotClock = cvtMode->dot_clock * 1000.0; + modeInfo.hSyncStart = cvtMode->hsync_start; + modeInfo.hSyncEnd = cvtMode->hsync_end; + modeInfo.hTotal = cvtMode->htotal; + modeInfo.vSyncStart = cvtMode->vsync_start; + modeInfo.vSyncEnd = cvtMode->vsync_end; + modeInfo.vTotal = cvtMode->vtotal; + modeInfo.modeFlags = cvtMode->mode_flags; + + free(cvtMode); + + /* libxcvt rounds up to multiples of 8, so override them here */ + modeInfo.width = width; + modeInfo.height = height; +#else modeInfo.width = width; modeInfo.height = height; modeInfo.hTotal = width; modeInfo.vTotal = height; modeInfo.dotClock = ((CARD32) width * (CARD32) height * 60); +#endif + + sprintf(name, "%dx%d", width, height); modeInfo.nameLength = strlen(name); mode = RRModeGet(&modeInfo, name); if (mode == NULL) diff --git a/unix/xserver120.patch b/unix/xserver120.patch index 9bc51822a..d36e5075f 100644 --- a/unix/xserver120.patch +++ b/unix/xserver120.patch @@ -10,7 +10,7 @@ index 0909cc5b4..c01873200 100644 AC_PROG_LN_S LT_PREREQ([2.2]) LT_INIT([disable-static win32-dll]) -@@ -1735,6 +1736,14 @@ if test "x$XVFB" = xyes; then +@@ -1735,6 +1736,19 @@ if test "x$XVFB" = xyes; then AC_SUBST([XVFB_SYS_LIBS]) fi @@ -21,6 +21,11 @@ index 0909cc5b4..c01873200 100644 +PKG_CHECK_MODULES(GBM, "$LIBGBM", [GBM=yes], [GBM=no]) +if test "x$GBM" = xyes; then + AC_DEFINE(HAVE_GBM, 1, [Have GBM support]) ++fi ++ ++PKG_CHECK_MODULES(LIBXCVT, "libxcvt", [XCVT=yes], [XCVT=no]) ++if test "x$XCVT" = xyes; then ++ AC_DEFINE(HAVE_LIBXCVT, 1, [Have libxcvt support]) +fi dnl Xnest DDX @@ -126,6 +131,16 @@ diff --git a/include/dix-config.h.in b/include/dix-config.h.in index f8fc67067..d53c4e72f 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in +@@ -63,6 +63,9 @@ + /* Has libunwind support */ + #undef HAVE_LIBUNWIND + ++/* Have libxcvt support */ ++#undef HAVE_LIBXCVT ++ + /* Define to 1 if you have the `cbrt' function. */ + #undef HAVE_CBRT + @@ -83,6 +83,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H diff --git a/unix/xserver21.patch b/unix/xserver21.patch index 7f1e8d4f6..c4258adfe 100644 --- a/unix/xserver21.patch +++ b/unix/xserver21.patch @@ -10,7 +10,7 @@ index fad7b5769..2c167de3d 100644 AC_PROG_LN_S LT_PREREQ([2.2]) LT_INIT([disable-static win32-dll]) -@@ -1720,6 +1721,14 @@ if test "x$XVFB" = xyes; then +@@ -1720,6 +1721,19 @@ if test "x$XVFB" = xyes; then AC_SUBST([XVFB_SYS_LIBS]) fi @@ -21,6 +21,11 @@ index fad7b5769..2c167de3d 100644 +PKG_CHECK_MODULES(GBM, "$LIBGBM", [GBM=yes], [GBM=no]) +if test "x$GBM" = xyes; then + AC_DEFINE(HAVE_GBM, 1, [Have GBM support]) ++fi ++ ++PKG_CHECK_MODULES(LIBXCVT, "$LIBXCVT", [XCVT=yes], [XCVT=no]) ++if test "x$XCVT" = xyes; then ++ AC_DEFINE(HAVE_LIBXCVT, 1, [Have libxcvt support]) +fi dnl Xnest DDX @@ -55,6 +60,16 @@ diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 382d70609..04a4fd263 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in +@@ -63,6 +63,9 @@ + /* Has libunwind support */ + #undef HAVE_LIBUNWIND + ++/* Have libxcvt support */ ++#undef HAVE_LIBXCVT ++ + /* Define to 1 if you have the `cbrt' function. */ + #undef HAVE_CBRT + @@ -77,6 +77,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H