mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
WindowManager: Allow moving windows around using Logo+LMB.
This commit is contained in:
parent
57fe316e01
commit
b4631d2083
Notes:
sideshowbarker
2024-07-19 15:33:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b4631d20839
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?
|
||||
|
|
|
@ -76,9 +76,9 @@ private:
|
|||
void process_mouse_event(WSMouseEvent&, WSWindow*& event_window);
|
||||
void handle_menu_mouse_event(WSMenu&, WSMouseEvent&);
|
||||
void handle_menubar_mouse_event(WSMouseEvent&);
|
||||
void handle_titlebar_mouse_event(WSWindow&, WSMouseEvent&);
|
||||
void handle_close_button_mouse_event(WSWindow&, WSMouseEvent&);
|
||||
void start_window_resize(WSWindow&, WSMouseEvent&);
|
||||
void start_window_drag(WSWindow&, WSMouseEvent&);
|
||||
void handle_client_request(WSAPIClientRequest&);
|
||||
void set_active_window(WSWindow*);
|
||||
void set_hovered_window(WSWindow*);
|
||||
|
|
Loading…
Reference in a new issue