[gimp] app: add gimp_get_monitor_at_pointer()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_get_monitor_at_pointer()
- Date: Fri, 2 May 2014 11:25:34 +0000 (UTC)
commit 051374a1b6bbebb9f6780953db613c9111603a94
Author: Michael Natterer <mitch gimp org>
Date: Fri May 2 13:23:25 2014 +0200
app: add gimp_get_monitor_at_pointer()
and use it instead of duplicating that code several times.
app/gui/gui-message.c | 10 ++--------
app/gui/gui-vtable.c | 6 +-----
app/gui/gui.c | 5 +----
app/gui/session.c | 6 ++----
app/widgets/gimpwidgets-utils.c | 14 ++++++++++++++
app/widgets/gimpwidgets-utils.h | 1 +
6 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index 32ae146..ba7fe48 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -112,12 +112,9 @@ gui_message_error_console (Gimp *gimp,
if (! dockable)
{
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);
+ monitor = gimp_get_monitor_at_pointer (&screen);
dockable =
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
@@ -189,12 +186,9 @@ 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);
+ monitor = gimp_get_monitor_at_pointer (&screen);
return gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
screen, monitor,
diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c
index 3876f76..be513d2 100644
--- a/app/gui/gui-vtable.c
+++ b/app/gui/gui-vtable.c
@@ -252,11 +252,7 @@ gui_get_display_name (Gimp *gimp,
}
else
{
- gint x, y;
-
- gdk_display_get_pointer (gdk_display_get_default (),
- &screen, &x, &y, NULL);
- monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+ monitor = gimp_get_monitor_at_pointer (&screen);
}
*monitor_number = monitor;
diff --git a/app/gui/gui.c b/app/gui/gui.c
index 4523716..83bfd87 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -602,12 +602,9 @@ 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);
+ monitor = gimp_get_monitor_at_pointer (&screen);
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
screen, monitor,
diff --git a/app/gui/session.c b/app/gui/session.c
index 35e25cc..9aa1037 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -38,6 +38,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpsessioninfo.h"
+#include "widgets/gimpwidgets-utils.h"
#include "dialogs/dialogs.h"
@@ -318,14 +319,11 @@ void
session_restore (Gimp *gimp)
{
GdkScreen *screen;
- gint x, y;
gint monitor;
g_return_if_fail (GIMP_IS_GIMP (gimp));
- gdk_display_get_pointer (gdk_display_get_default (),
- &screen, &x, &y, NULL);
- monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+ monitor = gimp_get_monitor_at_pointer (&screen);
gimp_dialog_factory_restore (gimp_dialog_factory_get_singleton (),
screen, monitor);
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index e4133bc..502d89c 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1366,3 +1366,17 @@ gimp_widget_get_monitor (GtkWidget *widget)
return gdk_screen_get_monitor_at_point (screen, x, y);
}
+
+gint
+gimp_get_monitor_at_pointer (GdkScreen **screen)
+{
+ gint x, y;
+ gint monitor;
+
+ g_return_val_if_fail (screen != NULL, 0);
+
+ gdk_display_get_pointer (gdk_display_get_default (),
+ screen, &x, &y, NULL);
+
+ 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 3b9710a..81bf514 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -105,6 +105,7 @@ void gimp_session_write_position (GimpConfigWriter *writer
gint position);
gint gimp_widget_get_monitor (GtkWidget *widget);
+gint gimp_get_monitor_at_pointer (GdkScreen **screen);
#endif /* __GIMP_WIDGETS_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]