keyboard: Listen to MetaBackend::last-device-changed for OSK changes

Instead of listening to a dbus property exported by g-s-d, listen to the
MetaBackend signal telling the last interacted device, and make sure we
only show the keyboard for touchscreens.

https://bugzilla.gnome.org/show_bug.cgi?id=745977
This commit is contained in:
Carlos Garnacho 2015-03-10 17:49:56 +01:00
parent 0389ae5299
commit ff1b76f4c7

View File

@ -6,6 +6,7 @@ const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Lang = imports.lang; const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const St = imports.gi.St; const St = imports.gi.St;
@ -60,14 +61,7 @@ const CaribouDaemonIface = '<node> \
</interface> \ </interface> \
</node>'; </node>';
const CursorManagerIface = '<node> \
<interface name="org.gnome.SettingsDaemon.Cursor"> \
<property name="ShowOSK" type="b" access="read" /> \
</interface> \
</node>';
const CaribouDaemonProxy = Gio.DBusProxy.makeProxyWrapper(CaribouDaemonIface); const CaribouDaemonProxy = Gio.DBusProxy.makeProxyWrapper(CaribouDaemonIface);
const CursorManagerProxy = Gio.DBusProxy.makeProxyWrapper(CursorManagerIface);
const Key = new Lang.Class({ const Key = new Lang.Class({
Name: 'Key', Name: 'Key',
@ -188,16 +182,17 @@ const Keyboard = new Lang.Class({
Lang.bind(this, this._sync), Lang.bind(this, this._sync),
Lang.bind(this, this._sync)); Lang.bind(this, this._sync));
this._daemonProxy = null; this._daemonProxy = null;
this._cursorProxy = new CursorManagerProxy(Gio.DBus.session, CURSOR_BUS_NAME, this._lastDeviceId = null;
CURSOR_OBJECT_PATH,
Lang.bind(this, function(proxy, error) { Meta.get_backend().connect('last-device-changed', Lang.bind(this,
if (error) { function (backend, deviceId) {
log(error.message); let manager = Clutter.DeviceManager.get_default();
return; let device = manager.get_device(deviceId);
}
this._cursorProxy.connect('g-properties-changed', if (device.get_device_name().indexOf('XTEST') < 0) {
Lang.bind(this, this._sync)); this._lastDeviceId = deviceId;
this._sync(); this._sync();
}
})); }));
this._sync(); this._sync();
@ -217,9 +212,22 @@ const Keyboard = new Lang.Class({
this._redraw(); this._redraw();
}, },
_lastDeviceIsTouchscreen: function () {
if (!this._lastDeviceId)
return false;
let manager = Clutter.DeviceManager.get_default();
let device = manager.get_device(this._lastDeviceId);
if (!device)
return false;
return device.get_device_type() == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE;
},
_sync: function () { _sync: function () {
this._enableKeyboard = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD) || this._enableKeyboard = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD) ||
this._cursorProxy.ShowOSK; this._lastDeviceIsTouchscreen();
if (!this._enableKeyboard && !this._keyboard) if (!this._enableKeyboard && !this._keyboard)
return; return;
if (this._enableKeyboard && this._keyboard && if (this._enableKeyboard && this._keyboard &&