[gimp/gtk3-port: 204/235] 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: 204/235] app: port GimpHistogramView to gdk_device_grab()/ungrab()
- Date: Wed, 12 Jul 2017 21:41:19 +0000 (UTC)
commit c7f9fd29513a84e901b0bf8566fd83065fd3ec8a
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 c2699d1..e48459f 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -585,12 +585,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);
@@ -612,11 +622,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;
@@ -639,14 +650,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) * view->n_bins) / width,
- 0, view->n_bins - 1);
+ view->start = CLAMP (((mevent->x - view->border_width) * view->n_bins) / width,
+ 0, view->n_bins - 1);
- 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 cbbfdb1..c48e7e8 100644
--- a/app/widgets/gimphistogramview.h
+++ b/app/widgets/gimphistogramview.h
@@ -43,6 +43,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]