deskflow/src/lib/platform/XWindowsEventQueueBuffer.h

64 lines
1.6 KiB
C
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
2012-06-10 16:50:54 +00:00
*/
#pragma once
#include "base/IEventQueueBuffer.h"
#include "mt/Mutex.h"
2012-06-10 16:50:54 +00:00
#include <vector>
2012-06-10 16:50:54 +00:00
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
2012-06-10 16:50:54 +00:00
#else
#include <X11/Xlib.h>
2012-06-10 16:50:54 +00:00
#endif
class IEventQueue;
2012-06-10 16:50:54 +00:00
//! Event queue buffer for X11
class XWindowsEventQueueBuffer : public IEventQueueBuffer
{
2012-06-10 16:50:54 +00:00
public:
XWindowsEventQueueBuffer(Display *, Window, IEventQueue *events);
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer const &) = delete;
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer &&) = delete;
~XWindowsEventQueueBuffer() override;
2012-06-10 16:50:54 +00:00
XWindowsEventQueueBuffer &operator=(XWindowsEventQueueBuffer const &) = delete;
XWindowsEventQueueBuffer &operator=(XWindowsEventQueueBuffer &&) = delete;
2020-11-03 10:52:56 +00:00
// IEventQueueBuffer overrides
void init() override
{
}
void waitForEvent(double timeout) override;
Type getEvent(Event &event, uint32_t &dataID) override;
bool addEvent(uint32_t dataID) override;
bool isEmpty() const override;
EventQueueTimer *newTimer(double duration, bool oneShot) const override;
void deleteTimer(EventQueueTimer *) const override;
2012-06-10 16:50:54 +00:00
private:
void flush();
2012-06-10 16:50:54 +00:00
int getPendingCountLocked();
2012-06-10 16:50:54 +00:00
private:
using EventList = std::vector<XEvent>;
2012-06-10 16:50:54 +00:00
Mutex m_mutex;
Display *m_display;
Window m_window;
Atom m_userEvent;
XEvent m_event;
EventList m_postedEvents;
bool m_waiting;
int m_pipefd[2];
IEventQueue *m_events;
2012-06-10 16:50:54 +00:00
};