Thanks for all of the replies. Took a while to puzzle it all together, but it seems to be working now:
The handlers for the drag events now look something like:
static void drag_begin(GtkGestureDrag *gesture, double x, double y,
GtkWidget *area) {
// First check if the event sequence is already handled by the stylus gesture; if not
// we will handle is here; if it is deny it
GdkEventSequence* sequence = gtk_gesture_get_last_updated_sequence(GTK_GESTURE(gesture));
if (gtk_gesture_get_sequence_state(GTK_GESTURE(stylus), sequence) == GTK_EVENT_SEQUENCE_CLAIMED) {
gtk_gesture_set_sequence_state(GTK_GESTURE(gesture), sequence, GTK_EVENT_SEQUENCE_DENIED);
} else {
// handle event
}
}
Those of the stylus as:
static void stylus_down(GtkGestureStylus* gesture, double x, double y, GtkWidget* area) {
double pressure;
// handle event
// Claim the event sequence; the drag gesture should not handle it
GdkEventSequence* sequence = gtk_gesture_get_last_updated_sequence(GTK_GESTURE(gesture));
gtk_gesture_set_sequence_state(GTK_GESTURE(gesture), sequence, GTK_EVENT_SEQUENCE_CLAIMED);
}
I also had to add the stylus gesture after adding the drag gesture as event controller to the drawing area. Am I right in observing the the lastly added event controller is called first?
The full example can be found as a gist here: gtk4_custom_draw_example_with_stylus.cpp · GitHub . Please let me know if you see me doing stupid things.
Thanks again for the help.