Jelajahi Sumber

Terminal+LibVT: Toggle TerminalWidget's focus on input preemption

This prevents Terminal's cursor from blinking when a Popup is open.
thankyouverycool 2 tahun lalu
induk
melakukan
f7eb72a8be

+ 4 - 0
Userland/Applications/Terminal/main.cpp

@@ -423,6 +423,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         return GUI::Window::CloseRequestDecision::StayOpen;
     };
 
+    window->on_input_preemption_change = [&](bool is_preempted) {
+        terminal->set_logical_focus(!is_preempted);
+    };
+
     TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/res", "r"));
     TRY(Core::System::unveil("/bin", "r"));

+ 2 - 2
Userland/Libraries/LibVT/TerminalWidget.h

@@ -96,6 +96,8 @@ public:
 
     void set_color_scheme(StringView);
 
+    void set_logical_focus(bool);
+
     VT::CursorShape cursor_shape() { return m_cursor_shape; }
     virtual void set_cursor_blinking(bool) override;
     virtual void set_cursor_shape(CursorShape) override;
@@ -136,8 +138,6 @@ private:
     // ^GUI::Clipboard::ClipboardClient
     virtual void clipboard_content_did_change(String const&) override { update_paste_action(); }
 
-    void set_logical_focus(bool);
-
     void send_non_user_input(ReadonlyBytes);
 
     Gfx::IntRect glyph_rect(u16 row, u16 column);