WindowServer: Disambiguate "dragging" a bit, use "moving" more instead
Windows that are being moved around by the user are now called "moving" windows instead of "dragging" windows, to avoid confusion with the drag and drop stuff.
This commit is contained in:
parent
39c2d04a9b
commit
e339c2bce8
Notes:
sideshowbarker
2024-07-19 10:55:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e339c2bce80
5 changed files with 60 additions and 60 deletions
Base/home/anon
Servers/WindowServer
|
@ -24,9 +24,9 @@ InactiveWindowBorder=128,128,128
|
|||
InactiveWindowBorder2=192,192,192
|
||||
InactiveWindowTitle=213,208,199
|
||||
|
||||
DraggingWindowBorder=161,50,13
|
||||
DraggingWindowBorder2=250,220,187
|
||||
DraggingWindowTitle=255,255,255
|
||||
MovingWindowBorder=161,50,13
|
||||
MovingWindowBorder2=250,220,187
|
||||
MovingWindowTitle=255,255,255
|
||||
|
||||
HighlightWindowBorder=161,13,13
|
||||
HighlightWindowBorder2=250,187,187
|
||||
|
|
|
@ -397,7 +397,7 @@ void WSCompositor::invalidate_cursor()
|
|||
void WSCompositor::draw_geometry_label()
|
||||
{
|
||||
auto& wm = WSWindowManager::the();
|
||||
auto* window_being_moved_or_resized = wm.m_drag_window ? wm.m_drag_window.ptr() : (wm.m_resize_window ? wm.m_resize_window.ptr() : nullptr);
|
||||
auto* window_being_moved_or_resized = wm.m_move_window ? wm.m_move_window.ptr() : (wm.m_resize_window ? wm.m_resize_window.ptr() : nullptr);
|
||||
if (!window_being_moved_or_resized) {
|
||||
m_last_geometry_label_rect = {};
|
||||
return;
|
||||
|
|
|
@ -173,10 +173,10 @@ void WSWindowFrame::paint(Painter& painter)
|
|||
border_color = wm.m_highlight_window_border_color;
|
||||
border_color2 = wm.m_highlight_window_border_color2;
|
||||
title_color = wm.m_highlight_window_title_color;
|
||||
} else if (&window == wm.m_drag_window) {
|
||||
border_color = wm.m_dragging_window_border_color;
|
||||
border_color2 = wm.m_dragging_window_border_color2;
|
||||
title_color = wm.m_dragging_window_title_color;
|
||||
} else if (&window == wm.m_move_window) {
|
||||
border_color = wm.m_moving_window_border_color;
|
||||
border_color2 = wm.m_moving_window_border_color2;
|
||||
title_color = wm.m_moving_window_title_color;
|
||||
} else if (&window == wm.m_active_window) {
|
||||
border_color = wm.m_active_window_border_color;
|
||||
border_color2 = wm.m_active_window_border_color2;
|
||||
|
@ -301,7 +301,7 @@ void WSWindowFrame::on_mouse_event(const WSMouseEvent& event)
|
|||
return button.on_mouse_event(event.translated(-button.relative_rect().location()));
|
||||
}
|
||||
if (event.type() == WSEvent::MouseDown && event.button() == MouseButton::Left)
|
||||
wm.start_window_drag(m_window, event.translated(rect().location()));
|
||||
wm.start_window_move(m_window, event.translated(rect().location()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
//#define DEBUG_COUNTERS
|
||||
//#define DEBUG_MENUS
|
||||
//#define RESIZE_DEBUG
|
||||
//#define DRAG_DEBUG
|
||||
//#define MOVE_DEBUG
|
||||
//#define DOUBLECLICK_DEBUG
|
||||
|
||||
static WSWindowManager* s_the;
|
||||
|
@ -197,9 +197,9 @@ void WSWindowManager::reload_config(bool set_screen)
|
|||
m_inactive_window_border_color2 = m_wm_config->read_color_entry("Colors", "InactiveWindowBorder2", Color::Red);
|
||||
m_inactive_window_title_color = m_wm_config->read_color_entry("Colors", "InactiveWindowTitle", Color::Red);
|
||||
|
||||
m_dragging_window_border_color = m_wm_config->read_color_entry("Colors", "DraggingWindowBorder", Color::Red);
|
||||
m_dragging_window_border_color2 = m_wm_config->read_color_entry("Colors", "DraggingWindowBorder2", Color::Red);
|
||||
m_dragging_window_title_color = m_wm_config->read_color_entry("Colors", "DraggingWindowTitle", Color::Red);
|
||||
m_moving_window_border_color = m_wm_config->read_color_entry("Colors", "MovingWindowBorder", Color::Red);
|
||||
m_moving_window_border_color2 = m_wm_config->read_color_entry("Colors", "MovingWindowBorder2", Color::Red);
|
||||
m_moving_window_title_color = m_wm_config->read_color_entry("Colors", "MovingWindowTitle", Color::Red);
|
||||
|
||||
m_highlight_window_border_color = m_wm_config->read_color_entry("Colors", "HighlightWindowBorder", Color::Red);
|
||||
m_highlight_window_border_color2 = m_wm_config->read_color_entry("Colors", "HighlightWindowBorder2", Color::Red);
|
||||
|
@ -410,15 +410,15 @@ void WSWindowManager::pick_new_active_window()
|
|||
});
|
||||
}
|
||||
|
||||
void WSWindowManager::start_window_drag(WSWindow& window, const WSMouseEvent& event)
|
||||
void WSWindowManager::start_window_move(WSWindow& window, const WSMouseEvent& event)
|
||||
{
|
||||
#ifdef DRAG_DEBUG
|
||||
dbg() << "[WM] Begin dragging WSWindow{" << &window << "}";
|
||||
#ifdef MOVE_DEBUG
|
||||
dbg() << "[WM] Begin moving WSWindow{" << &window << "}";
|
||||
#endif
|
||||
move_to_front_and_make_active(window);
|
||||
m_drag_window = window.make_weak_ptr();
|
||||
m_drag_origin = event.position();
|
||||
m_drag_window_origin = window.position();
|
||||
m_move_window = window.make_weak_ptr();
|
||||
m_move_origin = event.position();
|
||||
m_move_window_origin = window.position();
|
||||
invalidate(window);
|
||||
}
|
||||
|
||||
|
@ -459,53 +459,53 @@ void WSWindowManager::start_window_resize(WSWindow& window, const WSMouseEvent&
|
|||
start_window_resize(window, event.position(), event.button());
|
||||
}
|
||||
|
||||
bool WSWindowManager::process_ongoing_window_drag(WSMouseEvent& event, WSWindow*& hovered_window)
|
||||
bool WSWindowManager::process_ongoing_window_move(WSMouseEvent& event, WSWindow*& hovered_window)
|
||||
{
|
||||
if (!m_drag_window)
|
||||
if (!m_move_window)
|
||||
return false;
|
||||
if (event.type() == WSEvent::MouseUp && event.button() == MouseButton::Left) {
|
||||
#ifdef DRAG_DEBUG
|
||||
dbg() << "[WM] Finish dragging WSWindow{" << m_drag_window << "}";
|
||||
#ifdef MOVE_DEBUG
|
||||
dbg() << "[WM] Finish moving WSWindow{" << m_move_window << "}";
|
||||
#endif
|
||||
invalidate(*m_drag_window);
|
||||
if (m_drag_window->rect().contains(event.position()))
|
||||
hovered_window = m_drag_window;
|
||||
if (m_drag_window->is_resizable()) {
|
||||
process_event_for_doubleclick(*m_drag_window, event);
|
||||
invalidate(*m_move_window);
|
||||
if (m_move_window->rect().contains(event.position()))
|
||||
hovered_window = m_move_window;
|
||||
if (m_move_window->is_resizable()) {
|
||||
process_event_for_doubleclick(*m_move_window, event);
|
||||
if (event.type() == WSEvent::MouseDoubleClick) {
|
||||
#if defined(DOUBLECLICK_DEBUG)
|
||||
dbg() << "[WM] Click up became doubleclick!";
|
||||
#endif
|
||||
m_drag_window->set_maximized(!m_drag_window->is_maximized());
|
||||
m_move_window->set_maximized(!m_move_window->is_maximized());
|
||||
}
|
||||
}
|
||||
m_drag_window = nullptr;
|
||||
m_move_window = nullptr;
|
||||
return true;
|
||||
}
|
||||
if (event.type() == WSEvent::MouseMove) {
|
||||
|
||||
#ifdef DRAG_DEBUG
|
||||
dbg() << "[WM] Dragging, origin: " << m_drag_origin << ", now: " << event.position();
|
||||
if (m_drag_window->is_maximized()) {
|
||||
dbg() << " [!] The window is still maximized. Not dragging yet.";
|
||||
#ifdef MOVE_DEBUG
|
||||
dbg() << "[WM] Moving, origin: " << m_move_origin << ", now: " << event.position();
|
||||
if (m_move_window->is_maximized()) {
|
||||
dbg() << " [!] The window is still maximized. Not moving yet.";
|
||||
}
|
||||
#endif
|
||||
if (m_drag_window->is_maximized()) {
|
||||
auto pixels_moved_from_start = event.position().pixels_moved(m_drag_origin);
|
||||
// dbg() << "[WM] " << pixels_moved_from_start << " moved since start of drag";
|
||||
if (m_move_window->is_maximized()) {
|
||||
auto pixels_moved_from_start = event.position().pixels_moved(m_move_origin);
|
||||
// dbg() << "[WM] " << pixels_moved_from_start << " moved since start of window move";
|
||||
if (pixels_moved_from_start > 5) {
|
||||
// dbg() << "[WM] de-maximizing window";
|
||||
m_drag_origin = event.position();
|
||||
auto width_before_resize = m_drag_window->width();
|
||||
m_drag_window->set_maximized(false);
|
||||
m_drag_window->move_to(m_drag_origin.x() - (m_drag_window->width() * ((float)m_drag_origin.x() / width_before_resize)), m_drag_origin.y());
|
||||
m_drag_window_origin = m_drag_window->position();
|
||||
m_move_origin = event.position();
|
||||
auto width_before_resize = m_move_window->width();
|
||||
m_move_window->set_maximized(false);
|
||||
m_move_window->move_to(m_move_origin.x() - (m_move_window->width() * ((float)m_move_origin.x() / width_before_resize)), m_move_origin.y());
|
||||
m_move_window_origin = m_move_window->position();
|
||||
}
|
||||
} else {
|
||||
Point pos = m_drag_window_origin.translated(event.position() - m_drag_origin);
|
||||
m_drag_window->set_position_without_repaint(pos);
|
||||
if (m_drag_window->rect().contains(event.position()))
|
||||
hovered_window = m_drag_window;
|
||||
Point pos = m_move_window_origin.translated(event.position() - m_move_origin);
|
||||
m_move_window->set_position_without_repaint(pos);
|
||||
if (m_move_window->rect().contains(event.position()))
|
||||
hovered_window = m_move_window;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
|
|||
if (process_ongoing_drag(event, hovered_window))
|
||||
return;
|
||||
|
||||
if (process_ongoing_window_drag(event, hovered_window))
|
||||
if (process_ongoing_window_move(event, hovered_window))
|
||||
return;
|
||||
|
||||
if (process_ongoing_window_resize(event, hovered_window))
|
||||
|
@ -812,8 +812,8 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
|
|||
// client application. We must keep delivering to that client
|
||||
// application until the input sequence is done.
|
||||
//
|
||||
// This prevents e.g. dragging on one window out of the bounds starting
|
||||
// a drag in that other unrelated window, and other silly shennanigans.
|
||||
// This prevents e.g. moving on one window out of the bounds starting
|
||||
// a move in that other unrelated window, and other silly shenanigans.
|
||||
if (!windows_who_received_mouse_event_due_to_cursor_tracking.contains(m_active_input_window)) {
|
||||
auto translated_event = event.translated(-m_active_input_window->position());
|
||||
deliver_mouse_event(*m_active_input_window, translated_event);
|
||||
|
@ -839,12 +839,12 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
|
|||
if (&window != m_resize_candidate.ptr())
|
||||
clear_resize_candidate();
|
||||
|
||||
// First check if we should initiate a drag or resize (Logo+LMB or Logo+RMB).
|
||||
// First check if we should initiate a move or resize (Logo+LMB or Logo+RMB).
|
||||
// In those cases, the event is swallowed by the window manager.
|
||||
if (window.is_movable()) {
|
||||
if (!window.is_fullscreen() && m_keyboard_modifiers == Mod_Logo && event.type() == WSEvent::MouseDown && event.button() == MouseButton::Left) {
|
||||
hovered_window = &window;
|
||||
start_window_drag(window, event);
|
||||
start_window_move(window, event);
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
if (window.is_resizable() && m_keyboard_modifiers == Mod_Logo && event.type() == WSEvent::MouseDown && event.button() == MouseButton::Right && !window.is_blocked_by_modal_window()) {
|
||||
|
@ -1107,7 +1107,7 @@ const WSCursor& WSWindowManager::active_cursor() const
|
|||
if (m_dnd_client)
|
||||
return *m_drag_cursor;
|
||||
|
||||
if (m_drag_window)
|
||||
if (m_move_window)
|
||||
return *m_move_cursor;
|
||||
|
||||
if (m_resize_window || m_resize_candidate) {
|
||||
|
|
|
@ -164,9 +164,9 @@ private:
|
|||
void process_event_for_doubleclick(WSWindow& window, WSMouseEvent& event);
|
||||
void deliver_mouse_event(WSWindow& window, WSMouseEvent& event);
|
||||
bool process_ongoing_window_resize(const WSMouseEvent&, WSWindow*& hovered_window);
|
||||
bool process_ongoing_window_drag(WSMouseEvent&, WSWindow*& hovered_window);
|
||||
bool process_ongoing_window_move(WSMouseEvent&, WSWindow*& hovered_window);
|
||||
bool process_ongoing_drag(WSMouseEvent&, WSWindow*& hovered_window);
|
||||
void start_window_drag(WSWindow&, const WSMouseEvent&);
|
||||
void start_window_move(WSWindow&, const WSMouseEvent&);
|
||||
void set_hovered_window(WSWindow*);
|
||||
template<typename Callback>
|
||||
IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false);
|
||||
|
@ -206,9 +206,9 @@ private:
|
|||
Color m_inactive_window_border_color;
|
||||
Color m_inactive_window_border_color2;
|
||||
Color m_inactive_window_title_color;
|
||||
Color m_dragging_window_border_color;
|
||||
Color m_dragging_window_border_color2;
|
||||
Color m_dragging_window_title_color;
|
||||
Color m_moving_window_border_color;
|
||||
Color m_moving_window_border_color2;
|
||||
Color m_moving_window_title_color;
|
||||
Color m_highlight_window_border_color;
|
||||
Color m_highlight_window_border_color2;
|
||||
Color m_highlight_window_title_color;
|
||||
|
@ -246,9 +246,9 @@ private:
|
|||
WeakPtr<WSWindow> m_highlight_window;
|
||||
WeakPtr<WSWindow> m_active_input_window;
|
||||
|
||||
WeakPtr<WSWindow> m_drag_window;
|
||||
Point m_drag_origin;
|
||||
Point m_drag_window_origin;
|
||||
WeakPtr<WSWindow> m_move_window;
|
||||
Point m_move_origin;
|
||||
Point m_move_window_origin;
|
||||
|
||||
WeakPtr<WSWindow> m_resize_window;
|
||||
WeakPtr<WSWindow> m_resize_candidate;
|
||||
|
|
Loading…
Add table
Reference in a new issue