Commit c5700a8e authored by Giovanni Panozzo's avatar Giovanni Panozzo

Merge branch 'fsfixes' into 'master'

Fullscreen fixes

See merge request Remmina/Remmina!1897
parents 975f82c3 e3c89ba7
......@@ -2737,11 +2737,8 @@ static void rcw_init(RemminaConnectionWindow *cnnwin)
priv->ss_height = 480;
priv->ss_maximized = FALSE;
gtk_container_set_border_width(GTK_CONTAINER(cnnwin), 0);
remmina_widget_pool_register(GTK_WIDGET(cnnwin));
g_signal_connect(G_OBJECT(cnnwin), "toolbar-place", G_CALLBACK(rcw_toolbar_place_signal), NULL);
}
static gboolean rcw_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data)
......@@ -2761,8 +2758,39 @@ static gboolean rcw_state_event(GtkWidget *widget, GdkEventWindowState *event, g
return FALSE; // moved here because a function should return a value. Should be correct
}
static gboolean rcw_map_event_fullscreen(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gint target_monitor;
TRACE_CALL(__func__);
if (!REMMINA_IS_CONNECTION_WINDOW(widget))
return FALSE;
target_monitor = GPOINTER_TO_INT(data);
#if GTK_CHECK_VERSION(3, 18, 0)
if (remmina_pref.fullscreen_on_auto) {
if (target_monitor == FULL_SCREEN_TARGET_MONITOR_UNDEFINED) {
gtk_window_fullscreen(GTK_WINDOW(widget));
} else {
gtk_window_fullscreen_on_monitor(GTK_WINDOW(widget), gtk_window_get_screen(GTK_WINDOW(widget)),
target_monitor);
}
} else {
remmina_log_print("Fullscreen managed by WM or by the user, as per settings");
gtk_window_fullscreen(GTK_WINDOW(widget));
}
#else
remmina_log_print("Cannot fullscreen on a specific monitor, feature available from GTK 3.18");
gtk_window_fullscreen(GTK_WINDOW(widget));
#endif
return FALSE;
}
static RemminaConnectionWindow *
rcw_new()
rcw_new(gboolean fullscreen, int full_screen_target_monitor)
{
TRACE_CALL(__func__);
RemminaConnectionWindow *cnnwin;
......@@ -2770,6 +2798,14 @@ rcw_new()
cnnwin = RCW(g_object_new(REMMINA_TYPE_CONNECTION_WINDOW, NULL));
cnnwin->priv->on_delete_confirm_mode = RCW_ONDELETE_CONFIRM_IF_2_OR_MORE;
if (fullscreen) {
/* Put the window in fullscreen after it is mapped to have it appear on the same monitor */
g_signal_connect(G_OBJECT(cnnwin), "map-event", G_CALLBACK(rcw_map_event_fullscreen), GINT_TO_POINTER(full_screen_target_monitor));
}
gtk_container_set_border_width(GTK_CONTAINER(cnnwin), 0);
g_signal_connect(G_OBJECT(cnnwin), "toolbar-place", G_CALLBACK(rcw_toolbar_place_signal), NULL);
g_signal_connect(G_OBJECT(cnnwin), "delete-event", G_CALLBACK(rcw_delete_event), NULL);
g_signal_connect(G_OBJECT(cnnwin), "destroy", G_CALLBACK(rcw_destroy), NULL);
......@@ -3132,7 +3168,7 @@ static RemminaConnectionWindow *rcw_create_scrolled(gint width, gint height, gbo
GtkNotebook *notebook;
GList *chain;
cnnwin = rcw_new();
cnnwin = rcw_new(FALSE, 0);
gtk_widget_realize(GTK_WIDGET(cnnwin));
gtk_window_set_default_size(GTK_WINDOW(cnnwin), width, height);
......@@ -3192,37 +3228,6 @@ static RemminaConnectionWindow *rcw_create_scrolled(gint width, gint height, gbo
return cnnwin;
}
static gboolean rcw_go_fullscreen(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gint target_monitor;
TRACE_CALL(__func__);
if (!REMMINA_IS_CONNECTION_WINDOW(widget))
return FALSE;
target_monitor = (gint)data;
#if GTK_CHECK_VERSION(3, 18, 0)
if (remmina_pref.fullscreen_on_auto) {
if (target_monitor == FULL_SCREEN_TARGET_MONITOR_UNDEFINED) {
gtk_window_fullscreen(GTK_WINDOW(widget));
} else {
gtk_window_fullscreen_on_monitor(GTK_WINDOW(widget), gtk_window_get_screen(GTK_WINDOW(widget)),
target_monitor);
}
} else {
remmina_log_print("Fullscreen managed by WM or by the user, as per settings");
gtk_window_fullscreen(GTK_WINDOW(widget));
}
#else
remmina_log_print("Cannot fullscreen on a specific monitor, feature available from GTK 3.18");
gtk_window_fullscreen(GTK_WINDOW(widget));
#endif
return FALSE;
}
static void rcw_create_overlay_ftb_overlay(RemminaConnectionWindow *cnnwin)
{
TRACE_CALL(__func__);
......@@ -3359,14 +3364,36 @@ RemminaConnectionWindow *rcw_create_fullscreen(GtkWindow *old, gint view_mode)
TRACE_CALL(__func__);
RemminaConnectionWindow *cnnwin;
GtkNotebook *notebook;
#if GTK_CHECK_VERSION(3, 22, 0)
gint n_monitors;
gint i;
GdkDisplay* old_display;
GdkMonitor* old_monitor;
GdkDisplay* old_display;
GdkWindow* old_window;
#endif
gint full_screen_target_monitor;
cnnwin = rcw_new();
full_screen_target_monitor = FULL_SCREEN_TARGET_MONITOR_UNDEFINED;
if (old) {
#if GTK_CHECK_VERSION(3, 22, 0)
old_window = gtk_widget_get_window(GTK_WIDGET(old));
old_display = gdk_window_get_display(old_window);
old_monitor = gdk_display_get_monitor_at_window(old_display, old_window);
n_monitors = gdk_display_get_n_monitors(old_display);
for (i = 0; i < n_monitors; ++i) {
if (gdk_display_get_monitor(old_display, i) == old_monitor) {
full_screen_target_monitor = i;
break;
}
}
#else
full_screen_target_monitor = gdk_screen_get_monitor_at_window(
gdk_screen_get_default(),
gtk_widget_get_window(GTK_WIDGET(old)));
#endif
}
cnnwin = rcw_new(TRUE, full_screen_target_monitor);
gtk_widget_set_name(GTK_WIDGET(cnnwin), "remmina-connection-window-fullscreen");
gtk_widget_realize(GTK_WIDGET(cnnwin));
......@@ -3396,25 +3423,6 @@ RemminaConnectionWindow *rcw_create_fullscreen(GtkWindow *old, gint view_mode)
gtk_widget_show(GTK_WIDGET(cnnwin));
full_screen_target_monitor = FULL_SCREEN_TARGET_MONITOR_UNDEFINED;
if (old) {
old_window = gtk_widget_get_window(GTK_WIDGET(old));
old_display = gdk_window_get_display(old_window);
old_monitor = gdk_display_get_monitor_at_window(old_display, old_window);
n_monitors = gdk_display_get_n_monitors(old_display);
for (i = 0; i < n_monitors; ++i) {
if (gdk_display_get_monitor(old_display, i) == old_monitor) {
full_screen_target_monitor = i;
break;
}
}
}
/* Put the window in fullscreen after it is mapped to have it appear on the same monitor */
g_signal_connect(G_OBJECT(cnnwin), "map-event", G_CALLBACK(rcw_go_fullscreen), (gpointer)full_screen_target_monitor);
return cnnwin;
}
......@@ -3518,6 +3526,7 @@ static gboolean rcw_hostkey_func(RemminaProtocolWidget *gp, guint keyval, gboole
switch (priv->view_mode) {
case SCROLLED_WINDOW_MODE:
rcw_switch_viewmode(cnnobj->cnnwin, priv->fss_view_mode);
break;
case SCROLLED_FULLSCREEN_MODE:
case VIEWPORT_FULLSCREEN_MODE:
rcw_switch_viewmode(cnnobj->cnnwin, SCROLLED_WINDOW_MODE);
......
......@@ -875,7 +875,7 @@ void remmina_main_on_action_application_quit(GSimpleAction *action, GVariant *pa
{
// Called by quit signal in remmina_main.glade
TRACE_CALL(__func__);
g_print ("Quit intercept");
g_debug ("Quit intercept");
remmina_application_condexit(REMMINA_CONDEXIT_ONQUIT);
}
......
......@@ -343,10 +343,6 @@ void remmina_plugin_manager_init(void)
}
g_slist_free(secret_plugins);
}
RemminaPlugin* remmina_plugin_manager_get_plugin(RemminaPluginType type, const gchar *name)
......
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