WindowServer+LibGUI: Notify windows when their maximized state changes
Previously, GUI::Window::is_maximized() had to make a synchronous IPC request to WindowServer in order to find out if the window was indeed maximized. This patch removes the need for synchronous IPC by instead pushing the maximization state to clients when it changes. The motivation for this change was that GUI::Statusbar was checking if the containing window was maximized in its resize_event(), causing all windows with a statusbar to block on sync IPC *during* resize. Browser would typically block for ~15 milliseconds here every time on my machine, continuously during live resize.
This commit is contained in:
parent
463dc91049
commit
1a38ab0ca1
Notes:
sideshowbarker
2024-07-17 14:24:52 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1a38ab0ca1
7 changed files with 16 additions and 20 deletions
|
@ -372,10 +372,10 @@ void ConnectionToWindowServer::drag_cancelled()
|
|||
Application::the()->notify_drag_cancelled({});
|
||||
}
|
||||
|
||||
void ConnectionToWindowServer::window_state_changed(i32 window_id, bool minimized, bool occluded)
|
||||
void ConnectionToWindowServer::window_state_changed(i32 window_id, bool minimized, bool maximized, bool occluded)
|
||||
{
|
||||
if (auto* window = Window::from_window_id(window_id))
|
||||
window->notify_state_changed({}, minimized, occluded);
|
||||
window->notify_state_changed({}, minimized, maximized, occluded);
|
||||
}
|
||||
|
||||
void ConnectionToWindowServer::display_link_notification()
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
virtual void drag_cancelled() override;
|
||||
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
|
||||
virtual void update_system_fonts(String const&, String const&) override;
|
||||
virtual void window_state_changed(i32, bool, bool) override;
|
||||
virtual void window_state_changed(i32, bool, bool, bool) override;
|
||||
virtual void display_link_notification() override;
|
||||
virtual void track_mouse_move(Gfx::IntPoint const&) override;
|
||||
virtual void ping() override;
|
||||
|
|
|
@ -169,7 +169,7 @@ void Window::show()
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
set_maximized(m_maximized_when_windowless);
|
||||
set_maximized(m_maximized);
|
||||
reified_windows->set(m_window_id, this);
|
||||
Application::the()->did_create_window({});
|
||||
update();
|
||||
|
@ -1019,17 +1019,9 @@ void Window::set_forced_shadow(bool shadow)
|
|||
ConnectionToWindowServer::the().async_set_forced_shadow(m_window_id, shadow);
|
||||
}
|
||||
|
||||
bool Window::is_maximized() const
|
||||
{
|
||||
if (!is_visible())
|
||||
return m_maximized_when_windowless;
|
||||
|
||||
return ConnectionToWindowServer::the().is_maximized(m_window_id);
|
||||
}
|
||||
|
||||
void Window::set_maximized(bool maximized)
|
||||
{
|
||||
m_maximized_when_windowless = maximized;
|
||||
m_maximized = maximized;
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
||||
|
@ -1069,10 +1061,12 @@ void Window::update_all_windows(Badge<ConnectionToWindowServer>)
|
|||
}
|
||||
}
|
||||
|
||||
void Window::notify_state_changed(Badge<ConnectionToWindowServer>, bool minimized, bool occluded)
|
||||
void Window::notify_state_changed(Badge<ConnectionToWindowServer>, bool minimized, bool maximized, bool occluded)
|
||||
{
|
||||
m_visible_for_timer_purposes = !minimized && !occluded;
|
||||
|
||||
m_maximized = maximized;
|
||||
|
||||
// When double buffering is enabled, minimization/occlusion means we can mark the front bitmap volatile (in addition to the back bitmap.)
|
||||
// When double buffering is disabled, there is only the back bitmap (which we can now mark volatile!)
|
||||
auto& store = m_double_buffering_enabled ? m_front_store : m_back_store;
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
bool is_fullscreen() const { return m_fullscreen; }
|
||||
void set_fullscreen(bool);
|
||||
|
||||
bool is_maximized() const;
|
||||
bool is_maximized() const { return m_maximized; }
|
||||
void set_maximized(bool);
|
||||
|
||||
bool is_frameless() const { return m_frameless; }
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
|
||||
static void for_each_window(Badge<ConnectionToWindowServer>, Function<void(Window&)>);
|
||||
static void update_all_windows(Badge<ConnectionToWindowServer>);
|
||||
void notify_state_changed(Badge<ConnectionToWindowServer>, bool minimized, bool occluded);
|
||||
void notify_state_changed(Badge<ConnectionToWindowServer>, bool minimized, bool maximized, bool occluded);
|
||||
|
||||
virtual bool is_visible_for_timer_purposes() const override { return m_visible_for_timer_purposes; }
|
||||
|
||||
|
@ -290,7 +290,7 @@ private:
|
|||
Optional<Gfx::IntSize> m_resize_aspect_ratio {};
|
||||
bool m_minimizable { true };
|
||||
bool m_closeable { true };
|
||||
bool m_maximized_when_windowless { false };
|
||||
bool m_maximized { false };
|
||||
bool m_fullscreen { false };
|
||||
bool m_frameless { false };
|
||||
bool m_forced_shadow { false };
|
||||
|
|
|
@ -497,6 +497,8 @@ void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point)
|
|||
m_frame.did_set_maximized({}, maximized);
|
||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||
set_default_positioned(false);
|
||||
|
||||
WindowManager::the().notify_minimization_state_changed(*this);
|
||||
}
|
||||
|
||||
void Window::set_always_on_top(bool always_on_top)
|
||||
|
|
|
@ -19,7 +19,7 @@ endpoint WindowClient
|
|||
key_up(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode) =|
|
||||
window_activated(i32 window_id) =|
|
||||
window_deactivated(i32 window_id) =|
|
||||
window_state_changed(i32 window_id, bool minimized, bool occluded) =|
|
||||
window_state_changed(i32 window_id, bool minimized, bool maximized, bool occluded) =|
|
||||
window_close_request(i32 window_id) =|
|
||||
window_resized(i32 window_id, Gfx::IntRect new_rect) =|
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ void WindowManager::notify_minimization_state_changed(Window& window)
|
|||
tell_wms_window_state_changed(window);
|
||||
|
||||
if (window.client())
|
||||
window.client()->async_window_state_changed(window.window_id(), window.is_minimized(), window.is_occluded());
|
||||
window.client()->async_window_state_changed(window.window_id(), window.is_minimized(), window.is_maximized(), window.is_occluded());
|
||||
|
||||
if (window.is_active() && window.is_minimized())
|
||||
pick_new_active_window(&window);
|
||||
|
@ -634,7 +634,7 @@ void WindowManager::notify_minimization_state_changed(Window& window)
|
|||
void WindowManager::notify_occlusion_state_changed(Window& window)
|
||||
{
|
||||
if (window.client())
|
||||
window.client()->async_window_state_changed(window.window_id(), window.is_minimized(), window.is_occluded());
|
||||
window.client()->async_window_state_changed(window.window_id(), window.is_minimized(), window.is_maximized(), window.is_occluded());
|
||||
}
|
||||
|
||||
void WindowManager::notify_progress_changed(Window& window)
|
||||
|
|
Loading…
Add table
Reference in a new issue