gtk4-prep: replace direct GdkEvent struct access with accessor functions#21544
Open
Arecsu wants to merge 1 commit into
Open
gtk4-prep: replace direct GdkEvent struct access with accessor functions#21544Arecsu wants to merge 1 commit into
GdkEvent struct access with accessor functions#21544Arecsu wants to merge 1 commit into
Conversation
Replace all direct GdkEvent struct member accesses (`event->type`, `event->button`, `event->x`, `event->y`, `event->state`, `event->keyval`, `event->time`, `event->window`, `event->scroll.direction`, `event->delta_x`/`event->delta_y`, `event->direction`, `event->hardware_keycode`, etc.) with the corresponding `gdk_event_get_*()` accessor functions via thin inline wrappers in `src/common/gdk_event_utils.h`. The wrapper functions (`dt_gdk_event_get_*`) accept `const void*` so any typed event pointer (`GdkEventButton*`, `GdkEventKey*`, etc.) can be passed without an explicit cast. They return the field value directly instead of using out-parameters. This removes ~500 direct struct accesses across 65 files. Remaining direct accesses are limited to: - Synthetic event construction (writing to `gdk_event_new()` events) - Event mutation before forwarding - Fields without GTK3 accessor functions (`configure.width`/`configure.height`, `crossing.mode`/`crossing.detail`, `key.is_modifier`) See https://docs.gtk.org/gtk4/migrating-3to4.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace all direct GdkEvent struct member accesses:
event->typeevent->buttonevent->xevent->yevent->stateevent->keyvalevent->timeevent->windowevent->scroll.directionevent->delta_x/event->delta_yevent->directionevent->hardware_keycodeWith the corresponding
gdk_event_get_*()accessor functions via thin inline wrappers insrc/common/gdk_event_utils.h.The wrapper functions (
dt_gdk_event_get_*) acceptconst void*so any typed event pointer (GdkEventButton*,GdkEventKey*, etc.) can be passed without an explicit cast. They return the field value directly instead of using out-parameters.This removes ~500 direct struct accesses across 65 files. Remaining direct accesses are limited to:
gdk_event_new()events)configure.width/configure.height,crossing.mode/crossing.detail,key.is_modifier)See https://docs.gtk.org/gtk4/migrating-3to4.html
Related: "Stop using direct access to GdkEvent structs" #15920 #20433