mate-desktop / mate-applets

Applets for use with the MATE panel
http://www.mate-desktop.org
GNU General Public License v2.0
78 stars 66 forks source link

Port all wayland-usable applets to in-process #651

Closed lukefromdc closed 1 year ago

lukefromdc commented 1 year ago

Most mate-panel applets work in wayland the same or nearly the same as on x11 after porting to in-process.

*Accessx not ported, hard dependency on x11 for keyboard handling. The standalone xkb library could offer a future way to fix this

*The battstat applets works same in x11 and wayland, save that again notifications cannot yet be used

*The charpick applet itself will function in both x11 and wayland, but the primary paste preference does not work in wayland-and even resets the gsettings preference to disable it. Fixing this is probably the job of a wayland session manager. No change in x11 behavior

*Cpufreq and drivemount work same in x11 and wayland as they did in x11 before

*Geyes not ported as the applet cannot see the pointer in wayland once it moves outside the panel due to wayland restrictions on one app accessing another's windows. This is considered a security feature in wayland as it makes clickjacking much harder. Also when in-process, geyes improperly computes pointer position as it becomes relative to the mate-panel window not the GtkPlug window used for out of process.

*mateweather, multiload,netspeed, stickynotes all seem to work the same in wayland as in x11 and no behavioral differences were noticed in (ONE user) testing

*The timer applet must be used with the dialog not the notification in wayland, as we don't have a wayland-compatable notification daemon yet and the applet will freeze on a failed notification. No change x11 behavior.

*Trash applet works same in x11 and wayland if a wayland-compatable file manager is installed

lukefromdc commented 1 year ago

Looks like an issue running a docker script not the build itself failing on the Fedora build by travis

raveit65 commented 1 year ago

No, this is a library linking error. https://app.travis-ci.com/github/mate-desktop/mate-applets/jobs/604569199#L4989

*** Warning: Linking the shared library libmate-battstat-applet.la against the

*** static library apmlib/libapm.a is not portable!

/usr/bin/ld: apmlib/libapm.a(apmlib.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

/usr/bin/ld: failed to set dynamic section sizes: bad value

collect2: error: ld returned 1 exit status

make[3]: *** [Makefile:617: libmate-battstat-applet.la] Error 1

make[3]: *** Waiting for unfinished jobs....

make[3]: Leaving directory '/rootdir/battstat'

make[2]: *** [Makefile:694: all-recursive] Error 1

make[2]: Leaving directory '/rootdir/battstat'

make[1]: *** [Makefile:583: all-recursive] Error 1

make[1]: Leaving directory '/rootdir'

make: *** [Makefile:515: all] Error 2

ld failed to run.

lukefromdc commented 1 year ago

This is a primitive mate-wayland session running, w caja managing the desktop and some of these panel applets in use in my normal configuration. Photo taken w camera due to lack of a screenshot utility for wayland on my system at this time

Mate-Wayland_6--20-2023

cwendling commented 1 year ago

@raveit65 @lukefromdc check out #652, it should help with the libapm PIC issue. The reason why the problem appears now is probably because the applet is now in-process, and thus a library (requiring PIC on many platforms, including x86_64), instead of a separate executable (which doesn't usually need PIC). Using libtool should fix all cases, as it is able to build both static and dynamic libraries, suited to the platform.

raveit65 commented 1 year ago

Just rebased with master including the fix for battstat-applet.

lukefromdc commented 1 year ago

That came from not knowing enough about the build system-and from not realizinng that library was part of the package and thus fixable without having to have another package change. Rebuilding now

lukefromdc commented 1 year ago

Just cleaned up that last commit message since a fix is in master for the warning

lukefromdc commented 1 year ago

Battstat now builds with only deprecation warnings, thanks!

raveit65 commented 1 year ago

Starting with trash-applet. Everything seems OK in x11 when build in-process. In wayfire:

raveit65 commented 1 year ago

About cpufreq-applet: Runs fine under X11 when build in-process. In wayfire:

raveit65 commented 1 year ago

charpick: runs fine under x11 when build in-process wayfire:

raveit65 commented 1 year ago

Command-applet: Works fine under x11 when build in-process wayfire:

raveit65 commented 1 year ago

Drivemount applet: Runs fine under x11 when build in-process. Wayfire:

raveit65 commented 1 year ago

Weather-applet: Works fine under x11 when build in-process Wayfire:

raveit65 commented 1 year ago

Multiload-applet: Works fine under x11 when build in-process Wayfire:

raveit65 commented 1 year ago

Netspeed-applet: Works fine under x11 when build in-process -Wayfire:

raveit65 commented 1 year ago

Sticky-notes: Works fine under x11 when build in-process Wayfire:

raveit65 commented 1 year ago

Timer-applet: Works fine under x11 when build in-process Wayfire:

raveit65 commented 1 year ago

In general it seems port to in-process is OK. We need to discuss if we need an option to build in-process/out-of-process.

There are 2 general issues for me. I am thinking both are mate-panel bugs after port to wayland. Icons in applet menus are missing and i think we lost scaling for HIDPI. Which is a huge step back for me compare to my clear and sharp x11 HIDPI desktop. Btw, maybe x11 do better scaling than wayland in general? Here it looks like it.

At least some applets needs some extra work for wayland in single future PRs.

lukefromdc commented 1 year ago

Trasg apet: For open-trash to work (st least when not in a MATE session, Caja must be running

raveit65 commented 1 year ago

Trasg apet: For open-trash to work (st least when not in a MATE session, Caja must be running

Yes, caja is running as desktop and i can delete the trash-can , but i can't open the trash can with the applet.

Btw. i am starting caja desktop and nm-applet when starting wayfire with wayfire session-command modul.

lukefromdc commented 1 year ago

The no menu icons issue is a GTK default, remember no session manager is running. This is true also of button icons, which is why I had to force override this in the applet code to make the SNI tray work. For now, adding this code to ~/.config/gtk-3.0/settings.ini will bring the icons back in wayland: gtk-menu-images = true and adding gtk-button-images = true will make sure those always show up in all GTK apps in wayland

We can either consider that a job for a future wayland settings manager, or modifiy the applets to check gsettings themselves and not wait for a session manager. Remember that mate-panel has the potential to become a popular wayland panel outside of any future MATE session.

Coding all the applets to show the icons unconditionally could be put behind wayland-only selectors (or !x11 to avoid a new dependency) in every applet here, but would force all users to show the icons. Not sure if the applets can read the gsettings prefs outside any session manager running but I suspect they probably can. This would need to be done for every applet to make the icons follow the user set show/hide preference in a standalone mate-panel in an arbitrary wl-roots supporting wayland session

raveit65 commented 1 year ago

Not sure if the applets can read the gsettings prefs outside any session manager running but I suspect they probably can.

I think so, i am using gnome gsettings keys for gtk-theme, icon-theme and windows-decoration.

lukefromdc commented 1 year ago

We need to find out why I can open the trash and you cannot. Are you starting wayfire with dbus-launch wayfire or something else? On my end caja won't work without that in wayland.

UPDATE: I just had a successful open of trash in caja with caja NOT running. I assume you are testing with the wayland-desktop branch of caja installed?

raveit65 commented 1 year ago

I am starting wayfire from gdm display-manager and it makes no different when using dbus-launch wayfire But i think i found the problem: Debugging with:

journalctl --user -b0 -f --no-tail
<cut>
.
Jul 03 18:58:09 mother.mother.loc dbus-daemon[123847]: [session uid=1003 pid=123845] Activating service name='org.gnome.Nautilus' requested by ':1.0' (uid=1003 pid=123883 comm="mate-panel")
Jul 03 18:58:09 mother.mother.loc nautilus[124739]: Connecting to org.freedesktop.Tracker3.Miner.Files
Jul 03 18:58:09 mother.mother.loc dbus-daemon[123847]: [session uid=1003 pid=123845] Successfully activated service 'org.gnome.Nautilus'
Jul 03 18:58:09 mother.mother.loc nautilus[124739]: No such backend: *
Jul 03 18:58:09 mother.mother.loc nautilus[124739]: Failed to open display

This happens when i click on open-trash-can with the applet. Seems, that wayfire use some gnome defaults in fedora and i ran in a config issue. I will dig deeper.

lukefromdc commented 1 year ago

I've had problems in the past with the trash opening the wrong file manager even inside a MATE session, due to some misconfiguration or another

raveit65 commented 1 year ago

UPDATE: I just had a successful open of trash in caja with caja NOT running. I assume you are testing with the wayland-desktop branch of caja installed?

I use this in wayfire.ini to start caja.

[autostart]
a0 = caja --force-desktop -n
a1 = nm-applet --indicator
autostart_wf_shell = false
background = wf-background
gamma = wlsunset
idle = swayidle before-sleep swaylock
notifications = mako
outputs = kanshi
panel = mate-panel
portal = /usr/libexec/xdg-desktop-portal

Not sure for what xdg-desktop-portal is good for.

raveit65 commented 1 year ago

Found this link Boycott Wayland. It breaks everything! https://gist.github.com/probonopd/9feb7c20257af5dd915e3a9f2d1f2277 :)

lukefromdc commented 1 year ago

That just shows reasons not to go wayland-only as far as I am concerned. We've seen similar calls with systemd and with GTK3 over the years, especially with anything developed by Red Hat or GNOME it seems.

We do not know what the future holds for wayland vs x11. Being able to use either one is future-proofing and widens the userbase. This does however boost the point that no compromises should be made in the x11 code to support wayland, rather the codepaths should be split.

EDIT: this may be another reason to make in-process vs out-of-process selectable at build time.

lukefromdc commented 1 year ago

NICE tip about how to start my whole wayland session in wayfire!

raveit65 commented 1 year ago

Issue with trash-applet i could fix with adding a /home/Sa-wayland/.config/mimeapps.list. For some reasons this file was missing in home dir. And i use portal = /usr/libexec/xdg-desktop-portal-gtk in wayfire.ini [autostart] portal = /usr/libexec/xdg-desktop-portal seems for flatpak installation. But the issue with missing icons in applet menus still exists after adding ~/.config/gtk-3.0/settings.ini with that content

gtk-menu-images = true
gtk-button-images = true

Applets from mate-panel package have icons in menu ie. add-server-applet. mate-panel_wayfire_aad_to_server_applet All applets from mate-applets package have missing icons, ie. multiload: mate-panel_wayfire_multiload_applet Sorry, i was to lazy to switch to english language in screenshots :)

As you can see in screenshots HIDPI-Scaling seems broken :/

lukefromdc commented 1 year ago

We have a difference in behavior, probably best to just start forcing this with a check of the relevent gsettings prefs applet by applet.

lukefromdc commented 1 year ago

Also I get a mix of launcher icons in wayland, some blurry and some not, my guess is my icon theme may be providing the good ones as .svg files

lukefromdc commented 1 year ago

Another difference in behavior is cpufreq-applet works here in wayland, but note that I have it set up in x11 not to require passphrase entry to change cpu frequencies. If your is set up to ask for a passphrase, that dialog might contain an x'ism and not be coming up

raveit65 commented 1 year ago

Another difference in behavior is cpufreq-applet works here in wayland, but note that I have it set up in x11 not to require passphrase entry to change cpu frequencies. If your is set up to ask for a passphrase, that dialog might contain an x'ism and not be coming up

I use --enable-polkit to compile mate-applets in fedora. As distro-maintainer i can't build a package without it. I guess this flag is for cpu-freq applet. Seems like the polkit daemon isn't running here.

lukefromdc commented 1 year ago

Polkit can be set up to allow changing cpu frequency without a passphrase. I've long forgotten how I did that, but it's how I originally did this back in 2015. Never had to fiddle with it. Current build options for mate-applets here are

./autogen.sh --prefix=/usr libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --enable-shared=yes --enable-static=no --disable-maintainer-mode --disable-schemas-compile --with-cpufreq-lib=cpupower

The daemon would not be started by my wayland session, so either something else is going on here or in my setup it's being silently started since the passphrase is not called for

raveit65 commented 1 year ago

Also I get a mix of launcher icons in wayland, some blurry and some not, my guess is my icon theme may be providing the good ones as .svg files

I am using mate-icon-theme for wayland and X11 session. With x11 everything is sharp with HIDIPI. So i don't think it's an icon-theme problem. But honestly i have no idea what going on here. It's not only the panel. My feeling is that whole the desktop and any application looks a bit blurred compare to X11. Would be interesting how it looks with a mir wayland implementation. Mate on wayland from Ubuntu @wmww seems not do any update since 2021. https://snapcraft.io/mate-wayland

lukefromdc commented 1 year ago

Although I'm working with Wayland, Mir is another wlroots/foreign toplevel supporting wayland compositor from what I understand. It's my intention that this work should work with anything gtk-layer-shell can be used in, just as in x11 we can use marco, metacity, compiz, IceWM or almost anything else

lukefromdc commented 1 year ago

Looks like we need to force the icons by adding

gtk-menu-images = true
gtk-button-images = true 

to the settings.ini file in each of our themes, users can still override this in ~/.config/gtk-3.0/settings.ini if desired. It works fine from the theme, and if added to the theme's settings.ini file works just fine. Only other way would be to have a settings manager running in wayland, able to force the gsettings preference globally

I've run into an ugly problem with trying to force the icons to show in the applet menus in the code: The menus are loaded using

gtk_action_group_add_actions (priv->panel_action_group,
                                  menu_entries,
                                  G_N_ELEMENTS (menu_entries),
                                  applet);

in mate_panel_applet_init() in mate-panel-applet.c and I don't know enough about Gtk Builder to pull a single GtkAction out of that so gtk_action_set_always_show_image could be applied. No way to apply it to a whole gtk_action_group so no easy way to do this. I only see gtk_image_menu_item and gtk_action having a function to force images (icons) to render.

This icon issue effects every GTK application running under wayland, so we need a global fix anyway.

lukefromdc commented 1 year ago

Got a pleasant surprise testing fractional scaling in wayfire with caja and mate-panel: worked perfectly and didn't seem to bog things down. Also using different scaling on my 1080p secondary monitor and 4K main monitor has never been a problem in wayfire.

There may come a time when we can close out feature requests for fractional scaling with "use the wayland session." Scaling in x11 is a royal mess, it seems to "just plain work" in wayland.

raveit65 commented 1 year ago

I could fix some things :) After removing outputs = kanshi from wayfire.ini the scaling factor 1.7 is persistent. During testing mate notifications in wayfire i got the error message about settings.ini in terminal. .config/gtk-3.0/settings.ini: Key file does not start with a group After adding the missing group settings to the file all icons are ther in menu.

[Settings]

gtk-menu-images = true
gtk-button-images = true

So it was my fault and really sorry about the confusion.

Btw. mate-notifications are working in wayfire when the daemon is running. /usr/libexec/mate-notification-daemon -r

But the mate-notification-daemon won't be call automaticly with notify-send.......

raveit65 commented 1 year ago

Got a pleasant surprise testing fractional scaling in wayfire with caja and mate-panel: worked perfectly and didn't seem to bog things down. Also using different scaling on my 1080p secondary monitor and 4K main monitor has never been a problem in wayfire.

There may come a time when we can close out feature requests for fractional scaling with "use the wayland session." Scaling in x11 is a royal mess, it seems to "just plain work" in wayland.

Yes, fractional scaling is very nice

lukefromdc commented 1 year ago

Just tested mir, unfortunately current mir in the form of miral-system-compositor does NOT seem to support gtk-layer-shell. Mate-panel etc act as they do in Weston. Also tested Sway, which is strictly a tiling WM/compositor and thus quite different than Marco or Compiz.

Big problem for a full session now is that Xwayland seems to be broken in Wayfire and in Sway as well, showing up as running in mate-system-monitor but not reachable by any application. Might be a wlroots issue, as wlroots has to support xwayland for it to work, and this might be partially broken.

Probably easier to find and fix this in wayfire or wlroots than it would be to write a whole new wlroots based compositor(which is quite beyond my current ability).

I have posted https://github.com/WayfireWM/wayfire/issues/1827 about the xwayland problem, it's probably in wlroots, may have been fixed in recent post-wlroots12 soname bump commits there, but wayfire needs to be ported to those changes as it cannot be built against libwlroots12.so and while this can be built freestanding it cannot be built inside current wayfire. Once built, wayfire cannot yet be built against it. Once wayfire catches up and git master wayfire builds against git master wlroots this will hopefully be resolved

Wayfire was listed in a Gentoo wiki as one of the very few usable wayland compositors outside GNOME and KDE. The xwayland issue is actually the only problem I've had with it, but it's a big one with kdenlive, audacious, and GIMP all not supporting wayland yet. Likely to be one that partially goes away with time but will never be all the way gone as some legacy software will never be updated.

List_of_wayland_compositors

Sunderland93 commented 1 year ago

Just tested mir, unfortunately current mir in the form of miral-system-compositor does NOT seem to support gtk-layer-shell.

miral-shell --wayland-extensions wl_shell:xdg_wm_base:zwlr_foreign_toplevel_manager_v1:zwlr_layer_shell_v1 works well with mate-panel

lukefromdc commented 1 year ago

Ahh, that's the secret of how the Ubuntu mate-mir snap worked! That will allow us both a basic compositor (in the role of marco) and a fancy one (in the role of compiz). Mir is being promoted for use in places like standalone kiosks, which implies it needs to be relatively light and hard for a user to screw up.

In my judgement, being able to run with more than one compositor is a major plus, one of the big plusses of GNOME 2 and then MATE after was the modular nature, where the WM, the file manager, and the panel were all interchangeable and all could be used elsewhere too

raveit65 commented 1 year ago

Just tested mir, unfortunately current mir in the form of miral-system-compositor does NOT seem to support gtk-layer-shell.

miral-shell --wayland-extensions wl_shell:xdg_wm_base:zwlr_foreign_toplevel_manager_v1:zwlr_layer_shell_v1 works well with mate-panel

Yeap, that works, but i have heavy graphical glitches when moving a window or with ubuntu's session start animation. I am using Ryzen 5000 internal amdgpu. With wayfire i don't get this. I added

display-scale=2.0
display-config=single
startup-apps=mate-panel:caja
shell-terminal-emulator=mate-terminal

to ~/.config/.miral-shell.config. Sadly, startup-apps=mate-panel:caja --force-desktop -n confused the options of miral-shell binary.

lukefromdc commented 1 year ago

I guess the next job is to start getting these applets buildable in or out of process?

raveit65 commented 1 year ago

I guess the next job is to start getting these applets buildable in or out of process?

That would be amazing when you find some time for it. I will support it with tests and reviews.

lukefromdc commented 1 year ago

BTW, turns out in sddm (installed as secondary display manager) I have the wayfire session listed. It comes up as my wayfire-MATE session save a couple bugs that may related to different session variable storage: Caja forgets desktop icon positions and view defaults, trash applet is on the panel but icon is invisible. None of this is a problem on wayfire from a VT command line.

lukefromdc commented 1 year ago

I've had a lot of trouble with autotools in trying to get out or in-process building optional for the wayland usable applets. I made it work for the very simple timer applet, but on both the trash and the battstat applet ran into ugly errors caused by autotools either not passingENABLE_IN_PROCESS (or whatever else I tried) to the process of building the Makefile from Makefile.am or failing to read it, resulting in attempting to use both the code in the ENABLE_IN_PROCESS block and theelse block at the same time. Resulting errors from that show attempts to specifiy building both with and without libtool.

Maybe as I work my way up the complexity chain from timer I will find the culprit?

For the timer, I just put the in-process Makefile.am text in theENABLE_IN_PROCESS and the previous out of process code in theelse block for now. On that applet it worked (after failing on two others) but still gave a warnign about NULL being defined twice, so I moved it to the top of the file:

timerapplet/src/Makefile.am:41: warning: NULL was already defined in condition TRUE, which includes condition !ENABLE_IN_PROCESS ... which may be a clue to the problems I've had with other applets, notably autotools reading Makefile.am as calling for building both with and without libtool no matter what I put in it, including using the in-process and out-of-process makefiles whole between if and else selectors