Commit 262ec3a5 authored by Giovanni Panozzo's avatar Giovanni Panozzo

rcw fixes for fullscreen mode

parent fdcd234e
......@@ -59,6 +59,11 @@
#include "remmina_log.h"
#include "remmina/remmina_trace_calls.h"
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#define DEBUG_KB_GRABBING 0
#include "remmina_exec.h"
......@@ -878,52 +883,88 @@ static void remmina_connection_holder_toolbar_autofit(GtkWidget* widget, Remmina
}
static void remmina_connection_holder_check_resize(RemminaConnectionHolder* cnnhld)
void remmina_connection_object_get_monitor_geometry(RemminaConnectionObject* cnnobj, GdkRectangle *sz)
{
TRACE_CALL(__func__);
DECLARE_CNNOBJ
gboolean scroll_required = FALSE;
/* Fill sz with the monitor (or workarea) size and position
* of the monitor (or workarea) where cnnhld->cnnwin is located */
GdkRectangle monitor_geometry;
sz->x = sz->y = sz->width = sz->height = 0;
if (!cnnobj->cnnhld)
return;
if (!cnnobj->cnnhld->cnnwin)
return;
if (!gtk_widget_is_visible(GTK_WIDGET(cnnobj->cnnhld->cnnwin)))
return;
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay* display;
GdkMonitor* monitor;
display = gtk_widget_get_display(GTK_WIDGET(cnnobj->cnnhld->cnnwin));
monitor = gdk_display_get_monitor_at_window(display, gtk_widget_get_window(GTK_WIDGET(cnnobj->cnnhld->cnnwin)));
#else
GdkScreen* screen;
gint monitor;
screen = gtk_window_get_screen(GTK_WINDOW(cnnobj->cnnhld->cnnwin));
monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(GTK_WIDGET(cnnobj->cnnhld->cnnwin)));
#endif
GdkRectangle screen_size;
gint screen_width, screen_height;
gint server_width, server_height;
gint bordersz;
remmina_connection_holder_get_desktop_size(cnnhld, &server_width, &server_height);
#if GTK_CHECK_VERSION(3, 22, 0)
display = gtk_widget_get_display(GTK_WIDGET(cnnhld->cnnwin));
monitor = gdk_display_get_monitor_at_window(display, gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)));
#else
screen = gtk_window_get_screen(GTK_WINDOW(cnnhld->cnnwin));
monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)));
#endif
#if GTK_CHECK_VERSION(3, 22, 0)
gdk_monitor_get_workarea(monitor, &screen_size);
gdk_monitor_get_workarea(monitor, &monitor_geometry);
/* Under Wayland, GTK 3.22, all values returned by gdk_monitor_get_geometry()
* and gdk_monitor_get_workarea() seem to have been divided by the
* gdk scale factor, so we need to adjust the returned rect
* undoing the division */
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY(display)) {
int monitor_scale_factor = gdk_monitor_get_scale_factor(monitor);
monitor_geometry.width *= monitor_scale_factor;
monitor_geometry.height *= monitor_scale_factor;
}
#endif
#elif gdk_screen_get_monitor_workarea
gdk_screen_get_monitor_workarea(screen, monitor, &screen_size);
gdk_screen_get_monitor_workarea(screen, monitor, &monitor_geometry);
#else
gdk_screen_get_monitor_geometry(screen, monitor, &screen_size);
gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
#endif
screen_width = screen_size.width;
screen_height = screen_size.height;
*sz = monitor_geometry;
}
static void remmina_connection_holder_check_resize(RemminaConnectionHolder* cnnhld)
{
TRACE_CALL(__func__);
DECLARE_CNNOBJ
gboolean scroll_required = FALSE;
GdkRectangle monitor_geometry;
gint rd_width, rd_height;
gint bordersz;
gint scalemode;
scalemode = remmina_protocol_widget_get_current_scale_mode(REMMINA_PROTOCOL_WIDGET(cnnobj->proto));
/* Get remote destkop size */
remmina_connection_holder_get_desktop_size(cnnhld, &rd_width, &rd_height);
/* Get our monitor size */
remmina_connection_object_get_monitor_geometry(cnnobj, &monitor_geometry);
if (!remmina_protocol_widget_get_expand(REMMINA_PROTOCOL_WIDGET(cnnobj->proto))
&& (server_width <= 0 || server_height <= 0 || screen_width < server_width
|| screen_height < server_height)) {
if (!remmina_protocol_widget_get_expand(REMMINA_PROTOCOL_WIDGET(cnnobj->proto)) &&
(monitor_geometry.width < rd_width || monitor_geometry.height < rd_height) &&
scalemode == REMMINA_PROTOCOL_WIDGET_SCALE_MODE_NONE) {
scroll_required = TRUE;
}
switch (cnnhld->cnnwin->priv->view_mode) {
case SCROLLED_FULLSCREEN_MODE:
gtk_window_resize(GTK_WINDOW(cnnhld->cnnwin), screen_width, screen_height);
gtk_window_resize(GTK_WINDOW(cnnhld->cnnwin), monitor_geometry.width, monitor_geometry.height);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cnnobj->scrolled_container),
(scroll_required ? GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER),
(scroll_required ? GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER));
......@@ -931,7 +972,7 @@ static void remmina_connection_holder_check_resize(RemminaConnectionHolder* cnnh
case VIEWPORT_FULLSCREEN_MODE:
bordersz = scroll_required ? SCROLL_BORDER_SIZE : 0;
gtk_window_resize(GTK_WINDOW(cnnhld->cnnwin), screen_width, screen_height);
gtk_window_resize(GTK_WINDOW(cnnhld->cnnwin), monitor_geometry.width, monitor_geometry.height);
if (REMMINA_IS_SCROLLED_VIEWPORT(cnnobj->scrolled_container)) {
/* Put a border around Notebook content (RemminaScrolledViewpord), so we can
* move the mouse over the border to scroll */
......@@ -943,8 +984,8 @@ static void remmina_connection_holder_check_resize(RemminaConnectionHolder* cnnh
case SCROLLED_WINDOW_MODE:
if (remmina_file_get_int(cnnobj->remmina_file, "viewmode", AUTO_MODE) == AUTO_MODE) {
gtk_window_set_default_size(GTK_WINDOW(cnnhld->cnnwin),
MIN(server_width, screen_width), MIN(server_height, screen_height));
if (server_width >= screen_width || server_height >= screen_height) {
MIN(rd_width, monitor_geometry.width), MIN(rd_height, monitor_geometry.height));
if (rd_width >= monitor_geometry.width || rd_height >= monitor_geometry.height) {
gtk_window_maximize(GTK_WINDOW(cnnhld->cnnwin));
remmina_file_set_int(cnnobj->remmina_file, "window_maximize", TRUE);
}else {
......
......@@ -83,6 +83,7 @@ GtkWidget* remmina_connection_window_open_from_file_full(RemminaFile* remminafil
void remmina_connection_object_destroy_message_panel(RemminaConnectionObject *cnnobj, RemminaMessagePanel *mp);
void remmina_connection_object_show_message_panel(RemminaConnectionObject *cnnobj, RemminaMessagePanel *mp);
void remmina_connection_object_get_monitor_geometry(RemminaConnectionObject* cnnobj, GdkRectangle *sz);
#define MESSAGE_PANEL_SPINNER 0x00000001
#define MESSAGE_PANEL_OKBUTTON 0x00000002
......
......@@ -52,6 +52,11 @@
#include "remmina_log.h"
#include "remmina/remmina_trace_calls.h"
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
struct _RemminaProtocolWidgetPriv {
RemminaFile* remmina_file;
......@@ -1600,6 +1605,10 @@ void remmina_protocol_widget_update_remote_resolution(RemminaProtocolWidget* gp)
RemminaProtocolWidgetResolutionMode res_mode;
RemminaScaleMode scalemode;
remmina_connection_object_get_monitor_geometry(gp->cnnobj, &rect);
/* Integrity check: check that we have a cnnwin visible and get t */
res_mode = remmina_file_get_int(gp->priv->remmina_file, "resolution_mode", RES_INVALID);
scalemode = remmina_file_get_int(gp->priv->remmina_file, "scale", REMMINA_PROTOCOL_WIDGET_SCALE_MODE_NONE);
wfile = remmina_file_get_int(gp->priv->remmina_file, "resolution_width", -1);
......@@ -1630,24 +1639,14 @@ void remmina_protocol_widget_update_remote_resolution(RemminaProtocolWidget* gp)
* right of the desktop */
if ( (w & 1) != 0)
w -= 1;
/* Due to approximations while GTK calculates scaling, (w x h) may exceed our monitor geometry
* Adjust to fit. */
if (w > rect.width)
w = rect.width;
if (h > rect.height)
h = rect.height;
} else if (res_mode == RES_USE_CLIENT) {
display = gdk_display_get_default();
/* gdk_display_get_device_manager deprecated since 3.20, Use gdk_display_get_default_seat */
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(display);
device = gdk_seat_get_pointer(seat);
#else
device_manager = gdk_display_get_device_manager(display);
device = gdk_device_manager_get_client_pointer(device_manager);
#endif
gdk_device_get_position(device, &screen, &x, &y);
#if GTK_CHECK_VERSION(3, 22, 0)
monitor = gdk_display_get_monitor_at_point(display, x, y);
gdk_monitor_get_geometry(monitor, &rect);
#else
monitor = gdk_screen_get_monitor_at_point(screen, x, y);
gdk_screen_get_monitor_geometry(screen, monitor, &rect);
#endif
w = rect.width;
h = rect.height;
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment