Smithay / client-toolkit

Smithay's toolkit for writing wayland clients
MIT License
269 stars 76 forks source link

Automatically reload mouse cursor theme when theme config changes #232

Open Hubro opened 2 years ago

Hubro commented 2 years ago

Applications that use client-toolkit (such as Neovide and Alacritty) get the correct mouse cursor based on my current icon theme.

However, if I change the mouse cursor theme by editing $HOME/.icons/default/index.theme from, for example:

[icon theme]
Inherits=Adwaita

To:

[icon theme]
Inherits=Breeze_Snow

I have to restart the application for the change to take effect. This makes it extremely inconvenient to test out various mouse cursor themes and it makes it impossible to automate switching mouse cursor themes to comply with the system wide light/dark theme preference.

It would be amazing if client-toolkit could watch the current theme and reload the graphics if the theme changes.

Hubro commented 2 years ago

Alternatively, if this could be achieved more easily by disabling caching of the mouse cursor theme, perhaps through an environment variable, that would be acceptable to me.

elinorbgr commented 2 years ago

However, if I change the mouse cursor theme by editing $HOME/.icons/default/index.theme

Do you have examples of apps that react to this? That seems like requesting SCTK to randomly watch a bunch of files for modifications, which does not seem like something we actually would want to do.

Hubro commented 2 years ago

@vberger When I change my cursor theme, all Gnome applications pick it up immediately (nautilus, gnome-calculator, gnome-terminal etc.), in fact all GTK applications appear to pick it up immediately (tested solaar and waybar) and all my browsers pick it up immediately (tested Vivaldi, Chrome, Chromium, Firefox).

These applications all seem to pick up the cursor theme from gsettings though.

That seems like requesting SCTK to randomly watch a bunch of files for modifications, which does not seem like something we actually would want to do.

That does indeed sound overkill for something like this, but surely there must be other ways of picking up the change. What about reloading the cursor scheme any time the window gains focus or something like that?

Loading the cursor icons once and never letting them change just seems like the opposite extreme to me, and it blocks use cases such as globally changing color schemes.

elinorbgr commented 2 years ago

What about reloading the cursor scheme any time the window gains focus or something like that?

Given the current level of abstraction that SCTK is, that would rather be "provide a method for reloading the cursor theme that the downstream app invokes when it sees fit". I guess that could work.

Hubro commented 2 years ago

I think ideally SCTK would handle low-level "boring" things like this without application developers having to think about it, but if there's no graceful and sensible way to do that, providing a simple function for it would at least be a big improvement.

elinorbgr commented 2 years ago

I think ideally SCTK would handle low-level "boring" things like this without application developers having to think about it

The API exposed by SCTK is currently not high-level enough to do that. But that would be easily done in winit (which alacritty uses).

Hubro commented 2 years ago

Right, that makes sense. Is the pointer "ThemeManager" a long-lived object? Would it make sense to add a reload function to it?