libui-ng / libui-ng

libui-ng: a portable GUI library for C. "libui for the next generation"
https://libui-ng.github.io/libui-ng/
MIT License
581 stars 51 forks source link

uiWindow unit tests and fixes for unix #261

Open szanni opened 6 months ago

szanni commented 6 months ago

This sadly got a lot bigger than initially anticipated but much of this code is interdependent, hence all of this at once:

Fixes for unix:

uiWindowContentSize now uses gtk_window_get_size and gtk_window_resize instead of trying to do some magic calculations on the inner container. According to the docs gtk already does a best effort calculation to report the size sans window decorations. The prior, inner container size code does not work on hidden windows and margined windows anyways and does not add anything on all systems I tested (i3wm and weston) apart from code, confusion, bugs and brittleness, hence the removal.

It is unclear to me if there was ever a good reason for doing these calculations. I could not find any documentation in the code or git log. All code related to window sizing is a best effort on all Unix systems anyways as the gtk3 docs state everywhere. I did not notice any regressions by removing all the window size calculations.

cody271 commented 6 months ago

It is unclear to me if there was ever a good reason for doing these calculations. I could not find any documentation in the code or git log. All code related to window sizing is a best effort on all Unix systems anyways as the gtk3 docs state everywhere. I did not notice any regressions by removing all the window size calculations.

👍

on all systems I tested (i3wm and weston)

Has this been tested on Wayland yet?

I will try some other DEs besides Weston.

szanni commented 6 months ago

on all systems I tested (i3wm and weston)

Has this been tested on Wayland yet?

I will try some other DEs besides Weston.

To add to that, this means the unit test work. By no means do Wayland systems honor uiWindowSetPosition in any shape or form as Wayland has no protocol for doing so. And SetContentSize only really works when increasing window size form the original on Wayland systems consistently. Tested with weston and sway+floating windows.