Skip to content

GTK 4 porting #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

GTK 4 porting #1

wants to merge 1 commit into from

Conversation

MostlyKIGuess
Copy link
Member

On Works

  • Most of the decision will be described on the blogs whose link I will soon update in this PR, I will be explaining the process with as much detail as I can on changes that I make
  • I will keep updating the changes, based on the commits here are few changes:

Porting.md

Progress Tracking

Completed

  • Updated gi.require_version calls to 4.0 in Python files
  • Updated import statements
  • Updated build system GIR includes (Gtk-4.0, Gdk-4.0)
  • Fixed GdkEvent opaque struct access in sugar-event-controller.c
  • Fixed GTK 4 event handling in all event controllers
  • Migrated from GdkPoint to custom SugarPoint structure

In Progress

  • Find and update remaining 3.0 version references
  • Fix eggaccelerator errors

TODO

  • Replace GtkToolbar with GtkBox
  • Migrate GtkEventBox to GtkWidget + EventControllers
  • Update GtkContainer usage to new child management
  • Convert draw() methods to snapshot()
  • Update size request/allocation APIs
  • Replace widget "event" signal with proper event controllers

Breaking Changes

  • GdkEvent Opaque Structure: In GTK 4, GdkEvent structs are now opaque and immutable. Direct field access like event->type and event->grab_broken.keyboard is no longer allowed.

  • GDK_GRAB_BROKEN Event Removed: The GDK_GRAB_BROKEN event type and related grab broken handling has been removed/changed in GTK 4.

  • GdkPoint Removed: The GdkPoint structure was removed in GTK 4.

  • Event Coordinate Access: Direct access to event coordinates changed in GTK 4.

  • Widget "event" Signal: The generic widget "event" signal is deprecated in favor of specific event controllers.

Build Status

  • Last successful build: Pending - working on build system updates
  • Current blockers: Need to update configure.ac and remaining GTK 3.0 references

- Migrate event controllers to GTK 4 API
- Fix GdkEvent opaque struct access across all event controllers
- Replace direct field access with GTK 4 accessor functions:
- event->type → gdk_event_get_event_type()
- event->touch.x/y → gdk_event_get_position()
- event->grab_broken → removed (GTK 4 auto-manages grabs)
- Replace deprecated GdkPoint with custom SugarPoint structure
- Update timeout functions: gdk_threads_add_timeout() → g_timeout_add()
- Remove GDK_GRAB_BROKEN handling (not needed in GTK 4)

Hopefully this resolves the event handling issues in GTK 4.
@chimosky
Copy link
Member

chimosky commented Jun 4, 2025

Haven't reviewed yet, most of your opening comment should be in your commit message, that gets preserved by git which is what we want.

You've also opened the PR from the main branch, that's not our usual workflow.

@MostlyKIGuess
Copy link
Member Author

Haven't reviewed yet, most of your opening comment should be in your commit message, that gets preserved by git which is what we want.

So is the current commit, is that fine? I am not sure what exactly to change in that, I am just writing what I did and in the description about stuff I changed

You've also opened the PR from the main branch, that's not our usual workflow.

Correct, I will close that.

@chimosky
Copy link
Member

chimosky commented Jun 5, 2025

So is the current commit, is that fine? I am not sure what exactly to change in that, I am just writing what I did and in the description about stuff I changed

I haven't reviewed the commit, just looked at the commit message and your opening comment.

Look at making commits if you haven't before now.

Your current commit message is bland and monotonic, and for the change you're making it'll be great if it wasn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants