[gtk+] examples: Use GdkEvent API
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] examples: Use GdkEvent API
- Date: Tue, 19 Sep 2017 17:18:51 +0000 (UTC)
commit d5d0ee6f9d87a611b0f47dd5cd4ae0dc68f22946
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Aug 28 19:05:31 2017 -0400
examples: Use GdkEvent API
examples/drawing.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/examples/drawing.c b/examples/drawing.c
index dfd7dbc..59d8bea 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]