1 /* Haiku window system support 2 Copyright (C) 2021 Free Software Foundation, Inc. 3 4 This file is part of GNU Emacs. 5 6 GNU Emacs is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or (at 9 your option) any later version. 10 11 GNU Emacs is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ 18 19 #ifndef _HAIKU_TERM_H_ 20 #define _HAIKU_TERM_H_ 21 22 #include <pthread.h> 23 24 #ifdef USE_BE_CAIRO 25 #include <cairo.h> 26 #endif 27 28 #include "haikugui.h" 29 #include "frame.h" 30 #include "character.h" 31 #include "dispextern.h" 32 #include "font.h" 33 #include "systime.h" 34 35 #define C_FRAME struct frame * 36 #define C_FONT struct font * 37 #define C_TERMINAL struct terminal * 38 39 #define HAVE_CHAR_CACHE_MAX 65535 40 41 extern int popup_activated_p; 42 43 extern void be_app_quit (void); 44 45 struct haikufont_info 46 { 47 struct font font; 48 haiku be_font; 49 struct font_metrics **metrics; 50 short metrics_nrows; 51 52 unsigned short **glyphs; 53 }; 54 55 struct haiku_bitmap_record 56 { 57 haiku img; 58 char *file; 59 int refcount; 60 int height, width, depth; 61 }; 62 63 struct haiku_display_info 64 { 65 /* Chain of all haiku_display_info structures. */ 66 struct haiku_display_info *next; 67 C_TERMINAL terminal; 68 69 Lisp_Object name_list_element; 70 Lisp_Object color_map; 71 72 int n_fonts; 73 74 int smallest_char_width; 75 int smallest_font_height; 76 77 struct frame *focused_frame; 78 struct frame *focus_event_frame; 79 struct frame *last_mouse_glyph_frame; 80 81 struct haiku_bitmap_record *bitmaps; 82 ptrdiff_t bitmaps_size; 83 ptrdiff_t bitmaps_last; 84 85 int grabbed; 86 int n_planes; 87 int color_p; 88 89 Window root_window; 90 Lisp_Object rdb; 91 92 Emacs_Cursor vertical_scroll_bar_cursor; 93 Emacs_Cursor horizontal_scroll_bar_cursor; 94 95 Mouse_HLInfo mouse_highlight; 96 97 C_FRAME highlight_frame; 98 C_FRAME last_mouse_frame; 99 C_FRAME last_mouse_motion_frame; 100 101 int last_mouse_motion_x; 102 int last_mouse_motion_y; 103 104 struct haiku_rect last_mouse_glyph; 105 106 void *last_mouse_scroll_bar; 107 108 haiku display; 109 110 double resx, resy; 111 112 Time last_mouse_movement_time; 113 }; 114 115 struct haiku_output 116 { 117 Emacs_Cursor text_cursor; 118 Emacs_Cursor nontext_cursor; 119 Emacs_Cursor modeline_cursor; 120 Emacs_Cursor hand_cursor; 121 Emacs_Cursor hourglass_cursor; 122 Emacs_Cursor horizontal_drag_cursor; 123 Emacs_Cursor vertical_drag_cursor; 124 Emacs_Cursor left_edge_cursor; 125 Emacs_Cursor top_left_corner_cursor; 126 Emacs_Cursor top_edge_cursor; 127 Emacs_Cursor top_right_corner_cursor; 128 Emacs_Cursor right_edge_cursor; 129 Emacs_Cursor bottom_right_corner_cursor; 130 Emacs_Cursor bottom_edge_cursor; 131 Emacs_Cursor bottom_left_corner_cursor; 132 Emacs_Cursor no_cursor; 133 134 Emacs_Cursor current_cursor; 135 136 struct haiku_display_info *display_info; 137 138 int baseline_offset; 139 int fontset; 140 141 Emacs_Color cursor_color; 142 143 Window window_desc, parent_desc; 144 char explicit_parent; 145 146 int titlebar_height; 147 int toolbar_height; 148 149 haiku window; 150 haiku view; 151 haiku menubar; 152 153 int menu_up_to_date_p; 154 int zoomed_p; 155 156 int pending_zoom_x; 157 int pending_zoom_y; 158 int pending_zoom_width; 159 int pending_zoom_height; 160 161 int menu_bar_open_p; 162 163 C_FONT font; 164 165 int hourglass_p; 166 uint32_t cursor_fg; 167 bool dirty_p; 168 169 /* The pending position we're waiting for. */ 170 int pending_top, pending_left; 171 }; 172 173 struct x_output 174 { 175 /* Unused, makes term.c happy. */ 176 }; 177 178 extern struct haiku_display_info *x_display_list; 179 extern struct font_driver const haikufont_driver; 180 181 struct scroll_bar 182 { 183 /* These fields are shared by all vectors. */ 184 union vectorlike_header header; 185 186 /* The window we're a scroll bar for. */ 187 Lisp_Object window; 188 189 /* The next and previous in the chain of scroll bars in this frame. */ 190 Lisp_Object next, prev; 191 192 /* Fields after 'prev' are not traced by the GC. */ 193 194 /* The position and size of the scroll bar in pixels, relative to the 195 frame. */ 196 int top, left, width, height; 197 198 /* The actual scrollbar. */ 199 void *scroll_bar; 200 201 /* Non-nil if the scroll bar handle is currently being dragged by 202 the user. */ 203 int dragging; 204 205 /* The update position if we are waiting for a scrollbar update, or 206 -1. */ 207 int update; 208 209 /* The last known position of this scrollbar. */ 210 int position; 211 212 /* The total number of units inside this scrollbar. */ 213 int total; 214 215 /* True if the scroll bar is horizontal. */ 216 bool horizontal; 217 }; 218 219 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) 220 221 #define FRAME_DIRTY_P(f) (FRAME_OUTPUT_DATA (f)->dirty_p) 222 #define MAKE_FRAME_DIRTY(f) (FRAME_DIRTY_P (f) = 1) 223 #define FRAME_OUTPUT_DATA(f) ((f)->output_data.haiku) 224 #define FRAME_HAIKU_WINDOW(f) (FRAME_OUTPUT_DATA (f)->window) 225 #define FRAME_HAIKU_VIEW(f) ((MAKE_FRAME_DIRTY (f)), FRAME_OUTPUT_DATA (f)->view) 226 #define FRAME_HAIKU_MENU_BAR(f) (FRAME_OUTPUT_DATA (f)->menubar) 227 #define FRAME_DISPLAY_INFO(f) (FRAME_OUTPUT_DATA (f)->display_info) 228 #define FRAME_FONT(f) (FRAME_OUTPUT_DATA (f)->font) 229 #define FRAME_FONTSET(f) (FRAME_OUTPUT_DATA (f)->fontset) 230 #define FRAME_NATIVE_WINDOW(f) (FRAME_OUTPUT_DATA (f)->window) 231 #define FRAME_BASELINE_OFFSET(f) (FRAME_OUTPUT_DATA (f)->baseline_offset) 232 #define FRAME_CURSOR_COLOR(f) (FRAME_OUTPUT_DATA (f)->cursor_color) 233 234 #ifdef USE_BE_CAIRO 235 #define FRAME_CR_SURFACE(f) \ 236 (FRAME_HAIKU_VIEW (f) ? EmacsView_cairo_surface (FRAME_HAIKU_VIEW (f)) : 0); 237 #endif 238 239 extern void syms_of_haikuterm (void); 240 extern void syms_of_haikufns (void); 241 extern void syms_of_haikumenu (void); 242 extern void syms_of_haikufont (void); 243 extern void syms_of_haikuselect (void); 244 extern void init_haiku_select (void); 245 246 extern void haiku_iconify_frame (struct frame *); 247 extern void haiku_visualize_frame (struct frame *); 248 extern void haiku_unvisualize_frame (struct frame *); 249 extern void haiku_set_offset (struct frame *, int, int, int); 250 extern void haiku_set_frame_visible_invisible (struct frame *, bool); 251 extern void haiku_free_frame_resources (struct frame *f); 252 extern void haiku_scroll_bar_remove (struct scroll_bar *bar); 253 extern void haiku_clear_under_internal_border (struct frame *f); 254 extern void haiku_set_name (struct frame *f, Lisp_Object name, bool explicit_p); 255 256 extern struct haiku_display_info *haiku_term_init (void); 257 258 extern void mark_haiku_display (void); 259 260 extern int haiku_get_color (const char *name, Emacs_Color *color); 261 extern void haiku_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval); 262 extern void haiku_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval); 263 extern void haiku_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval); 264 extern void haiku_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval); 265 extern void haiku_change_tab_bar_height (struct frame *f, int height); 266 extern void haiku_change_tool_bar_height (struct frame *f, int height); 267 268 extern void haiku_query_color (uint32_t col, Emacs_Color *color); 269 270 extern unsigned long haiku_get_pixel (haiku bitmap, int x, int y); 271 extern void haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel); 272 273 extern Lisp_Object haiku_menu_show (struct frame *f, int x, int y, int menu_flags, 274 Lisp_Object title, const char **error_name); 275 extern Lisp_Object haiku_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents); 276 277 extern void initialize_frame_menubar (struct frame *f); 278 279 extern void run_menu_bar_help_event (struct frame *f, int mb_idx); 280 extern void put_xrm_resource (Lisp_Object name, Lisp_Object val); 281 282 #ifdef HAVE_NATIVE_IMAGE_API 283 extern bool haiku_can_use_native_image_api (Lisp_Object type); 284 extern int haiku_load_image (struct frame *f, struct image *img, 285 Lisp_Object spec_file, Lisp_Object spec_data); 286 extern void syms_of_haikuimage (void); 287 #endif 288 289 #ifdef USE_BE_CAIRO 290 extern cairo_t * 291 haiku_begin_cr_clip (struct frame *f, struct glyph_string *s); 292 293 extern void 294 haiku_end_cr_clip (cairo_t *cr); 295 #endif 296 #endif /* _HAIKU_TERM_H_ */ 297