From af0a46e79cf5a89da1ec92cdf73f0f0673ebec63 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 3 Aug 2025 16:13:37 +0300 Subject: [PATCH] LibGUI/WindowServer: Rename mouse capture -> mouse relative My terminology was incorrect and this is more correct --- userspace/libraries/LibGUI/Window.cpp | 6 ++--- .../libraries/LibGUI/include/LibGUI/Packet.h | 6 ++--- .../libraries/LibGUI/include/LibGUI/Window.h | 2 +- .../programs/WindowServer/WindowServer.cpp | 22 +++++++++---------- .../programs/WindowServer/WindowServer.h | 4 ++-- userspace/programs/WindowServer/main.cpp | 22 +++++++++---------- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/userspace/libraries/LibGUI/Window.cpp b/userspace/libraries/LibGUI/Window.cpp index 9e2ab867..453f228b 100644 --- a/userspace/libraries/LibGUI/Window.cpp +++ b/userspace/libraries/LibGUI/Window.cpp @@ -142,10 +142,10 @@ namespace LibGUI return on_socket_error(__FUNCTION__); } - void Window::set_mouse_capture(bool captured) + void Window::set_mouse_relative(bool enabled) { - WindowPacket::WindowSetMouseCapture packet; - packet.captured = captured; + WindowPacket::WindowSetMouseRelative packet; + packet.enabled = enabled; if (auto ret = packet.send_serialized(m_server_fd); ret.is_error()) return on_socket_error(__FUNCTION__); diff --git a/userspace/libraries/LibGUI/include/LibGUI/Packet.h b/userspace/libraries/LibGUI/include/LibGUI/Packet.h index 8eb236d0..67a06e29 100644 --- a/userspace/libraries/LibGUI/include/LibGUI/Packet.h +++ b/userspace/libraries/LibGUI/include/LibGUI/Packet.h @@ -205,7 +205,7 @@ namespace LibGUI WindowInvalidate, WindowSetPosition, WindowSetAttributes, - WindowSetMouseCapture, + WindowSetMouseRelative, WindowSetSize, WindowSetMinSize, WindowSetMaxSize, @@ -266,8 +266,8 @@ namespace LibGUI ); DEFINE_PACKET( - WindowSetMouseCapture, - bool, captured + WindowSetMouseRelative, + bool, enabled ); DEFINE_PACKET( diff --git a/userspace/libraries/LibGUI/include/LibGUI/Window.h b/userspace/libraries/LibGUI/include/LibGUI/Window.h index 27ce6153..c29b031f 100644 --- a/userspace/libraries/LibGUI/include/LibGUI/Window.h +++ b/userspace/libraries/LibGUI/include/LibGUI/Window.h @@ -43,7 +43,7 @@ namespace LibGUI void invalidate(int32_t x, int32_t y, uint32_t width, uint32_t height); void invalidate() { return invalidate(0, 0, width(), height()); } - void set_mouse_capture(bool captured); + void set_mouse_relative(bool enabled); void set_fullscreen(bool fullscreen); void set_title(BAN::StringView title); diff --git a/userspace/programs/WindowServer/WindowServer.cpp b/userspace/programs/WindowServer/WindowServer.cpp index ba6d4448..ef89ff31 100644 --- a/userspace/programs/WindowServer/WindowServer.cpp +++ b/userspace/programs/WindowServer/WindowServer.cpp @@ -199,13 +199,13 @@ void WindowServer::on_window_set_attributes(int fd, const LibGUI::WindowPacket:: dwarnln("could not send window shown event: {}", ret.error()); } -void WindowServer::on_window_set_mouse_capture(int fd, const LibGUI::WindowPacket::WindowSetMouseCapture& packet) +void WindowServer::on_window_set_mouse_relative(int fd, const LibGUI::WindowPacket::WindowSetMouseRelative& packet) { - if (m_is_mouse_captured && packet.captured) + if (m_is_mouse_relative && packet.enabled) { ASSERT(m_focused_window); if (fd != m_focused_window->client_fd()) - dwarnln("client tried to set mouse capture while other window has it already captured"); + dwarnln("client tried to set mouse relative while other window has it already"); return; } @@ -221,11 +221,11 @@ void WindowServer::on_window_set_mouse_capture(int fd, const LibGUI::WindowPacke return; } - if (packet.captured == m_is_mouse_captured) + if (packet.enabled == m_is_mouse_relative) return; set_focused_window(target_window); - m_is_mouse_captured = packet.captured; + m_is_mouse_relative = packet.enabled; invalidate(cursor_area()); } @@ -490,7 +490,7 @@ void WindowServer::on_key_event(LibInput::KeyEvent event) void WindowServer::on_mouse_button(LibInput::MouseButtonEvent event) { - if (m_is_mouse_captured) + if (m_is_mouse_relative) { ASSERT(m_focused_window); @@ -681,7 +681,7 @@ void WindowServer::on_mouse_move_impl(int32_t new_x, int32_t new_y) void WindowServer::on_mouse_move(LibInput::MouseMoveEvent event) { - if (m_is_mouse_captured) + if (m_is_mouse_relative) { ASSERT(m_focused_window); @@ -767,9 +767,9 @@ void WindowServer::set_focused_window(BAN::RefPtr window) if (m_focused_window == window) return; - if (m_is_mouse_captured) + if (m_is_mouse_relative) { - m_is_mouse_captured = false; + m_is_mouse_relative = false; invalidate(cursor_area()); } @@ -903,7 +903,7 @@ void WindowServer::invalidate(Rectangle area) mark_pending_sync(dst_area); } - if (!m_is_mouse_captured) + if (!m_is_mouse_relative) { auto cursor_area = this->cursor_area(); cursor_area.x -= m_focused_window->client_x(); @@ -1140,7 +1140,7 @@ void WindowServer::invalidate(Rectangle area) } } - if (!m_is_mouse_captured) + if (!m_is_mouse_relative) { if (const auto overlap = cursor_area().get_overlap(area); overlap.has_value()) { diff --git a/userspace/programs/WindowServer/WindowServer.h b/userspace/programs/WindowServer/WindowServer.h index c6bae008..de0ff854 100644 --- a/userspace/programs/WindowServer/WindowServer.h +++ b/userspace/programs/WindowServer/WindowServer.h @@ -35,7 +35,7 @@ public: void on_window_invalidate(int fd, const LibGUI::WindowPacket::WindowInvalidate&); void on_window_set_position(int fd, const LibGUI::WindowPacket::WindowSetPosition&); void on_window_set_attributes(int fd, const LibGUI::WindowPacket::WindowSetAttributes&); - void on_window_set_mouse_capture(int fd, const LibGUI::WindowPacket::WindowSetMouseCapture&); + void on_window_set_mouse_relative(int fd, const LibGUI::WindowPacket::WindowSetMouseRelative&); void on_window_set_size(int fd, const LibGUI::WindowPacket::WindowSetSize&); void on_window_set_min_size(int fd, const LibGUI::WindowPacket::WindowSetMinSize&); void on_window_set_max_size(int fd, const LibGUI::WindowPacket::WindowSetMaxSize&); @@ -112,7 +112,7 @@ private: uint8_t m_resize_quadrant { 0 }; Position m_resize_start; - bool m_is_mouse_captured { false }; + bool m_is_mouse_relative { false }; bool m_deleted_window { false }; bool m_is_stopped { false }; diff --git a/userspace/programs/WindowServer/main.cpp b/userspace/programs/WindowServer/main.cpp index 2a75e42c..b60b7a54 100644 --- a/userspace/programs/WindowServer/main.cpp +++ b/userspace/programs/WindowServer/main.cpp @@ -364,17 +364,17 @@ int main() if (auto ret = LibGUI::WindowPacket::enum::deserialize(client_data.packet_buffer.span()); !ret.is_error()) \ window_server.function(fd, ret.release_value()); \ break - WINDOW_PACKET_CASE(WindowCreate, on_window_create); - WINDOW_PACKET_CASE(WindowInvalidate, on_window_invalidate); - WINDOW_PACKET_CASE(WindowSetPosition, on_window_set_position); - WINDOW_PACKET_CASE(WindowSetAttributes, on_window_set_attributes); - WINDOW_PACKET_CASE(WindowSetMouseCapture, on_window_set_mouse_capture); - WINDOW_PACKET_CASE(WindowSetSize, on_window_set_size); - WINDOW_PACKET_CASE(WindowSetMinSize, on_window_set_min_size); - WINDOW_PACKET_CASE(WindowSetMaxSize, on_window_set_max_size); - WINDOW_PACKET_CASE(WindowSetFullscreen, on_window_set_fullscreen); - WINDOW_PACKET_CASE(WindowSetTitle, on_window_set_title); - WINDOW_PACKET_CASE(WindowSetCursor, on_window_set_cursor); + WINDOW_PACKET_CASE(WindowCreate, on_window_create); + WINDOW_PACKET_CASE(WindowInvalidate, on_window_invalidate); + WINDOW_PACKET_CASE(WindowSetPosition, on_window_set_position); + WINDOW_PACKET_CASE(WindowSetAttributes, on_window_set_attributes); + WINDOW_PACKET_CASE(WindowSetMouseRelative, on_window_set_mouse_relative); + WINDOW_PACKET_CASE(WindowSetSize, on_window_set_size); + WINDOW_PACKET_CASE(WindowSetMinSize, on_window_set_min_size); + WINDOW_PACKET_CASE(WindowSetMaxSize, on_window_set_max_size); + WINDOW_PACKET_CASE(WindowSetFullscreen, on_window_set_fullscreen); + WINDOW_PACKET_CASE(WindowSetTitle, on_window_set_title); + WINDOW_PACKET_CASE(WindowSetCursor, on_window_set_cursor); #undef WINDOW_PACKET_CASE default: dprintln("unhandled packet type: {}", *reinterpret_cast(client_data.packet_buffer.data()));