mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-16 17:00:35 +03:00
LibGUI: Allow blocking CommandPalette/EmojiInput on a per Window basis
Instead of having to negate every focusable widget or textbox, let windows override all their widgets. These two Dialogs now block themselves and each other.
This commit is contained in:
parent
bfcb4d88cf
commit
f8e65d24cf
Notes:
sideshowbarker
2024-07-17 07:19:11 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/f8e65d24cf Pull-request: https://github.com/SerenityOS/serenity/pull/15175 Reviewed-by: https://github.com/trflynn89 ✅
@ -176,6 +176,8 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen
|
||||
: GUI::Dialog(&parent_window, screen_position)
|
||||
{
|
||||
set_frameless(true);
|
||||
set_blocks_command_palette(true);
|
||||
set_blocks_emoji_input(true);
|
||||
resize(450, 300);
|
||||
|
||||
collect_actions(parent_window);
|
||||
|
@ -193,7 +193,7 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
|
||||
}
|
||||
|
||||
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->accepts_emoji_input();
|
||||
if (focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) {
|
||||
if (!window->blocks_emoji_input() && focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) {
|
||||
auto emoji_input_dialog = EmojiInputDialog::construct(window);
|
||||
emoji_input_dialog->set_window_mode(GUI::WindowMode::Passive);
|
||||
if (emoji_input_dialog->exec() != EmojiInputDialog::ExecResult::OK)
|
||||
@ -207,8 +207,8 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
|
||||
key_event->m_code_point = emoji_code_point;
|
||||
}
|
||||
|
||||
bool accepts_command_palette = true;
|
||||
if (window->focused_widget())
|
||||
bool accepts_command_palette = !window->blocks_command_palette();
|
||||
if (accepts_command_palette && window->focused_widget())
|
||||
accepts_command_palette = window->focused_widget()->accepts_command_palette();
|
||||
|
||||
// FIXME: This shortcut should be configurable.
|
||||
|
@ -53,6 +53,8 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
set_frameless(true);
|
||||
set_blocks_command_palette(true);
|
||||
set_blocks_emoji_input(true);
|
||||
resize(400, 300);
|
||||
|
||||
auto& scrollable_container = *main_widget.find_descendant_of_type_named<GUI::ScrollableContainerWidget>("scrollable_container"sv);
|
||||
|
@ -775,6 +775,9 @@ void TextEditor::select_all()
|
||||
|
||||
void TextEditor::insert_emoji()
|
||||
{
|
||||
if (!accepts_emoji_input() || window()->blocks_emoji_input())
|
||||
return;
|
||||
|
||||
auto emoji_input_dialog = EmojiInputDialog::construct(window());
|
||||
emoji_input_dialog->set_window_mode(GUI::WindowMode::Passive);
|
||||
if (emoji_input_dialog->exec() != EmojiInputDialog::ExecResult::OK)
|
||||
@ -1722,6 +1725,8 @@ void TextEditor::context_menu_event(ContextMenuEvent& event)
|
||||
if (is_displayonly())
|
||||
return;
|
||||
|
||||
m_insert_emoji_action->set_enabled(accepts_emoji_input() && !window()->blocks_emoji_input());
|
||||
|
||||
if (!m_context_menu) {
|
||||
m_context_menu = Menu::construct();
|
||||
m_context_menu->add_action(undo_action());
|
||||
|
@ -225,6 +225,12 @@ public:
|
||||
Menubar& menubar() { return *m_menubar; }
|
||||
Menubar const& menubar() const { return *m_menubar; }
|
||||
|
||||
void set_blocks_command_palette(bool b) { m_blocks_command_palette = b; }
|
||||
bool blocks_command_palette() const { return m_blocks_command_palette; }
|
||||
|
||||
void set_blocks_emoji_input(bool b) { m_blocks_emoji_input = b; }
|
||||
bool blocks_emoji_input() const { return m_blocks_emoji_input; }
|
||||
|
||||
protected:
|
||||
Window(Core::Object* parent = nullptr);
|
||||
virtual void wm_event(WMEvent&);
|
||||
@ -307,6 +313,8 @@ private:
|
||||
bool m_visible_for_timer_purposes { true };
|
||||
bool m_visible { false };
|
||||
bool m_moved_by_client { false };
|
||||
bool m_blocks_command_palette { false };
|
||||
bool m_blocks_emoji_input { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user