From: Po Lu Date: Fri, 13 May 2022 04:03:36 +0000 (+0000) Subject: Allow setting cursor colors for custom cursors on Haiku X-Git-Tag: emacs-29.0.90~1910^2~748 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=53ed3ad5945411162dc514f439ad7f499daa30be;p=emacs.git 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. --- diff --git a/src/haikufns.c b/src/haikufns.c index 9bf672f1d83..e6bf60e1d90 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); }