emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 095a776d06: Clean up various bits of Haiku code


From: Po Lu
Subject: master 095a776d06: Clean up various bits of Haiku code
Date: Fri, 15 Apr 2022 02:37:45 -0400 (EDT)

branch: master
commit 095a776d0642bced88a6357f2d889c8980e0b83a
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Clean up various bits of Haiku code
    
    * src/haiku_font_support.cc (BFont_string_width): Delete unused
    function.
    * src/haiku_support.cc (BWindow_new): Clean up type of `view'.
    (BWindow_quit): Clean up coding style.
    (BView_mouse_down, BView_mouse_up, BView_mouse_moved): Delete
    unused functions.
    (unwind_popup_file_dialog): Clean up coding style.
    (be_popup_file_dialog_safe_set_target): Delete function.
    (be_popup_file_dialog): Improve code clarity.
    * src/haiku_support.h: Fix coding style.
    * src/haikufns.c (haiku_get_color, haiku_display_info_for_name)
    (check_haiku_display_info, Fhaiku_read_file_name)
    (Fx_display_save_under, Fhaiku_frame_restack): Remove references
    to "Be displays" and replace them with "Haiku displays".
    * src/haikuselect.h: Clean up coding style.
    * src/haikuterm.c (haiku_read_socket): Clean up coding style and
    fix a few latent bugs.
---
 src/haiku_font_support.cc |   6 -
 src/haiku_support.cc      |  99 ++----
 src/haiku_support.h       | 776 ++++++++++++++--------------------------------
 src/haikufns.c            |  40 ++-
 src/haikuselect.h         | 123 +++-----
 src/haikuterm.c           |  33 +-
 6 files changed, 342 insertions(+), 735 deletions(-)

diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc
index fd41ee71f0..d3e1128e09 100644
--- a/src/haiku_font_support.cc
+++ b/src/haiku_font_support.cc
@@ -622,12 +622,6 @@ BFont_populate_plain_family (struct haiku_font_pattern 
*ptn)
   ptn->family[sizeof ptn->family - 1] = '\0';
 }
 
-int
-BFont_string_width (void *font, const char *utf8)
-{
-  return ((BFont *) font)->StringWidth (utf8);
-}
-
 haiku_font_family_or_style *
 be_list_font_families (size_t *length)
 {
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index d92e3d95ac..4fd2fc4aa5 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -2458,20 +2458,22 @@ BApplication_setup (void)
 
 /* Set up and return a window with its view put in VIEW.  */
 void *
-BWindow_new (void *_view)
+BWindow_new (void **view)
 {
-  BWindow *window = new (std::nothrow) EmacsWindow;
-  BView **v = (BView **) _view;
+  BWindow *window;
+  BView *vw;
+
+  window = new (std::nothrow) EmacsWindow;
   if (!window)
     {
-      *v = NULL;
+      *view = NULL;
       return window;
     }
 
-  BView *vw = new (std::nothrow) EmacsView;
+  vw = new (std::nothrow) EmacsView;
   if (!vw)
     {
-      *v = NULL;
+      *view = NULL;
       window->LockLooper ();
       window->Quit ();
       return NULL;
@@ -2485,15 +2487,17 @@ BWindow_new (void *_view)
      the first time.  */
   window->UnlockLooper ();
   window->AddChild (vw);
-  *v = vw;
+  *view = vw;
   return window;
 }
 
 void
 BWindow_quit (void *window)
 {
-  ((BWindow *) window)->LockLooper ();
-  ((BWindow *) window)->Quit ();
+  BWindow *w = (BWindow *) window;
+
+  w->LockLooper ();
+  w->Quit ();
 }
 
 /* Set WINDOW's offset to X, Y.  */
@@ -2814,42 +2818,6 @@ BWindow_center_on_screen (void *window)
   w->CenterOnScreen ();
 }
 
-/* Tell VIEW it has been clicked at X by Y.  */
-void
-BView_mouse_down (void *view, int x, int y)
-{
-  BView *vw = (BView *) view;
-  if (vw->LockLooper ())
-    {
-      vw->MouseDown (BPoint (x, y));
-      vw->UnlockLooper ();
-    }
-}
-
-/* Tell VIEW the mouse has been released at X by Y.  */
-void
-BView_mouse_up (void *view, int x, int y)
-{
-  BView *vw = (BView *) view;
-  if (vw->LockLooper ())
-    {
-      vw->MouseUp (BPoint (x, y));
-      vw->UnlockLooper ();
-    }
-}
-
-/* Tell VIEW that the mouse has moved to Y by Y.  */
-void
-BView_mouse_moved (void *view, int x, int y, uint32_t transit)
-{
-  BView *vw = (BView *) view;
-  if (vw->LockLooper ())
-    {
-      vw->MouseMoved (BPoint (x, y), transit, NULL);
-      vw->UnlockLooper ();
-    }
-}
-
 /* Import fringe bitmap (short array, low bit rightmost) BITS into
    BITMAP using the B_GRAY1 colorspace.  */
 void
@@ -3715,44 +3683,45 @@ struct popup_file_dialog_data
 static void
 unwind_popup_file_dialog (void *ptr)
 {
-  struct popup_file_dialog_data *data =
-    (struct popup_file_dialog_data *) ptr;
+  struct popup_file_dialog_data *data
+    = (struct popup_file_dialog_data *) ptr;
   BFilePanel *panel = data->panel;
+
   delete panel;
   delete data->entry;
   delete data->msg;
 }
 
-static void
-be_popup_file_dialog_safe_set_target (BFilePanel *dialog, BWindow *window)
-{
-  dialog->SetTarget (BMessenger (window));
-}
-
 /* Popup a file dialog.  */
 char *
-be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, 
int dir_only_p,
-                     void *window, const char *save_text, const char *prompt,
-                     void (*block_input_function) (void),
+be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p,
+                     int dir_only_p, void *window, const char *save_text,
+                     const char *prompt, void (*block_input_function) (void),
                      void (*unblock_input_function) (void),
                      void (*maybe_quit_function) (void))
 {
   specpdl_ref idx = c_specpdl_idx_from_cxx ();
   /* setjmp/longjmp is UB with automatic objects. */
-  block_input_function ();
   BWindow *w = (BWindow *) window;
-  uint32_t mode = dir_only_p ? B_DIRECTORY_NODE : B_FILE_NODE | 
B_DIRECTORY_NODE;
+  uint32_t mode = (dir_only_p
+                  ? B_DIRECTORY_NODE
+                  : B_FILE_NODE | B_DIRECTORY_NODE);
   BEntry *path = new BEntry;
   BMessage *msg = new BMessage ('FPSE');
   BFilePanel *panel = new BFilePanel (open_p ? B_OPEN_PANEL : B_SAVE_PANEL,
                                      NULL, NULL, mode);
-
+  void *buf;
+  enum haiku_event_type type;
+  char *ptr;
   struct popup_file_dialog_data dat;
+  ssize_t b_s;
+
   dat.entry = path;
   dat.msg = msg;
   dat.panel = panel;
 
   record_c_unwind_protect_from_cxx (unwind_popup_file_dialog, &dat);
+
   if (default_dir)
     {
       if (path->SetTo (default_dir, 0) != B_OK)
@@ -3760,22 +3729,21 @@ be_popup_file_dialog (int open_p, const char 
*default_dir, int must_match_p, int
     }
 
   panel->SetMessage (msg);
+
   if (default_dir)
     panel->SetPanelDirectory (path);
   if (save_text)
     panel->SetSaveText (save_text);
+
   panel->SetHideWhenDone (0);
   panel->Window ()->SetTitle (prompt);
-  be_popup_file_dialog_safe_set_target (panel, w);
-
+  panel->SetTarget (BMessenger (w));
   panel->Show ();
-  unblock_input_function ();
 
-  void *buf = alloca (200);
+  buf = alloca (200);
   while (1)
     {
-      enum haiku_event_type type;
-      char *ptr = NULL;
+      ptr = NULL;
 
       if (!haiku_read_with_timeout (&type, buf, 200, 1000000, false))
        {
@@ -3789,7 +3757,6 @@ be_popup_file_dialog (int open_p, const char 
*default_dir, int must_match_p, int
          maybe_quit_function ();
        }
 
-      ssize_t b_s;
       block_input_function ();
       haiku_read_size (&b_s, false);
       if (!b_s || ptr || panel->Window ()->IsHidden ())
diff --git a/src/haiku_support.h b/src/haiku_support.h
index 1de135c55b..eb54fe75dd 100644
--- a/src/haiku_support.h
+++ b/src/haiku_support.h
@@ -372,7 +372,6 @@ struct haiku_menu_bar_state_event
    to bind to the specpdl and handle quitting correctly.  */
 
 #ifdef __cplusplus
-
 #if SIZE_MAX > 0xffffffff
 #define WRAP_SPECPDL_REF 1
 #endif
@@ -394,572 +393,249 @@ extern "C"
 #include <OS.h>
 
 #ifdef __cplusplus
-  typedef void *haiku;
+typedef void *haiku;
 
-  extern void
-  haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel);
+extern void
+haiku_put_pixel (haiku, int, int, unsigned long);
 
-  extern unsigned long
-  haiku_get_pixel (haiku bitmap, int x, int y);
+extern unsigned long
+haiku_get_pixel (haiku, int, int);
 #endif
 
-  extern port_id port_application_to_emacs;
-  extern port_id port_popup_menu_to_emacs;
-
-  extern void haiku_io_init (void);
-  extern void haiku_io_init_in_app_thread (void);
-
-  extern void
-  haiku_read_size (ssize_t *len, bool popup_menu_p);
-
-  extern int
-  haiku_read (enum haiku_event_type *type, void *buf, ssize_t len);
-
-  extern int
-  haiku_read_with_timeout (enum haiku_event_type *type, void *buf, ssize_t len,
-                          bigtime_t timeout, bool popup_menu_p);
-
-  extern int
-  haiku_write (enum haiku_event_type type, void *buf);
-
-  extern int
-  haiku_write_without_signal (enum haiku_event_type type, void *buf,
-                             bool popup_menu_p);
-
-  extern void
-  rgb_color_hsl (uint32_t rgb, double *h, double *s, double *l);
-
-  extern void
-  hsl_color_rgb (double h, double s, double l, uint32_t *rgb);
-
-  extern void *
-  BBitmap_new (int width, int height, int mono_p);
-
-  extern void *
-  BBitmap_data (void *bitmap);
-
-  extern int
-  BBitmap_convert (void *bitmap, void **new_bitmap);
-
-  extern void
-  BBitmap_free (void *bitmap);
-
-  extern void
-  BBitmap_dimensions (void *bitmap, int *left, int *top,
-                     int *right, int *bottom, int32_t *bytes_per_row,
-                     int *mono_p);
-
-  extern void *
-  BApplication_setup (void);
-
-  extern void *
-  BWindow_new (void *view);
-
-  extern void
-  BWindow_quit (void *window);
-
-  extern void
-  BWindow_set_offset (void *window, int x, int y);
-
-  extern void
-  BWindow_iconify (void *window);
-
-  extern void
-  BWindow_set_visible (void *window, int visible_p);
-
-  extern void
-  BFont_close (void *font);
-
-  extern void
-  BFont_dat (void *font, int *px_size, int *min_width, int *max_width,
-            int *avg_width, int *height, int *space_width, int *ascent,
-            int *descent, int *underline_position, int *underline_thickness);
-
-  extern int
-  BFont_have_char_p (void *font, int32_t chr);
-
-  extern int
-  BFont_have_char_block (void *font, int32_t beg, int32_t end);
-
-  extern void
-  BFont_char_bounds (void *font, const char *mb_str, int *advance,
-                    int *lb, int *rb);
-
-  extern void
-  BFont_nchar_bounds (void *font, const char *mb_str, int *advance,
-                     int *lb, int *rb, int32_t n);
-
-  extern void
-  BWindow_retitle (void *window, const char *title);
-
-  extern void
-  BWindow_resize (void *window, int width, int height);
-
-  extern void
-  BWindow_activate (void *window);
-
-  extern void
-  BView_StartClip (void *view);
-
-  extern void
-  BView_EndClip (void *view);
-
-  extern void
-  BView_SetHighColor (void *view, uint32_t color);
-
-  extern void
-  BView_SetHighColorForVisibleBell (void *view, uint32_t color);
-
-  extern void
-  BView_SetLowColor (void *view, uint32_t color);
-
-  extern void
-  BView_SetPenSize (void *view, int u);
-
-  extern void
-  BView_SetFont (void *view, void *font);
-
-  extern void
-  BView_MovePenTo (void *view, int x, int y);
-
-  extern void
-  BView_DrawString (void *view, const char *chr, ptrdiff_t len);
-
-  extern void
-  BView_DrawChar (void *view, char chr);
-
-  extern void
-  BView_FillRectangle (void *view, int x, int y, int width, int height);
-
-  extern void
-  BView_FillRectangleAbs (void *view, int x, int y, int x1, int y1);
-
-  extern void
-  BView_FillTriangle (void *view, int x1, int y1,
-                     int x2, int y2, int x3, int y3);
-
-  extern void
-  BView_StrokeRectangle (void *view, int x, int y, int width, int height);
-
-  extern void
-  BView_SetViewColor (void *view, uint32_t color);
-
-  extern void
-  BView_ClipToRect (void *view, int x, int y, int width, int height);
-
-  extern void
-  BView_ClipToInverseRect (void *view, int x, int y, int width, int height);
-
-  extern void
-  BView_StrokeLine (void *view, int sx, int sy, int tx, int ty);
-
-  extern void
-  BView_CopyBits (void *view, int x, int y, int width, int height,
-                 int tox, int toy, int towidth, int toheight);
-
-  extern void
-  BView_DrawBitmap (void *view, void *bitmap, int x, int y,
-                   int width, int height, int vx, int vy, int vwidth,
-                   int vheight);
-
-  extern void
-  BView_DrawBitmapWithEraseOp (void *view, void *bitmap, int x,
-                              int y, int width, int height);
-
-  extern void
-  BView_DrawMask (void *src, void *view,
-                 int x, int y, int width, int height,
-                 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
-  BScreen_px_dim (int *width, int *height);
-
-  extern void
-  BView_resize_to (void *view, int width, int height);
-
-  /* Functions for creating and freeing cursors.  */
-  extern void *
-  BCursor_create_default (void);
-
-  extern void *
-  BCursor_from_id (enum haiku_cursor cursor);
-
-  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 *cursor);
-
-  extern void
-  BView_set_view_cursor (void *view, void *cursor);
-
-  extern void
-  BWindow_Flush (void *window);
-
-  extern void *
-  BScrollBar_make_for_view (void *view, int horizontal_p,
-                           int x, int y, int x1, int y1,
-                           void *scroll_bar_ptr);
-
-  extern void
-  BScrollBar_delete (void *sb);
-
-  extern void
-  BView_move_frame (void *view, int x, int y, int x1, int y1);
-
-  extern void
-  BView_scroll_bar_update (void *sb, int portion, int whole, int position,
-                          int dragging, bool can_overscroll);
-
-  extern int
-  BScrollBar_default_size (int horizontal_p);
-
-  extern void
-  BView_invalidate (void *view);
-
-  extern void
-  BView_draw_lock (void *view, bool invalidate_region,
-                  int x, int y, int width, int height);
-
-  extern void
-  BView_invalidate_region (void *view, int x, int y, int width, int height);
-
-  extern void
-  BView_draw_unlock (void *view);
-
-  extern void
-  BWindow_center_on_screen (void *window);
-
-  extern void
-  BView_mouse_moved (void *view, int x, int y, uint32_t transit);
-
-  extern void
-  BView_mouse_down (void *view, int x, int y);
-
-  extern void
-  BView_mouse_up (void *view, int x, int y);
-
-  extern void
-  BBitmap_import_fringe_bitmap (void *bitmap, unsigned short *bits,
-                               int wd, int h);
-
-  extern void
-  BBitmap_import_mono_bits (void *bitmap, void *bits, int wd, int h);
-
-  extern void
-  haiku_font_pattern_free (struct haiku_font_pattern *pt);
-
-  extern struct haiku_font_pattern *
-  BFont_find (struct haiku_font_pattern *pt);
-
-  extern int
-  BFont_open_pattern (struct haiku_font_pattern *pat, void **font, float size);
-
-  extern void
-  BFont_populate_fixed_family (struct haiku_font_pattern *ptn);
-
-  extern void
-  BFont_populate_plain_family (struct haiku_font_pattern *ptn);
-
-  extern void
-  BView_publish_scroll_bar (void *view, int x, int y, int width, int height);
-
-  extern void
-  BView_forget_scroll_bar (void *view, int x, int y, int width, int height);
-
-  extern bool
-  BView_inside_scroll_bar (void *view, int x, int y);
-
-  extern void
-  BView_get_mouse (void *view, int *x, int *y);
-
-  extern void
-  BView_convert_to_screen (void *view, int *x, int *y);
-
-  extern void
-  BView_convert_from_screen (void *view, int *x, int *y);
-
-  extern void
-  BWindow_change_decoration (void *window, int decorate_p);
-
-  extern void
-  BWindow_set_tooltip_decoration (void *window);
-
-  extern void
-  BWindow_set_avoid_focus (void *window, int avoid_focus_p);
-
-  extern void
-  BView_emacs_delete (void *view);
-
-  extern uint32_t
-  haiku_current_workspace (void);
-
-  extern uint32_t
-  BWindow_workspaces (void *window);
-
-  extern void *
-  BPopUpMenu_new (const char *name);
-
-  extern void
-  BMenu_add_item (void *menu, const char *label, void *ptr, bool enabled_p,
-                 bool marked_p, bool mbar_p, void *mbw_ptr, const char *key,
-                 const char *help);
-
-  extern void
-  BMenu_add_separator (void *menu);
-
-  extern void *
-  BMenu_new_submenu (void *menu, const char *label, bool enabled_p);
-
-  extern void *
-  BMenu_new_menu_bar_submenu (void *menu, const char *label);
-
-  extern int
-  BMenu_count_items (void *menu);
-
-  extern void *
-  BMenu_item_at (void *menu, int idx);
-
-  extern void *
-  BMenu_run (void *menu, int x, int y,
-            void (*run_help_callback) (void *, void *),
-            void (*block_input_function) (void),
-            void (*unblock_input_function) (void),
-            struct timespec (*process_pending_signals_function) (void),
-            void *run_help_callback_data);
-
-  extern void
-  BPopUpMenu_delete (void *menu);
-
-  extern void *
-  BMenuBar_new (void *view);
-
-  extern void
-  BMenu_delete_all (void *menu);
-
-  extern void
-  BMenuBar_delete (void *menubar);
-
-  extern void
-  BMenu_item_set_label (void *item, const char *label);
-
-  extern void *
-  BMenu_item_get_menu (void *item);
-
-  extern void
-  BMenu_delete_from (void *menu, int start, int count);
-
-  extern void
-  haiku_ring_bell (void);
-
-  extern void *
-  BAlert_new (const char *text, enum haiku_alert_type type);
-
-  extern void *
-  BAlert_add_button (void *alert, const char *text);
-
-  extern void
-  BAlert_set_offset_spacing (void *alert);
-
-  extern int32
-  BAlert_go (void *alert,
-            void (*block_input_function) (void),
-            void (*unblock_input_function) (void),
-            void (*process_pending_signals_function) (void));
-
-  extern void
-  BButton_set_enabled (void *button, int enabled_p);
-
-  extern void
-  BView_set_tooltip (void *view, const char *tooltip);
-
-  extern void
-  BAlert_delete (void *alert);
-
-  extern void
-  BScreen_res (double *rrsx, double *rrsy);
-
-  extern void
-  EmacsWindow_parent_to (void *window, void *other_window);
-
-  extern void
-  EmacsWindow_unparent (void *window);
-
-  extern int
-  BFont_string_width (void *font, const char *utf8);
-
-  extern void
-  be_get_version_string (char *version, int len);
-
-  extern int
-  be_get_display_planes (void);
-
-  extern int
-  be_get_display_color_cells (void);
-
-  extern void
-  be_warp_pointer (int x, int y);
-
-  extern void
-  EmacsWindow_move_weak_child (void *window, void *child, int xoff, int yoff);
-
-  extern void
-  EmacsView_set_up_double_buffering (void *vw);
-
-  extern void
-  EmacsView_disable_double_buffering (void *vw);
-
-  extern void
-  EmacsView_flip_and_blit (void *vw);
-
-  extern int
-  EmacsView_double_buffered_p (void *vw);
-
-  extern char *
-  be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p,
-                       int dir_only_p, void *window, const char *save_text,
-                       const char *prompt,
-                       void (*block_input_function) (void),
-                       void (*unblock_input_function) (void),
-                       void (*maybe_quit_function) (void));
-
-  extern void
-  record_c_unwind_protect_from_cxx (void (*) (void *), void *);
-
-  extern specpdl_ref c_specpdl_idx_from_cxx (void);
-
-  extern void
-  c_unbind_to_nil_from_cxx (specpdl_ref idx);
-
-  extern void
-  BWindow_zoom (void *window);
-
-  extern void
-  EmacsWindow_make_fullscreen (void *window, int fullscreen_p);
-
-  extern void
-  EmacsWindow_unzoom (void *window);
+extern port_id port_application_to_emacs;
+extern port_id port_popup_menu_to_emacs;
+
+extern void haiku_io_init (void);
+extern void haiku_io_init_in_app_thread (void);
+
+extern void haiku_read_size (ssize_t *, bool);
+
+extern int haiku_read (enum haiku_event_type *, void *, ssize_t);
+extern int haiku_read_with_timeout (enum haiku_event_type *, void *, ssize_t,
+                                   bigtime_t, bool);
+extern int haiku_write (enum haiku_event_type, void *);
+extern int haiku_write_without_signal (enum haiku_event_type, void *, bool);
+
+extern void rgb_color_hsl (uint32_t, double *, double *, double *);
+extern void hsl_color_rgb (double, double, double, uint32_t *);
+
+extern void *BBitmap_new (int, int, int);
+extern void *BBitmap_data (void *);
+extern int BBitmap_convert (void *, void **);
+
+extern void BBitmap_free (void *);
+
+extern void BBitmap_dimensions (void *, int *, int *,  int *, int *,
+                               int32_t *, int *);
+extern void *BApplication_setup (void);
+extern void *BWindow_new (void **);
+extern void BWindow_quit (void *);
+
+extern void BWindow_set_offset (void *, int, int);
+extern void BWindow_iconify (void *);
+extern void BWindow_set_visible (void *, int);
+extern void BWindow_retitle (void *, const char *);
+extern void BWindow_resize (void *, int, int);
+extern void BWindow_activate (void *);
+extern void BWindow_center_on_screen (void *);
+extern void BWindow_change_decoration (void *, int);
+extern void BWindow_set_tooltip_decoration (void *);
+extern void BWindow_set_avoid_focus (void *, int);
+extern uint32_t BWindow_workspaces (void *);
+extern void BWindow_zoom (void *);
+extern void BWindow_set_min_size (void *, int, int);
+extern void BWindow_set_size_alignment (void *, int, int);
+extern void BWindow_sync (void *);
+extern void BWindow_send_behind (void *, void *);
+extern bool BWindow_is_active (void *);
+extern void BWindow_set_override_redirect (void *, bool);
+extern void BWindow_dimensions (void *, int *, int *);
+extern void BWindow_Flush (void *);
+
+extern void BFont_close (void *);
+extern void BFont_dat (void *, int *, int *, int *, int *,
+                      int *, int *, int *, int *, int *, int *);
+extern int BFont_have_char_p (void *, int32_t);
+extern int BFont_have_char_block (void *, int32_t, int32_t);
+extern void BFont_char_bounds (void *, const char *, int *, int *, int *);
+extern void BFont_nchar_bounds (void *, const char *, int *, int *,
+                               int *, int32_t);
+extern struct haiku_font_pattern *BFont_find (struct haiku_font_pattern *);
+
+
+extern void BView_StartClip (void *);
+extern void BView_EndClip (void *);
+extern void BView_SetHighColor (void *, uint32_t);
+extern void BView_SetHighColorForVisibleBell (void *, uint32_t);
+extern void BView_SetLowColor (void *, uint32_t);
+extern void BView_SetPenSize (void *, int);
+extern void BView_SetFont (void *, void *);
+extern void BView_MovePenTo (void *, int, int);
+extern void BView_DrawString (void *, const char *, ptrdiff_t);
+extern void BView_DrawChar (void *, char);
+extern void BView_FillRectangle (void *, int, int, int, int);
+extern void BView_FillRectangleAbs (void *, int, int, int, int);
+extern void BView_FillTriangle (void *, int, int, int, int, int, int);
+extern void BView_StrokeRectangle (void *, int, int, int, int);
+extern void BView_SetViewColor (void *, uint32_t);
+extern void BView_ClipToRect (void *, int, int, int, int);
+extern void BView_ClipToInverseRect (void *, int, int, int, int);
+extern void BView_StrokeLine (void *, int, int, int, int);
+extern void BView_CopyBits (void *, int, int, int, int, int, int, int, int);
+extern void BView_InvertRect (void *, int, int, int, int);
+extern void BView_DrawBitmap (void *, void *, int, int, int, int, int, int,
+                             int, int);
+extern void BView_DrawBitmapWithEraseOp (void *, void *, int, int, int, int);
+extern void BView_DrawMask (void *, void *, int, int, int, int,        int, 
int,
+                           int, int, uint32_t);
+
+extern void BView_resize_to (void *, int, int);
+extern void BView_set_view_cursor (void *, void *);
+extern void BView_move_frame (void *, int, int, int, int);
+extern void BView_scroll_bar_update (void *, int, int, int, int, bool);
+
+extern void *BBitmap_transform_bitmap (void *, void *, uint32_t, double,
+                                      int, int);
+
+extern void BScreen_px_dim (int *, int *);
+extern void BScreen_res (double *, double *);
+
+/* Functions for creating and freeing cursors.  */
+extern void *BCursor_create_default (void);
+extern void *BCursor_from_id (enum haiku_cursor);
+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 *BScrollBar_make_for_view (void *, int, int, int, int, int, void 
*);
+extern void BScrollBar_delete (void *);
+extern int BScrollBar_default_size (int);
+
+extern void BView_invalidate (void *);
+extern void BView_draw_lock (void *, bool, int, int, int, int);
+extern void BView_invalidate_region (void *, int, int, int, int);
+extern void BView_draw_unlock (void *);
+
+extern void BBitmap_import_fringe_bitmap (void *, unsigned short *, int, int);
+extern void BBitmap_import_mono_bits (void *, void *, int, int);
+
+extern void haiku_font_pattern_free (struct haiku_font_pattern *);
+
+extern int BFont_open_pattern (struct haiku_font_pattern *, void **, float);
+extern void BFont_populate_fixed_family (struct haiku_font_pattern *);
+extern void BFont_populate_plain_family (struct haiku_font_pattern *);
+
+extern void BView_publish_scroll_bar (void *, int, int, int, int);
+extern void BView_forget_scroll_bar (void *, int, int, int, int);
+extern bool BView_inside_scroll_bar (void *, int, int);
+extern void BView_get_mouse (void *, int *, int *);
+extern void BView_convert_to_screen (void *, int *, int *);
+extern void BView_convert_from_screen (void *, int *, int *);
+
+extern void BView_emacs_delete (void *);
+extern uint32_t haiku_current_workspace (void);
+
+extern void *BPopUpMenu_new (const char *);
+
+extern void BMenu_add_item (void *, const char *, void *, bool,
+                           bool, bool, void *, const char *,
+                           const char *);
+extern void BMenu_add_separator (void *);
+extern void *BMenu_new_submenu (void *, const char *, bool);
+extern void *BMenu_new_menu_bar_submenu (void *, const char *);
+extern int BMenu_count_items (void *);
+extern void *BMenu_item_at (void *, int);
+extern void *BMenu_run (void *, int, int, void (*) (void *, void *),
+                       void (*) (void), void (*) (void),
+                       struct timespec (*) (void), void *);
+extern void BPopUpMenu_delete (void *);
+extern void *BMenuBar_new (void *);
+extern void BMenu_delete_all (void *);
+extern void BMenuBar_delete (void *);
+extern void BMenu_item_set_label (void *, const char *);
+extern void *BMenu_item_get_menu (void *);
+extern void BMenu_delete_from (void *, int, int);
+
+extern void haiku_ring_bell (void);
+
+extern void *BAlert_new (const char *, enum haiku_alert_type);
+extern void *BAlert_add_button (void *, const char *);
+extern void BAlert_set_offset_spacing (void *);
+extern int32 BAlert_go (void *, void (*) (void), void (*) (void),
+                       void (*) (void));
+extern void BButton_set_enabled (void *, int);
+extern void BView_set_tooltip (void *, const char *);
+extern void BView_show_tooltip (void *);
+extern void BView_set_and_show_sticky_tooltip (void *, const char *,
+                                              int, int);
+
+extern void BAlert_delete (void *);
+
+extern void EmacsWindow_parent_to (void *, void *);
+extern void EmacsWindow_unparent (void *);
+extern void EmacsWindow_move_weak_child (void *, void *, int, int);
+extern void EmacsWindow_make_fullscreen (void *, int);
+extern void EmacsWindow_unzoom (void *);
+extern void EmacsWindow_signal_menu_update_complete (void *);
+
+extern void be_get_version_string (char *, int);
+extern int be_get_display_planes (void);
+extern int be_get_display_color_cells (void);
+extern void be_warp_pointer (int, int);
+
+extern void EmacsView_set_up_double_buffering (void *);
+extern void EmacsView_disable_double_buffering (void *);
+extern void EmacsView_flip_and_blit (void *);
+extern int EmacsView_double_buffered_p (void *);
+
+extern char *be_popup_file_dialog (int, const char *, int,
+                                  int, void *, const char *,
+                                  const char *, void (*) (void),
+                                  void (*) (void), void (*) (void));
+
+extern void record_c_unwind_protect_from_cxx (void (*) (void *), void *);
+extern specpdl_ref c_specpdl_idx_from_cxx (void);
+extern void c_unbind_to_nil_from_cxx (specpdl_ref);
 
 #ifdef HAVE_NATIVE_IMAGE_API
-  extern int
-  be_can_translate_type_to_bitmap_p (const char *mime);
-
-  extern void *
-  be_translate_bitmap_from_file_name (const char *filename);
-
-  extern void *
-  be_translate_bitmap_from_memory (const void *buf, size_t bytes);
+extern int be_can_translate_type_to_bitmap_p (const char *);
+extern void *be_translate_bitmap_from_file_name (const char *);
+extern void *be_translate_bitmap_from_memory (const void *, size_t);
 #endif
 
-  extern bool
-  BMenuBar_start_tracking (void *mbar);
-
-  extern size_t
-  BBitmap_bytes_length (void *bitmap);
-
-  extern void
-  BView_show_tooltip (void *view);
+extern bool BMenuBar_start_tracking (void *);
+extern size_t BBitmap_bytes_length (void *);
 
 #ifdef USE_BE_CAIRO
-  extern cairo_t *
-  EmacsView_cairo_context (void *view);
-
-  extern void
-  BView_cr_dump_clipping (void *view, cairo_t *ctx);
-
-  extern void
-  EmacsWindow_begin_cr_critical_section (void *window);
-
-  extern void
-  EmacsWindow_end_cr_critical_section (void *window);
+extern cairo_t *EmacsView_cairo_context (void *);
+extern void BView_cr_dump_clipping (void *, cairo_t *);
+extern void EmacsWindow_begin_cr_critical_section (void *);
+extern void EmacsWindow_end_cr_critical_section (void *);
 #endif
 
-  extern void
-  BView_set_and_show_sticky_tooltip (void *view, const char *tooltip,
-                                    int x, int y);
-
-  extern void
-  BMenu_add_title (void *menu, const char *text);
-
-  extern int
-  be_plain_font_height (void);
-
-  extern int
-  be_string_width_with_plain_font (const char *str);
-
-  extern int
-  be_get_display_screens (void);
-
-  extern void
-  BWindow_set_min_size (void *window, int width, int height);
-
-  extern void
-  BWindow_set_size_alignment (void *window, int align_width, int align_height);
+extern void BMenu_add_title (void *, const char *);
 
-  extern void
-  BWindow_sync (void *window);
+extern int be_plain_font_height (void);
+extern int be_string_width_with_plain_font (const char *);
+extern int be_get_display_screens (void);
+extern bool be_use_subpixel_antialiasing (void);
+extern const char *be_find_setting (const char *);
+extern haiku_font_family_or_style *be_list_font_families (size_t *);
 
-  extern void
-  BWindow_send_behind (void *window, void *other_window);
+extern void BMessage_delete (void *);
 
-  extern bool
-  BWindow_is_active (void *window);
-
-  extern bool
-  be_use_subpixel_antialiasing (void);
-
-  extern void
-  BWindow_set_override_redirect (void *window, bool override_redirect_p);
-
-  extern const char *
-  be_find_setting (const char *name);
-
-  extern void
-  EmacsWindow_signal_menu_update_complete (void *window);
-
-  extern haiku_font_family_or_style *
-  be_list_font_families (size_t *length);
-
-  extern void
-  BWindow_dimensions (void *window, int *width, int *height);
-
-  extern void
-  BMessage_delete (void *message);
-
-  extern bool
-  be_drag_message (void *view, void *message, bool allow_same_view,
-                  void (*block_input_function) (void),
-                  void (*unblock_input_function) (void),
-                  void (*process_pending_signals_function) (void),
-                  bool (*should_quit_function) (void));
-
-  extern bool
-  be_drag_and_drop_in_progress (void);
+extern bool be_drag_message (void *, void *, bool, void (*) (void),
+                            void (*) (void), void (*) (void),
+                            bool (*) (void));
+extern bool be_drag_and_drop_in_progress (void);
 
 #ifdef __cplusplus
-  extern void *
-  find_appropriate_view_for_draw (void *vw);
+extern void *find_appropriate_view_for_draw (void *vw);
 }
 
-extern _Noreturn void
-gui_abort (const char *msg);
+extern _Noreturn void gui_abort (const char *msg);
 #endif /* _cplusplus */
 
 /* Borrowed from X.Org keysymdef.h */
@@ -1001,3 +677,7 @@ gui_abort (const char *msg);
 #define XK_F1                            0xffbe
 
 #endif /* _HAIKU_SUPPORT_H_ */
+
+// Local Variables:
+// eval: (setf (alist-get 'inextern-lang c-offsets-alist) 0)
+// End:
diff --git a/src/haikufns.c b/src/haikufns.c
index b282cf292a..874ebaaf91 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -64,11 +64,8 @@ static Lisp_Object tip_last_frame;
 /* PARMS argument of last `x-show-tip' call.  */
 static Lisp_Object tip_last_parms;
 
-static void
-haiku_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval);
-static void
-haiku_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name);
-
+static void haiku_explicitly_set_name (struct frame *, Lisp_Object, 
Lisp_Object);
+static void haiku_set_title (struct frame *, Lisp_Object, Lisp_Object);
 static ptrdiff_t image_cache_refcount;
 
 static Lisp_Object
@@ -255,7 +252,8 @@ int
 haiku_get_color (const char *name, Emacs_Color *color)
 {
   unsigned short r16, g16, b16;
-  Lisp_Object tem;
+  Lisp_Object tem, col;
+  int32 clr;
 
   if (parse_color_spec (name, &r16, &g16, &b16))
     {
@@ -272,10 +270,11 @@ haiku_get_color (const char *name, Emacs_Color *color)
       tem = x_display_list->color_map;
       for (; CONSP (tem); tem = XCDR (tem))
        {
-         Lisp_Object col = XCAR (tem);
+         col = XCAR (tem);
+
          if (CONSP (col) && !xstrcasecmp (SSDATA (XCAR (col)), name))
            {
-             int32_t clr = XFIXNUM (XCDR (col));
+             clr = XFIXNUM (XCDR (col));
              color->pixel = clr;
              color->red = RED_FROM_ULONG (clr) * 257;
              color->green = GREEN_FROM_ULONG (clr) * 257;
@@ -301,10 +300,10 @@ haiku_display_info_for_name (Lisp_Object name)
       if (!x_display_list)
        return x_display_list;
 
-      error ("Be windowing not initialized");
+      error ("Haiku windowing not initialized");
     }
 
-  error ("Be displays can only be named \"be\"");
+  error ("Haiku displays can only be named \"be\"");
 }
 
 static struct haiku_display_info *
@@ -321,14 +320,14 @@ check_haiku_display_info (Lisp_Object object)
       else if (x_display_list)
        dpyinfo = x_display_list;
       else
-       error ("Be windowing not present");
+       error ("Haiku windowing not present");
     }
   else if (TERMINALP (object))
     {
       struct terminal *t = decode_live_terminal (object);
 
       if (t->type != output_haiku)
-       error ("Terminal %d is not a Be display", t->id);
+       error ("Terminal %d is not a Haiku display", t->id);
 
       dpyinfo = t->display_info.haiku;
     }
@@ -2412,7 +2411,7 @@ Optional arg SAVE_TEXT, if non-nil, specifies some text 
to show in the entry fie
    Lisp_Object dir_only_p, Lisp_Object save_text)
 {
   if (!x_display_list)
-    error ("Be windowing not initialized");
+    error ("Haiku windowing not initialized");
 
   if (!NILP (dir))
     CHECK_STRING (dir);
@@ -2513,13 +2512,15 @@ DEFUN ("x-display-save-under", Fx_display_save_under,
        doc: /* SKIP: real doc in xfns.c.  */)
   (Lisp_Object terminal)
 {
+  struct frame *f;
   check_haiku_display_info (terminal);
 
   if (FRAMEP (terminal))
     {
-      struct frame *f = decode_window_system_frame (terminal);
-      return FRAME_HAIKU_VIEW (f) && EmacsView_double_buffered_p 
(FRAME_HAIKU_VIEW (f)) ?
-       Qt : Qnil;
+      f = decode_window_system_frame (terminal);
+      return ((FRAME_HAIKU_VIEW (f)
+              && EmacsView_double_buffered_p (FRAME_HAIKU_VIEW (f)))
+             ? Qt : Qnil);
     }
 
   return Qnil;
@@ -2536,11 +2537,8 @@ frames overlap, FRAME1 (partially) obscures FRAME2.
 Some window managers may refuse to restack windows.  */)
      (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object above)
 {
-  struct frame *f1 = decode_live_frame (frame1);
-  struct frame *f2 = decode_live_frame (frame2);
-
-  check_window_system (f1);
-  check_window_system (f2);
+  struct frame *f1 = decode_window_system_frame (frame1);
+  struct frame *f2 = decode_window_system_frame (frame2);
 
   block_input ();
 
diff --git a/src/haikuselect.h b/src/haikuselect.h
index bac9663c70..a99721dd22 100644
--- a/src/haikuselect.h
+++ b/src/haikuselect.h
@@ -36,86 +36,53 @@ enum haiku_clipboard
 #include <stdio.h>
 extern "C"
 {
-  extern void init_haiku_select (void);
+extern void init_haiku_select (void);
 #endif
-
-  /* Whether or not the selection was recently changed.  */
-  extern int selection_state_flag;
-
-  /* Find a string with the MIME type TYPE in the system clipboard.  */
-  extern char *
-  BClipboard_find_system_data (const char *type, ssize_t *len);
-
-  /* Ditto, but for the primary selection and not clipboard.  */
-  extern char *
-  BClipboard_find_primary_selection_data (const char *type, ssize_t *len);
-
-  /* Ditto, this time for the secondary selection.  */
-  extern char *
-  BClipboard_find_secondary_selection_data (const char *type, ssize_t *len);
-
-  extern void
-  BClipboard_set_system_data (const char *type, const char *data, ssize_t len,
-                             bool clear);
-
-  extern void
-  BClipboard_set_primary_selection_data (const char *type, const char *data,
-                                        ssize_t len, bool clear);
-
-  extern void
-  BClipboard_set_secondary_selection_data (const char *type, const char *data,
-                                          ssize_t len, bool clear);
-
-  extern void
-  BClipboard_system_targets (char **buf, int len);
-
-  extern void
-  BClipboard_primary_targets (char **buf, int len);
-
-  extern void
-  BClipboard_secondary_targets (char **buf, int len);
-
-  extern bool
-  BClipboard_owns_clipboard (void);
-
-  extern bool
-  BClipboard_owns_primary (void);
-
-  extern bool BClipboard_owns_secondary (void);
-
-  /* Free the returned data.  */
-  extern void BClipboard_free_data (void *ptr);
-
-  extern int be_enum_message (void *message, int32 *tc, int32 index,
-                             int32 *count, const char **name_return);
-  extern int be_get_message_data (void *message, const char *name,
-                                 int32 type_code, int32 index,
-                                 const void **buf_return,
-                                 ssize_t *size_return);
-  extern int be_get_refs_data (void *message, const char *name,
-                              int32 index, char **path_buffer);
-  extern int be_get_point_data (void *message, const char *name,
-                               int32 index, float *x, float *y);
-  extern uint32 be_get_message_type (void *message);
-  extern void be_set_message_type (void *message, uint32 what);
-  extern void *be_get_message_message (void *message, const char *name,
-                                      int32 index);
-  extern void *be_create_simple_message (void);
-  extern int be_add_message_data (void *message, const char *name,
-                                 int32 type_code, const void *buf,
-                                 ssize_t buf_size);
-  extern int be_add_refs_data (void *message, const char *name,
-                              const char *filename);
-  extern int be_add_point_data (void *message, const char *name,
-                               float x, float y);
-  extern int be_add_message_message (void *message, const char *name,
-                                    void *data);
-  extern int be_lock_clipboard_message (enum haiku_clipboard clipboard,
-                                       void **message_return,
-                                       bool clear);
-  extern void be_unlock_clipboard (enum haiku_clipboard clipboard,
-                                  bool discard);
+/* Whether or not the selection was recently changed.  */
+extern int selection_state_flag;
+
+/* Find a string with the MIME type TYPE in the system clipboard.  */
+extern char *BClipboard_find_system_data (const char *, ssize_t *);
+extern char *BClipboard_find_primary_selection_data (const char *, ssize_t *);
+extern char *BClipboard_find_secondary_selection_data (const char *, ssize_t 
*);
+
+extern void BClipboard_set_system_data (const char *, const char *, ssize_t, 
bool);
+extern void BClipboard_set_primary_selection_data (const char *, const char *,
+                                                  ssize_t, bool);
+extern void BClipboard_set_secondary_selection_data (const char *, const char 
*,
+                                                    ssize_t, bool);
+
+extern void BClipboard_system_targets (char **, int);
+extern void BClipboard_primary_targets (char **, int);
+extern void BClipboard_secondary_targets (char **, int);
+
+extern bool BClipboard_owns_clipboard (void);
+extern bool BClipboard_owns_primary (void);
+extern bool BClipboard_owns_secondary (void);
+
+/* Free the returned data.  */
+extern void BClipboard_free_data (void *);
+
+extern int be_enum_message (void *, int32 *, int32, int32 *, const char **);
+extern int be_get_message_data (void *, const char *, int32, int32,
+                               const void **, ssize_t *);
+extern int be_get_refs_data (void *, const char *, int32, char **);
+extern int be_get_point_data (void *, const char *, int32, float *, float *);
+extern uint32 be_get_message_type (void *);
+extern void be_set_message_type (void *, uint32);
+extern void *be_get_message_message (void *, const char *, int32);
+extern void *be_create_simple_message (void);
+extern int be_add_message_data (void *, const char *, int32, const void *, 
ssize_t);
+extern int be_add_refs_data (void *, const char *, const char *);
+extern int be_add_point_data (void *, const char *, float, float);
+extern int be_add_message_message (void *, const char *, void *);
+extern int be_lock_clipboard_message (enum haiku_clipboard, void **, bool);
+extern void be_unlock_clipboard (enum haiku_clipboard, bool);
 #ifdef __cplusplus
 };
 #endif
 #endif /* _HAIKU_SELECT_H_ */
+
+// Local Variables:
+// eval: (setf (alist-get 'inextern-lang c-offsets-alist) 0)
+// End:
diff --git a/src/haikuterm.c b/src/haikuterm.c
index 6137e985b4..74a34fdb4b 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -2769,23 +2769,26 @@ flush_dirty_back_buffers (void)
 static int
 haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 {
-  block_input ();
-  int message_count = 0;
-  static void *buf = NULL;
+  int message_count;
+  static void *buf;
   ssize_t b_size;
   struct unhandled_event *unhandled_events = NULL;
-  int button_or_motion_p;
-  int need_flush = 0;
-  int do_help = 0;
+  int button_or_motion_p, need_flush, do_help;
+  enum haiku_event_type type;
+  struct input_event inev, inev2;
 
+  message_count = 0;
+  need_flush = 0;
+  button_or_motion_p = 0;
+  do_help = 0;
+  buf = NULL;
+
+  block_input ();
   if (!buf)
     buf = xmalloc (200);
   haiku_read_size (&b_size, false);
   while (b_size >= 0)
     {
-      enum haiku_event_type type;
-      struct input_event inev, inev2;
-
       if (b_size > 200)
        emacs_abort ();
 
@@ -2797,7 +2800,6 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
       inev2.arg = Qnil;
 
       button_or_motion_p = 0;
-
       haiku_read (&type, buf, b_size);
 
       switch (type)
@@ -2864,7 +2866,6 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
              continue;
 
            expose_frame (f, b->x, b->y, b->width, b->height);
-
            haiku_clear_under_internal_border (f);
            break;
          }
@@ -2874,6 +2875,9 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
            Mouse_HLInfo *hlinfo = &x_display_list->mouse_highlight;
            struct frame *f = haiku_window_to_frame (b->window);
 
+           if (!f)
+             continue;
+
            /* If mouse-highlight is an integer, input clears out
               mouse highlighting.  */
            if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight)
@@ -2886,9 +2890,6 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
                need_flush = 1;
              }
 
-           if (!f)
-             continue;
-
            inev.code = b->keysym ? b->keysym : b->multibyte_char;
 
            if (b->keysym)
@@ -2917,8 +2918,8 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
            if (!f)
              continue;
 
-           if ((x_display_list->focus_event_frame != f && b->activated_p) ||
-               (x_display_list->focus_event_frame == f && !b->activated_p))
+           if ((x_display_list->focus_event_frame != f && b->activated_p)
+               || (x_display_list->focus_event_frame == f && !b->activated_p))
              {
                haiku_new_focus_frame (b->activated_p ? f : NULL);
                if (b->activated_p)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]