Add Workspace::findToplevel
Like findClient and findUnmanaged, just a little bit more generic. Toplevel::findInList got adjusted to support it.icc-effect-5.14.5
parent
7843bbdbfb
commit
e463905f04
|
@ -731,7 +731,7 @@ xcb_timestamp_t Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id, c
|
||||||
; // is transient for currently active window, even though it's not
|
; // is transient for currently active window, even though it's not
|
||||||
// the same app (e.g. kcookiejar dialog) -> allow activation
|
// the same app (e.g. kcookiejar dialog) -> allow activation
|
||||||
else if (groupTransient() &&
|
else if (groupTransient() &&
|
||||||
findInList<Client>(mainClients(), sameApplicationActiveHackPredicate) == NULL)
|
findInList<Client, Client>(mainClients(), sameApplicationActiveHackPredicate) == NULL)
|
||||||
; // standalone transient
|
; // standalone transient
|
||||||
else
|
else
|
||||||
first_window = false;
|
first_window = false;
|
||||||
|
|
10
toplevel.h
10
toplevel.h
|
@ -361,8 +361,8 @@ public:
|
||||||
* @param func The condition function (compare std::find_if)
|
* @param func The condition function (compare std::find_if)
|
||||||
* @return T* The found Toplevel or @c null if there is no matching Toplevel
|
* @return T* The found Toplevel or @c null if there is no matching Toplevel
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T, class U>
|
||||||
static T *findInList(const QList<T*> &list, std::function<bool (const T*)> func);
|
static T *findInList(const QList<T*> &list, std::function<bool (const U*)> func);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity);
|
void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity);
|
||||||
|
@ -718,9 +718,11 @@ inline quint32 Toplevel::surfaceId() const
|
||||||
return m_surfaceId;
|
return m_surfaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T, class U>
|
||||||
inline T *Toplevel::findInList(const QList<T*> &list, std::function<bool (const T*)> func)
|
inline T *Toplevel::findInList(const QList<T*> &list, std::function<bool (const U*)> func)
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_base_of<U, T>::value,
|
||||||
|
"U must be derived from T");
|
||||||
const auto it = std::find_if(list.begin(), list.end(), func);
|
const auto it = std::find_if(list.begin(), list.end(), func);
|
||||||
if (it == list.end()) {
|
if (it == list.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -1576,6 +1576,20 @@ Client *Workspace::findClient(Predicate predicate, xcb_window_t w) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toplevel *Workspace::findToplevel(std::function<bool (const Toplevel*)> func) const
|
||||||
|
{
|
||||||
|
if (Client *ret = Toplevel::findInList(clients, func)) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (Client *ret = Toplevel::findInList(desktops, func)) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (Unmanaged *ret = Toplevel::findInList(unmanaged, func)) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "workspace.moc"
|
#include "workspace.moc"
|
||||||
|
|
|
@ -122,6 +122,7 @@ public:
|
||||||
*/
|
*/
|
||||||
Unmanaged *findUnmanaged(xcb_window_t w) const;
|
Unmanaged *findUnmanaged(xcb_window_t w) const;
|
||||||
void forEachUnmanaged(std::function<void (Unmanaged*)> func);
|
void forEachUnmanaged(std::function<void (Unmanaged*)> func);
|
||||||
|
Toplevel *findToplevel(std::function<bool (const Toplevel*)> func) const;
|
||||||
|
|
||||||
QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const;
|
QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const;
|
||||||
QRect clientArea(clientAreaOption, const Client* c) const;
|
QRect clientArea(clientAreaOption, const Client* c) const;
|
||||||
|
|
Loading…
Reference in New Issue