[gimp/gtk3-port: 215/223] app: port GimpHistogramView to gdk_device_grab()/ungrab()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 215/223] app: port GimpHistogramView to gdk_device_grab()/ungrab()
- Date: Thu, 3 Nov 2011 23:52:46 +0000 (UTC)
commit bb8bd203ab27c9958448b7bfb7e7f267c4fbeba2
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 3 12:48:19 2011 +0200
app: port GimpHistogramView to gdk_device_grab()/ungrab()
app/widgets/gimphistogramview.c | 39 +++++++++++++++++++++++++--------------
app/widgets/gimphistogramview.h | 2 ++
2 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c
index f459e65..e65a294 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -586,14 +586,22 @@ gimp_histogram_view_button_press (GtkWidget *widget,
{
GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget);
- if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
+ if (! view->grab_device &&
+ bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
{
- GtkAllocation allocation;
- gint width;
+ GdkDevice *device = gdk_event_get_device ((GdkEvent *) bevent);
+ GtkAllocation allocation;
+ gint width;
+
+ if (gdk_device_grab (device, gtk_widget_get_window (widget),
+ GDK_OWNERSHIP_WINDOW, FALSE,
+ GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK,
+ NULL, bevent->time) != GDK_GRAB_SUCCESS)
+ {
+ return TRUE;
+ }
- gdk_pointer_grab (gtk_widget_get_window (widget), FALSE,
- GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK,
- NULL, NULL, bevent->time);
+ view->grab_device = device;
gtk_widget_get_allocation (widget, &allocation);
@@ -615,12 +623,12 @@ gimp_histogram_view_button_release (GtkWidget *widget,
{
GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget);
- if (bevent->button == 1)
+ if (gdk_event_get_device ((GdkEvent *) bevent) == view->grab_device &&
+ bevent->button == 1)
{
gint start, end;
- gdk_display_pointer_ungrab (gtk_widget_get_display (GTK_WIDGET (view)),
- bevent->time);
+ gdk_device_ungrab (view->grab_device, bevent->time);
start = view->start;
end = view->end;
@@ -643,14 +651,17 @@ gimp_histogram_view_motion_notify (GtkWidget *widget,
GtkAllocation allocation;
gint width;
- gtk_widget_get_allocation (widget, &allocation);
+ if (gdk_event_get_device ((GdkEvent *) mevent) == view->grab_device)
+ {
+ gtk_widget_get_allocation (widget, &allocation);
- width = allocation.width - 2 * view->border_width;
+ width = allocation.width - 2 * view->border_width;
- view->start = CLAMP ((((mevent->x - view->border_width) * 256) / width),
- 0, 255);
+ view->start = CLAMP ((((mevent->x - view->border_width) * 256) / width),
+ 0, 255);
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
+ }
return TRUE;
}
diff --git a/app/widgets/gimphistogramview.h b/app/widgets/gimphistogramview.h
index 3dd810f..5b98815 100644
--- a/app/widgets/gimphistogramview.h
+++ b/app/widgets/gimphistogramview.h
@@ -42,6 +42,8 @@ struct _GimpHistogramView
gint border_width;
gint subdivisions;
+
+ GdkDevice *grab_device;
};
struct _GimpHistogramViewClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]