[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bd2734f0b6: Don't allocate duplicate cursors for each frame on Ha
From: |
Po Lu |
Subject: |
master bd2734f0b6: Don't allocate duplicate cursors for each frame on Haiku |
Date: |
Tue, 22 Mar 2022 22:28:35 -0400 (EDT) |
branch: master
commit bd2734f0b6b4342f02ce18b5a950a41c3fa35a29
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Don't allocate duplicate cursors for each frame on Haiku
* src/haikufns.c (haiku_create_frame)
(haiku_free_frame_resources): Stop creating cursors.
* src/haikuterm.c (haiku_delete_terminal, haiku_term_init):
Create and free cursors here instead.
* src/haikuterm.h (struct haiku_display_info): New fields for
cursors.
---
src/haikufns.c | 72 +++++++++++++++++----------------------------------------
src/haikuterm.c | 50 +++++++++++++++++++++++++++++++++++++++
src/haikuterm.h | 17 ++++++++++++++
3 files changed, 88 insertions(+), 51 deletions(-)
diff --git a/src/haikufns.c b/src/haikufns.c
index 14d4c870c1..767f555317 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -761,38 +761,27 @@ haiku_create_frame (Lisp_Object parms)
f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem));
block_input ();
-#define ASSIGN_CURSOR(cursor, be_cursor) \
- (FRAME_OUTPUT_DATA (f)->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));
-
- ASSIGN_CURSOR (current_cursor, FRAME_OUTPUT_DATA (f)->text_cursor);
+#define ASSIGN_CURSOR(cursor) \
+ (FRAME_OUTPUT_DATA (f)->cursor = dpyinfo->cursor)
+
+ ASSIGN_CURSOR (text_cursor);
+ ASSIGN_CURSOR (nontext_cursor);
+ ASSIGN_CURSOR (modeline_cursor);
+ ASSIGN_CURSOR (hand_cursor);
+ ASSIGN_CURSOR (hourglass_cursor);
+ ASSIGN_CURSOR (horizontal_drag_cursor);
+ ASSIGN_CURSOR (vertical_drag_cursor);
+ ASSIGN_CURSOR (left_edge_cursor);
+ ASSIGN_CURSOR (top_left_corner_cursor);
+ ASSIGN_CURSOR (top_edge_cursor);
+ ASSIGN_CURSOR (top_right_corner_cursor);
+ ASSIGN_CURSOR (right_edge_cursor);
+ ASSIGN_CURSOR (bottom_right_corner_cursor);
+ ASSIGN_CURSOR (bottom_edge_cursor);
+ ASSIGN_CURSOR (bottom_left_corner_cursor);
+ ASSIGN_CURSOR (no_cursor);
+
+ FRAME_OUTPUT_DATA (f)->current_cursor = dpyinfo->text_cursor;
#undef ASSIGN_CURSOR
f->terminal->reference_count++;
@@ -1555,25 +1544,6 @@ haiku_free_frame_resources (struct frame *f)
if (window)
BWindow_quit (window);
- /* Free cursors */
-
- BCursor_delete (f->output_data.haiku->text_cursor);
- BCursor_delete (f->output_data.haiku->nontext_cursor);
- BCursor_delete (f->output_data.haiku->modeline_cursor);
- BCursor_delete (f->output_data.haiku->hand_cursor);
- BCursor_delete (f->output_data.haiku->hourglass_cursor);
- BCursor_delete (f->output_data.haiku->horizontal_drag_cursor);
- BCursor_delete (f->output_data.haiku->vertical_drag_cursor);
- BCursor_delete (f->output_data.haiku->left_edge_cursor);
- BCursor_delete (f->output_data.haiku->top_left_corner_cursor);
- BCursor_delete (f->output_data.haiku->top_edge_cursor);
- BCursor_delete (f->output_data.haiku->top_right_corner_cursor);
- BCursor_delete (f->output_data.haiku->right_edge_cursor);
- BCursor_delete (f->output_data.haiku->bottom_right_corner_cursor);
- BCursor_delete (f->output_data.haiku->bottom_edge_cursor);
- BCursor_delete (f->output_data.haiku->bottom_left_corner_cursor);
- BCursor_delete (f->output_data.haiku->no_cursor);
-
xfree (FRAME_OUTPUT_DATA (f));
FRAME_OUTPUT_DATA (f) = NULL;
diff --git a/src/haikuterm.c b/src/haikuterm.c
index b0bbee9e3b..c2e8375a10 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -122,7 +122,26 @@ haiku_delete_terminal (struct terminal *terminal)
return;
block_input ();
+
be_app_quit ();
+ delete_port (port_application_to_emacs);
+
+ BCursor_delete (dpyinfo->text_cursor);
+ BCursor_delete (dpyinfo->nontext_cursor);
+ BCursor_delete (dpyinfo->modeline_cursor);
+ BCursor_delete (dpyinfo->hand_cursor);
+ BCursor_delete (dpyinfo->hourglass_cursor);
+ BCursor_delete (dpyinfo->horizontal_drag_cursor);
+ BCursor_delete (dpyinfo->vertical_drag_cursor);
+ BCursor_delete (dpyinfo->left_edge_cursor);
+ BCursor_delete (dpyinfo->top_left_corner_cursor);
+ BCursor_delete (dpyinfo->top_edge_cursor);
+ BCursor_delete (dpyinfo->top_right_corner_cursor);
+ BCursor_delete (dpyinfo->right_edge_cursor);
+ BCursor_delete (dpyinfo->bottom_right_corner_cursor);
+ BCursor_delete (dpyinfo->bottom_edge_cursor);
+ BCursor_delete (dpyinfo->bottom_left_corner_cursor);
+ BCursor_delete (dpyinfo->no_cursor);
/* Close all frames and delete the generic struct terminal. */
for (t = terminal_list; t; t = t->next_terminal)
@@ -3911,6 +3930,37 @@ haiku_term_init (void)
dpyinfo->smallest_char_width = 1;
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));
+#undef ASSIGN_CURSOR
+
unblock_input ();
return dpyinfo;
diff --git a/src/haikuterm.h b/src/haikuterm.h
index bce1c627eb..5f8052f0f9 100644
--- a/src/haikuterm.h
+++ b/src/haikuterm.h
@@ -107,6 +107,23 @@ struct haiku_display_info
Time last_mouse_movement_time;
Window root_window;
+
+ Emacs_Cursor text_cursor;
+ Emacs_Cursor nontext_cursor;
+ Emacs_Cursor modeline_cursor;
+ Emacs_Cursor hand_cursor;
+ Emacs_Cursor hourglass_cursor;
+ Emacs_Cursor horizontal_drag_cursor;
+ Emacs_Cursor vertical_drag_cursor;
+ Emacs_Cursor left_edge_cursor;
+ Emacs_Cursor top_left_corner_cursor;
+ Emacs_Cursor top_edge_cursor;
+ Emacs_Cursor top_right_corner_cursor;
+ Emacs_Cursor right_edge_cursor;
+ Emacs_Cursor bottom_right_corner_cursor;
+ Emacs_Cursor bottom_edge_cursor;
+ Emacs_Cursor bottom_left_corner_cursor;
+ Emacs_Cursor no_cursor;
};
struct haiku_output
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bd2734f0b6: Don't allocate duplicate cursors for each frame on Haiku,
Po Lu <=