Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
XWindowsEventQueueBuffer.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
4 * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
11
12#include <mutex>
13#include <vector>
14
15#include <X11/Xlib.h>
16
17class IEventQueue;
18
21{
22public:
23 XWindowsEventQueueBuffer(Display *, Window, IEventQueue *events);
27
30
31 // IEventQueueBuffer overrides
32 void init() override
33 {
34 // do nothing
35 }
36 void waitForEvent(double timeout) override;
37 Type getEvent(Event &event, uint32_t &dataID) override;
38 bool addEvent(uint32_t dataID) override;
39 bool isEmpty() const override;
40 EventQueueTimer *newTimer(double duration, bool oneShot) const override;
41 void deleteTimer(EventQueueTimer *) const override;
42
43private:
44 void flush();
45
46 int getPendingCountLocked();
47
48private:
49 using EventList = std::vector<XEvent>;
50
51 mutable std::mutex m_mutex;
52 Display *m_display;
53 Window m_window;
54 Atom m_userEvent;
55 XEvent m_event;
56 EventList m_postedEvents;
57 bool m_waiting = false;
58 int m_pipefd[2];
59 IEventQueue *m_events;
60};
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:39
Definition SimpleEventQueueBuffer.cpp:13
Event.
Definition Event.h:27
Event queue buffer interface.
Definition IEventQueueBuffer.h:21
Type
Definition IEventQueueBuffer.h:24
Event queue interface.
Definition IEventQueue.h:32
~XWindowsEventQueueBuffer() override
Definition XWindowsEventQueueBuffer.cpp:44
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer &&)=delete
EventQueueTimer * newTimer(double duration, bool oneShot) const override
Create a timer object.
Definition XWindowsEventQueueBuffer.cpp:193
Type getEvent(Event &event, uint32_t &dataID) override
Get the next event.
Definition XWindowsEventQueueBuffer.cpp:132
void init() override
Initialize.
Definition XWindowsEventQueueBuffer.h:32
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer const &)=delete
XWindowsEventQueueBuffer & operator=(XWindowsEventQueueBuffer const &)=delete
XWindowsEventQueueBuffer & operator=(XWindowsEventQueueBuffer &&)=delete
void deleteTimer(EventQueueTimer *) const override
Destroy a timer object.
Definition XWindowsEventQueueBuffer.cpp:198
bool isEmpty() const override
Check if event queue buffer is empty.
Definition XWindowsEventQueueBuffer.cpp:187
bool addEvent(uint32_t dataID) override
Post an event.
Definition XWindowsEventQueueBuffer.cpp:152
void waitForEvent(double timeout) override
Block waiting for an event.
Definition XWindowsEventQueueBuffer.cpp:57
XWindowsEventQueueBuffer(Display *, Window, IEventQueue *events)
Definition XWindowsEventQueueBuffer.cpp:30