diff options
author | Matthias Clasen <mclasen@redhat.com> | 2023-04-09 08:28:26 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2023-04-21 09:14:12 +0200 |
commit | 4e340afce07097b4459b6ee16934cce76201c14b (patch) | |
tree | 6596997ae3877b8bf596eca2ea75fe076389c72a | |
parent | 7d634f8671e379e6de958a1e6fb6b77cd3fa8289 (diff) | |
download | gtk+-4e340afce07097b4459b6ee16934cce76201c14b.tar.gz |
gtk-demo: Work without stylus
In the paint demo, don't assume that the event
backlog contains pressure. It won't, if we are
working with a plain old mouse.
-rw-r--r-- | demos/gtk-demo/paint.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/demos/gtk-demo/paint.c b/demos/gtk-demo/paint.c index 59561ed7b4..b9fb350215 100644 --- a/demos/gtk-demo/paint.c +++ b/demos/gtk-demo/paint.c @@ -263,7 +263,7 @@ drawing_area_apply_stroke (DrawingArea *area, double y, double pressure) { - if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER) + if (tool && gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER) { cairo_set_line_width (area->cr, 10 * pressure * area->brush_size); cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT); @@ -314,7 +314,9 @@ stylus_gesture_motion (GtkGestureStylus *gesture, drawing_area_apply_stroke (area, tool, backlog[i].axes[GDK_AXIS_X], backlog[i].axes[GDK_AXIS_Y], - backlog[i].axes[GDK_AXIS_PRESSURE]); + backlog[i].flags & GDK_AXIS_FLAG_PRESSURE + ? backlog[i].axes[GDK_AXIS_PRESSURE] + : 1); } g_free (backlog); |