summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/Widget.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Window.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Window.h2
3 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp
index 8e9da86a51..96c30728cb 100644
--- a/Userland/Libraries/LibGUI/Widget.cpp
+++ b/Userland/Libraries/LibGUI/Widget.cpp
@@ -726,6 +726,8 @@ void Widget::set_visible(bool visible)
parent->invalidate_layout();
if (m_visible)
update();
+ if (!m_visible && is_focused())
+ set_focus(false);
if (m_visible) {
ShowEvent e;
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp
index d3ade0736d..648371985d 100644
--- a/Userland/Libraries/LibGUI/Window.cpp
+++ b/Userland/Libraries/LibGUI/Window.cpp
@@ -654,11 +654,15 @@ void Window::set_focused_widget(Widget* widget, FocusSource source)
WeakPtr<Widget> previously_focused_widget = m_focused_widget;
m_focused_widget = widget;
+ if (!m_focused_widget && m_previously_focused_widget)
+ m_focused_widget = m_previously_focused_widget;
+
if (previously_focused_widget) {
Core::EventLoop::current().post_event(*previously_focused_widget, make<FocusEvent>(Event::FocusOut, source));
previously_focused_widget->update();
if (previously_focused_widget && previously_focused_widget->on_focus_change)
previously_focused_widget->on_focus_change(previously_focused_widget->is_focused(), source);
+ m_previously_focused_widget = previously_focused_widget;
}
if (m_focused_widget) {
Core::EventLoop::current().post_event(*m_focused_widget, make<FocusEvent>(Event::FocusIn, source));
diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h
index ad4bd7e3dc..662141ff4b 100644
--- a/Userland/Libraries/LibGUI/Window.h
+++ b/Userland/Libraries/LibGUI/Window.h
@@ -228,6 +228,8 @@ private:
void flip(const Vector<Gfx::IntRect, 32>& dirty_rects);
void force_update();
+ WeakPtr<Widget> m_previously_focused_widget;
+
OwnPtr<WindowBackingStore> m_front_store;
OwnPtr<WindowBackingStore> m_back_store;