xcursormgr: dont apply scale on gsettings (#7316)

gtk scales the cursor size itself since its CSD so if we scale the size
its gonna get double scaled. incorporate the scale into xcursormanager
to keep track of it.
This commit is contained in:
Tom Englund 2024-08-16 18:00:59 +02:00 committed by GitHub
parent 1840a907a8
commit c5feee1e35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 17 deletions

View file

@ -100,12 +100,13 @@ CXCursorManager::CXCursorManager() {
defaultCursor = hyprCursor;
}
void CXCursorManager::loadTheme(std::string const& name, int size) {
if (lastLoadSize == size && themeName == name)
void CXCursorManager::loadTheme(std::string const& name, int size, float scale) {
if (lastLoadSize == (size * std::ceil(scale)) && themeName == name && lastLoadScale == scale)
return;
lastLoadSize = size;
themeName = name.empty() ? "default" : name;
lastLoadSize = size * std::ceil(scale);
lastLoadScale = scale;
themeName = name.empty() ? "default" : name;
defaultCursor.reset();
cursors.clear();
@ -156,10 +157,10 @@ void CXCursorManager::loadTheme(std::string const& name, int size) {
syncGsettings();
}
SP<SXCursors> CXCursorManager::getShape(std::string const& shape, int size) {
SP<SXCursors> CXCursorManager::getShape(std::string const& shape, int size, float scale) {
// monitor scaling changed etc, so reload theme with new size.
if (size != lastLoadSize)
loadTheme(themeName, size);
if ((size * std::ceil(scale)) != lastLoadSize || scale != lastLoadScale)
loadTheme(themeName, size, scale);
// try to get an icon we know if we have one
for (auto const& c : cursors) {
@ -602,6 +603,7 @@ void CXCursorManager::syncGsettings() {
g_object_unref(gsettings);
};
int unscaledSize = lastLoadSize / std::ceil(lastLoadScale);
setValue("cursor-theme", themeName, "org.gnome.desktop.interface");
setValue("cursor-size", lastLoadSize, "org.gnome.desktop.interface");
setValue("cursor-size", unscaledSize, "org.gnome.desktop.interface");
}