| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "OSScreenSaverIdleInhibitUnstableV1.h" |
| 10 |
|
| 11 |
#include "Registry.h" |
| 12 |
|
| 13 |
#include <cassert> |
| 14 |
|
| 15 |
using namespace KODI::WINDOWING::WAYLAND; |
| 16 |
|
| 17 |
COSScreenSaverIdleInhibitUnstableV1* COSScreenSaverIdleInhibitUnstableV1::TryCreate(CConnection& connection, wayland::surface_t const& inhibitSurface) |
| 18 |
{ |
| 19 |
wayland::zwp_idle_inhibit_manager_v1_t manager; |
| 20 |
CRegistry registry{connection}; |
| 21 |
registry.RequestSingleton(manager, 1, 1, false); |
| 22 |
registry.Bind(); |
| 23 |
|
| 24 |
if (manager) |
| 25 |
{ |
| 26 |
return new COSScreenSaverIdleInhibitUnstableV1(manager, inhibitSurface); |
| 27 |
} |
| 28 |
else |
| 29 |
{ |
| 30 |
return nullptr; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
COSScreenSaverIdleInhibitUnstableV1::COSScreenSaverIdleInhibitUnstableV1(const wayland::zwp_idle_inhibit_manager_v1_t& manager, const wayland::surface_t& inhibitSurface) |
| 35 |
: m_manager{manager}, m_surface{inhibitSurface} |
| 36 |
{ |
| 37 |
assert(m_manager); |
| 38 |
assert(m_surface); |
| 39 |
} |
| 40 |
|
| 41 |
void COSScreenSaverIdleInhibitUnstableV1::Inhibit() |
| 42 |
{ |
| 43 |
if (!m_inhibitor) |
| 44 |
{ |
| 45 |
m_inhibitor = m_manager.create_inhibitor(m_surface); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
void COSScreenSaverIdleInhibitUnstableV1::Uninhibit() |
| 50 |
{ |
| 51 |
m_inhibitor.proxy_release(); |
| 52 |
} |