Changeset View
Changeset View
Standalone View
Standalone View
idle_inhibition.cpp
Show All 13 Lines | |||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
17 | 17 | | |||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "idle_inhibition.h" | 21 | #include "idle_inhibition.h" | ||
22 | #include "abstract_client.h" | ||||
22 | #include "deleted.h" | 23 | #include "deleted.h" | ||
23 | #include "xdgshellclient.h" | | |||
24 | #include "workspace.h" | 24 | #include "workspace.h" | ||
25 | 25 | | |||
26 | #include <KWayland/Server/idle_interface.h> | 26 | #include <KWayland/Server/idle_interface.h> | ||
27 | #include <KWayland/Server/surface_interface.h> | 27 | #include <KWayland/Server/surface_interface.h> | ||
28 | 28 | | |||
29 | #include <algorithm> | 29 | #include <algorithm> | ||
30 | #include <functional> | 30 | #include <functional> | ||
31 | 31 | | |||
32 | using KWayland::Server::SurfaceInterface; | 32 | using KWayland::Server::SurfaceInterface; | ||
33 | 33 | | |||
34 | namespace KWin | 34 | namespace KWin | ||
35 | { | 35 | { | ||
36 | 36 | | |||
37 | IdleInhibition::IdleInhibition(IdleInterface *idle) | 37 | IdleInhibition::IdleInhibition(IdleInterface *idle) | ||
38 | : QObject(idle) | 38 | : QObject(idle) | ||
39 | , m_idle(idle) | 39 | , m_idle(idle) | ||
40 | { | 40 | { | ||
41 | // Workspace is created after the wayland server is initialized. | 41 | // Workspace is created after the wayland server is initialized. | ||
42 | connect(kwinApp(), &Application::workspaceCreated, this, &IdleInhibition::slotWorkspaceCreated); | 42 | connect(kwinApp(), &Application::workspaceCreated, this, &IdleInhibition::slotWorkspaceCreated); | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | IdleInhibition::~IdleInhibition() = default; | 45 | IdleInhibition::~IdleInhibition() = default; | ||
46 | 46 | | |||
47 | void IdleInhibition::registerXdgShellClient(XdgShellClient *client) | 47 | void IdleInhibition::registerClient(AbstractClient *client) | ||
48 | { | 48 | { | ||
49 | auto updateInhibit = [this, client] { | 49 | auto updateInhibit = [this, client] { | ||
50 | update(client); | 50 | update(client); | ||
51 | }; | 51 | }; | ||
52 | 52 | | |||
53 | m_connections[client] = connect(client->surface(), &SurfaceInterface::inhibitsIdleChanged, this, updateInhibit); | 53 | m_connections[client] = connect(client->surface(), &SurfaceInterface::inhibitsIdleChanged, this, updateInhibit); | ||
54 | connect(client, &XdgShellClient::desktopChanged, this, updateInhibit); | 54 | connect(client, &AbstractClient::desktopChanged, this, updateInhibit); | ||
55 | connect(client, &XdgShellClient::clientMinimized, this, updateInhibit); | 55 | connect(client, &AbstractClient::clientMinimized, this, updateInhibit); | ||
56 | connect(client, &XdgShellClient::clientUnminimized, this, updateInhibit); | 56 | connect(client, &AbstractClient::clientUnminimized, this, updateInhibit); | ||
57 | connect(client, &XdgShellClient::windowHidden, this, updateInhibit); | 57 | connect(client, &AbstractClient::windowHidden, this, updateInhibit); | ||
58 | connect(client, &XdgShellClient::windowShown, this, updateInhibit); | 58 | connect(client, &AbstractClient::windowShown, this, updateInhibit); | ||
59 | connect(client, &XdgShellClient::windowClosed, this, | 59 | connect(client, &AbstractClient::windowClosed, this, | ||
60 | [this, client] { | 60 | [this, client] { | ||
61 | uninhibit(client); | 61 | uninhibit(client); | ||
62 | auto it = m_connections.find(client); | 62 | auto it = m_connections.find(client); | ||
63 | if (it != m_connections.end()) { | 63 | if (it != m_connections.end()) { | ||
64 | disconnect(it.value()); | 64 | disconnect(it.value()); | ||
65 | m_connections.erase(it); | 65 | m_connections.erase(it); | ||
66 | } | 66 | } | ||
67 | } | 67 | } | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |