mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
WindowServer: Implement tile window overlay
This adds a tiling mode that will show a tile window overlay rather than immediately tiling a window, triggering window resizes.
This commit is contained in:
parent
035b0f9df6
commit
fe54a0ca27
15 changed files with 279 additions and 71 deletions
|
@ -420,8 +420,8 @@ void Window::set_maximized(bool maximized)
|
|||
else
|
||||
set_rect(m_floating_rect);
|
||||
m_frame.did_set_maximized({}, maximized);
|
||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||
Core::EventLoop::current().post_event(*this, make<MoveEvent>(m_rect));
|
||||
send_resize_event_to_client();
|
||||
send_move_event_to_client();
|
||||
set_default_positioned(false);
|
||||
|
||||
WindowManager::the().notify_minimization_state_changed(*this);
|
||||
|
@ -842,8 +842,8 @@ void Window::set_fullscreen(bool fullscreen)
|
|||
new_window_rect = m_saved_nonfullscreen_rect;
|
||||
}
|
||||
|
||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(new_window_rect));
|
||||
Core::EventLoop::current().post_event(*this, make<MoveEvent>(new_window_rect));
|
||||
send_resize_event_to_client();
|
||||
send_move_event_to_client();
|
||||
set_rect(new_window_rect);
|
||||
}
|
||||
|
||||
|
@ -858,7 +858,7 @@ WindowTileType Window::tile_type_based_on_rect(Gfx::IntRect const& rect) const
|
|||
bool tiling_to_left = current_tile_type == WindowTileType::Left || current_tile_type == WindowTileType::TopLeft || current_tile_type == WindowTileType::BottomLeft;
|
||||
bool tiling_to_right = current_tile_type == WindowTileType::Right || current_tile_type == WindowTileType::TopRight || current_tile_type == WindowTileType::BottomRight;
|
||||
|
||||
auto ideal_tiled_rect = WindowManager::the().tiled_window_rect(*this, current_tile_type);
|
||||
auto ideal_tiled_rect = WindowManager::the().tiled_window_rect(*this, window_screen, current_tile_type);
|
||||
bool same_top = ideal_tiled_rect.top() == rect.top();
|
||||
bool same_left = ideal_tiled_rect.left() == rect.left();
|
||||
bool same_right = ideal_tiled_rect.right() == rect.right();
|
||||
|
@ -870,9 +870,9 @@ WindowTileType Window::tile_type_based_on_rect(Gfx::IntRect const& rect) const
|
|||
if (tiling_to_top && same_top && same_left && same_right)
|
||||
return WindowTileType::Top;
|
||||
else if ((tiling_to_top || tiling_to_left) && same_top && same_left)
|
||||
return rect.bottom() == WindowManager::the().tiled_window_rect(*this, WindowTileType::Bottom).bottom() ? WindowTileType::Left : WindowTileType::TopLeft;
|
||||
return rect.bottom() == WindowManager::the().tiled_window_rect(*this, window_screen, WindowTileType::Bottom).bottom() ? WindowTileType::Left : WindowTileType::TopLeft;
|
||||
else if ((tiling_to_top || tiling_to_right) && same_top && same_right)
|
||||
return rect.bottom() == WindowManager::the().tiled_window_rect(*this, WindowTileType::Bottom).bottom() ? WindowTileType::Right : WindowTileType::TopRight;
|
||||
return rect.bottom() == WindowManager::the().tiled_window_rect(*this, window_screen, WindowTileType::Bottom).bottom() ? WindowTileType::Right : WindowTileType::TopRight;
|
||||
else if (tiling_to_left && same_left && same_top && same_bottom)
|
||||
return WindowTileType::Left;
|
||||
else if (tiling_to_right && same_right && same_top && same_bottom)
|
||||
|
@ -880,9 +880,9 @@ WindowTileType Window::tile_type_based_on_rect(Gfx::IntRect const& rect) const
|
|||
else if (tiling_to_bottom && same_bottom && same_left && same_right)
|
||||
return WindowTileType::Bottom;
|
||||
else if ((tiling_to_bottom || tiling_to_left) && same_bottom && same_left)
|
||||
return rect.top() == WindowManager::the().tiled_window_rect(*this, WindowTileType::Left).top() ? WindowTileType::Left : WindowTileType::BottomLeft;
|
||||
return rect.top() == WindowManager::the().tiled_window_rect(*this, window_screen, WindowTileType::Left).top() ? WindowTileType::Left : WindowTileType::BottomLeft;
|
||||
else if ((tiling_to_bottom || tiling_to_right) && same_bottom && same_right)
|
||||
return rect.top() == WindowManager::the().tiled_window_rect(*this, WindowTileType::Right).top() ? WindowTileType::Right : WindowTileType::BottomRight;
|
||||
return rect.top() == WindowManager::the().tiled_window_rect(*this, window_screen, WindowTileType::Right).top() ? WindowTileType::Right : WindowTileType::BottomRight;
|
||||
}
|
||||
return tile_type;
|
||||
}
|
||||
|
@ -911,15 +911,11 @@ bool Window::set_untiled()
|
|||
VERIFY(!resize_aspect_ratio().has_value());
|
||||
|
||||
m_tile_type = WindowTileType::None;
|
||||
set_rect(m_floating_rect);
|
||||
|
||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||
Core::EventLoop::current().post_event(*this, make<MoveEvent>(m_rect));
|
||||
|
||||
tile_type_changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Window::set_tiled(WindowTileType tile_type)
|
||||
void Window::set_tiled(WindowTileType tile_type, Optional<Screen const&> tile_on_screen)
|
||||
{
|
||||
VERIFY(tile_type != WindowTileType::None);
|
||||
|
||||
|
@ -933,9 +929,26 @@ void Window::set_tiled(WindowTileType tile_type)
|
|||
set_maximized(false);
|
||||
|
||||
m_tile_type = tile_type;
|
||||
tile_type_changed(tile_on_screen);
|
||||
}
|
||||
|
||||
set_rect(WindowManager::the().tiled_window_rect(*this, tile_type));
|
||||
void Window::tile_type_changed(Optional<Screen const&> tile_on_screen)
|
||||
{
|
||||
if (m_tile_type != WindowTileType::None)
|
||||
set_rect(WindowManager::the().tiled_window_rect(*this, tile_on_screen, m_tile_type));
|
||||
else
|
||||
set_rect(m_floating_rect);
|
||||
send_resize_event_to_client();
|
||||
send_move_event_to_client();
|
||||
}
|
||||
|
||||
void Window::send_resize_event_to_client()
|
||||
{
|
||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||
}
|
||||
|
||||
void Window::send_move_event_to_client()
|
||||
{
|
||||
Core::EventLoop::current().post_event(*this, make<MoveEvent>(m_rect));
|
||||
}
|
||||
|
||||
|
@ -951,7 +964,7 @@ void Window::recalculate_rect()
|
|||
|
||||
bool send_event = true;
|
||||
if (is_tiled()) {
|
||||
set_rect(WindowManager::the().tiled_window_rect(*this, m_tile_type));
|
||||
set_rect(WindowManager::the().tiled_window_rect(*this, {}, m_tile_type));
|
||||
} else if (type() == WindowType::Desktop) {
|
||||
set_rect(WindowManager::the().arena_rect_for_type(Screen::main(), WindowType::Desktop));
|
||||
} else {
|
||||
|
@ -959,7 +972,7 @@ void Window::recalculate_rect()
|
|||
}
|
||||
|
||||
if (send_event) {
|
||||
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||
send_resize_event_to_client();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue