Skip to content

Commit 9141ce1

Browse files
committed
setDesktopSize support: disable support if older libvncserver version
Signed-off-by: Floris Bos <[email protected]>
1 parent 4b64054 commit 9141ce1

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

configure.ac

+6
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ elif test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then
285285
case `(uname -sr) 2>/dev/null` in
286286
"SunOS 5"*) CPPFLAGS="$CPPFLAGS -I/usr/X11/include" ;;
287287
esac
288+
289+
# support for setdesktopsize needs xrandr and libvncserver with setDesktopSizeHook
290+
AC_CHECK_MEMBER([struct _rfbScreenInfo.setDesktopSizeHook],
291+
[AC_DEFINE(HAVE_SETDESKTOPSIZE, 1, [libvncserver supports setDesktopSizeHook])],
292+
[AC_MSG_WARN([Support for option -setdesktopsize disabled. Needs libvncserver 0.9.13])],
293+
[[#include "rfb/rfb.h"]])
288294
fi
289295

290296
X_LIBS="$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS"

src/connections.c

+2
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,11 @@ void client_gone(rfbClientPtr client) {
838838
}
839839
}
840840

841+
#if HAVE_SETDESKTOPSIZE
841842
if (enable_setdesktopsize && xrandr && client_count == 0) {
842843
xrandr_reset_scaling();
843844
}
845+
#endif
844846
if (no_autorepeat && client_count == 0) {
845847
autorepeat(1, 0);
846848
}

src/help.c

+2
Original file line numberDiff line numberDiff line change
@@ -3058,12 +3058,14 @@ void print_help(int mode) {
30583058
" prefix \"string\" with \"nc:\", e.g. \"nc:+90\",\n"
30593059
" \"nc:xy\", etc.\n"
30603060
"\n"
3061+
#if HAVE_SETDESKTOPSIZE
30613062
"-setdesktopsize Allow client to change framebuffer resolution to fit\n"
30623063
" size of client window. x11vnc will use xrandr commands\n"
30633064
" to change the X framebuffer size. The mode of the physical\n"
30643065
" screen will not be changed, but scaling will be used to\n"
30653066
" display the new framebuffer size on the physical screen.\n"
30663067
"\n"
3068+
#endif
30673069
"-padgeom WxH Whenever a new vncviewer connects, the framebuffer is\n"
30683070
" replaced with a fake, solid black one of geometry WxH.\n"
30693071
" Shortly afterwards the framebuffer is replaced with the\n"

src/screen.c

+4
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ void free_old_fb(void) {
820820
}
821821
}
822822

823+
#if HAVE_SETDESKTOPSIZE
823824
static int set_desktop_size_hook(int width, int height, int numScreens, rfbExtDesktopScreen* extDesktopScreens, rfbClientPtr cl)
824825
{
825826
int i;
@@ -836,6 +837,7 @@ static int set_desktop_size_hook(int width, int height, int numScreens, rfbExtDe
836837

837838
return xrandr_set_scale_from(width, height) ? rfbExtDesktopSize_Success : rfbExtDesktopSize_InvalidScreenLayout;
838839
}
840+
#endif
839841

840842
static char _lcs_tmp[128];
841843
static int _bytes0_size = 128, _bytes0[128];
@@ -3669,9 +3671,11 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
36693671
screen->ptrAddEvent = pointer_event;
36703672
screen->setXCutText = xcut_receive;
36713673
screen->setTranslateFunction = set_xlate_wrapper;
3674+
#if HAVE_SETDESKTOPSIZE
36723675
if (enable_setdesktopsize) {
36733676
screen->setDesktopSizeHook = set_desktop_size_hook;
36743677
}
3678+
#endif
36753679

36763680
screen->kbdReleaseAllKeys = kbd_release_all_keys;
36773681
screen->setSingleWindow = set_single_window;

src/x11vnc.c

+2
Original file line numberDiff line numberDiff line change
@@ -3888,10 +3888,12 @@ int main(int argc, char* argv[]) {
38883888
grab_buster = 0;
38893889
continue;
38903890
}
3891+
#if HAVE_SETDESKTOPSIZE
38913892
if (!strcmp(arg, "-setdesktopsize")) {
38923893
enable_setdesktopsize = 1;
38933894
continue;
38943895
}
3896+
#endif
38953897
if (!strcmp(arg, "-snapfb")) {
38963898
use_snapfb = 1;
38973899
continue;

src/xrandr.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ int known_xrandr_mode(char *s) {
304304
}
305305
}
306306

307+
#if HAVE_SETDESKTOPSIZE
307308
/* Set framebuffer size to w x h
308309
* Does not alter physical resolution but scales desired framebuffer to physical display resolution */
309310
rfbBool xrandr_set_scale_from(int w, int h)
310311
{
311-
#if HAVE_LIBXRANDR
312312
XTransform transform;
313313
XRRScreenResources *screens;
314314
XRRCrtcInfo *crtcInfo;
@@ -446,16 +446,12 @@ rfbBool xrandr_set_scale_from(int w, int h)
446446
the old size.) */
447447

448448
return TRUE;
449-
#else
450-
rfbLog("Cannot resize desktop. XRANDR support not compiled into x11vnc\n");
451-
return FALSE;
452-
#endif
453449
}
454450

455451
/* Restore scaling to original size */
456452
void xrandr_reset_scaling()
457453
{
458454
xrandr_set_scale_from(-1, -1);
459455
}
460-
456+
#endif
461457

0 commit comments

Comments
 (0)