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.
This commit is contained in:
Michael Natterer 2018-06-20 15:59:29 +02:00
parent a04f2f3b3a
commit 1ae2b5d573
1 changed files with 35 additions and 0 deletions

View File

@ -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);