Parcourir la source

Spreadsheet+LibGUI: Set EmojiInputDialog as a CaptureInput modal

This has two advantages: First the picker no longer changes the active
window state of its parent. Visually this is an additional hint that the
dialog is "fragile" and will close on loss of focus. Second, because
it contains a search box, its own input won't be preempted by global
application shortcuts when typing (pending #15129). This is a problem
in apps like PixelPaint which use shortcuts without modifiers.
thankyouverycool il y a 2 ans
Parent
commit
b70e4e9909

+ 0 - 1
Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp

@@ -212,7 +212,6 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
 
     m_insert_emoji_action = GUI::CommonActions::make_insert_emoji_action([&](auto&) {
         auto emoji_input_dialog = GUI::EmojiInputDialog::construct(window());
-        emoji_input_dialog->set_window_mode(GUI::WindowMode::Passive);
         if (emoji_input_dialog->exec() != GUI::EmojiInputDialog::ExecResult::OK)
             return;
 

+ 0 - 1
Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp

@@ -195,7 +195,6 @@ 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 (!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)
             return;
         key_event->m_key = Key_Invalid;

+ 8 - 2
Userland/Libraries/LibGUI/EmojiInputDialog.cpp

@@ -55,6 +55,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
     set_frameless(true);
     set_blocks_command_palette(true);
     set_blocks_emoji_input(true);
+    set_window_mode(GUI::WindowMode::CaptureInput);
     resize(400, 300);
 
     auto& scrollable_container = *main_widget.find_descendant_of_type_named<GUI::ScrollableContainerWidget>("scrollable_container"sv);
@@ -90,8 +91,13 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
     scrollable_container.horizontal_scrollbar().set_visible(false);
     update_displayed_emoji();
 
-    on_active_window_change = [this](bool is_active_window) {
-        if (!is_active_window)
+    on_active_input_change = [this](bool is_active_input) {
+        if (!is_active_input)
+            close();
+    };
+
+    on_input_preemption = [this](InputPreemptor preemptor) {
+        if (preemptor != InputPreemptor::ContextMenu)
             close();
     };
 

+ 0 - 1
Userland/Libraries/LibGUI/TextEditor.cpp

@@ -779,7 +779,6 @@ void TextEditor::insert_emoji()
         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)
         return;