mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-23 00:56:21 +03:00
x11: Wrap platform functions in XWindowsEventQueueBuffer class
This commit is contained in:
parent
2c32270d49
commit
51118014b1
@ -230,4 +230,5 @@ public:
|
||||
int level, int eGroup) = 0;
|
||||
virtual unsigned char do_XkbKeyGroupInfo(XkbDescPtr m_xkb,
|
||||
KeyCode keycode) = 0;
|
||||
virtual int XNextEvent(Display* display, XEvent* event_return) = 0;
|
||||
};
|
||||
|
@ -52,17 +52,18 @@ class EventQueueTimer { };
|
||||
// XWindowsEventQueueBuffer
|
||||
//
|
||||
|
||||
XWindowsEventQueueBuffer::XWindowsEventQueueBuffer(
|
||||
XWindowsEventQueueBuffer::XWindowsEventQueueBuffer(IXWindowsImpl* impl,
|
||||
Display* display, Window window, IEventQueue* events) :
|
||||
m_events(events),
|
||||
m_display(display),
|
||||
m_window(window),
|
||||
m_waiting(false)
|
||||
{
|
||||
m_impl = impl;
|
||||
assert(m_display != NULL);
|
||||
assert(m_window != None);
|
||||
|
||||
m_userEvent = XInternAtom(m_display, "BARRIER_USER_EVENT", False);
|
||||
m_userEvent = m_impl->XInternAtom(m_display, "BARRIER_USER_EVENT", False);
|
||||
// set up for pipe hack
|
||||
int result = pipe(m_pipefd);
|
||||
assert(result == 0);
|
||||
@ -206,7 +207,7 @@ XWindowsEventQueueBuffer::getEvent(Event& event, UInt32& dataID)
|
||||
flush();
|
||||
|
||||
// get next event
|
||||
XNextEvent(m_display, &m_event);
|
||||
m_impl->XNextEvent(m_display, &m_event);
|
||||
|
||||
// process event
|
||||
if (m_event.xany.type == ClientMessage &&
|
||||
@ -262,7 +263,7 @@ bool
|
||||
XWindowsEventQueueBuffer::isEmpty() const
|
||||
{
|
||||
Lock lock(&m_mutex);
|
||||
return (XPending(m_display) == 0 );
|
||||
return (m_impl->XPending(m_display) == 0 );
|
||||
}
|
||||
|
||||
EventQueueTimer*
|
||||
@ -284,8 +285,8 @@ XWindowsEventQueueBuffer::flush()
|
||||
|
||||
// flush the posted event list to the X server
|
||||
for (size_t i = 0; i < m_postedEvents.size(); ++i) {
|
||||
XSendEvent(m_display, m_window, False, 0, &m_postedEvents[i]);
|
||||
m_impl->XSendEvent(m_display, m_window, False, 0, &m_postedEvents[i]);
|
||||
}
|
||||
XFlush(m_display);
|
||||
m_impl->XFlush(m_display);
|
||||
m_postedEvents.clear();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mt/Mutex.h"
|
||||
#include "base/IEventQueueBuffer.h"
|
||||
#include "common/stdvector.h"
|
||||
#include "XWindowsImpl.h"
|
||||
|
||||
#if X_DISPLAY_MISSING
|
||||
# error X11 is required to build barrier
|
||||
@ -33,7 +34,8 @@ class IEventQueue;
|
||||
//! Event queue buffer for X11
|
||||
class XWindowsEventQueueBuffer : public IEventQueueBuffer {
|
||||
public:
|
||||
XWindowsEventQueueBuffer(Display*, Window, IEventQueue* events);
|
||||
XWindowsEventQueueBuffer(IXWindowsImpl* impl, Display*, Window,
|
||||
IEventQueue* events);
|
||||
virtual ~XWindowsEventQueueBuffer();
|
||||
|
||||
// IEventQueueBuffer overrides
|
||||
@ -51,6 +53,7 @@ private:
|
||||
|
||||
private:
|
||||
typedef std::vector<XEvent> EventList;
|
||||
IXWindowsImpl* m_impl;
|
||||
|
||||
Mutex m_mutex;
|
||||
Display* m_display;
|
||||
|
@ -639,3 +639,8 @@ unsigned char XWindowsImpl::do_XkbKeyGroupInfo(XkbDescPtr m_xkb,
|
||||
{
|
||||
return do_XkbKeyGroupInfo(m_xkb, keycode);
|
||||
}
|
||||
|
||||
int XWindowsImpl::XNextEvent(Display* display, XEvent* event_return)
|
||||
{
|
||||
return ::XNextEvent(display, event_return);
|
||||
}
|
||||
|
@ -192,4 +192,5 @@ public:
|
||||
int level, int eGroup);
|
||||
virtual unsigned char do_XkbKeyGroupInfo(XkbDescPtr m_xkb,
|
||||
KeyCode keycode);
|
||||
virtual int XNextEvent(Display* display, XEvent* event_return);
|
||||
};
|
||||
|
@ -160,7 +160,7 @@ XWindowsScreen::XWindowsScreen(
|
||||
&XWindowsScreen::handleSystemEvent));
|
||||
|
||||
// install the platform event queue
|
||||
m_events->adoptBuffer(new XWindowsEventQueueBuffer(
|
||||
m_events->adoptBuffer(new XWindowsEventQueueBuffer(m_impl,
|
||||
m_display, m_window, m_events));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user