diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-02-03 15:01:07 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-03 23:28:56 +0100 |
commit | bf4328de52f4807d4f356d90a7a402429558409b (patch) | |
tree | baadbb901b8cf679b6c04b7eec3e44da8b8ab8a2 /Userland | |
parent | a4cb6a49ae00d1f1288c5a50a568abd5db67c638 (diff) | |
download | serenity-bf4328de52f4807d4f356d90a7a402429558409b.zip |
LibGUI: Allow widgets to opt-out from showing the command palette
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/Widget.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/WindowServerConnection.cpp | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index d8074de3f5..b8c7979d2d 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -283,6 +283,9 @@ public: void set_accepts_emoji_input(bool b) { m_accepts_emoji_input = b; } bool accepts_emoji_input() const { return m_accepts_emoji_input; } + void set_accepts_command_palette(bool b) { m_accepts_command_palette = b; } + bool accepts_command_palette() const { return m_accepts_command_palette; } + virtual Gfx::IntRect children_clip_rect() const; AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> override_cursor() const { return m_override_cursor; } @@ -378,6 +381,7 @@ private: bool m_enabled { true }; bool m_updates_enabled { true }; bool m_accepts_emoji_input { false }; + bool m_accepts_command_palette { true }; bool m_shrink_to_fit { false }; bool m_default_font { true }; diff --git a/Userland/Libraries/LibGUI/WindowServerConnection.cpp b/Userland/Libraries/LibGUI/WindowServerConnection.cpp index 2cf836458a..26909be401 100644 --- a/Userland/Libraries/LibGUI/WindowServerConnection.cpp +++ b/Userland/Libraries/LibGUI/WindowServerConnection.cpp @@ -196,7 +196,8 @@ void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u3 } // FIXME: This shortcut should be configurable. - if (!m_in_command_palette && modifiers == (Mod_Ctrl | Mod_Shift) && key == Key_A) { + bool focused_widget_accepts_command_palette = window->focused_widget() && window->focused_widget()->accepts_command_palette(); + if (focused_widget_accepts_command_palette && !m_in_command_palette && modifiers == (Mod_Ctrl | Mod_Shift) && key == Key_A) { auto command_palette = CommandPalette::construct(*window); TemporaryChange change { m_in_command_palette, true }; if (command_palette->exec() != GUI::Dialog::ExecOK) |