LibGUI/WindowServer: Rename mouse capture -> mouse relative
My terminology was incorrect and this is more correct
This commit is contained in:
parent
4519c48284
commit
af0a46e79c
|
@ -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__);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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> 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())
|
||||
{
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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<uint32_t*>(client_data.packet_buffer.data()));
|
||||
|
|
Loading…
Reference in New Issue