[gimp] app: make things behave more reasonable with multiple monitors
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make things behave more reasonable with multiple monitors
- Date: Fri, 2 May 2014 01:17:59 +0000 (UTC)
commit 843866e7e71c49ff0912aa6fb56407903f6fbf68
Author: Michael Natterer <mitch gimp org>
Date: Fri May 2 03:01:23 2014 +0200
app: make things behave more reasonable with multiple monitors
There is now a preference option that determines whether windows
should be opened on the same monitor as before. It should be disabled
when the machine gets monitors plugged/unplugged dynamically ("laptop")
and enabled when there is a static multi-monitor setup ("wokstation").
This is merely the current simplistic policy on top of the newly added
underlying infrastructure:
- pass integer monitor numbers around in all places where we already
pass around a GdkScreen. Pass the "current" monitor to these changed
APIs, where "current" is either the monitor where the action-triggering
widget is, or if that is unavailable the monitor where the mouse is.
- add gimp_widget_get_monitor() in order to easily get to the monitor,
just like gtk_widget_get_screen().
- add screen and monitor parameters in some places that were missed
before.
- in sessionrc, save all window positions relative to the window's
monitor, and save the monitor separately, if it's not the screen's
primary monitor.
- when restoring window positions, use the stored monitor when the new
prefs options says so (use the screen's primary monitor if there is
no stored monitor), otherwise use current monitor that is now passed
around.
app/actions/data-commands.c | 5 +-
app/actions/dialogs-commands.c | 3 +
app/actions/edit-commands.c | 2 +
app/actions/file-commands.c | 6 +
app/actions/image-commands.c | 2 +
app/actions/palettes-commands.c | 2 +
app/actions/select-commands.c | 2 +
app/actions/tool-options-commands.c | 2 +
app/actions/view-commands.c | 2 +
app/actions/windows-commands.c | 6 +-
app/config/gimpguiconfig.c | 11 ++
app/config/gimpguiconfig.h | 1 +
app/config/gimprc-blurbs.h | 5 +
app/dialogs/dialogs.c | 10 ++-
app/dialogs/preferences-dialog.c | 5 +
app/display/gimpimagewindow.c | 49 ++++++--
app/display/gimpmultiwindowstrategy.c | 5 +-
app/display/gimpsinglewindowstrategy.c | 10 +-
app/display/gimptooldialog.c | 6 +-
app/display/gimptooldialog.h | 2 +
app/display/gimptoolgui.c | 17 ++-
app/display/gimptoolgui.h | 4 +
app/gui/gimpuiconfigurer.c | 3 +
app/gui/gui-message.c | 32 ++++-
app/gui/gui.c | 10 ++-
app/gui/session.c | 11 ++-
app/tests/gimp-app-test-utils.c | 2 +-
app/tests/test-ui.c | 9 +-
app/tools/gimpcolorpickertool.c | 14 ++-
app/tools/gimpcolortool.c | 7 +-
app/tools/gimpforegroundselecttool.c | 6 +-
app/tools/gimpimagemaptool.c | 6 +-
app/tools/gimpmeasuretool.c | 15 ++-
app/tools/gimptexttool-editor.c | 9 ++-
app/tools/gimptransformtool.c | 17 +++-
app/widgets/gimpcolordialog.c | 9 +-
app/widgets/gimpcontainerpopup.c | 2 +
app/widgets/gimpcontrollereditor.c | 5 +-
app/widgets/gimpcontrollerlist.c | 4 +-
app/widgets/gimpdevicestatus.c | 2 +
app/widgets/gimpdialogfactory.c | 36 +++++-
app/widgets/gimpdialogfactory.h | 16 ++-
app/widgets/gimpdockable.c | 1 +
app/widgets/gimpsessioninfo-dock.c | 2 +
app/widgets/gimpsessioninfo-dock.h | 1 +
app/widgets/gimpsessioninfo-private.h | 1 +
app/widgets/gimpsessioninfo.c | 185 ++++++++++++++++--------------
app/widgets/gimpsessioninfo.h | 9 +-
app/widgets/gimptoolbox-image-area.c | 3 +-
app/widgets/gimptoolbox-indicator-area.c | 5 +-
app/widgets/gimptoolpalette.c | 2 +-
app/widgets/gimpviewablebox.c | 2 +
app/widgets/gimpwidgets-utils.c | 31 +++++-
app/widgets/gimpwidgets-utils.h | 4 +
app/widgets/gimpwindowstrategy.c | 2 +
app/widgets/gimpwindowstrategy.h | 2 +
app/widgets/widgets-types.h | 1 +
57 files changed, 456 insertions(+), 167 deletions(-)
---
diff --git a/app/actions/data-commands.c b/app/actions/data-commands.c
index c11c6fb..badb0f0 100644
--- a/app/actions/data-commands.c
+++ b/app/actions/data-commands.c
@@ -40,6 +40,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "dialogs/data-delete-dialog.h"
@@ -255,7 +256,8 @@ data_edit_cmd_callback (GtkAction *action,
if (data && gimp_data_factory_view_have (view,
GIMP_OBJECT (data)))
{
- GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
+ gint monitor = gimp_widget_get_monitor (GTK_WIDGET (view));
GtkWidget *dockable;
dockable =
@@ -263,6 +265,7 @@ data_edit_cmd_callback (GtkAction *action,
context->gimp,
gimp_dialog_factory_get_singleton (),
screen,
+ monitor,
value);
gimp_data_editor_set_data (GIMP_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
diff --git a/app/actions/dialogs-commands.c b/app/actions/dialogs-commands.c
index 056a71e..f75ba4d 100644
--- a/app/actions/dialogs-commands.c
+++ b/app/actions/dialogs-commands.c
@@ -27,6 +27,7 @@
#include "core/gimp.h"
#include "widgets/gimpdialogfactory.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "actions.h"
@@ -46,6 +47,7 @@ dialogs_create_toplevel_cmd_callback (GtkAction *action,
if (value)
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
value, -1, TRUE);
}
@@ -65,5 +67,6 @@ dialogs_create_dockable_cmd_callback (GtkAction *action,
gimp,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
value);
}
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index 1263e5c..53a7a0f 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -44,6 +44,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "display/gimpdisplay.h"
@@ -468,6 +469,7 @@ edit_named_paste_cmd_callback (GtkAction *action,
gimp,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-buffer-list|gimp-buffer-grid");
}
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 47d983b..1ea4cd5 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -48,6 +48,7 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
+#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
@@ -150,6 +151,7 @@ file_open_location_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
"gimp-file-open-location-dialog", -1, TRUE);
}
@@ -473,6 +475,7 @@ file_close_all_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-close-all-dialog", -1);
}
}
@@ -512,6 +515,7 @@ file_open_dialog_show (Gimp *gimp,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (parent),
+ gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
"gimp-file-open-dialog", -1, FALSE);
@@ -556,6 +560,7 @@ file_save_dialog_show (Gimp *gimp,
{
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (parent),
+ gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
"gimp-file-save-dialog",
-1, FALSE);
@@ -644,6 +649,7 @@ file_export_dialog_show (Gimp *gimp,
{
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (parent),
+ gimp_widget_get_monitor (parent),
NULL /*ui_manager*/,
"gimp-file-export-dialog",
-1, FALSE);
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index efb9230..28c36e8 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -50,6 +50,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
+#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@@ -140,6 +141,7 @@ image_new_cmd_callback (GtkAction *action,
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
"gimp-image-new-dialog", -1, FALSE);
diff --git a/app/actions/palettes-commands.c b/app/actions/palettes-commands.c
index 6e91b3d..eaa1b39 100644
--- a/app/actions/palettes-commands.c
+++ b/app/actions/palettes-commands.c
@@ -34,6 +34,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpview.h"
+#include "widgets/gimpwidgets-utils.h"
#include "actions.h"
#include "palettes-commands.h"
@@ -59,6 +60,7 @@ palettes_import_cmd_callback (GtkAction *action,
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
NULL /*ui_manager*/,
"gimp-palette-import-dialog", -1, TRUE);
}
diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c
index f11dd27..e9999df 100644
--- a/app/actions/select-commands.c
+++ b/app/actions/select-commands.c
@@ -33,6 +33,7 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpdialogfactory.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "display/gimpdisplay.h"
@@ -322,6 +323,7 @@ select_save_cmd_callback (GtkAction *action,
image->gimp,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-channel-list");
}
diff --git a/app/actions/tool-options-commands.c b/app/actions/tool-options-commands.c
index 19c1d79..cf3f784 100644
--- a/app/actions/tool-options-commands.c
+++ b/app/actions/tool-options-commands.c
@@ -42,6 +42,7 @@
#include "widgets/gimpmessagedialog.h"
#include "widgets/gimptooloptionseditor.h"
#include "widgets/gimpuimanager.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "dialogs/data-delete-dialog.h"
@@ -243,6 +244,7 @@ tool_options_show_preset_editor (Gimp *gimp,
gimp,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (GTK_WIDGET (editor)),
+ gimp_widget_get_monitor (GTK_WIDGET (editor)),
"gimp-tool-preset-editor");
gimp_data_editor_set_data (GIMP_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index f90a53f..7bed4a6 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -38,6 +38,7 @@
#include "widgets/gimpdock.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpuimanager.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "display/gimpdisplay.h"
@@ -392,6 +393,7 @@ view_navigation_window_cmd_callback (GtkAction *action,
gimp,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
"gimp-navigation-view");
}
diff --git a/app/actions/windows-commands.c b/app/actions/windows-commands.c
index 9a04c47..2244910 100644
--- a/app/actions/windows-commands.c
+++ b/app/actions/windows-commands.c
@@ -167,7 +167,9 @@ windows_open_recent_cmd_callback (GtkAction *action,
GimpSessionInfo *info;
GimpDialogFactoryEntry *entry;
Gimp *gimp;
+ GtkWidget *widget;
return_if_no_gimp (gimp, data);
+ return_if_no_widget (widget, data);
info = g_object_get_data (G_OBJECT (action), "info");
entry = gimp_session_info_get_factory_entry (info);
@@ -190,7 +192,9 @@ windows_open_recent_cmd_callback (GtkAction *action,
gimp_dialog_factory_add_session_info (gimp_dialog_factory_get_singleton (),
info);
- gimp_session_info_restore (info, gimp_dialog_factory_get_singleton ());
+ gimp_session_info_restore (info, gimp_dialog_factory_get_singleton (),
+ gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget));
g_object_unref (info);
}
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index 5fd934a..e886b88 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -49,6 +49,7 @@ enum
PROP_SAVE_DEVICE_STATUS,
PROP_SAVE_SESSION_INFO,
PROP_RESTORE_SESSION,
+ PROP_RESTORE_MONITOR,
PROP_SAVE_TOOL_OPTIONS,
PROP_SHOW_TOOLTIPS,
PROP_TEAROFF_MENUS,
@@ -146,6 +147,10 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
"restore-session", RESTORE_SESSION_BLURB,
TRUE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_MONITOR,
+ "restore-monitor", RESTORE_MONITOR_BLURB,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_TOOL_OPTIONS,
"save-tool-options",
SAVE_TOOL_OPTIONS_BLURB,
@@ -386,6 +391,9 @@ gimp_gui_config_set_property (GObject *object,
case PROP_RESTORE_SESSION:
gui_config->restore_session = g_value_get_boolean (value);
break;
+ case PROP_RESTORE_MONITOR:
+ gui_config->restore_monitor = g_value_get_boolean (value);
+ break;
case PROP_SAVE_TOOL_OPTIONS:
gui_config->save_tool_options = g_value_get_boolean (value);
break;
@@ -521,6 +529,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_RESTORE_SESSION:
g_value_set_boolean (value, gui_config->restore_session);
break;
+ case PROP_RESTORE_MONITOR:
+ g_value_set_boolean (value, gui_config->restore_monitor);
+ break;
case PROP_SAVE_TOOL_OPTIONS:
g_value_set_boolean (value, gui_config->save_tool_options);
break;
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index 6cbe87a..4b98f84 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -43,6 +43,7 @@ struct _GimpGuiConfig
gboolean save_device_status;
gboolean save_session_info;
gboolean restore_session;
+ gboolean restore_monitor;
gboolean save_tool_options;
gboolean show_tooltips;
gboolean tearoff_menus;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index f8b143f..1454164 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -294,6 +294,11 @@ N_("When enabled, the image window will automatically resize itself " \
#define RESTORE_SESSION_BLURB \
N_("Let GIMP try to restore your last saved session on each startup.")
+#define RESTORE_MONITOR_BLURB \
+N_("When enabled, GIMP will try to restore windows on the monitor they " \
+ "were open before. When disabled, windows will appear on the currently " \
+ "used monitor.")
+
#define SAVE_DEVICE_STATUS_BLURB \
N_("Remember the current tool, pattern, color, and brush across GIMP " \
"sessions.")
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index 7624e06..4489dcd 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -212,9 +212,11 @@ GimpContainer *global_recent_docks = NULL;
static GtkWidget * dialogs_restore_dialog (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpSessionInfo *info);
static GtkWidget * dialogs_restore_window (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpSessionInfo *info);
@@ -422,6 +424,7 @@ static const GimpDialogFactoryEntry entries[] =
* dialogs_restore_dialog:
* @factory:
* @screen:
+ * @monitor:
* @info:
*
* Creates a top level widget based on the given session info object
@@ -433,6 +436,7 @@ static const GimpDialogFactoryEntry entries[] =
static GtkWidget *
dialogs_restore_dialog (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpSessionInfo *info)
{
GtkWidget *dialog;
@@ -443,7 +447,7 @@ dialogs_restore_dialog (GimpDialogFactory *factory,
info);
dialog =
- gimp_dialog_factory_dialog_new (factory, screen,
+ gimp_dialog_factory_dialog_new (factory, screen, monitor,
NULL /*ui_manager*/,
gimp_session_info_get_factory_entry (info)->identifier,
gimp_session_info_get_factory_entry (info)->view_size,
@@ -461,17 +465,19 @@ dialogs_restore_dialog (GimpDialogFactory *factory,
* dialogs_restore_window:
* @factory:
* @screen:
+ * @monitor:
* @info:
*
* "restores" the image window. We don't really restore anything since
* the image window is created earlier, so we just look for and return
* the already-created image window.
*
- * Returns:
+ * Returns:
**/
static GtkWidget *
dialogs_restore_window (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpSessionInfo *info)
{
Gimp *gimp = gimp_dialog_factory_get_context (factory)->gimp;
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 5965a8d..6060fea 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -492,6 +492,7 @@ prefs_input_devices_dialog (GtkWidget *widget,
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-input-devices-dialog", 0);
}
@@ -501,6 +502,7 @@ prefs_keyboard_shortcuts_dialog (GtkWidget *widget,
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-keyboard-shortcuts-dialog", 0);
}
@@ -2509,6 +2511,9 @@ prefs_dialog_new (Gimp *gimp,
prefs_check_button_add (object, "save-session-info",
_("_Save window positions on exit"),
GTK_BOX (vbox2));
+ prefs_check_button_add (object, "restore-monitor",
+ _("Open windows on the same _monitor they were open before"),
+ GTK_BOX (vbox2));
button = prefs_button_add (GTK_STOCK_SAVE,
_("Save Window Positions _Now"),
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index ec81ffe..5634a87 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -49,6 +49,7 @@
#include "widgets/gimptoolbox.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpview.h"
+#include "widgets/gimpwidgets-utils.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
@@ -178,10 +179,14 @@ static void gimp_image_window_config_notify (GimpImageWindow *win
GimpGuiConfig *config);
static void gimp_image_window_session_clear (GimpImageWindow *window);
static void gimp_image_window_session_apply (GimpImageWindow *window,
- const gchar *entry_id);
+ const gchar *entry_id,
+ GdkScreen *screen,
+ gint monitor);
static void gimp_image_window_session_update (GimpImageWindow *window,
GimpDisplay *new_display,
- const gchar *new_entry_id);
+ const gchar *new_entry_id,
+ GdkScreen *screen,
+ gint monitor);
static const gchar *
gimp_image_window_config_to_entry_id (GimpGuiConfig *config);
static void gimp_image_window_show_tooltip (GimpUIManager *manager,
@@ -454,7 +459,9 @@ gimp_image_window_constructed (GObject *object)
gimp_image_window_session_update (window,
NULL /*new_display*/,
- gimp_image_window_config_to_entry_id (config));
+ gimp_image_window_config_to_entry_id (config),
+ gdk_screen_get_default (), /* FIXME monitor */
+ 0 /* FIXME monitor */);
}
static void
@@ -1645,7 +1652,9 @@ gimp_image_window_config_notify (GimpImageWindow *window,
{
gimp_image_window_session_update (window,
NULL /*new_display*/,
- gimp_image_window_config_to_entry_id (config));
+ gimp_image_window_config_to_entry_id (config),
+ gtk_widget_get_screen (GTK_WIDGET (window)),
+ gimp_widget_get_monitor (GTK_WIDGET (window)));
}
}
@@ -1765,7 +1774,9 @@ gimp_image_window_switch_page (GtkNotebook *notebook,
gimp_image_window_session_update (window,
active_display,
- NULL /*new_entry_id*/);
+ NULL /*new_entry_id*/,
+ gtk_widget_get_screen (GTK_WIDGET (window)),
+ gimp_widget_get_monitor (GTK_WIDGET (window)));
gimp_context_set_display (gimp_get_user_context (private->gimp),
active_display);
@@ -1861,7 +1872,9 @@ gimp_image_window_image_notify (GimpDisplay *display,
gimp_image_window_session_update (window,
display,
- NULL /*new_entry_id*/);
+ NULL /*new_entry_id*/,
+ gtk_widget_get_screen (GTK_WIDGET (window)),
+ gimp_widget_get_monitor (GTK_WIDGET (window)));
tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (private->notebook),
GTK_WIDGET (gimp_display_get_shell (display)));
@@ -1888,7 +1901,9 @@ gimp_image_window_session_clear (GimpImageWindow *window)
static void
gimp_image_window_session_apply (GimpImageWindow *window,
- const gchar *entry_id)
+ const gchar *entry_id,
+ GdkScreen *screen,
+ gint monitor)
{
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
GimpSessionInfo *session_info = NULL;
@@ -1921,7 +1936,9 @@ gimp_image_window_session_apply (GimpImageWindow *window,
gimp_dialog_factory_add_foreign (private->dialog_factory,
entry_id,
- GTK_WIDGET (window));
+ GTK_WIDGET (window),
+ screen,
+ monitor);
gtk_window_unmaximize (GTK_WINDOW (window));
gtk_window_resize (GTK_WINDOW (window), width, height);
@@ -1930,7 +1947,9 @@ gimp_image_window_session_apply (GimpImageWindow *window,
static void
gimp_image_window_session_update (GimpImageWindow *window,
GimpDisplay *new_display,
- const gchar *new_entry_id)
+ const gchar *new_entry_id,
+ GdkScreen *screen,
+ gint monitor)
{
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
@@ -1946,7 +1965,8 @@ gimp_image_window_session_update (GimpImageWindow *window,
*/
if (strcmp (new_entry_id, GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID) == 0)
{
- gimp_image_window_session_apply (window, new_entry_id);
+ gimp_image_window_session_apply (window, new_entry_id,
+ screen, monitor);
}
}
else if (strcmp (private->entry_id, new_entry_id) != 0)
@@ -1966,7 +1986,8 @@ gimp_image_window_session_update (GimpImageWindow *window,
! gimp_display_get_image (private->active_shell->display) &&
g_list_length (private->shells) <= 1)
{
- gimp_image_window_session_apply (window, new_entry_id);
+ gimp_image_window_session_apply (window, new_entry_id,
+ screen, monitor);
}
}
else if (strcmp (new_entry_id, GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID) == 0)
@@ -1975,7 +1996,8 @@ gimp_image_window_session_update (GimpImageWindow *window,
* shall session manage ourself until single-window mode
* is exited
*/
- gimp_image_window_session_apply (window, new_entry_id);
+ gimp_image_window_session_apply (window, new_entry_id,
+ screen, monitor);
}
}
@@ -2002,7 +2024,8 @@ gimp_image_window_session_update (GimpImageWindow *window,
/* As soon as we have no image (and no other shells that may
* contain images) we should become the empty image window
*/
- gimp_image_window_session_apply (window, private->entry_id);
+ gimp_image_window_session_apply (window, private->entry_id,
+ screen, monitor);
}
}
}
diff --git a/app/display/gimpmultiwindowstrategy.c b/app/display/gimpmultiwindowstrategy.c
index f736e72..5c632ec 100644
--- a/app/display/gimpmultiwindowstrategy.c
+++ b/app/display/gimpmultiwindowstrategy.c
@@ -38,6 +38,7 @@ static GtkWidget * gimp_multi_window_strategy_show_dockable_dialog (GimpWi
Gimp *gimp,
GimpDialogFactory
*factory,
GdkScreen
*screen,
+ gint
monitor,
const gchar
*identifiers);
@@ -69,9 +70,11 @@ gimp_multi_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
Gimp *gimp,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers)
{
- return gimp_dialog_factory_dialog_raise (factory, screen, identifiers, -1);
+ return gimp_dialog_factory_dialog_raise (factory, screen, monitor,
+ identifiers, -1);
}
GimpObject *
diff --git a/app/display/gimpsinglewindowstrategy.c b/app/display/gimpsinglewindowstrategy.c
index 0c46888..6f3c5e2 100644
--- a/app/display/gimpsinglewindowstrategy.c
+++ b/app/display/gimpsinglewindowstrategy.c
@@ -44,6 +44,7 @@ static GtkWidget * gimp_single_window_strategy_show_dockable_dialog (GimpW
Gimp *gimp,
GimpDialogFactory
*factory,
GdkScreen
*screen,
+ gint
monitor,
const gchar
*identifiers);
@@ -75,6 +76,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
Gimp *gimp,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers)
{
GList *windows = gimp_get_image_windows (gimp);
@@ -96,6 +98,7 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
widget = gimp_dialog_factory_dialog_new (factory,
screen,
+ monitor,
ui_manager,
"gimp-toolbox",
-1 /*view_size*/,
@@ -111,7 +114,8 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
else if (gimp_dialog_factory_find_widget (factory, identifiers))
{
/* if the dialog is already open, simply raise it */
- return gimp_dialog_factory_dialog_raise (factory, screen, identifiers, -1);
+ return gimp_dialog_factory_dialog_raise (factory, screen, monitor,
+ identifiers, -1);
}
else
{
@@ -131,8 +135,8 @@ gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
}
widget = gimp_dockbook_add_from_dialog_factory (GIMP_DOCKBOOK (dockbook),
- identifiers,
- -1 /*index*/);
+ identifiers,
+ -1 /*index*/);
}
diff --git a/app/display/gimptooldialog.c b/app/display/gimptooldialog.c
index 771421f..b0e4e92 100644
--- a/app/display/gimptooldialog.c
+++ b/app/display/gimptooldialog.c
@@ -103,6 +103,8 @@ gimp_tool_dialog_dispose (GObject *object)
**/
GtkWidget *
gimp_tool_dialog_new (GimpToolInfo *tool_info,
+ GdkScreen *screen,
+ gint monitor,
const gchar *desc,
...)
{
@@ -132,7 +134,9 @@ gimp_tool_dialog_new (GimpToolInfo *tool_info,
gimp_dialog_factory_add_foreign (gimp_dialog_factory_get_singleton (),
identifier,
- dialog);
+ dialog,
+ screen,
+ monitor);
g_free (identifier);
diff --git a/app/display/gimptooldialog.h b/app/display/gimptooldialog.h
index 674a4f4..c97e24c 100644
--- a/app/display/gimptooldialog.h
+++ b/app/display/gimptooldialog.h
@@ -43,6 +43,8 @@ struct _GimpToolDialog
GType gimp_tool_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_tool_dialog_new (GimpToolInfo *tool_info,
+ GdkScreen *screen,
+ gint monitor,
const gchar *desc,
...) G_GNUC_NULL_TERMINATED;
diff --git a/app/display/gimptoolgui.c b/app/display/gimptoolgui.c
index 80141b2..203c145 100644
--- a/app/display/gimptoolgui.c
+++ b/app/display/gimptoolgui.c
@@ -84,7 +84,9 @@ struct _GimpToolGuiPrivate
static void gimp_tool_gui_dispose (GObject *object);
static void gimp_tool_gui_finalize (GObject *object);
-static void gimp_tool_gui_create_dialog (GimpToolGui *gui);
+static void gimp_tool_gui_create_dialog (GimpToolGui *gui,
+ GdkScreen *screen,
+ gint monitor);
static void gimp_tool_gui_update_buttons (GimpToolGui *gui);
static void gimp_tool_gui_update_shell (GimpToolGui *gui);
static void gimp_tool_gui_update_viewable (GimpToolGui *gui);
@@ -211,6 +213,8 @@ gimp_tool_gui_finalize (GObject *object)
GimpToolGui *
gimp_tool_gui_new (GimpToolInfo *tool_info,
const gchar *description,
+ GdkScreen *screen,
+ gint monitor,
gboolean overlay,
...)
{
@@ -244,7 +248,7 @@ gimp_tool_gui_new (GimpToolInfo *tool_info,
va_end (args);
- gimp_tool_gui_create_dialog (gui);
+ gimp_tool_gui_create_dialog (gui, screen, monitor);
return gui;
}
@@ -394,6 +398,8 @@ gimp_tool_gui_hide (GimpToolGui *gui)
void
gimp_tool_gui_set_overlay (GimpToolGui *gui,
+ GdkScreen *screen,
+ gint monitor,
gboolean overlay)
{
GimpToolGuiPrivate *private;
@@ -421,7 +427,7 @@ gimp_tool_gui_set_overlay (GimpToolGui *gui,
private->overlay = overlay ? TRUE : FALSE;
- gimp_tool_gui_create_dialog (gui);
+ gimp_tool_gui_create_dialog (gui, screen, monitor);
if (visible)
gimp_tool_gui_show (gui);
@@ -557,7 +563,9 @@ gimp_tool_gui_set_alternative_button_order (GimpToolGui *gui,
/* private functions */
static void
-gimp_tool_gui_create_dialog (GimpToolGui *gui)
+gimp_tool_gui_create_dialog (GimpToolGui *gui,
+ GdkScreen *screen,
+ gint monitor)
{
GimpToolGuiPrivate *private = GET_PRIVATE (gui);
GList *list;
@@ -596,6 +604,7 @@ gimp_tool_gui_create_dialog (GimpToolGui *gui)
else
{
private->dialog = gimp_tool_dialog_new (private->tool_info,
+ screen, monitor,
private->description,
NULL);
diff --git a/app/display/gimptoolgui.h b/app/display/gimptoolgui.h
index b98eae2..7b57dcf 100644
--- a/app/display/gimptoolgui.h
+++ b/app/display/gimptoolgui.h
@@ -54,6 +54,8 @@ GType gimp_tool_gui_get_type (void) G_GNUC_CONST;
GimpToolGui * gimp_tool_gui_new (GimpToolInfo *tool_info,
const gchar *description,
+ GdkScreen *screen,
+ gint monitor,
gboolean overlay,
...) G_GNUC_NULL_TERMINATED;
@@ -72,6 +74,8 @@ void gimp_tool_gui_show (GimpToolGui *gui);
void gimp_tool_gui_hide (GimpToolGui *gui);
void gimp_tool_gui_set_overlay (GimpToolGui *gui,
+ GdkScreen *screen,
+ gint monitor,
gboolean overlay);
gboolean gimp_tool_gui_get_overlay (GimpToolGui *gui);
diff --git a/app/gui/gimpuiconfigurer.c b/app/gui/gimpuiconfigurer.c
index fe8afee..d53f450 100644
--- a/app/gui/gimpuiconfigurer.c
+++ b/app/gui/gimpuiconfigurer.c
@@ -34,6 +34,7 @@
#include "widgets/gimpdockcontainer.h"
#include "widgets/gimpdockwindow.h"
#include "widgets/gimptoolbox.h"
+#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@@ -332,6 +333,7 @@ gimp_ui_configurer_move_docks_to_window (GimpUIConfigurer *ui_configurer,
GimpAlignmentType screen_side_destination)
{
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (dock_columns));
+ gint monitor = gimp_widget_get_monitor (GTK_WIDGET (dock_columns));
GList *docks = g_list_copy (gimp_dock_columns_get_docks (dock_columns));
GList *iter = NULL;
gboolean contains_toolbox = FALSE;
@@ -367,6 +369,7 @@ gimp_ui_configurer_move_docks_to_window (GimpUIConfigurer *ui_configurer,
dock_window =
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
screen,
+ monitor,
NULL /*ui_manager*/,
(contains_toolbox ?
"gimp-toolbox-window" :
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index 27469fb..32ae146 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -110,12 +110,22 @@ gui_message_error_console (Gimp *gimp,
}
if (! dockable)
- dockable =
- gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
- gimp,
- gimp_dialog_factory_get_singleton (),
- gdk_screen_get_default (),
- "gimp-error-console");
+ {
+ GdkScreen *screen;
+ gint x, y;
+ gint monitor;
+
+ gdk_display_get_pointer (gdk_display_get_default (),
+ &screen, &x, &y, NULL);
+ monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+
+ dockable =
+ gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
+ gimp,
+ gimp_dialog_factory_get_singleton (),
+ screen, monitor,
+ "gimp-error-console");
+ }
if (dockable)
{
@@ -178,8 +188,16 @@ progress_error_dialog (GimpProgress *progress)
static GtkWidget *
global_error_dialog (void)
{
+ GdkScreen *screen;
+ gint x, y;
+ gint monitor;
+
+ gdk_display_get_pointer (gdk_display_get_default (),
+ &screen, &x, &y, NULL);
+ monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+
return gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
- gdk_screen_get_default (),
+ screen, monitor,
NULL /*ui_manager*/,
"gimp-error-dialog", -1,
FALSE);
diff --git a/app/gui/gui.c b/app/gui/gui.c
index e10d943..4523716 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -601,8 +601,16 @@ gui_exit_callback (Gimp *gimp,
if (! force && gimp_displays_dirty (gimp))
{
+ GdkScreen *screen;
+ gint x, y;
+ gint monitor;
+
+ gdk_display_get_pointer (gdk_display_get_default (),
+ &screen, &x, &y, NULL);
+ monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
- gdk_screen_get_default (),
+ screen, monitor,
"gimp-quit-dialog", -1);
return TRUE; /* stop exit for now */
diff --git a/app/gui/session.c b/app/gui/session.c
index 2efa1cc..35e25cc 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -317,9 +317,18 @@ session_exit (Gimp *gimp)
void
session_restore (Gimp *gimp)
{
+ GdkScreen *screen;
+ gint x, y;
+ gint monitor;
+
g_return_if_fail (GIMP_IS_GIMP (gimp));
- gimp_dialog_factory_restore (gimp_dialog_factory_get_singleton ());
+ gdk_display_get_pointer (gdk_display_get_default (),
+ &screen, &x, &y, NULL);
+ monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+
+ gimp_dialog_factory_restore (gimp_dialog_factory_get_singleton (),
+ screen, monitor);
/* make sure GimpImageWindow acts upon hide-docks at the right time,
* see bug #678043.
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index 962d4ec..844d0b9 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -227,7 +227,7 @@ gimp_test_utils_create_image_from_dialog (Gimp *gimp)
/* Get the GtkWindow of the dialog */
new_image_dialog =
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
- gdk_screen_get_default (),
+ gdk_screen_get_default (), 0,
"gimp-image-new-dialog",
-1 /*view_size*/);
diff --git a/app/tests/test-ui.c b/app/tests/test-ui.c
index ea4ef51..e9b631c 100644
--- a/app/tests/test-ui.c
+++ b/app/tests/test-ui.c
@@ -114,6 +114,7 @@ tool_options_editor_updates (gconstpointer data)
GimpUIManager *ui_manager = gimp_image_window_get_ui_manager (image_window);
GtkWidget *dockable = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (toplevel),
+ gimp_widget_get_monitor (toplevel),
NULL /*ui_manager*/,
"gimp-tool-options",
-1 /*view_size*/,
@@ -127,8 +128,7 @@ tool_options_editor_updates (gconstpointer data)
g_assert_cmpstr (GIMP_HELP_TOOL_RECT_SELECT,
==,
gimp_tool_options_editor_get_tool_options (editor)->
- tool_info->
- help_id);
+ tool_info->help_id);
/* Change tool and make sure the change is taken into account by the
* tool options editor
@@ -139,8 +139,7 @@ tool_options_editor_updates (gconstpointer data)
g_assert_cmpstr (GIMP_HELP_TOOL_ELLIPSE_SELECT,
==,
gimp_tool_options_editor_get_tool_options (editor)->
- tool_info->
- help_id);
+ tool_info->help_id);
}
static GtkWidget *
@@ -764,9 +763,11 @@ window_roles (gconstpointer data)
dock = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
gdk_screen_get_default (),
+ 0,
FALSE /*toolbox*/);
toolbox = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
gdk_screen_get_default (),
+ 0,
TRUE /*toolbox*/);
dock_window = gimp_dock_window_from_dock (GIMP_DOCK (dock));
toolbox_window = gimp_dock_window_from_dock (GIMP_DOCK (toolbox));
diff --git a/app/tools/gimpcolorpickertool.c b/app/tools/gimpcolorpickertool.c
index 4f10885..d09dabb 100644
--- a/app/tools/gimpcolorpickertool.c
+++ b/app/tools/gimpcolorpickertool.c
@@ -303,15 +303,21 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
static void
gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool)
{
- GimpTool *tool = GIMP_TOOL (picker_tool);
- GtkWidget *hbox;
- GtkWidget *frame;
- GimpRGB color;
+ GimpTool *tool = GIMP_TOOL (picker_tool);
+ GimpDisplayShell *shell;
+ GtkWidget *hbox;
+ GtkWidget *frame;
+ GimpRGB color;
+ g_return_if_fail (tool->display != NULL);
g_return_if_fail (tool->drawable != NULL);
+ shell = gimp_display_get_shell (tool->display);
+
picker_tool->gui = gimp_tool_gui_new (tool->tool_info,
_("Color Picker Information"),
+ gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
FALSE,
GTK_STOCK_CLOSE,
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 76eb7d5..c5e05b5 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -42,6 +42,7 @@
#include "widgets/gimpdockable.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimpsessioninfo.h"
+#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpwindowstrategy.h"
#include "display/gimpcanvasitem.h"
@@ -663,8 +664,9 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
case GIMP_COLOR_PICK_MODE_PALETTE:
{
- GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
- GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
+ GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
+ gint monitor = gimp_widget_get_monitor (GTK_WIDGET (shell));
GtkWidget *dockable;
dockable =
@@ -672,6 +674,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
tool->display->gimp,
gimp_dialog_factory_get_singleton (),
screen,
+ monitor,
"gimp-palette-editor");
if (dockable)
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index 203d0a8..9ed02f6 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -295,13 +295,13 @@ gimp_foreground_select_tool_initialize (GimpTool *tool,
fg_select->gui =
gimp_tool_gui_new (tool->tool_info,
_("Dialog for foreground select"),
- FALSE,
+ gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
+ TRUE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GIMP_STOCK_TOOL_FOREGROUND_SELECT, GTK_RESPONSE_APPLY,
NULL);
- gimp_tool_gui_set_overlay (fg_select->gui, TRUE);
-
g_signal_connect (fg_select->gui, "response",
G_CALLBACK (gimp_foreground_select_tool_response),
fg_select);
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index ad3538b..d3434fd 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -280,7 +280,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
GimpToolInfo *tool_info = tool->tool_info;
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
- GimpDisplayShell *display_shell = gimp_display_get_shell (display);
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
if (! drawable)
return FALSE;
@@ -330,6 +330,8 @@ gimp_image_map_tool_initialize (GimpTool *tool,
image_map_tool->gui =
gimp_tool_gui_new (tool_info,
klass->dialog_desc,
+ gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
image_map_tool->overlay,
GIMP_STOCK_RESET, RESPONSE_RESET,
@@ -392,7 +394,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
gimp_image_map_tool_dialog (image_map_tool);
}
- gimp_tool_gui_set_shell (image_map_tool->gui, display_shell);
+ gimp_tool_gui_set_shell (image_map_tool->gui, shell);
gimp_tool_gui_set_viewable (image_map_tool->gui, GIMP_VIEWABLE (drawable));
gimp_tool_gui_show (image_map_tool->gui);
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index 3d24e60..11c304e 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -1040,13 +1040,20 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
static GimpToolGui *
gimp_measure_tool_dialog_new (GimpMeasureTool *measure)
{
- GimpTool *tool = GIMP_TOOL (measure);
- GimpToolGui *gui;
- GtkWidget *table;
- GtkWidget *label;
+ GimpTool *tool = GIMP_TOOL (measure);
+ GimpDisplayShell *shell;
+ GimpToolGui *gui;
+ GtkWidget *table;
+ GtkWidget *label;
+
+ g_return_if_fail (tool->display != NULL);
+
+ shell = gimp_display_get_shell (tool->display);
gui = gimp_tool_gui_new (tool->tool_info,
_("Measure Distances and Angles"),
+ gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
FALSE,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index c4e950e..fcdda04 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -44,6 +44,7 @@
#include "widgets/gimptexteditor.h"
#include "widgets/gimptextproxy.h"
#include "widgets/gimptextstyleeditor.h"
+#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@@ -1205,7 +1206,13 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
gimp_dialog_factory_add_foreign (dialog_factory,
"gimp-text-tool-dialog",
- text_tool->editor_dialog);
+ text_tool->editor_dialog,
+ parent ?
+ gtk_widget_get_screen (GTK_WIDGET (parent)) :
+ gdk_screen_get_default (), /* FIXME monitor */
+ parent ?
+ gimp_widget_get_monitor (GTK_WIDGET (parent)) :
+ 0 /* FIXME monitor */);
g_signal_connect (text_tool->editor_dialog, "destroy",
G_CALLBACK (gimp_text_tool_editor_destroy),
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index ef72997..afa8d53 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -1628,19 +1628,26 @@ gimp_transform_tool_handles_recalc (GimpTransformTool *tr_tool,
static void
gimp_transform_tool_dialog (GimpTransformTool *tr_tool)
{
- GimpTool *tool = GIMP_TOOL (tr_tool);
- GimpToolInfo *tool_info = tool->tool_info;
- const gchar *stock_id;
+ GimpTool *tool = GIMP_TOOL (tr_tool);
+ GimpToolInfo *tool_info = tool->tool_info;
+ GimpDisplayShell *shell;
+ const gchar *stock_id;
if (! GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->dialog)
return;
+ g_return_if_fail (tool->display != NULL);
+
+ shell = gimp_display_get_shell (tool->display);
+
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
tr_tool->overlay = FALSE;
tr_tool->gui = gimp_tool_gui_new (tool_info,
tool_info->blurb,
+ gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
tr_tool->overlay,
GIMP_STOCK_WILBER_EEK, RESPONSE_EEK,
@@ -1713,7 +1720,11 @@ gimp_transform_tool_response (GimpToolGui *gui,
case RESPONSE_EEK:
if (tr_tool->gui)
{
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
+
gimp_tool_gui_set_overlay (tr_tool->gui,
+ gtk_widget_get_screen (GTK_WIDGET (shell)),
+ gimp_widget_get_monitor (GTK_WIDGET (shell)),
! gimp_tool_gui_get_overlay (tr_tool->gui));
}
break;
diff --git a/app/widgets/gimpcolordialog.c b/app/widgets/gimpcolordialog.c
index 06c36a4..85c927e 100644
--- a/app/widgets/gimpcolordialog.c
+++ b/app/widgets/gimpcolordialog.c
@@ -38,6 +38,7 @@
#include "gimpcolordialog.h"
#include "gimpdialogfactory.h"
#include "gimphelp-ids.h"
+#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@@ -295,8 +296,12 @@ gimp_color_dialog_new (GimpViewable *viewable,
dialog->wants_updates = wants_updates;
if (dialog_factory)
- gimp_dialog_factory_add_foreign (dialog_factory, dialog_identifier,
- GTK_WIDGET (dialog));
+ {
+ gimp_dialog_factory_add_foreign (dialog_factory, dialog_identifier,
+ GTK_WIDGET (dialog),
+ gtk_widget_get_screen (parent),
+ gimp_widget_get_monitor (parent));
+ }
gimp_color_selection_set_show_alpha (GIMP_COLOR_SELECTION (dialog->selection),
show_alpha);
diff --git a/app/widgets/gimpcontainerpopup.c b/app/widgets/gimpcontainerpopup.c
index 6ae322c..52ea753 100644
--- a/app/widgets/gimpcontainerpopup.c
+++ b/app/widgets/gimpcontainerpopup.c
@@ -41,6 +41,7 @@
#include "gimpcontainerview.h"
#include "gimpdialogfactory.h"
#include "gimpviewrenderer.h"
+#include "gimpwidgets-utils.h"
#include "gimpwindowstrategy.h"
#include "gimp-intl.h"
@@ -663,6 +664,7 @@ gimp_container_popup_dialog_clicked (GtkWidget *button,
popup->context->gimp,
popup->dialog_factory,
gtk_widget_get_screen (button),
+ gimp_widget_get_monitor (button),
popup->dialog_identifier);
g_signal_emit (popup, popup_signals[CONFIRM], 0);
}
diff --git a/app/widgets/gimpcontrollereditor.c b/app/widgets/gimpcontrollereditor.c
index 80831b4..c9b7318 100644
--- a/app/widgets/gimpcontrollereditor.c
+++ b/app/widgets/gimpcontrollereditor.c
@@ -42,6 +42,7 @@
#include "gimphelp-ids.h"
#include "gimpuimanager.h"
#include "gimpviewabledialog.h"
+#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@@ -678,7 +679,9 @@ gimp_controller_editor_edit_clicked (GtkWidget *button,
gimp_dialog_factory_add_foreign (gimp_dialog_factory_get_singleton (),
"gimp-controller-action-dialog",
- editor->edit_dialog);
+ editor->edit_dialog,
+ gtk_widget_get_screen (button),
+ gimp_widget_get_monitor (button));
g_signal_connect (editor->edit_dialog, "response",
G_CALLBACK (gimp_controller_editor_edit_response),
diff --git a/app/widgets/gimpcontrollerlist.c b/app/widgets/gimpcontrollerlist.c
index a35efa8..0a544bd 100644
--- a/app/widgets/gimpcontrollerlist.c
+++ b/app/widgets/gimpcontrollerlist.c
@@ -645,7 +645,9 @@ gimp_controller_list_edit_clicked (GtkWidget *button,
gimp_dialog_factory_add_foreign (gimp_dialog_factory_get_singleton (),
"gimp-controller-editor-dialog",
- dialog);
+ dialog,
+ gtk_widget_get_screen (button),
+ gimp_widget_get_monitor (button));
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
diff --git a/app/widgets/gimpdevicestatus.c b/app/widgets/gimpdevicestatus.c
index 12825ba..30abb6f 100644
--- a/app/widgets/gimpdevicestatus.c
+++ b/app/widgets/gimpdevicestatus.c
@@ -46,6 +46,7 @@
#include "gimpdialogfactory.h"
#include "gimppropwidgets.h"
#include "gimpview.h"
+#include "gimpwidgets-utils.h"
#include "gimpwindowstrategy.h"
#include "gimp-intl.h"
@@ -465,5 +466,6 @@ gimp_device_status_view_clicked (GtkWidget *widget,
status->gimp,
dialog_factory,
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
identifier);
}
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index 04e743a..a386d91 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -441,6 +441,7 @@ gimp_dialog_factory_dialog_sane (GimpDialogFactory *factory,
static GtkWidget *
gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpContext *context,
GimpUIManager *ui_manager,
const gchar *identifier,
@@ -500,6 +501,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
*/
dock = gimp_dock_with_window_new (factory,
screen,
+ monitor,
FALSE /*toolbox*/);
dockbook = gimp_dockbook_new (factory->p->menu_factory);
@@ -513,6 +515,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
dock_window = gimp_dialog_factory_dialog_new (factory,
screen,
+ monitor,
NULL /*ui_manager*/,
"gimp-toolbox-window",
-1 /*view_size*/,
@@ -618,7 +621,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
}
if (dialog)
- gimp_dialog_factory_add_dialog (factory, dialog);
+ gimp_dialog_factory_add_dialog (factory, dialog, screen, monitor);
}
/* Finally, if we found an existing dialog or created a new one, raise it.
@@ -689,6 +692,7 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
GtkWidget *
gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpUIManager *ui_manager,
const gchar *identifier,
gint view_size,
@@ -700,6 +704,7 @@ gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
return gimp_dialog_factory_dialog_new_internal (factory,
screen,
+ monitor,
factory->p->context,
ui_manager,
identifier,
@@ -774,6 +779,7 @@ gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
GtkWidget *
gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers,
gint view_size)
{
@@ -800,6 +806,7 @@ gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
dialog = gimp_dialog_factory_dialog_new_internal (factory,
screen,
+ monitor,
NULL,
NULL,
ids[i] ? ids[i] : ids[0],
@@ -842,6 +849,7 @@ gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
return gimp_dialog_factory_dialog_new_internal (factory,
gtk_widget_get_screen (GTK_WIDGET (dock)),
+ 0,
gimp_dock_get_context (dock),
gimp_dock_get_ui_manager (dock),
identifier,
@@ -853,7 +861,9 @@ gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
void
gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
- GtkWidget *dialog)
+ GtkWidget *dialog,
+ GdkScreen *screen,
+ gint monitor)
{
GimpDialogFactory *dialog_factory = NULL;
GimpDialogFactoryEntry *entry = NULL;
@@ -863,6 +873,7 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
g_return_if_fail (GTK_IS_WIDGET (dialog));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
if (g_list_find (factory->p->open_dialogs, dialog))
{
@@ -925,7 +936,13 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
gimp_session_info_is_session_managed (current_info) &&
! gtk_widget_get_visible (dialog))
{
- gimp_session_info_apply_geometry (current_info);
+ GimpGuiConfig *gui_config;
+
+ gui_config = GIMP_GUI_CONFIG (factory->p->context->gimp->config);
+
+ gimp_session_info_apply_geometry (current_info,
+ screen, monitor,
+ gui_config->restore_monitor);
}
info = current_info;
@@ -993,7 +1010,9 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
void
gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
const gchar *identifier,
- GtkWidget *dialog)
+ GtkWidget *dialog,
+ GdkScreen *screen,
+ gint monitor)
{
GimpDialogFactory *dialog_factory;
GimpDialogFactoryEntry *entry;
@@ -1002,6 +1021,7 @@ gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
g_return_if_fail (identifier != NULL);
g_return_if_fail (GTK_IS_WIDGET (dialog));
g_return_if_fail (gtk_widget_is_toplevel (dialog));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
@@ -1030,7 +1050,7 @@ gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
gimp_dialog_factory_set_widget_data (dialog, factory, entry);
- gimp_dialog_factory_add_dialog (factory, dialog);
+ gimp_dialog_factory_add_dialog (factory, dialog, screen, monitor);
}
void
@@ -1423,7 +1443,9 @@ gimp_dialog_factory_save (GimpDialogFactory *factory,
}
void
-gimp_dialog_factory_restore (GimpDialogFactory *factory)
+gimp_dialog_factory_restore (GimpDialogFactory *factory,
+ GdkScreen *screen,
+ gint monitor)
{
GList *infos;
@@ -1433,7 +1455,7 @@ gimp_dialog_factory_restore (GimpDialogFactory *factory)
if (gimp_session_info_get_open (info))
{
- gimp_session_info_restore (info, factory);
+ gimp_session_info_restore (info, factory, screen, monitor);
}
else
{
diff --git a/app/widgets/gimpdialogfactory.h b/app/widgets/gimpdialogfactory.h
index 9e05ccf..b7983b1 100644
--- a/app/widgets/gimpdialogfactory.h
+++ b/app/widgets/gimpdialogfactory.h
@@ -39,7 +39,7 @@ typedef enum
* takes the union of the set of arguments required for each type of
* widget constructor. If this set becomes too big we can consider
* passing a struct or use varargs.
- */
+ */
typedef GtkWidget * (* GimpDialogNewFunc) (GimpDialogFactory *factory,
GimpContext *context,
GimpUIManager *ui_manager,
@@ -139,6 +139,7 @@ GtkWidget * gimp_dialog_factory_find_widget (GimpDialogFactory
const gchar *identifiers);
GtkWidget * gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpUIManager *ui_manager,
const gchar *identifier,
gint view_size,
@@ -151,6 +152,7 @@ void gimp_dialog_factory_add_session_info (GimpDialogFactory
GimpSessionInfo *info);
GtkWidget * gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers,
gint view_size);
GtkWidget * gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
@@ -158,16 +160,22 @@ GtkWidget * gimp_dialog_factory_dockable_new (GimpDialogFactory
const gchar *identifier,
gint view_size);
void gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
- GtkWidget *dialog);
+ GtkWidget *dialog,
+ GdkScreen *screen,
+ gint monitor);
void gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
const gchar *identifier,
- GtkWidget *dialog);
+ GtkWidget *dialog,
+ GdkScreen *screen,
+ gint monitor);
void gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
GtkWidget *dialog);
void gimp_dialog_factory_hide_dialog (GtkWidget *dialog);
void gimp_dialog_factory_save (GimpDialogFactory *factory,
GimpConfigWriter *writer);
-void gimp_dialog_factory_restore (GimpDialogFactory *factory);
+void gimp_dialog_factory_restore (GimpDialogFactory *factory,
+ GdkScreen *screen,
+ gint monitor);
void gimp_dialog_factory_set_state (GimpDialogFactory *factory,
GimpDialogsState state);
GimpDialogsState gimp_dialog_factory_get_state (GimpDialogFactory *factory);
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index c2d99f9..c5adcb5 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -864,6 +864,7 @@ gimp_dockable_detach (GimpDockable *dockable)
dock = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (GTK_WIDGET (dockable)),
+ gimp_widget_get_monitor (GTK_WIDGET (dockable)),
FALSE /*toolbox*/);
dock_window = gimp_dock_window_from_dock (GIMP_DOCK (dock));
gtk_window_set_position (GTK_WINDOW (dock_window), GTK_WIN_POS_MOUSE);
diff --git a/app/widgets/gimpsessioninfo-dock.c b/app/widgets/gimpsessioninfo-dock.c
index 563258d..05713ec 100644
--- a/app/widgets/gimpsessioninfo-dock.c
+++ b/app/widgets/gimpsessioninfo-dock.c
@@ -270,6 +270,7 @@ GimpDock *
gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpDockContainer *dock_container)
{
gint n_books = 0;
@@ -283,6 +284,7 @@ gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
dock = gimp_dialog_factory_dialog_new (factory,
screen,
+ monitor,
ui_manager,
dock_info->dock_type,
-1 /*view_size*/,
diff --git a/app/widgets/gimpsessioninfo-dock.h b/app/widgets/gimpsessioninfo-dock.h
index f762ec7..7dee2b0 100644
--- a/app/widgets/gimpsessioninfo-dock.h
+++ b/app/widgets/gimpsessioninfo-dock.h
@@ -58,6 +58,7 @@ GimpSessionInfoDock * gimp_session_info_dock_from_widget (GimpDock *
GimpDock * gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpDockContainer *dock_container);
diff --git a/app/widgets/gimpsessioninfo-private.h b/app/widgets/gimpsessioninfo-private.h
index 31ea9a3..bf44b98 100644
--- a/app/widgets/gimpsessioninfo-private.h
+++ b/app/widgets/gimpsessioninfo-private.h
@@ -35,6 +35,7 @@ struct _GimpSessionInfoPrivate
gint height;
gboolean right_align;
gboolean bottom_align;
+ gint monitor;
/* only valid while restoring and saving the session */
gboolean open;
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index dd940c7..0538790 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -54,6 +54,7 @@ enum
SESSION_INFO_FACTORY_ENTRY,
SESSION_INFO_POSITION,
SESSION_INFO_SIZE,
+ SESSION_INFO_MONITOR,
SESSION_INFO_OPEN,
SESSION_INFO_AUX,
SESSION_INFO_DOCK,
@@ -62,6 +63,7 @@ enum
};
#define DEFAULT_SCREEN -1
+#define DEFAULT_MONITOR -1
typedef struct
@@ -69,6 +71,7 @@ typedef struct
GimpSessionInfo *info;
GimpDialogFactory *factory;
GdkScreen *screen;
+ gint monitor;
GtkWidget *dialog;
} GimpRestoreDocksData;
@@ -116,7 +119,9 @@ gimp_session_info_init (GimpSessionInfo *info)
info->p = G_TYPE_INSTANCE_GET_PRIVATE (info,
GIMP_TYPE_SESSION_INFO,
GimpSessionInfoPrivate);
- info->p->screen = DEFAULT_SCREEN;
+
+ info->p->monitor = DEFAULT_MONITOR;
+ info->p->screen = DEFAULT_SCREEN;
}
static void
@@ -191,6 +196,13 @@ gimp_session_info_serialize (GimpConfig *config,
gimp_config_writer_close (writer);
}
+ if (info->p->monitor != DEFAULT_MONITOR)
+ {
+ gimp_config_writer_open (writer, "monitor");
+ gimp_config_writer_printf (writer, "%d", info->p->monitor);
+ gimp_config_writer_close (writer);
+ }
+
if (info->p->open)
{
gimp_config_writer_open (writer, "open-on-exit");
@@ -262,6 +274,8 @@ gimp_session_info_deserialize (GimpConfig *config,
GINT_TO_POINTER (SESSION_INFO_POSITION));
g_scanner_scope_add_symbol (scanner, scope_id, "size",
GINT_TO_POINTER (SESSION_INFO_SIZE));
+ g_scanner_scope_add_symbol (scanner, scope_id, "monitor",
+ GINT_TO_POINTER (SESSION_INFO_MONITOR));
g_scanner_scope_add_symbol (scanner, scope_id, "open-on-exit",
GINT_TO_POINTER (SESSION_INFO_OPEN));
g_scanner_scope_add_symbol (scanner, scope_id, "aux-info",
@@ -330,6 +344,12 @@ gimp_session_info_deserialize (GimpConfig *config,
goto error;
break;
+ case SESSION_INFO_MONITOR:
+ token = G_TOKEN_INT;
+ if (! gimp_scanner_parse_int (scanner, &info->p->monitor))
+ goto error;
+ break;
+
case SESSION_INFO_OPEN:
info->p->open = TRUE;
@@ -466,6 +486,7 @@ gimp_session_info_restore_docks (GimpRestoreDocksData *data)
GimpSessionInfo *info = data->info;
GimpDialogFactory *factory = data->factory;
GdkScreen *screen = data->screen;
+ gint monitor = data->monitor;
GtkWidget *dialog = data->dialog;
GList *iter;
@@ -484,6 +505,7 @@ gimp_session_info_restore_docks (GimpRestoreDocksData *data)
GTK_WIDGET (gimp_session_info_dock_restore (dock_info,
factory,
screen,
+ monitor,
GIMP_DOCK_CONTAINER (dialog)));
if (dock && dock_info->position != 0)
@@ -524,25 +546,30 @@ gimp_session_info_new (void)
void
gimp_session_info_restore (GimpSessionInfo *info,
- GimpDialogFactory *factory)
+ GimpDialogFactory *factory,
+ GdkScreen *screen,
+ gint monitor)
{
- GtkWidget *dialog = NULL;
- GdkDisplay *display = NULL;
- GdkScreen *screen = NULL;
- GimpRestoreDocksData *data = NULL;
+ GtkWidget *dialog = NULL;
+ GimpRestoreDocksData *data;
g_return_if_fail (GIMP_IS_SESSION_INFO (info));
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
g_object_ref (info);
- display = gdk_display_get_default ();
-
if (info->p->screen != DEFAULT_SCREEN)
- screen = gdk_display_get_screen (display, info->p->screen);
+ {
+ GdkDisplay *display;
+ GdkScreen *info_screen;
+
+ display = gdk_display_get_default ();
+ info_screen = gdk_display_get_screen (display, info->p->screen);
- if (! screen)
- screen = gdk_display_get_default_screen (display);
+ if (info_screen)
+ screen = info_screen;
+ }
info->p->open = FALSE;
info->p->screen = DEFAULT_SCREEN;
@@ -552,6 +579,7 @@ gimp_session_info_restore (GimpSessionInfo *info,
{
dialog = info->p->factory_entry->restore_func (factory,
screen,
+ monitor,
info);
}
@@ -571,106 +599,69 @@ gimp_session_info_restore (GimpSessionInfo *info,
data->info = g_object_ref (info);
data->factory = g_object_ref (factory);
data->screen = g_object_ref (screen);
- data->dialog = g_object_ref (dialog);
+ data->monitor = monitor;
+ data->dialog = dialog ? g_object_ref (dialog) : NULL;
g_idle_add ((GSourceFunc) gimp_session_info_restore_docks, data);
g_object_unref (info);
}
-/* This function mostly lifted from
- * gtk+/gdk/gdkscreen.c:gdk_screen_get_monitor_at_window()
- */
-static gint
-gimp_session_info_get_appropriate_monitor (GdkScreen *screen,
- gint x,
- gint y,
- gint w,
- gint h)
-{
- GdkRectangle rect;
- gint area = 0;
- gint monitor = -1;
- gint num_monitors;
- gint i;
-
- rect.x = x;
- rect.y = y;
- rect.width = w;
- rect.height = h;
-
- num_monitors = gdk_screen_get_n_monitors (screen);
-
- for (i = 0; i < num_monitors; i++)
- {
- GdkRectangle geometry;
-
- gdk_screen_get_monitor_geometry (screen, i, &geometry);
-
- if (gdk_rectangle_intersect (&rect, &geometry, &geometry) &&
- geometry.width * geometry.height > area)
- {
- area = geometry.width * geometry.height;
- monitor = i;
- }
- }
-
- if (monitor >= 0)
- return monitor;
- else
- return gdk_screen_get_monitor_at_point (screen,
- rect.x + rect.width / 2,
- rect.y + rect.height / 2);
-}
-
/**
* gimp_session_info_apply_geometry:
* @info:
+ * @screen:
+ * @current_monitor:
*
* Apply the geometry stored in the session info object to the
* associated widget.
**/
void
-gimp_session_info_apply_geometry (GimpSessionInfo *info)
+gimp_session_info_apply_geometry (GimpSessionInfo *info,
+ GdkScreen *screen,
+ gint current_monitor,
+ gboolean apply_stored_monitor)
{
- GdkScreen *screen;
GdkRectangle rect;
gchar geom[32];
gint monitor;
- gboolean use_size;
g_return_if_fail (GIMP_IS_SESSION_INFO (info));
g_return_if_fail (GTK_IS_WINDOW (info->p->widget));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
- screen = gtk_widget_get_screen (info->p->widget);
-
- use_size = (gimp_session_info_get_remember_size (info) &&
- info->p->width > 0 &&
- info->p->height > 0);
+ monitor = current_monitor;
- if (use_size)
+ if (apply_stored_monitor)
{
- monitor = gimp_session_info_get_appropriate_monitor (screen,
- info->p->x,
- info->p->y,
- info->p->width,
- info->p->height);
- }
- else
- {
- monitor = gdk_screen_get_monitor_at_point (screen, info->p->x, info->p->y);
+ gint n_monitors;
+
+ n_monitors = gdk_screen_get_n_monitors (screen);
+
+ if (info->p->monitor != DEFAULT_MONITOR &&
+ info->p->monitor < n_monitors)
+ {
+ monitor = info->p->monitor;
+ }
+ else
+ {
+ monitor = gdk_screen_get_primary_monitor (screen);
+ }
}
gdk_screen_get_monitor_geometry (screen, monitor, &rect);
+ 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));
+ 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));
+ rect.y,
+ rect.y + rect.height - (info->p->height > 0 ?
+ info->p->height : 128));
if (info->p->right_align && info->p->bottom_align)
{
@@ -691,15 +682,19 @@ gimp_session_info_apply_geometry (GimpSessionInfo *info)
gtk_window_parse_geometry (GTK_WINDOW (info->p->widget), geom);
- if (use_size)
- gtk_window_set_default_size (GTK_WINDOW (info->p->widget),
- info->p->width, info->p->height);
+ if (gimp_session_info_get_remember_size (info) &&
+ info->p->width > 0 &&
+ info->p->height > 0)
+ {
+ gtk_window_set_default_size (GTK_WINDOW (info->p->widget),
+ info->p->width, info->p->height);
+ }
/* Window managers and windowing systems suck. They have their own
* ideas about WM standards and when it's appropriate to honor
* user/application-set window positions and when not. Therefore,
* use brute force and "manually" position dialogs whenever they
- * are shown. This is important especially for transient dialog,
+ * are shown. This is important especially for transient dialogs,
* because window managers behave even "smarter" then...
*/
if (GTK_IS_DIALOG (info->p->widget))
@@ -721,15 +716,19 @@ gimp_session_info_read_geometry (GimpSessionInfo *info,
GdkEventConfigure *cevent)
{
GdkWindow *window;
+ GdkScreen *screen = gtk_widget_get_screen (info->p->widget);
g_return_if_fail (GIMP_IS_SESSION_INFO (info));
g_return_if_fail (GTK_IS_WINDOW (info->p->widget));
window = gtk_widget_get_window (info->p->widget);
+ screen = gtk_widget_get_screen (info->p->widget);
if (window)
{
- gint x, y;
+ gint x, y;
+ gint monitor;
+ GdkRectangle geometry;
gdk_window_get_root_origin (window, &x, &y);
@@ -740,6 +739,14 @@ gimp_session_info_read_geometry (GimpSessionInfo *info,
info->p->x = MAX (0, x);
info->p->y = MAX (0, y);
+ monitor = gdk_screen_get_monitor_at_point (screen,
+ info->p->x, info->p->y);
+ gdk_screen_get_monitor_geometry (screen, monitor, &geometry);
+
+ /* Always store window coordinates relative to the monitor */
+ info->p->x -= geometry.x;
+ info->p->y -= geometry.y;
+
if (gimp_session_info_get_remember_size (info))
{
int width;
@@ -768,6 +775,11 @@ gimp_session_info_read_geometry (GimpSessionInfo *info,
info->p->width = 0;
info->p->height = 0;
}
+
+ info->p->monitor = DEFAULT_MONITOR;
+
+ if (monitor != gdk_screen_get_primary_monitor (screen))
+ info->p->monitor = monitor;
}
info->p->open = FALSE;
@@ -806,7 +818,6 @@ gimp_session_info_read_geometry (GimpSessionInfo *info,
if (info->p->open)
{
GdkDisplay *display = gtk_widget_get_display (info->p->widget);
- GdkScreen *screen = gtk_widget_get_screen (info->p->widget);
if (screen != gdk_display_get_default_screen (display))
info->p->screen = gdk_screen_get_number (screen);
diff --git a/app/widgets/gimpsessioninfo.h b/app/widgets/gimpsessioninfo.h
index 5f0c88f..c631f80 100644
--- a/app/widgets/gimpsessioninfo.h
+++ b/app/widgets/gimpsessioninfo.h
@@ -60,8 +60,13 @@ struct _GimpSessionInfoClass
GType gimp_session_info_get_type (void) G_GNUC_CONST;
GimpSessionInfo * gimp_session_info_new (void);
void gimp_session_info_restore (GimpSessionInfo *info,
- GimpDialogFactory *factory);
-void gimp_session_info_apply_geometry (GimpSessionInfo *info);
+ GimpDialogFactory *factory,
+ GdkScreen *screen,
+ gint monitor);
+void gimp_session_info_apply_geometry (GimpSessionInfo *info,
+ GdkScreen *screen,
+ gint
current_monitor,
+ gboolean
apply_stored_monitor);
void gimp_session_info_read_geometry (GimpSessionInfo *info,
GdkEventConfigure *cevent);
void gimp_session_info_get_info (GimpSessionInfo *info);
diff --git a/app/widgets/gimptoolbox-image-area.c b/app/widgets/gimptoolbox-image-area.c
index d4965d1..98eec1b 100644
--- a/app/widgets/gimptoolbox-image-area.c
+++ b/app/widgets/gimptoolbox-image-area.c
@@ -31,12 +31,12 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
-#include "gimpdialogfactory.h"
#include "gimpdnd.h"
#include "gimpview.h"
#include "gimptoolbox.h"
#include "gimptoolbox-image-area.h"
#include "gimpwindowstrategy.h"
+#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@@ -52,6 +52,7 @@ image_preview_clicked (GtkWidget *widget,
context->gimp,
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-image-list|gimp-image-grid");
}
diff --git a/app/widgets/gimptoolbox-indicator-area.c b/app/widgets/gimptoolbox-indicator-area.c
index 32dcdab..48b3207 100644
--- a/app/widgets/gimptoolbox-indicator-area.c
+++ b/app/widgets/gimptoolbox-indicator-area.c
@@ -33,11 +33,11 @@
#include "core/gimpgradient.h"
#include "core/gimppattern.h"
-#include "gimpdialogfactory.h"
#include "gimpdnd.h"
#include "gimpview.h"
#include "gimptoolbox.h"
#include "gimptoolbox-indicator-area.h"
+#include "gimpwidgets-utils.h"
#include "gimpwindowstrategy.h"
#include "gimp-intl.h"
@@ -60,6 +60,7 @@ brush_preview_clicked (GtkWidget *widget,
context->gimp,
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-brush-grid|gimp-brush-list");
}
@@ -86,6 +87,7 @@ pattern_preview_clicked (GtkWidget *widget,
context->gimp,
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-pattern-grid|gimp-pattern-list");
}
@@ -112,6 +114,7 @@ gradient_preview_clicked (GtkWidget *widget,
context->gimp,
gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-gradient-list|gimp-gradient-grid");
}
diff --git a/app/widgets/gimptoolpalette.c b/app/widgets/gimptoolpalette.c
index 3b61c0d..d5bd5e2 100644
--- a/app/widgets/gimptoolpalette.c
+++ b/app/widgets/gimptoolpalette.c
@@ -31,7 +31,6 @@
#include "core/gimpcontext.h"
#include "core/gimptoolinfo.h"
-#include "gimpdialogfactory.h"
#include "gimptoolbox.h"
#include "gimptoolpalette.h"
#include "gimpuimanager.h"
@@ -361,6 +360,7 @@ gimp_tool_palette_tool_button_press (GtkWidget *widget,
context->gimp,
gimp_dock_get_dialog_factory (dock),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
"gimp-tool-options");
}
diff --git a/app/widgets/gimpviewablebox.c b/app/widgets/gimpviewablebox.c
index 47a5f14..61fd5d0 100644
--- a/app/widgets/gimpviewablebox.c
+++ b/app/widgets/gimpviewablebox.c
@@ -38,6 +38,7 @@
#include "gimpviewablebutton.h"
#include "gimpviewablebox.h"
#include "gimpviewrenderergradient.h"
+#include "gimpwidgets-utils.h"
#include "gimpwindowstrategy.h"
#include "gimp-intl.h"
@@ -632,6 +633,7 @@ gimp_viewable_box_edit_clicked (GtkWidget *widget,
button->context->gimp,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (widget),
+ gimp_widget_get_monitor (widget),
editor_id);
}
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 8eed9b8..e4133bc 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1145,6 +1145,7 @@ gimp_highlight_widget (GtkWidget *widget,
GtkWidget *
gimp_dock_with_window_new (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
gboolean toolbox)
{
GtkWidget *dock_window;
@@ -1159,7 +1160,7 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
* dock window before the dock because the dock has a dependency to
* the ui manager in the dock window
*/
- dock_window = gimp_dialog_factory_dialog_new (factory, screen,
+ dock_window = gimp_dialog_factory_dialog_new (factory, screen, monitor,
NULL /*ui_manager*/,
(toolbox ?
"gimp-toolbox-window" :
@@ -1171,6 +1172,7 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
dock = gimp_dialog_factory_dialog_new (factory,
screen,
+ monitor,
ui_manager,
(toolbox ?
"gimp-toolbox" :
@@ -1337,3 +1339,30 @@ gimp_session_write_position (GimpConfigWriter *writer,
g_type_class_unref (klass);
}
+
+gint
+gimp_widget_get_monitor (GtkWidget *widget)
+{
+ GdkWindow *window;
+ GdkScreen *screen;
+ GtkAllocation allocation;
+ gint x, y;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ window = gtk_widget_get_window (widget);
+ screen = gtk_widget_get_screen (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (window)
+ gdk_window_get_origin (window, &x, &y);
+ else
+ gdk_display_get_pointer (gdk_display_get_default (),
+ NULL, &x, &y, NULL);
+
+ x += allocation.x + allocation.width / 2;
+ y += allocation.y + allocation.height / 2;
+
+ return gdk_screen_get_monitor_at_point (screen, x, y);
+}
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index e6390be..3b9710a 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -91,6 +91,7 @@ void gimp_highlight_widget (GtkWidget *widget
gboolean highlight);
GtkWidget * gimp_dock_with_window_new (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
gboolean toolbox);
GtkWidget * gimp_tools_get_tool_options_gui (GimpToolOptions *tool_options);
void gimp_tools_set_tool_options_gui (GimpToolOptions *tool_options,
@@ -99,8 +100,11 @@ void gimp_tools_set_tool_options_gui (GimpToolOptions *tool_o
void gimp_widget_flush_expose (GtkWidget *widget);
const gchar * gimp_print_event (const GdkEvent *event);
+
void gimp_session_write_position (GimpConfigWriter *writer,
gint position);
+gint gimp_widget_get_monitor (GtkWidget *widget);
+
#endif /* __GIMP_WIDGETS_UTILS_H__ */
diff --git a/app/widgets/gimpwindowstrategy.c b/app/widgets/gimpwindowstrategy.c
index e29dfde..f35ced5 100644
--- a/app/widgets/gimpwindowstrategy.c
+++ b/app/widgets/gimpwindowstrategy.c
@@ -71,6 +71,7 @@ gimp_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
Gimp *gimp,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers)
{
GimpWindowStrategyInterface *iface;
@@ -84,6 +85,7 @@ gimp_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy,
gimp,
factory,
screen,
+ monitor,
identifiers);
return NULL;
diff --git a/app/widgets/gimpwindowstrategy.h b/app/widgets/gimpwindowstrategy.h
index bbfdacb..2193453 100644
--- a/app/widgets/gimpwindowstrategy.h
+++ b/app/widgets/gimpwindowstrategy.h
@@ -39,6 +39,7 @@ struct _GimpWindowStrategyInterface
Gimp *gimp,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers);
};
@@ -48,6 +49,7 @@ GtkWidget * gimp_window_strategy_show_dockable_dialog (GimpWindowStrategy *strat
Gimp *gimp,
GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
const gchar *identifiers);
diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h
index 2ecd232..eda8634 100644
--- a/app/widgets/widgets-types.h
+++ b/app/widgets/widgets-types.h
@@ -265,6 +265,7 @@ typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
typedef GtkWidget * (* GimpDialogRestoreFunc) (GimpDialogFactory *factory,
GdkScreen *screen,
+ gint monitor,
GimpSessionInfo *info);
typedef void (* GimpActionGroupSetupFunc) (GimpActionGroup *group);
typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *group,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]