summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-12-11 19:27:35 -0500
committerMatthias Clasen <mclasen@redhat.com>2017-12-11 19:27:35 -0500
commita0df3ac544b6b0b95ace91e268e34a75cfafaf6a (patch)
tree768ecb315dd64c34920ebda1dffec6991eb1c085
parent6dde66d4d8cdba559b2aa7fbf9a427745f4d1418 (diff)
downloadgtk+-wip/matthiasc/motion-controller.tar.gz
paned: Stop using motion notifywip/matthiasc/motion-controller
We can use the new motion event controller that was introduced for this purpose.
-rw-r--r--gtk/gtkpaned.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 1340f84b35..e31048c1c6 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -43,6 +43,7 @@
#include "gtkcssstylepropertyprivate.h"
#include "gtkrendericonprivate.h"
#include "gtkgizmoprivate.h"
+#include "gtkeventcontrollermotion.h"
#include <math.h>
@@ -140,6 +141,7 @@ struct _GtkPanedPrivate
GtkGesture *pan_gesture; /* Used for touch */
GtkGesture *drag_gesture; /* Used for mice */
+ GtkEventController *motion_controller;
gint child1_size;
gint drag_pos;
@@ -304,32 +306,28 @@ get_handle_area (GtkPaned *paned,
area->height += extra * 2;
}
-static gboolean
-gtk_paned_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
+static void
+gtk_paned_motion (GtkEventControllerMotion *motion,
+ double x,
+ double y,
+ GtkPaned *paned)
{
- GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned);
GdkRectangle handle_area;
- gdouble x, y;
get_handle_area (paned, &handle_area);
- if (gdk_event_get_coords ((GdkEvent *) event, &x, &y) &&
- (gdk_rectangle_contains_point (&handle_area, x, y) ||
- priv->panning))
+ if (gdk_rectangle_contains_point (&handle_area, x, y) || priv->panning)
{
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_set_cursor_from_name (widget, "col-resize");
+ gtk_widget_set_cursor_from_name (GTK_WIDGET (paned), "col-resize");
else
- gtk_widget_set_cursor_from_name (widget, "row-resize");
+ gtk_widget_set_cursor_from_name (GTK_WIDGET (paned), "row-resize");
}
else
{
- gtk_widget_set_cursor (widget, NULL);
+ gtk_widget_set_cursor (GTK_WIDGET (paned), NULL);
}
-
- return GTK_WIDGET_CLASS (gtk_paned_parent_class)->motion_notify_event (widget, event);
}
static GtkWidget *
@@ -374,7 +372,6 @@ gtk_paned_class_init (GtkPanedClass *class)
widget_class->unrealize = gtk_paned_unrealize;
widget_class->snapshot = gtk_paned_snapshot;
widget_class->focus = gtk_paned_focus;
- widget_class->motion_notify_event = gtk_paned_motion_notify;
widget_class->direction_changed = gtk_paned_direction_changed;
widget_class->pick = gtk_paned_pick;
@@ -1019,6 +1016,7 @@ gtk_paned_finalize (GObject *object)
g_clear_object (&paned->priv->pan_gesture);
g_clear_object (&paned->priv->drag_gesture);
+ g_clear_object (&paned->priv->motion_controller);
gtk_widget_unparent (priv->handle_widget);
@@ -1561,6 +1559,9 @@ gtk_paned_init (GtkPaned *paned)
connect_drag_gesture_signals (paned, gesture);
priv->drag_gesture = gesture;
+ priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (paned));
+ g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_paned_motion), paned);
+
priv->handle_widget = gtk_gizmo_new ("separator",
NULL,
NULL,