flathub / com.mattermost.Desktop

https://flathub.org/apps/details/com.mattermost.Desktop
8 stars 11 forks source link

Added proper opt-in Wayland support #117

Open danilown opened 11 months ago

danilown commented 11 months ago

Using the same approach from Joplin Flatpak for Wayland support.

flathubbot commented 11 months ago

Started test build 89249

flathubbot commented 11 months ago

Build 89249 failed

flathubbot commented 11 months ago

Started test build 89250

flathubbot commented 11 months ago

Build 89250 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/71927/com.mattermost.Desktop.flatpakref
SemaiCZE commented 11 months ago

Hi @danilown,

do you have somewhere a documentation to read about Electron, Flatpak and Wayland? I can't find anything good and up-to-date. I'm using Fedora with Gnome on Wayland and everything is working fine, including HiDPI and so on. In the issue https://github.com/flathub/com.mattermost.Desktop/issues/114 someone had even problems with these "ozone" flags. For me your version is working as good as the original one. ArchWiki article mentions a bit different flags like --ozone-platform-hint=auto.

At this stage I'm not very comfortable to merge this unless I understand a bit more what it's doing and what are all the consequences. And then I'd like to put that to the flathub-beta repo (built from beta branch) first to let some people test before putting it to the master.

Thanks.

danilown commented 11 months ago

Hi @SemaiCZE,

HiDPI is not the problem in itself. The problem is on HiDPI displays that necessitate non-integer scaling.

The app is currently running under X-Wayland, so GNOME will scale it to the next integer and then downscale to the desired scaling factor, for example, 1.5x. This scaling method is what makes the applications blurry.

By enabling the ozone platform and setting it to Wayland, apps can properly scale themselves.

This patch keeps everything the same if things are already working for you and/or you are running the app under X11 because it was already running under X-Wayland (i.e., it wasn't using the Wayland socket). It will only make a difference if you enable the Wayland socket (now turned off by default because the app was not using the Wayland socket) and start it in a Wayland session. The launch script can check if the app is running under Wayland, and if yes, it will add the proper ozone flags; if not, the ozone flags aren't set, as before. It is the same as used in the Joplin flatpak, an Electron app.

The auto flag would have been perfect, as we would not need to check for the display server manually. But I think the electron version Mattermost uses doesn't support it, as the app crashes when using auto instead of wayland as the ozone platform.

I left it disabled because the Mattermost app has a bug when running under the Wayland Ozone platform. The right pane, where a chat would be, rescales when doing Alt+Tab, and a fraction of the bottom and right corners are cut, which can be annoying. But for someone reading messages more often than writing, that is fine and much less annoying than blurry text. Also, as I added in the README, this problem is fixed by reloading the window with Ctrl+R.

Some links that might be useful:

https://github.com/microsoft/vscode/issues/72759 https://www.reddit.com/r/kde/comments/lficfe/wayland_fractional_scaling_may_be_sort_of_a/ https://www.reddit.com/r/linux/comments/n05z7k/why_is_hidpi_support_on_linux_still_so_bad/

Putting it in the beta channel first isn't necessary, as the same chances have already been tested in similar apps and are an opt-in improvement. One needs to enable the Wayland socket manually. Otherwise, the app will behave the same as before.

Let me know if something needs to be better clarified.

Best Regards!

danilown commented 11 months ago

A correction: I haven't tested the --ozone-platform-hint=auto option. I've tried setting the --ozone-platform=auto, which probably doesn't exist. It might be worth the test as well. I can test it in a few days, but the PR is still okay to be merged.

SemaiCZE commented 11 months ago

Thank you, some things are getting more clear for me now. The thing is that you don't want to make native Wayland support for everybody but just for a few that will enable the wayland socket through Flatseal ... that's not quite ideal in my eyes. Mattermost Desktop seems to use quite recent Electron version, so I guess the ozone-platform-hint should be supported, it's definitely worth trying if it's the ideal long term version.

I'd still like to make it to the beta branch first. I try to include all new features there (platform updates, RC versions, ...) and I'm personally using that version on daily basis. Then you can use this version youself as well. And when the Mattermost app gets fixed with this Alt+Tab rescaling, we can include this to the master and let wayland enabled by default.

Does it sound reasonable? Will you please make a PR to the beta branch as well when you get a bit of time? Thank you.