From 11ee81be6040bcf7fe9bf1ff23a5049939d11ec7 Mon Sep 17 00:00:00 2001 From: David Fort Date: Fri, 8 Dec 2017 10:45:50 +0100 Subject: [PATCH] Fix XRandr for old systems and MacOSX We need a recent enough version of XRandr to correctly detect monitor. Also this patch adds some typo or style fixes. --- client/X11/CMakeLists.txt | 2 +- client/X11/xf_monitor.c | 15 +++++++++++---- libfreerdp/core/capabilities.c | 5 ++--- libfreerdp/core/rdp.c | 2 +- libfreerdp/core/transport.c | 3 +-- libfreerdp/gdi/gfx.c | 3 +-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index fdd5e9d5e..44ace842d 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -199,7 +199,7 @@ if(WITH_XRENDER) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XRENDER_LIBRARIES}) endif() -if(NOT APPLE AND WITH_XRANDR) +if(WITH_XRANDR) add_definitions(-DWITH_XRANDR) include_directories(${XRANDR_INCLUDE_DIRS}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XRANDR_LIBRARIES}) diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 47715a4bf..641a873ed 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -41,6 +41,11 @@ #ifdef WITH_XRANDR #include #include + +#if (RANDR_MAJOR * 100 + RANDR_MINOR) > 105 +# define USABLE_XRANDR +#endif + #endif #include "xf_monitor.h" @@ -60,8 +65,9 @@ int xf_list_monitors(xfContext* xfc) return -1; } -#ifdef WITH_XRANDR - if (XRRQueryExtension(xfc->display, &major, &minor)) +#if defined(USABLE_XRANDR) + if (XRRQueryExtension(xfc->display, &major, &minor) && (XRRQueryVersion(xfc->display, &major, &minor) == True) && + (major * 100 + minor >= 105)) { XRRMonitorInfo *monitors = XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1, &nmonitors); @@ -148,8 +154,9 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) &_dummy_i, &_dummy_i, (void*) &_dummy_i)) mouse_x = mouse_y = 0; -#ifdef WITH_XRANDR - if (XRRQueryExtension(xfc->display, &major, &minor)) +#if defined(USABLE_XRANDR) + if (XRRQueryExtension(xfc->display, &major, &minor) && (XRRQueryVersion(xfc->display, &major, &minor) == True) && + (major * 100 + minor >= 105)) { XRRMonitorInfo *monitors = XRRGetMonitors(xfc->display, DefaultRootWindow(xfc->display), 1, &vscreen->nmonitors); diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index bf1e1d777..f97918a50 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -3870,12 +3870,11 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) /* capabilitySets */ if (!rdp_read_capability_sets(s, rdp->settings, numberCapabilities)) { - WLog_ERR(TAG, "rdp_read_capability_sets failed"); + WLog_ERR(TAG, "rdp_read_capability_sets failed"); return FALSE; } - rdp->update->secondary->glyph_v2 = (rdp->settings->GlyphSupportLevel > - GLYPH_SUPPORT_FULL) ? TRUE : FALSE; + rdp->update->secondary->glyph_v2 = (rdp->settings->GlyphSupportLevel > GLYPH_SUPPORT_FULL); return TRUE; } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 8c7ce979c..0b6cdf4e3 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -604,7 +604,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) Stream_SetPosition(s, length); Stream_SealLength(s); - WLog_DBG(TAG, "%s: sending data (type=0x%x size=%d channelId)", __FUNCTION__, type, Stream_Length(s), channel_id); + WLog_DBG(TAG, "%s: sending data (type=0x%x size=%d channelId=%d)", __FUNCTION__, type, Stream_Length(s), channel_id); if (transport_write(rdp->transport, s) < 0) return FALSE; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 4fdceb988..400cd9568 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -1032,8 +1032,7 @@ int transport_check_fds(rdpTransport* transport) * 0: success * 1: redirection */ - recv_status = transport->ReceiveCallback(transport, received, - transport->ReceiveExtra); + recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra); Stream_Release(received); /* session redirection or activation */ diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index 4e8b07104..b54c0ce64 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -61,8 +61,7 @@ static UINT gdi_ResetGraphics(RdpgfxClientContext* context, DesktopWidth = resetGraphics->width; DesktopHeight = resetGraphics->height; - if ((DesktopWidth != settings->DesktopWidth) - || (DesktopHeight != settings->DesktopHeight)) + if ((DesktopWidth != settings->DesktopWidth) || (DesktopHeight != settings->DesktopHeight)) { settings->DesktopWidth = DesktopWidth; settings->DesktopHeight = DesktopHeight;