[gimp] app: don't session-restore windows partially offscreen or on 2 monitors



commit a1a70a4d1f64a6878b849a2d75d0d2dec0a5c3a0
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 3 23:59:15 2014 +0200

    app: don't session-restore windows partially offscreen or on 2 monitors

 app/widgets/gimpsessioninfo.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index 805fe36..ef31e38 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -627,6 +627,8 @@ gimp_session_info_apply_geometry (GimpSessionInfo *info,
   GdkRectangle rect;
   gchar        geom[32];
   gint         monitor;
+  gint         width;
+  gint         height;
 
   g_return_if_fail (GIMP_IS_SESSION_INFO (info));
   g_return_if_fail (GTK_IS_WINDOW (info->p->widget));
@@ -656,14 +658,25 @@ gimp_session_info_apply_geometry (GimpSessionInfo *info,
   info->p->x += rect.x;
   info->p->y += rect.y;
 
-  info->p->x = CLAMP (info->p->x,
-                      rect.x,
-                      rect.x + rect.width - (info->p->width > 0 ?
-                                             info->p->width : 128));
-  info->p->y = CLAMP (info->p->y,
-                      rect.y,
-                      rect.y + rect.height - (info->p->height > 0 ?
-                                              info->p->height : 128));
+  if (gimp_session_info_get_remember_size (info) &&
+      info->p->width  > 0 &&
+      info->p->height > 0)
+    {
+      width  = info->p->width;
+      height = info->p->height;
+    }
+  else
+    {
+      GtkRequisition requisition;
+
+      gtk_widget_size_request (info->p->widget, &requisition);
+
+      width  = requisition.width;
+      height = requisition.height;
+    }
+
+  info->p->x = CLAMP (info->p->x, rect.x, rect.x + rect.width  - width);
+  info->p->y = CLAMP (info->p->y, rect.y, rect.y + rect.height - height);
 
   if (info->p->right_align && info->p->bottom_align)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]