diff --git a/configure.ac b/configure.ac index b17beff0..54fc74c2 100644 --- a/configure.ac +++ b/configure.ac @@ -285,6 +285,12 @@ elif test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then case `(uname -sr) 2>/dev/null` in "SunOS 5"*) CPPFLAGS="$CPPFLAGS -I/usr/X11/include" ;; esac + + # support for setdesktopsize needs xrandr and libvncserver with setDesktopSizeHook + AC_CHECK_MEMBER([struct _rfbScreenInfo.setDesktopSizeHook], + [AC_DEFINE(HAVE_SETDESKTOPSIZE, 1, [libvncserver supports setDesktopSizeHook])], + [AC_MSG_WARN([Support for option -setdesktopsize disabled. Needs libvncserver 0.9.13])], + [[#include "rfb/rfb.h"]]) fi X_LIBS="$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS" diff --git a/src/connections.c b/src/connections.c index 1cc64902..0086dca4 100644 --- a/src/connections.c +++ b/src/connections.c @@ -838,9 +838,11 @@ void client_gone(rfbClientPtr client) { } } +#if HAVE_SETDESKTOPSIZE if (enable_setdesktopsize && xrandr && client_count == 0) { xrandr_reset_scaling(); } +#endif if (no_autorepeat && client_count == 0) { autorepeat(1, 0); } diff --git a/src/help.c b/src/help.c index 7e9d9212..6328c47a 100644 --- a/src/help.c +++ b/src/help.c @@ -3058,12 +3058,14 @@ void print_help(int mode) { " prefix \"string\" with \"nc:\", e.g. \"nc:+90\",\n" " \"nc:xy\", etc.\n" "\n" +#if HAVE_SETDESKTOPSIZE "-setdesktopsize Allow client to change framebuffer resolution to fit\n" " size of client window. x11vnc will use xrandr commands\n" " to change the X framebuffer size. The mode of the physical\n" " screen will not be changed, but scaling will be used to\n" " display the new framebuffer size on the physical screen.\n" "\n" +#endif "-padgeom WxH Whenever a new vncviewer connects, the framebuffer is\n" " replaced with a fake, solid black one of geometry WxH.\n" " Shortly afterwards the framebuffer is replaced with the\n" diff --git a/src/screen.c b/src/screen.c index f124625e..ee7363d3 100644 --- a/src/screen.c +++ b/src/screen.c @@ -820,6 +820,7 @@ void free_old_fb(void) { } } +#if HAVE_SETDESKTOPSIZE static int set_desktop_size_hook(int width, int height, int numScreens, rfbExtDesktopScreen* extDesktopScreens, rfbClientPtr cl) { int i; @@ -836,6 +837,7 @@ static int set_desktop_size_hook(int width, int height, int numScreens, rfbExtDe return xrandr_set_scale_from(width, height) ? rfbExtDesktopSize_Success : rfbExtDesktopSize_InvalidScreenLayout; } +#endif static char _lcs_tmp[128]; static int _bytes0_size = 128, _bytes0[128]; @@ -3669,9 +3671,11 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { screen->ptrAddEvent = pointer_event; screen->setXCutText = xcut_receive; screen->setTranslateFunction = set_xlate_wrapper; +#if HAVE_SETDESKTOPSIZE if (enable_setdesktopsize) { screen->setDesktopSizeHook = set_desktop_size_hook; } +#endif screen->kbdReleaseAllKeys = kbd_release_all_keys; screen->setSingleWindow = set_single_window; diff --git a/src/x11vnc.c b/src/x11vnc.c index 308eabf7..4c3397f8 100644 --- a/src/x11vnc.c +++ b/src/x11vnc.c @@ -3888,10 +3888,12 @@ int main(int argc, char* argv[]) { grab_buster = 0; continue; } +#if HAVE_SETDESKTOPSIZE if (!strcmp(arg, "-setdesktopsize")) { enable_setdesktopsize = 1; continue; } +#endif if (!strcmp(arg, "-snapfb")) { use_snapfb = 1; continue; diff --git a/src/xrandr.c b/src/xrandr.c index 36a8c559..9574e465 100644 --- a/src/xrandr.c +++ b/src/xrandr.c @@ -304,11 +304,11 @@ int known_xrandr_mode(char *s) { } } +#if HAVE_SETDESKTOPSIZE /* Set framebuffer size to w x h * Does not alter physical resolution but scales desired framebuffer to physical display resolution */ rfbBool xrandr_set_scale_from(int w, int h) { -#if HAVE_LIBXRANDR XTransform transform; XRRScreenResources *screens; XRRCrtcInfo *crtcInfo; @@ -446,10 +446,6 @@ rfbBool xrandr_set_scale_from(int w, int h) the old size.) */ return TRUE; -#else - rfbLog("Cannot resize desktop. XRANDR support not compiled into x11vnc\n"); - return FALSE; -#endif } /* Restore scaling to original size */ @@ -457,5 +453,5 @@ void xrandr_reset_scaling() { xrandr_set_scale_from(-1, -1); } - +#endif