From b86d6d6d474489f5e2f36594ffcf1c6b555dfc74 Mon Sep 17 00:00:00 2001 From: khimaros Date: Mon, 22 Apr 2024 01:38:10 -0700 Subject: [PATCH] fix broken preferences and timeouts --- smart-auto-move@khimaros.com/extension.js | 8 ++++---- smart-auto-move@khimaros.com/metadata.json | 2 +- smart-auto-move@khimaros.com/prefs.js | 16 ++++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/smart-auto-move@khimaros.com/extension.js b/smart-auto-move@khimaros.com/extension.js index 73edda7..5b003f2 100644 --- a/smart-auto-move@khimaros.com/extension.js +++ b/smart-auto-move@khimaros.com/extension.js @@ -392,7 +392,7 @@ function handleTimeoutSave() { GLib.Source.remove(timeoutSaveSignal); timeoutSaveSignal = null; saveSettings(); - timeoutSaveSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, saveFrequencyMs, handleTimeoutSave); + timeoutSaveSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, saveFrequencyMs / 1000.0, handleTimeoutSave); return GLib.SOURCE_CONTINUE; } @@ -401,7 +401,7 @@ function handleTimeoutSync() { GLib.Source.remove(timeoutSyncSignal); timeoutSyncSignal = null; syncWindows(); - timeoutSyncSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, syncFrequencyMs, handleTimeoutSync); + timeoutSyncSignal = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, syncFrequencyMs / 1000.0, handleTimeoutSync); return GLib.SOURCE_CONTINUE; } @@ -480,9 +480,9 @@ function disconnectSignals() { function addTimeouts() { timeoutSyncSignal = GLib.timeout_add_seconds( - GLib.PRIORITY_DEFAULT, syncFrequencyMs, handleTimeoutSync); + GLib.PRIORITY_DEFAULT, syncFrequencyMs / 1000.0, handleTimeoutSync); timeoutSaveSignal = GLib.timeout_add_seconds( - GLib.PRIORITY_DEFAULT, saveFrequencyMs, handleTimeoutSave); + GLib.PRIORITY_DEFAULT, saveFrequencyMs / 1000.0, handleTimeoutSave); } function removeTimeouts() { diff --git a/smart-auto-move@khimaros.com/metadata.json b/smart-auto-move@khimaros.com/metadata.json index f46029f..f95171a 100644 --- a/smart-auto-move@khimaros.com/metadata.json +++ b/smart-auto-move@khimaros.com/metadata.json @@ -5,6 +5,6 @@ "description": "Smart Auto Move learns the position, size, and workspace of your application windows and restores them on subsequent launches. Supports Wayland.\n\nNOTE: Optimized for use with static workspaces. For more control, set the default behavior to IGNORE and then selectively RESTORE only desired apps.\n\nKNOWN ISSUES: Multi-monitor is not yet well supported. You may need to manually delete Saved Windows in preferences after adding or removing a display.", "settings-schema": "org.gnome.shell.extensions.smart-auto-move", "original-author": "khimaros", - "version": "24", + "version": "25", "shell-version": ["45", "46"] } diff --git a/smart-auto-move@khimaros.com/prefs.js b/smart-auto-move@khimaros.com/prefs.js index 0603f68..46f4f17 100644 --- a/smart-auto-move@khimaros.com/prefs.js +++ b/smart-auto-move@khimaros.com/prefs.js @@ -134,8 +134,10 @@ function buildPrefsWidget(extension) { let saved_windows_list_widget = builder.get_object('saved-windows-listbox'); let saved_windows_list_objects = []; - loadSavedWindowsSetting(saved_windows_list_widget, saved_windows_list_objects); - changedSavedWindowsSignal = settings.connect('changed::' + Common.SETTINGS_KEY_SAVED_WINDOWS, function () { loadSavedWindowsSetting(saved_windows_list_widget, saved_windows_list_objects); }); + loadSavedWindowsSetting(extension, saved_windows_list_widget, saved_windows_list_objects); + changedSavedWindowsSignal = settings.connect('changed::' + Common.SETTINGS_KEY_SAVED_WINDOWS, function () { + loadSavedWindowsSetting(extension, saved_windows_list_widget, saved_windows_list_objects); + }); /// OVERRIDES @@ -145,13 +147,15 @@ function buildPrefsWidget(extension) { overrides_add_application_widget.connect('clicked', function () { // TODO }); - loadOverridesSetting(overrides_list_widget, overrides_list_objects); - changedOverridesSignal = settings.connect('changed::' + Common.SETTINGS_KEY_OVERRIDES, function () { loadOverridesSetting(overrides_list_widget, overrides_list_objects); }); + loadOverridesSetting(extension, overrides_list_widget, overrides_list_objects); + changedOverridesSignal = settings.connect('changed::' + Common.SETTINGS_KEY_OVERRIDES, function () { + loadOverridesSetting(extension, overrides_list_widget, overrides_list_objects); + }); return root; } -function loadOverridesSetting(list_widget, list_objects) { +function loadOverridesSetting(extension, list_widget, list_objects) { let settings = extension.getSettings(); let overrides = JSON.parse(settings.get_string(Common.SETTINGS_KEY_OVERRIDES)); @@ -237,7 +241,7 @@ function loadOverridesSetting(list_widget, list_objects) { }); } -function loadSavedWindowsSetting(list_widget, list_objects) { +function loadSavedWindowsSetting(extension, list_widget, list_objects) { let settings = extension.getSettings(); let saved_windows = JSON.parse(settings.get_string(Common.SETTINGS_KEY_SAVED_WINDOWS));