Fix default frame name on Haiku

* src/haikufns.c (haiku_set_background_color)
(haiku_set_cursor_color, haiku_get_pixel, haiku_put_pixel)
(haiku_set_internal_border_width)
(haiku_set_inhibit_double_buffering)
(Fhaiku_mouse_absolute_pixel_position, Fxw_color_defined_p)
(Fxw_color_values, Fx_double_buffered_p)
(Fx_display_backing_store): Clean up coding style.
(haiku_set_name): Use correct default name and don't cons extra
string all the time.

* src/haikuterm.c (haiku_read_socket): Remove unused variable.
(haiku_term_init): Set default name.
(mark_haiku_display): Mark new field.

* src/haikuterm.h (struct haiku_display_info): New field
`default_name'.
This commit is contained in:
Po Lu 2022-04-22 05:42:09 +00:00
parent 664da3e936
commit 381eb5d5a0
3 changed files with 70 additions and 55 deletions

View file

@ -1394,11 +1394,12 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
void
haiku_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
Emacs_Color color;
struct face *defface;
CHECK_STRING (arg);
block_input ();
Emacs_Color color;
if (haiku_get_color (SSDATA (arg), &color))
{
store_frame_param (f, Qbackground_color, oldval);
@ -1411,8 +1412,6 @@ haiku_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval
if (FRAME_HAIKU_VIEW (f))
{
struct face *defface;
BView_draw_lock (FRAME_HAIKU_VIEW (f), false, 0, 0, 0, 0);
BView_SetViewColor (FRAME_HAIKU_VIEW (f), color.pixel);
BView_draw_unlock (FRAME_HAIKU_VIEW (f));
@ -1434,11 +1433,11 @@ haiku_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval
void
haiku_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
CHECK_STRING (arg);
block_input ();
Emacs_Color color, fore_pixel;
CHECK_STRING (arg);
block_input ();
if (haiku_get_color (SSDATA (arg), &color))
{
store_frame_param (f, Qcursor_color, oldval);
@ -1478,11 +1477,7 @@ haiku_get_pixel (haiku bitmap, int x, int y)
{
unsigned char *data;
int32_t bytes_per_row;
int mono_p;
int left;
int right;
int top;
int bottom;
int mono_p, left, right, top, bottom, byte;
data = BBitmap_data (bitmap);
BBitmap_dimensions (bitmap, &left, &top, &right, &bottom,
@ -1494,20 +1489,17 @@ haiku_get_pixel (haiku bitmap, int x, int y)
if (!mono_p)
return ((uint32_t *) (data + (bytes_per_row * y)))[x];
int byte = y * bytes_per_row + x / 8;
byte = y * bytes_per_row + x / 8;
return data[byte] & (1 << (x % 8));
}
void
haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel)
{
unsigned char *data;
unsigned char *data, *byte;
int32_t bytes_per_row;
int mono_p;
int left;
int right;
int top;
int bottom;
int mono_p, left, right, top, bottom;
ptrdiff_t off, bit, xoff;
data = BBitmap_data (bitmap);
BBitmap_dimensions (bitmap, &left, &top, &right, &bottom,
@ -1518,11 +1510,11 @@ haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel)
if (mono_p)
{
ptrdiff_t off = y * bytes_per_row;
ptrdiff_t bit = x % 8;
ptrdiff_t xoff = x / 8;
off = y * bytes_per_row;
bit = x % 8;
xoff = x / 8;
unsigned char *byte = data + off + xoff;
byte = data + off + xoff;
if (!pixel)
*byte &= ~(1 << bit);
else
@ -1652,7 +1644,8 @@ haiku_unvisualize_frame (struct frame *f)
}
void
haiku_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
haiku_set_internal_border_width (struct frame *f, Lisp_Object arg,
Lisp_Object oldval)
{
int old_width = FRAME_INTERNAL_BORDER_WIDTH (f);
int new_width = check_int_nonnegative (arg);
@ -1707,28 +1700,33 @@ check_x_display_info (Lisp_Object object)
return check_haiku_display_info (object);
}
/* Rename frame F to NAME. If NAME is nil, set F's name to "GNU
Emacs". If EXPLICIT_P is non-zero, that indicates Lisp code is
setting the name, not redisplay; in that case, set F's name to NAME
and set F->explicit_name; if NAME is nil, clear F->explicit_name.
/* Rename frame F to NAME. If NAME is nil, set F's name to the
default name. If EXPLICIT_P is non-zero, that indicates Lisp code
is setting the name, not redisplay; in that case, set F's name to
NAME and set F->explicit_name; if NAME is nil, clear
F->explicit_name.
If EXPLICIT_P is zero, it means redisplay is setting the name; the
name provided will be ignored if explicit_name is set. */
void
haiku_set_name (struct frame *f, Lisp_Object name, bool explicit_p)
{
struct haiku_display_info *dpyinfo;
if (explicit_p)
{
if (f->explicit_name && NILP (name))
update_mode_lines = 24;
update_mode_lines = 37;
f->explicit_name = !NILP (name);
}
else if (f->explicit_name)
return;
dpyinfo = FRAME_DISPLAY_INFO (f);
if (NILP (name))
name = build_unibyte_string ("GNU Emacs");
name = dpyinfo->default_name;
if (!NILP (Fstring_equal (name, f->name)))
return;
@ -1754,11 +1752,9 @@ haiku_set_inhibit_double_buffering (struct frame *f,
{
#endif
EmacsView_set_up_double_buffering (FRAME_HAIKU_VIEW (f));
if (!NILP (old_value))
{
SET_FRAME_GARBAGED (f);
expose_frame (f, 0, 0, 0, 0);
}
expose_frame (f, 0, 0, 0, 0);
#ifndef USE_BE_CAIRO
}
else
@ -1798,19 +1794,15 @@ the mouse cursor position in pixels relative to a position (0, 0) of the
selected frame's display. */)
(void)
{
if (!x_display_list)
return Qnil;
struct frame *f = SELECTED_FRAME ();
void *view;
int x, y;
if (FRAME_INITIAL_P (f) || !FRAME_HAIKU_P (f)
|| !FRAME_HAIKU_VIEW (f))
if (FRAME_INITIAL_P (f) || !FRAME_HAIKU_P (f))
return Qnil;
block_input ();
void *view = FRAME_HAIKU_VIEW (f);
int x, y;
view = FRAME_HAIKU_VIEW (f);
BView_get_mouse (view, &x, &y);
BView_convert_to_screen (view, &x, &y);
unblock_input ();
@ -1830,6 +1822,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
(Lisp_Object color, Lisp_Object frame)
{
Emacs_Color col;
CHECK_STRING (color);
decode_window_system_frame (frame);
@ -1841,6 +1834,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
(Lisp_Object color, Lisp_Object frame)
{
Emacs_Color col;
CHECK_STRING (color);
decode_window_system_frame (frame);
@ -1851,7 +1845,9 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
return Qnil;
}
unblock_input ();
return list3i (lrint (col.red), lrint (col.green), lrint (col.blue));
return list3i (lrint (col.red), lrint (col.green),
lrint (col.blue));
}
DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
@ -2346,8 +2342,7 @@ DEFUN ("x-double-buffered-p", Fx_double_buffered_p, Sx_double_buffered_p,
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object frame)
{
struct frame *f = decode_live_frame (frame);
check_window_system (f);
struct frame *f = decode_window_system_frame (frame);
return EmacsView_double_buffered_p (FRAME_HAIKU_VIEW (f)) ? Qt : Qnil;
}
@ -2357,13 +2352,14 @@ DEFUN ("x-display-backing-store", Fx_display_backing_store, Sx_display_backing_s
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object terminal)
{
struct frame *f;
if (FRAMEP (terminal))
{
CHECK_LIVE_FRAME (terminal);
struct frame *f = decode_window_system_frame (terminal);
f = decode_window_system_frame (terminal);
if (FRAME_HAIKU_VIEW (f) &&
EmacsView_double_buffered_p (FRAME_HAIKU_VIEW (f)))
if (FRAME_HAIKU_VIEW (f)
&& EmacsView_double_buffered_p (FRAME_HAIKU_VIEW (f)))
return FRAME_PARENT_FRAME (f) ? Qwhen_mapped : Qalways;
else
return Qnot_useful;

View file

@ -3121,7 +3121,6 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
|| b->y < r.y || b->y >= r.y + r.height)
{
f->mouse_moved = true;
dpyinfo->last_mouse_scroll_bar = NULL;
note_mouse_highlight (f, b->x, b->y);
remember_mouse_glyph (f, b->x, b->y,
&FRAME_DISPLAY_INFO (f)->last_mouse_glyph);
@ -3948,8 +3947,9 @@ haiku_term_init (void)
{
struct haiku_display_info *dpyinfo;
struct terminal *terminal;
Lisp_Object color_file, color_map;
Lisp_Object color_file, color_map, system_name;
ptrdiff_t nbytes;
void *name_buffer;
block_input ();
Fset_input_interrupt_mode (Qt);
@ -4026,6 +4026,23 @@ haiku_term_init (void)
BCursor_from_id (CURSOR_ID_NO_CURSOR));
#undef ASSIGN_CURSOR
system_name = Fsystem_name ();
if (STRINGP (system_name))
{
nbytes = sizeof "GNU Emacs" + sizeof " at ";
if (INT_ADD_WRAPV (nbytes, SBYTES (system_name), &nbytes))
memory_full (SIZE_MAX);
name_buffer = alloca (nbytes);
sprintf (name_buffer, "%s%s%s", "GNU Emacs",
" at ", SDATA (system_name));
dpyinfo->default_name = build_string (name_buffer);
}
else
dpyinfo->default_name = build_string ("GNU Emacs");
unblock_input ();
return dpyinfo;
@ -4093,7 +4110,10 @@ void
mark_haiku_display (void)
{
if (x_display_list)
mark_object (x_display_list->color_map);
{
mark_object (x_display_list->color_map);
mark_object (x_display_list->default_name);
}
}
void

View file

@ -81,6 +81,7 @@ struct haiku_display_info
int color_p;
Lisp_Object rdb;
Lisp_Object default_name;
Emacs_Cursor vertical_scroll_bar_cursor;
Emacs_Cursor horizontal_scroll_bar_cursor;
@ -96,8 +97,6 @@ struct haiku_display_info
struct haiku_rect last_mouse_glyph;
void *last_mouse_scroll_bar;
haiku display;
double resx, resy;