hugolabe / Wike

Wikipedia Reader for the GNOME Desktop
https://hugolabe.github.io/Wike/
GNU General Public License v3.0
231 stars 32 forks source link

fix adaptive headerbar for maximised state #125

Closed camelCaseNick closed 1 year ago

camelCaseNick commented 1 year ago

As the headerbar will receive its layout update when the window is (re-)allocated its default is only used for measurement of this widget.

Therefore, it should reflect the state with minimal width to properly work with the height for width way GTK uses for allocating space.

depends on and includes ceb38a3642923eef895dbc792e894151c1fdb47e from the current develop branch

fixes #122

hugolabe commented 1 year ago

Thanks @camelCaseNick !

However, the initialization of the mobile layout should not be removed (commit cce5b4c38d1ad911b8394f060eee1ec59b82d749) as an undesired effect occurs.

The problem it causes is that on the desktop the window always opens with a minimum width (605px) even though the user has set it to a smaller size. It's not a very common use case, but it shouldn't happen.

camelCaseNick commented 1 year ago

The problem it causes is that on the desktop the window always opens with a minimum width (605px) even though the user has set it to a smaller size. It's not a very common use case, but it shouldn't happen.

That does not happen to me. I have tested this on a screen with > 720px with both a start-up with of < 400px and > 720px. Also, I have tested this with a small screen with one side > 720px and the other < 720px and started Wike in portrait mode after closing it in landscape and the other way around to test this.

However, to not run into the problem you describe here, you might need my other commit. (How) Did you test this branch?

camelCaseNick commented 1 year ago

I have rearranged them to not have Wike in a potentially broken state between commits.

hugolabe commented 1 year ago

With the last change (by removing line 92) it now always boot in mobile layout, even when the window is large.

The solution to make everything work is to remove commit c2de100bd75c6d3814e27a2a35872a1825ecd04d. That is, leave window.py as it is in the develop branch and only make the change to header.py

camelCaseNick commented 1 year ago

It does not always boot into mobile_layout, because at initial allocation of the window the mobile_layout is reevaluated, because do_size_allocate is not only called, when the window is resized, but also at initial allocation, i.e. before the window is drawn the first time.

camelCaseNick commented 1 year ago

But if it makes you happy, I will drop the commit, as it is merely a cleanup, that does not change behaviour.

camelCaseNick commented 1 year ago

done

hugolabe commented 1 year ago

It does not always boot into mobile_layout, because at initial allocation of the window the mobile_layout is reevaluated, because do_size_allocate is not only called, when the window is resized, but also at initial allocation, i.e. before the window is drawn the first time.

It happens to me.

It happens because when do_size_alloctate is executed at initial allocation (with size > 720), as the mobile_layout variable is set to False it does not make the call to _set_layout

wike.webm

hugolabe commented 1 year ago

Thanks for your work!

camelCaseNick commented 1 year ago

Right, the initial _set_layout is needed indeed. And I didn't remove in my first version. Removing that was causing this issue. Because with it, it is mobile_layout = False initially and self._set_layout() in init makes sure this does not happen. Sorry, the version from four hours ago was broken indeed.

hugolabe commented 1 year ago

No problem. The important thing is that we were able to solve it. Thank you!