1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

Simplify Haiku cursor management code

* src/haiku_support.cc (BCursor_create_default)
(BCursor_create_modeline, BCursor_from_id, BCursor_create_i_beam)
(BCursor_create_progress_cursor, BCursor_create_grab)
(BCursor_delete): Delete specialized cursor creation functions.
(be_delete_cursor, be_create_cursor_from_id): New functions.
(BView_set_view_cursor): Fix coding style.
* src/haiku_support.h (enum haiku_cursor): Add all cursor IDs.
* src/haikufns.c (haiku_free_custom_cursors):
(haiku_set_mouse_color):
* src/haikuterm.c (haiku_term_init): Adjust accordingly.
This commit is contained in:
Po Lu 2022-05-15 06:23:25 +00:00
parent fef8a3a3cd
commit 99df11a393
4 changed files with 51 additions and 78 deletions

View file

@ -3379,56 +3379,28 @@ BView_resize_to (void *view, int width, int height)
vw->UnlockLooper ();
}
void *
BCursor_create_default (void)
{
return new BCursor (B_CURSOR_ID_SYSTEM_DEFAULT);
}
void *
BCursor_create_modeline (void)
{
return new BCursor (B_CURSOR_ID_CONTEXT_MENU);
}
void *
BCursor_from_id (int cursor)
{
return new BCursor ((enum BCursorID) cursor);
}
void *
BCursor_create_i_beam (void)
{
return new BCursor (B_CURSOR_ID_I_BEAM);
}
void *
BCursor_create_progress_cursor (void)
{
return new BCursor (B_CURSOR_ID_PROGRESS);
}
void *
BCursor_create_grab (void)
{
return new BCursor (B_CURSOR_ID_GRAB);
}
void
BCursor_delete (void *cursor)
be_delete_cursor (void *cursor)
{
if (cursor)
delete (BCursor *) cursor;
}
void *
be_create_cursor_from_id (int id)
{
return new BCursor ((enum BCursorID) id);
}
void
BView_set_view_cursor (void *view, void *cursor)
{
if (!((BView *) view)->LockLooper ())
BView *v = (BView *) view;
if (!v->LockLooper ())
gui_abort ("Failed to lock view setting cursor");
((BView *) view)->SetViewCursor ((BCursor *) cursor);
((BView *) view)->UnlockLooper ();
v->SetViewCursor ((BCursor *) cursor);
v->UnlockLooper ();
}
void

View file

@ -38,7 +38,21 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
enum haiku_cursor
{
CURSOR_ID_SYSTEM_DEFAULT = 1,
CURSOR_ID_CONTEXT_MENU = 3,
CURSOR_ID_COPY = 4,
CURSOR_ID_CREATE_LINK = 29,
CURSOR_ID_CROSS_HAIR = 5,
CURSOR_ID_FOLLOW_LINK = 6,
CURSOR_ID_GRAB = 7,
CURSOR_ID_GRABBING = 8,
CURSOR_ID_HELP = 9,
CURSOR_ID_I_BEAM = 2,
CURSOR_ID_I_BEAM_HORIZONTAL = 10,
CURSOR_ID_MOVE = 11,
CURSOR_ID_NO_CURSOR = 12,
CURSOR_ID_NOT_ALLOWED = 13,
CURSOR_ID_PROGRESS = 14,
CURSOR_ID_RESIZE_NORTH = 15,
CURSOR_ID_RESIZE_EAST = 16,
CURSOR_ID_RESIZE_SOUTH = 17,
@ -50,7 +64,9 @@ enum haiku_cursor
CURSOR_ID_RESIZE_NORTH_SOUTH = 23,
CURSOR_ID_RESIZE_EAST_WEST = 24,
CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST = 25,
CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST = 26
CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST = 26,
CURSOR_ID_ZOOM_IN = 27,
CURSOR_ID_ZOOM_OUT = 28
};
enum haiku_z_group
@ -556,14 +572,9 @@ extern void be_get_display_resolution (double *, double *);
extern void be_get_screen_dimensions (int *, int *);
/* Functions for creating and freeing cursors. */
extern void *BCursor_create_default (void);
extern void *BCursor_from_id (int);
extern void *BCursor_create_modeline (void);
extern void *BCursor_create_i_beam (void);
extern void *BCursor_create_progress_cursor (void);
extern void *BCursor_create_grab (void);
extern void BCursor_delete (void *);
extern void *be_create_cursor_from_id (int);
extern void *be_create_pixmap_cursor (void *, int, int);
extern void be_delete_cursor (void *);
extern void *BScrollBar_make_for_view (void *, int, int, int, int, int, void *);
extern void BScrollBar_delete (void *);

View file

@ -1975,7 +1975,7 @@ haiku_free_custom_cursors (struct frame *f)
if (output->current_cursor == *frame_cursor)
output->current_cursor = *display_cursor;
BCursor_delete (*frame_cursor);
be_delete_cursor (*frame_cursor);
}
*frame_cursor = *display_cursor;
@ -2039,7 +2039,7 @@ haiku_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
}
/* Create and set the custom cursor. */
*frame_cursor = BCursor_from_id (n);
*frame_cursor = be_create_cursor_from_id (n);
}
else if (color_specified_p && cursor_bitmaps[i].bits)
{

View file

@ -4216,34 +4216,24 @@ haiku_term_init (void)
gui_init_fringe (terminal->rif);
#define ASSIGN_CURSOR(cursor, be_cursor) (dpyinfo->cursor = be_cursor)
ASSIGN_CURSOR (text_cursor, BCursor_create_i_beam ());
ASSIGN_CURSOR (nontext_cursor, BCursor_create_default ());
ASSIGN_CURSOR (modeline_cursor, BCursor_create_modeline ());
ASSIGN_CURSOR (hand_cursor, BCursor_create_grab ());
ASSIGN_CURSOR (hourglass_cursor, BCursor_create_progress_cursor ());
ASSIGN_CURSOR (horizontal_drag_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_EAST_WEST));
ASSIGN_CURSOR (vertical_drag_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_NORTH_SOUTH));
ASSIGN_CURSOR (left_edge_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_WEST));
ASSIGN_CURSOR (top_left_corner_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_NORTH_WEST));
ASSIGN_CURSOR (top_edge_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_NORTH));
ASSIGN_CURSOR (top_right_corner_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_NORTH_EAST));
ASSIGN_CURSOR (right_edge_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_EAST));
ASSIGN_CURSOR (bottom_right_corner_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_SOUTH_EAST));
ASSIGN_CURSOR (bottom_edge_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_SOUTH));
ASSIGN_CURSOR (bottom_left_corner_cursor,
BCursor_from_id (CURSOR_ID_RESIZE_SOUTH_WEST));
ASSIGN_CURSOR (no_cursor,
BCursor_from_id (CURSOR_ID_NO_CURSOR));
#define ASSIGN_CURSOR(cursor, cursor_id) \
(dpyinfo->cursor = be_create_cursor_from_id (cursor_id))
ASSIGN_CURSOR (text_cursor, CURSOR_ID_I_BEAM);
ASSIGN_CURSOR (nontext_cursor, CURSOR_ID_SYSTEM_DEFAULT);
ASSIGN_CURSOR (modeline_cursor, CURSOR_ID_CONTEXT_MENU);
ASSIGN_CURSOR (hand_cursor, CURSOR_ID_GRAB);
ASSIGN_CURSOR (hourglass_cursor, CURSOR_ID_PROGRESS);
ASSIGN_CURSOR (horizontal_drag_cursor, CURSOR_ID_RESIZE_EAST_WEST);
ASSIGN_CURSOR (vertical_drag_cursor, CURSOR_ID_RESIZE_NORTH_SOUTH);
ASSIGN_CURSOR (left_edge_cursor, CURSOR_ID_RESIZE_WEST);
ASSIGN_CURSOR (top_left_corner_cursor, CURSOR_ID_RESIZE_NORTH_WEST);
ASSIGN_CURSOR (top_edge_cursor, CURSOR_ID_RESIZE_NORTH);
ASSIGN_CURSOR (top_right_corner_cursor, CURSOR_ID_RESIZE_NORTH_EAST);
ASSIGN_CURSOR (right_edge_cursor, CURSOR_ID_RESIZE_EAST);
ASSIGN_CURSOR (bottom_right_corner_cursor, CURSOR_ID_RESIZE_SOUTH_EAST);
ASSIGN_CURSOR (bottom_edge_cursor, CURSOR_ID_RESIZE_SOUTH);
ASSIGN_CURSOR (bottom_left_corner_cursor, CURSOR_ID_RESIZE_SOUTH_WEST);
ASSIGN_CURSOR (no_cursor, CURSOR_ID_NO_CURSOR);
#undef ASSIGN_CURSOR
system_name = Fsystem_name ();