summaryrefslogtreecommitdiff
path: root/plugingui/nativewindow_x11.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-10-28 17:55:06 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-10-28 17:55:06 +0200
commit05b3e8cdc7f6cf7056c96d9cd150a0e2a8fb85a4 (patch)
tree19c2723984cef60a8000812dc4fb5176dcba42d0 /plugingui/nativewindow_x11.cc
parente19d48332a7bc8963bc0a58d746a75dc15eeb58c (diff)
Rewrite event handler to use shared_ptr Events instead of raw pointers.
Diffstat (limited to 'plugingui/nativewindow_x11.cc')
-rw-r--r--plugingui/nativewindow_x11.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc
index b0188e1..f50551e 100644
--- a/plugingui/nativewindow_x11.cc
+++ b/plugingui/nativewindow_x11.cc
@@ -354,7 +354,7 @@ bool NativeWindowX11::hasEvent()
return XPending(display);
}
-Event* NativeWindowX11::getNextEvent()
+std::shared_ptr<Event> NativeWindowX11::getNextEvent()
{
if(display == nullptr)
{
@@ -366,7 +366,7 @@ Event* NativeWindowX11::getNextEvent()
return translateXMessage(xEvent);
}
-Event* NativeWindowX11::peekNextEvent()
+std::shared_ptr<Event> NativeWindowX11::peekNextEvent()
{
if(display == nullptr)
{
@@ -378,14 +378,15 @@ Event* NativeWindowX11::peekNextEvent()
return translateXMessage(peekXEvent, true);
}
-Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
+std::shared_ptr<Event> NativeWindowX11::translateXMessage(XEvent& xevent,
+ bool peek)
{
- Event* event = nullptr;
+ std::shared_ptr<Event> event = nullptr;
switch(xevent.type) {
case MotionNotify:
{
- auto mouseMoveEvent = new MouseMoveEvent();
+ auto mouseMoveEvent = std::make_shared<MouseMoveEvent>();
mouseMoveEvent->window_id = xevent.xmotion.window;
mouseMoveEvent->x = xevent.xmotion.x;
mouseMoveEvent->y = xevent.xmotion.y;
@@ -396,7 +397,7 @@ Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
case Expose:
if(xevent.xexpose.count == 0)
{
- auto repaintEvent = new RepaintEvent();
+ auto repaintEvent = std::make_shared<RepaintEvent>();
repaintEvent->window_id = xevent.xexpose.window;
repaintEvent->x = xevent.xexpose.x;
repaintEvent->y = xevent.xexpose.y;
@@ -408,7 +409,7 @@ Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
case ConfigureNotify:
{
- auto resizeEvent = new ResizeEvent();
+ auto resizeEvent = std::make_shared<ResizeEvent>();
resizeEvent->window_id = xevent.xconfigure.window;
//resizeEvent->x = xevent.xconfigure.x;
//resizeEvent->y = xevent.xconfigure.y;
@@ -424,7 +425,7 @@ Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
if((xevent.xbutton.button == 4) || (xevent.xbutton.button == 5))
{
int scroll = 1;
- auto scrollEvent = new ScrollEvent();
+ auto scrollEvent = std::make_shared<ScrollEvent>();
scrollEvent->window_id = xevent.xbutton.window;
scrollEvent->x = xevent.xbutton.x;
scrollEvent->y = xevent.xbutton.y;
@@ -433,7 +434,7 @@ Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
}
else
{
- auto buttonEvent = new ButtonEvent();
+ auto buttonEvent = std::make_shared<ButtonEvent>();
buttonEvent->window_id = xevent.xbutton.window;
buttonEvent->x = xevent.xbutton.x;
buttonEvent->y = xevent.xbutton.y;
@@ -474,7 +475,7 @@ Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
case KeyPress:
case KeyRelease:
{
- auto keyEvent = new KeyEvent();
+ auto keyEvent = std::make_shared<KeyEvent>();
keyEvent->window_id = xevent.xkey.window;
switch(xevent.xkey.keycode) {
@@ -512,7 +513,7 @@ Event* NativeWindowX11::translateXMessage(XEvent& xevent, bool peek)
case ClientMessage:
if(((unsigned int)xevent.xclient.data.l[0] == wmDeleteMessage))
{
- auto closeEvent = new CloseEvent();
+ auto closeEvent = std::make_shared<CloseEvent>();
event = closeEvent;
}
break;