diff options
Diffstat (limited to 'src/androidfns.c')
| -rw-r--r-- | src/androidfns.c | 1779 |
1 files changed, 1779 insertions, 0 deletions
diff --git a/src/androidfns.c b/src/androidfns.c new file mode 100644 index 00000000000..e9e1ae3d52e --- /dev/null +++ b/src/androidfns.c | |||
| @@ -0,0 +1,1779 @@ | |||
| 1 | /* Communication module for Android terminals. | ||
| 2 | |||
| 3 | Copyright (C) 2023 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or (at | ||
| 10 | your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #include <config.h> | ||
| 21 | #include <math.h> | ||
| 22 | |||
| 23 | #include "lisp.h" | ||
| 24 | #include "androidterm.h" | ||
| 25 | #include "blockinput.h" | ||
| 26 | #include "keyboard.h" | ||
| 27 | |||
| 28 | #ifndef ANDROID_STUBIFY | ||
| 29 | |||
| 30 | /* Some kind of reference count for the image cache. */ | ||
| 31 | static ptrdiff_t image_cache_refcount; | ||
| 32 | |||
| 33 | #endif | ||
| 34 | |||
| 35 | static struct android_display_info * | ||
| 36 | android_display_info_for_name (Lisp_Object name) | ||
| 37 | { | ||
| 38 | struct android_display_info *dpyinfo; | ||
| 39 | |||
| 40 | CHECK_STRING (name); | ||
| 41 | |||
| 42 | for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) | ||
| 43 | { | ||
| 44 | if (!NILP (Fstring_equal (XCAR (dpyinfo->name_list_element), | ||
| 45 | name))) | ||
| 46 | return dpyinfo; | ||
| 47 | } | ||
| 48 | |||
| 49 | error ("Cannot connect to Android if it was not initialized" | ||
| 50 | " at startup"); | ||
| 51 | } | ||
| 52 | |||
| 53 | static struct android_display_info * | ||
| 54 | check_android_display_info (Lisp_Object object) | ||
| 55 | { | ||
| 56 | struct android_display_info *dpyinfo; | ||
| 57 | struct frame *sf, *f; | ||
| 58 | struct terminal *t; | ||
| 59 | |||
| 60 | if (NILP (object)) | ||
| 61 | { | ||
| 62 | sf = XFRAME (selected_frame); | ||
| 63 | |||
| 64 | if (FRAME_ANDROID_P (sf) && FRAME_LIVE_P (sf)) | ||
| 65 | dpyinfo = FRAME_DISPLAY_INFO (sf); | ||
| 66 | else if (x_display_list) | ||
| 67 | dpyinfo = x_display_list; | ||
| 68 | else | ||
| 69 | error ("Android windows are not in use or not initialized"); | ||
| 70 | } | ||
| 71 | else if (TERMINALP (object)) | ||
| 72 | { | ||
| 73 | t = decode_live_terminal (object); | ||
| 74 | |||
| 75 | if (t->type != output_android) | ||
| 76 | error ("Terminal %d is not an Android display", t->id); | ||
| 77 | |||
| 78 | dpyinfo = t->display_info.android; | ||
| 79 | } | ||
| 80 | else if (STRINGP (object)) | ||
| 81 | dpyinfo = android_display_info_for_name (object); | ||
| 82 | else | ||
| 83 | { | ||
| 84 | f = decode_window_system_frame (object); | ||
| 85 | dpyinfo = FRAME_DISPLAY_INFO (f); | ||
| 86 | } | ||
| 87 | |||
| 88 | return dpyinfo; | ||
| 89 | } | ||
| 90 | |||
| 91 | Display_Info * | ||
| 92 | check_x_display_info (Lisp_Object object) | ||
| 93 | { | ||
| 94 | return check_android_display_info (object); | ||
| 95 | } | ||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | #ifndef ANDROID_STUBIFY | ||
| 100 | |||
| 101 | void | ||
| 102 | gamma_correct (struct frame *f, Emacs_Color *color) | ||
| 103 | { | ||
| 104 | if (f->gamma) | ||
| 105 | { | ||
| 106 | color->red = pow (color->red / 65535.0, f->gamma) * 65535.0 + 0.5; | ||
| 107 | color->green = pow (color->green / 65535.0, f->gamma) * 65535.0 + 0.5; | ||
| 108 | color->blue = pow (color->blue / 65535.0, f->gamma) * 65535.0 + 0.5; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | /* Decide if color named COLOR_NAME is valid for use on frame F. If | ||
| 113 | so, return the RGB values in COLOR. If ALLOC_P, allocate the | ||
| 114 | color. Value is false if COLOR_NAME is invalid, or no color could | ||
| 115 | be allocated. MAKE_INDEX is some mysterious argument used on | ||
| 116 | NS. */ | ||
| 117 | |||
| 118 | bool | ||
| 119 | android_defined_color (struct frame *f, const char *color_name, | ||
| 120 | Emacs_Color *color, bool alloc_p, | ||
| 121 | bool make_index) | ||
| 122 | { | ||
| 123 | bool success_p; | ||
| 124 | |||
| 125 | success_p = false; | ||
| 126 | |||
| 127 | block_input (); | ||
| 128 | success_p = android_parse_color (f, color_name, color); | ||
| 129 | if (success_p && alloc_p) | ||
| 130 | success_p = android_alloc_nearest_color (f, color); | ||
| 131 | unblock_input (); | ||
| 132 | |||
| 133 | return success_p; | ||
| 134 | } | ||
| 135 | |||
| 136 | /* Return the pixel color value for color COLOR_NAME on frame F. If F | ||
| 137 | is a monochrome frame, return MONO_COLOR regardless of what ARG | ||
| 138 | says. Signal an error if color can't be allocated. */ | ||
| 139 | |||
| 140 | static unsigned long | ||
| 141 | android_decode_color (struct frame *f, Lisp_Object color_name, int mono_color) | ||
| 142 | { | ||
| 143 | Emacs_Color cdef; | ||
| 144 | |||
| 145 | CHECK_STRING (color_name); | ||
| 146 | |||
| 147 | if (android_defined_color (f, SSDATA (color_name), &cdef, | ||
| 148 | true, false)) | ||
| 149 | return cdef.pixel; | ||
| 150 | |||
| 151 | signal_error ("Undefined color", color_name); | ||
| 152 | } | ||
| 153 | |||
| 154 | void | ||
| 155 | android_implicitly_set_name (struct frame *f, Lisp_Object arg, | ||
| 156 | Lisp_Object oldval) | ||
| 157 | { | ||
| 158 | |||
| 159 | } | ||
| 160 | |||
| 161 | void | ||
| 162 | android_explicitly_set_name (struct frame *f, Lisp_Object arg, | ||
| 163 | Lisp_Object oldval) | ||
| 164 | { | ||
| 165 | |||
| 166 | } | ||
| 167 | |||
| 168 | /* Set the number of lines used for the tool bar of frame F to VALUE. | ||
| 169 | VALUE not an integer, or < 0 means set the lines to zero. OLDVAL | ||
| 170 | is the old number of tool bar lines. This function changes the | ||
| 171 | height of all windows on frame F to match the new tool bar height. | ||
| 172 | The frame's height doesn't change. */ | ||
| 173 | |||
| 174 | static void | ||
| 175 | android_set_tool_bar_lines (struct frame *f, Lisp_Object value, | ||
| 176 | Lisp_Object oldval) | ||
| 177 | { | ||
| 178 | int nlines; | ||
| 179 | |||
| 180 | /* Treat tool bars like menu bars. */ | ||
| 181 | if (FRAME_MINIBUF_ONLY_P (f)) | ||
| 182 | return; | ||
| 183 | |||
| 184 | /* Use VALUE only if an int >= 0. */ | ||
| 185 | if (RANGED_FIXNUMP (0, value, INT_MAX)) | ||
| 186 | nlines = XFIXNAT (value); | ||
| 187 | else | ||
| 188 | nlines = 0; | ||
| 189 | |||
| 190 | android_change_tool_bar_height (f, nlines * FRAME_LINE_HEIGHT (f)); | ||
| 191 | } | ||
| 192 | |||
| 193 | void | ||
| 194 | android_change_tool_bar_height (struct frame *f, int height) | ||
| 195 | { | ||
| 196 | int unit = FRAME_LINE_HEIGHT (f); | ||
| 197 | int old_height = FRAME_TOOL_BAR_HEIGHT (f); | ||
| 198 | int lines = (height + unit - 1) / unit; | ||
| 199 | Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); | ||
| 200 | |||
| 201 | /* Make sure we redisplay all windows in this frame. */ | ||
| 202 | fset_redisplay (f); | ||
| 203 | |||
| 204 | FRAME_TOOL_BAR_HEIGHT (f) = height; | ||
| 205 | FRAME_TOOL_BAR_LINES (f) = lines; | ||
| 206 | store_frame_param (f, Qtool_bar_lines, make_fixnum (lines)); | ||
| 207 | |||
| 208 | if (FRAME_ANDROID_WINDOW (f) && FRAME_TOOL_BAR_HEIGHT (f) == 0) | ||
| 209 | { | ||
| 210 | clear_frame (f); | ||
| 211 | clear_current_matrices (f); | ||
| 212 | } | ||
| 213 | |||
| 214 | if ((height < old_height) && WINDOWP (f->tool_bar_window)) | ||
| 215 | clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix); | ||
| 216 | |||
| 217 | if (!f->tool_bar_resized) | ||
| 218 | { | ||
| 219 | /* As long as tool_bar_resized is false, effectively try to change | ||
| 220 | F's native height. */ | ||
| 221 | if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) | ||
| 222 | adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), | ||
| 223 | 1, false, Qtool_bar_lines); | ||
| 224 | else | ||
| 225 | adjust_frame_size (f, -1, -1, 4, false, Qtool_bar_lines); | ||
| 226 | |||
| 227 | f->tool_bar_resized = f->tool_bar_redisplayed; | ||
| 228 | } | ||
| 229 | else | ||
| 230 | /* Any other change may leave the native size of F alone. */ | ||
| 231 | adjust_frame_size (f, -1, -1, 3, false, Qtool_bar_lines); | ||
| 232 | |||
| 233 | /* adjust_frame_size might not have done anything, garbage frame | ||
| 234 | here. */ | ||
| 235 | adjust_frame_glyphs (f); | ||
| 236 | SET_FRAME_GARBAGED (f); | ||
| 237 | } | ||
| 238 | |||
| 239 | /* Set the number of lines used for the tab bar of frame F to VALUE. | ||
| 240 | VALUE not an integer, or < 0 means set the lines to zero. OLDVAL | ||
| 241 | is the old number of tab bar lines. This function may change the | ||
| 242 | height of all windows on frame F to match the new tab bar height. | ||
| 243 | The frame's height may change if frame_inhibit_implied_resize was | ||
| 244 | set accordingly. */ | ||
| 245 | |||
| 246 | static void | ||
| 247 | android_set_tab_bar_lines (struct frame *f, Lisp_Object value, | ||
| 248 | Lisp_Object oldval) | ||
| 249 | { | ||
| 250 | int olines; | ||
| 251 | int nlines; | ||
| 252 | |||
| 253 | olines = FRAME_TAB_BAR_LINES (f); | ||
| 254 | |||
| 255 | /* Treat tab bars like menu bars. */ | ||
| 256 | if (FRAME_MINIBUF_ONLY_P (f)) | ||
| 257 | return; | ||
| 258 | |||
| 259 | /* Use VALUE only if an int >= 0. */ | ||
| 260 | if (RANGED_FIXNUMP (0, value, INT_MAX)) | ||
| 261 | nlines = XFIXNAT (value); | ||
| 262 | else | ||
| 263 | nlines = 0; | ||
| 264 | |||
| 265 | if (nlines != olines && (olines == 0 || nlines == 0)) | ||
| 266 | android_change_tab_bar_height (f, nlines * FRAME_LINE_HEIGHT (f)); | ||
| 267 | } | ||
| 268 | |||
| 269 | void | ||
| 270 | android_change_tab_bar_height (struct frame *f, int height) | ||
| 271 | { | ||
| 272 | int unit, old_height, lines; | ||
| 273 | Lisp_Object fullscreen; | ||
| 274 | |||
| 275 | unit = FRAME_LINE_HEIGHT (f); | ||
| 276 | old_height = FRAME_TAB_BAR_HEIGHT (f); | ||
| 277 | fullscreen = get_frame_param (f, Qfullscreen); | ||
| 278 | |||
| 279 | /* This differs from the tool bar code in that the tab bar height is | ||
| 280 | not rounded up. Otherwise, if redisplay_tab_bar decides to grow | ||
| 281 | the tab bar by even 1 pixel, FRAME_TAB_BAR_LINES will be changed, | ||
| 282 | leading to the tab bar height being incorrectly set upon the next | ||
| 283 | call to android_set_font. (bug#59285) */ | ||
| 284 | lines = height / unit; | ||
| 285 | |||
| 286 | /* Make sure we redisplay all windows in this frame. */ | ||
| 287 | fset_redisplay (f); | ||
| 288 | |||
| 289 | /* Recalculate tab bar and frame text sizes. */ | ||
| 290 | FRAME_TAB_BAR_HEIGHT (f) = height; | ||
| 291 | FRAME_TAB_BAR_LINES (f) = lines; | ||
| 292 | store_frame_param (f, Qtab_bar_lines, make_fixnum (lines)); | ||
| 293 | |||
| 294 | if (FRAME_ANDROID_WINDOW (f) && FRAME_TAB_BAR_HEIGHT (f) == 0) | ||
| 295 | { | ||
| 296 | clear_frame (f); | ||
| 297 | clear_current_matrices (f); | ||
| 298 | } | ||
| 299 | |||
| 300 | if ((height < old_height) && WINDOWP (f->tab_bar_window)) | ||
| 301 | clear_glyph_matrix (XWINDOW (f->tab_bar_window)->current_matrix); | ||
| 302 | |||
| 303 | if (!f->tab_bar_resized) | ||
| 304 | { | ||
| 305 | /* As long as tab_bar_resized is false, effectively try to change | ||
| 306 | F's native height. */ | ||
| 307 | if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) | ||
| 308 | adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), | ||
| 309 | 1, false, Qtab_bar_lines); | ||
| 310 | else | ||
| 311 | adjust_frame_size (f, -1, -1, 4, false, Qtab_bar_lines); | ||
| 312 | |||
| 313 | f->tab_bar_resized = f->tab_bar_redisplayed; | ||
| 314 | } | ||
| 315 | else | ||
| 316 | /* Any other change may leave the native size of F alone. */ | ||
| 317 | adjust_frame_size (f, -1, -1, 3, false, Qtab_bar_lines); | ||
| 318 | |||
| 319 | /* adjust_frame_size might not have done anything, garbage frame | ||
| 320 | here. */ | ||
| 321 | adjust_frame_glyphs (f); | ||
| 322 | SET_FRAME_GARBAGED (f); | ||
| 323 | } | ||
| 324 | |||
| 325 | void | ||
| 326 | android_set_scroll_bar_default_height (struct frame *f) | ||
| 327 | { | ||
| 328 | int height; | ||
| 329 | |||
| 330 | height = FRAME_LINE_HEIGHT (f); | ||
| 331 | |||
| 332 | /* The height of a non-toolkit scrollbar is 14 pixels. */ | ||
| 333 | FRAME_CONFIG_SCROLL_BAR_LINES (f) = (14 + height - 1) / height; | ||
| 334 | |||
| 335 | /* Use all of that space (aside from required margins) for the | ||
| 336 | scroll bar. */ | ||
| 337 | FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = 14; | ||
| 338 | } | ||
| 339 | |||
| 340 | void | ||
| 341 | android_set_scroll_bar_default_width (struct frame *f) | ||
| 342 | { | ||
| 343 | int unit; | ||
| 344 | |||
| 345 | unit = FRAME_COLUMN_WIDTH (f); | ||
| 346 | |||
| 347 | FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + unit - 1) / unit; | ||
| 348 | FRAME_CONFIG_SCROLL_BAR_WIDTH (f) | ||
| 349 | = FRAME_CONFIG_SCROLL_BAR_COLS (f) * unit; | ||
| 350 | } | ||
| 351 | |||
| 352 | |||
| 353 | /* Verify that the icon position args for this window are valid. */ | ||
| 354 | |||
| 355 | static void | ||
| 356 | android_icon_verify (struct frame *f, Lisp_Object parms) | ||
| 357 | { | ||
| 358 | Lisp_Object icon_x, icon_y; | ||
| 359 | |||
| 360 | /* Set the position of the icon. Note that twm groups all | ||
| 361 | icons in an icon window. */ | ||
| 362 | icon_x = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, | ||
| 363 | RES_TYPE_NUMBER); | ||
| 364 | icon_y = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, | ||
| 365 | RES_TYPE_NUMBER); | ||
| 366 | |||
| 367 | if (!BASE_EQ (icon_x, Qunbound) && !BASE_EQ (icon_y, Qunbound)) | ||
| 368 | { | ||
| 369 | CHECK_FIXNUM (icon_x); | ||
| 370 | CHECK_FIXNUM (icon_y); | ||
| 371 | } | ||
| 372 | else if (!BASE_EQ (icon_x, Qunbound) || !BASE_EQ (icon_y, Qunbound)) | ||
| 373 | error ("Both left and top icon corners of icon must be specified"); | ||
| 374 | } | ||
| 375 | |||
| 376 | /* Handle the icon stuff for this window. Perhaps later we might | ||
| 377 | want an x_set_icon_position which can be called interactively as | ||
| 378 | well. */ | ||
| 379 | |||
| 380 | static void | ||
| 381 | android_icon (struct frame *f, Lisp_Object parms) | ||
| 382 | { | ||
| 383 | /* Set the position of the icon. Note that twm groups all | ||
| 384 | icons in an icon window. */ | ||
| 385 | Lisp_Object icon_x | ||
| 386 | = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, | ||
| 387 | RES_TYPE_NUMBER); | ||
| 388 | Lisp_Object icon_y | ||
| 389 | = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, | ||
| 390 | RES_TYPE_NUMBER); | ||
| 391 | |||
| 392 | bool xgiven = !BASE_EQ (icon_x, Qunbound); | ||
| 393 | bool ygiven = !BASE_EQ (icon_y, Qunbound); | ||
| 394 | |||
| 395 | if (xgiven != ygiven) | ||
| 396 | error ("Both left and top icon corners of icon must be specified"); | ||
| 397 | |||
| 398 | if (xgiven) | ||
| 399 | { | ||
| 400 | check_integer_range (icon_x, INT_MIN, INT_MAX); | ||
| 401 | check_integer_range (icon_y, INT_MIN, INT_MAX); | ||
| 402 | } | ||
| 403 | |||
| 404 | /* Now return as this is not supported on Android. */ | ||
| 405 | } | ||
| 406 | |||
| 407 | /* Make the GCs needed for this window, setting the background | ||
| 408 | color. */ | ||
| 409 | |||
| 410 | static void | ||
| 411 | android_make_gc (struct frame *f) | ||
| 412 | { | ||
| 413 | struct android_gc_values gc_values; | ||
| 414 | |||
| 415 | block_input (); | ||
| 416 | |||
| 417 | /* Create the GCs of this frame. | ||
| 418 | Note that many default values are used. */ | ||
| 419 | |||
| 420 | gc_values.foreground = FRAME_FOREGROUND_PIXEL (f); | ||
| 421 | gc_values.background = FRAME_BACKGROUND_PIXEL (f); | ||
| 422 | f->output_data.android->normal_gc | ||
| 423 | = android_create_gc (ANDROID_GC_FOREGROUND | ANDROID_GC_BACKGROUND, | ||
| 424 | &gc_values); | ||
| 425 | |||
| 426 | /* Reverse video style. */ | ||
| 427 | gc_values.foreground = FRAME_BACKGROUND_PIXEL (f); | ||
| 428 | gc_values.background = FRAME_FOREGROUND_PIXEL (f); | ||
| 429 | f->output_data.android->reverse_gc | ||
| 430 | = android_create_gc (ANDROID_GC_FOREGROUND | ANDROID_GC_BACKGROUND, | ||
| 431 | &gc_values); | ||
| 432 | |||
| 433 | /* Cursor has cursor-color background, background-color foreground. */ | ||
| 434 | gc_values.foreground = FRAME_BACKGROUND_PIXEL (f); | ||
| 435 | gc_values.background = f->output_data.android->cursor_pixel; | ||
| 436 | f->output_data.android->cursor_gc | ||
| 437 | = android_create_gc (ANDROID_GC_FOREGROUND | ANDROID_GC_BACKGROUND, | ||
| 438 | &gc_values); | ||
| 439 | unblock_input (); | ||
| 440 | } | ||
| 441 | |||
| 442 | |||
| 443 | /* Free what was allocated in android_make_gc. */ | ||
| 444 | |||
| 445 | void | ||
| 446 | android_free_gcs (struct frame *f) | ||
| 447 | { | ||
| 448 | block_input (); | ||
| 449 | |||
| 450 | if (f->output_data.android->normal_gc) | ||
| 451 | { | ||
| 452 | android_free_gc (f->output_data.android->normal_gc); | ||
| 453 | f->output_data.android->normal_gc = 0; | ||
| 454 | } | ||
| 455 | |||
| 456 | if (f->output_data.android->reverse_gc) | ||
| 457 | { | ||
| 458 | android_free_gc (f->output_data.android->reverse_gc); | ||
| 459 | f->output_data.android->reverse_gc = 0; | ||
| 460 | } | ||
| 461 | |||
| 462 | if (f->output_data.android->cursor_gc) | ||
| 463 | { | ||
| 464 | android_free_gc (f->output_data.android->cursor_gc); | ||
| 465 | f->output_data.android->cursor_gc = 0; | ||
| 466 | } | ||
| 467 | |||
| 468 | unblock_input (); | ||
| 469 | } | ||
| 470 | |||
| 471 | /* Handler for signals raised during x_create_frame and | ||
| 472 | Fx_create_tip_frame. FRAME is the frame which is partially | ||
| 473 | constructed. */ | ||
| 474 | |||
| 475 | static Lisp_Object | ||
| 476 | unwind_create_frame (Lisp_Object frame) | ||
| 477 | { | ||
| 478 | struct frame *f = XFRAME (frame); | ||
| 479 | |||
| 480 | /* If frame is already dead, nothing to do. This can happen if the | ||
| 481 | display is disconnected after the frame has become official, but | ||
| 482 | before Fx_create_frame removes the unwind protect. */ | ||
| 483 | if (!FRAME_LIVE_P (f)) | ||
| 484 | return Qnil; | ||
| 485 | |||
| 486 | /* If frame is ``official'', nothing to do. */ | ||
| 487 | if (NILP (Fmemq (frame, Vframe_list))) | ||
| 488 | { | ||
| 489 | /* If the frame's image cache refcount is still the same as our | ||
| 490 | private shadow variable, it means we are unwinding a frame | ||
| 491 | for which we didn't yet call init_frame_faces, where the | ||
| 492 | refcount is incremented. Therefore, we increment it here, so | ||
| 493 | that free_frame_faces, called in x_free_frame_resources | ||
| 494 | below, will not mistakenly decrement the counter that was not | ||
| 495 | incremented yet to account for this new frame. */ | ||
| 496 | if (FRAME_IMAGE_CACHE (f) != NULL | ||
| 497 | && FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount) | ||
| 498 | FRAME_IMAGE_CACHE (f)->refcount++; | ||
| 499 | |||
| 500 | android_free_frame_resources (f); | ||
| 501 | free_glyphs (f); | ||
| 502 | return Qt; | ||
| 503 | } | ||
| 504 | |||
| 505 | return Qnil; | ||
| 506 | } | ||
| 507 | |||
| 508 | static void | ||
| 509 | do_unwind_create_frame (Lisp_Object frame) | ||
| 510 | { | ||
| 511 | unwind_create_frame (frame); | ||
| 512 | } | ||
| 513 | |||
| 514 | void | ||
| 515 | android_default_font_parameter (struct frame *f, Lisp_Object parms) | ||
| 516 | { | ||
| 517 | struct android_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); | ||
| 518 | Lisp_Object font_param = gui_display_get_arg (dpyinfo, parms, Qfont, NULL, NULL, | ||
| 519 | RES_TYPE_STRING); | ||
| 520 | Lisp_Object font = Qnil; | ||
| 521 | if (BASE_EQ (font_param, Qunbound)) | ||
| 522 | font_param = Qnil; | ||
| 523 | |||
| 524 | if (NILP (font)) | ||
| 525 | font = (!NILP (font_param) | ||
| 526 | ? font_param | ||
| 527 | : gui_display_get_arg (dpyinfo, parms, | ||
| 528 | Qfont, "font", "Font", | ||
| 529 | RES_TYPE_STRING)); | ||
| 530 | |||
| 531 | if (! FONTP (font) && ! STRINGP (font)) | ||
| 532 | { | ||
| 533 | const char *names[] = { | ||
| 534 | /* This will find the normal font. */ | ||
| 535 | "DroidSansMono", | ||
| 536 | "monospace", | ||
| 537 | NULL | ||
| 538 | }; | ||
| 539 | int i; | ||
| 540 | |||
| 541 | for (i = 0; names[i]; i++) | ||
| 542 | { | ||
| 543 | font = font_open_by_name (f, build_unibyte_string (names[i])); | ||
| 544 | if (! NILP (font)) | ||
| 545 | break; | ||
| 546 | } | ||
| 547 | |||
| 548 | if (NILP (font)) | ||
| 549 | error ("No suitable font was found"); | ||
| 550 | } | ||
| 551 | |||
| 552 | gui_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING); | ||
| 553 | } | ||
| 554 | |||
| 555 | static void | ||
| 556 | android_create_frame_window (struct frame *f) | ||
| 557 | { | ||
| 558 | struct android_set_window_attributes attributes; | ||
| 559 | enum android_window_value_mask attribute_mask; | ||
| 560 | |||
| 561 | attributes.background_pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 562 | attribute_mask = ANDROID_CW_BACK_PIXEL; | ||
| 563 | |||
| 564 | block_input (); | ||
| 565 | FRAME_ANDROID_WINDOW (f) | ||
| 566 | = android_create_window (FRAME_DISPLAY_INFO (f)->root_window, | ||
| 567 | f->left_pos, | ||
| 568 | f->top_pos, | ||
| 569 | FRAME_PIXEL_WIDTH (f), | ||
| 570 | FRAME_PIXEL_HEIGHT (f), | ||
| 571 | attribute_mask, &attributes); | ||
| 572 | unblock_input (); | ||
| 573 | } | ||
| 574 | |||
| 575 | #endif /* ANDROID_STUBIFY */ | ||
| 576 | |||
| 577 | |||
| 578 | |||
| 579 | DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, | ||
| 580 | 1, 1, 0, | ||
| 581 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 582 | (Lisp_Object parms) | ||
| 583 | { | ||
| 584 | #ifdef ANDROID_STUBIFY | ||
| 585 | error ("Android cross-compilation stub called!"); | ||
| 586 | return Qnil; | ||
| 587 | #else | ||
| 588 | struct frame *f; | ||
| 589 | Lisp_Object frame, tem; | ||
| 590 | Lisp_Object name; | ||
| 591 | bool minibuffer_only; | ||
| 592 | bool undecorated, override_redirect; | ||
| 593 | long window_prompting; | ||
| 594 | specpdl_ref count; | ||
| 595 | Lisp_Object display; | ||
| 596 | struct android_display_info *dpyinfo; | ||
| 597 | Lisp_Object parent, parent_frame; | ||
| 598 | struct kboard *kb; | ||
| 599 | |||
| 600 | minibuffer_only = false; | ||
| 601 | undecorated = false; | ||
| 602 | override_redirect = false; | ||
| 603 | window_prompting = 0; | ||
| 604 | count = SPECPDL_INDEX (); | ||
| 605 | dpyinfo = NULL; | ||
| 606 | |||
| 607 | /* Not actually used, but be consistent with X. */ | ||
| 608 | ((void) window_prompting); | ||
| 609 | |||
| 610 | parms = Fcopy_alist (parms); | ||
| 611 | |||
| 612 | /* Use this general default value to start with | ||
| 613 | until we know if this frame has a specified name. */ | ||
| 614 | Vx_resource_name = Vinvocation_name; | ||
| 615 | |||
| 616 | display = gui_display_get_arg (dpyinfo, parms, Qterminal, 0, 0, | ||
| 617 | RES_TYPE_NUMBER); | ||
| 618 | if (BASE_EQ (display, Qunbound)) | ||
| 619 | display = gui_display_get_arg (dpyinfo, parms, Qdisplay, 0, 0, | ||
| 620 | RES_TYPE_STRING); | ||
| 621 | if (BASE_EQ (display, Qunbound)) | ||
| 622 | display = Qnil; | ||
| 623 | dpyinfo = check_android_display_info (display); | ||
| 624 | kb = dpyinfo->terminal->kboard; | ||
| 625 | |||
| 626 | if (!dpyinfo->terminal->name) | ||
| 627 | error ("Terminal is not live, can't create new frames on it"); | ||
| 628 | |||
| 629 | name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name", | ||
| 630 | RES_TYPE_STRING); | ||
| 631 | if (!STRINGP (name) | ||
| 632 | && ! BASE_EQ (name, Qunbound) | ||
| 633 | && ! NILP (name)) | ||
| 634 | error ("Invalid frame name--not a string or nil"); | ||
| 635 | |||
| 636 | if (STRINGP (name)) | ||
| 637 | Vx_resource_name = name; | ||
| 638 | |||
| 639 | /* See if parent window is specified. */ | ||
| 640 | parent = gui_display_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL, | ||
| 641 | RES_TYPE_NUMBER); | ||
| 642 | if (BASE_EQ (parent, Qunbound)) | ||
| 643 | parent = Qnil; | ||
| 644 | if (! NILP (parent)) | ||
| 645 | CHECK_FIXNUM (parent); | ||
| 646 | |||
| 647 | frame = Qnil; | ||
| 648 | tem = gui_display_get_arg (dpyinfo, | ||
| 649 | parms, Qminibuffer, "minibuffer", "Minibuffer", | ||
| 650 | RES_TYPE_SYMBOL); | ||
| 651 | if (EQ (tem, Qnone) || NILP (tem)) | ||
| 652 | f = make_frame_without_minibuffer (Qnil, kb, display); | ||
| 653 | else if (EQ (tem, Qonly)) | ||
| 654 | { | ||
| 655 | f = make_minibuffer_frame (); | ||
| 656 | minibuffer_only = true; | ||
| 657 | } | ||
| 658 | else if (WINDOWP (tem)) | ||
| 659 | f = make_frame_without_minibuffer (tem, kb, display); | ||
| 660 | else | ||
| 661 | f = make_frame (true); | ||
| 662 | |||
| 663 | parent_frame = gui_display_get_arg (dpyinfo, | ||
| 664 | parms, | ||
| 665 | Qparent_frame, | ||
| 666 | NULL, | ||
| 667 | NULL, | ||
| 668 | RES_TYPE_SYMBOL); | ||
| 669 | /* Accept parent-frame iff parent-id was not specified. */ | ||
| 670 | if (!NILP (parent) | ||
| 671 | || BASE_EQ (parent_frame, Qunbound) | ||
| 672 | || NILP (parent_frame) | ||
| 673 | || !FRAMEP (parent_frame) | ||
| 674 | || !FRAME_LIVE_P (XFRAME (parent_frame)) | ||
| 675 | || !FRAME_ANDROID_P (XFRAME (parent_frame))) | ||
| 676 | parent_frame = Qnil; | ||
| 677 | |||
| 678 | fset_parent_frame (f, parent_frame); | ||
| 679 | store_frame_param (f, Qparent_frame, parent_frame); | ||
| 680 | |||
| 681 | if (!NILP (tem = (gui_display_get_arg (dpyinfo, | ||
| 682 | parms, | ||
| 683 | Qundecorated, | ||
| 684 | NULL, | ||
| 685 | NULL, | ||
| 686 | RES_TYPE_BOOLEAN))) | ||
| 687 | && !(BASE_EQ (tem, Qunbound))) | ||
| 688 | undecorated = true; | ||
| 689 | |||
| 690 | FRAME_UNDECORATED (f) = undecorated; | ||
| 691 | store_frame_param (f, Qundecorated, undecorated ? Qt : Qnil); | ||
| 692 | |||
| 693 | if (!NILP (tem = (gui_display_get_arg (dpyinfo, | ||
| 694 | parms, | ||
| 695 | Qoverride_redirect, | ||
| 696 | NULL, | ||
| 697 | NULL, | ||
| 698 | RES_TYPE_BOOLEAN))) | ||
| 699 | && !(BASE_EQ (tem, Qunbound))) | ||
| 700 | override_redirect = true; | ||
| 701 | |||
| 702 | FRAME_OVERRIDE_REDIRECT (f) = override_redirect; | ||
| 703 | store_frame_param (f, Qoverride_redirect, override_redirect ? Qt : Qnil); | ||
| 704 | |||
| 705 | XSETFRAME (frame, f); | ||
| 706 | |||
| 707 | f->terminal = dpyinfo->terminal; | ||
| 708 | |||
| 709 | f->output_method = output_android; | ||
| 710 | f->output_data.android = xzalloc (sizeof *f->output_data.android); | ||
| 711 | FRAME_FONTSET (f) = -1; | ||
| 712 | f->output_data.android->scroll_bar_foreground_pixel = -1; | ||
| 713 | f->output_data.android->scroll_bar_background_pixel = -1; | ||
| 714 | f->output_data.android->white_relief.pixel = -1; | ||
| 715 | f->output_data.android->black_relief.pixel = -1; | ||
| 716 | |||
| 717 | fset_icon_name (f, gui_display_get_arg (dpyinfo, | ||
| 718 | parms, | ||
| 719 | Qicon_name, | ||
| 720 | "iconName", | ||
| 721 | "Title", | ||
| 722 | RES_TYPE_STRING)); | ||
| 723 | if (! STRINGP (f->icon_name)) | ||
| 724 | fset_icon_name (f, Qnil); | ||
| 725 | |||
| 726 | FRAME_DISPLAY_INFO (f) = dpyinfo; | ||
| 727 | |||
| 728 | /* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */ | ||
| 729 | record_unwind_protect (do_unwind_create_frame, frame); | ||
| 730 | |||
| 731 | /* These colors will be set anyway later, but it's important | ||
| 732 | to get the color reference counts right, so initialize them! | ||
| 733 | |||
| 734 | (Not really on Android, but it's best to be consistent with | ||
| 735 | X.) */ | ||
| 736 | { | ||
| 737 | Lisp_Object black; | ||
| 738 | |||
| 739 | /* Function x_decode_color can signal an error. Make | ||
| 740 | sure to initialize color slots so that we won't try | ||
| 741 | to free colors we haven't allocated. */ | ||
| 742 | FRAME_FOREGROUND_PIXEL (f) = -1; | ||
| 743 | FRAME_BACKGROUND_PIXEL (f) = -1; | ||
| 744 | f->output_data.android->cursor_pixel = -1; | ||
| 745 | f->output_data.android->cursor_foreground_pixel = -1; | ||
| 746 | |||
| 747 | black = build_string ("black"); | ||
| 748 | FRAME_FOREGROUND_PIXEL (f) | ||
| 749 | = android_decode_color (f, black, BLACK_PIX_DEFAULT (f)); | ||
| 750 | FRAME_BACKGROUND_PIXEL (f) | ||
| 751 | = android_decode_color (f, black, BLACK_PIX_DEFAULT (f)); | ||
| 752 | f->output_data.android->cursor_pixel | ||
| 753 | = android_decode_color (f, black, BLACK_PIX_DEFAULT (f)); | ||
| 754 | f->output_data.android->cursor_foreground_pixel | ||
| 755 | = android_decode_color (f, black, BLACK_PIX_DEFAULT (f)); | ||
| 756 | } | ||
| 757 | |||
| 758 | /* Set the name; the functions to which we pass f expect the name to | ||
| 759 | be set. */ | ||
| 760 | if (BASE_EQ (name, Qunbound) || NILP (name)) | ||
| 761 | { | ||
| 762 | fset_name (f, build_string ("GNU Emacs")); | ||
| 763 | f->explicit_name = false; | ||
| 764 | } | ||
| 765 | else | ||
| 766 | { | ||
| 767 | fset_name (f, name); | ||
| 768 | f->explicit_name = true; | ||
| 769 | /* Use the frame's title when getting resources for this frame. */ | ||
| 770 | specbind (Qx_resource_name, name); | ||
| 771 | } | ||
| 772 | |||
| 773 | register_font_driver (&androidfont_driver, f); | ||
| 774 | |||
| 775 | image_cache_refcount = (FRAME_IMAGE_CACHE (f) | ||
| 776 | ? FRAME_IMAGE_CACHE (f)->refcount | ||
| 777 | : 0); | ||
| 778 | |||
| 779 | gui_default_parameter (f, parms, Qfont_backend, Qnil, | ||
| 780 | "fontBackend", "FontBackend", RES_TYPE_STRING); | ||
| 781 | |||
| 782 | /* Extract the window parameters from the supplied values | ||
| 783 | that are needed to determine window geometry. */ | ||
| 784 | android_default_font_parameter (f, parms); | ||
| 785 | if (!FRAME_FONT (f)) | ||
| 786 | { | ||
| 787 | delete_frame (frame, Qnoelisp); | ||
| 788 | error ("Invalid frame font"); | ||
| 789 | } | ||
| 790 | |||
| 791 | if (NILP (Fassq (Qinternal_border_width, parms))) | ||
| 792 | { | ||
| 793 | Lisp_Object value; | ||
| 794 | |||
| 795 | value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width, | ||
| 796 | "internalBorder", "internalBorder", | ||
| 797 | RES_TYPE_NUMBER); | ||
| 798 | if (! BASE_EQ (value, Qunbound)) | ||
| 799 | parms = Fcons (Fcons (Qinternal_border_width, value), | ||
| 800 | parms); | ||
| 801 | } | ||
| 802 | |||
| 803 | gui_default_parameter (f, parms, Qinternal_border_width, | ||
| 804 | make_fixnum (0), | ||
| 805 | "internalBorderWidth", "internalBorderWidth", | ||
| 806 | RES_TYPE_NUMBER); | ||
| 807 | |||
| 808 | /* Same for child frames. */ | ||
| 809 | if (NILP (Fassq (Qchild_frame_border_width, parms))) | ||
| 810 | { | ||
| 811 | Lisp_Object value; | ||
| 812 | |||
| 813 | value = gui_display_get_arg (dpyinfo, parms, Qchild_frame_border_width, | ||
| 814 | "childFrameBorder", "childFrameBorder", | ||
| 815 | RES_TYPE_NUMBER); | ||
| 816 | if (! BASE_EQ (value, Qunbound)) | ||
| 817 | parms = Fcons (Fcons (Qchild_frame_border_width, value), | ||
| 818 | parms); | ||
| 819 | } | ||
| 820 | |||
| 821 | gui_default_parameter (f, parms, Qchild_frame_border_width, Qnil, | ||
| 822 | "childFrameBorderWidth", "childFrameBorderWidth", | ||
| 823 | RES_TYPE_NUMBER); | ||
| 824 | gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0), | ||
| 825 | NULL, NULL, RES_TYPE_NUMBER); | ||
| 826 | gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0), | ||
| 827 | NULL, NULL, RES_TYPE_NUMBER); | ||
| 828 | |||
| 829 | /* gui_default_parameter (f, parms, Qvertical_scroll_bars, */ | ||
| 830 | /* Qleft, */ | ||
| 831 | /* "verticalScrollBars", "ScrollBars", */ | ||
| 832 | /* RES_TYPE_SYMBOL); */ | ||
| 833 | /* gui_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil, */ | ||
| 834 | /* "horizontalScrollBars", "ScrollBars", */ | ||
| 835 | /* RES_TYPE_SYMBOL); TODO */ | ||
| 836 | |||
| 837 | /* Also do the stuff which must be set before the window exists. */ | ||
| 838 | gui_default_parameter (f, parms, Qforeground_color, build_string ("black"), | ||
| 839 | "foreground", "Foreground", RES_TYPE_STRING); | ||
| 840 | gui_default_parameter (f, parms, Qbackground_color, build_string ("white"), | ||
| 841 | "background", "Background", RES_TYPE_STRING); | ||
| 842 | gui_default_parameter (f, parms, Qmouse_color, build_string ("black"), | ||
| 843 | "pointerColor", "Foreground", RES_TYPE_STRING); | ||
| 844 | gui_default_parameter (f, parms, Qborder_color, build_string ("black"), | ||
| 845 | "borderColor", "BorderColor", RES_TYPE_STRING); | ||
| 846 | gui_default_parameter (f, parms, Qscreen_gamma, Qnil, | ||
| 847 | "screenGamma", "ScreenGamma", RES_TYPE_FLOAT); | ||
| 848 | gui_default_parameter (f, parms, Qline_spacing, Qnil, | ||
| 849 | "lineSpacing", "LineSpacing", RES_TYPE_NUMBER); | ||
| 850 | gui_default_parameter (f, parms, Qleft_fringe, Qnil, | ||
| 851 | "leftFringe", "LeftFringe", RES_TYPE_NUMBER); | ||
| 852 | gui_default_parameter (f, parms, Qright_fringe, Qnil, | ||
| 853 | "rightFringe", "RightFringe", RES_TYPE_NUMBER); | ||
| 854 | gui_default_parameter (f, parms, Qno_special_glyphs, Qnil, | ||
| 855 | NULL, NULL, RES_TYPE_BOOLEAN); | ||
| 856 | |||
| 857 | #if 0 | ||
| 858 | android_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground, | ||
| 859 | "scrollBarForeground", | ||
| 860 | "ScrollBarForeground", true); | ||
| 861 | android_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_background, | ||
| 862 | "scrollBarBackground", | ||
| 863 | "ScrollBarBackground", false); | ||
| 864 | #endif /* TODO */ | ||
| 865 | |||
| 866 | /* Init faces before gui_default_parameter is called for the | ||
| 867 | scroll-bar-width parameter because otherwise we end up in | ||
| 868 | init_iterator with a null face cache, which should not | ||
| 869 | happen. */ | ||
| 870 | |||
| 871 | init_frame_faces (f); | ||
| 872 | |||
| 873 | tem = gui_display_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL, | ||
| 874 | RES_TYPE_NUMBER); | ||
| 875 | if (FIXNUMP (tem)) | ||
| 876 | store_frame_param (f, Qmin_width, tem); | ||
| 877 | tem = gui_display_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL, | ||
| 878 | RES_TYPE_NUMBER); | ||
| 879 | if (FIXNUMP (tem)) | ||
| 880 | store_frame_param (f, Qmin_height, tem); | ||
| 881 | |||
| 882 | adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), | ||
| 883 | FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, true, | ||
| 884 | Qx_create_frame_1); | ||
| 885 | |||
| 886 | /* Set the menu-bar-lines and tool-bar-lines parameters. We don't | ||
| 887 | look up the X resources controlling the menu-bar and tool-bar | ||
| 888 | here; they are processed specially at startup, and reflected in | ||
| 889 | the values of the mode variables. */ | ||
| 890 | |||
| 891 | gui_default_parameter (f, parms, Qmenu_bar_lines, | ||
| 892 | NILP (Vmenu_bar_mode) | ||
| 893 | ? make_fixnum (0) : make_fixnum (1), | ||
| 894 | NULL, NULL, RES_TYPE_NUMBER); | ||
| 895 | gui_default_parameter (f, parms, Qtab_bar_lines, | ||
| 896 | NILP (Vtab_bar_mode) | ||
| 897 | ? make_fixnum (0) : make_fixnum (1), | ||
| 898 | NULL, NULL, RES_TYPE_NUMBER); | ||
| 899 | gui_default_parameter (f, parms, Qtool_bar_lines, | ||
| 900 | NILP (Vtool_bar_mode) | ||
| 901 | ? make_fixnum (0) : make_fixnum (1), | ||
| 902 | NULL, NULL, RES_TYPE_NUMBER); | ||
| 903 | |||
| 904 | gui_default_parameter (f, parms, Qbuffer_predicate, Qnil, | ||
| 905 | "bufferPredicate", "BufferPredicate", | ||
| 906 | RES_TYPE_SYMBOL); | ||
| 907 | gui_default_parameter (f, parms, Qtitle, Qnil, | ||
| 908 | "title", "Title", RES_TYPE_STRING); | ||
| 909 | gui_default_parameter (f, parms, Qwait_for_wm, Qt, | ||
| 910 | "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN); | ||
| 911 | gui_default_parameter (f, parms, Qtool_bar_position, | ||
| 912 | FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL); | ||
| 913 | gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil, | ||
| 914 | "inhibitDoubleBuffering", "InhibitDoubleBuffering", | ||
| 915 | RES_TYPE_BOOLEAN); | ||
| 916 | |||
| 917 | /* Compute the size of the X window. */ | ||
| 918 | window_prompting = gui_figure_window_size (f, parms, true, true); | ||
| 919 | |||
| 920 | tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, | ||
| 921 | RES_TYPE_BOOLEAN); | ||
| 922 | f->no_split = minibuffer_only || EQ (tem, Qt); | ||
| 923 | |||
| 924 | android_icon_verify (f, parms); | ||
| 925 | android_create_frame_window (f); | ||
| 926 | android_icon (f, parms); | ||
| 927 | android_make_gc (f); | ||
| 928 | |||
| 929 | /* Now consider the frame official. */ | ||
| 930 | f->terminal->reference_count++; | ||
| 931 | Vframe_list = Fcons (frame, Vframe_list); | ||
| 932 | |||
| 933 | /* We need to do this after creating the window, so that the | ||
| 934 | icon-creation functions can say whose icon they're | ||
| 935 | describing. */ | ||
| 936 | gui_default_parameter (f, parms, Qicon_type, Qt, | ||
| 937 | "bitmapIcon", "BitmapIcon", RES_TYPE_BOOLEAN); | ||
| 938 | |||
| 939 | gui_default_parameter (f, parms, Qauto_raise, Qnil, | ||
| 940 | "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN); | ||
| 941 | gui_default_parameter (f, parms, Qauto_lower, Qnil, | ||
| 942 | "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN); | ||
| 943 | gui_default_parameter (f, parms, Qcursor_type, Qbox, | ||
| 944 | "cursorType", "CursorType", RES_TYPE_SYMBOL); | ||
| 945 | gui_default_parameter (f, parms, Qscroll_bar_width, Qnil, | ||
| 946 | "scrollBarWidth", "ScrollBarWidth", | ||
| 947 | RES_TYPE_NUMBER); | ||
| 948 | gui_default_parameter (f, parms, Qscroll_bar_height, Qnil, | ||
| 949 | "scrollBarHeight", "ScrollBarHeight", | ||
| 950 | RES_TYPE_NUMBER); | ||
| 951 | gui_default_parameter (f, parms, Qalpha, Qnil, | ||
| 952 | "alpha", "Alpha", RES_TYPE_NUMBER); | ||
| 953 | gui_default_parameter (f, parms, Qalpha_background, Qnil, | ||
| 954 | "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); | ||
| 955 | |||
| 956 | if (!NILP (parent_frame)) | ||
| 957 | { | ||
| 958 | struct frame *p = XFRAME (parent_frame); | ||
| 959 | |||
| 960 | block_input (); | ||
| 961 | android_reparent_window (FRAME_ANDROID_WINDOW (f), | ||
| 962 | FRAME_ANDROID_WINDOW (p), | ||
| 963 | f->left_pos, f->top_pos); | ||
| 964 | unblock_input (); | ||
| 965 | } | ||
| 966 | |||
| 967 | gui_default_parameter (f, parms, Qno_focus_on_map, Qnil, | ||
| 968 | NULL, NULL, RES_TYPE_BOOLEAN); | ||
| 969 | gui_default_parameter (f, parms, Qno_accept_focus, Qnil, | ||
| 970 | NULL, NULL, RES_TYPE_BOOLEAN); | ||
| 971 | |||
| 972 | /* Consider frame official, now. */ | ||
| 973 | f->can_set_window_size = true; | ||
| 974 | |||
| 975 | adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), | ||
| 976 | 0, true, Qx_create_frame_2); | ||
| 977 | |||
| 978 | /* Process fullscreen parameter here in the hope that normalizing a | ||
| 979 | fullheight/fullwidth frame will produce the size set by the last | ||
| 980 | adjust_frame_size call. */ | ||
| 981 | gui_default_parameter (f, parms, Qfullscreen, Qnil, | ||
| 982 | "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); | ||
| 983 | |||
| 984 | /* When called from `x-create-frame-with-faces' visibility is | ||
| 985 | always explicitly nil. */ | ||
| 986 | Lisp_Object visibility | ||
| 987 | = gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0, | ||
| 988 | RES_TYPE_SYMBOL); | ||
| 989 | Lisp_Object height | ||
| 990 | = gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); | ||
| 991 | Lisp_Object width | ||
| 992 | = gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); | ||
| 993 | |||
| 994 | if (EQ (visibility, Qicon)) | ||
| 995 | { | ||
| 996 | f->was_invisible = true; | ||
| 997 | android_iconify_frame (f); | ||
| 998 | } | ||
| 999 | else | ||
| 1000 | { | ||
| 1001 | if (BASE_EQ (visibility, Qunbound)) | ||
| 1002 | visibility = Qt; | ||
| 1003 | |||
| 1004 | if (!NILP (visibility)) | ||
| 1005 | android_make_frame_visible (f); | ||
| 1006 | else | ||
| 1007 | f->was_invisible = true; | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | /* Leave f->was_invisible true only if height or width were | ||
| 1011 | specified too. This takes effect only when we are not called | ||
| 1012 | from `x-create-frame-with-faces' (see above comment). */ | ||
| 1013 | f->was_invisible | ||
| 1014 | = (f->was_invisible | ||
| 1015 | && (!BASE_EQ (height, Qunbound) || !BASE_EQ (width, Qunbound))); | ||
| 1016 | |||
| 1017 | store_frame_param (f, Qvisibility, visibility); | ||
| 1018 | |||
| 1019 | /* Set whether or not frame synchronization is enabled. */ | ||
| 1020 | gui_default_parameter (f, parms, Quse_frame_synchronization, Qt, | ||
| 1021 | NULL, NULL, RES_TYPE_BOOLEAN); | ||
| 1022 | |||
| 1023 | /* Works iff frame has been already mapped. */ | ||
| 1024 | gui_default_parameter (f, parms, Qskip_taskbar, Qnil, | ||
| 1025 | NULL, NULL, RES_TYPE_BOOLEAN); | ||
| 1026 | /* The `z-group' parameter works only for visible frames. */ | ||
| 1027 | gui_default_parameter (f, parms, Qz_group, Qnil, | ||
| 1028 | NULL, NULL, RES_TYPE_SYMBOL); | ||
| 1029 | |||
| 1030 | /* Initialize `default-minibuffer-frame' in case this is the first | ||
| 1031 | frame on this terminal. */ | ||
| 1032 | if (FRAME_HAS_MINIBUF_P (f) | ||
| 1033 | && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame)) | ||
| 1034 | || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame))))) | ||
| 1035 | kset_default_minibuffer_frame (kb, frame); | ||
| 1036 | |||
| 1037 | /* All remaining specified parameters, which have not been "used" by | ||
| 1038 | gui_display_get_arg and friends, now go in the misc. alist of the | ||
| 1039 | frame. */ | ||
| 1040 | for (tem = parms; CONSP (tem); tem = XCDR (tem)) | ||
| 1041 | if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) | ||
| 1042 | fset_param_alist (f, Fcons (XCAR (tem), f->param_alist)); | ||
| 1043 | |||
| 1044 | /* Make sure windows on this frame appear in calls to next-window | ||
| 1045 | and similar functions. */ | ||
| 1046 | Vwindow_list = Qnil; | ||
| 1047 | |||
| 1048 | return unbind_to (count, frame); | ||
| 1049 | #endif | ||
| 1050 | } | ||
| 1051 | |||
| 1052 | DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, | ||
| 1053 | 1, 2, 0, doc: /* SKIP: real doc in xfns.c. */) | ||
| 1054 | (Lisp_Object color, Lisp_Object frame) | ||
| 1055 | { | ||
| 1056 | #ifdef ANDROID_STUBIFY | ||
| 1057 | error ("Android cross-compilation stub called!"); | ||
| 1058 | return Qnil; | ||
| 1059 | #else | ||
| 1060 | Emacs_Color foo; | ||
| 1061 | struct frame *f; | ||
| 1062 | |||
| 1063 | f = decode_window_system_frame (frame); | ||
| 1064 | |||
| 1065 | CHECK_STRING (color); | ||
| 1066 | |||
| 1067 | if (android_defined_color (f, SSDATA (color), &foo, false, false)) | ||
| 1068 | return Qt; | ||
| 1069 | else | ||
| 1070 | return Qnil; | ||
| 1071 | #endif | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, | ||
| 1075 | 0, doc: /* SKIP: real doc in xfns.c. */) | ||
| 1076 | (Lisp_Object color, Lisp_Object frame) | ||
| 1077 | { | ||
| 1078 | #ifdef ANDROID_STUBIFY | ||
| 1079 | error ("Android cross-compilation stub called!"); | ||
| 1080 | return Qnil; | ||
| 1081 | #else | ||
| 1082 | Emacs_Color foo; | ||
| 1083 | struct frame *f; | ||
| 1084 | |||
| 1085 | f = decode_window_system_frame (frame); | ||
| 1086 | |||
| 1087 | CHECK_STRING (color); | ||
| 1088 | |||
| 1089 | if (android_defined_color (f, SSDATA (color), &foo, false, false)) | ||
| 1090 | return list3i (foo.red, foo.green, foo.blue); | ||
| 1091 | else | ||
| 1092 | return Qnil; | ||
| 1093 | #endif | ||
| 1094 | } | ||
| 1095 | |||
| 1096 | DEFUN ("xw-display-color-p", Fxw_display_color_p, | ||
| 1097 | Sxw_display_color_p, 0, 1, 0, | ||
| 1098 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1099 | (Lisp_Object terminal) | ||
| 1100 | { | ||
| 1101 | return Qt; | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, | ||
| 1105 | Sx_display_grayscale_p, 0, 1, 0, | ||
| 1106 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1107 | (Lisp_Object terminal) | ||
| 1108 | { | ||
| 1109 | return Qnil; | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | DEFUN ("x-display-pixel-width", Fx_display_pixel_width, | ||
| 1113 | Sx_display_pixel_width, 0, 1, 0, | ||
| 1114 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1115 | (Lisp_Object terminal) | ||
| 1116 | { | ||
| 1117 | #ifdef ANDROID_STUBIFY | ||
| 1118 | error ("Android cross-compilation stub called!"); | ||
| 1119 | return Qnil; | ||
| 1120 | #else | ||
| 1121 | error ("Not implemented"); | ||
| 1122 | return Qnil; | ||
| 1123 | #endif | ||
| 1124 | } | ||
| 1125 | |||
| 1126 | DEFUN ("x-display-pixel-height", Fx_display_pixel_height, | ||
| 1127 | Sx_display_pixel_height, 0, 1, 0, | ||
| 1128 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1129 | (Lisp_Object terminal) | ||
| 1130 | { | ||
| 1131 | #ifdef ANDROID_STUBIFY | ||
| 1132 | error ("Android cross-compilation stub called!"); | ||
| 1133 | return Qnil; | ||
| 1134 | #else | ||
| 1135 | error ("Not implemented"); | ||
| 1136 | return Qnil; | ||
| 1137 | #endif | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, | ||
| 1141 | 0, 1, 0, | ||
| 1142 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1143 | (Lisp_Object terminal) | ||
| 1144 | { | ||
| 1145 | struct android_display_info *dpyinfo; | ||
| 1146 | |||
| 1147 | dpyinfo = check_android_display_info (terminal); | ||
| 1148 | |||
| 1149 | return make_fixnum (dpyinfo->n_planes); | ||
| 1150 | } | ||
| 1151 | |||
| 1152 | DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, | ||
| 1153 | 0, 1, 0, | ||
| 1154 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1155 | (Lisp_Object terminal) | ||
| 1156 | { | ||
| 1157 | struct android_display_info *dpyinfo; | ||
| 1158 | int nr_planes; | ||
| 1159 | |||
| 1160 | dpyinfo = check_android_display_info (terminal); | ||
| 1161 | nr_planes = dpyinfo->n_planes; | ||
| 1162 | |||
| 1163 | /* Truncate nr_planes to 24 to avoid integer overflow. */ | ||
| 1164 | |||
| 1165 | if (nr_planes > 24) | ||
| 1166 | nr_planes = 24; | ||
| 1167 | |||
| 1168 | return make_fixnum (1 << nr_planes); | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, | ||
| 1172 | 0, 1, 0, doc: /* SKIP: real doc in xfns.c. */) | ||
| 1173 | (Lisp_Object terminal) | ||
| 1174 | { | ||
| 1175 | check_android_display_info (terminal); | ||
| 1176 | return make_fixnum (1); | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, | ||
| 1180 | 0, 1, 0, doc: /* SKIP: real doc in xfns.c. */) | ||
| 1181 | (Lisp_Object terminal) | ||
| 1182 | { | ||
| 1183 | #ifdef ANDROID_STUBIFY | ||
| 1184 | error ("Android cross-compilation stub called!"); | ||
| 1185 | return Qnil; | ||
| 1186 | #else | ||
| 1187 | error ("Not implemented"); | ||
| 1188 | return Qnil; | ||
| 1189 | #endif | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, | ||
| 1193 | 0, 1, 0, doc: /* SKIP: real doc in xfns.c. */) | ||
| 1194 | (Lisp_Object terminal) | ||
| 1195 | { | ||
| 1196 | #ifdef ANDROID_STUBIFY | ||
| 1197 | error ("Android cross-compilation stub called!"); | ||
| 1198 | return Qnil; | ||
| 1199 | #else | ||
| 1200 | error ("Not implemented"); | ||
| 1201 | return Qnil; | ||
| 1202 | #endif | ||
| 1203 | } | ||
| 1204 | |||
| 1205 | DEFUN ("x-display-backing-store", Fx_display_backing_store, | ||
| 1206 | Sx_display_backing_store, 0, 1, 0, | ||
| 1207 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1208 | (Lisp_Object terminal) | ||
| 1209 | { | ||
| 1210 | check_android_display_info (terminal); | ||
| 1211 | |||
| 1212 | /* The Java part is implemented in a way that it always does the | ||
| 1213 | equivalent of backing store. */ | ||
| 1214 | return Qalways; | ||
| 1215 | } | ||
| 1216 | |||
| 1217 | DEFUN ("x-display-visual-class", Fx_display_visual_class, | ||
| 1218 | Sx_display_visual_class, 0, 1, 0, | ||
| 1219 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1220 | (Lisp_Object terminal) | ||
| 1221 | { | ||
| 1222 | check_android_display_info (terminal); | ||
| 1223 | |||
| 1224 | return Qtrue_color; | ||
| 1225 | } | ||
| 1226 | |||
| 1227 | DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list, | ||
| 1228 | Sx_display_monitor_attributes_list, | ||
| 1229 | 0, 1, 0, | ||
| 1230 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1231 | (Lisp_Object terminal) | ||
| 1232 | { | ||
| 1233 | #ifdef ANDROID_STUBIFY | ||
| 1234 | error ("Android cross-compilation stub called!"); | ||
| 1235 | return Qnil; | ||
| 1236 | #else | ||
| 1237 | error ("Not implemented"); | ||
| 1238 | return Qnil; | ||
| 1239 | #endif | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, | ||
| 1243 | 0, 1, 0, doc: /* SKIP: real doc in xfns.c. */) | ||
| 1244 | (Lisp_Object terminal) | ||
| 1245 | { | ||
| 1246 | #ifdef ANDROID_STUBIFY | ||
| 1247 | error ("Android cross-compilation stub called!"); | ||
| 1248 | return Qnil; | ||
| 1249 | #else | ||
| 1250 | error ("Not implemented"); | ||
| 1251 | return Qnil; | ||
| 1252 | #endif | ||
| 1253 | } | ||
| 1254 | |||
| 1255 | DEFUN ("x-frame-list-z-order", Fx_frame_list_z_order, | ||
| 1256 | Sx_frame_list_z_order, 0, 1, 0, | ||
| 1257 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1258 | (Lisp_Object terminal) | ||
| 1259 | { | ||
| 1260 | #ifdef ANDROID_STUBIFY | ||
| 1261 | error ("Android cross-compilation stub called!"); | ||
| 1262 | return Qnil; | ||
| 1263 | #else | ||
| 1264 | error ("Not implemented"); | ||
| 1265 | return Qnil; | ||
| 1266 | #endif | ||
| 1267 | } | ||
| 1268 | |||
| 1269 | DEFUN ("x-frame-restack", Fx_frame_restack, Sx_frame_restack, 2, 3, 0, | ||
| 1270 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1271 | (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object frame3) | ||
| 1272 | { | ||
| 1273 | #ifdef ANDROID_STUBIFY | ||
| 1274 | error ("Android cross-compilation stub called!"); | ||
| 1275 | return Qnil; | ||
| 1276 | #else | ||
| 1277 | error ("Not implemented"); | ||
| 1278 | return Qnil; | ||
| 1279 | #endif | ||
| 1280 | } | ||
| 1281 | |||
| 1282 | DEFUN ("x-mouse-absolute-pixel-position", Fx_mouse_absolute_pixel_position, | ||
| 1283 | Sx_mouse_absolute_pixel_position, 0, 0, 0, | ||
| 1284 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1285 | (void) | ||
| 1286 | { | ||
| 1287 | /* TODO: figure out how to implement this. */ | ||
| 1288 | return Qnil; | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | DEFUN ("x-set-mouse-absolute-pixel-position", | ||
| 1292 | Fx_set_mouse_absolute_pixel_position, | ||
| 1293 | Sx_set_mouse_absolute_pixel_position, 2, 2, 0, | ||
| 1294 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1295 | (Lisp_Object x, Lisp_Object y) | ||
| 1296 | { | ||
| 1297 | /* TODO: figure out how to implement this. */ | ||
| 1298 | return Qnil; | ||
| 1299 | } | ||
| 1300 | |||
| 1301 | DEFUN ("android-get-connection", Fandroid_get_connection, | ||
| 1302 | Sandroid_get_connection, 0, 0, 0, | ||
| 1303 | doc: /* Get the connection to the display server. | ||
| 1304 | Return the terminal if it exists, else nil. | ||
| 1305 | |||
| 1306 | Emacs cannot open a connection to the display server itself under | ||
| 1307 | Android, so there is no equivalent of `x-open-connection'. */) | ||
| 1308 | (void) | ||
| 1309 | { | ||
| 1310 | #ifdef ANDROID_STUBIFY | ||
| 1311 | error ("Android cross-compilation stub called!"); | ||
| 1312 | return Qnil; | ||
| 1313 | #else | ||
| 1314 | Lisp_Object terminal; | ||
| 1315 | |||
| 1316 | terminal = Qnil; | ||
| 1317 | |||
| 1318 | if (x_display_list) | ||
| 1319 | XSETTERMINAL (terminal, x_display_list->terminal); | ||
| 1320 | |||
| 1321 | return terminal; | ||
| 1322 | #endif | ||
| 1323 | } | ||
| 1324 | |||
| 1325 | DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, | ||
| 1326 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1327 | (void) | ||
| 1328 | { | ||
| 1329 | Lisp_Object result; | ||
| 1330 | |||
| 1331 | result = Qnil; | ||
| 1332 | |||
| 1333 | if (x_display_list) | ||
| 1334 | result = Fcons (XCAR (x_display_list->name_list_element), | ||
| 1335 | result); | ||
| 1336 | |||
| 1337 | return result; | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, | ||
| 1341 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1342 | (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, | ||
| 1343 | Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy) | ||
| 1344 | { | ||
| 1345 | #ifdef ANDROID_STUBIFY | ||
| 1346 | error ("Android cross-compilation stub called!"); | ||
| 1347 | return Qnil; | ||
| 1348 | #else | ||
| 1349 | error ("Not implemented"); | ||
| 1350 | return Qnil; | ||
| 1351 | #endif | ||
| 1352 | } | ||
| 1353 | |||
| 1354 | DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, | ||
| 1355 | doc: /* SKIP: real doc in xfns.c. */) | ||
| 1356 | (void) | ||
| 1357 | { | ||
| 1358 | #ifdef ANDROID_STUBIFY | ||
| 1359 | error ("Android cross-compilation stub called!"); | ||
| 1360 | return Qnil; | ||
| 1361 | #else | ||
| 1362 | error ("Not implemented"); | ||
| 1363 | return Qnil; | ||
| 1364 | #endif | ||
| 1365 | } | ||
| 1366 | |||
| 1367 | |||
| 1368 | |||
| 1369 | #ifndef ANDROID_STUBIFY | ||
| 1370 | |||
| 1371 | static void | ||
| 1372 | android_set_background_color (struct frame *f, Lisp_Object arg, | ||
| 1373 | Lisp_Object oldval) | ||
| 1374 | { | ||
| 1375 | struct android_output *x; | ||
| 1376 | unsigned long bg; | ||
| 1377 | |||
| 1378 | x = f->output_data.android; | ||
| 1379 | bg = android_decode_color (f, arg, WHITE_PIX_DEFAULT (f)); | ||
| 1380 | FRAME_BACKGROUND_PIXEL (f) = bg; | ||
| 1381 | |||
| 1382 | if (FRAME_ANDROID_WINDOW (f) != 0) | ||
| 1383 | { | ||
| 1384 | block_input (); | ||
| 1385 | android_set_background (x->normal_gc, bg); | ||
| 1386 | android_set_foreground (x->reverse_gc, bg); | ||
| 1387 | android_set_window_background (FRAME_ANDROID_WINDOW (f), bg); | ||
| 1388 | android_set_foreground (x->cursor_gc, bg); | ||
| 1389 | unblock_input (); | ||
| 1390 | |||
| 1391 | update_face_from_frame_parameter (f, Qbackground_color, arg); | ||
| 1392 | |||
| 1393 | if (FRAME_VISIBLE_P (f)) | ||
| 1394 | redraw_frame (f); | ||
| 1395 | } | ||
| 1396 | } | ||
| 1397 | |||
| 1398 | static void | ||
| 1399 | android_set_border_color (struct frame *f, Lisp_Object arg, | ||
| 1400 | Lisp_Object oldval) | ||
| 1401 | { | ||
| 1402 | /* Left unimplemented because Android has no window borders. */ | ||
| 1403 | CHECK_STRING (arg); | ||
| 1404 | android_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); | ||
| 1405 | update_face_from_frame_parameter (f, Qborder_color, arg); | ||
| 1406 | } | ||
| 1407 | |||
| 1408 | static void | ||
| 1409 | android_set_cursor_color (struct frame *f, Lisp_Object arg, | ||
| 1410 | Lisp_Object oldval) | ||
| 1411 | { | ||
| 1412 | unsigned long fore_pixel, pixel; | ||
| 1413 | struct android_output *x; | ||
| 1414 | |||
| 1415 | x = f->output_data.android; | ||
| 1416 | |||
| 1417 | if (!NILP (Vx_cursor_fore_pixel)) | ||
| 1418 | fore_pixel = android_decode_color (f, Vx_cursor_fore_pixel, | ||
| 1419 | WHITE_PIX_DEFAULT (f)); | ||
| 1420 | else | ||
| 1421 | fore_pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 1422 | |||
| 1423 | pixel = android_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); | ||
| 1424 | |||
| 1425 | /* Make sure that the cursor color differs from the background color. */ | ||
| 1426 | if (pixel == FRAME_BACKGROUND_PIXEL (f)) | ||
| 1427 | { | ||
| 1428 | pixel = FRAME_FOREGROUND_PIXEL (f); | ||
| 1429 | if (pixel == fore_pixel) | ||
| 1430 | fore_pixel = FRAME_BACKGROUND_PIXEL (f); | ||
| 1431 | } | ||
| 1432 | |||
| 1433 | x->cursor_foreground_pixel = fore_pixel; | ||
| 1434 | x->cursor_pixel = pixel; | ||
| 1435 | |||
| 1436 | if (FRAME_ANDROID_WINDOW (f) != 0) | ||
| 1437 | { | ||
| 1438 | block_input (); | ||
| 1439 | android_set_background (x->cursor_gc, x->cursor_pixel); | ||
| 1440 | android_set_foreground (x->cursor_gc, fore_pixel); | ||
| 1441 | unblock_input (); | ||
| 1442 | |||
| 1443 | if (FRAME_VISIBLE_P (f)) | ||
| 1444 | { | ||
| 1445 | gui_update_cursor (f, false); | ||
| 1446 | gui_update_cursor (f, true); | ||
| 1447 | } | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | update_face_from_frame_parameter (f, Qcursor_color, arg); | ||
| 1451 | } | ||
| 1452 | |||
| 1453 | static void | ||
| 1454 | android_set_cursor_type (struct frame *f, Lisp_Object arg, | ||
| 1455 | Lisp_Object oldval) | ||
| 1456 | { | ||
| 1457 | set_frame_cursor_types (f, arg); | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | static void | ||
| 1461 | android_set_foreground_color (struct frame *f, Lisp_Object arg, | ||
| 1462 | Lisp_Object oldval) | ||
| 1463 | { | ||
| 1464 | struct android_output *x; | ||
| 1465 | unsigned long fg, old_fg; | ||
| 1466 | |||
| 1467 | x = f->output_data.android; | ||
| 1468 | |||
| 1469 | fg = android_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); | ||
| 1470 | old_fg = FRAME_FOREGROUND_PIXEL (f); | ||
| 1471 | FRAME_FOREGROUND_PIXEL (f) = fg; | ||
| 1472 | |||
| 1473 | if (FRAME_ANDROID_WINDOW (f) != 0) | ||
| 1474 | { | ||
| 1475 | block_input (); | ||
| 1476 | android_set_foreground (x->normal_gc, fg); | ||
| 1477 | android_set_background (x->reverse_gc, fg); | ||
| 1478 | |||
| 1479 | if (x->cursor_pixel == old_fg) | ||
| 1480 | { | ||
| 1481 | x->cursor_pixel = fg; | ||
| 1482 | android_set_background (x->cursor_gc, x->cursor_pixel); | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | unblock_input (); | ||
| 1486 | |||
| 1487 | update_face_from_frame_parameter (f, Qforeground_color, arg); | ||
| 1488 | |||
| 1489 | if (FRAME_VISIBLE_P (f)) | ||
| 1490 | redraw_frame (f); | ||
| 1491 | } | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | static void | ||
| 1495 | android_set_child_frame_border_width (struct frame *f, Lisp_Object arg, | ||
| 1496 | Lisp_Object oldval) | ||
| 1497 | { | ||
| 1498 | int border; | ||
| 1499 | |||
| 1500 | if (NILP (arg)) | ||
| 1501 | border = -1; | ||
| 1502 | else if (RANGED_FIXNUMP (0, arg, INT_MAX)) | ||
| 1503 | border = XFIXNAT (arg); | ||
| 1504 | else | ||
| 1505 | signal_error ("Invalid child frame border width", arg); | ||
| 1506 | |||
| 1507 | if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f)) | ||
| 1508 | { | ||
| 1509 | f->child_frame_border_width = border; | ||
| 1510 | |||
| 1511 | if (FRAME_ANDROID_WINDOW (f)) | ||
| 1512 | { | ||
| 1513 | adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width); | ||
| 1514 | android_clear_under_internal_border (f); | ||
| 1515 | } | ||
| 1516 | } | ||
| 1517 | } | ||
| 1518 | |||
| 1519 | static void | ||
| 1520 | android_set_internal_border_width (struct frame *f, Lisp_Object arg, | ||
| 1521 | Lisp_Object oldval) | ||
| 1522 | { | ||
| 1523 | int border = check_int_nonnegative (arg); | ||
| 1524 | |||
| 1525 | if (border != FRAME_INTERNAL_BORDER_WIDTH (f)) | ||
| 1526 | { | ||
| 1527 | f->internal_border_width = border; | ||
| 1528 | |||
| 1529 | if (FRAME_ANDROID_WINDOW (f)) | ||
| 1530 | { | ||
| 1531 | adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width); | ||
| 1532 | android_clear_under_internal_border (f); | ||
| 1533 | } | ||
| 1534 | } | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | static void | ||
| 1538 | android_set_menu_bar_lines (struct frame *f, Lisp_Object value, | ||
| 1539 | Lisp_Object oldval) | ||
| 1540 | { | ||
| 1541 | int nlines; | ||
| 1542 | int olines = FRAME_MENU_BAR_LINES (f); | ||
| 1543 | |||
| 1544 | /* Right now, menu bars don't work properly in minibuf-only frames; | ||
| 1545 | most of the commands try to apply themselves to the minibuffer | ||
| 1546 | frame itself, and get an error because you can't switch buffers | ||
| 1547 | in or split the minibuffer window. */ | ||
| 1548 | if (FRAME_MINIBUF_ONLY_P (f) || FRAME_PARENT_FRAME (f)) | ||
| 1549 | return; | ||
| 1550 | |||
| 1551 | if (TYPE_RANGED_FIXNUMP (int, value)) | ||
| 1552 | nlines = XFIXNUM (value); | ||
| 1553 | else | ||
| 1554 | nlines = 0; | ||
| 1555 | |||
| 1556 | /* Make sure we redisplay all windows in this frame. */ | ||
| 1557 | fset_redisplay (f); | ||
| 1558 | |||
| 1559 | FRAME_MENU_BAR_LINES (f) = nlines; | ||
| 1560 | FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f); | ||
| 1561 | if (FRAME_ANDROID_WINDOW (f)) | ||
| 1562 | android_clear_under_internal_border (f); | ||
| 1563 | |||
| 1564 | /* If the menu bar height gets changed, the internal border below | ||
| 1565 | the top margin has to be cleared. Also, if the menu bar gets | ||
| 1566 | larger, the area for the added lines has to be cleared except for | ||
| 1567 | the first menu bar line that is to be drawn later. */ | ||
| 1568 | if (nlines != olines) | ||
| 1569 | { | ||
| 1570 | int height = FRAME_INTERNAL_BORDER_WIDTH (f); | ||
| 1571 | int width = FRAME_PIXEL_WIDTH (f); | ||
| 1572 | int y; | ||
| 1573 | |||
| 1574 | adjust_frame_size (f, -1, -1, 3, true, Qmenu_bar_lines); | ||
| 1575 | |||
| 1576 | /* height can be zero here. */ | ||
| 1577 | if (FRAME_ANDROID_WINDOW (f) && height > 0 && width > 0) | ||
| 1578 | { | ||
| 1579 | y = FRAME_TOP_MARGIN_HEIGHT (f); | ||
| 1580 | |||
| 1581 | block_input (); | ||
| 1582 | android_clear_area (FRAME_ANDROID_WINDOW (f), | ||
| 1583 | 0, y, width, height); | ||
| 1584 | unblock_input (); | ||
| 1585 | } | ||
| 1586 | |||
| 1587 | if (nlines > 1 && nlines > olines) | ||
| 1588 | { | ||
| 1589 | y = (olines == 0 ? 1 : olines) * FRAME_LINE_HEIGHT (f); | ||
| 1590 | height = nlines * FRAME_LINE_HEIGHT (f) - y; | ||
| 1591 | |||
| 1592 | block_input (); | ||
| 1593 | android_clear_area (FRAME_ANDROID_WINDOW (f), 0, y, | ||
| 1594 | width, height); | ||
| 1595 | unblock_input (); | ||
| 1596 | } | ||
| 1597 | |||
| 1598 | if (nlines == 0 && WINDOWP (f->menu_bar_window)) | ||
| 1599 | clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix); | ||
| 1600 | } | ||
| 1601 | |||
| 1602 | adjust_frame_glyphs (f); | ||
| 1603 | } | ||
| 1604 | |||
| 1605 | static void | ||
| 1606 | android_set_mouse_color (struct frame *f, Lisp_Object arg, | ||
| 1607 | Lisp_Object oldval) | ||
| 1608 | { | ||
| 1609 | /* Changing the mouse color is unsupported under Android, so this is | ||
| 1610 | left intact. */ | ||
| 1611 | android_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); | ||
| 1612 | } | ||
| 1613 | |||
| 1614 | static void | ||
| 1615 | android_set_title (struct frame *f, Lisp_Object name, | ||
| 1616 | Lisp_Object old_name) | ||
| 1617 | { | ||
| 1618 | /* Don't change the title if it's already NAME. */ | ||
| 1619 | if (EQ (name, f->title)) | ||
| 1620 | return; | ||
| 1621 | |||
| 1622 | update_mode_lines = 38; | ||
| 1623 | |||
| 1624 | fset_title (f, name); | ||
| 1625 | |||
| 1626 | if (NILP (name)) | ||
| 1627 | name = f->name; | ||
| 1628 | else | ||
| 1629 | CHECK_STRING (name); | ||
| 1630 | } | ||
| 1631 | |||
| 1632 | static void | ||
| 1633 | android_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | ||
| 1634 | { | ||
| 1635 | double alpha = 1.0; | ||
| 1636 | double newval[2]; | ||
| 1637 | int i; | ||
| 1638 | Lisp_Object item; | ||
| 1639 | |||
| 1640 | /* N.B. that setting the window alpha is actually unsupported under | ||
| 1641 | Android. */ | ||
| 1642 | |||
| 1643 | for (i = 0; i < 2; i++) | ||
| 1644 | { | ||
| 1645 | newval[i] = 1.0; | ||
| 1646 | if (CONSP (arg)) | ||
| 1647 | { | ||
| 1648 | item = CAR (arg); | ||
| 1649 | arg = CDR (arg); | ||
| 1650 | } | ||
| 1651 | else | ||
| 1652 | item = arg; | ||
| 1653 | |||
| 1654 | if (NILP (item)) | ||
| 1655 | alpha = - 1.0; | ||
| 1656 | else if (FLOATP (item)) | ||
| 1657 | { | ||
| 1658 | alpha = XFLOAT_DATA (item); | ||
| 1659 | if (! (0 <= alpha && alpha <= 1.0)) | ||
| 1660 | args_out_of_range (make_float (0.0), make_float (1.0)); | ||
| 1661 | } | ||
| 1662 | else if (FIXNUMP (item)) | ||
| 1663 | { | ||
| 1664 | EMACS_INT ialpha = XFIXNUM (item); | ||
| 1665 | if (! (0 <= ialpha && ialpha <= 100)) | ||
| 1666 | args_out_of_range (make_fixnum (0), make_fixnum (100)); | ||
| 1667 | alpha = ialpha / 100.0; | ||
| 1668 | } | ||
| 1669 | else | ||
| 1670 | wrong_type_argument (Qnumberp, item); | ||
| 1671 | newval[i] = alpha; | ||
| 1672 | } | ||
| 1673 | |||
| 1674 | for (i = 0; i < 2; i++) | ||
| 1675 | f->alpha[i] = newval[i]; | ||
| 1676 | |||
| 1677 | if (FRAME_TERMINAL (f)->set_frame_alpha_hook) | ||
| 1678 | { | ||
| 1679 | block_input (); | ||
| 1680 | FRAME_TERMINAL (f)->set_frame_alpha_hook (f); | ||
| 1681 | unblock_input (); | ||
| 1682 | } | ||
| 1683 | } | ||
| 1684 | |||
| 1685 | frame_parm_handler android_frame_parm_handlers[] = | ||
| 1686 | { | ||
| 1687 | gui_set_autoraise, | ||
| 1688 | gui_set_autolower, | ||
| 1689 | android_set_background_color, | ||
| 1690 | android_set_border_color, | ||
| 1691 | gui_set_border_width, | ||
| 1692 | android_set_cursor_color, | ||
| 1693 | android_set_cursor_type, | ||
| 1694 | gui_set_font, | ||
| 1695 | android_set_foreground_color, | ||
| 1696 | NULL, | ||
| 1697 | NULL, | ||
| 1698 | android_set_child_frame_border_width, | ||
| 1699 | android_set_internal_border_width, | ||
| 1700 | gui_set_right_divider_width, | ||
| 1701 | gui_set_bottom_divider_width, | ||
| 1702 | android_set_menu_bar_lines, | ||
| 1703 | android_set_mouse_color, | ||
| 1704 | android_explicitly_set_name, | ||
| 1705 | gui_set_scroll_bar_width, | ||
| 1706 | gui_set_scroll_bar_height, | ||
| 1707 | android_set_title, | ||
| 1708 | gui_set_unsplittable, | ||
| 1709 | gui_set_vertical_scroll_bars, | ||
| 1710 | gui_set_horizontal_scroll_bars, | ||
| 1711 | gui_set_visibility, | ||
| 1712 | android_set_tab_bar_lines, | ||
| 1713 | android_set_tool_bar_lines, | ||
| 1714 | NULL, | ||
| 1715 | NULL, | ||
| 1716 | gui_set_screen_gamma, | ||
| 1717 | gui_set_line_spacing, | ||
| 1718 | gui_set_left_fringe, | ||
| 1719 | gui_set_right_fringe, | ||
| 1720 | NULL, | ||
| 1721 | gui_set_fullscreen, | ||
| 1722 | gui_set_font_backend, | ||
| 1723 | android_set_alpha, | ||
| 1724 | NULL, | ||
| 1725 | NULL, | ||
| 1726 | NULL, | ||
| 1727 | NULL, /* x_set_undecorated, */ | ||
| 1728 | NULL, /* x_set_parent_frame, */ | ||
| 1729 | NULL, /* x_set_skip_taskbar, */ | ||
| 1730 | NULL, /* x_set_no_focus_on_map, */ | ||
| 1731 | NULL, /* x_set_no_accept_focus, */ | ||
| 1732 | NULL, /* x_set_z_group, */ | ||
| 1733 | NULL, /* x_set_override_redirect, */ | ||
| 1734 | gui_set_no_special_glyphs, | ||
| 1735 | NULL, /* x_set_alpha_background, */ | ||
| 1736 | NULL, /* x_set_use_frame_synchronization, */ | ||
| 1737 | }; | ||
| 1738 | |||
| 1739 | #endif | ||
| 1740 | |||
| 1741 | |||
| 1742 | |||
| 1743 | void | ||
| 1744 | syms_of_androidfns (void) | ||
| 1745 | { | ||
| 1746 | /* Miscellaneous symbols used by some functions here. */ | ||
| 1747 | DEFSYM (Qtrue_color, "true-color"); | ||
| 1748 | DEFSYM (Qalways, "always"); | ||
| 1749 | |||
| 1750 | DEFVAR_LISP ("x-cursor-fore-pixel", Vx_cursor_fore_pixel, | ||
| 1751 | doc: /* SKIP: real doc in xfns.c. */); | ||
| 1752 | Vx_cursor_fore_pixel = Qnil; | ||
| 1753 | |||
| 1754 | /* Functions defined. */ | ||
| 1755 | defsubr (&Sx_create_frame); | ||
| 1756 | defsubr (&Sxw_color_defined_p); | ||
| 1757 | defsubr (&Sxw_color_values); | ||
| 1758 | defsubr (&Sxw_display_color_p); | ||
| 1759 | defsubr (&Sx_display_grayscale_p); | ||
| 1760 | defsubr (&Sx_display_pixel_width); | ||
| 1761 | defsubr (&Sx_display_pixel_height); | ||
| 1762 | defsubr (&Sx_display_planes); | ||
| 1763 | defsubr (&Sx_display_color_cells); | ||
| 1764 | defsubr (&Sx_display_screens); | ||
| 1765 | defsubr (&Sx_display_mm_width); | ||
| 1766 | defsubr (&Sx_display_mm_height); | ||
| 1767 | defsubr (&Sx_display_backing_store); | ||
| 1768 | defsubr (&Sx_display_visual_class); | ||
| 1769 | defsubr (&Sx_display_monitor_attributes_list); | ||
| 1770 | defsubr (&Sx_frame_geometry); | ||
| 1771 | defsubr (&Sx_frame_list_z_order); | ||
| 1772 | defsubr (&Sx_frame_restack); | ||
| 1773 | defsubr (&Sx_mouse_absolute_pixel_position); | ||
| 1774 | defsubr (&Sx_set_mouse_absolute_pixel_position); | ||
| 1775 | defsubr (&Sandroid_get_connection); | ||
| 1776 | defsubr (&Sx_display_list); | ||
| 1777 | defsubr (&Sx_show_tip); | ||
| 1778 | defsubr (&Sx_hide_tip); | ||
| 1779 | } | ||