diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-11 01:48:09 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-11 01:48:09 +0200 |
commit | f337616741b690feb36ed8e104df85ed5117daaa (patch) | |
tree | ddf346dd5c7f3871d56f8457e3a496e829ae51ae /Widgets/EventLoopSDL.cpp | |
parent | aee66e011954b4a071edfca0e5ebf124da5f0ffb (diff) | |
download | serenity-f337616741b690feb36ed8e104df85ed5117daaa.zip |
More hacking on Widgets.
Diffstat (limited to 'Widgets/EventLoopSDL.cpp')
-rw-r--r-- | Widgets/EventLoopSDL.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Widgets/EventLoopSDL.cpp b/Widgets/EventLoopSDL.cpp index 13eb047075..f607c3be15 100644 --- a/Widgets/EventLoopSDL.cpp +++ b/Widgets/EventLoopSDL.cpp @@ -12,6 +12,19 @@ EventLoopSDL::~EventLoopSDL() { } +static inline MouseButton toMouseButton(byte sdlButton) +{ + printf("sdlbutton = %u\n", sdlButton); + if (sdlButton == 1) + return MouseButton::Left; + if (sdlButton == 2) + return MouseButton::Middle; + if (sdlButton == 3) + return MouseButton::Right; + ASSERT_NOT_REACHED(); + return MouseButton::None; +} + void EventLoopSDL::waitForEvent() { SDL_Event sdlEvent; @@ -30,6 +43,9 @@ void EventLoopSDL::waitForEvent() case SDL_MOUSEMOTION: postEvent(&AbstractScreen::the(), make<MouseEvent>(Event::MouseMove, sdlEvent.motion.x, sdlEvent.motion.y)); return; + case SDL_MOUSEBUTTONDOWN: + postEvent(&AbstractScreen::the(), make<MouseEvent>(Event::MouseDown, sdlEvent.button.x, sdlEvent.button.y, toMouseButton(sdlEvent.button.button))); + return; } } } |