[gnome-shell-extensions/wip/rstrode/heads-up-display: 58/62] desktopGrid: Handle TOUCH_BEGIN events explicitly




commit 8f2871215f640ba65ca1bdc6899adaec54c3ed77
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 31 19:31:03 2021 +0200

    desktopGrid: Handle TOUCH_BEGIN events explicitly
    
    We do not get pointer emulated events on Wayland, so touch events should
    be handled explicitly there. Handle starting rubberband selection via
    touch.

 extensions/desktop-icons/desktopGrid.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/extensions/desktop-icons/desktopGrid.js b/extensions/desktop-icons/desktopGrid.js
index 94d2dfd..602fa7f 100644
--- a/extensions/desktop-icons/desktopGrid.js
+++ b/extensions/desktop-icons/desktopGrid.js
@@ -21,6 +21,7 @@ const Clutter = imports.gi.Clutter;
 const St = imports.gi.St;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
+const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 
 const Signals = imports.signals;
@@ -123,6 +124,7 @@ var DesktopGrid = class {
             () => this._backgroundDestroyed());
 
         this._grid.connect('button-press-event', (actor, event) => this._onPressButton(actor, event));
+        this._grid.connect('touch-event', (actor, event) => this._onTouchEvent(actor, event));
 
         this._grid.connect('key-press-event', this._onKeyPress.bind(this));
 
@@ -506,6 +508,23 @@ var DesktopGrid = class {
         return Clutter.EVENT_PROPAGATE;
     }
 
+    _onTouchEvent(actor, event) {
+        // Let x11 pointer emulation do the job on X11
+        if (!Meta.is_wayland_compositor())
+            return Clutter.EVENT_PROPAGATE;
+
+       if (event.type() == Clutter.EventType.TOUCH_BEGIN &&
+           global.display.is_pointer_emulating_sequence(event.get_event_sequence())) {
+            Extension.desktopManager.clearSelection();
+            let [x, y] = event.get_coords();
+            let [gridX, gridY] = this._grid.get_transformed_position();
+            Extension.desktopManager.startRubberBand(x, y, gridX, gridY);
+            return Clutter.EVENT_STOP;
+        }
+
+        return Clutter.EVENT_PROPAGATE;
+    }
+
     _addDesktopBackgroundMenu() {
         this.actor._desktopBackgroundMenu = this._createDesktopBackgroundMenu();
         this.actor._desktopBackgroundManager = new PopupMenu.PopupMenuManager({ actor: this.actor });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]