[gimp] app: fix gimp_widget_get_monitor()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix gimp_widget_get_monitor()
- Date: Sat, 3 May 2014 19:46:16 +0000 (UTC)
commit bb3ab4c506c52bd47dc128a5eed6d5897f74ae02
Author: Michael Natterer <mitch gimp org>
Date: Sat May 3 21:40:59 2014 +0200
app: fix gimp_widget_get_monitor()
Do the right thing for widgets that have a window when the widget is
realized, and simply call gimp_get_monitor_at_pointer() if it's not
realized.
app/widgets/gimpwidgets-utils.c | 35 +++++++++++++++++++++++------------
1 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index ad036d8..9ce8f20 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1340,26 +1340,37 @@ gimp_session_write_position (GimpConfigWriter *writer,
gint
gimp_widget_get_monitor (GtkWidget *widget)
{
- GdkWindow *window;
- GdkScreen *screen;
- GtkAllocation allocation;
- gint x, y;
+ GdkWindow *window;
+ GdkScreen *screen;
+ 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);
+ {
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gdk_window_get_origin (window, &x, &y);
+
+ if (! gtk_widget_get_has_window (widget))
+ {
+ x += allocation.x;
+ y += allocation.y;
+ }
- x += allocation.x + allocation.width / 2;
- y += allocation.y + allocation.height / 2;
+ x += allocation.x + allocation.width / 2;
+ y += allocation.y + allocation.height / 2;
+ }
+ else
+ {
+ gdk_display_get_pointer (gtk_widget_get_display (widget),
+ NULL, &x, &y, NULL);
+ }
return gdk_screen_get_monitor_at_point (screen, x, y);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]