LibGUI/WindowServer: Allow custom cursor origin

This commit is contained in:
2026-02-10 23:09:19 +02:00
parent 4801fd3e67
commit 7a66eb44d4
5 changed files with 24 additions and 7 deletions

View File

@@ -201,11 +201,13 @@ namespace LibGUI
set_attributes(attributes);
}
void Window::set_cursor(uint32_t width, uint32_t height, BAN::Span<uint32_t> pixels)
void Window::set_cursor(uint32_t width, uint32_t height, BAN::Span<const uint32_t> pixels, int32_t origin_x, int32_t origin_y)
{
WindowPacket::WindowSetCursor packet;
packet.width = width;
packet.height = height;
packet.origin_x = origin_x;
packet.origin_y = origin_y;
MUST(packet.pixels.resize(pixels.size()));
for (size_t i = 0; i < packet.pixels.size(); i++)
packet.pixels[i] = pixels[i];

View File

@@ -15,6 +15,7 @@
#define FOR_EACH_4(macro, type, name, ...) macro(type, name) FOR_EACH_2(macro, __VA_ARGS__)
#define FOR_EACH_6(macro, type, name, ...) macro(type, name) FOR_EACH_4(macro, __VA_ARGS__)
#define FOR_EACH_8(macro, type, name, ...) macro(type, name) FOR_EACH_6(macro, __VA_ARGS__)
#define FOR_EACH_10(macro, type, name, ...) macro(type, name) FOR_EACH_8(macro, __VA_ARGS__)
#define CONCATENATE_2(arg1, arg2) arg1 ## arg2
#define CONCATENATE_1(arg1, arg2) CONCATENATE_2(arg1, arg2)
@@ -22,8 +23,8 @@
#define FOR_EACH_NARG(...) FOR_EACH_NARG_(__VA_ARGS__ __VA_OPT__(,) FOR_EACH_RSEQ_N())
#define FOR_EACH_NARG_(...) FOR_EACH_ARG_N(__VA_ARGS__)
#define FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
#define FOR_EACH_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0
#define FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define FOR_EACH_RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
#define FOR_EACH_(N, what, ...) CONCATENATE(FOR_EACH_, N)(what __VA_OPT__(,) __VA_ARGS__)
#define FOR_EACH(what, ...) FOR_EACH_(FOR_EACH_NARG(__VA_ARGS__), what __VA_OPT__(,) __VA_ARGS__)
@@ -303,6 +304,8 @@ namespace LibGUI
WindowSetCursor,
uint32_t, width,
uint32_t, height,
int32_t, origin_x,
int32_t, origin_y,
BAN::Vector<uint32_t>, pixels
);

View File

@@ -50,7 +50,7 @@ namespace LibGUI
void set_position(int32_t x, int32_t y);
void set_cursor_visible(bool visible);
void set_cursor(uint32_t width, uint32_t height, BAN::Span<uint32_t> pixels);
void set_cursor(uint32_t width, uint32_t height, BAN::Span<const uint32_t> pixels, int32_t origin_x = 0, int32_t origin_y = 0);
Attributes get_attributes() const { return m_attributes; }
void set_attributes(Attributes attributes);