diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-08-28 19:05:31 -0400 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-09-19 18:39:03 +0200 |
commit | d5d0ee6f9d87a611b0f47dd5cd4ae0dc68f22946 (patch) | |
tree | 0e13a723760df389fde2b719f95639bd47937335 /examples | |
parent | 880d44aa4872a0d0923289ce1c3c4a0fe33b424d (diff) | |
download | gtk+-d5d0ee6f9d87a611b0f47dd5cd4ae0dc68f22946.tar.gz |
examples: Use GdkEvent API
Diffstat (limited to 'examples')
-rw-r--r-- | examples/drawing.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/examples/drawing.c b/examples/drawing.c index dfd7dbc863..59d8bea026 100644 --- a/examples/drawing.c +++ b/examples/drawing.c @@ -82,15 +82,21 @@ button_press_event_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + guint button; + double x, y; + /* paranoia check, in case we haven't gotten a configure event */ if (surface == NULL) return FALSE; - if (event->button == GDK_BUTTON_PRIMARY) + gdk_event_get_button ((GdkEvent *)event, &button); + gdk_event_get_coords ((GdkEvent *)event, &x, &y); + + if (button == GDK_BUTTON_PRIMARY) { - draw_brush (widget, event->x, event->y); + draw_brush (widget, x, y); } - else if (event->button == GDK_BUTTON_SECONDARY) + else if (button == GDK_BUTTON_SECONDARY) { clear_surface (); gtk_widget_queue_draw (widget); @@ -109,12 +115,18 @@ motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer data) { + double x, y; + GdkModifierType state; + /* paranoia check, in case we haven't gotten a configure event */ if (surface == NULL) return FALSE; - if (event->state & GDK_BUTTON1_MASK) - draw_brush (widget, event->x, event->y); + gdk_event_get_state ((GdkEvent *)event, &state); + gdk_event_get_coords ((GdkEvent *)event, &x, &y); + + if (state & GDK_BUTTON1_MASK) + draw_brush (widget, x, y); /* We've handled it, stop processing */ return TRUE; |