Browse Source

LibGUI: Allow activation of CommandPalette without a focused widget

Previously we required there to be a focused widget so it would have
been able to opt out. In case the isn't a focused widget there is no way
for it to opt out anyways, so let's allow CommandPalette to work in this
case :^)
networkException 3 years ago
parent
commit
daf2ebca3b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      Userland/Libraries/LibGUI/WindowServerConnection.cpp

+ 5 - 2
Userland/Libraries/LibGUI/WindowServerConnection.cpp

@@ -195,9 +195,12 @@ void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u3
         key_event->m_code_point = emoji_code_point;
     }
 
+    bool accepts_command_palette = true;
+    if (window->focused_widget())
+        accepts_command_palette = window->focused_widget()->accepts_command_palette();
+
     // FIXME: This shortcut should be configurable.
-    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) {
+    if (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)