summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-05-12 16:41:45 +0200
committerCarlos Garnacho <carlosg@gnome.org>2020-05-12 16:41:45 +0200
commitf68fd6068fd3bf1799b74803d5d3ec2114b0385b (patch)
treeb605fa0cf73b6a016770fe55da08c0e9de07b454
parent79aeabcf769937e9eb6cf417d8a6b201756a9a57 (diff)
downloadgnome-shell-wip/carlosg/im-caret-taps-x11-3.36.tar.gz
keyboard: Detect taps close to the cursor caret on X11wip/carlosg/im-caret-taps-x11-3.36
Try to bring some feature parity wrt OSK being toggled on. Set up a gesture that triggers on taps nearby the text caret position, as reported by ibus.
-rw-r--r--js/ui/keyboard.js54
1 files changed, 52 insertions, 2 deletions
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index e8a79f507..5c4709d24 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -529,6 +529,43 @@ var KeyboardModel = class {
}
};
+var IMFocusAction = GObject.registerClass({
+ Signals: {
+ 'activated': {},
+ },
+}, class IMFocusAction extends Clutter.GestureAction {
+ constructor() {
+ this.parent();
+ this.set_n_touch_points(1);
+ this.set_threshold_trigger_edge(Clutter.GestureTriggerEdge.BEFORE);
+ this._rect = null;
+ }
+
+ vfunc_gesture_prepare(actor) {
+ let event = this.get_last_event(0);
+
+ if (event.type() != Clutter.EventType.TOUCH_BEGIN)
+ return false;
+
+ let [x, y] = event.get_coords();
+
+ if (this._rect &&
+ x >= this._rect.x - 40 &&
+ x < this._rect.x + this._rect.width + 40 &&
+ y >= this._rect.y - 40 &&
+ y < this._rect.y + this._rect.height + 40) {
+ this.emit('activated');
+ }
+
+ // Action work is already done
+ return false;
+ }
+
+ setFocusRect(rect) {
+ this._rect = rect;
+ }
+});
+
var FocusTracker = class {
constructor() {
this._currentWindow = null;
@@ -1210,6 +1247,15 @@ class Keyboard extends St.BoxLayout {
this._suggestions = null;
this._emojiKeyVisible = Meta.is_wayland_compositor();
+ this._imFocusAction = new IMFocusAction();
+ this._imFocusAction.connect('activated', () => {
+ /* Valid for X11 clients only */
+ if (Main.inputMethod.currentFocus)
+ return;
+ this.open(Main.layoutManager.focusIndex);
+ });
+ global.stage.add_action(this._imFocusAction);
+
this._focusTracker = new FocusTracker();
this._connectSignal(this._focusTracker, 'position-changed',
this._onFocusPositionChanged.bind(this));
@@ -1217,14 +1263,17 @@ class Keyboard extends St.BoxLayout {
this._delayedAnimFocusWindow = null;
this._animFocusedWindow = null;
this._oskFocusWindow = null;
+ this._imFocusAction.setFocusRect(null);
});
// Valid only for X11
if (!Meta.is_wayland_compositor()) {
this._connectSignal(this._focusTracker, 'focus-changed', (_tracker, focused) => {
- if (focused)
+ if (focused) {
this.open(Main.layoutManager.focusIndex);
- else
+ } else {
this.close();
+ this._imFocusAction.setFocusRect(null);
+ }
});
}
@@ -1264,6 +1313,7 @@ class Keyboard extends St.BoxLayout {
_onFocusPositionChanged(focusTracker) {
let rect = focusTracker.getCurrentRect();
this.setCursorLocation(focusTracker.currentWindow, rect.x, rect.y, rect.width, rect.height);
+ this._imFocusAction.setFocusRect(rect);
}
_onDestroy() {