diff --git a/screen-rotate@shyzus.github.io/extension.js b/screen-rotate@shyzus.github.io/extension.js index 9b5b509..df1bd25 100644 --- a/screen-rotate@shyzus.github.io/extension.js +++ b/screen-rotate@shyzus.github.io/extension.js @@ -16,6 +16,7 @@ */ import { Extension, gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js'; +import { QuickMenuToggle, QuickSettingsMenu, SystemIndicator } from 'resource:///org/gnome/shell/ui/quickSettings.js'; import Gio from 'gi://Gio'; import GObject from 'gi://GObject'; @@ -25,11 +26,12 @@ import * as SystemActions from 'resource:///org/gnome/shell/misc/systemActions.j import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as Rotator from './rotator.js' import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; +import * as KeyboardUI from 'resource:///org/gnome/shell/ui/keyboard.js'; const ORIENTATION_LOCK_SCHEMA = 'org.gnome.settings-daemon.peripherals.touchscreen'; const ORIENTATION_LOCK_KEY = 'orientation-lock'; - -import { QuickMenuToggle, QuickSettingsMenu, SystemIndicator } from 'resource:///org/gnome/shell/ui/quickSettings.js'; +const A11Y_APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications'; +const SHOW_KEYBOARD = 'screen-keyboard-enabled'; // Orientation names must match those provided by net.hadess.SensorProxy const Orientation = Object.freeze({ @@ -197,6 +199,7 @@ class ScreenAutorotate { this._settings = settings; this._system_actions_backup = null; this._override_system_actions(); + this._a11yApplicationsSettings = new Gio.Settings({schema_id: A11Y_APPLICATIONS_SCHEMA}); this._orientation_settings = new Gio.Settings({ schema_id: ORIENTATION_LOCK_SCHEMA }); this._orientation_settings.connect('changed::' + ORIENTATION_LOCK_KEY, this._orientation_lock_changed.bind(this)); @@ -238,6 +241,7 @@ class ScreenAutorotate { destroy() { this._sensor_proxy.destroy(); this._orientation_settings = null; + this._a11yApplicationsSettings = null; this._restore_system_actions(); } @@ -249,15 +253,39 @@ class ScreenAutorotate { } } enable() { + this._originala11yKeyboardSetting = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD); this._sensor_proxy.enable(); this._state = true; } disable() { + this._a11yApplicationsSettings.set_boolean(SHOW_KEYBOARD, this._originala11yKeyboardSetting); + this._originala11yKeyboardSetting = null; this._sensor_proxy.disable(); this._state = false; } + _handle_osk(target) { + const landscapeOsk = this._settings.get_boolean('landscape-osk'); + const portraitRightOsk = this._settings.get_boolean('portrait-right-osk'); + const portraitLeftOsk = this._settings.get_boolean('portrait-left-osk'); + const landscapeFlippedOsk = this._settings.get_boolean('landscape-flipped-osk'); + switch (target) { + case 0: + this._a11yApplicationsSettings.set_boolean(SHOW_KEYBOARD, landscapeOsk); + break; + case 1: + this._a11yApplicationsSettings.set_boolean(SHOW_KEYBOARD, portraitLeftOsk); + break; + case 2: + this._a11yApplicationsSettings.set_boolean(SHOW_KEYBOARD, landscapeFlippedOsk); + break; + case 3: + this._a11yApplicationsSettings.set_boolean(SHOW_KEYBOARD, portraitRightOsk); + break; + } + } + rotate_to(orientation) { const sensor = Orientation[orientation]; const invert_horizontal_direction = this._settings.get_boolean('invert-horizontal-rotation-direction'); @@ -294,11 +322,12 @@ class ScreenAutorotate { target = (target + offset) % 4; if (this._settings.get_boolean('debug-logging')) { - console.debug(`sensor=${Orientation[orientation]}`); - console.debug(`offset=${offset}`); - console.debug(`target=${target}`); + console.log(`sensor=${Orientation[orientation]}`); + console.log(`offset=${offset}`); + console.log(`target=${target}`); } Rotator.rotate_to(target); + this._handle_osk(target); } } diff --git a/screen-rotate@shyzus.github.io/prefs.js b/screen-rotate@shyzus.github.io/prefs.js index 85c2e6c..a106153 100644 --- a/screen-rotate@shyzus.github.io/prefs.js +++ b/screen-rotate@shyzus.github.io/prefs.js @@ -37,6 +37,10 @@ export default class MyExtensionPreferences extends ExtensionPreferences { shellMenuGroup.set_title('GNOME Shell Menu Settings'); page.add(shellMenuGroup); + const oskSettingsGroup = new Adw.PreferencesGroup(); + oskSettingsGroup.set_title('On-Screen-Keyboard Settings'); + page.add(oskSettingsGroup); + const debugGroup = new Adw.PreferencesGroup(); debugGroup.set_title('Debug Settings'); page.add(debugGroup); @@ -77,6 +81,26 @@ export default class MyExtensionPreferences extends ExtensionPreferences { }); shellMenuGroup.add(hideLockRotateRow); + const landscapeOskRow = new Adw.ActionRow({ + title: 'Show OSK in landscape orientation' + }); + oskSettingsGroup.add(landscapeOskRow); + + const portraitRightOskRow = new Adw.ActionRow({ + title: 'Show OSK in portrait (right) orientation' + }); + oskSettingsGroup.add(portraitRightOskRow); + + const portraitLeftOskRow = new Adw.ActionRow({ + title: 'Show OSK in portrait (left) orientation' + }); + oskSettingsGroup.add(portraitLeftOskRow); + + const landscapeFlippedOskRow = new Adw.ActionRow({ + title: 'Show OSK in landscape (flipped) orientation' + }); + oskSettingsGroup.add(landscapeFlippedOskRow); + const toggleLoggingRow = new Adw.ActionRow({ title: 'Enable debug logging', subtitle: 'Use "journalctl /usr/bin/gnome-shell -f" to see log output.' @@ -111,6 +135,26 @@ export default class MyExtensionPreferences extends ExtensionPreferences { valign: Gtk.Align.CENTER, }); + const landscapeOskCheckButton = new Gtk.CheckButton({ + active: window._settings.get_boolean('landscape-osk'), + valign: Gtk.Align.CENTER + }); + + const portraitRightOskCheckButton = new Gtk.CheckButton({ + active: window._settings.get_boolean('portrait-right-osk'), + valign: Gtk.Align.CENTER + }); + + const portraitLeftOskCheckButton = new Gtk.CheckButton({ + active: window._settings.get_boolean('portrait-left-osk'), + valign: Gtk.Align.CENTER + }); + + const landscapeFlippedOskCheckButton = new Gtk.CheckButton({ + active: window._settings.get_boolean('landscape-flipped-osk'), + valign: Gtk.Align.CENTER + }); + const toggleLoggingSwitch = new Gtk.Switch({ active: window._settings.get_boolean('debug-logging'), valign: Gtk.Align.CENTER @@ -134,6 +178,18 @@ export default class MyExtensionPreferences extends ExtensionPreferences { window._settings.bind('hide-lock-rotate', hideLockRotateSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); + window._settings.bind('landscape-osk', + landscapeOskCheckButton, 'active', Gio.SettingsBindFlags.DEFAULT); + + window._settings.bind('portrait-right-osk', + portraitRightOskCheckButton, 'active', Gio.SettingsBindFlags.DEFAULT); + + window._settings.bind('portrait-left-osk', + portraitLeftOskCheckButton, 'active', Gio.SettingsBindFlags.DEFAULT); + + window._settings.bind('landscape-flipped-osk', + landscapeFlippedOskCheckButton, 'active', Gio.SettingsBindFlags.DEFAULT); + window._settings.bind('debug-logging', toggleLoggingSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); @@ -155,6 +211,18 @@ export default class MyExtensionPreferences extends ExtensionPreferences { hideLockRotateRow.add_suffix(hideLockRotateSwitch); hideLockRotateRow.activatable_widget = hideLockRotateSwitch; + landscapeOskRow.add_suffix(landscapeOskCheckButton); + landscapeOskRow.activatable_widget = landscapeOskCheckButton; + + portraitRightOskRow.add_suffix(portraitRightOskCheckButton); + portraitRightOskRow.activatable_widget = portraitRightOskCheckButton; + + portraitLeftOskRow.add_suffix(portraitLeftOskCheckButton); + portraitLeftOskRow.activatable_widget = portraitLeftOskCheckButton; + + landscapeFlippedOskRow.add_suffix(landscapeFlippedOskCheckButton); + landscapeFlippedOskRow.activatable_widget = landscapeFlippedOskCheckButton; + toggleLoggingRow.add_suffix(toggleLoggingSwitch); toggleLoggingRow.activatable_widget = toggleLoggingSwitch; } diff --git a/screen-rotate@shyzus.github.io/schemas/gschemas.compiled b/screen-rotate@shyzus.github.io/schemas/gschemas.compiled index 4e7e366..6e35225 100644 Binary files a/screen-rotate@shyzus.github.io/schemas/gschemas.compiled and b/screen-rotate@shyzus.github.io/schemas/gschemas.compiled differ diff --git a/screen-rotate@shyzus.github.io/schemas/org.gnome.shell.extensions.screen-rotate.gschema.xml b/screen-rotate@shyzus.github.io/schemas/org.gnome.shell.extensions.screen-rotate.gschema.xml index 0eeb5f6..492188f 100644 --- a/screen-rotate@shyzus.github.io/schemas/org.gnome.shell.extensions.screen-rotate.gschema.xml +++ b/screen-rotate@shyzus.github.io/schemas/org.gnome.shell.extensions.screen-rotate.gschema.xml @@ -40,10 +40,27 @@ false Enable a toggle in the GNOME Shell System Menu to manually flip between landscape and portrait. - + + false Hide the 'Auto Rotate' quick toggle. + + false + Enable the use of the On-Screen-Keyboard for the landscape orientation. + + + false + Enable the use of the On-Screen-Keyboard for the portrait (right) orientation. + + + false + Enable the use of the On-Screen-Keyboard for the portrait (left) orientation. + + + false + Enable the use of the On-Screen-Keyboard for the landscape (flipped) orientation. + false Toggle debug logging.