summaryrefslogtreecommitdiff
path: root/plugingui/nativewindow_x11.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-02-10 18:39:27 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-02-10 18:39:27 +0100
commit09e923d965a86a944dad7d77b336721386f6bf63 (patch)
tree1000abf99b16bb6d70d8d88f1cd26096b634b027 /plugingui/nativewindow_x11.cc
parent53fa1c76c27726670f2724793d867d817c029709 (diff)
Return a list of events form native window instead of one event at a time.
Diffstat (limited to 'plugingui/nativewindow_x11.cc')
-rw-r--r--plugingui/nativewindow_x11.cc67
1 files changed, 9 insertions, 58 deletions
diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc
index f50e01d..3fffcd5 100644
--- a/plugingui/nativewindow_x11.cc
+++ b/plugingui/nativewindow_x11.cc
@@ -264,52 +264,21 @@ void NativeWindowX11::grabMouse(bool grab)
// Don't need to do anything on this platform...
}
-bool NativeWindowX11::hasEvent()
+std::queue<std::shared_ptr<Event>> NativeWindowX11::getEvents()
{
- if(display == nullptr)
- {
- return false;
- }
-
- return XPending(display);
-}
-
-std::shared_ptr<Event> NativeWindowX11::getNextEvent()
-{
- if(display == nullptr)
- {
- return nullptr;
- }
-
- if(!XPending(display))
- {
- return nullptr;
- }
-
- XEvent xEvent;
- XNextEvent(display, &xEvent);
- return translateXMessage(xEvent);
-}
+ std::queue<std::shared_ptr<Event>> events;
-std::shared_ptr<Event> NativeWindowX11::peekNextEvent()
-{
- if(display == nullptr)
+ while(XPending(display))
{
- return nullptr;
+ XEvent xEvent;
+ XNextEvent(display, &xEvent);
+ events.push(translateXMessage(xEvent));
}
- if(!XPending(display))
- {
- return nullptr;
- }
-
- XEvent peekXEvent;
- XPeekEvent(display, &peekXEvent);
- return translateXMessage(peekXEvent, true);
+ return events;
}
-std::shared_ptr<Event> NativeWindowX11::translateXMessage(XEvent& xevent,
- bool peek)
+std::shared_ptr<Event> NativeWindowX11::translateXMessage(XEvent& xevent)
{
std::shared_ptr<Event> event = nullptr;
@@ -327,15 +296,6 @@ std::shared_ptr<Event> NativeWindowX11::translateXMessage(XEvent& xevent,
case Expose:
//DEBUG(x11, "Expose");
- //if(!peek)
- //{
- // XEvent peekXEvent;
- // while(XCheckWindowEvent(display, xwindow, Expose, &peekXEvent))
- // {
- // xevent.xexpose = peekXEvent.xexpose;
- // }
- //}
-
if(xevent.xexpose.count == 0)
{
auto repaintEvent = std::make_shared<RepaintEvent>();
@@ -351,15 +311,6 @@ std::shared_ptr<Event> NativeWindowX11::translateXMessage(XEvent& xevent,
case ConfigureNotify:
//DEBUG(x11, "ConfigureNotify");
{
- //if(!peek)
- //{
- // XEvent peekXEvent;
- // while(XCheckWindowEvent(display, xwindow, ConfigureNotify, &peekXEvent))
- // {
- // xevent.xconfigure = peekXEvent.xconfigure;
- // }
- //}
-
if((window.width() != (std::size_t)xevent.xconfigure.width) ||
(window.height() != (std::size_t)xevent.xconfigure.height))
{
@@ -435,7 +386,7 @@ std::shared_ptr<Event> NativeWindowX11::translateXMessage(XEvent& xevent,
(xevent.type == ButtonPress) &&
((xevent.xbutton.time - last_click) < 200);
- if(!peek && (xevent.type == ButtonPress))
+ if(xevent.type == ButtonPress)
{
last_click = xevent.xbutton.time;
}