Due to being a compositor, kwin has to conform to some certain interfaces. It means a lot of virtual functions and function tables to integrate with C APIs. Naturally, we not always want to use every argument in such functions. Since we get -Wunused-parameter from -Wall, we have to plumb those unused arguments in order to suppress compiler warnings at the moment. However, I don't think that extra work is worth it. We cannot change or alter prototypes in any way to fix the warning the desired way. Q_UNUSED and similar macros are not good indicators of whether an argument is used too, we tend to overlook putting or removing those macros. I've also noticed that Q_UNUSED are not used to guide us with the removal no longer needed parameters. Therefore, I think it's worth adding -Wno-unused-parameter compiler option to stop the compiler producing warnings about unused parameters. It changes nothing except that we don't need to put Q_UNUSED anymore, which can be really cumbersome sometimes. Note that it doesn't affect unused variables, you'll still get a -Wunused-variable compiler warning if a variable is unused.
74 lines
2 KiB
C++
74 lines
2 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
*/
|
|
#include "display.h"
|
|
#include "idle_interface_p.h"
|
|
#include "seat_interface.h"
|
|
|
|
#include "idledetector.h"
|
|
#include "input.h"
|
|
|
|
using namespace KWin;
|
|
|
|
namespace KWaylandServer
|
|
{
|
|
|
|
static const quint32 s_version = 1;
|
|
|
|
IdleInterfacePrivate::IdleInterfacePrivate(Display *display)
|
|
: QtWaylandServer::org_kde_kwin_idle(*display, s_version)
|
|
{
|
|
}
|
|
|
|
void IdleInterfacePrivate::org_kde_kwin_idle_get_idle_timeout(Resource *resource, uint32_t id, wl_resource *seat, uint32_t timeout)
|
|
{
|
|
SeatInterface *s = SeatInterface::get(seat);
|
|
Q_ASSERT(s);
|
|
|
|
wl_resource *idleTimoutResource = wl_resource_create(resource->client(), &org_kde_kwin_idle_timeout_interface, resource->version(), id);
|
|
if (!idleTimoutResource) {
|
|
wl_client_post_no_memory(resource->client());
|
|
return;
|
|
}
|
|
|
|
new IdleTimeoutInterface(std::chrono::milliseconds(timeout), idleTimoutResource);
|
|
}
|
|
|
|
IdleInterface::IdleInterface(Display *display, QObject *parent)
|
|
: QObject(parent)
|
|
, d(new IdleInterfacePrivate(display))
|
|
{
|
|
}
|
|
|
|
IdleInterface::~IdleInterface() = default;
|
|
|
|
IdleTimeoutInterface::IdleTimeoutInterface(std::chrono::milliseconds timeout, wl_resource *resource)
|
|
: QtWaylandServer::org_kde_kwin_idle_timeout(resource)
|
|
{
|
|
auto detector = new IdleDetector(timeout, this);
|
|
connect(detector, &IdleDetector::idle, this, [this]() {
|
|
send_idle();
|
|
});
|
|
connect(detector, &IdleDetector::resumed, this, [this]() {
|
|
send_resumed();
|
|
});
|
|
}
|
|
|
|
void IdleTimeoutInterface::org_kde_kwin_idle_timeout_release(Resource *resource)
|
|
{
|
|
wl_resource_destroy(resource->handle);
|
|
}
|
|
|
|
void IdleTimeoutInterface::org_kde_kwin_idle_timeout_destroy_resource(Resource *resource)
|
|
{
|
|
delete this;
|
|
}
|
|
|
|
void IdleTimeoutInterface::org_kde_kwin_idle_timeout_simulate_user_activity(Resource *resource)
|
|
{
|
|
input()->simulateUserActivity();
|
|
}
|
|
|
|
}
|