[gimp/gtk3-port: 212/228] 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: 212/228] app: port GimpHistogramView to gdk_device_grab()/ungrab()
- Date: Mon, 14 Jan 2013 01:17:52 +0000 (UTC)
commit 46000d32b5650ff448bbc33c2602f182294db5cb
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 | 36 +++++++++++++++++++++++++-----------
app/widgets/gimphistogramview.h | 2 ++
2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c
index 7981675..ad7578b 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -586,12 +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;
+ }
- gtk_grab_add (widget);
+ view->grab_device = device;
gtk_widget_get_allocation (widget, &allocation);
@@ -613,11 +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;
- gtk_grab_remove (widget);
+ gdk_device_ungrab (view->grab_device, bevent->time);
start = view->start;
end = view->end;
@@ -640,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]