KWin
Loading...
Searching...
No Matches
syncalarmx11filter.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include "syncalarmx11filter.h"
11#include "utils/xcbutils.h"
12#include "workspace.h"
13#include "x11window.h"
14
15namespace KWin
16{
17
22
23bool SyncAlarmX11Filter::event(xcb_generic_event_t *event)
24{
25 auto alarmEvent = reinterpret_cast<xcb_sync_alarm_notify_event_t *>(event);
26 auto client = workspace()->findClient([alarmEvent](const X11Window *client) {
27 const auto syncRequest = client->syncRequest();
28 return alarmEvent->alarm == syncRequest.alarm && alarmEvent->counter_value.hi == syncRequest.value.hi && alarmEvent->counter_value.lo == syncRequest.value.lo;
29 });
30 if (client) {
31 client->handleSync();
32 }
33 return false;
34}
35
36} // namespace KWin
bool event(xcb_generic_event_t *event) override
X11Window * findClient(std::function< bool(const X11Window *)> func) const
Finds the first Client matching the condition expressed by passed in func.
const SyncRequest & syncRequest() const
Definition x11window.h:287
static Extensions * self()
Definition xcbutils.cpp:346
int syncAlarmNotifyEvent() const
Definition xcbutils.cpp:539
Workspace * workspace()
Definition workspace.h:830