[gtk+/wip/baedert/drawing: 18/63] button: Fix in_button checks
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 18/63] button: Fix in_button checks
- Date: Tue, 27 Jun 2017 16:52:59 +0000 (UTC)
commit 523fe3bf31086d9066b56d246c3db205721f6038
Author: Timm Bäder <mail baedert org>
Date: Sat Jun 17 09:27:03 2017 +0200
button: Fix in_button checks
The gesture coords are relative to the button's origin, so use
gtk_widget_get_own_allocation to check if the coords are inside the
button.
gtk/gtkbutton.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 5432c49..0159322 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -330,12 +330,11 @@ touch_release_in_button (GtkButton *button)
}
gdk_event_get_coords (event, &x, &y);
- gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
+ gtk_widget_get_own_allocation (GTK_WIDGET (button), &allocation);
gdk_event_free (event);
- if (x >= 0 && x <= allocation.width &&
- y >= 0 && y <= allocation.height)
+ if (gdk_rectangle_contains_point (&allocation, x, y))
return TRUE;
return FALSE;
@@ -379,10 +378,10 @@ multipress_gesture_update_cb (GtkGesture *gesture,
if (sequence != gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)))
return;
- gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
+ gtk_widget_get_own_allocation (GTK_WIDGET (button), &allocation);
gtk_gesture_get_point (gesture, sequence, &x, &y);
- in_button = (x >= 0 && y >= 0 && x < allocation.width && y < allocation.height);
+ in_button = gdk_rectangle_contains_point (&allocation, x, y);
if (priv->in_button != in_button)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]