[gimp] Issue #1093 - Color dialog appears in the first monitor...



commit 1ae2b5d573dbf87961dd6b1fbcf4dbdb4f14dc97
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jun 20 15:59:29 2018 +0200

    Issue #1093 - Color dialog appears in the first monitor...
    
    ...while other windows are on the second monitor if window positions
    are saved at exit
    
    Add some lines of code to color_area_color_clicked() which position
    the already existing color dialog exactly like a newly created dialog
    would be positioned by gimp_dialog_factory_add_dialog().
    
    This should be part of GimpDialogFactory but let's wait for another
    case before we generalize it.

 app/widgets/gimptoolbox-color-area.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/app/widgets/gimptoolbox-color-area.c b/app/widgets/gimptoolbox-color-area.c
index 387633434f..0593c341ad 100644
--- a/app/widgets/gimptoolbox-color-area.c
+++ b/app/widgets/gimptoolbox-color-area.c
@@ -24,12 +24,15 @@
 
 #include "widgets-types.h"
 
+#include "config/gimpguiconfig.h"
+
 #include "core/gimp.h"
 #include "core/gimpcontext.h"
 
 #include "gimpcolordialog.h"
 #include "gimpdialogfactory.h"
 #include "gimpfgbgeditor.h"
+#include "gimpsessioninfo.h"
 #include "gimptoolbox.h"
 #include "gimptoolbox-color-area.h"
 
@@ -239,6 +242,38 @@ color_area_color_clicked (GimpFgBgEditor  *editor,
                                G_CALLBACK (color_area_background_changed),
                                G_OBJECT (color_dialog), 0);
     }
+  else if (! gtk_widget_get_visible (color_dialog))
+    {
+      /*  See https://gitlab.gnome.org/GNOME/gimp/issues/1093
+       *
+       *  We correctly position all newly created dialog via
+       *  gimp_dialog_factory_add_dialog(), but the color dialog is
+       *  special, it's never destroyed but created only once per
+       *  session. On re-showing, whatever window managing magic kicks
+       *  in and the dialog sometimes goes where it shouldn't.
+       *
+       *  The code below belongs into GimpDialogFactory, perhaps a new
+       *  function gimp_dialog_factory_position_dialog() and does the
+       *  same positioning logic as add_dialog().
+       */
+      GimpDialogFactory *dialog_factory = gimp_dialog_factory_get_singleton ();
+      GimpSessionInfo   *info;
+
+      info = gimp_dialog_factory_find_session_info (dialog_factory,
+                                                    "gimp-toolbox-color-dialog");
+
+      if (gimp_session_info_get_widget (info) == color_dialog)
+        {
+          GdkMonitor    *monitor = gimp_widget_get_monitor (GTK_WIDGET (editor));
+          GimpGuiConfig *gui_config;
+
+          gui_config = GIMP_GUI_CONFIG (context->gimp->config);
+
+          gimp_session_info_apply_geometry (info,
+                                            monitor,
+                                            gui_config->restore_monitor);
+        }
+    }
 
   gtk_window_set_title (GTK_WINDOW (color_dialog), title);
   gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (color_dialog), &color);


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