Skip to content

Commit

Permalink
Generate better (fake) modelines
Browse files Browse the repository at this point in the history
This is what Xwayland does, so let's try to do the same to avoid any
incompatibilites with applications.
  • Loading branch information
CendioOssman committed Jul 23, 2024
1 parent 422444a commit 876cbf0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
8 changes: 6 additions & 2 deletions unix/xserver/hw/vnc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
29 changes: 28 additions & 1 deletion unix/xserver/hw/vnc/xvnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ from the X Consortium.
#include "xorg-version.h"

#include <stdio.h>
#ifdef HAVE_LIBXCVT
#include <libxcvt/libxcvt.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xos.h>
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion unix/xserver120.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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 <fcntl.h> header file. */
#undef HAVE_FCNTL_H
Expand Down
17 changes: 16 additions & 1 deletion unix/xserver21.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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 <fcntl.h> header file. */
#undef HAVE_FCNTL_H
Expand Down

0 comments on commit 876cbf0

Please sign in to comment.