Skip to content

Commit

Permalink
Dynamic resolution update #2
Browse files Browse the repository at this point in the history
  • Loading branch information
giox069 committed Sep 25, 2017
1 parent bd86291 commit 3e644d7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
7 changes: 0 additions & 7 deletions remmina-plugins/rdp/rdp_channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ void remmina_rdp_OnChannelConnectedEventHandler(rdpContext* context, ChannelConn
remmina_rdp_event_send_delayed_monitor_layout(rfi->protocol_widget);
}
}
else if (g_strcmp0(e->name, "drdynvc") == 0)
{
}
else
{
g_printf("Unknown channel %s connected\n", e->name);
}
}

void remmina_rdp_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e)
Expand Down
15 changes: 13 additions & 2 deletions remmina-plugins/rdp/rdp_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,14 @@ static void remmina_rdp_event_queue_monitor_layout(RemminaProtocolWidget* gp)
TRACE_CALL("remmina_rdp_event_queue_monitor_layout\n");
GtkAllocation a;
gint desktopOrientation, desktopScaleFactor, deviceScaleFactor;
RemminaFile* remminafile;

rfContext* rfi = GET_PLUGIN_DATA(gp);

rfi->delayed_monitor_layout_handler = 0;

// gboolean scale;
gint gpwidth, gpheight;
gint gpwidth, gpheight, prevwidth, prevheight;

printf("GIO: remmina_rdp_event_queue_monitor_layout\n");
if (rfi->dispcontext && rfi->dispcontext->SendMonitorLayout) {
Expand All @@ -365,10 +366,14 @@ static void remmina_rdp_event_queue_monitor_layout(RemminaProtocolWidget* gp)
gpwidth = a.width;
gpheight = a.height;
printf("GIO: Final resize to %d %d\n", gpwidth, gpheight);
prevwidth = remmina_plugin_service->protocol_plugin_get_width(gp);
prevheight = remmina_plugin_service->protocol_plugin_get_height(gp);
printf("GIO: prev size to %d %d\n", prevwidth, prevheight);

// Try to send a resize message to gpwidth x gpheight
printf("GIO: dispcontext = %p\n", rfi->dispcontext);
if (gpwidth >= 200 && gpwidth < 8192 &&
if ((gpwidth != prevwidth || gpheight != prevheight) &&
gpwidth >= 200 && gpwidth < 8192 &&
gpheight >= 200 && gpheight < 8192) {
DISPLAY_CONTROL_MONITOR_LAYOUT* dcml;
dcml = g_malloc0(sizeof(DISPLAY_CONTROL_MONITOR_LAYOUT));
Expand All @@ -385,6 +390,10 @@ static void remmina_rdp_event_queue_monitor_layout(RemminaProtocolWidget* gp)
printf("GIO: SENDING MONITOR LAYOUT %d %d\n", dcml->Width, dcml->Height);
rfi->dispcontext->SendMonitorLayout(rfi->dispcontext, 1, dcml);
g_free(dcml);
/* Save new resolution in profile */
remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);
remmina_plugin_service->file_set_int(remminafile, "resolution_width", gpwidth);
remmina_plugin_service->file_set_int(remminafile, "resolution_height", gpheight);
} else
printf("g_malloc0 failed\n");
}
Expand All @@ -396,6 +405,8 @@ static gboolean remmina_rdp_event_delayed_monitor_layout(RemminaProtocolWidget*
{
TRACE_CALL("remmina_rdp_event_delayed_monitor_layout");
rfContext* rfi = GET_PLUGIN_DATA(gp);
if (!rfi || !rfi->connected || rfi->is_reconnecting)
return FALSE;
if (rfi->scale == REMMINA_PROTOCOL_WIDGET_SCALE_MODE_AUTORES)
remmina_rdp_event_queue_monitor_layout(gp);

Expand Down
2 changes: 2 additions & 0 deletions remmina-plugins/rdp/rdp_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget* gp)
remmina_plugin_service->protocol_plugin_set_width(gp, rfi->settings->DesktopWidth);
remmina_plugin_service->protocol_plugin_set_height(gp, rfi->settings->DesktopHeight);

printf("Initial DesktopWidth=%d DesktopHeight=%d\n", rfi->settings->DesktopWidth, rfi->settings->DesktopHeight);

if (remmina_plugin_service->file_get_string(remminafile, "username"))
rfi->settings->Username = strdup(remmina_plugin_service->file_get_string(remminafile, "username"));

Expand Down
7 changes: 7 additions & 0 deletions remmina/src/remmina_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ void remmina_file_save(RemminaFile *remminafile)
}
}

/* Merge resolution_width and resolution_height into resolution */
s = g_strdup_printf("%dx%d", remmina_file_get_int(remminafile, "resolution_width", 800), remmina_file_get_int(remminafile, "resolution_height", 600));
g_key_file_set_string(gkeyfile, "remmina", "resolution", s);
g_free(s);
g_key_file_remove_key(gkeyfile, "remmina", "resolution_width", NULL);
g_key_file_remove_key(gkeyfile, "remmina", "resolution_height", NULL);

/* Store gkeyfile to disk (password are already sent to keyring) */
content = g_key_file_to_data(gkeyfile, &length, NULL);
g_file_set_contents(remminafile->filename, content, length, NULL);
Expand Down

0 comments on commit 3e644d7

Please sign in to comment.