set focus after scrolling with the touchpad gesture
Co-authored-by: Grafcube <grafcube@disroot.org>
This commit is contained in:
@@ -141,8 +141,20 @@ class Desktop {
|
||||
this.setScroll(this.gestureScrollXInitial + this.config.gestureScrollStep * amount, false);
|
||||
}
|
||||
|
||||
public gestureScrollFinish() {
|
||||
public gestureScrollFinish(focusedWindow: Window|null) {
|
||||
const scrolledRight = this.scrollX > this.gestureScrollXInitial!;
|
||||
this.gestureScrollXInitial = null;
|
||||
|
||||
const visibleRange = this.getCurrentVisibleRange();
|
||||
if (focusedWindow !== null && !Range.contains(visibleRange, focusedWindow.column)) {
|
||||
// the focused window is no longer visible, find a new window to focus
|
||||
const focusTargetColumn = scrolledRight ?
|
||||
this.grid.getLeftmostVisibleColumn(visibleRange) :
|
||||
this.grid.getRightmostVisibleColumn(visibleRange);
|
||||
if (focusTargetColumn !== null) {
|
||||
focusTargetColumn.getWindowToFocus().focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public arrange() {
|
||||
|
||||
@@ -158,9 +158,11 @@ class World {
|
||||
|
||||
public gestureScrollFinish() {
|
||||
this.do((clientManager, desktopManager) => {
|
||||
const focusedWindow = Workspace.activeWindow === null ? null : clientManager.findTiledWindow(Workspace.activeWindow);
|
||||
const currentDesktop = desktopManager.getCurrentDesktop();
|
||||
if (currentDesktop !== undefined) {
|
||||
currentDesktop.gestureScrollFinish();
|
||||
console.assert(focusedWindow === null || focusedWindow.column.grid.desktop === currentDesktop);
|
||||
currentDesktop.gestureScrollFinish(focusedWindow);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user