This source file includes following definitions.
- android_display_info_for_name
- check_android_display_info
- check_x_display_info
- gamma_correct
- android_defined_color
- android_decode_color
- android_set_parent_frame
- android_implicitly_set_name
- android_explicitly_set_name
- android_set_tool_bar_lines
- android_set_tool_bar_position
- android_change_tool_bar_height
- android_set_tab_bar_lines
- android_change_tab_bar_height
- android_set_scroll_bar_default_height
- android_set_scroll_bar_default_width
- android_icon_verify
- android_icon
- android_make_gc
- android_free_gcs
- unwind_create_frame
- do_unwind_create_frame
- android_default_font_parameter
- android_create_frame_window
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- android_make_monitor_attribute_list
- DEFUN
- frame_geometry
- DEFUN
- android_frame_list_z_order
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- unwind_create_tip_frame
- android_create_tip_frame
- android_hide_tip
- compute_tip_xy
- DEFUN
- DEFUN
- android_set_background_color
- android_set_border_color
- android_set_cursor_color
- android_set_cursor_type
- android_set_foreground_color
- android_set_child_frame_border_width
- android_set_internal_border_width
- android_set_menu_bar_lines
- android_set_mouse_color
- android_set_title
- android_set_alpha
- android_set_no_focus_on_map
- android_set_no_accept_focus
- DEFUN
- DEFUN
- android_set_preeditarea
- syms_of_androidfns
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21 #include <math.h>
22
23 #include "lisp.h"
24 #include "android.h"
25 #include "androidterm.h"
26 #include "blockinput.h"
27 #include "keyboard.h"
28 #include "buffer.h"
29 #include "androidgui.h"
30
31 #ifndef ANDROID_STUBIFY
32
33
34 static ptrdiff_t image_cache_refcount;
35
36
37 static Lisp_Object tip_frame;
38
39
40
41 static android_window tip_window;
42
43
44 static Lisp_Object tip_dx, tip_dy;
45
46
47
48 static Lisp_Object tip_timer;
49
50
51 static Lisp_Object tip_last_string;
52
53
54 static Lisp_Object tip_last_frame;
55
56
57 static Lisp_Object tip_last_parms;
58
59 #endif
60
61 static struct android_display_info *
62 android_display_info_for_name (Lisp_Object name)
63 {
64 struct android_display_info *dpyinfo;
65
66 CHECK_STRING (name);
67
68 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
69 {
70 if (!NILP (Fstring_equal (XCAR (dpyinfo->name_list_element),
71 name)))
72 return dpyinfo;
73 }
74
75 error ("Cannot connect to Android if it was not initialized"
76 " at startup");
77 }
78
79 static struct android_display_info *
80 check_android_display_info (Lisp_Object object)
81 {
82 struct android_display_info *dpyinfo;
83 struct frame *sf, *f;
84 struct terminal *t;
85
86 if (NILP (object))
87 {
88 sf = XFRAME (selected_frame);
89
90 if (FRAME_ANDROID_P (sf) && FRAME_LIVE_P (sf))
91 dpyinfo = FRAME_DISPLAY_INFO (sf);
92 else if (x_display_list)
93 dpyinfo = x_display_list;
94 else
95 error ("Android windows are not in use or not initialized");
96 }
97 else if (TERMINALP (object))
98 {
99 t = decode_live_terminal (object);
100
101 if (t->type != output_android)
102 error ("Terminal %d is not an Android display", t->id);
103
104 dpyinfo = t->display_info.android;
105 }
106 else if (STRINGP (object))
107 dpyinfo = android_display_info_for_name (object);
108 else
109 {
110 f = decode_window_system_frame (object);
111 dpyinfo = FRAME_DISPLAY_INFO (f);
112 }
113
114 return dpyinfo;
115 }
116
117 Display_Info *
118 check_x_display_info (Lisp_Object object)
119 {
120 return check_android_display_info (object);
121 }
122
123
124
125 #ifndef ANDROID_STUBIFY
126
127 void
128 gamma_correct (struct frame *f, Emacs_Color *color)
129 {
130 if (f->gamma)
131 {
132 color->red = pow (color->red / 65535.0, f->gamma) * 65535.0 + 0.5;
133 color->green = pow (color->green / 65535.0, f->gamma) * 65535.0 + 0.5;
134 color->blue = pow (color->blue / 65535.0, f->gamma) * 65535.0 + 0.5;
135 }
136 }
137
138
139
140
141
142
143
144 bool
145 android_defined_color (struct frame *f, const char *color_name,
146 Emacs_Color *color, bool alloc_p,
147 bool make_index)
148 {
149 bool success_p;
150
151 success_p = false;
152
153 block_input ();
154 success_p = android_parse_color (f, color_name, color);
155 if (success_p && alloc_p)
156 success_p = android_alloc_nearest_color (f, color);
157 unblock_input ();
158
159 return success_p;
160 }
161
162
163
164
165
166 static unsigned long
167 android_decode_color (struct frame *f, Lisp_Object color_name, int mono_color)
168 {
169 Emacs_Color cdef;
170
171 CHECK_STRING (color_name);
172
173 if (android_defined_color (f, SSDATA (color_name), &cdef,
174 true, false))
175 return cdef.pixel;
176
177 signal_error ("Undefined color", color_name);
178 }
179
180 static void
181 android_set_parent_frame (struct frame *f, Lisp_Object new_value,
182 Lisp_Object old_value)
183 {
184 struct frame *p;
185
186 p = NULL;
187
188 if (!NILP (new_value)
189 && (!FRAMEP (new_value)
190 || !FRAME_LIVE_P (p = XFRAME (new_value))
191 || !FRAME_ANDROID_P (p)))
192 {
193 store_frame_param (f, Qparent_frame, old_value);
194 error ("Invalid specification of `parent-frame'");
195 }
196
197 if (p != FRAME_PARENT_FRAME (f))
198 {
199 block_input ();
200 android_reparent_window (FRAME_ANDROID_WINDOW (f),
201 (p ? FRAME_ANDROID_WINDOW (p)
202 : FRAME_DISPLAY_INFO (f)->root_window),
203 f->left_pos, f->top_pos);
204 unblock_input ();
205
206 fset_parent_frame (f, new_value);
207 }
208
209
210 FRAME_TERMINAL (f)->fullscreen_hook (f);
211 }
212
213 void
214 android_implicitly_set_name (struct frame *f, Lisp_Object arg,
215 Lisp_Object oldval)
216 {
217
218 }
219
220 void
221 android_explicitly_set_name (struct frame *f, Lisp_Object arg,
222 Lisp_Object oldval)
223 {
224
225 }
226
227
228
229
230
231
232
233 static void
234 android_set_tool_bar_lines (struct frame *f, Lisp_Object value,
235 Lisp_Object oldval)
236 {
237 int nlines;
238
239
240 if (FRAME_MINIBUF_ONLY_P (f))
241 return;
242
243
244 if (RANGED_FIXNUMP (0, value, INT_MAX))
245 nlines = XFIXNAT (value);
246 else
247 nlines = 0;
248
249 android_change_tool_bar_height (f, nlines * FRAME_LINE_HEIGHT (f));
250 }
251
252 static void
253 android_set_tool_bar_position (struct frame *f,
254 Lisp_Object new_value,
255 Lisp_Object old_value)
256 {
257 if (!EQ (new_value, Qtop) && !EQ (new_value, Qbottom))
258 error ("Tool bar position must be either `top' or `bottom'");
259
260 if (EQ (new_value, old_value))
261 return;
262
263
264 fset_tool_bar_position (f, new_value);
265
266
267
268
269
270
271 adjust_frame_size (f, -1, -1, 3, false, Qtool_bar_position);
272 adjust_frame_glyphs (f);
273 SET_FRAME_GARBAGED (f);
274
275 if (FRAME_ANDROID_WINDOW (f))
276 android_clear_under_internal_border (f);
277 }
278
279 void
280 android_change_tool_bar_height (struct frame *f, int height)
281 {
282 int unit = FRAME_LINE_HEIGHT (f);
283 int old_height = FRAME_TOOL_BAR_HEIGHT (f);
284 int lines = (height + unit - 1) / unit;
285 Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
286
287
288 fset_redisplay (f);
289
290 FRAME_TOOL_BAR_HEIGHT (f) = height;
291 FRAME_TOOL_BAR_LINES (f) = lines;
292 store_frame_param (f, Qtool_bar_lines, make_fixnum (lines));
293
294 if (FRAME_ANDROID_WINDOW (f) && FRAME_TOOL_BAR_HEIGHT (f) == 0)
295 {
296 clear_frame (f);
297 clear_current_matrices (f);
298 }
299
300 if ((height < old_height) && WINDOWP (f->tool_bar_window))
301 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
302
303 if (!f->tool_bar_resized)
304 {
305
306
307 if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth))
308 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
309 1, false, Qtool_bar_lines);
310 else
311 adjust_frame_size (f, -1, -1, 4, false, Qtool_bar_lines);
312
313 f->tool_bar_resized = f->tool_bar_redisplayed;
314 }
315 else
316
317 adjust_frame_size (f, -1, -1, 3, false, Qtool_bar_lines);
318
319
320
321 adjust_frame_glyphs (f);
322 SET_FRAME_GARBAGED (f);
323 }
324
325
326
327
328
329
330
331
332 static void
333 android_set_tab_bar_lines (struct frame *f, Lisp_Object value,
334 Lisp_Object oldval)
335 {
336 int olines;
337 int nlines;
338
339 olines = FRAME_TAB_BAR_LINES (f);
340
341
342 if (FRAME_MINIBUF_ONLY_P (f))
343 return;
344
345
346 if (RANGED_FIXNUMP (0, value, INT_MAX))
347 nlines = XFIXNAT (value);
348 else
349 nlines = 0;
350
351 if (nlines != olines && (olines == 0 || nlines == 0))
352 android_change_tab_bar_height (f, nlines * FRAME_LINE_HEIGHT (f));
353 }
354
355 void
356 android_change_tab_bar_height (struct frame *f, int height)
357 {
358 int unit, old_height, lines;
359 Lisp_Object fullscreen;
360
361 unit = FRAME_LINE_HEIGHT (f);
362 old_height = FRAME_TAB_BAR_HEIGHT (f);
363 fullscreen = get_frame_param (f, Qfullscreen);
364
365
366
367
368
369
370 lines = height / unit;
371
372
373 fset_redisplay (f);
374
375
376 FRAME_TAB_BAR_HEIGHT (f) = height;
377 FRAME_TAB_BAR_LINES (f) = lines;
378 store_frame_param (f, Qtab_bar_lines, make_fixnum (lines));
379
380 if (FRAME_ANDROID_WINDOW (f) && FRAME_TAB_BAR_HEIGHT (f) == 0)
381 {
382 clear_frame (f);
383 clear_current_matrices (f);
384 }
385
386 if ((height < old_height) && WINDOWP (f->tab_bar_window))
387 clear_glyph_matrix (XWINDOW (f->tab_bar_window)->current_matrix);
388
389 if (!f->tab_bar_resized)
390 {
391
392
393 if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth))
394 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
395 1, false, Qtab_bar_lines);
396 else
397 adjust_frame_size (f, -1, -1, 4, false, Qtab_bar_lines);
398
399 f->tab_bar_resized = f->tab_bar_redisplayed;
400 }
401 else
402
403 adjust_frame_size (f, -1, -1, 3, false, Qtab_bar_lines);
404
405
406
407 adjust_frame_glyphs (f);
408 SET_FRAME_GARBAGED (f);
409 }
410
411 void
412 android_set_scroll_bar_default_height (struct frame *f)
413 {
414 int height;
415
416 height = FRAME_LINE_HEIGHT (f);
417
418
419 FRAME_CONFIG_SCROLL_BAR_LINES (f) = (14 + height - 1) / height;
420
421
422
423 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = 14;
424 }
425
426 void
427 android_set_scroll_bar_default_width (struct frame *f)
428 {
429 int unit;
430
431 unit = FRAME_COLUMN_WIDTH (f);
432
433 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + unit - 1) / unit;
434 FRAME_CONFIG_SCROLL_BAR_WIDTH (f)
435 = FRAME_CONFIG_SCROLL_BAR_COLS (f) * unit;
436 }
437
438
439
440
441 static void
442 android_icon_verify (struct frame *f, Lisp_Object parms)
443 {
444 Lisp_Object icon_x, icon_y;
445
446
447
448 icon_x = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0,
449 RES_TYPE_NUMBER);
450 icon_y = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0,
451 RES_TYPE_NUMBER);
452
453 if (!BASE_EQ (icon_x, Qunbound) && !BASE_EQ (icon_y, Qunbound))
454 {
455 CHECK_FIXNUM (icon_x);
456 CHECK_FIXNUM (icon_y);
457 }
458 else if (!BASE_EQ (icon_x, Qunbound) || !BASE_EQ (icon_y, Qunbound))
459 error ("Both left and top icon corners of icon must be specified");
460 }
461
462
463
464
465
466 static void
467 android_icon (struct frame *f, Lisp_Object parms)
468 {
469
470
471 Lisp_Object icon_x
472 = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0,
473 RES_TYPE_NUMBER);
474 Lisp_Object icon_y
475 = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0,
476 RES_TYPE_NUMBER);
477
478 bool xgiven = !BASE_EQ (icon_x, Qunbound);
479 bool ygiven = !BASE_EQ (icon_y, Qunbound);
480
481 if (xgiven != ygiven)
482 error ("Both left and top icon corners of icon must be specified");
483
484 if (xgiven)
485 {
486 check_integer_range (icon_x, INT_MIN, INT_MAX);
487 check_integer_range (icon_y, INT_MIN, INT_MAX);
488 }
489
490
491 }
492
493
494
495
496 static void
497 android_make_gc (struct frame *f)
498 {
499 struct android_gc_values gc_values;
500
501 block_input ();
502
503
504
505
506 gc_values.foreground = FRAME_FOREGROUND_PIXEL (f);
507 gc_values.background = FRAME_BACKGROUND_PIXEL (f);
508 f->output_data.android->normal_gc
509 = android_create_gc (ANDROID_GC_FOREGROUND | ANDROID_GC_BACKGROUND,
510 &gc_values);
511
512
513 gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
514 gc_values.background = FRAME_FOREGROUND_PIXEL (f);
515 f->output_data.android->reverse_gc
516 = android_create_gc (ANDROID_GC_FOREGROUND | ANDROID_GC_BACKGROUND,
517 &gc_values);
518
519
520 gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
521 gc_values.background = f->output_data.android->cursor_pixel;
522 f->output_data.android->cursor_gc
523 = android_create_gc (ANDROID_GC_FOREGROUND | ANDROID_GC_BACKGROUND,
524 &gc_values);
525 unblock_input ();
526 }
527
528
529
530
531 void
532 android_free_gcs (struct frame *f)
533 {
534 block_input ();
535
536 if (f->output_data.android->normal_gc)
537 {
538 android_free_gc (f->output_data.android->normal_gc);
539 f->output_data.android->normal_gc = 0;
540 }
541
542 if (f->output_data.android->reverse_gc)
543 {
544 android_free_gc (f->output_data.android->reverse_gc);
545 f->output_data.android->reverse_gc = 0;
546 }
547
548 if (f->output_data.android->cursor_gc)
549 {
550 android_free_gc (f->output_data.android->cursor_gc);
551 f->output_data.android->cursor_gc = 0;
552 }
553
554 unblock_input ();
555 }
556
557
558
559
560
561 static Lisp_Object
562 unwind_create_frame (Lisp_Object frame)
563 {
564 struct frame *f = XFRAME (frame);
565
566
567
568
569 if (!FRAME_LIVE_P (f))
570 return Qnil;
571
572
573 if (NILP (Fmemq (frame, Vframe_list)))
574 {
575
576
577
578
579
580
581
582 if (FRAME_IMAGE_CACHE (f) != NULL
583 && FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount)
584 FRAME_IMAGE_CACHE (f)->refcount++;
585
586 android_free_frame_resources (f);
587 free_glyphs (f);
588 return Qt;
589 }
590
591 return Qnil;
592 }
593
594 static void
595 do_unwind_create_frame (Lisp_Object frame)
596 {
597 unwind_create_frame (frame);
598 }
599
600 void
601 android_default_font_parameter (struct frame *f, Lisp_Object parms)
602 {
603 struct android_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
604 Lisp_Object font_param = gui_display_get_arg (dpyinfo, parms, Qfont, NULL, NULL,
605 RES_TYPE_STRING);
606 Lisp_Object font = Qnil;
607 if (BASE_EQ (font_param, Qunbound))
608 font_param = Qnil;
609
610 if (NILP (font))
611 font = (!NILP (font_param)
612 ? font_param
613 : gui_display_get_arg (dpyinfo, parms,
614 Qfont, "font", "Font",
615 RES_TYPE_STRING));
616
617 if (! FONTP (font) && ! STRINGP (font))
618 {
619 const char *names[] = {
620 "Droid Sans Mono-12",
621 "Monospace-12",
622 "DroidSansMono-12",
623 NULL
624 };
625 int i;
626
627 for (i = 0; names[i]; i++)
628 {
629 font = font_open_by_name (f, build_unibyte_string (names[i]));
630 if (! NILP (font))
631 break;
632 }
633
634 if (NILP (font))
635 error ("No suitable font was found");
636 }
637
638 gui_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING);
639 }
640
641 static void
642 android_create_frame_window (struct frame *f)
643 {
644 struct android_set_window_attributes attributes;
645 enum android_window_value_mask attribute_mask;
646
647 attributes.background_pixel = FRAME_BACKGROUND_PIXEL (f);
648 attribute_mask = ANDROID_CW_BACK_PIXEL;
649
650 block_input ();
651 FRAME_ANDROID_WINDOW (f)
652 = android_create_window (FRAME_DISPLAY_INFO (f)->root_window,
653 f->left_pos,
654 f->top_pos,
655 FRAME_PIXEL_WIDTH (f),
656 FRAME_PIXEL_HEIGHT (f),
657 attribute_mask, &attributes);
658 unblock_input ();
659 }
660
661 #endif
662
663
664
665 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
666 1, 1, 0,
667 doc: )
668 (Lisp_Object parms)
669 {
670 #ifdef ANDROID_STUBIFY
671 error ("Android cross-compilation stub called!");
672 return Qnil;
673 #else
674 struct frame *f;
675 Lisp_Object frame, tem;
676 Lisp_Object name;
677 bool minibuffer_only;
678 bool undecorated, override_redirect;
679 long window_prompting;
680 specpdl_ref count;
681 Lisp_Object display;
682 struct android_display_info *dpyinfo;
683 Lisp_Object parent, parent_frame;
684 struct kboard *kb;
685
686 minibuffer_only = false;
687 undecorated = false;
688 override_redirect = false;
689 window_prompting = 0;
690 count = SPECPDL_INDEX ();
691 dpyinfo = NULL;
692
693
694 ((void) window_prompting);
695
696 parms = Fcopy_alist (parms);
697
698
699
700 Vx_resource_name = Vinvocation_name;
701
702 display = gui_display_get_arg (dpyinfo, parms, Qterminal, 0, 0,
703 RES_TYPE_NUMBER);
704 if (BASE_EQ (display, Qunbound))
705 display = gui_display_get_arg (dpyinfo, parms, Qdisplay, 0, 0,
706 RES_TYPE_STRING);
707 if (BASE_EQ (display, Qunbound))
708 display = Qnil;
709 dpyinfo = check_android_display_info (display);
710 kb = dpyinfo->terminal->kboard;
711
712 if (!dpyinfo->terminal->name)
713 error ("Terminal is not live, can't create new frames on it");
714
715 name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
716 RES_TYPE_STRING);
717 if (!STRINGP (name)
718 && ! BASE_EQ (name, Qunbound)
719 && ! NILP (name))
720 error ("Invalid frame name--not a string or nil");
721
722 if (STRINGP (name))
723 Vx_resource_name = name;
724
725
726 parent = gui_display_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL,
727 RES_TYPE_NUMBER);
728 if (BASE_EQ (parent, Qunbound))
729 parent = Qnil;
730 if (! NILP (parent))
731 CHECK_FIXNUM (parent);
732
733 frame = Qnil;
734 tem = gui_display_get_arg (dpyinfo,
735 parms, Qminibuffer, "minibuffer", "Minibuffer",
736 RES_TYPE_SYMBOL);
737 if (EQ (tem, Qnone) || NILP (tem))
738 f = make_frame_without_minibuffer (Qnil, kb, display);
739 else if (EQ (tem, Qonly))
740 {
741 f = make_minibuffer_frame ();
742 minibuffer_only = true;
743 }
744 else if (WINDOWP (tem))
745 f = make_frame_without_minibuffer (tem, kb, display);
746 else
747 f = make_frame (true);
748
749 parent_frame = gui_display_get_arg (dpyinfo,
750 parms,
751 Qparent_frame,
752 NULL,
753 NULL,
754 RES_TYPE_SYMBOL);
755
756 if (!NILP (parent)
757 || BASE_EQ (parent_frame, Qunbound)
758 || NILP (parent_frame)
759 || !FRAMEP (parent_frame)
760 || !FRAME_LIVE_P (XFRAME (parent_frame))
761 || !FRAME_ANDROID_P (XFRAME (parent_frame)))
762 parent_frame = Qnil;
763
764 fset_parent_frame (f, parent_frame);
765 store_frame_param (f, Qparent_frame, parent_frame);
766
767 if (!NILP (tem = (gui_display_get_arg (dpyinfo,
768 parms,
769 Qundecorated,
770 NULL,
771 NULL,
772 RES_TYPE_BOOLEAN)))
773 && !(BASE_EQ (tem, Qunbound)))
774 undecorated = true;
775
776 FRAME_UNDECORATED (f) = undecorated;
777 store_frame_param (f, Qundecorated, undecorated ? Qt : Qnil);
778
779 if (!NILP (tem = (gui_display_get_arg (dpyinfo,
780 parms,
781 Qoverride_redirect,
782 NULL,
783 NULL,
784 RES_TYPE_BOOLEAN)))
785 && !(BASE_EQ (tem, Qunbound)))
786 override_redirect = true;
787
788 FRAME_OVERRIDE_REDIRECT (f) = override_redirect;
789 store_frame_param (f, Qoverride_redirect, override_redirect ? Qt : Qnil);
790
791 XSETFRAME (frame, f);
792
793 f->terminal = dpyinfo->terminal;
794
795 f->output_method = output_android;
796 f->output_data.android = xzalloc (sizeof *f->output_data.android);
797 FRAME_FONTSET (f) = -1;
798 f->output_data.android->scroll_bar_foreground_pixel = -1;
799 f->output_data.android->scroll_bar_background_pixel = -1;
800 f->output_data.android->white_relief.pixel = -1;
801 f->output_data.android->black_relief.pixel = -1;
802
803 fset_icon_name (f, gui_display_get_arg (dpyinfo,
804 parms,
805 Qicon_name,
806 "iconName",
807 "Title",
808 RES_TYPE_STRING));
809 if (! STRINGP (f->icon_name))
810 fset_icon_name (f, Qnil);
811
812 FRAME_DISPLAY_INFO (f) = dpyinfo;
813
814
815 record_unwind_protect (do_unwind_create_frame, frame);
816
817
818
819
820
821
822 {
823 Lisp_Object black;
824
825
826
827
828 FRAME_FOREGROUND_PIXEL (f) = -1;
829 FRAME_BACKGROUND_PIXEL (f) = -1;
830 f->output_data.android->cursor_pixel = -1;
831 f->output_data.android->cursor_foreground_pixel = -1;
832 f->output_data.android->mouse_pixel = -1;
833
834 black = build_string ("black");
835 FRAME_FOREGROUND_PIXEL (f)
836 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
837 FRAME_BACKGROUND_PIXEL (f)
838 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
839 f->output_data.android->cursor_pixel
840 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
841 f->output_data.android->cursor_foreground_pixel
842 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
843 f->output_data.android->mouse_pixel
844 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
845 }
846
847
848
849 if (BASE_EQ (name, Qunbound) || NILP (name))
850 {
851 fset_name (f, build_string ("GNU Emacs"));
852 f->explicit_name = false;
853 }
854 else
855 {
856 fset_name (f, name);
857 f->explicit_name = true;
858
859 specbind (Qx_resource_name, name);
860 }
861
862 register_font_driver (&androidfont_driver, f);
863 register_font_driver (&android_sfntfont_driver, f);
864
865 image_cache_refcount = (FRAME_IMAGE_CACHE (f)
866 ? FRAME_IMAGE_CACHE (f)->refcount
867 : 0);
868
869 gui_default_parameter (f, parms, Qfont_backend, Qnil,
870 "fontBackend", "FontBackend", RES_TYPE_STRING);
871
872
873
874 android_default_font_parameter (f, parms);
875 if (!FRAME_FONT (f))
876 {
877 delete_frame (frame, Qnoelisp);
878 error ("Invalid frame font");
879 }
880
881 if (NILP (Fassq (Qinternal_border_width, parms)))
882 {
883 Lisp_Object value;
884
885 value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
886 "internalBorder", "internalBorder",
887 RES_TYPE_NUMBER);
888 if (! BASE_EQ (value, Qunbound))
889 parms = Fcons (Fcons (Qinternal_border_width, value),
890 parms);
891 }
892
893 gui_default_parameter (f, parms, Qinternal_border_width,
894 make_fixnum (0),
895 "internalBorderWidth", "internalBorderWidth",
896 RES_TYPE_NUMBER);
897
898
899 if (NILP (Fassq (Qchild_frame_border_width, parms)))
900 {
901 Lisp_Object value;
902
903 value = gui_display_get_arg (dpyinfo, parms, Qchild_frame_border_width,
904 "childFrameBorder", "childFrameBorder",
905 RES_TYPE_NUMBER);
906 if (! BASE_EQ (value, Qunbound))
907 parms = Fcons (Fcons (Qchild_frame_border_width, value),
908 parms);
909 }
910
911 gui_default_parameter (f, parms, Qchild_frame_border_width, Qnil,
912 "childFrameBorderWidth", "childFrameBorderWidth",
913 RES_TYPE_NUMBER);
914 gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
915 NULL, NULL, RES_TYPE_NUMBER);
916 gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
917 NULL, NULL, RES_TYPE_NUMBER);
918
919
920
921
922 gui_default_parameter (f, parms, Qvertical_scroll_bars, Qnil,
923 "verticalScrollBars", "ScrollBars",
924 RES_TYPE_SYMBOL);
925 gui_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil,
926 "horizontalScrollBars", "ScrollBars",
927 RES_TYPE_SYMBOL);
928
929
930 gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
931 "foreground", "Foreground", RES_TYPE_STRING);
932 gui_default_parameter (f, parms, Qbackground_color, build_string ("white"),
933 "background", "Background", RES_TYPE_STRING);
934 gui_default_parameter (f, parms, Qmouse_color, build_string ("black"),
935 "pointerColor", "Foreground", RES_TYPE_STRING);
936 gui_default_parameter (f, parms, Qborder_color, build_string ("black"),
937 "borderColor", "BorderColor", RES_TYPE_STRING);
938 gui_default_parameter (f, parms, Qscreen_gamma, Qnil,
939 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
940 gui_default_parameter (f, parms, Qline_spacing, Qnil,
941 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
942 gui_default_parameter (f, parms, Qleft_fringe, Qnil,
943 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
944 gui_default_parameter (f, parms, Qright_fringe, Qnil,
945 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
946 gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
947 NULL, NULL, RES_TYPE_BOOLEAN);
948
949 #if 0
950 android_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground,
951 "scrollBarForeground",
952 "ScrollBarForeground", true);
953 android_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_background,
954 "scrollBarBackground",
955 "ScrollBarBackground", false);
956 #endif
957
958
959
960
961
962
963 init_frame_faces (f);
964
965 tem = gui_display_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL,
966 RES_TYPE_NUMBER);
967 if (FIXNUMP (tem))
968 store_frame_param (f, Qmin_width, tem);
969 tem = gui_display_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL,
970 RES_TYPE_NUMBER);
971 if (FIXNUMP (tem))
972 store_frame_param (f, Qmin_height, tem);
973
974 adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
975 FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, true,
976 Qx_create_frame_1);
977
978
979
980
981
982
983 gui_default_parameter (f, parms, Qmenu_bar_lines,
984 NILP (Vmenu_bar_mode)
985 ? make_fixnum (0) : make_fixnum (1),
986 NULL, NULL, RES_TYPE_NUMBER);
987 gui_default_parameter (f, parms, Qtab_bar_lines,
988 NILP (Vtab_bar_mode)
989 ? make_fixnum (0) : make_fixnum (1),
990 NULL, NULL, RES_TYPE_NUMBER);
991 gui_default_parameter (f, parms, Qtool_bar_lines,
992 NILP (Vtool_bar_mode)
993 ? make_fixnum (0) : make_fixnum (1),
994 NULL, NULL, RES_TYPE_NUMBER);
995
996 gui_default_parameter (f, parms, Qbuffer_predicate, Qnil,
997 "bufferPredicate", "BufferPredicate",
998 RES_TYPE_SYMBOL);
999 gui_default_parameter (f, parms, Qtitle, Qnil,
1000 "title", "Title", RES_TYPE_STRING);
1001 gui_default_parameter (f, parms, Qwait_for_wm, Qt,
1002 "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN);
1003 gui_default_parameter (f, parms, Qtool_bar_position,
1004 FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL);
1005 gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil,
1006 "inhibitDoubleBuffering", "InhibitDoubleBuffering",
1007 RES_TYPE_BOOLEAN);
1008
1009
1010 window_prompting = gui_figure_window_size (f, parms, true, true);
1011
1012 tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0,
1013 RES_TYPE_BOOLEAN);
1014 f->no_split = minibuffer_only || EQ (tem, Qt);
1015
1016 android_icon_verify (f, parms);
1017 android_create_frame_window (f);
1018 android_icon (f, parms);
1019 android_make_gc (f);
1020
1021
1022 f->terminal->reference_count++;
1023 Vframe_list = Fcons (frame, Vframe_list);
1024
1025
1026
1027
1028 gui_default_parameter (f, parms, Qicon_type, Qt,
1029 "bitmapIcon", "BitmapIcon", RES_TYPE_BOOLEAN);
1030
1031 gui_default_parameter (f, parms, Qauto_raise, Qnil,
1032 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1033 gui_default_parameter (f, parms, Qauto_lower, Qnil,
1034 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1035 gui_default_parameter (f, parms, Qcursor_type, Qbox,
1036 "cursorType", "CursorType", RES_TYPE_SYMBOL);
1037
1038
1039 gui_default_parameter (f, parms, Qscroll_bar_width, Qnil,
1040 "scrollBarWidth", "ScrollBarWidth",
1041 RES_TYPE_NUMBER);
1042 gui_default_parameter (f, parms, Qscroll_bar_height, Qnil,
1043 "scrollBarHeight", "ScrollBarHeight",
1044 RES_TYPE_NUMBER);
1045 gui_default_parameter (f, parms, Qalpha, Qnil,
1046 "alpha", "Alpha", RES_TYPE_NUMBER);
1047 gui_default_parameter (f, parms, Qalpha_background, Qnil,
1048 "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
1049
1050 if (!NILP (parent_frame))
1051 {
1052 struct frame *p = XFRAME (parent_frame);
1053
1054 block_input ();
1055 android_reparent_window (FRAME_ANDROID_WINDOW (f),
1056 FRAME_ANDROID_WINDOW (p),
1057 f->left_pos, f->top_pos);
1058 unblock_input ();
1059 }
1060
1061 gui_default_parameter (f, parms, Qno_focus_on_map, Qnil,
1062 NULL, NULL, RES_TYPE_BOOLEAN);
1063 gui_default_parameter (f, parms, Qno_accept_focus, Qnil,
1064 NULL, NULL, RES_TYPE_BOOLEAN);
1065
1066
1067 f->can_set_window_size = true;
1068
1069 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
1070 0, true, Qx_create_frame_2);
1071
1072
1073
1074
1075
1076 gui_default_parameter (f, parms, Qfullscreen, Qmaximized,
1077 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
1078
1079
1080
1081 Lisp_Object visibility
1082 = gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
1083 RES_TYPE_SYMBOL);
1084 Lisp_Object height
1085 = gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
1086 Lisp_Object width
1087 = gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
1088
1089 if (EQ (visibility, Qicon))
1090 {
1091 f->was_invisible = true;
1092 android_iconify_frame (f);
1093 }
1094 else
1095 {
1096 if (BASE_EQ (visibility, Qunbound))
1097 visibility = Qt;
1098
1099 if (!NILP (visibility))
1100 android_make_frame_visible (f);
1101 else
1102 f->was_invisible = true;
1103 }
1104
1105
1106
1107
1108 f->was_invisible
1109 = (f->was_invisible
1110 && (!BASE_EQ (height, Qunbound) || !BASE_EQ (width, Qunbound)));
1111
1112 store_frame_param (f, Qvisibility, visibility);
1113
1114
1115 gui_default_parameter (f, parms, Quse_frame_synchronization, Qt,
1116 NULL, NULL, RES_TYPE_BOOLEAN);
1117
1118
1119 gui_default_parameter (f, parms, Qskip_taskbar, Qnil,
1120 NULL, NULL, RES_TYPE_BOOLEAN);
1121
1122 gui_default_parameter (f, parms, Qz_group, Qnil,
1123 NULL, NULL, RES_TYPE_SYMBOL);
1124
1125
1126
1127 if (FRAME_HAS_MINIBUF_P (f)
1128 && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame))
1129 || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
1130 kset_default_minibuffer_frame (kb, frame);
1131
1132
1133
1134
1135 for (tem = parms; CONSP (tem); tem = XCDR (tem))
1136 if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
1137 fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
1138
1139
1140
1141 Vwindow_list = Qnil;
1142
1143 return unbind_to (count, frame);
1144 #endif
1145 }
1146
1147 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p,
1148 1, 2, 0, doc: )
1149 (Lisp_Object color, Lisp_Object frame)
1150 {
1151 #ifdef ANDROID_STUBIFY
1152 error ("Android cross-compilation stub called!");
1153 return Qnil;
1154 #else
1155 Emacs_Color foo;
1156 struct frame *f;
1157
1158 f = decode_window_system_frame (frame);
1159
1160 CHECK_STRING (color);
1161
1162 if (android_defined_color (f, SSDATA (color), &foo, false, false))
1163 return Qt;
1164 else
1165 return Qnil;
1166 #endif
1167 }
1168
1169 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2,
1170 0, doc: )
1171 (Lisp_Object color, Lisp_Object frame)
1172 {
1173 #ifdef ANDROID_STUBIFY
1174 error ("Android cross-compilation stub called!");
1175 return Qnil;
1176 #else
1177 Emacs_Color foo;
1178 struct frame *f;
1179
1180 f = decode_window_system_frame (frame);
1181
1182 CHECK_STRING (color);
1183
1184 if (android_defined_color (f, SSDATA (color), &foo, false, false))
1185 return list3i (foo.red, foo.green, foo.blue);
1186 else
1187 return Qnil;
1188 #endif
1189 }
1190
1191 DEFUN ("xw-display-color-p", Fxw_display_color_p,
1192 Sxw_display_color_p, 0, 1, 0,
1193 doc: )
1194 (Lisp_Object terminal)
1195 {
1196 return Qt;
1197 }
1198
1199 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p,
1200 Sx_display_grayscale_p, 0, 1, 0,
1201 doc: )
1202 (Lisp_Object terminal)
1203 {
1204 return Qnil;
1205 }
1206
1207 DEFUN ("x-display-pixel-width", Fx_display_pixel_width,
1208 Sx_display_pixel_width, 0, 1, 0,
1209 doc: )
1210 (Lisp_Object terminal)
1211 {
1212 #ifdef ANDROID_STUBIFY
1213 error ("Android cross-compilation stub called!");
1214 return Qnil;
1215 #else
1216 return make_fixnum (android_get_screen_width ());
1217 #endif
1218 }
1219
1220 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
1221 Sx_display_pixel_height, 0, 1, 0,
1222 doc: )
1223 (Lisp_Object terminal)
1224 {
1225 #ifdef ANDROID_STUBIFY
1226 error ("Android cross-compilation stub called!");
1227 return Qnil;
1228 #else
1229 return make_fixnum (android_get_screen_height ());
1230 #endif
1231 }
1232
1233 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
1234 0, 1, 0,
1235 doc: )
1236 (Lisp_Object terminal)
1237 {
1238 struct android_display_info *dpyinfo;
1239
1240 dpyinfo = check_android_display_info (terminal);
1241
1242 return make_fixnum (dpyinfo->n_planes);
1243 }
1244
1245 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
1246 0, 1, 0,
1247 doc: )
1248 (Lisp_Object terminal)
1249 {
1250 struct android_display_info *dpyinfo;
1251 int nr_planes;
1252
1253 dpyinfo = check_android_display_info (terminal);
1254 nr_planes = dpyinfo->n_planes;
1255
1256
1257
1258 if (nr_planes > 24)
1259 nr_planes = 24;
1260
1261 return make_fixnum (1 << nr_planes);
1262 }
1263
1264 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
1265 doc: )
1266 (Lisp_Object terminal)
1267 {
1268 #ifdef ANDROID_STUBIFY
1269 error ("Android cross-compilation stub called!");
1270 return Qnil;
1271 #else
1272 check_android_display_info (terminal);
1273 return Vandroid_build_manufacturer;
1274 #endif
1275 }
1276
1277 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
1278 doc: )
1279 (Lisp_Object terminal)
1280 {
1281 #ifdef ANDROID_STUBIFY
1282 error ("Android cross-compilation stub called!");
1283 return Qnil;
1284 #else
1285 check_android_display_info (terminal);
1286 return list3i (android_get_current_api_level (), 0, 0);
1287 #endif
1288 }
1289
1290 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens,
1291 0, 1, 0, doc: )
1292 (Lisp_Object terminal)
1293 {
1294 check_android_display_info (terminal);
1295 return make_fixnum (1);
1296 }
1297
1298 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width,
1299 0, 1, 0, doc: )
1300 (Lisp_Object terminal)
1301 {
1302 #ifdef ANDROID_STUBIFY
1303 error ("Android cross-compilation stub called!");
1304 return Qnil;
1305 #else
1306 return make_fixnum (android_get_mm_width ());
1307 #endif
1308 }
1309
1310 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height,
1311 0, 1, 0, doc: )
1312 (Lisp_Object terminal)
1313 {
1314 #ifdef ANDROID_STUBIFY
1315 error ("Android cross-compilation stub called!");
1316 return Qnil;
1317 #else
1318 return make_fixnum (android_get_mm_height ());
1319 #endif
1320 }
1321
1322 DEFUN ("x-display-backing-store", Fx_display_backing_store,
1323 Sx_display_backing_store, 0, 1, 0,
1324 doc: )
1325 (Lisp_Object terminal)
1326 {
1327 check_android_display_info (terminal);
1328
1329
1330
1331 return Qalways;
1332 }
1333
1334 DEFUN ("x-display-visual-class", Fx_display_visual_class,
1335 Sx_display_visual_class, 0, 1, 0,
1336 doc: )
1337 (Lisp_Object terminal)
1338 {
1339 check_android_display_info (terminal);
1340
1341 return Qtrue_color;
1342 }
1343
1344 #ifndef ANDROID_STUBIFY
1345
1346 static Lisp_Object
1347 android_make_monitor_attribute_list (struct MonitorInfo *monitors,
1348 int n_monitors,
1349 int primary_monitor)
1350 {
1351 Lisp_Object monitor_frames;
1352 Lisp_Object frame, rest;
1353 struct frame *f;
1354
1355 monitor_frames = make_nil_vector (n_monitors);
1356
1357 FOR_EACH_FRAME (rest, frame)
1358 {
1359 f = XFRAME (frame);
1360
1361
1362
1363 if (FRAME_WINDOW_P (f)
1364 && !FRAME_TOOLTIP_P (f))
1365 ASET (monitor_frames, primary_monitor,
1366 Fcons (frame, AREF (monitor_frames,
1367 primary_monitor)));
1368 }
1369
1370 return make_monitor_attribute_list (monitors, n_monitors,
1371 primary_monitor,
1372 monitor_frames, NULL);
1373 }
1374
1375 #endif
1376
1377 DEFUN ("android-display-monitor-attributes-list",
1378 Fandroid_display_monitor_attributes_list,
1379 Sandroid_display_monitor_attributes_list,
1380 0, 1, 0,
1381 doc:
1382
1383
1384
1385
1386
1387 )
1388 (Lisp_Object terminal)
1389 {
1390 #ifdef ANDROID_STUBIFY
1391 error ("Android cross-compilation stub called!");
1392 return Qnil;
1393 #else
1394 struct MonitorInfo monitor;
1395
1396 memset (&monitor, 0, sizeof monitor);
1397 monitor.geom.width = android_get_screen_width ();
1398 monitor.geom.height = android_get_screen_height ();
1399 monitor.mm_width = android_get_mm_width ();
1400 monitor.mm_height = android_get_mm_height ();
1401 monitor.work = monitor.geom;
1402 monitor.name = (char *) "Android device monitor";
1403
1404 return android_make_monitor_attribute_list (&monitor, 1, 0);
1405 #endif
1406 }
1407
1408 #ifndef ANDROID_STUBIFY
1409
1410 static Lisp_Object
1411 frame_geometry (Lisp_Object frame, Lisp_Object attribute)
1412 {
1413 struct frame *f = decode_live_frame (frame);
1414 android_window rootw;
1415 unsigned int native_width, native_height, x_border_width = 0;
1416 int x_native = 0, y_native = 0, xptr = 0, yptr = 0;
1417 int left_off = 0, right_off = 0, top_off = 0, bottom_off = 0;
1418 int outer_left, outer_top, outer_right, outer_bottom;
1419 int native_left, native_top, native_right, native_bottom;
1420 int inner_left, inner_top, inner_right, inner_bottom;
1421 int internal_border_width;
1422 bool menu_bar_external = false, tool_bar_external = false;
1423 int menu_bar_height = 0, menu_bar_width = 0;
1424 int tab_bar_height = 0, tab_bar_width = 0;
1425 int tool_bar_height = 0, tool_bar_width = 0;
1426
1427 if (FRAME_INITIAL_P (f) || !FRAME_ANDROID_P (f)
1428 || !FRAME_ANDROID_WINDOW (f))
1429 return Qnil;
1430
1431 block_input ();
1432 android_get_geometry (FRAME_ANDROID_WINDOW (f),
1433 &rootw, &x_native, &y_native,
1434 &native_width, &native_height, &x_border_width);
1435 unblock_input ();
1436
1437 if (FRAME_PARENT_FRAME (f))
1438 {
1439 Lisp_Object parent, edges;
1440
1441 XSETFRAME (parent, FRAME_PARENT_FRAME (f));
1442 edges = Fandroid_frame_edges (parent, Qnative_edges);
1443 if (!NILP (edges))
1444 {
1445 x_native += XFIXNUM (Fnth (make_fixnum (0), edges));
1446 y_native += XFIXNUM (Fnth (make_fixnum (1), edges));
1447 }
1448
1449 outer_left = x_native;
1450 outer_top = y_native;
1451 outer_right = outer_left + native_width + 2 * x_border_width;
1452 outer_bottom = outer_top + native_height + 2 * x_border_width;
1453
1454 native_left = x_native + x_border_width;
1455 native_top = y_native + x_border_width;
1456 native_right = native_left + native_width;
1457 native_bottom = native_top + native_height;
1458 }
1459 else
1460 {
1461 outer_left = xptr;
1462 outer_top = yptr;
1463 outer_right = outer_left + left_off + native_width + right_off;
1464 outer_bottom = outer_top + top_off + native_height + bottom_off;
1465
1466 native_left = outer_left + left_off;
1467 native_top = outer_top + top_off;
1468 native_right = native_left + native_width;
1469 native_bottom = native_top + native_height;
1470 }
1471
1472 internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
1473 inner_left = native_left + internal_border_width;
1474 inner_top = native_top + internal_border_width;
1475 inner_right = native_right - internal_border_width;
1476 inner_bottom = native_bottom - internal_border_width;
1477
1478 menu_bar_height = FRAME_MENU_BAR_HEIGHT (f);
1479 inner_top += menu_bar_height;
1480 menu_bar_width = menu_bar_height ? native_width : 0;
1481
1482 tab_bar_height = FRAME_TAB_BAR_HEIGHT (f);
1483 tab_bar_width = (tab_bar_height
1484 ? native_width - 2 * internal_border_width
1485 : 0);
1486 inner_top += tab_bar_height;
1487
1488 tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
1489 tool_bar_width = (tool_bar_height
1490 ? native_width - 2 * internal_border_width
1491 : 0);
1492
1493
1494
1495
1496 if (EQ (FRAME_TOOL_BAR_POSITION (f), Qtop))
1497 inner_top += tool_bar_height;
1498 else
1499 inner_bottom -= tool_bar_height;
1500
1501
1502 if (EQ (attribute, Qouter_edges))
1503 return list4i (outer_left, outer_top, outer_right, outer_bottom);
1504 else if (EQ (attribute, Qnative_edges))
1505 return list4i (native_left, native_top, native_right, native_bottom);
1506 else if (EQ (attribute, Qinner_edges))
1507 return list4i (inner_left, inner_top, inner_right, inner_bottom);
1508 else
1509 return
1510 list (Fcons (Qouter_position,
1511 Fcons (make_fixnum (outer_left),
1512 make_fixnum (outer_top))),
1513 Fcons (Qouter_size,
1514 Fcons (make_fixnum (outer_right - outer_left),
1515 make_fixnum (outer_bottom - outer_top))),
1516
1517 Fcons (Qexternal_border_size,
1518 Fcons (make_fixnum (right_off),
1519 make_fixnum (bottom_off))),
1520 Fcons (Qouter_border_width, make_fixnum (x_border_width)),
1521
1522 Fcons (Qtitle_bar_size,
1523 Fcons (make_fixnum (0),
1524 make_fixnum (top_off - bottom_off))),
1525 Fcons (Qmenu_bar_external, menu_bar_external ? Qt : Qnil),
1526 Fcons (Qmenu_bar_size,
1527 Fcons (make_fixnum (menu_bar_width),
1528 make_fixnum (menu_bar_height))),
1529 Fcons (Qtab_bar_size,
1530 Fcons (make_fixnum (tab_bar_width),
1531 make_fixnum (tab_bar_height))),
1532 Fcons (Qtool_bar_external, tool_bar_external ? Qt : Qnil),
1533 Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)),
1534 Fcons (Qtool_bar_size,
1535 Fcons (make_fixnum (tool_bar_width),
1536 make_fixnum (tool_bar_height))),
1537 Fcons (Qinternal_border_width,
1538 make_fixnum (internal_border_width)));
1539 }
1540
1541 #endif
1542
1543 DEFUN ("android-frame-geometry", Fandroid_frame_geometry,
1544 Sandroid_frame_geometry,
1545 0, 1, 0,
1546 doc:
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583 )
1584 (Lisp_Object frame)
1585 {
1586 #ifdef ANDROID_STUBIFY
1587 error ("Android cross-compilation stub called!");
1588 return Qnil;
1589 #else
1590 return frame_geometry (frame, Qnil);
1591 #endif
1592 }
1593
1594 DEFUN ("android-frame-edges", Fandroid_frame_edges, Sandroid_frame_edges, 0, 2, 0,
1595 doc:
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609 )
1610 (Lisp_Object frame, Lisp_Object type)
1611 {
1612 #ifndef ANDROID_STUBIFY
1613 return frame_geometry (frame, ((EQ (type, Qouter_edges)
1614 || EQ (type, Qinner_edges))
1615 ? type
1616 : Qnative_edges));
1617 #else
1618 return Qnil;
1619 #endif
1620 }
1621
1622 #ifndef ANDROID_STUBIFY
1623
1624 static Lisp_Object
1625 android_frame_list_z_order (struct android_display_info *dpyinfo,
1626 android_window window)
1627 {
1628 android_window root, parent, *children;
1629 unsigned int nchildren;
1630 unsigned long i;
1631 Lisp_Object frames;
1632
1633 frames = Qnil;
1634
1635 if (android_query_tree (window, &root, &parent,
1636 &children, &nchildren))
1637 {
1638 for (i = 0; i < nchildren; i++)
1639 {
1640 Lisp_Object frame, tail;
1641
1642 FOR_EACH_FRAME (tail, frame)
1643 {
1644 struct frame *cf = XFRAME (frame);
1645
1646 if (FRAME_ANDROID_P (cf)
1647 && (FRAME_ANDROID_WINDOW (cf) == children[i]))
1648 frames = Fcons (frame, frames);
1649 }
1650 }
1651
1652 if (children)
1653 xfree (children);
1654 }
1655
1656 return frames;
1657 }
1658
1659 #endif
1660
1661 DEFUN ("android-frame-list-z-order", Fandroid_frame_list_z_order,
1662 Sandroid_frame_list_z_order, 0, 1, 0,
1663 doc:
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675 )
1676 (Lisp_Object terminal)
1677 {
1678 #ifdef ANDROID_STUBIFY
1679 error ("Android cross-compilation stub called!");
1680 return Qnil;
1681 #else
1682 struct android_display_info *dpyinfo;
1683 android_window window;
1684
1685 dpyinfo = check_android_display_info (terminal);
1686
1687 if (FRAMEP (terminal) && FRAME_LIVE_P (XFRAME (terminal)))
1688 window = FRAME_ANDROID_WINDOW (XFRAME (terminal));
1689 else
1690 window = dpyinfo->root_window;
1691
1692 return android_frame_list_z_order (dpyinfo, window);
1693 #endif
1694 }
1695
1696 DEFUN ("android-frame-restack", Fandroid_frame_restack,
1697 Sandroid_frame_restack, 2, 3, 0,
1698 doc:
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713 )
1714 (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object frame3)
1715 {
1716 #ifdef ANDROID_STUBIFY
1717 error ("Android cross-compilation stub called!");
1718 return Qnil;
1719 #else
1720
1721
1722
1723 return Qnil;
1724 #endif
1725 }
1726
1727 DEFUN ("android-mouse-absolute-pixel-position",
1728 Fandroid_mouse_absolute_pixel_position,
1729 Sandroid_mouse_absolute_pixel_position, 0, 0, 0,
1730 doc:
1731
1732
1733 )
1734 (void)
1735 {
1736
1737 return Qnil;
1738 }
1739
1740 DEFUN ("android-set-mouse-absolute-pixel-position",
1741 Fandroid_set_mouse_absolute_pixel_position,
1742 Sandroid_set_mouse_absolute_pixel_position, 2, 2, 0,
1743 doc:
1744
1745 )
1746 (Lisp_Object x, Lisp_Object y)
1747 {
1748
1749 return Qnil;
1750 }
1751
1752 DEFUN ("android-get-connection", Fandroid_get_connection,
1753 Sandroid_get_connection, 0, 0, 0,
1754 doc:
1755
1756
1757
1758 )
1759 (void)
1760 {
1761 #ifdef ANDROID_STUBIFY
1762 error ("Android cross-compilation stub called!");
1763 return Qnil;
1764 #else
1765 Lisp_Object terminal;
1766
1767 terminal = Qnil;
1768
1769 if (x_display_list)
1770 XSETTERMINAL (terminal, x_display_list->terminal);
1771
1772 return terminal;
1773 #endif
1774 }
1775
1776 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
1777 doc: )
1778 (void)
1779 {
1780 Lisp_Object result;
1781
1782 result = Qnil;
1783
1784 if (x_display_list)
1785 result = Fcons (XCAR (x_display_list->name_list_element),
1786 result);
1787
1788 return result;
1789 }
1790
1791 #ifndef ANDROID_STUBIFY
1792
1793 static void
1794 unwind_create_tip_frame (Lisp_Object frame)
1795 {
1796 Lisp_Object deleted;
1797
1798 deleted = unwind_create_frame (frame);
1799 if (EQ (deleted, Qt))
1800 {
1801 tip_window = ANDROID_NONE;
1802 tip_frame = Qnil;
1803 }
1804 }
1805
1806 static Lisp_Object
1807 android_create_tip_frame (struct android_display_info *dpyinfo,
1808 Lisp_Object parms)
1809 {
1810 struct frame *f;
1811 Lisp_Object frame;
1812 Lisp_Object name;
1813 specpdl_ref count = SPECPDL_INDEX ();
1814 bool face_change_before = face_change;
1815
1816 if (!dpyinfo->terminal->name)
1817 error ("Terminal is not live, can't create new frames on it");
1818
1819 parms = Fcopy_alist (parms);
1820
1821
1822 name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
1823 RES_TYPE_STRING);
1824 if (!STRINGP (name)
1825 && !BASE_EQ (name, Qunbound)
1826 && !NILP (name))
1827 error ("Invalid frame name--not a string or nil");
1828
1829 frame = Qnil;
1830 f = make_frame (false);
1831 f->wants_modeline = false;
1832 XSETFRAME (frame, f);
1833 record_unwind_protect (unwind_create_tip_frame, frame);
1834
1835 f->terminal = dpyinfo->terminal;
1836
1837
1838
1839
1840
1841 f->output_method = output_android;
1842 f->output_data.android = xzalloc (sizeof *f->output_data.android);
1843 FRAME_FONTSET (f) = -1;
1844 f->output_data.android->white_relief.pixel = -1;
1845 f->output_data.android->black_relief.pixel = -1;
1846
1847 f->tooltip = true;
1848 fset_icon_name (f, Qnil);
1849 FRAME_DISPLAY_INFO (f) = dpyinfo;
1850 f->output_data.android->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
1851
1852
1853
1854 {
1855 Lisp_Object black;
1856
1857
1858
1859
1860 FRAME_FOREGROUND_PIXEL (f) = -1;
1861 FRAME_BACKGROUND_PIXEL (f) = -1;
1862 f->output_data.android->cursor_pixel = -1;
1863 f->output_data.android->cursor_foreground_pixel = -1;
1864 f->output_data.android->mouse_pixel = -1;
1865
1866 black = build_string ("black");
1867 FRAME_FOREGROUND_PIXEL (f)
1868 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
1869 FRAME_BACKGROUND_PIXEL (f)
1870 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
1871 f->output_data.android->cursor_pixel
1872 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
1873 f->output_data.android->cursor_foreground_pixel
1874 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
1875 f->output_data.android->mouse_pixel
1876 = android_decode_color (f, black, BLACK_PIX_DEFAULT (f));
1877 }
1878
1879
1880
1881 if (BASE_EQ (name, Qunbound) || NILP (name))
1882 f->explicit_name = false;
1883 else
1884 {
1885 fset_name (f, name);
1886 f->explicit_name = true;
1887
1888 specbind (Qx_resource_name, name);
1889 }
1890
1891 register_font_driver (&androidfont_driver, f);
1892 register_font_driver (&android_sfntfont_driver, f);
1893
1894 image_cache_refcount
1895 = FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
1896 #ifdef GLYPH_DEBUG
1897 dpyinfo_refcount = dpyinfo->reference_count;
1898 #endif
1899
1900 gui_default_parameter (f, parms, Qfont_backend, Qnil,
1901 "fontBackend", "FontBackend", RES_TYPE_STRING);
1902
1903
1904
1905 android_default_font_parameter (f, parms);
1906
1907 gui_default_parameter (f, parms, Qborder_width, make_fixnum (0),
1908 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
1909
1910
1911
1912
1913 if (NILP (Fassq (Qinternal_border_width, parms)))
1914 {
1915 Lisp_Object value;
1916
1917 value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
1918 "internalBorder", "internalBorder",
1919 RES_TYPE_NUMBER);
1920 if (! BASE_EQ (value, Qunbound))
1921 parms = Fcons (Fcons (Qinternal_border_width, value),
1922 parms);
1923 }
1924
1925 gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (1),
1926 "internalBorderWidth", "internalBorderWidth",
1927 RES_TYPE_NUMBER);
1928 gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
1929 NULL, NULL, RES_TYPE_NUMBER);
1930 gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
1931 NULL, NULL, RES_TYPE_NUMBER);
1932
1933
1934 gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
1935 "foreground", "Foreground", RES_TYPE_STRING);
1936 gui_default_parameter (f, parms, Qbackground_color, build_string ("white"),
1937 "background", "Background", RES_TYPE_STRING);
1938 gui_default_parameter (f, parms, Qmouse_color, build_string ("black"),
1939 "pointerColor", "Foreground", RES_TYPE_STRING);
1940 gui_default_parameter (f, parms, Qcursor_color, build_string ("black"),
1941 "cursorColor", "Foreground", RES_TYPE_STRING);
1942 gui_default_parameter (f, parms, Qborder_color, build_string ("black"),
1943 "borderColor", "BorderColor", RES_TYPE_STRING);
1944 gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
1945 NULL, NULL, RES_TYPE_BOOLEAN);
1946
1947 {
1948 struct android_set_window_attributes attrs;
1949 unsigned long mask;
1950
1951 block_input ();
1952 mask = ANDROID_CW_OVERRIDE_REDIRECT | ANDROID_CW_BACK_PIXEL;
1953
1954 attrs.override_redirect = true;
1955 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);
1956 tip_window
1957 = FRAME_ANDROID_WINDOW (f)
1958 = android_create_window (FRAME_DISPLAY_INFO (f)->root_window,
1959
1960
1961 0, 0, 1, 1, mask, &attrs);
1962 unblock_input ();
1963 }
1964
1965
1966
1967
1968 init_frame_faces (f);
1969
1970 gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil,
1971 "inhibitDoubleBuffering", "InhibitDoubleBuffering",
1972 RES_TYPE_BOOLEAN);
1973
1974 gui_figure_window_size (f, parms, false, false);
1975
1976 f->output_data.android->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
1977
1978 android_make_gc (f);
1979
1980 gui_default_parameter (f, parms, Qauto_raise, Qnil,
1981 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1982 gui_default_parameter (f, parms, Qauto_lower, Qnil,
1983 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1984 gui_default_parameter (f, parms, Qcursor_type, Qbox,
1985 "cursorType", "CursorType", RES_TYPE_SYMBOL);
1986 gui_default_parameter (f, parms, Qalpha, Qnil,
1987 "alpha", "Alpha", RES_TYPE_NUMBER);
1988 gui_default_parameter (f, parms, Qalpha_background, Qnil,
1989 "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER);
1990
1991
1992 if (NILP (Fframe_parameter (frame, Qtooltip)))
1993 {
1994 AUTO_FRAME_ARG (arg, Qtooltip, Qt);
1995 Fmodify_frame_parameters (frame, arg);
1996 }
1997
1998
1999
2000
2001
2002 {
2003 Lisp_Object disptype;
2004
2005 disptype = Qcolor;
2006
2007 if (NILP (Fframe_parameter (frame, Qdisplay_type)))
2008 {
2009 AUTO_FRAME_ARG (arg, Qdisplay_type, disptype);
2010 Fmodify_frame_parameters (frame, arg);
2011 }
2012 }
2013
2014
2015
2016 {
2017 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
2018
2019 call2 (Qface_set_after_frame_default, frame, Qnil);
2020
2021 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
2022 {
2023 AUTO_FRAME_ARG (arg, Qbackground_color, bg);
2024 Fmodify_frame_parameters (frame, arg);
2025 }
2026 }
2027
2028 f->no_split = true;
2029
2030
2031
2032 f->terminal->reference_count++;
2033
2034
2035
2036
2037 Vframe_list = Fcons (frame, Vframe_list);
2038 f->can_set_window_size = true;
2039 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
2040 0, true, Qtip_frame);
2041
2042
2043
2044
2045
2046
2047 face_change = face_change_before;
2048
2049
2050 return unbind_to (count, frame);
2051 }
2052
2053 static Lisp_Object
2054 android_hide_tip (bool delete)
2055 {
2056 if (!NILP (tip_timer))
2057 {
2058 call1 (Qcancel_timer, tip_timer);
2059 tip_timer = Qnil;
2060 }
2061
2062 if (NILP (tip_frame)
2063 || (!delete
2064 && !NILP (tip_frame)
2065 && FRAME_LIVE_P (XFRAME (tip_frame))
2066 && !FRAME_VISIBLE_P (XFRAME (tip_frame))))
2067 return Qnil;
2068 else
2069 {
2070 Lisp_Object was_open = Qnil;
2071
2072 specpdl_ref count = SPECPDL_INDEX ();
2073 specbind (Qinhibit_redisplay, Qt);
2074 specbind (Qinhibit_quit, Qt);
2075
2076 if (!NILP (tip_frame))
2077 {
2078 struct frame *f = XFRAME (tip_frame);
2079
2080 if (FRAME_LIVE_P (f))
2081 {
2082 if (delete)
2083 {
2084 delete_frame (tip_frame, Qnil);
2085 tip_frame = Qnil;
2086 }
2087 else
2088 android_make_frame_invisible (XFRAME (tip_frame));
2089
2090 was_open = Qt;
2091 }
2092 else
2093 tip_frame = Qnil;
2094 }
2095 else
2096 tip_frame = Qnil;
2097
2098 return unbind_to (count, was_open);
2099 }
2100 }
2101
2102 static void
2103 compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx,
2104 Lisp_Object dy, int width, int height, int *root_x,
2105 int *root_y)
2106 {
2107 Lisp_Object left, top, right, bottom;
2108 int min_x, min_y, max_x, max_y = -1;
2109 android_window window;
2110 struct frame *mouse_frame;
2111
2112
2113 *root_x = 0;
2114 *root_y = 0;
2115
2116
2117 left = CDR (Fassq (Qleft, parms));
2118 top = CDR (Fassq (Qtop, parms));
2119 right = CDR (Fassq (Qright, parms));
2120 bottom = CDR (Fassq (Qbottom, parms));
2121
2122
2123
2124 if ((!FIXNUMP (left) && !FIXNUMP (right))
2125 || (!FIXNUMP (top) && !FIXNUMP (bottom)))
2126 {
2127 if (x_display_list->last_mouse_motion_frame)
2128 {
2129 *root_x = x_display_list->last_mouse_motion_x;
2130 *root_y = x_display_list->last_mouse_motion_y;
2131 mouse_frame = x_display_list->last_mouse_motion_frame;
2132 window = FRAME_ANDROID_WINDOW (mouse_frame);
2133
2134
2135 android_translate_coordinates (window, *root_x, *root_y,
2136 root_x, root_y);
2137 }
2138 }
2139
2140 min_x = 0;
2141 min_y = 0;
2142 max_x = android_get_screen_width ();
2143 max_y = android_get_screen_height ();
2144
2145 if (FIXNUMP (top))
2146 *root_y = XFIXNUM (top);
2147 else if (FIXNUMP (bottom))
2148 *root_y = XFIXNUM (bottom) - height;
2149 else if (*root_y + XFIXNUM (dy) <= min_y)
2150 *root_y = min_y;
2151 else if (*root_y + XFIXNUM (dy) + height <= max_y)
2152
2153 *root_y += XFIXNUM (dy);
2154 else if (height + XFIXNUM (dy) + min_y <= *root_y)
2155
2156 *root_y -= height + XFIXNUM (dy);
2157 else
2158
2159 *root_y = min_y;
2160
2161 if (FIXNUMP (left))
2162 *root_x = XFIXNUM (left);
2163 else if (FIXNUMP (right))
2164 *root_x = XFIXNUM (right) - width;
2165 else if (*root_x + XFIXNUM (dx) <= min_x)
2166 *root_x = 0;
2167 else if (*root_x + XFIXNUM (dx) + width <= max_x)
2168
2169 *root_x += XFIXNUM (dx);
2170 else if (width + XFIXNUM (dx) + min_x <= *root_x)
2171
2172 *root_x -= width + XFIXNUM (dx);
2173 else
2174
2175 *root_x = min_x;
2176 }
2177
2178 #endif
2179
2180 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
2181 doc: )
2182 (Lisp_Object string, Lisp_Object frame, Lisp_Object parms,
2183 Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy)
2184 {
2185 #ifdef ANDROID_STUBIFY
2186 error ("Android cross-compilation stub called!");
2187 return Qnil;
2188 #else
2189 struct frame *f, *tip_f;
2190 struct window *w;
2191 int root_x, root_y;
2192 struct buffer *old_buffer;
2193 struct text_pos pos;
2194 int width, height;
2195 int old_windows_or_buffers_changed = windows_or_buffers_changed;
2196 specpdl_ref count = SPECPDL_INDEX ();
2197 Lisp_Object window, size, tip_buf;
2198 bool displayed;
2199 #ifdef ENABLE_CHECKING
2200 struct glyph_row *row, *end;
2201 #endif
2202 AUTO_STRING (tip, " *tip*");
2203
2204 specbind (Qinhibit_redisplay, Qt);
2205
2206 CHECK_STRING (string);
2207 if (SCHARS (string) == 0)
2208 string = make_unibyte_string (" ", 1);
2209
2210 if (NILP (frame))
2211 frame = selected_frame;
2212 f = decode_window_system_frame (frame);
2213
2214 if (NILP (timeout))
2215 timeout = Vx_show_tooltip_timeout;
2216 CHECK_FIXNAT (timeout);
2217
2218 if (NILP (dx))
2219 dx = make_fixnum (5);
2220 else
2221 CHECK_FIXNUM (dx);
2222
2223 if (NILP (dy))
2224 dy = make_fixnum (-10);
2225 else
2226 CHECK_FIXNUM (dy);
2227
2228 tip_dx = dx;
2229 tip_dy = dy;
2230
2231 if (!NILP (tip_frame) && FRAME_LIVE_P (XFRAME (tip_frame)))
2232 {
2233 if (FRAME_VISIBLE_P (XFRAME (tip_frame))
2234 && !NILP (Fequal_including_properties (tip_last_string,
2235 string))
2236 && !NILP (Fequal (tip_last_parms, parms)))
2237 {
2238
2239 tip_f = XFRAME (tip_frame);
2240 if (!NILP (tip_timer))
2241 {
2242 call1 (Qcancel_timer, tip_timer);
2243 tip_timer = Qnil;
2244 }
2245
2246 block_input ();
2247 compute_tip_xy (tip_f, parms, dx, dy, FRAME_PIXEL_WIDTH (tip_f),
2248 FRAME_PIXEL_HEIGHT (tip_f), &root_x, &root_y);
2249 android_move_window (FRAME_ANDROID_WINDOW (tip_f),
2250 root_x, root_y);
2251 unblock_input ();
2252
2253 goto start_timer;
2254 }
2255 else
2256 android_hide_tip (true);
2257 }
2258 else
2259 android_hide_tip (true);
2260
2261 tip_last_frame = frame;
2262 tip_last_string = string;
2263 tip_last_parms = parms;
2264
2265 if (NILP (tip_frame) || !FRAME_LIVE_P (XFRAME (tip_frame)))
2266 {
2267
2268 if (NILP (Fassq (Qname, parms)))
2269 parms = Fcons (Fcons (Qname, build_string ("tooltip")), parms);
2270 if (NILP (Fassq (Qinternal_border_width, parms)))
2271 parms = Fcons (Fcons (Qinternal_border_width, make_fixnum (3)),
2272 parms);
2273 if (NILP (Fassq (Qborder_width, parms)))
2274 parms = Fcons (Fcons (Qborder_width, make_fixnum (1)), parms);
2275 if (NILP (Fassq (Qborder_color, parms)))
2276 parms = Fcons (Fcons (Qborder_color, build_string ("lightyellow")),
2277 parms);
2278 if (NILP (Fassq (Qbackground_color, parms)))
2279 parms = Fcons (Fcons (Qbackground_color,
2280 build_string ("lightyellow")),
2281 parms);
2282
2283
2284
2285 if (NILP (tip_frame = android_create_tip_frame (FRAME_DISPLAY_INFO (f),
2286 parms)))
2287
2288 return unbind_to (count, Qnil);
2289 }
2290
2291 tip_f = XFRAME (tip_frame);
2292 window = FRAME_ROOT_WINDOW (tip_f);
2293 tip_buf = Fget_buffer_create (tip, Qnil);
2294
2295
2296 bset_left_margin_cols (XBUFFER (tip_buf), make_fixnum (0));
2297 bset_right_margin_cols (XBUFFER (tip_buf), make_fixnum (0));
2298 set_window_buffer (window, tip_buf, false, false);
2299 w = XWINDOW (window);
2300 w->pseudo_window_p = true;
2301
2302 Fset_window_parameter (window, Qno_other_window, Qt);
2303
2304
2305
2306
2307
2308 w->left_col = 0;
2309 w->top_line = 0;
2310 w->pixel_left = 0;
2311 w->pixel_top = 0;
2312
2313 if (CONSP (Vx_max_tooltip_size)
2314 && RANGED_FIXNUMP (1, XCAR (Vx_max_tooltip_size), INT_MAX)
2315 && RANGED_FIXNUMP (1, XCDR (Vx_max_tooltip_size), INT_MAX))
2316 {
2317 w->total_cols = XFIXNAT (XCAR (Vx_max_tooltip_size));
2318 w->total_lines = XFIXNAT (XCDR (Vx_max_tooltip_size));
2319 }
2320 else
2321 {
2322 w->total_cols = 80;
2323 w->total_lines = 40;
2324 }
2325
2326 w->pixel_width = w->total_cols * FRAME_COLUMN_WIDTH (tip_f);
2327 w->pixel_height = w->total_lines * FRAME_LINE_HEIGHT (tip_f);
2328 FRAME_TOTAL_COLS (tip_f) = w->total_cols;
2329 adjust_frame_glyphs (tip_f);
2330
2331
2332
2333 specpdl_ref count_1 = SPECPDL_INDEX ();
2334 old_buffer = current_buffer;
2335 set_buffer_internal_1 (XBUFFER (w->contents));
2336 bset_truncate_lines (current_buffer, Qnil);
2337 specbind (Qinhibit_read_only, Qt);
2338 specbind (Qinhibit_modification_hooks, Qt);
2339 specbind (Qinhibit_point_motion_hooks, Qt);
2340 Ferase_buffer ();
2341 Finsert (1, &string);
2342 clear_glyph_matrix (w->desired_matrix);
2343 clear_glyph_matrix (w->current_matrix);
2344 SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
2345 displayed = try_window (window, pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
2346
2347 if (!displayed && NILP (Vx_max_tooltip_size))
2348 {
2349 #ifdef ENABLE_CHECKING
2350 row = w->desired_matrix->rows;
2351 end = w->desired_matrix->rows + w->desired_matrix->nrows;
2352
2353 while (row < end)
2354 {
2355 if (!row->displays_text_p
2356 || row->ends_at_zv_p)
2357 break;
2358 ++row;
2359 }
2360
2361 eassert (row < end && row->ends_at_zv_p);
2362 #endif
2363 }
2364
2365
2366 size = Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil,
2367 make_fixnum (w->pixel_height), Qnil,
2368 Qnil);
2369
2370 width = XFIXNUM (CAR (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f);
2371 height = XFIXNUM (CDR (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f);
2372
2373
2374 compute_tip_xy (tip_f, parms, dx, dy, width, height, &root_x, &root_y);
2375
2376
2377 block_input ();
2378 android_move_resize_window (FRAME_ANDROID_WINDOW (tip_f),
2379 root_x, root_y, width,
2380 height);
2381 android_map_raised (FRAME_ANDROID_WINDOW (tip_f));
2382 unblock_input ();
2383
2384
2385 SET_FRAME_GARBAGED (tip_f);
2386
2387 w->must_be_updated_p = true;
2388 update_single_window (w);
2389 flush_frame (tip_f);
2390 set_buffer_internal_1 (old_buffer);
2391 unbind_to (count_1, Qnil);
2392 windows_or_buffers_changed = old_windows_or_buffers_changed;
2393
2394
2395
2396
2397 SET_FRAME_VISIBLE (tip_f, true);
2398
2399 start_timer:
2400
2401 tip_timer = call3 (Qrun_at_time, timeout, Qnil,
2402 Qx_hide_tip);
2403
2404 return unbind_to (count, Qnil);
2405 #endif
2406 }
2407
2408 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
2409 doc: )
2410 (void)
2411 {
2412 #ifdef ANDROID_STUBIFY
2413
2414
2415
2416 #if 0
2417 error ("Android cross-compilation stub called!");
2418 #endif
2419 return Qnil;
2420 #else
2421 return android_hide_tip (true);
2422 #endif
2423 }
2424
2425 DEFUN ("android-detect-mouse", Fandroid_detect_mouse,
2426 Sandroid_detect_mouse, 0, 0, 0,
2427 doc:
2428
2429 )
2430 (void)
2431 {
2432 #ifndef ANDROID_STUBIFY
2433
2434
2435 if (!android_init_gui)
2436 return Qnil;
2437
2438 return android_detect_mouse () ? Qt : Qnil;
2439 #else
2440 return Qnil;
2441 #endif
2442 }
2443
2444 DEFUN ("android-toggle-on-screen-keyboard",
2445 Fandroid_toggle_on_screen_keyboard,
2446 Sandroid_toggle_on_screen_keyboard, 2, 2, 0,
2447 doc:
2448
2449
2450
2451 )
2452 (Lisp_Object frame, Lisp_Object hide)
2453 {
2454 #ifndef ANDROID_STUBIFY
2455 struct frame *f;
2456
2457 f = decode_window_system_frame (frame);
2458
2459 block_input ();
2460 android_toggle_on_screen_keyboard (FRAME_ANDROID_WINDOW (f),
2461 NILP (hide));
2462 unblock_input ();
2463 #endif
2464
2465 return Qnil;
2466 }
2467
2468
2469
2470 #ifndef ANDROID_STUBIFY
2471
2472 static void
2473 android_set_background_color (struct frame *f, Lisp_Object arg,
2474 Lisp_Object oldval)
2475 {
2476 struct android_output *x;
2477 unsigned long bg;
2478
2479 x = f->output_data.android;
2480 bg = android_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
2481 FRAME_BACKGROUND_PIXEL (f) = bg;
2482
2483 if (FRAME_ANDROID_WINDOW (f) != 0)
2484 {
2485 block_input ();
2486 android_set_background (x->normal_gc, bg);
2487 android_set_foreground (x->reverse_gc, bg);
2488 android_set_window_background (FRAME_ANDROID_WINDOW (f), bg);
2489 android_set_foreground (x->cursor_gc, bg);
2490 unblock_input ();
2491
2492 update_face_from_frame_parameter (f, Qbackground_color, arg);
2493
2494 if (FRAME_VISIBLE_P (f))
2495 redraw_frame (f);
2496 }
2497 }
2498
2499 static void
2500 android_set_border_color (struct frame *f, Lisp_Object arg,
2501 Lisp_Object oldval)
2502 {
2503
2504 CHECK_STRING (arg);
2505 android_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
2506 update_face_from_frame_parameter (f, Qborder_color, arg);
2507 }
2508
2509 static void
2510 android_set_cursor_color (struct frame *f, Lisp_Object arg,
2511 Lisp_Object oldval)
2512 {
2513 unsigned long fore_pixel, pixel;
2514 struct android_output *x;
2515
2516 x = f->output_data.android;
2517
2518 if (!NILP (Vx_cursor_fore_pixel))
2519 fore_pixel = android_decode_color (f, Vx_cursor_fore_pixel,
2520 WHITE_PIX_DEFAULT (f));
2521 else
2522 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
2523
2524 pixel = android_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
2525
2526
2527 if (pixel == FRAME_BACKGROUND_PIXEL (f))
2528 {
2529 pixel = FRAME_FOREGROUND_PIXEL (f);
2530 if (pixel == fore_pixel)
2531 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
2532 }
2533
2534 x->cursor_foreground_pixel = fore_pixel;
2535 x->cursor_pixel = pixel;
2536
2537 if (FRAME_ANDROID_WINDOW (f) != 0)
2538 {
2539 block_input ();
2540 android_set_background (x->cursor_gc, x->cursor_pixel);
2541 android_set_foreground (x->cursor_gc, fore_pixel);
2542 unblock_input ();
2543
2544 if (FRAME_VISIBLE_P (f))
2545 {
2546 gui_update_cursor (f, false);
2547 gui_update_cursor (f, true);
2548 }
2549 }
2550
2551 update_face_from_frame_parameter (f, Qcursor_color, arg);
2552 }
2553
2554 static void
2555 android_set_cursor_type (struct frame *f, Lisp_Object arg,
2556 Lisp_Object oldval)
2557 {
2558 set_frame_cursor_types (f, arg);
2559 }
2560
2561 static void
2562 android_set_foreground_color (struct frame *f, Lisp_Object arg,
2563 Lisp_Object oldval)
2564 {
2565 struct android_output *x;
2566 unsigned long fg, old_fg;
2567
2568 x = f->output_data.android;
2569
2570 fg = android_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
2571 old_fg = FRAME_FOREGROUND_PIXEL (f);
2572 FRAME_FOREGROUND_PIXEL (f) = fg;
2573
2574 if (FRAME_ANDROID_WINDOW (f) != 0)
2575 {
2576 block_input ();
2577 android_set_foreground (x->normal_gc, fg);
2578 android_set_background (x->reverse_gc, fg);
2579
2580 if (x->cursor_pixel == old_fg)
2581 {
2582 x->cursor_pixel = fg;
2583 android_set_background (x->cursor_gc, x->cursor_pixel);
2584 }
2585
2586 unblock_input ();
2587
2588 update_face_from_frame_parameter (f, Qforeground_color, arg);
2589
2590 if (FRAME_VISIBLE_P (f))
2591 redraw_frame (f);
2592 }
2593 }
2594
2595 static void
2596 android_set_child_frame_border_width (struct frame *f, Lisp_Object arg,
2597 Lisp_Object oldval)
2598 {
2599 int border;
2600
2601 if (NILP (arg))
2602 border = -1;
2603 else if (RANGED_FIXNUMP (0, arg, INT_MAX))
2604 border = XFIXNAT (arg);
2605 else
2606 signal_error ("Invalid child frame border width", arg);
2607
2608 if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
2609 {
2610 f->child_frame_border_width = border;
2611
2612 if (FRAME_ANDROID_WINDOW (f))
2613 {
2614 adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width);
2615 android_clear_under_internal_border (f);
2616 }
2617 }
2618 }
2619
2620 static void
2621 android_set_internal_border_width (struct frame *f, Lisp_Object arg,
2622 Lisp_Object oldval)
2623 {
2624 int border = check_int_nonnegative (arg);
2625
2626 if (border != FRAME_INTERNAL_BORDER_WIDTH (f))
2627 {
2628 f->internal_border_width = border;
2629
2630 if (FRAME_ANDROID_WINDOW (f))
2631 {
2632 adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width);
2633 android_clear_under_internal_border (f);
2634 }
2635 }
2636 }
2637
2638 static void
2639 android_set_menu_bar_lines (struct frame *f, Lisp_Object value,
2640 Lisp_Object oldval)
2641 {
2642 int nlines;
2643 int olines = FRAME_MENU_BAR_LINES (f);
2644
2645
2646
2647
2648
2649 if (FRAME_MINIBUF_ONLY_P (f) || FRAME_PARENT_FRAME (f))
2650 return;
2651
2652 if (TYPE_RANGED_FIXNUMP (int, value))
2653 nlines = XFIXNUM (value);
2654 else
2655 nlines = 0;
2656
2657
2658 fset_redisplay (f);
2659
2660 FRAME_MENU_BAR_LINES (f) = nlines;
2661 FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f);
2662 if (FRAME_ANDROID_WINDOW (f))
2663 android_clear_under_internal_border (f);
2664
2665
2666
2667
2668
2669 if (nlines != olines)
2670 {
2671 int height = FRAME_INTERNAL_BORDER_WIDTH (f);
2672 int width = FRAME_PIXEL_WIDTH (f);
2673 int y;
2674
2675 adjust_frame_size (f, -1, -1, 3, true, Qmenu_bar_lines);
2676
2677
2678 if (FRAME_ANDROID_WINDOW (f) && height > 0 && width > 0)
2679 {
2680 y = FRAME_TOP_MARGIN_HEIGHT (f);
2681
2682 block_input ();
2683 android_clear_area (FRAME_ANDROID_DRAWABLE (f),
2684 0, y, width, height);
2685 unblock_input ();
2686 }
2687
2688 if (nlines > 1 && nlines > olines)
2689 {
2690 y = (olines == 0 ? 1 : olines) * FRAME_LINE_HEIGHT (f);
2691 height = nlines * FRAME_LINE_HEIGHT (f) - y;
2692
2693 block_input ();
2694 android_clear_area (FRAME_ANDROID_DRAWABLE (f), 0, y,
2695 width, height);
2696 unblock_input ();
2697 }
2698
2699 if (nlines == 0 && WINDOWP (f->menu_bar_window))
2700 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
2701 }
2702
2703 adjust_frame_glyphs (f);
2704 }
2705
2706
2707
2708
2709
2710
2711 enum mouse_cursor
2712 {
2713 mouse_cursor_text,
2714 mouse_cursor_nontext,
2715 mouse_cursor_hourglass,
2716 mouse_cursor_mode,
2717 mouse_cursor_hand,
2718 mouse_cursor_horizontal_drag,
2719 mouse_cursor_vertical_drag,
2720 mouse_cursor_left_edge,
2721 mouse_cursor_top_left_corner,
2722 mouse_cursor_top_edge,
2723 mouse_cursor_top_right_corner,
2724 mouse_cursor_right_edge,
2725 mouse_cursor_bottom_right_corner,
2726 mouse_cursor_bottom_edge,
2727 mouse_cursor_bottom_left_corner,
2728 mouse_cursor_max
2729 };
2730
2731 struct mouse_cursor_types
2732 {
2733
2734 const char *name;
2735
2736
2737
2738
2739
2740 Lisp_Object *shape_var_ptr;
2741
2742
2743 int default_shape;
2744 };
2745
2746
2747
2748 static const struct mouse_cursor_types mouse_cursor_types[] =
2749 {
2750 {"text", &Vx_pointer_shape, ANDROID_XC_XTERM, },
2751 {"nontext", &Vx_nontext_pointer_shape, ANDROID_XC_LEFT_PTR, },
2752 {"hourglass", &Vx_hourglass_pointer_shape, ANDROID_XC_WATCH, },
2753 {"modeline", &Vx_mode_pointer_shape, ANDROID_XC_XTERM, },
2754 {NULL, &Vx_sensitive_text_pointer_shape, ANDROID_XC_HAND2, },
2755 {NULL, &Vx_window_horizontal_drag_shape, ANDROID_XC_SB_H_DOUBLE_ARROW, },
2756 {NULL, &Vx_window_vertical_drag_shape, ANDROID_XC_SB_V_DOUBLE_ARROW, },
2757 {NULL, &Vx_window_left_edge_shape, ANDROID_XC_LEFT_SIDE, },
2758 {NULL, &Vx_window_top_left_corner_shape, ANDROID_XC_TOP_LEFT_CORNER, },
2759 {NULL, &Vx_window_top_edge_shape, ANDROID_XC_TOP_SIDE, },
2760 {NULL, &Vx_window_top_right_corner_shape, ANDROID_XC_TOP_RIGHT_CORNER, },
2761 {NULL, &Vx_window_right_edge_shape, ANDROID_XC_RIGHT_SIDE, },
2762 {NULL, &Vx_window_bottom_right_corner_shape,
2763 ANDROID_XC_BOTTOM_RIGHT_CORNER, },
2764 {NULL, &Vx_window_bottom_edge_shape, ANDROID_XC_BOTTOM_SIDE, },
2765 {NULL, &Vx_window_bottom_left_corner_shape,
2766 ANDROID_XC_BOTTOM_LEFT_CORNER, },
2767 };
2768
2769 struct mouse_cursor_data
2770 {
2771
2772 unsigned int cursor_num[mouse_cursor_max];
2773
2774
2775 android_cursor cursor[mouse_cursor_max];
2776 };
2777
2778
2779
2780 static void
2781 android_set_mouse_color (struct frame *f, Lisp_Object arg,
2782 Lisp_Object oldval)
2783 {
2784 struct android_output *x = f->output_data.android;
2785 struct mouse_cursor_data cursor_data = { -1, -1 };
2786 unsigned long pixel = android_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
2787 unsigned long mask_color = FRAME_BACKGROUND_PIXEL (f);
2788 int i;
2789
2790
2791 if (mask_color == pixel)
2792 pixel = FRAME_FOREGROUND_PIXEL (f);
2793
2794 x->mouse_pixel = pixel;
2795
2796 for (i = 0; i < mouse_cursor_max; i++)
2797 {
2798 Lisp_Object shape_var = *mouse_cursor_types[i].shape_var_ptr;
2799 cursor_data.cursor_num[i]
2800 = (!NILP (shape_var)
2801 ? check_uinteger_max (shape_var, UINT_MAX)
2802 : mouse_cursor_types[i].default_shape);
2803 }
2804
2805 block_input ();
2806
2807 for (i = 0; i < mouse_cursor_max; i++)
2808 cursor_data.cursor[i]
2809 = android_create_font_cursor (cursor_data.cursor_num[i]);
2810
2811 if (FRAME_ANDROID_WINDOW (f))
2812 {
2813 f->output_data.android->current_cursor
2814 = cursor_data.cursor[mouse_cursor_text];
2815 android_define_cursor (FRAME_ANDROID_WINDOW (f),
2816 f->output_data.android->current_cursor);
2817 }
2818
2819 #define INSTALL_CURSOR(FIELD, SHORT_INDEX) \
2820 eassert (x->FIELD \
2821 != cursor_data.cursor[mouse_cursor_ ## SHORT_INDEX]); \
2822 if (x->FIELD != 0) \
2823 android_free_cursor (x->FIELD); \
2824 x->FIELD = cursor_data.cursor[mouse_cursor_ ## SHORT_INDEX];
2825
2826 INSTALL_CURSOR (text_cursor, text);
2827 INSTALL_CURSOR (nontext_cursor, nontext);
2828 INSTALL_CURSOR (hourglass_cursor, hourglass);
2829 INSTALL_CURSOR (modeline_cursor, mode);
2830 INSTALL_CURSOR (hand_cursor, hand);
2831 INSTALL_CURSOR (horizontal_drag_cursor, horizontal_drag);
2832 INSTALL_CURSOR (vertical_drag_cursor, vertical_drag);
2833 INSTALL_CURSOR (left_edge_cursor, left_edge);
2834 INSTALL_CURSOR (top_left_corner_cursor, top_left_corner);
2835 INSTALL_CURSOR (top_edge_cursor, top_edge);
2836 INSTALL_CURSOR (top_right_corner_cursor, top_right_corner);
2837 INSTALL_CURSOR (right_edge_cursor, right_edge);
2838 INSTALL_CURSOR (bottom_right_corner_cursor, bottom_right_corner);
2839 INSTALL_CURSOR (bottom_edge_cursor, bottom_edge);
2840 INSTALL_CURSOR (bottom_left_corner_cursor, bottom_left_corner);
2841
2842 #undef INSTALL_CURSOR
2843
2844 unblock_input ();
2845
2846 update_face_from_frame_parameter (f, Qmouse_color, arg);
2847 }
2848
2849 static void
2850 android_set_title (struct frame *f, Lisp_Object name,
2851 Lisp_Object old_name)
2852 {
2853
2854 if (EQ (name, f->title))
2855 return;
2856
2857 update_mode_lines = 38;
2858
2859 fset_title (f, name);
2860
2861 if (NILP (name))
2862 name = f->name;
2863 else
2864 CHECK_STRING (name);
2865 }
2866
2867 static void
2868 android_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
2869 {
2870 double alpha = 1.0;
2871 double newval[2];
2872 int i;
2873 Lisp_Object item;
2874
2875
2876
2877
2878 for (i = 0; i < 2; i++)
2879 {
2880 newval[i] = 1.0;
2881 if (CONSP (arg))
2882 {
2883 item = CAR (arg);
2884 arg = CDR (arg);
2885 }
2886 else
2887 item = arg;
2888
2889 if (NILP (item))
2890 alpha = - 1.0;
2891 else if (FLOATP (item))
2892 {
2893 alpha = XFLOAT_DATA (item);
2894 if (! (0 <= alpha && alpha <= 1.0))
2895 args_out_of_range (make_float (0.0), make_float (1.0));
2896 }
2897 else if (FIXNUMP (item))
2898 {
2899 EMACS_INT ialpha = XFIXNUM (item);
2900 if (! (0 <= ialpha && ialpha <= 100))
2901 args_out_of_range (make_fixnum (0), make_fixnum (100));
2902 alpha = ialpha / 100.0;
2903 }
2904 else
2905 wrong_type_argument (Qnumberp, item);
2906 newval[i] = alpha;
2907 }
2908
2909 for (i = 0; i < 2; i++)
2910 f->alpha[i] = newval[i];
2911
2912 if (FRAME_TERMINAL (f)->set_frame_alpha_hook)
2913 {
2914 block_input ();
2915 FRAME_TERMINAL (f)->set_frame_alpha_hook (f);
2916 unblock_input ();
2917 }
2918 }
2919
2920 static void
2921 android_set_no_focus_on_map (struct frame *f, Lisp_Object new_value,
2922 Lisp_Object old_value)
2923 {
2924 if (!EQ (new_value, old_value))
2925 {
2926 android_set_dont_focus_on_map (FRAME_ANDROID_WINDOW (f),
2927 !NILP (new_value));
2928 FRAME_NO_FOCUS_ON_MAP (f) = !NILP (new_value);
2929 }
2930 }
2931
2932 static void
2933 android_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
2934 Lisp_Object old_value)
2935 {
2936 if (!EQ (new_value, old_value))
2937 {
2938 android_set_dont_accept_focus (FRAME_ANDROID_WINDOW (f),
2939 !NILP (new_value));
2940 FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value);
2941 }
2942 }
2943
2944 frame_parm_handler android_frame_parm_handlers[] =
2945 {
2946 gui_set_autoraise,
2947 gui_set_autolower,
2948 android_set_background_color,
2949 android_set_border_color,
2950 gui_set_border_width,
2951 android_set_cursor_color,
2952 android_set_cursor_type,
2953 gui_set_font,
2954 android_set_foreground_color,
2955 NULL,
2956 NULL,
2957 android_set_child_frame_border_width,
2958 android_set_internal_border_width,
2959 gui_set_right_divider_width,
2960 gui_set_bottom_divider_width,
2961 android_set_menu_bar_lines,
2962 android_set_mouse_color,
2963 android_explicitly_set_name,
2964 gui_set_scroll_bar_width,
2965 gui_set_scroll_bar_height,
2966 android_set_title,
2967 gui_set_unsplittable,
2968 gui_set_vertical_scroll_bars,
2969 gui_set_horizontal_scroll_bars,
2970 gui_set_visibility,
2971 android_set_tab_bar_lines,
2972 android_set_tool_bar_lines,
2973 NULL,
2974 NULL,
2975 gui_set_screen_gamma,
2976 gui_set_line_spacing,
2977 gui_set_left_fringe,
2978 gui_set_right_fringe,
2979 NULL,
2980 gui_set_fullscreen,
2981 gui_set_font_backend,
2982 android_set_alpha,
2983 NULL,
2984 android_set_tool_bar_position,
2985 NULL,
2986 NULL,
2987 android_set_parent_frame,
2988 NULL,
2989 android_set_no_focus_on_map,
2990 android_set_no_accept_focus,
2991 NULL,
2992 NULL,
2993 gui_set_no_special_glyphs,
2994 NULL,
2995 NULL,
2996 };
2997
2998
2999
3000
3001
3002 DEFUN ("android-query-battery", Fandroid_query_battery,
3003 Sandroid_query_battery, 0, 0, 0,
3004 doc:
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017 )
3018 (void)
3019 {
3020 struct android_battery_state state;
3021
3022
3023
3024 if (!android_init_gui)
3025 return Qnil;
3026
3027
3028
3029 if (android_query_battery (&state))
3030 return Qnil;
3031
3032 return listn (8, make_int (state.capacity),
3033 make_fixnum (state.charge_counter),
3034 make_int (state.current_average),
3035 make_int (state.current_now),
3036 make_fixnum (state.status),
3037 make_int (state.remaining),
3038 make_fixnum (state.plugged),
3039 make_fixnum (state.temperature));
3040 }
3041
3042
3043
3044
3045
3046 DEFUN ("android-request-directory-access", Fandroid_request_directory_access,
3047 Sandroid_request_directory_access, 0, 0, "",
3048 doc:
3049
3050
3051
3052
3053
3054 )
3055 (void)
3056 {
3057 if (android_get_current_api_level () < 21)
3058 error ("Emacs can only access application storage on"
3059 " Android 5.0 and later");
3060
3061 if (!android_init_gui)
3062 return Qnil;
3063
3064 android_request_directory_access ();
3065 return Qnil;
3066 }
3067
3068
3069
3070
3071
3072
3073
3074
3075 void
3076 android_set_preeditarea (struct window *w, int x, int y)
3077 {
3078 struct frame *f;
3079
3080 f = WINDOW_XFRAME (w);
3081
3082
3083
3084 x = (WINDOW_TO_FRAME_PIXEL_X (w, x)
3085 + WINDOW_LEFT_FRINGE_WIDTH (w)
3086 + WINDOW_LEFT_MARGIN_WIDTH (w));
3087 y = WINDOW_TO_FRAME_PIXEL_Y (w, y);
3088
3089
3090
3091 android_update_cursor_anchor_info (FRAME_ANDROID_WINDOW (f), x,
3092 y, y + w->phys_cursor_height,
3093 y + w->phys_cursor_height);
3094 }
3095
3096 #endif
3097
3098
3099
3100 void
3101 syms_of_androidfns (void)
3102 {
3103
3104 DEFSYM (Qtrue_color, "true-color");
3105 DEFSYM (Qalways, "always");
3106
3107 DEFVAR_LISP ("x-pointer-shape", Vx_pointer_shape,
3108 doc: );
3109 Vx_pointer_shape = Qnil;
3110
3111 #if false
3112 DEFVAR_LISP ("x-nontext-pointer-shape", Vx_nontext_pointer_shape,
3113 doc: );
3114 #endif
3115 Vx_nontext_pointer_shape = Qnil;
3116
3117 DEFVAR_LISP ("x-hourglass-pointer-shape", Vx_hourglass_pointer_shape,
3118 doc: );
3119 Vx_hourglass_pointer_shape = Qnil;
3120
3121 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
3122 Vx_sensitive_text_pointer_shape,
3123 doc: );
3124 Vx_sensitive_text_pointer_shape = Qnil;
3125
3126 DEFVAR_LISP ("x-window-horizontal-drag-cursor",
3127 Vx_window_horizontal_drag_shape,
3128 doc: );
3129 Vx_window_horizontal_drag_shape = Qnil;
3130
3131 DEFVAR_LISP ("x-window-vertical-drag-cursor",
3132 Vx_window_vertical_drag_shape,
3133 doc: );
3134 Vx_window_vertical_drag_shape = Qnil;
3135
3136 DEFVAR_LISP ("x-window-left-edge-cursor",
3137 Vx_window_left_edge_shape,
3138 doc: );
3139 Vx_window_left_edge_shape = Qnil;
3140
3141 DEFVAR_LISP ("x-window-top-left-corner-cursor",
3142 Vx_window_top_left_corner_shape,
3143 doc: );
3144 Vx_window_top_left_corner_shape = Qnil;
3145
3146 DEFVAR_LISP ("x-window-top-edge-cursor",
3147 Vx_window_top_edge_shape,
3148 doc: );
3149 Vx_window_top_edge_shape = Qnil;
3150
3151 DEFVAR_LISP ("x-window-top-right-corner-cursor",
3152 Vx_window_top_right_corner_shape,
3153 doc: );
3154 Vx_window_top_right_corner_shape = Qnil;
3155
3156 DEFVAR_LISP ("x-window-right-edge-cursor",
3157 Vx_window_right_edge_shape,
3158 doc: );
3159 Vx_window_right_edge_shape = Qnil;
3160
3161 DEFVAR_LISP ("x-window-bottom-right-corner-cursor",
3162 Vx_window_bottom_right_corner_shape,
3163 doc: );
3164 Vx_window_bottom_right_corner_shape = Qnil;
3165
3166 DEFVAR_LISP ("x-window-bottom-edge-cursor",
3167 Vx_window_bottom_edge_shape,
3168 doc: );
3169 Vx_window_bottom_edge_shape = Qnil;
3170
3171 #if false
3172 DEFVAR_LISP ("x-mode-pointer-shape", Vx_mode_pointer_shape,
3173 doc: );
3174 #endif
3175 Vx_mode_pointer_shape = Qnil;
3176
3177 DEFVAR_LISP ("x-window-bottom-left-corner-cursor",
3178 Vx_window_bottom_left_corner_shape,
3179 doc: );
3180 Vx_window_bottom_left_corner_shape = Qnil;
3181
3182 DEFVAR_LISP ("x-cursor-fore-pixel", Vx_cursor_fore_pixel,
3183 doc: );
3184 Vx_cursor_fore_pixel = Qnil;
3185
3186
3187 DEFSYM (Qrun_at_time, "run-at-time");
3188 DEFSYM (Qx_hide_tip, "x-hide-tip");
3189 DEFSYM (Qcancel_timer, "cancel-timer");
3190 DEFSYM (Qassq_delete_all, "assq-delete-all");
3191 DEFSYM (Qcolor, "color");
3192
3193 DEFVAR_LISP ("x-max-tooltip-size", Vx_max_tooltip_size,
3194 doc: );
3195 Vx_max_tooltip_size = Qnil;
3196
3197 DEFVAR_BOOL ("android-pass-multimedia-buttons-to-system",
3198 android_pass_multimedia_buttons_to_system,
3199 doc:
3200
3201
3202
3203
3204
3205 );
3206 android_pass_multimedia_buttons_to_system = false;
3207
3208 DEFVAR_BOOL ("android-use-exec-loader", android_use_exec_loader,
3209 doc:
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219 );
3220 android_use_exec_loader = true;
3221
3222
3223 defsubr (&Sx_create_frame);
3224 defsubr (&Sxw_color_defined_p);
3225 defsubr (&Sxw_color_values);
3226 defsubr (&Sxw_display_color_p);
3227 defsubr (&Sx_display_grayscale_p);
3228 defsubr (&Sx_display_pixel_width);
3229 defsubr (&Sx_display_pixel_height);
3230 defsubr (&Sx_display_planes);
3231 defsubr (&Sx_display_color_cells);
3232 defsubr (&Sx_display_screens);
3233 defsubr (&Sx_display_mm_width);
3234 defsubr (&Sx_display_mm_height);
3235 defsubr (&Sx_display_backing_store);
3236 defsubr (&Sx_display_visual_class);
3237 defsubr (&Sandroid_display_monitor_attributes_list);
3238 defsubr (&Sandroid_frame_geometry);
3239 defsubr (&Sandroid_frame_edges);
3240 defsubr (&Sandroid_frame_list_z_order);
3241 defsubr (&Sandroid_frame_restack);
3242 defsubr (&Sandroid_mouse_absolute_pixel_position);
3243 defsubr (&Sandroid_set_mouse_absolute_pixel_position);
3244 defsubr (&Sandroid_get_connection);
3245 defsubr (&Sx_display_list);
3246 defsubr (&Sx_show_tip);
3247 defsubr (&Sx_hide_tip);
3248 defsubr (&Sandroid_detect_mouse);
3249 defsubr (&Sandroid_toggle_on_screen_keyboard);
3250 defsubr (&Sx_server_vendor);
3251 defsubr (&Sx_server_version);
3252 #ifndef ANDROID_STUBIFY
3253 defsubr (&Sandroid_query_battery);
3254 defsubr (&Sandroid_request_directory_access);
3255
3256 tip_timer = Qnil;
3257 staticpro (&tip_timer);
3258 tip_frame = Qnil;
3259 staticpro (&tip_frame);
3260 tip_last_frame = Qnil;
3261 staticpro (&tip_last_frame);
3262 tip_last_string = Qnil;
3263 staticpro (&tip_last_string);
3264 tip_last_parms = Qnil;
3265 staticpro (&tip_last_parms);
3266 tip_dx = Qnil;
3267 staticpro (&tip_dx);
3268 tip_dy = Qnil;
3269 staticpro (&tip_dy);
3270 #endif
3271 }