Changeset View
Changeset View
Standalone View
Standalone View
idle_inhibition.h
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org> | 5 | Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org> | ||
6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 18 Lines | |||||
32 | class IdleInterface; | 33 | class IdleInterface; | ||
33 | } | 34 | } | ||
34 | } | 35 | } | ||
35 | 36 | | |||
36 | using KWayland::Server::IdleInterface; | 37 | using KWayland::Server::IdleInterface; | ||
37 | 38 | | |||
38 | namespace KWin | 39 | namespace KWin | ||
39 | { | 40 | { | ||
41 | class AbstractClient; | ||||
40 | class ShellClient; | 42 | class ShellClient; | ||
41 | 43 | | |||
42 | class IdleInhibition : public QObject | 44 | class IdleInhibition : public QObject | ||
43 | { | 45 | { | ||
44 | Q_OBJECT | 46 | Q_OBJECT | ||
45 | public: | 47 | public: | ||
46 | explicit IdleInhibition(IdleInterface *idle); | 48 | explicit IdleInhibition(IdleInterface *idle); | ||
47 | ~IdleInhibition(); | 49 | ~IdleInhibition(); | ||
48 | 50 | | |||
49 | void registerShellClient(ShellClient *client); | 51 | void registerShellClient(ShellClient *client); | ||
50 | 52 | | |||
51 | bool isInhibited() const { | 53 | bool isInhibited() const { | ||
52 | return !m_idleInhibitors.isEmpty(); | 54 | return !m_idleInhibitors.isEmpty(); | ||
53 | } | 55 | } | ||
54 | bool isInhibited(ShellClient *client) const { | 56 | bool isInhibited(AbstractClient *client) const { | ||
55 | return std::any_of(m_idleInhibitors.begin(), m_idleInhibitors.end(), [client] (auto c) { return c == client; }); | 57 | return std::any_of(m_idleInhibitors.begin(), m_idleInhibitors.end(), [client] (auto c) { return c == client; }); | ||
56 | } | 58 | } | ||
57 | 59 | | |||
60 | private Q_SLOTS: | ||||
graesslin: You don't need the Q_SLOTS any more with the new connect syntax. | |||||
zzag: Yes, I know, I just prefer to be explicit. | |||||
61 | void slotWorkspaceCreated(); | ||||
62 | void slotDesktopChanged(); | ||||
63 | | ||||
58 | private: | 64 | private: | ||
59 | void inhibit(ShellClient *client); | 65 | void inhibit(AbstractClient *client); | ||
60 | void uninhibit(ShellClient *client); | 66 | void uninhibit(AbstractClient *client); | ||
67 | void update(AbstractClient *client); | ||||
61 | 68 | | |||
62 | IdleInterface *m_idle; | 69 | IdleInterface *m_idle; | ||
63 | QVector<ShellClient*> m_idleInhibitors; | 70 | QVector<AbstractClient *> m_idleInhibitors; | ||
64 | QMap<ShellClient*, QMetaObject::Connection> m_connections; | 71 | QMap<AbstractClient *, QMetaObject::Connection> m_connections; | ||
65 | }; | 72 | }; | ||
66 | } | 73 | } |
You don't need the Q_SLOTS any more with the new connect syntax.