1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:47:35 +00:00

LibGUI: Move shortcut actions from GEventLoop to GApplications.

I'm gonna want to have nested event loops sooner or later, so let's not
pollute GEventLoop with things that are meant to work globally.

This patch also changes key events to pass around their modifiers as a
bitfield all the way around the system instead of breaking them up.
This commit is contained in:
Andreas Kling 2019-03-03 12:32:15 +01:00
parent 725b57fe1f
commit 5e40aa4f1a
11 changed files with 63 additions and 55 deletions

View file

@ -4,6 +4,7 @@
#include <SharedGraphics/Rect.h>
#include <AK/AKString.h>
#include <AK/Types.h>
#include <Kernel/KeyCode.h>
class GEvent {
public:
@ -112,24 +113,24 @@ enum GMouseButton : byte {
class GKeyEvent final : public GEvent {
public:
GKeyEvent(Type type, int key)
GKeyEvent(Type type, int key, byte modifiers)
: GEvent(type)
, m_key(key)
, m_modifiers(modifiers)
{
}
int key() const { return m_key; }
bool ctrl() const { return m_ctrl; }
bool alt() const { return m_alt; }
bool shift() const { return m_shift; }
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
bool alt() const { return m_modifiers & Mod_Alt; }
bool shift() const { return m_modifiers & Mod_Shift; }
byte modifiers() const { return m_modifiers; }
String text() const { return m_text; }
private:
friend class GEventLoop;
int m_key { 0 };
bool m_ctrl { false };
bool m_alt { false };
bool m_shift { false };
byte m_modifiers { 0 };
String m_text;
};