Add a Toplevel *Workspace::findInternal(QWindow *w) const

This method is able to match a QWindow created by KWin to a Toplevel.
On X11 by matching winId against Unmanaged, on Wayland by matching
to internal window of ShellClient.

Finding the internal window is a commonly needed feature to e.g.
elevate the TabBox window.
This commit is contained in:
Martin Gräßlin 2016-03-04 09:42:33 +01:00
parent 9c78d28327
commit 59e3b96812
2 changed files with 21 additions and 0 deletions

View file

@ -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

View file

@ -127,6 +127,15 @@ public:
Unmanaged *findUnmanaged(xcb_window_t w) const;
void forEachUnmanaged(std::function<void (Unmanaged*)> func);
Toplevel *findToplevel(std::function<bool (const Toplevel*)> 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;