class EmacsView : public BView
{
public:
- uint32_t visible_bell_color = 0;
uint32_t previous_buttons = 0;
int looper_locked_count = 0;
BRegion sb_region;
}
}
- void
- Pulse (void)
- {
- visible_bell_color = 0;
- SetFlags (Flags () & ~B_PULSE_NEEDED);
- Window ()->SetPulseRate (0);
- Invalidate ();
- }
-
void
Draw (BRect expose_bounds)
{
struct haiku_expose_event rq;
EmacsWindow *w = (EmacsWindow *) Window ();
- if (visible_bell_color > 0)
- {
- PushState ();
- BView_SetHighColorForVisibleBell (this, visible_bell_color);
- FillRect (Frame ());
- PopState ();
- return;
- }
-
if (w->shown_flag && offscreen_draw_view)
{
PushState ();
}
}
- void
- DoVisibleBell (uint32_t color)
- {
- if (!LockLooper ())
- gui_abort ("Failed to lock looper during visible bell");
- visible_bell_color = color | (255 << 24);
- SetFlags (Flags () | B_PULSE_NEEDED);
- Window ()->SetPulseRate (100 * 1000);
- Invalidate ();
- UnlockLooper ();
- }
-
void
FlipBuffers (void)
{
}
}
-/* Temporarily fill VIEW with COLOR. */
-void
-EmacsView_do_visible_bell (void *view, uint32_t color)
-{
- EmacsView *vw = (EmacsView *) view;
- vw->DoVisibleBell (color);
-}
-
/* Zoom WINDOW. */
void
BWindow_zoom (void *window)
extern void
BView_SetHighColorForVisibleBell (void *view, uint32_t color);
- extern void
- BView_FillRectangleForVisibleBell (void *view, int x, int y, int width,
- int height);
-
extern void
BView_SetLowColor (void *view, uint32_t color);
int vx, int vy, int vwidth, int vheight,
uint32_t color);
+ extern void
+ BView_InvertRect (void *view, int x, int y, int width, int height);
+
extern void *
BBitmap_transform_bitmap (void *bitmap, void *mask, uint32_t m_color,
double rot, int desw, int desh);
extern void
c_unbind_to_nil_from_cxx (ptrdiff_t idx);
- extern void
- EmacsView_do_visible_bell (void *view, uint32_t color);
-
extern void
BWindow_zoom (void *window);
BBitmap_free (pixmap);
}
+static void
+haiku_flash (struct frame *f)
+{
+ /* Get the height not including a menu bar widget. */
+ int height = FRAME_PIXEL_HEIGHT (f);
+ /* Height of each line to flash. */
+ int flash_height = FRAME_LINE_HEIGHT (f);
+ /* These will be the left and right margins of the rectangles. */
+ int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
+ int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f);
+ int width = flash_right - flash_left;
+ void *view = FRAME_HAIKU_VIEW (f);
+ struct timespec delay, wakeup, current, timeout;
+
+ delay = make_timespec (0, 150 * 1000 * 1000);
+ wakeup = timespec_add (current_timespec (), delay);
+
+ BView_draw_lock (view);
+ BView_StartClip (view);
+ /* If window is tall, flash top and bottom line. */
+ if (height > 3 * FRAME_LINE_HEIGHT (f))
+ {
+ BView_InvertRect (view, flash_left,
+ (FRAME_INTERNAL_BORDER_WIDTH (f)
+ + FRAME_TOP_MARGIN_HEIGHT (f)),
+ width, flash_height);
+
+ BView_InvertRect (view, flash_left,
+ (height - flash_height
+ - FRAME_INTERNAL_BORDER_WIDTH (f)),
+ width, flash_height);
+ }
+ else
+ /* If it is short, flash it all. */
+ BView_InvertRect (view, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+ width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+ BView_EndClip (view);
+ BView_draw_unlock (view);
+
+ flush_frame (f);
+
+ if (EmacsView_double_buffered_p (view))
+ haiku_flip_buffers (f);
+
+ /* Keep waiting until past the time wakeup or any input gets
+ available. */
+ while (!detect_input_pending ())
+ {
+ current = current_timespec ();
+
+ /* Break if result would not be positive. */
+ if (timespec_cmp (wakeup, current) <= 0)
+ break;
+
+ /* How long `select' should wait. */
+ timeout = make_timespec (0, 10 * 1000 * 1000);
+
+ /* Try to wait that long--but we might wake up sooner. */
+ pselect (0, NULL, NULL, NULL, &timeout, NULL);
+ }
+
+ BView_draw_lock (view);
+ BView_StartClip (view);
+ /* If window is tall, flash top and bottom line. */
+ if (height > 3 * FRAME_LINE_HEIGHT (f))
+ {
+ BView_InvertRect (view, flash_left,
+ (FRAME_INTERNAL_BORDER_WIDTH (f)
+ + FRAME_TOP_MARGIN_HEIGHT (f)),
+ width, flash_height);
+
+ BView_InvertRect (view, flash_left,
+ (height - flash_height
+ - FRAME_INTERNAL_BORDER_WIDTH (f)),
+ width, flash_height);
+ }
+ else
+ /* If it is short, flash it all. */
+ BView_InvertRect (view, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+ width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
+ BView_EndClip (view);
+ BView_draw_unlock (view);
+
+ flush_frame (f);
+ if (EmacsView_double_buffered_p (view))
+ haiku_flip_buffers (f);
+}
+
static void
haiku_beep (struct frame *f)
{
if (view)
{
block_input ();
- BView_draw_lock (view);
- if (!EmacsView_double_buffered_p (view))
- {
- BView_SetHighColorForVisibleBell (view, FRAME_FOREGROUND_PIXEL (f));
- BView_FillRectangleForVisibleBell (view, 0, 0, FRAME_PIXEL_WIDTH (f),
- FRAME_PIXEL_HEIGHT (f));
- SET_FRAME_GARBAGED (f);
- expose_frame (f, 0, 0, 0, 0);
- }
- else
- {
- EmacsView_do_visible_bell (view, FRAME_FOREGROUND_PIXEL (f));
- haiku_flip_buffers (f);
- }
- BView_draw_unlock (view);
+ haiku_flash (f);
unblock_input ();
}
}