Getting focused window class/title in Wayland on Cinnamon

About programming and getting involved with Linux Mint development
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Post Reply
RedBearAK
Level 1
Level 1
Posts: 36
Joined: Wed Aug 19, 2020 3:03 am

Getting focused window class/title in Wayland on Cinnamon

Post by RedBearAK »

It's early in the process, but I hear that Cinnamon is beginning the transition to Wayland. I am looking for any information about exactly how this is being done with Cinnamon, whether it's a `wlroots` based compositor that might have the "foreign toplevel management" protocol already implemented, or if it's some kind of custom compositor, different from that used by GNOME, KDE Plasma, sway or Hyprland.

The reason is I need to figure out if I can get the focused window info (app class and window title) in a Cinnamon Wayland session, for a project I maintain that uses this info to provide app-specific shortcut remaps. It used to rely totally on getting this info via the Python Xlib module, but I expanded the keymapper with methods that work in Wayland+GNOME, Wayland+KDE (Plasma), sway, and Hyprland (untested).

There is theoretically a generic `wlroots` method I might be able to get working, but if Cinnamon won't be using a `wlroots` compositor I'll need to find out the method to get the active window info that might be specific to Cinnamon's Wayland implementation.

Any info about this would be appreciated. Direct info, or pointers to development issue threads or source files that might be related, anything at all.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: Getting focused window class/title in Wayland on Cinnamon

Post by xenopeek »

You can download the Linux Mint 21.3 Cinnamon Beta ISO and install it in a VM: https://blog.linuxmint.com/?p=4611. On the login screen you can switch to the experimental Wayland session, so you can test it.

Cinnamon won't be using wlroots. Cinnamon's window manager Muffin is a fork of Gnome's Mutter, which is a full Wayland compositor. I don't know the specifics but you can try searching for 'wayland' in the Cinnamon and Muffin projects on https://github.com/linuxmint.
Image
RedBearAK
Level 1
Level 1
Posts: 36
Joined: Wed Aug 19, 2020 3:03 am

Re: Getting focused window class/title in Wayland on Cinnamon

Post by RedBearAK »

xenopeek wrote: Mon Dec 11, 2023 3:14 am You can download the Linux Mint 21.3 Cinnamon Beta ISO and install it in a VM: https://blog.linuxmint.com/?p=4611. On the login screen you can switch to the experimental Wayland session, so you can test it.

Cinnamon won't be using wlroots. Cinnamon's window manager Muffin is a fork of Gnome's Mutter, which is a full Wayland compositor. I don't know the specifics but you can try searching for 'wayland' in the Cinnamon and Muffin projects on https://github.com/linuxmint.
Thanks, that's a helpful start on understanding the situation. The method for getting the window info in GNOME unfortunately requires a shell extension that can be queried via D-Bus. I've found three different GNOME shell extensions that I was able to use as options to make my project work. Now I'll have to find out if there is some sort of equivalent that could work for Cinnamon/Muffin, or if some other method like IPC calls will be implemented.
RedBearAK
Level 1
Level 1
Posts: 36
Joined: Wed Aug 19, 2020 3:03 am

Re: Getting focused window class/title in Wayland on Cinnamon

Post by RedBearAK »

@xenopeek

Thanks to your concise explanation of the basis of the Wayland implementation in Cinnamon, I was able to put together a Cinnamon extension that did the same thing that one of the GNOME extensions does. So my project is already working on the Mint 21.3 beta in the Cinnamon Wayland session.

The extension, for reference:

https://github.com/RedBearAK/toshy/blob ... tension.js
Post Reply

Return to “Programming & Development”