Skip to content

Commit

Permalink
Restack position shadow actor when switching workspace
Browse files Browse the repository at this point in the history
When switching workspace, the _syncStacking() of
imports.ui.workspaceAnimation.WorkspaceGroup will be called, we need let
shadow actor always behind window by monkey patch this method

Fix #55
  • Loading branch information
yilozt committed Sep 13, 2022
1 parent 21cae39 commit 80baee9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions @imports/ui/workspaceAnimation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export class WorkspaceGroup extends Actor {
}>
_createWindows(): void;
_removeWindows(): void;
_syncStacking(): void;
_shouldShowWindow(win: Window): boolean;
}
24 changes: 23 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class Extension {
// The methods of gnome-shell to monkey patch
private _orig_add_window !: (_: Window) => void
private _orig_create_windows !: () => void
private _orig_sync_stacking !: () => void
private _orig_size_changed !: (wm: WM, actor: WindowActor) => void
private _add_background_menu !: typeof BackgroundMenu.addBackgroundMenu

Expand All @@ -55,6 +56,7 @@ export class Extension {
// extensions is disabled
this._orig_add_window = WindowPreview.prototype._addWindow
this._orig_create_windows = WorkspaceGroup.prototype._createWindows
this._orig_sync_stacking = WorkspaceGroup.prototype._syncStacking
this._orig_size_changed = WindowManager.prototype._sizeChangeWindowDone
this._add_background_menu = BackgroundMenu.addBackgroundMenu

Expand Down Expand Up @@ -234,12 +236,29 @@ export class Extension {
clone.translation_z + 0.006)
)

// Add reference shadow clone for clone actor, so that we
// can restack position of shadow when we need
;(clone as WsAnimationActor)._shadow_clone = shadow_clone
clone.bind_property ('visible', shadow_clone, 'visible', 0)
this.insert_child_below (shadow_clone, clone)
this.set_child_below_sibling (shadow_clone, clone)
}
})
}

// Let shadow actor always behind the window clone actor when we
// switch workspace by Ctrl+Alt+Left/Right
//
// Fix #55
WorkspaceGroup.prototype._syncStacking = function () {
self._orig_sync_stacking.apply (this, [])
for (const { clone } of this._windowRecords) {
const shadow_clone = (clone as WsAnimationActor)._shadow_clone
if (shadow_clone && shadow_clone.visible) {
this.set_child_below_sibling (shadow_clone, clone)
}
}
}

// Window Size Changed
WindowManager.prototype._sizeChangeWindowDone = function (
shell_wm,
Expand Down Expand Up @@ -295,6 +314,7 @@ export class Extension {
// Restore patched methods
WindowPreview.prototype._addWindow = this._orig_add_window
WorkspaceGroup.prototype._createWindows = this._orig_create_windows
WorkspaceGroup.prototype._syncStacking = this._orig_sync_stacking
WindowManager.prototype._sizeChangeWindowDone = this._orig_size_changed
BackgroundMenu.addBackgroundMenu = this._add_background_menu

Expand Down Expand Up @@ -401,3 +421,5 @@ const OverviewShadowActor = registerClass (
}
}
)

type WsAnimationActor = Clutter.Actor & { _shadow_clone?: Clutter.Actor }

0 comments on commit 80baee9

Please sign in to comment.