diff --git a/workspace.cpp b/workspace.cpp index 7547c64938..a179a198db 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1693,5 +1693,17 @@ void Workspace::forEachAbstractClient(std::function< void (AbstractClient*) > fu std::for_each(desktops.constBegin(), desktops.constEnd(), func); } +Toplevel *Workspace::findInternal(QWindow *w) const +{ + if (!w) { + return nullptr; + } + if (kwinApp()->operationMode() == Application::OperationModeX11) { + return findUnmanaged(w->winId()); + } else { + return waylandServer()->findClient(w); + } +} + } // namespace diff --git a/workspace.h b/workspace.h index 1c4d8a737b..0c07bed52d 100644 --- a/workspace.h +++ b/workspace.h @@ -127,6 +127,15 @@ public: Unmanaged *findUnmanaged(xcb_window_t w) const; void forEachUnmanaged(std::function func); Toplevel *findToplevel(std::function func) const; + /** + * @brief Finds a Toplevel for the internal window @p w. + * + * Internal window means a window created by KWin itself. On X11 this is an Unmanaged + * and mapped by the window id, on Wayland a ShellClient mapped on the internal window id. + * + * @returns Toplevel + **/ + Toplevel *findInternal(QWindow *w) const; QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const; QRect clientArea(clientAreaOption, const AbstractClient* c) const;