diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-21 07:28:04 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-21 07:28:04 +0100 |
commit | 51595603bd2cb3fa44db92fa7a5d09d6fa2e33ef (patch) | |
tree | 058f09a86402c07195d4efeb81239eb6cd7ee9c7 /WindowServer/WSScreen.cpp | |
parent | aefbbeb3cb1decfe7e8c5e331e4c7a9bd8668710 (diff) | |
download | serenity-51595603bd2cb3fa44db92fa7a5d09d6fa2e33ef.zip |
WindowServer: Rename WSEvent subclasses WSFooEvent for consistency.
Add a WSWindowInvalidationEvent that carries a rect instead of having an
awkward single-purpose rect in WSEvent.
Flesh out WSKeyEvent a bit more.
Diffstat (limited to 'WindowServer/WSScreen.cpp')
-rw-r--r-- | WindowServer/WSScreen.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/WindowServer/WSScreen.cpp b/WindowServer/WSScreen.cpp index e74a36a2e8..2634f2b018 100644 --- a/WindowServer/WSScreen.cpp +++ b/WindowServer/WSScreen.cpp @@ -47,7 +47,7 @@ void WSScreen::on_receive_mouse_data(int dx, int dy, bool left_button, bool righ if (right_button) buttons |= (unsigned)MouseButton::Right; if (m_cursor_location != prev_location) { - auto event = make<MouseEvent>(WSEvent::MouseMove, m_cursor_location, buttons); + auto event = make<WSMouseEvent>(WSEvent::MouseMove, m_cursor_location, buttons); WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); } bool prev_left_button = m_left_mouse_button_pressed; @@ -55,38 +55,22 @@ void WSScreen::on_receive_mouse_data(int dx, int dy, bool left_button, bool righ m_left_mouse_button_pressed = left_button; m_right_mouse_button_pressed = right_button; if (prev_left_button != left_button) { - auto event = make<MouseEvent>(left_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Left); + auto event = make<WSMouseEvent>(left_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Left); WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); } if (prev_right_button != right_button) { - auto event = make<MouseEvent>(right_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Right); + auto event = make<WSMouseEvent>(right_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Right); WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); } if (m_cursor_location != prev_location || prev_left_button != left_button) WSWindowManager::the().draw_cursor(); } -void WSScreen::on_receive_keyboard_data(Keyboard::Event key) +void WSScreen::on_receive_keyboard_data(Keyboard::Event kernel_event) { - auto event = make<KeyEvent>(key.is_press() ? WSEvent::KeyDown : WSEvent::KeyUp, 0); - int key_code = 0; - - switch (key.character) { - case 8: key_code = KeyboardKey::Backspace; break; - case 10: key_code = KeyboardKey::Return; break; - } - event->m_key = key_code; - - if (key.character) { - char buf[] = { 0, 0 }; - char& ch = buf[0]; - ch = key.character; - event->m_text = buf; - } - - event->m_shift = key.shift(); - event->m_ctrl = key.ctrl(); - event->m_alt = key.alt(); - + auto event = make<WSKeyEvent>(kernel_event.is_press() ? WSEvent::KeyDown : WSEvent::KeyUp, kernel_event.key, kernel_event.character); + event->m_shift = kernel_event.shift(); + event->m_ctrl = kernel_event.ctrl(); + event->m_alt = kernel_event.alt(); WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); } |