From 649cb67f28d46dc7c740c4e1a998c753fd27febc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 21 Oct 2021 19:38:59 +0200 Subject: [PATCH] LibGUI: Don't paint TextEditor selection in non-focused widgets Showing the selection in non-focused text editors was not really useful, since refocusing the widget would clear or change the selection immediately anyway. Note that TextEditors in inactive windows can still be the focused widget within that window, and will still be painted with an "inactive" looking selection. --- Userland/Libraries/LibGUI/TextEditor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 5d42ae0491..149f9f2804 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -670,7 +670,7 @@ void TextEditor::paint_event(PaintEvent& event) } } - if (physical_line_has_selection) { + if (physical_line_has_selection && window()->focused_widget() == this) { size_t start_of_selection_within_visual_line = (size_t)max(0, (int)selection_start_column_within_line - (int)start_of_visual_line); size_t end_of_selection_within_visual_line = selection_end_column_within_line - start_of_visual_line; @@ -696,8 +696,8 @@ void TextEditor::paint_event(PaintEvent& event) visual_line_rect.height() }; - Color background_color = is_focused() ? palette().selection() : palette().inactive_selection(); - Color text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text(); + Color background_color = window()->is_active() ? palette().selection() : palette().inactive_selection(); + Color text_color = window()->is_active() ? palette().selection_text() : palette().inactive_selection_text(); painter.fill_rect(selection_rect, background_color);