Commit c76cff06 authored by Giovanni Panozzo's avatar Giovanni Panozzo

Delay window state saving for remmina_connection_window

It seems that under gnome shell during configure_event for
unmaximizing a window, gdk_window_get_state is still reporting
that the window is maximized. This could be the cause of
issue #1262
parent 67b5d0b0
...@@ -103,6 +103,9 @@ struct _RemminaConnectionWindowPriv ...@@ -103,6 +103,9 @@ struct _RemminaConnectionWindowPriv
/* Timer to hide the toolbar */ /* Timer to hide the toolbar */
guint hidetb_timer; guint hidetb_timer;
/* Timer to save new window state and wxh */
guint savestate_eventsourceid;
GtkWidget* toolbar; GtkWidget* toolbar;
GtkWidget* grid; GtkWidget* grid;
...@@ -587,6 +590,11 @@ static void remmina_connection_window_destroy(GtkWidget* widget, RemminaConnecti ...@@ -587,6 +590,11 @@ static void remmina_connection_window_destroy(GtkWidget* widget, RemminaConnecti
g_source_remove(priv->ftb_hide_eventsource); g_source_remove(priv->ftb_hide_eventsource);
priv->ftb_hide_eventsource = 0; priv->ftb_hide_eventsource = 0;
} }
if (priv->savestate_eventsourceid)
{
g_source_remove(priv->savestate_eventsourceid);
priv->savestate_eventsourceid = 0;
}
#if FLOATING_TOOLBAR_WIDGET #if FLOATING_TOOLBAR_WIDGET
/* There is no need to destroy priv->floating_toolbar_widget, /* There is no need to destroy priv->floating_toolbar_widget,
...@@ -2489,33 +2497,65 @@ static gboolean remmina_connection_holder_floating_toolbar_on_scroll(GtkWidget* ...@@ -2489,33 +2497,65 @@ static gboolean remmina_connection_holder_floating_toolbar_on_scroll(GtkWidget*
return FALSE; return FALSE;
} }
static gboolean remmina_connection_window_after_configure_scrolled(gpointer user_data)
{
TRACE_CALL("remmina_connection_window_after_configure_scrolled");
gint width, height;
GdkWindowState s;
gint ipg, npages;
RemminaConnectionObject* cnnobj;
RemminaConnectionHolder* cnnhld;
cnnhld = (RemminaConnectionHolder*)user_data;
s = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)));
if (!cnnhld || !cnnhld->cnnwin)
return FALSE;
/* Changed window_maximize, window_width and window_height for all
* connections inside the notebook */
npages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(cnnhld->cnnwin->priv->notebook));
for(ipg = 0; ipg < npages; ipg ++) {
cnnobj = g_object_get_data(
G_OBJECT(gtk_notebook_get_nth_page(GTK_NOTEBOOK(cnnhld->cnnwin->priv->notebook), ipg)),
"cnnobj");
if (s & GDK_WINDOW_STATE_MAXIMIZED) {
remmina_file_set_int(cnnobj->remmina_file, "window_maximize", TRUE);
} else {
gtk_window_get_size(GTK_WINDOW(cnnhld->cnnwin), &width, &height);
remmina_file_set_int(cnnobj->remmina_file, "window_width", width);
remmina_file_set_int(cnnobj->remmina_file, "window_height", height);
remmina_file_set_int(cnnobj->remmina_file, "window_maximize", FALSE);
}
}
cnnhld->cnnwin->priv->savestate_eventsourceid = 0;
return FALSE;
}
static gboolean remmina_connection_window_on_configure(GtkWidget* widget, GdkEventConfigure* event, static gboolean remmina_connection_window_on_configure(GtkWidget* widget, GdkEventConfigure* event,
RemminaConnectionHolder* cnnhld) RemminaConnectionHolder* cnnhld)
{ {
TRACE_CALL("remmina_connection_window_on_configure"); TRACE_CALL("remmina_connection_window_on_configure");
DECLARE_CNNOBJ_WITH_RETURN(FALSE) DECLARE_CNNOBJ_WITH_RETURN(FALSE)
gint width, height;
#if !FLOATING_TOOLBAR_WIDGET #if !FLOATING_TOOLBAR_WIDGET
RemminaConnectionWindowPriv* priv = cnnhld->cnnwin->priv; RemminaConnectionWindowPriv* priv = cnnhld->cnnwin->priv;
GtkRequisition req; GtkRequisition req;
gint y; gint y;
#endif #endif
if (cnnhld->cnnwin->priv->savestate_eventsourceid) {
g_source_remove(cnnhld->cnnwin->priv->savestate_eventsourceid);
cnnhld->cnnwin->priv->savestate_eventsourceid = 0;
}
if (cnnhld->cnnwin && gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)) if (cnnhld->cnnwin && gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin))
&& cnnhld->cnnwin->priv->view_mode == SCROLLED_WINDOW_MODE) && cnnhld->cnnwin->priv->view_mode == SCROLLED_WINDOW_MODE)
{ {
/* Here we store the window state in real-time */ /* Under gnome shell we receive this configure_event BEFORE a window
if ((gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin))) & GDK_WINDOW_STATE_MAXIMIZED) == 0) * is really unmaximized, so we must read its new state and dimensions
{ * later, not now */
gtk_window_get_size(GTK_WINDOW(cnnhld->cnnwin), &width, &height); cnnhld->cnnwin->priv->savestate_eventsourceid = g_timeout_add(500, remmina_connection_window_after_configure_scrolled, cnnhld);
remmina_file_set_int(cnnobj->remmina_file, "window_width", width);
remmina_file_set_int(cnnobj->remmina_file, "window_height", height);
remmina_file_set_int(cnnobj->remmina_file, "window_maximize", FALSE);
}
else
{
remmina_file_set_int(cnnobj->remmina_file, "window_maximize", TRUE);
}
} }
#if !FLOATING_TOOLBAR_WIDGET #if !FLOATING_TOOLBAR_WIDGET
......
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