return 0;
}
+static BOOL handle_window_events(freerdp* instance)
+{
+ rdpSettings* settings;
+
+ if (!instance || !instance->settings)
+ return FALSE;
+
+ settings = instance->settings;
+
+ if (!settings->AsyncInput)
+ {
+ if (!xf_process_x_events(instance))
+ {
+ WLog_INFO(TAG, "Closed from X11");
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
/** Main loop for the rdp connection.
* It will be run from the thread's entry point (thread_func()).
* It initiates the connection, and will continue to run until the session ends,
{
if (!freerdp_check_event_handles(context))
{
- if (client_auto_reconnect(instance))
+ if (client_auto_reconnect_ex(instance, handle_window_events))
continue;
else
{
}
}
- if (!settings->AsyncInput)
- {
- if (!xf_process_x_events(instance))
- {
- WLog_INFO(TAG, "Closed from X11");
- break;
- }
- }
+ if (!handle_window_events(instance))
+ break;
if ((status != WAIT_TIMEOUT) && (waitStatus == WAIT_OBJECT_0))
{
static BOOL xf_disp_settings_changed(xfDispContext* xfDisp)
{
rdpSettings* settings;
+
+ if (!xfDisp || !xfDisp->xfc || !xfDisp->xfc->context.settings)
+ return FALSE;
+
settings = xfDisp->xfc->context.settings;
if (xfDisp->lastSentWidth != xfDisp->targetWidth)
static BOOL xf_update_last_sent(xfDispContext* xfDisp)
{
- rdpSettings* settings = xfDisp->xfc->context.settings;
+ rdpSettings* settings;
+
+ if (!xfDisp || !xfDisp->xfc)
+ return FALSE;
+
+ settings = xfDisp->xfc->context.settings;
+
+ if (!settings)
+ return FALSE;
+
xfDisp->lastSentWidth = xfDisp->targetWidth;
xfDisp->lastSentHeight = xfDisp->targetHeight;
xfDisp->lastSentDesktopOrientation = settings->DesktopOrientation;
static BOOL xf_disp_sendResize(xfDispContext* xfDisp)
{
DISPLAY_CONTROL_MONITOR_LAYOUT layout;
- xfContext* xfc = xfDisp->xfc;
- rdpSettings* settings = xfc->context.settings;
+ xfContext* xfc;
+ rdpSettings* settings;
+
+ if (!xfDisp || !xfDisp->xfc)
+ return FALSE;
+
+ xfc = xfDisp->xfc;
+ settings = xfc->context.settings;
+
+ if (!settings)
+ return FALSE;
if (!xfDisp->activated)
return TRUE;
layout.PhysicalWidth = xfDisp->targetWidth;
layout.PhysicalHeight = xfDisp->targetHeight;
- if (xfc->disp->SendMonitorLayout(xfc->disp, 1, &layout) != CHANNEL_RC_OK)
+ if (IFCALLRESULT(CHANNEL_RC_OK, xfc->disp->SendMonitorLayout, xfc->disp, 1,
+ &layout) != CHANNEL_RC_OK)
return FALSE;
}
layouts[i].DeviceScaleFactor = settings->DeviceScaleFactor;
}
- ret = disp->SendMonitorLayout(disp, nmonitors, layouts);
+ ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, nmonitors, layouts);
free(layouts);
return ret;
}
BOOL xf_disp_handle_xevent(xfContext* xfc, XEvent* event)
{
- xfDispContext* xfDisp = xfc->xfDisp;
- rdpSettings* settings = xfc->context.settings;
+ xfDispContext* xfDisp;
+ rdpSettings* settings;
UINT32 maxWidth, maxHeight;
+ if (!xfc || !event)
+ return FALSE;
+
+ xfDisp = xfc->xfDisp;
+
+ if (!xfDisp)
+ return FALSE;
+
+ settings = xfc->context.settings;
+
+ if (!settings)
+ return FALSE;
+
if (!xfDisp->haveXRandr)
return TRUE;
BOOL xf_disp_handle_configureNotify(xfContext* xfc, int width, int height)
{
- xfDispContext* xfDisp = xfc->xfDisp;
+ xfDispContext* xfDisp;
+
+ if (!xfc || !xfc->disp)
+ return FALSE;
+
+ xfDisp = xfc->xfDisp;
xfDisp->targetWidth = width;
xfDisp->targetHeight = height;
return xf_disp_sendResize(xfDisp);
BOOL client_auto_reconnect(freerdp* instance)
{
+ return client_auto_reconnect_ex(instance, NULL);
+}
+
+BOOL client_auto_reconnect_ex(freerdp* instance, BOOL(*window_events)(freerdp* instance))
+{
UINT32 maxRetries;
UINT32 numRetries = 0;
rdpSettings* settings;
/* Perform an auto-reconnect. */
while (TRUE)
{
+ UINT32 x;
+
/* Quit retrying if max retries has been exceeded */
if ((maxRetries > 0) && (numRetries++ >= maxRetries))
{
if (freerdp_reconnect(instance))
return TRUE;
- Sleep(5000);
+ for (x = 0; x < 50; x++)
+ {
+ if (!IFCALLRESULT(TRUE, window_events, instance))
+ return FALSE;
+
+ Sleep(100);
+ }
}
WLog_ERR(TAG, "Maximum reconnect retries exceeded");