WindowServer: Introduce keyboard shortcuts for fast window management

This commit is contained in:
Jami Kettunen 2020-01-04 15:30:11 +02:00 committed by Andreas Kling
parent 6c2fa0ee0a
commit 874a6c4039
Notes: sideshowbarker 2024-07-19 10:22:02 +09:00
2 changed files with 44 additions and 3 deletions

View file

@ -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;
}

View file

@ -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;
}