[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 53ed3ad594: Allow setting cursor colors for custom cursors on Hai
From: |
Po Lu |
Subject: |
master 53ed3ad594: Allow setting cursor colors for custom cursors on Haiku |
Date: |
Fri, 13 May 2022 00:04:21 -0400 (EDT) |
branch: master
commit 53ed3ad5945411162dc514f439ad7f499daa30be
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Allow setting cursor colors for custom cursors on Haiku
* src/haikufns.c: (struct user_cursor_bitmap_info):
(cursor_bitmaps): Fix hotspot for left arrow pointer.
(cursor_bitmaps_for_id): New array.
(haiku_set_mouse_color): If a color was specified, consult
`cursor_bitmaps_for_id' for user-specified cursors.
---
src/haikufns.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/src/haikufns.c b/src/haikufns.c
index 9bf672f1d8..e6bf60e1d9 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -1795,8 +1795,8 @@ struct user_cursor_info
struct user_cursor_bitmap_info
{
- /* The name of a bitmap to use instead of the font cursor if a
- cursor color was set. */
+ /* A bitmap to use instead of the font cursor to create cursors in a
+ certain color. */
const void *bits;
/* The mask for that bitmap. */
@@ -1837,8 +1837,8 @@ struct user_cursor_info custom_cursors[] =
struct user_cursor_bitmap_info cursor_bitmaps[] =
{
{ NULL, NULL, 0, 0, 0, 0 }, /* text_cursor
*/
- { left_ptr_bits, left_ptrmsk_bits, 16, 16, 4, 1 }, /* nontext_cursor */
- { left_ptr_bits, left_ptrmsk_bits, 16, 16, 4, 1 }, /* modeline_cursor */
+ { left_ptr_bits, left_ptrmsk_bits, 16, 16, 3, 1 }, /* nontext_cursor */
+ { left_ptr_bits, left_ptrmsk_bits, 16, 16, 3, 1 }, /* modeline_cursor */
{ NULL, NULL, 0, 0, 0, 0 }, /* hand_cursor
*/
{ NULL, NULL, 0, 0, 0, 0 }, /*
hourglass_cursor */
{ NULL, NULL, 0, 0, 0, 0 }, /*
horizontal_drag_cursor */
@@ -1854,6 +1854,40 @@ struct user_cursor_bitmap_info cursor_bitmaps[] =
{ NULL, NULL, 0, 0, 0, 0 }, /* no_cursor */
};
+/* Array of cursor bitmaps for each system cursor ID. This is used to
+ color in user-specified cursors. */
+struct user_cursor_bitmap_info cursor_bitmaps_for_id[28] =
+ {
+ { NULL, NULL, 0, 0, 0, 0 },
+ { left_ptr_bits, left_ptrmsk_bits, 16, 16, 3, 1 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 },
+ };
+
static void *
haiku_create_colored_cursor (struct user_cursor_bitmap_info *info,
uint32_t foreground, uint32_t background)
@@ -1973,6 +2007,20 @@ haiku_set_mouse_color (struct frame *f, Lisp_Object arg,
Lisp_Object oldval)
n = XFIXNUM (*custom_cursors[i].lisp_cursor);
+ if (color_specified_p && cursor_bitmaps_for_id[n].bits)
+ {
+ recolored
+ = haiku_create_colored_cursor (&cursor_bitmaps_for_id[n],
+ color.pixel,
+ FRAME_BACKGROUND_PIXEL (f));
+
+ if (recolored)
+ {
+ *frame_cursor = recolored;
+ continue;
+ }
+ }
+
/* Create and set the custom cursor. */
*frame_cursor = BCursor_from_id (n);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 53ed3ad594: Allow setting cursor colors for custom cursors on Haiku,
Po Lu <=