[gnome-shell/wip/carlosg/im-caret-taps-x11-3.36] keyboard: Detect taps close to the cursor caret on X11
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/im-caret-taps-x11-3.36] keyboard: Detect taps close to the cursor caret on X11
- Date: Tue, 12 May 2020 14:43:40 +0000 (UTC)
commit f68fd6068fd3bf1799b74803d5d3ec2114b0385b
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue May 12 16:41:45 2020 +0200
keyboard: Detect taps close to the cursor caret on X11
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.
js/ui/keyboard.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index e8a79f5078..5c4709d248 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() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]