Skip to content

Commit

Permalink
mouse-click-effects@anaximeno: Fix persistent movement tracking inter…
Browse files Browse the repository at this point in the history
…fering with DND operations (#752)
  • Loading branch information
anaximeno authored Sep 21, 2024
1 parent 01a42ea commit c50e10a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -309,6 +319,7 @@ class MouseClickEffects {
}

destroy() {
DND.removeDragMonitor(this);
this.set_active(false);
this.unset_keybindings();
this.settings.finalize();
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit c50e10a

Please sign in to comment.