Convert bauhaus to use GtkGestures #19523
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first step "backport" from #19448, partly to test if the conversion to gestures, needed for gtk4, could be executed already under gtk3. New helper functions are introduced to connect handlers to click and motion event controllers:
These macros do function signature validation, so at least for these it will no longer be possible to connect functions with the wrong number/type of parameters or return value to a signal.
The mouse scroll event controller is not used; it was backported to gtk3 as well, but different from gtk4 it does not use a gboolean return to indicate if the scroll has been handled. So would have to be changed (back) again on final porting. Not much point.
Since we pass through mouse drags from the histogram module to bauhaus widgets (expose and black level), that widget has been transitioned as well.
This exercise ran into some interesting consequences of mixing event controllers and handling events directly, the old gtk3 way. The way events are propagated and stopped from doing so has changed. So for example to avoid the notebook header from also processing a double-click, after a bauhaus received it, we have to test if it was directly delivered to the notebook or propagated. Otherwise double-clicking on a slider in colorbalance rgb will reset the whole page. These workarounds partially won't be needed in gtk4 and anyway would not work in the same way. So a full conversion in gtk3 now seems tedious and worthless.
This opportunity was used to thoroughly clean up bauhaus and its header:
The click gesture sends a "stopped" signal once it is clear that we are not dealing with a double-click. This was used to slightly delay updating on first click just in case a user wanted to double-click and reset. In the past this used to trigger two recalculations; now only one (or none, if we are already at the default value). It may also avoid double calcs for pen or touchscreen users, but I can't verify. Of course at the cost of a slight delay in response to a click. Scrolls and drags are not affected and are as responsive as before. Feedback welcome.