Skip to content

refactor internal surface API

Benjamin Otte requested to merge wip/otte/surface-surgery into main

The goal here is to add late initialization code to GdkSurface::constructed() that runs after system resources (wl_surface, HWND, XWindow) have been created. In particular, I want to bring up the renderer from here, and the graphics system needs access to those resources.

For that, I've done the following steps:

  1. Remove the x/y/width/height arguments from GdkDisplay::create_surface - they're just leftovers from GTK3, sizes are only decided on present() these days. However, some backends still may use these sizes for their internal surfaces, hopefully I've properly handled those.

  2. Moved code out of the backends' create_surface() vfunc into GdkBackendSurface::constructed. This was more complicated than it looks because many backends haven't properly split Toplevel/Popup/DragSurface yet.

  3. Make surfaces create their own frame clocks instead of passing them in via constructor. This has the benefit of allowing custom frame clocks, should we ever want to do that.

  4. Removed the GdkDisplay::create_surface vfunc with GdkDisplay::toplevel/popup_type members and just using g_object_new() with those. This is again trickier than it looks, because the internal surfaces now need custom constructors.

The actual addition of the late initialization code will follow in future MRs.

I did not test this MR on Windows or MacOS. I made sure it compiles, but because neither runs the testsuite in CI, I can't know if I've made some stupid mistakes while copying things around.

Edited by Benjamin Otte

Merge request reports