[gtk] Do not modify a const GdkEvent in place
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Do not modify a const GdkEvent in place
- Date: Tue, 26 Jun 2018 17:08:19 +0000 (UTC)
commit 73d736d800270bad8fb355b959a570b45d58ff1d
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Jun 26 17:57:29 2018 +0100
Do not modify a const GdkEvent in place
When deciding whether or not to emulate a press event, we're translating
the last event coordinates and mutating the given event structure
unconditionally.
We should modify the newly created GdkEvent copy, since it's what we're
going to use when emitting the press event.
This avoids mutating a constant GdkEvent and global state, and also
avoids a compiler warning.
gtk/gtkwidget.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 234c1302dd..2fea7f9143 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2515,7 +2515,6 @@ _gtk_widget_emulate_press (GtkWidget *widget,
gtk_widget_get_toplevel (event_widget),
x, y,
&x, &y);
- gdk_event_set_coords (event, x, y);
if (event->any.type == GDK_TOUCH_BEGIN ||
event->any.type == GDK_TOUCH_UPDATE ||
@@ -2535,8 +2534,6 @@ _gtk_widget_emulate_press (GtkWidget *widget,
press = gdk_event_new (GDK_BUTTON_PRESS);
press->any.surface = g_object_ref (event->any.surface);
press->button.time = event->motion.time;
- press->button.x = event->motion.x;
- press->button.y = event->motion.y;
press->button.x_root = event->motion.x_root;
press->button.y_root = event->motion.y_root;
press->button.state = event->motion.state;
@@ -2563,6 +2560,8 @@ _gtk_widget_emulate_press (GtkWidget *widget,
else
return;
+ gdk_event_set_coords (press, x, y);
+
press->any.send_event = TRUE;
next_child = event_widget;
parent = _gtk_widget_get_parent (next_child);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]