[gtk+] viewport: Implement clipping for picking
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] viewport: Implement clipping for picking
- Date: Sun, 5 Nov 2017 06:19:46 +0000 (UTC)
commit 73077c4e904675be56b0b7c2e0f6ad4ebec3c3e6
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 5 07:17:36 2017 +0100
viewport: Implement clipping for picking
This is necessary because picking is no longer automatically constrained
to a widget's box. So all clipping widgets need to constrain their
clipping, too.
This patch does that for GtkViewport only.
gtk/gtkviewport.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index cb47726..d5ccf27 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -198,6 +198,25 @@ viewport_set_adjustment_values (GtkViewport *viewport,
viewport_size);
}
+static GtkWidget *
+gtk_viewport_pick (GtkWidget *widget,
+ double x,
+ double y)
+{
+ if (x >= 0 && x <= gtk_widget_get_width (widget) &&
+ y >= 0 && y <= gtk_widget_get_height(widget))
+ {
+ return GTK_WIDGET_CLASS (gtk_viewport_parent_class)->pick (widget, x, y);
+ }
+ else
+ {
+ if (gtk_widget_contains (widget, x, y))
+ return widget;
+ else
+ return NULL;
+ }
+}
+
static void
gtk_viewport_measure (GtkWidget *widget,
GtkOrientation orientation,
@@ -236,6 +255,7 @@ gtk_viewport_class_init (GtkViewportClass *class)
widget_class->snapshot = gtk_viewport_snapshot;
widget_class->size_allocate = gtk_viewport_size_allocate;
widget_class->measure = gtk_viewport_measure;
+ widget_class->pick = gtk_viewport_pick;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_VIEWPORT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]