mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
WindowServer: Unify Window restore rects
Previously, different rects were used to restore tiled and maximized windows, creating edge cases for inconsistent restoration. All states now restore m_floating_rect, which saves the last valid size and location of a window while free-floating.
This commit is contained in:
parent
3d7e701451
commit
1607fd511f
3 changed files with 19 additions and 6 deletions
|
@ -159,6 +159,9 @@ void Window::set_rect(const Gfx::IntRect& rect)
|
||||||
m_backing_store = Gfx::Bitmap::try_create(format, m_rect.size()).release_value_but_fixme_should_propagate_errors();
|
m_backing_store = Gfx::Bitmap::try_create(format, m_rect.size()).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_floating_rect.is_empty())
|
||||||
|
m_floating_rect = rect;
|
||||||
|
|
||||||
invalidate(true, old_rect.size() != rect.size());
|
invalidate(true, old_rect.size() != rect.size());
|
||||||
m_frame.window_rect_changed(old_rect, rect);
|
m_frame.window_rect_changed(old_rect, rect);
|
||||||
invalidate_last_rendered_screen_rects();
|
invalidate_last_rendered_screen_rects();
|
||||||
|
@ -481,7 +484,7 @@ void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point)
|
||||||
m_maximized = maximized;
|
m_maximized = maximized;
|
||||||
update_window_menu_items();
|
update_window_menu_items();
|
||||||
if (maximized) {
|
if (maximized) {
|
||||||
m_unmaximized_rect = m_rect;
|
m_unmaximized_rect = m_floating_rect;
|
||||||
set_rect(WindowManager::the().maximized_window_rect(*this));
|
set_rect(WindowManager::the().maximized_window_rect(*this));
|
||||||
} else {
|
} else {
|
||||||
if (fixed_point.has_value()) {
|
if (fixed_point.has_value()) {
|
||||||
|
@ -1090,10 +1093,10 @@ bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point)
|
||||||
|
|
||||||
if (fixed_point.has_value()) {
|
if (fixed_point.has_value()) {
|
||||||
auto new_rect = Gfx::IntRect(m_rect);
|
auto new_rect = Gfx::IntRect(m_rect);
|
||||||
new_rect.set_size_around(m_untiled_rect.size(), fixed_point.value());
|
new_rect.set_size_around(m_floating_rect.size(), fixed_point.value());
|
||||||
set_rect(new_rect);
|
set_rect(new_rect);
|
||||||
} else {
|
} else {
|
||||||
set_rect(m_untiled_rect);
|
set_rect(m_floating_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||||
|
@ -1111,8 +1114,9 @@ void Window::set_tiled(Screen* screen, WindowTileType tile_type)
|
||||||
if (resize_aspect_ratio().has_value())
|
if (resize_aspect_ratio().has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_tile_type == WindowTileType::None)
|
if (is_maximized())
|
||||||
m_untiled_rect = m_rect;
|
set_maximized(false);
|
||||||
|
|
||||||
m_tile_type = tile_type;
|
m_tile_type = tile_type;
|
||||||
|
|
||||||
set_rect(tiled_rect(screen, tile_type));
|
set_rect(tiled_rect(screen, tile_type));
|
||||||
|
|
|
@ -123,6 +123,9 @@ public:
|
||||||
void check_untile_due_to_resize(Gfx::IntRect const&);
|
void check_untile_due_to_resize(Gfx::IntRect const&);
|
||||||
bool set_untiled(Optional<Gfx::IntPoint> fixed_point = {});
|
bool set_untiled(Optional<Gfx::IntPoint> fixed_point = {});
|
||||||
|
|
||||||
|
Gfx::IntRect floating_rect() const { return m_floating_rect; }
|
||||||
|
void set_floating_rect(Gfx::IntRect rect) { m_floating_rect = rect; }
|
||||||
|
|
||||||
void set_forced_shadow(bool b) { m_forced_shadow = b; }
|
void set_forced_shadow(bool b) { m_forced_shadow = b; }
|
||||||
bool has_forced_shadow() const { return m_forced_shadow; }
|
bool has_forced_shadow() const { return m_forced_shadow; }
|
||||||
|
|
||||||
|
@ -436,7 +439,7 @@ private:
|
||||||
bool m_invalidate_last_render_rects { false };
|
bool m_invalidate_last_render_rects { false };
|
||||||
Vector<i32> m_stealable_by_client_ids;
|
Vector<i32> m_stealable_by_client_ids;
|
||||||
WindowTileType m_tile_type { WindowTileType::None };
|
WindowTileType m_tile_type { WindowTileType::None };
|
||||||
Gfx::IntRect m_untiled_rect;
|
Gfx::IntRect m_floating_rect;
|
||||||
bool m_occluded { false };
|
bool m_occluded { false };
|
||||||
RefPtr<Gfx::Bitmap> m_backing_store;
|
RefPtr<Gfx::Bitmap> m_backing_store;
|
||||||
RefPtr<Gfx::Bitmap> m_last_backing_store;
|
RefPtr<Gfx::Bitmap> m_last_backing_store;
|
||||||
|
|
|
@ -740,6 +740,9 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event)
|
||||||
|
|
||||||
dbgln_if(MOVE_DEBUG, "[WM] Finish moving Window({})", m_move_window);
|
dbgln_if(MOVE_DEBUG, "[WM] Finish moving Window({})", m_move_window);
|
||||||
|
|
||||||
|
if (!m_move_window->is_tiled() && !m_move_window->is_maximized())
|
||||||
|
m_move_window->set_floating_rect(m_move_window->rect());
|
||||||
|
|
||||||
m_move_window->invalidate(true, true);
|
m_move_window->invalidate(true, true);
|
||||||
if (m_move_window->is_resizable()) {
|
if (m_move_window->is_resizable()) {
|
||||||
process_event_for_doubleclick(*m_move_window, event);
|
process_event_for_doubleclick(*m_move_window, event);
|
||||||
|
@ -824,6 +827,9 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event)
|
||||||
if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) {
|
if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) {
|
||||||
dbgln_if(RESIZE_DEBUG, "[WM] Finish resizing Window({})", m_resize_window);
|
dbgln_if(RESIZE_DEBUG, "[WM] Finish resizing Window({})", m_resize_window);
|
||||||
|
|
||||||
|
if (!m_resize_window->is_tiled() && !m_resize_window->is_maximized())
|
||||||
|
m_resize_window->set_floating_rect(m_resize_window->rect());
|
||||||
|
|
||||||
const int vertical_maximize_deadzone = 5;
|
const int vertical_maximize_deadzone = 5;
|
||||||
auto& cursor_screen = ScreenInput::the().cursor_location_screen();
|
auto& cursor_screen = ScreenInput::the().cursor_location_screen();
|
||||||
if (&cursor_screen == &Screen::closest_to_rect(m_resize_window->rect())) {
|
if (&cursor_screen == &Screen::closest_to_rect(m_resize_window->rect())) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue