mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 11:25:07 +00:00
WindowManager: Allow moving windows around using Logo+LMB.
This commit is contained in:
parent
57fe316e01
commit
b4631d2083
2 changed files with 24 additions and 20 deletions
|
@ -535,20 +535,6 @@ void WSWindowManager::handle_menubar_mouse_event(WSMouseEvent& event)
|
|||
});
|
||||
}
|
||||
|
||||
void WSWindowManager::handle_titlebar_mouse_event(WSWindow& window, WSMouseEvent& event)
|
||||
{
|
||||
if (event.type() == WSMessage::MouseDown && event.button() == MouseButton::Left) {
|
||||
#ifdef DRAG_DEBUG
|
||||
printf("[WM] Begin dragging WSWindow{%p}\n", &window);
|
||||
#endif
|
||||
m_drag_window = window.make_weak_ptr();;
|
||||
m_drag_origin = event.position();
|
||||
m_drag_window_origin = window.position();
|
||||
invalidate(window);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void WSWindowManager::handle_close_button_mouse_event(WSWindow& window, WSMouseEvent& event)
|
||||
{
|
||||
if (event.type() == WSMessage::MouseDown && event.button() == MouseButton::Left) {
|
||||
|
@ -558,6 +544,17 @@ void WSWindowManager::handle_close_button_mouse_event(WSWindow& window, WSMouseE
|
|||
}
|
||||
}
|
||||
|
||||
void WSWindowManager::start_window_drag(WSWindow& window, WSMouseEvent& event)
|
||||
{
|
||||
#ifdef DRAG_DEBUG
|
||||
printf("[WM] Begin dragging WSWindow{%p}\n", &window);
|
||||
#endif
|
||||
m_drag_window = window.make_weak_ptr();;
|
||||
m_drag_origin = event.position();
|
||||
m_drag_window_origin = window.position();
|
||||
invalidate(window);
|
||||
}
|
||||
|
||||
void WSWindowManager::start_window_resize(WSWindow& window, WSMouseEvent& event)
|
||||
{
|
||||
constexpr ResizeDirection direction_for_hot_area[3][3] = {
|
||||
|
@ -738,6 +735,16 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
|
|||
}
|
||||
|
||||
for_each_visible_window_from_front_to_back([&] (WSWindow& window) {
|
||||
if (window.type() != WSWindowType::Menu && outer_window_rect(window.rect()).contains(event.position())) {
|
||||
if (m_keyboard_modifiers == Mod_Logo && event.type() == WSMessage::MouseDown && event.button() == MouseButton::Left) {
|
||||
start_window_drag(window, event);
|
||||
return IterationDecision::Abort;
|
||||
}
|
||||
if (m_keyboard_modifiers == Mod_Logo && event.type() == WSMessage::MouseDown && event.button() == MouseButton::Right) {
|
||||
start_window_resize(window, event);
|
||||
return IterationDecision::Abort;
|
||||
}
|
||||
}
|
||||
if (window.type() != WSWindowType::Menu && title_bar_rect(window.rect()).contains(event.position())) {
|
||||
if (event.type() == WSMessage::MouseDown) {
|
||||
move_to_front(window);
|
||||
|
@ -747,7 +754,8 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
|
|||
handle_close_button_mouse_event(window, event);
|
||||
return IterationDecision::Abort;
|
||||
}
|
||||
handle_titlebar_mouse_event(window, event);
|
||||
if (event.type() == WSMessage::MouseDown)
|
||||
start_window_drag(window, event);
|
||||
return IterationDecision::Abort;
|
||||
}
|
||||
|
||||
|
@ -756,10 +764,6 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
|
|||
move_to_front(window);
|
||||
set_active_window(&window);
|
||||
}
|
||||
if (m_keyboard_modifiers == Mod_Logo && event.type() == WSMessage::MouseDown && event.button() == MouseButton::Right) {
|
||||
start_window_resize(window, event);
|
||||
return IterationDecision::Abort;
|
||||
}
|
||||
event_window = &window;
|
||||
if (!window.global_cursor_tracking()) {
|
||||
// FIXME: Should we just alter the coordinates of the existing MouseEvent and pass it through?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue