gtk4-prep: replace direct GdkEvent struct access with accessor functions - #21544
Conversation
|
@Arecsu : This needs a conflict resolution. TIA. |
Done! |
|
The policy is to rebase and never merge master into a topic branch. Sorry should have been clear before :) Can you rebase? TIA. |
349599a to
f2d8507
Compare
|
Thank you for clarify, I didn't know. Just did it, please check! |
TurboGit
left a comment
There was a problem hiding this comment.
Not tested yet, looks good just minor comments.
f2d8507 to
421bdee
Compare
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
421bdee to
53f1ad5
Compare
|
Updated copyright headers to 2026 across all changed files. Done! |
|
@Arecsu : This introduce a regression, the zoom in/out is broken, both direction of the mouse wheel does zoom-in there is no way to zoom-out (in darkroom, shapes...). Can you fix? If this is not possible before tonight I'll revert this to let you rework this part without pressure. Just let me know, TIA. |
|
The issue #21622. |
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