be_get_display_planes (void)
{
color_space space = dpy_color_space;
+ BScreen screen;
+
if (space == B_NO_COLOR_SPACE)
{
- BScreen screen; /* This is actually a very slow operation. */
if (!screen.IsValid ())
gui_abort ("Invalid screen");
+
space = dpy_color_space = screen.ColorSpace ();
}
- if (space == B_RGB32 || space == B_RGB24)
- return 24;
- if (space == B_RGB16)
- return 16;
- if (space == B_RGB15)
- return 15;
- if (space == B_CMAP8)
- return 8;
+ switch (space)
+ {
+ case B_RGB32:
+ case B_RGB24:
+ return 24;
+ case B_RGB16:
+ return 16;
+ case B_RGB15:
+ return 15;
+ case B_CMAP8:
+ case B_GRAY8:
+ return 8;
+ case B_GRAY1:
+ return 1;
+
+ default:
+ gui_abort ("Bad colorspace for screen");
+ }
- gui_abort ("Bad colorspace for screen");
/* https://www.haiku-os.org/docs/api/classBScreen.html
says a valid screen can't be anything else. */
return -1;
int
be_get_display_color_cells (void)
{
+ BScreen screen;
color_space space = dpy_color_space;
+
if (space == B_NO_COLOR_SPACE)
{
- BScreen screen;
if (!screen.IsValid ())
gui_abort ("Invalid screen");
+
space = dpy_color_space = screen.ColorSpace ();
}
- if (space == B_RGB32 || space == B_RGB24)
- return 1677216;
- if (space == B_RGB16)
- return 65536;
- if (space == B_RGB15)
- return 32768;
- if (space == B_CMAP8)
- return 256;
+ switch (space)
+ {
+ case B_RGB32:
+ case B_RGB24:
+ return 16777216;
+ case B_RGB16:
+ return 65536;
+ case B_RGB15:
+ return 32768;
+ case B_CMAP8:
+ case B_GRAY8:
+ return 256;
+ case B_GRAY1:
+ return 2;
+
+ default:
+ gui_abort ("Bad colorspace for screen");
+ }
- gui_abort ("Bad colorspace for screen");
return -1;
}
+/* Return whether or not the current display is only capable of
+ producing grayscale colors. */
+bool
+be_is_display_grayscale (void)
+{
+ BScreen screen;
+ color_space space = dpy_color_space;
+
+ if (space == B_NO_COLOR_SPACE)
+ {
+ if (!screen.IsValid ())
+ gui_abort ("Invalid screen");
+
+ space = dpy_color_space = screen.ColorSpace ();
+ }
+
+ return space == B_GRAY8 || space == B_GRAY1;
+}
+
/* Warp the pointer to X by Y. */
void
be_warp_pointer (int x, int y)
static void
haiku_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
{
- block_input ();
if (!EQ (new_value, old_value))
FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value);
+ block_input ();
if (FRAME_HAIKU_WINDOW (f))
- {
- BWindow_set_avoid_focus (FRAME_HAIKU_WINDOW (f),
- FRAME_NO_ACCEPT_FOCUS (f));
- }
+ BWindow_set_avoid_focus (FRAME_HAIKU_WINDOW (f),
+ FRAME_NO_ACCEPT_FOCUS (f));
unblock_input ();
}
if (FRAME_ICONIFIED_P (frame))
return;
- block_input ();
-
SET_FRAME_VISIBLE (frame, false);
SET_FRAME_ICONIFIED (frame, true);
+ block_input ();
BWindow_iconify (FRAME_HAIKU_WINDOW (frame));
-
unblock_input ();
}
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object terminal)
{
- return Qt;
+ check_haiku_display_info (terminal);
+
+ return be_is_display_grayscale () ? Qnil : Qt;
}
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;
+ int rc;
CHECK_STRING (color);
decode_window_system_frame (frame);
block_input ();
- if (haiku_get_color (SSDATA (color), &col))
- {
- unblock_input ();
- return Qnil;
- }
+ rc = haiku_get_color (SSDATA (color), &col);
unblock_input ();
- return list3i (lrint (col.red), lrint (col.green),
- lrint (col.blue));
+ if (rc)
+ return Qnil;
+
+ return list3i (col.red, col.green, col.blue);
}
DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object terminal)
{
- return Qnil;
+ check_haiku_display_info (terminal);
+
+ return be_is_display_grayscale () ? Qt : Qnil;
}
DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
(Lisp_Object terminal)
{
+ int width, height;
check_haiku_display_info (terminal);
- int width, height;
BScreen_px_dim (&width, &height);
return make_fixnum (width);
}
(Lisp_Object terminal)
{
+ int width, height;
check_haiku_display_info (terminal);
- int width, height;
BScreen_px_dim (&width, &height);
return make_fixnum (width);
}
(Lisp_Object terminal)
{
struct haiku_display_info *dpyinfo = check_haiku_display_info (terminal);
-
int width, height;
- BScreen_px_dim (&width, &height);
+ BScreen_px_dim (&width, &height);
return make_fixnum (height / (dpyinfo->resy / 25.4));
}
(Lisp_Object terminal)
{
struct haiku_display_info *dpyinfo = check_haiku_display_info (terminal);
-
int width, height;
- BScreen_px_dim (&width, &height);
+ BScreen_px_dim (&width, &height);
return make_fixnum (width / (dpyinfo->resx / 25.4));
}
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object terminal)
{
+ int planes;
+ bool grayscale_p;
+
check_haiku_display_info (terminal);
- int planes = be_get_display_planes ();
+ grayscale_p = be_is_display_grayscale ();
+ if (grayscale_p)
+ return Qstatic_gray;
+ planes = be_get_display_planes ();
if (planes == 8)
- return intern ("static-color");
+ return Qstatic_color;
- return intern ("true-color");
+ return Qtrue_color;
}
DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
DEFSYM (Qwhen_mapped, "when-mapped");
DEFSYM (Qtooltip_reuse_hidden_frame, "tooltip-reuse-hidden-frame");
+ DEFSYM (Qstatic_color, "static-color");
+ DEFSYM (Qstatic_gray, "static-gray");
+ DEFSYM (Qtrue_color, "true-color");
+
defsubr (&Sx_hide_tip);
defsubr (&Sxw_display_color_p);
defsubr (&Sx_display_grayscale_p);