1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-22 14:12:10 +00:00

WindowServer: Windows tile when moved onto the edge of the screen

This commit is contained in:
Chyza 2020-01-01 17:24:14 +00:00 committed by Andreas Kling
parent 275bc0d587
commit 93ce1bb4a1
3 changed files with 58 additions and 4 deletions

View file

@ -340,3 +340,33 @@ void WSWindow::set_fullscreen(bool fullscreen)
CEventLoop::current().post_event(*this, make<WSResizeEvent>(m_rect, new_window_rect));
set_rect(new_window_rect);
}
void WSWindow::set_tiled(WindowTileType tiled)
{
if (m_tiled == tiled)
return;
m_tiled = tiled;
auto old_rect = m_rect;
auto frame_width = m_frame.rect().width() - m_rect.width();
switch (tiled) {
case WindowTileType::None :
set_rect(m_untiled_rect);
break;
case WindowTileType::Left :
m_untiled_rect = m_rect;
set_rect(0,
WSWindowManager::the().maximized_window_rect(*this).y(),
WSScreen::the().width() / 2,
WSWindowManager::the().maximized_window_rect(*this).height());
break;
case WindowTileType::Right :
m_untiled_rect = m_rect;
set_rect(WSScreen::the().width() / 2 + frame_width,
WSWindowManager::the().maximized_window_rect(*this).y(),
(WSScreen::the().width() / 2),
WSWindowManager::the().maximized_window_rect(*this).height());
break;
}
CEventLoop::current().post_event(*this, make<WSResizeEvent>(old_rect, m_rect));
}