mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-03 16:15:13 +00:00
Handle cursor size in the custom GTK integration
This commit is contained in:
@@ -161,6 +161,14 @@ bool IconThemeShouldBeSet() {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CursorSizeShouldBeSet() {
|
||||||
|
// change the cursor size only on Wayland and if it wasn't already set
|
||||||
|
static const auto Result = IsWayland()
|
||||||
|
&& qEnvironmentVariableIsEmpty("XCURSOR_SIZE");
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
void SetIconTheme() {
|
void SetIconTheme() {
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
||||||
if (GtkSettingSupported()
|
if (GtkSettingSupported()
|
||||||
@@ -183,6 +191,21 @@ void SetIconTheme() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetCursorSize() {
|
||||||
|
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
||||||
|
if (GtkSettingSupported()
|
||||||
|
&& GtkLoaded()
|
||||||
|
&& CursorSizeShouldBeSet()) {
|
||||||
|
DEBUG_LOG(("Setting GTK cursor size"));
|
||||||
|
|
||||||
|
const auto newCursorSize = GtkSetting<gint>("gtk-cursor-theme-size");
|
||||||
|
qputenv("XCURSOR_SIZE", QByteArray::number(newCursorSize));
|
||||||
|
|
||||||
|
DEBUG_LOG(("New cursor size: %1").arg(newCursorSize));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void DarkModeChanged() {
|
void DarkModeChanged() {
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
||||||
Core::App().settings().setSystemDarkMode(IsDarkMode());
|
Core::App().settings().setSystemDarkMode(IsDarkMode());
|
||||||
@@ -319,10 +342,12 @@ void start() {
|
|||||||
LOAD_SYMBOL(lib_gtk, "gtk_app_chooser_get_type", gtk_app_chooser_get_type);
|
LOAD_SYMBOL(lib_gtk, "gtk_app_chooser_get_type", gtk_app_chooser_get_type);
|
||||||
|
|
||||||
SetIconTheme();
|
SetIconTheme();
|
||||||
|
SetCursorSize();
|
||||||
|
|
||||||
const auto settings = gtk_settings_get_default();
|
const auto settings = gtk_settings_get_default();
|
||||||
g_signal_connect(settings, "notify::gtk-icon-theme-name", G_CALLBACK(SetIconTheme), nullptr);
|
g_signal_connect(settings, "notify::gtk-icon-theme-name", G_CALLBACK(SetIconTheme), nullptr);
|
||||||
g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(DarkModeChanged), nullptr);
|
g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(DarkModeChanged), nullptr);
|
||||||
|
g_signal_connect(settings, "notify::gtk-cursor-theme-size", G_CALLBACK(SetCursorSize), nullptr);
|
||||||
|
|
||||||
if (!gtk_check_version(3, 0, 0)) {
|
if (!gtk_check_version(3, 0, 0)) {
|
||||||
g_signal_connect(settings, "notify::gtk-application-prefer-dark-theme", G_CALLBACK(DarkModeChanged), nullptr);
|
g_signal_connect(settings, "notify::gtk-application-prefer-dark-theme", G_CALLBACK(DarkModeChanged), nullptr);
|
||||||
|
Reference in New Issue
Block a user