[gnome-shell/wip/carlosg/magnifier-improvements: 5/5] windowManager: Add keybindings for a11y zoom control
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/magnifier-improvements: 5/5] windowManager: Add keybindings for a11y zoom control
- Date: Thu, 6 Feb 2020 14:17:36 +0000 (UTC)
commit bea748df481510b4b1625621aa791824173328bd
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Feb 6 14:21:43 2020 +0100
windowManager: Add keybindings for a11y zoom control
It may be desirable to change the zoom level without going to the
a11y control center panel. Add the <win>plus and <win>minus keybindings
to do that.
data/org.gnome.shell.gschema.xml.in | 8 ++++++++
js/ui/magnifier.js | 22 ++++++++++++++++++++++
js/ui/windowManager.js | 20 ++++++++++++++++++++
3 files changed, 50 insertions(+)
---
diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in
index 49d38d7662..db141c8431 100644
--- a/data/org.gnome.shell.gschema.xml.in
+++ b/data/org.gnome.shell.gschema.xml.in
@@ -186,6 +186,14 @@
<default>["<Super>9"]</default>
<summary>Switch to application 9</summary>
</key>
+ <key name="a11y-zoom-in" type="as">
+ <default>["<Super>Plus"]</default>
+ <summary>Accessibility zoom in</summary>
+ </key>
+ <key name="a11y-zoom-out" type="as">
+ <default>["<Super>Minus"]</default>
+ <summary>Accessibility zoom out</summary>
+ </key>
</schema>
<schema id="org.gnome.shell.app-switcher"
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index 30691f66d9..b7af324d36 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -706,6 +706,28 @@ var Magnifier = class Magnifier {
this._zoomRegions[0].setContrast(contrast);
}
}
+
+ zoomIn(factor) {
+ if (!this.isActive())
+ return;
+
+ this._zoomRegions.forEach(zoomRegion => {
+ let [xMag, yMag] = zoomRegion.getMagFactor();
+ zoomRegion.setMagFactor(xMag * factor, yMag * factor);
+ });
+ }
+
+ zoomOut(factor) {
+ if (!this.isActive())
+ return;
+
+ this._zoomRegions.forEach(zoomRegion => {
+ let [xMag, yMag] = zoomRegion.getMagFactor();
+ xMag = Math.max(xMag / factor, 1);
+ yMag = Math.max(yMag / factor, 1);
+ zoomRegion.setMagFactor(xMag, yMag);
+ });
+ }
};
Signals.addSignalMethods(Magnifier.prototype);
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 8634274a49..cd7ea3978e 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -864,6 +864,18 @@ var WindowManager = class {
Shell.ActionMode.NORMAL |
Shell.ActionMode.OVERVIEW,
this._switchToApplication.bind(this));
+ this.addKeybinding('a11y-zoom-in',
+ new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+ Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+ Shell.ActionMode.NORMAL |
+ Shell.ActionMode.OVERVIEW,
+ this._a11yZoomIn.bind(this));
+ this.addKeybinding('a11y-zoom-out',
+ new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
+ Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+ Shell.ActionMode.NORMAL |
+ Shell.ActionMode.OVERVIEW,
+ this._a11yZoomOut.bind(this));
global.display.connect('show-resize-popup', this._showResizePopup.bind(this));
global.display.connect('show-pad-osd', this._showPadOsd.bind(this));
@@ -2016,6 +2028,14 @@ var WindowManager = class {
app.activate();
}
+ _a11yZoomIn() {
+ Main.magnifier.zoomIn(2);
+ }
+
+ _a11yZoomOut() {
+ Main.magnifier.zoomOut(2);
+ }
+
_toggleAppMenu() {
Main.panel.toggleAppMenu();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]