Skip to content

Commit

Permalink
fix(tiling): Prevent moving pointer if pointer is already in window
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Dec 31, 2020
1 parent 9e43c27 commit c97b9b2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,11 @@ export class ShellWindow {
private window_raised() {
this.restack(RESTACK_STATE.RAISED);
this.show_border();
if (this.ext.conf.move_pointer_on_switch && !this.pointer_already_on_window()) {
if (this.ext.conf.move_pointer_on_switch && !pointer_already_on_window(this.meta)) {
place_pointer_on(this.ext.conf.default_pointer_position, this.meta);
}
}

private pointer_already_on_window(): boolean {
const rect = Rect.Rectangle.from_meta(this.meta.get_frame_rect());
const cursor = lib.cursor_rect();

return cursor.intersects(rect);
}

private workspace_changed() {
this.restack(RESTACK_STATE.WORKSPACE_CHANGED);
}
Expand All @@ -557,7 +550,10 @@ export function activate(default_pointer_position: Config.DefaultPointerPosition
win.raise();
win.unminimize();
win.activate(global.get_current_time());
place_pointer_on(default_pointer_position, win)

if (!pointer_already_on_window(win)) {
place_pointer_on(default_pointer_position, win)
}
}

export function place_pointer_on(default_pointer_position: Config.DefaultPointerPosition, win: Meta.Window) {
Expand Down Expand Up @@ -598,3 +594,10 @@ export function place_pointer_on(default_pointer_position: Config.DefaultPointer
.get_pointer()
.warp(display.get_default_screen(), x, y);
}

function pointer_already_on_window(meta: Meta.Window): boolean {
const rect = Rect.Rectangle.from_meta(meta.get_frame_rect());
const cursor = lib.cursor_rect();

return cursor.intersects(rect);
}

0 comments on commit c97b9b2

Please sign in to comment.