1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

Detect the "Logo" (Windows/Apple/whatever) key and use it for window resize.

This will be comfortable enough while I'm still developing with emulators.
QEMU keeps eating my "Alt" key presses and it's making things difficult.
This commit is contained in:
Andreas Kling 2019-03-03 12:56:48 +01:00
parent 159fa99539
commit 57fe316e01
7 changed files with 21 additions and 2 deletions

View file

@ -107,13 +107,15 @@ enum KeyCode : byte {
Key_Pipe,
Key_Tilde,
Key_Backtick,
Key_Logo,
};
enum KeyModifier {
Mod_Alt = 0x01,
Mod_Ctrl = 0x02,
Mod_Shift = 0x04,
Mod_Mask = 0x07,
Mod_Logo = 0x08,
Mod_Mask = 0x0f,
Is_Press = 0x80,
};
@ -125,6 +127,7 @@ struct KeyEvent {
bool alt() const { return flags & Mod_Alt; }
bool ctrl() const { return flags & Mod_Ctrl; }
bool shift() const { return flags & Mod_Shift; }
bool logo() const { return flags & Mod_Logo; }
unsigned modifiers() const { return flags & Mod_Mask; }
bool is_press() const { return flags & Is_Press; }
};

View file

@ -72,6 +72,9 @@ static KeyCode unshifted_key_map[0x80] =
Key_Invalid,
Key_F11,
Key_F12,
Key_Invalid,
Key_Invalid,
Key_Logo,
};
static KeyCode shifted_key_map[0x100] =
@ -111,6 +114,9 @@ static KeyCode shifted_key_map[0x100] =
Key_Invalid,
Key_F11,
Key_F12,
Key_Invalid,
Key_Invalid,
Key_Logo,
};
void KeyboardDevice::key_state_changed(byte raw, bool pressed)
@ -143,6 +149,9 @@ void KeyboardDevice::handle_irq()
case 0x38: update_modifier(Mod_Alt, pressed); break;
case 0x1d: update_modifier(Mod_Ctrl, pressed); break;
case 0x2a: update_modifier(Mod_Shift, pressed); break;
case 0x5b: update_modifier(Mod_Logo, pressed); break;
}
switch (ch) {
case I8042_ACK: break;
default:
if (m_modifiers & Mod_Alt) {

View file

@ -124,6 +124,7 @@ public:
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
bool alt() const { return m_modifiers & Mod_Alt; }
bool shift() const { return m_modifiers & Mod_Shift; }
bool logo() const { return m_modifiers & Mod_Logo; }
byte modifiers() const { return m_modifiers; }
String text() const { return m_text; }

View file

@ -124,6 +124,8 @@ String GShortcut::to_string() const
parts.append("Shift");
if (m_modifiers & Mod_Alt)
parts.append("Alt");
if (m_modifiers & Mod_Logo)
parts.append("Logo");
parts.append(::to_string(m_key));

View file

@ -463,6 +463,7 @@ public:
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
bool alt() const { return m_modifiers & Mod_Alt; }
bool shift() const { return m_modifiers & Mod_Shift; }
bool logo() const { return m_modifiers & Mod_Logo; }
byte modifiers() const { return m_modifiers; }
char character() const { return m_character; }

View file

@ -756,7 +756,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
move_to_front(window);
set_active_window(&window);
}
if (event.type() == WSMessage::MouseDown && event.button() == MouseButton::Right) {
if (m_keyboard_modifiers == Mod_Logo && event.type() == WSMessage::MouseDown && event.button() == MouseButton::Right) {
start_window_resize(window, event);
return IterationDecision::Abort;
}
@ -984,6 +984,7 @@ void WSWindowManager::on_message(WSMessage& message)
if (message.is_key_event()) {
// FIXME: This is a good place to hook key events globally. :)
m_keyboard_modifiers = static_cast<WSKeyEvent&>(message).modifiers();
if (m_active_window)
return m_active_window->on_message(message);
return;

View file

@ -150,6 +150,8 @@ private:
bool m_flash_flush { false };
bool m_buffers_are_flipped { false };
byte m_keyboard_modifiers { 0 };
OwnPtr<WSMenu> m_system_menu;
Color m_menu_selection_color;
WeakPtr<WSMenuBar> m_current_menubar;