From 18fad099d5bb5de3d4b8634b995cde2a054bb290 Mon Sep 17 00:00:00 2001 From: anaximeno Date: Sat, 21 Sep 2024 17:27:43 -0100 Subject: [PATCH] FIx persistent movement tracking interfering with DND operations --- .../5.4/extension.js | 35 ++++++++++++++----- .../5.4/mouseMovementTracker.js | 1 + .../metadata.json | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/extension.js b/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/extension.js index 59992fe3..69e6c415 100644 --- a/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/extension.js +++ b/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/extension.js @@ -19,6 +19,7 @@ const Main = imports.ui.main; const Settings = imports.ui.settings; +const DND = imports.ui.dnd; const Gettext = imports.gettext; const ByteArray = imports.byteArray; const { Atspi, GLib, Gio } = imports.gi; @@ -59,19 +60,14 @@ class MouseClickEffects { this.clickAnimator = ClickAnimationFactory.createForMode(this.animation_mode); - this.display_click = (new Debouncer()).debounce((...args) => { - if (this.deactivate_in_fullscreen && global.display.focus_window && global.display.focus_window.is_fullscreen()) { - // global.log(UUID, "Click effects not displayed due to being disabled for fullscreen focused windows"); - return; - } - this.animate_click(...args); - }, CLICK_DEBOUNCE_MS); - this.listener = Atspi.EventListener.new(this.on_mouse_click.bind(this)); this.idleMonitor = null; this.mouse_movement_tracker = null; + this._enable_on_drag_end = false; + DND.addDragMonitor(this); + this.enabled = false; this.set_active(false); } @@ -254,6 +250,20 @@ class MouseClickEffects { return settings; } + dragMotion = ((event) => { + if (this.enabled) { + this._enable_on_drag_end = true; + this.set_active(false); + } + }).bind(this) + + dragDrop = ((event) => { + if (this._enable_on_drag_end) { + this._enable_on_drag_end = false; + this.set_active(true); + } + }).bind(this) + enable() { this.update_colored_icons(); this.set_keybindings(); @@ -309,6 +319,7 @@ class MouseClickEffects { } destroy() { + DND.removeDragMonitor(this); this.set_active(false); this.unset_keybindings(); this.settings.finalize(); @@ -390,6 +401,14 @@ class MouseClickEffects { return r_success; } + display_click = (new Debouncer()).debounce((...args) => { + if (this.deactivate_in_fullscreen && global.display.focus_window && global.display.focus_window.is_fullscreen()) { + // global.log(UUID, "Click effects not displayed due to being disabled for fullscreen focused windows"); + return; + } + this.animate_click(...args); + }, CLICK_DEBOUNCE_MS) + animate_click(click_type, color) { this.update_animation_mode(); diff --git a/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/mouseMovementTracker.js b/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/mouseMovementTracker.js index 9f95c984..bde5fdd7 100644 --- a/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/mouseMovementTracker.js +++ b/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/mouseMovementTracker.js @@ -30,6 +30,7 @@ var MouseMovementTracker = class MouseMovementTracker { opacity: this.opacity, gicon: this.icon, }); + this.icon_actor.set_style("pointer-events: none;"); this.move_to(x, y); Main.uiGroup.add_child(this.icon_actor); this.listener = PointerWatcher.addWatch(POINTER_WATCH_MS, this.move_to.bind(this)); diff --git a/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/metadata.json b/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/metadata.json index 1bdb7b2d..a47948aa 100644 --- a/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/metadata.json +++ b/mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/metadata.json @@ -1,7 +1,7 @@ { "uuid": "mouse-click-effects@anaximeno", "name": "Mouse Click Effects", - "version": "1.0.0", + "version": "1.0.1", "description": "Display mouse click effects on Cinnamon.", "url": "https://github.com/anaximeno/mouse-click-effects", "website": "https://github.com/anaximeno/mouse-click-effects",