mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
WindowServer: Introduce keyboard shortcuts for fast window management
This commit is contained in:
parent
6c2fa0ee0a
commit
874a6c4039
Notes:
sideshowbarker
2024-07-19 10:22:02 +09:00
Author: https://github.com/JamiKettunen Commit: https://github.com/SerenityOS/serenity/commit/874a6c40397 Pull-request: https://github.com/SerenityOS/serenity/pull/1010 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/shannonbooth
2 changed files with 44 additions and 3 deletions
|
@ -162,6 +162,7 @@ void WSWindow::set_maximized(bool maximized)
|
|||
return;
|
||||
if (maximized && !is_resizable())
|
||||
return;
|
||||
set_tiled(WindowTileType::None);
|
||||
m_maximized = maximized;
|
||||
update_menu_item_text(PopupMenuItem::Maximize);
|
||||
auto old_rect = m_rect;
|
||||
|
@ -355,7 +356,7 @@ void WSWindow::set_tiled(WindowTileType tiled)
|
|||
|
||||
int frame_width = (m_frame.rect().width() - m_rect.width()) / 2;
|
||||
switch (tiled) {
|
||||
case WindowTileType::None :
|
||||
case WindowTileType::None :
|
||||
set_rect(m_untiled_rect);
|
||||
break;
|
||||
case WindowTileType::Left :
|
||||
|
@ -369,7 +370,7 @@ void WSWindow::set_tiled(WindowTileType tiled)
|
|||
m_untiled_rect = m_rect;
|
||||
set_rect(WSScreen::the().width() / 2 + frame_width,
|
||||
WSWindowManager::the().maximized_window_rect(*this).y(),
|
||||
(WSScreen::the().width() / 2) - frame_width,
|
||||
WSScreen::the().width() / 2 - frame_width,
|
||||
WSWindowManager::the().maximized_window_rect(*this).height());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1114,8 +1114,48 @@ void WSWindowManager::event(CEvent& event)
|
|||
m_switcher.on_key_event(key_event);
|
||||
return;
|
||||
}
|
||||
if (m_active_window)
|
||||
|
||||
if (m_active_window) {
|
||||
if (key_event.type() == WSEvent::KeyDown && key_event.modifiers() == Mod_Logo) {
|
||||
if (key_event.key() == Key_Down) {
|
||||
if (m_active_window->is_resizable() && m_active_window->is_maximized()) {
|
||||
m_active_window->set_maximized(false);
|
||||
return;
|
||||
}
|
||||
if (m_active_window->is_minimizable())
|
||||
m_active_window->set_minimized(true);
|
||||
return;
|
||||
}
|
||||
if (m_active_window->is_resizable()) {
|
||||
if (key_event.key() == Key_Up) {
|
||||
m_active_window->set_maximized(!m_active_window->is_maximized());
|
||||
return;
|
||||
}
|
||||
if (key_event.key() == Key_Left) {
|
||||
if (m_active_window->tiled() != WindowTileType::None) {
|
||||
m_active_window->set_tiled(WindowTileType::None);
|
||||
return;
|
||||
}
|
||||
if (m_active_window->is_maximized())
|
||||
m_active_window->set_maximized(false);
|
||||
m_active_window->set_tiled(WindowTileType::Left);
|
||||
return;
|
||||
}
|
||||
if (key_event.key() == Key_Right) {
|
||||
if (m_active_window->tiled() != WindowTileType::None) {
|
||||
m_active_window->set_tiled(WindowTileType::None);
|
||||
return;
|
||||
}
|
||||
if (m_active_window->is_maximized())
|
||||
m_active_window->set_maximized(false);
|
||||
m_active_window->set_tiled(WindowTileType::Right);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_active_window->dispatch_event(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue