keyboard: Implement more of the wayland caribou adapter

Have it notify properly of changes to the current input source, as
well as exposing those in get_groups().

The support for virtual keyboard events has been replaced by
ClutterVirtualInputDevice, which can be thought of as the equivalent
to the XTEST devices in X11.

https://bugzilla.gnome.org/show_bug.cgi?id=765009
This commit is contained in:
Carlos Garnacho 2016-07-20 17:50:55 +02:00
parent ffa28e7ee7
commit c3e68955e3

View File

@ -10,6 +10,7 @@ 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;
const InputSourceManager = imports.ui.status.keyboard;
const BoxPointer = imports.ui.boxpointer; const BoxPointer = imports.ui.boxpointer;
const Layout = imports.ui.layout; const Layout = imports.ui.layout;
@ -757,19 +758,48 @@ const ShellWaylandAdapter = new Lang.Class({
Name: 'ShellWaylandAdapter', Name: 'ShellWaylandAdapter',
Extends: Caribou.XAdapter, Extends: Caribou.XAdapter,
_init: function () {
this.parent();
let deviceManager = Clutter.DeviceManager.get_default();
this._virtualDevice = deviceManager.create_virtual_device(Clutter.InputDeviceType.KEYBOARD_DEVICE);
this._inputSourceManager = InputSourceManager.getInputSourceManager();
this._sourceChangedId = this._inputSourceManager.connect('current-source-changed',
Lang.bind(this, this._onSourceChanged));
this._sourcesModifiedId = this._inputSourceManager.connect ('sources-changed',
Lang.bind(this, this._onSourcesModified));
},
_onSourcesModified: function () {
this.emit('config-changed');
},
_onSourceChanged: function (inputSourceManager, oldSource) {
let source = inputSourceManager.currentSource;
this.emit('group-changed', source.index, source.id, '');
},
vfunc_get_groups: function () {
let inputSources = this._inputSourceManager.inputSources;
let groups = []
let variants = [];
for (let i in inputSources) {
let is = inputSources[i];
groups[is.index] = is.id;
variants[is.index] = '';
}
return [groups, groups.length, variants, variants.length];
},
vfunc_keyval_press: function(keyval) { vfunc_keyval_press: function(keyval) {
let focus = global.stage.get_key_focus(); this._virtualDevice.notify_keyval(Clutter.get_current_event_time(),
if (focus instanceof Clutter.Text) keyval, Clutter.KeyState.PRESSED);
Shell.util_text_insert_keyval(focus, keyval);
else
this.parent(keyval);
}, },
vfunc_keyval_release: function(keyval) { vfunc_keyval_release: function(keyval) {
let focus = global.stage.get_key_focus(); this._virtualDevice.notify_keyval(Clutter.get_current_event_time(),
if (focus instanceof Clutter.Text) keyval, Clutter.KeyState.RELEASED);
return; // do nothing
else
this.parent(keyval);
}, },
}); });