aboutsummaryrefslogtreecommitdiffstats
path: root/src/haikufns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/haikufns.c')
-rw-r--r--src/haikufns.c498
1 files changed, 327 insertions, 171 deletions
diff --git a/src/haikufns.c b/src/haikufns.c
index 52bb13bc89b..58a2e1d4642 100644
--- a/src/haikufns.c
+++ b/src/haikufns.c
@@ -45,7 +45,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
45#define BLUE_FROM_ULONG(color) ((color) & 0xff) 45#define BLUE_FROM_ULONG(color) ((color) & 0xff)
46 46
47/* The frame of the currently visible tooltip. */ 47/* The frame of the currently visible tooltip. */
48static Lisp_Object tip_frame; 48Lisp_Object tip_frame;
49 49
50/* The window-system window corresponding to the frame of the 50/* The window-system window corresponding to the frame of the
51 currently visible tooltip. */ 51 currently visible tooltip. */
@@ -452,6 +452,15 @@ haiku_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object o
452} 452}
453 453
454static void 454static void
455initial_setup_back_buffer (struct frame *f)
456{
457 block_input ();
458 if (NILP (CDR (Fassq (Qinhibit_double_buffering, f->param_alist))))
459 EmacsView_set_up_double_buffering (FRAME_HAIKU_VIEW (f));
460 unblock_input ();
461}
462
463static void
455unwind_create_frame (Lisp_Object frame) 464unwind_create_frame (Lisp_Object frame)
456{ 465{
457 struct frame *f = XFRAME (frame); 466 struct frame *f = XFRAME (frame);
@@ -547,13 +556,12 @@ unwind_popup (void)
547} 556}
548 557
549static Lisp_Object 558static Lisp_Object
550haiku_create_frame (Lisp_Object parms, int ttip_p) 559haiku_create_frame (Lisp_Object parms)
551{ 560{
552 struct frame *f; 561 struct frame *f;
553 Lisp_Object frame, tem; 562 Lisp_Object frame, tem;
554 Lisp_Object name; 563 Lisp_Object name;
555 bool minibuffer_only = false; 564 bool minibuffer_only = false;
556 bool face_change_before = face_change;
557 long window_prompting = 0; 565 long window_prompting = 0;
558 ptrdiff_t count = SPECPDL_INDEX (); 566 ptrdiff_t count = SPECPDL_INDEX ();
559 Lisp_Object display; 567 Lisp_Object display;
@@ -593,10 +601,8 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
593 tem = gui_display_get_arg (dpyinfo, parms, Qminibuffer, 601 tem = gui_display_get_arg (dpyinfo, parms, Qminibuffer,
594 "minibuffer", "Minibuffer", 602 "minibuffer", "Minibuffer",
595 RES_TYPE_SYMBOL); 603 RES_TYPE_SYMBOL);
596 if (ttip_p) 604 if (EQ (tem, Qnone) || NILP (tem))
597 f = make_frame (0); 605 f = make_frame_without_minibuffer (Qnil, kb, display);
598 else if (EQ (tem, Qnone) || NILP (tem))
599 f = make_frame_without_minibuffer (Qnil, kb, display);
600 else if (EQ (tem, Qonly)) 606 else if (EQ (tem, Qonly))
601 { 607 {
602 f = make_minibuffer_frame (); 608 f = make_minibuffer_frame ();
@@ -618,22 +624,16 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
618 f->output_data.haiku->pending_zoom_width = INT_MIN; 624 f->output_data.haiku->pending_zoom_width = INT_MIN;
619 f->output_data.haiku->pending_zoom_height = INT_MIN; 625 f->output_data.haiku->pending_zoom_height = INT_MIN;
620 626
621 if (ttip_p)
622 f->wants_modeline = false;
623
624 fset_icon_name (f, gui_display_get_arg (dpyinfo, parms, Qicon_name, 627 fset_icon_name (f, gui_display_get_arg (dpyinfo, parms, Qicon_name,
625 "iconName", "Title", 628 "iconName", "Title",
626 RES_TYPE_STRING)); 629 RES_TYPE_STRING));
627 if (! STRINGP (f->icon_name) || ttip_p) 630 if (! STRINGP (f->icon_name))
628 fset_icon_name (f, Qnil); 631 fset_icon_name (f, Qnil);
629 632
630 FRAME_DISPLAY_INFO (f) = dpyinfo; 633 FRAME_DISPLAY_INFO (f) = dpyinfo;
631 634
632 /* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */ 635 /* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */
633 if (!ttip_p) 636 record_unwind_protect (unwind_create_frame, frame);
634 record_unwind_protect (unwind_create_frame, frame);
635 else
636 record_unwind_protect (unwind_create_tip_frame, frame);
637 637
638 FRAME_OUTPUT_DATA (f)->parent_desc = NULL; 638 FRAME_OUTPUT_DATA (f)->parent_desc = NULL;
639 FRAME_OUTPUT_DATA (f)->explicit_parent = 0; 639 FRAME_OUTPUT_DATA (f)->explicit_parent = 0;
@@ -660,8 +660,6 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
660#endif 660#endif
661 register_font_driver (&haikufont_driver, f); 661 register_font_driver (&haikufont_driver, f);
662 662
663 f->tooltip = ttip_p;
664
665 image_cache_refcount = 663 image_cache_refcount =
666 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; 664 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
667 665
@@ -674,7 +672,7 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
674 672
675 gui_default_parameter (f, parms, Qborder_width, make_fixnum (0), 673 gui_default_parameter (f, parms, Qborder_width, make_fixnum (0),
676 "borderwidth", "BorderWidth", RES_TYPE_NUMBER); 674 "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
677 gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (ttip_p ? 1 : 2), 675 gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (2),
678 "internalBorderWidth", "InternalBorderWidth", 676 "internalBorderWidth", "InternalBorderWidth",
679 RES_TYPE_NUMBER); 677 RES_TYPE_NUMBER);
680 gui_default_parameter (f, parms, Qchild_frame_border_width, Qnil, 678 gui_default_parameter (f, parms, Qchild_frame_border_width, Qnil,
@@ -684,7 +682,7 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
684 NULL, NULL, RES_TYPE_NUMBER); 682 NULL, NULL, RES_TYPE_NUMBER);
685 gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0), 683 gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
686 NULL, NULL, RES_TYPE_NUMBER); 684 NULL, NULL, RES_TYPE_NUMBER);
687 gui_default_parameter (f, parms, Qvertical_scroll_bars, !ttip_p ? Qt : Qnil, 685 gui_default_parameter (f, parms, Qvertical_scroll_bars, Qt,
688 "verticalScrollBars", "VerticalScrollBars", 686 "verticalScrollBars", "VerticalScrollBars",
689 RES_TYPE_SYMBOL); 687 RES_TYPE_SYMBOL);
690 gui_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil, 688 gui_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil,
@@ -700,7 +698,7 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
700 "leftFringe", "LeftFringe", RES_TYPE_NUMBER); 698 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
701 gui_default_parameter (f, parms, Qright_fringe, Qnil, 699 gui_default_parameter (f, parms, Qright_fringe, Qnil,
702 "rightFringe", "RightFringe", RES_TYPE_NUMBER); 700 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
703 gui_default_parameter (f, parms, Qno_special_glyphs, ttip_p ? Qnil : Qt, 701 gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
704 NULL, NULL, RES_TYPE_BOOLEAN); 702 NULL, NULL, RES_TYPE_BOOLEAN);
705 703
706 init_frame_faces (f); 704 init_frame_faces (f);
@@ -718,57 +716,39 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
718 FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, 716 FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1,
719 Qx_create_frame_1); 717 Qx_create_frame_1);
720 718
721 if (!ttip_p) 719 gui_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL);
722 { 720 gui_default_parameter (f, parms, Qno_focus_on_map, Qnil,
723 gui_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL); 721 NULL, NULL, RES_TYPE_BOOLEAN);
724 gui_default_parameter (f, parms, Qno_focus_on_map, Qnil, 722 gui_default_parameter (f, parms, Qno_accept_focus, Qnil,
725 NULL, NULL, RES_TYPE_BOOLEAN); 723 NULL, NULL, RES_TYPE_BOOLEAN);
726 gui_default_parameter (f, parms, Qno_accept_focus, Qnil, 724
727 NULL, NULL, RES_TYPE_BOOLEAN); 725 /* The resources controlling the menu-bar, tool-bar, and tab-bar are
728 726 processed specially at startup, and reflected in the mode
729 /* The resources controlling the menu-bar, tool-bar, and tab-bar are 727 variables; ignore them here. */
730 processed specially at startup, and reflected in the mode 728 gui_default_parameter (f, parms, Qmenu_bar_lines,
731 variables; ignore them here. */ 729 NILP (Vmenu_bar_mode)
732 gui_default_parameter (f, parms, Qmenu_bar_lines, 730 ? make_fixnum (0) : make_fixnum (1),
733 NILP (Vmenu_bar_mode) 731 NULL, NULL, RES_TYPE_NUMBER);
734 ? make_fixnum (0) : make_fixnum (1), 732 gui_default_parameter (f, parms, Qtab_bar_lines,
735 NULL, NULL, RES_TYPE_NUMBER); 733 NILP (Vtab_bar_mode)
736 gui_default_parameter (f, parms, Qtab_bar_lines, 734 ? make_fixnum (0) : make_fixnum (1),
737 NILP (Vtab_bar_mode) 735 NULL, NULL, RES_TYPE_NUMBER);
738 ? make_fixnum (0) : make_fixnum (1), 736 gui_default_parameter (f, parms, Qtool_bar_lines,
739 NULL, NULL, RES_TYPE_NUMBER); 737 NILP (Vtool_bar_mode)
740 gui_default_parameter (f, parms, Qtool_bar_lines, 738 ? make_fixnum (0) : make_fixnum (1),
741 NILP (Vtool_bar_mode) 739 NULL, NULL, RES_TYPE_NUMBER);
742 ? make_fixnum (0) : make_fixnum (1), 740 gui_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate",
743 NULL, NULL, RES_TYPE_NUMBER); 741 "BufferPredicate", RES_TYPE_SYMBOL);
744 gui_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate", 742 gui_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
745 "BufferPredicate", RES_TYPE_SYMBOL); 743 RES_TYPE_STRING);
746 gui_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
747 RES_TYPE_STRING);
748 }
749 744
750 parms = get_geometry_from_preferences (dpyinfo, parms); 745 parms = get_geometry_from_preferences (dpyinfo, parms);
751 window_prompting = gui_figure_window_size (f, parms, false, true); 746 window_prompting = gui_figure_window_size (f, parms, false, true);
752 747
753 if (ttip_p)
754 {
755 /* No fringes on tip frame. */
756 f->fringe_cols = 0;
757 f->left_fringe_width = 0;
758 f->right_fringe_width = 0;
759 /* No dividers on tip frame. */
760 f->right_divider_width = 0;
761 f->bottom_divider_width = 0;
762 }
763
764 tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, 748 tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0,
765 RES_TYPE_BOOLEAN); 749 RES_TYPE_BOOLEAN);
766 f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem)); 750 f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem));
767 751
768 /* Add `tooltip' frame parameter's default value. */
769 if (NILP (Fframe_parameter (frame, Qtooltip)) && ttip_p)
770 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtooltip, Qt), Qnil));
771
772#define ASSIGN_CURSOR(cursor, be_cursor) \ 752#define ASSIGN_CURSOR(cursor, be_cursor) \
773 (FRAME_OUTPUT_DATA (f)->cursor = be_cursor) 753 (FRAME_OUTPUT_DATA (f)->cursor = be_cursor)
774 754
@@ -803,16 +783,13 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
803 ASSIGN_CURSOR (current_cursor, FRAME_OUTPUT_DATA (f)->text_cursor); 783 ASSIGN_CURSOR (current_cursor, FRAME_OUTPUT_DATA (f)->text_cursor);
804#undef ASSIGN_CURSOR 784#undef ASSIGN_CURSOR
805 785
806
807 if (ttip_p)
808 f->no_split = true;
809 f->terminal->reference_count++; 786 f->terminal->reference_count++;
810 787
811 FRAME_OUTPUT_DATA (f)->window = BWindow_new (&FRAME_OUTPUT_DATA (f)->view); 788 FRAME_OUTPUT_DATA (f)->window = BWindow_new (&FRAME_OUTPUT_DATA (f)->view);
812 if (!FRAME_OUTPUT_DATA (f)->window) 789 if (!FRAME_OUTPUT_DATA (f)->window)
813 xsignal1 (Qerror, build_unibyte_string ("Could not create window")); 790 xsignal1 (Qerror, build_unibyte_string ("Could not create window"));
814 791
815 if (!minibuffer_only && !ttip_p && FRAME_EXTERNAL_MENU_BAR (f)) 792 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
816 initialize_frame_menubar (f); 793 initialize_frame_menubar (f);
817 794
818 FRAME_OUTPUT_DATA (f)->window_desc = FRAME_OUTPUT_DATA (f)->window; 795 FRAME_OUTPUT_DATA (f)->window_desc = FRAME_OUTPUT_DATA (f)->window;
@@ -839,58 +816,33 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
839 816
840 gui_default_parameter (f, parms, Qicon_type, Qnil, 817 gui_default_parameter (f, parms, Qicon_type, Qnil,
841 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL); 818 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
842 if (ttip_p) 819 gui_default_parameter (f, parms, Qauto_raise, Qnil,
843 { 820 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
844 gui_default_parameter (f, parms, Qundecorated, Qt, NULL, NULL, RES_TYPE_BOOLEAN); 821 gui_default_parameter (f, parms, Qauto_lower, Qnil,
845 gui_default_parameter (f, parms, Qno_accept_focus, Qt, NULL, NULL, 822 "autoLower", "AutoLower", RES_TYPE_BOOLEAN);
846 RES_TYPE_BOOLEAN); 823 gui_default_parameter (f, parms, Qcursor_type, Qbox,
847 } 824 "cursorType", "CursorType", RES_TYPE_SYMBOL);
848 else 825 gui_default_parameter (f, parms, Qscroll_bar_width, Qnil,
849 { 826 "scrollBarWidth", "ScrollBarWidth",
850 gui_default_parameter (f, parms, Qauto_raise, Qnil, 827 RES_TYPE_NUMBER);
851 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN); 828 gui_default_parameter (f, parms, Qscroll_bar_height, Qnil,
852 gui_default_parameter (f, parms, Qauto_lower, Qnil, 829 "scrollBarHeight", "ScrollBarHeight",
853 "autoLower", "AutoLower", RES_TYPE_BOOLEAN); 830 RES_TYPE_NUMBER);
854 gui_default_parameter (f, parms, Qcursor_type, Qbox, 831 gui_default_parameter (f, parms, Qalpha, Qnil,
855 "cursorType", "CursorType", RES_TYPE_SYMBOL); 832 "alpha", "Alpha", RES_TYPE_NUMBER);
856 gui_default_parameter (f, parms, Qscroll_bar_width, Qnil, 833 gui_default_parameter (f, parms, Qfullscreen, Qnil,
857 "scrollBarWidth", "ScrollBarWidth", 834 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
858 RES_TYPE_NUMBER);
859 gui_default_parameter (f, parms, Qscroll_bar_height, Qnil,
860 "scrollBarHeight", "ScrollBarHeight",
861 RES_TYPE_NUMBER);
862 gui_default_parameter (f, parms, Qalpha, Qnil,
863 "alpha", "Alpha", RES_TYPE_NUMBER);
864 gui_default_parameter (f, parms, Qfullscreen, Qnil,
865 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
866 }
867 835
868 gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil, 836 gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil,
869 "inhibitDoubleBuffering", "InhibitDoubleBuffering", 837 "inhibitDoubleBuffering", "InhibitDoubleBuffering",
870 RES_TYPE_BOOLEAN); 838 RES_TYPE_BOOLEAN);
871 839
872 if (ttip_p)
873 {
874 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
875
876 call2 (Qface_set_after_frame_default, frame, Qnil);
877
878 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
879 {
880 AUTO_FRAME_ARG (arg, Qbackground_color, bg);
881 Fmodify_frame_parameters (frame, arg);
882 }
883 }
884
885 if (ttip_p)
886 face_change = face_change_before;
887
888 f->can_set_window_size = true; 840 f->can_set_window_size = true;
889 841
890 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 842 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
891 0, true, ttip_p ? Qtip_frame : Qx_create_frame_2); 843 0, true, Qx_create_frame_2);
892 844
893 if (!FRAME_OUTPUT_DATA (f)->explicit_parent && !ttip_p) 845 if (!FRAME_OUTPUT_DATA (f)->explicit_parent)
894 { 846 {
895 Lisp_Object visibility; 847 Lisp_Object visibility;
896 848
@@ -908,13 +860,10 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
908 } 860 }
909 } 861 }
910 862
911 if (!ttip_p) 863 if (FRAME_HAS_MINIBUF_P (f)
912 { 864 && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame))
913 if (FRAME_HAS_MINIBUF_P (f) 865 || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
914 && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame)) 866 kset_default_minibuffer_frame (kb, frame);
915 || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
916 kset_default_minibuffer_frame (kb, frame);
917 }
918 867
919 for (tem = parms; CONSP (tem); tem = XCDR (tem)) 868 for (tem = parms; CONSP (tem); tem = XCDR (tem))
920 if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) 869 if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
@@ -929,13 +878,230 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
929 and similar functions. */ 878 and similar functions. */
930 Vwindow_list = Qnil; 879 Vwindow_list = Qnil;
931 880
932 if (ttip_p) 881 return unbind_to (count, frame);
933 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 882}
934 0, true, Qtip_frame); 883
884/* Create a frame for a tooltip. PARMS is a list of frame parameters.
885 TEXT is the string to display in the tip frame. Value is the
886 frame.
887
888 Note that functions called here, esp. gui_default_parameter can
889 signal errors, for instance when a specified color name is
890 undefined. We have to make sure that we're in a consistent state
891 when this happens. */
935 892
893static Lisp_Object
894haiku_create_tip_frame (Lisp_Object parms)
895{
896 struct frame *f;
897 Lisp_Object frame;
898 Lisp_Object name;
899 ptrdiff_t count = SPECPDL_INDEX ();
900 bool face_change_before = face_change;
901 struct haiku_display_info *dpyinfo = x_display_list;
902
903 if (!dpyinfo->terminal->name)
904 error ("Terminal is not live, can't create new frames on it");
905
906 parms = Fcopy_alist (parms);
907
908 /* Get the name of the frame to use for resource lookup. */
909 name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
910 RES_TYPE_STRING);
911 if (!STRINGP (name)
912 && !EQ (name, Qunbound)
913 && !NILP (name))
914 error ("Invalid frame name--not a string or nil");
915
916 frame = Qnil;
917 f = make_frame (false);
918 f->wants_modeline = false;
919 XSETFRAME (frame, f);
920 record_unwind_protect (unwind_create_tip_frame, frame);
921
922 f->terminal = dpyinfo->terminal;
923
924 /* By setting the output method, we're essentially saying that
925 the frame is live, as per FRAME_LIVE_P. If we get a signal
926 from this point on, x_destroy_window might screw up reference
927 counts etc. */
928 f->output_method = output_haiku;
929 f->output_data.haiku = xzalloc (sizeof *f->output_data.haiku);
930
931 f->output_data.haiku->pending_zoom_x = INT_MIN;
932 f->output_data.haiku->pending_zoom_y = INT_MIN;
933 f->output_data.haiku->pending_zoom_width = INT_MIN;
934 f->output_data.haiku->pending_zoom_height = INT_MIN;
935
936 f->tooltip = true;
937 fset_icon_name (f, Qnil);
938 FRAME_DISPLAY_INFO (f) = dpyinfo;
939
940 FRAME_OUTPUT_DATA (f)->parent_desc = NULL;
941 FRAME_OUTPUT_DATA (f)->explicit_parent = 0;
942
943 /* Set the name; the functions to which we pass f expect the name to
944 be set. */
945 if (EQ (name, Qunbound) || NILP (name))
946 f->explicit_name = false;
947 else
948 {
949 fset_name (f, name);
950 f->explicit_name = true;
951 /* use the frame's title when getting resources for this frame. */
952 specbind (Qx_resource_name, name);
953 }
954
955#ifdef USE_BE_CAIRO
956 register_font_driver (&ftcrfont_driver, f);
957#ifdef HAVE_HARFBUZZ
958 register_font_driver (&ftcrhbfont_driver, f);
959#endif
960#endif
961 register_font_driver (&haikufont_driver, f);
962
963 image_cache_refcount =
964 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
965
966 gui_default_parameter (f, parms, Qfont_backend, Qnil,
967 "fontBackend", "FontBackend", RES_TYPE_STRING);
968
969 /* Extract the window parameters from the supplied values that are
970 needed to determine window geometry. */
971 FRAME_RIF (f)->default_font_parameter (f, parms);
972
973 /* This defaults to 1 in order to match xterm. We recognize either
974 internalBorderWidth or internalBorder (which is what xterm calls
975 it). */
976 if (NILP (Fassq (Qinternal_border_width, parms)))
977 {
978 Lisp_Object value;
979
980 value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
981 "internalBorder", "internalBorder",
982 RES_TYPE_NUMBER);
983 if (! EQ (value, Qunbound))
984 parms = Fcons (Fcons (Qinternal_border_width, value),
985 parms);
986 }
987
988 gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (1),
989 "internalBorderWidth", "internalBorderWidth",
990 RES_TYPE_NUMBER);
991
992 gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
993 NULL, NULL, RES_TYPE_NUMBER);
994 gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
995 NULL, NULL, RES_TYPE_NUMBER);
996
997 /* Also do the stuff which must be set before the window exists. */
998 gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
999 "foreground", "Foreground", RES_TYPE_STRING);
1000
1001 gui_default_parameter (f, parms, Qbackground_color, build_string ("white"),
1002 "background", "Background", RES_TYPE_STRING);
1003 gui_default_parameter (f, parms, Qmouse_color, build_string ("black"),
1004 "pointerColor", "Foreground", RES_TYPE_STRING);
1005 gui_default_parameter (f, parms, Qcursor_color, build_string ("black"),
1006 "cursorColor", "Foreground", RES_TYPE_STRING);
1007 gui_default_parameter (f, parms, Qborder_color, build_string ("black"),
1008 "borderColor", "BorderColor", RES_TYPE_STRING);
1009 gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
1010 NULL, NULL, RES_TYPE_BOOLEAN);
1011
1012 /* Init faces before gui_default_parameter is called for the
1013 scroll-bar-width parameter because otherwise we end up in
1014 init_iterator with a null face cache, which should not happen. */
1015 init_frame_faces (f);
1016
1017 gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil,
1018 "inhibitDoubleBuffering", "InhibitDoubleBuffering",
1019 RES_TYPE_BOOLEAN);
1020
1021 gui_figure_window_size (f, parms, false, false);
1022
1023 {
1024 void *window;
1025
1026 block_input ();
1027 window = BWindow_new (&FRAME_OUTPUT_DATA (f)->view);
1028
1029 FRAME_OUTPUT_DATA (f)->window = window;
1030 if (!window)
1031 emacs_abort ();
1032
1033 FRAME_OUTPUT_DATA (f)->window_desc = window;
1034 BWindow_set_tooltip_decoration (window);
1035 unblock_input ();
1036 }
1037
1038 gui_default_parameter (f, parms, Qauto_raise, Qnil,
1039 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1040 gui_default_parameter (f, parms, Qauto_lower, Qnil,
1041 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1042 gui_default_parameter (f, parms, Qcursor_type, Qbox,
1043 "cursorType", "CursorType", RES_TYPE_SYMBOL);
1044 gui_default_parameter (f, parms, Qalpha, Qnil,
1045 "alpha", "Alpha", RES_TYPE_NUMBER);
1046
1047 initial_setup_back_buffer (f);
1048
1049 /* Add `tooltip' frame parameter's default value. */
1050 if (NILP (Fframe_parameter (frame, Qtooltip)))
1051 {
1052 AUTO_FRAME_ARG (arg, Qtooltip, Qt);
1053 Fmodify_frame_parameters (frame, arg);
1054 }
1055
1056 /* FIXME - can this be done in a similar way to normal frames?
1057 https://lists.gnu.org/r/emacs-devel/2007-10/msg00641.html */
1058
1059 /* Set up faces after all frame parameters are known. This call
1060 also merges in face attributes specified for new frames.
1061
1062 Frame parameters may be changed if .Xdefaults contains
1063 specifications for the default font. For example, if there is an
1064 `Emacs.default.attributeBackground: pink', the `background-color'
1065 attribute of the frame gets set, which let's the internal border
1066 of the tooltip frame appear in pink. Prevent this. */
1067 {
1068 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
1069
1070 call2 (Qface_set_after_frame_default, frame, Qnil);
1071
1072 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
1073 {
1074 AUTO_FRAME_ARG (arg, Qbackground_color, bg);
1075 Fmodify_frame_parameters (frame, arg);
1076 }
1077 }
1078
1079 f->no_split = true;
1080
1081 /* Now that the frame will be official, it counts as a reference to
1082 its display and terminal. */
1083 f->terminal->reference_count++;
1084
1085 /* It is now ok to make the frame official even if we get an error
1086 below. And the frame needs to be on Vframe_list or making it
1087 visible won't work. */
1088 Vframe_list = Fcons (frame, Vframe_list);
1089 f->can_set_window_size = true;
1090 adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
1091 0, true, Qtip_frame);
1092
1093 /* Setting attributes of faces of the tooltip frame from resources
1094 and similar will set face_change, which leads to the clearing of
1095 all current matrices. Since this isn't necessary here, avoid it
1096 by resetting face_change to the value it had before we created
1097 the tip frame. */
1098 face_change = face_change_before;
1099
1100 /* Discard the unwind_protect. */
936 return unbind_to (count, frame); 1101 return unbind_to (count, frame);
937} 1102}
938 1103
1104
939static void 1105static void
940compute_tip_xy (struct frame *f, 1106compute_tip_xy (struct frame *f,
941 Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, 1107 Lisp_Object parms, Lisp_Object dx, Lisp_Object dy,
@@ -1440,6 +1606,7 @@ haiku_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object o
1440 1606
1441 if (new_width == old_width) 1607 if (new_width == old_width)
1442 return; 1608 return;
1609
1443 f->internal_border_width = new_width; 1610 f->internal_border_width = new_width;
1444 1611
1445 if (FRAME_HAIKU_WINDOW (f)) 1612 if (FRAME_HAIKU_WINDOW (f))
@@ -1527,9 +1694,9 @@ haiku_set_inhibit_double_buffering (struct frame *f,
1527 Lisp_Object old_value) 1694 Lisp_Object old_value)
1528{ 1695{
1529 block_input (); 1696 block_input ();
1530#ifndef USE_BE_CAIRO
1531 if (FRAME_HAIKU_WINDOW (f)) 1697 if (FRAME_HAIKU_WINDOW (f))
1532 { 1698 {
1699#ifndef USE_BE_CAIRO
1533 if (NILP (new_value)) 1700 if (NILP (new_value))
1534 { 1701 {
1535#endif 1702#endif
@@ -1543,8 +1710,8 @@ haiku_set_inhibit_double_buffering (struct frame *f,
1543 } 1710 }
1544 else 1711 else
1545 EmacsView_disable_double_buffering (FRAME_HAIKU_VIEW (f)); 1712 EmacsView_disable_double_buffering (FRAME_HAIKU_VIEW (f));
1546 }
1547#endif 1713#endif
1714 }
1548 unblock_input (); 1715 unblock_input ();
1549} 1716}
1550 1717
@@ -1709,7 +1876,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
1709 int width, height; 1876 int width, height;
1710 BScreen_px_dim (&width, &height); 1877 BScreen_px_dim (&width, &height);
1711 1878
1712 return make_fixnum (height / (dpyinfo->resy / 25.4)); 1879 return make_fixnum (width / (dpyinfo->resx / 25.4));
1713} 1880}
1714 1881
1715DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1882DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
@@ -1717,7 +1884,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1717 doc: /* SKIP: real doc in xfns.c. */) 1884 doc: /* SKIP: real doc in xfns.c. */)
1718 (Lisp_Object parms) 1885 (Lisp_Object parms)
1719{ 1886{
1720 return haiku_create_frame (parms, 0); 1887 return haiku_create_frame (parms);
1721} 1888}
1722 1889
1723DEFUN ("x-display-visual-class", Fx_display_visual_class, 1890DEFUN ("x-display-visual-class", Fx_display_visual_class,
@@ -1752,12 +1919,13 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1752 ptrdiff_t count = SPECPDL_INDEX (); 1919 ptrdiff_t count = SPECPDL_INDEX ();
1753 ptrdiff_t count_1; 1920 ptrdiff_t count_1;
1754 Lisp_Object window, size, tip_buf; 1921 Lisp_Object window, size, tip_buf;
1755
1756 AUTO_STRING (tip, " *tip*"); 1922 AUTO_STRING (tip, " *tip*");
1757 1923
1758 specbind (Qinhibit_redisplay, Qt); 1924 specbind (Qinhibit_redisplay, Qt);
1759 1925
1760 CHECK_STRING (string); 1926 CHECK_STRING (string);
1927 if (SCHARS (string) == 0)
1928 string = make_unibyte_string (" ", 1);
1761 1929
1762 if (NILP (frame)) 1930 if (NILP (frame))
1763 frame = selected_frame; 1931 frame = selected_frame;
@@ -1778,7 +1946,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1778 else 1946 else
1779 CHECK_FIXNUM (dy); 1947 CHECK_FIXNUM (dy);
1780 1948
1781 if (haiku_use_system_tooltips) 1949 if (use_system_tooltips)
1782 { 1950 {
1783 int root_x, root_y; 1951 int root_x, root_y;
1784 CHECK_STRING (string); 1952 CHECK_STRING (string);
@@ -1821,24 +1989,21 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1821 { 1989 {
1822 if (FRAME_VISIBLE_P (XFRAME (tip_frame)) 1990 if (FRAME_VISIBLE_P (XFRAME (tip_frame))
1823 && EQ (frame, tip_last_frame) 1991 && EQ (frame, tip_last_frame)
1824 && !NILP (Fequal_including_properties (string, tip_last_string)) 1992 && !NILP (Fequal_including_properties (tip_last_string, string))
1825 && !NILP (Fequal (parms, tip_last_parms))) 1993 && !NILP (Fequal (tip_last_parms, parms)))
1826 { 1994 {
1827 /* Only DX and DY have changed. */ 1995 /* Only DX and DY have changed. */
1828 tip_f = XFRAME (tip_frame); 1996 tip_f = XFRAME (tip_frame);
1829 if (!NILP (tip_timer)) 1997 if (!NILP (tip_timer))
1830 { 1998 {
1831 Lisp_Object timer = tip_timer; 1999 call1 (Qcancel_timer, tip_timer);
1832
1833 tip_timer = Qnil; 2000 tip_timer = Qnil;
1834 call1 (Qcancel_timer, timer);
1835 } 2001 }
1836 2002
1837 block_input (); 2003 block_input ();
1838 compute_tip_xy (tip_f, parms, dx, dy, FRAME_PIXEL_WIDTH (tip_f), 2004 compute_tip_xy (tip_f, parms, dx, dy, FRAME_PIXEL_WIDTH (tip_f),
1839 FRAME_PIXEL_HEIGHT (tip_f), &root_x, &root_y); 2005 FRAME_PIXEL_HEIGHT (tip_f), &root_x, &root_y);
1840 haiku_set_offset (tip_f, root_x, root_y, 1); 2006 BWindow_set_offset (FRAME_HAIKU_WINDOW (tip_f), root_x, root_y);
1841 haiku_visualize_frame (tip_f);
1842 unblock_input (); 2007 unblock_input ();
1843 2008
1844 goto start_timer; 2009 goto start_timer;
@@ -1849,8 +2014,8 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1849 Lisp_Object tail, elt, parm, last; 2014 Lisp_Object tail, elt, parm, last;
1850 2015
1851 /* Check if every parameter in PARMS has the same value in 2016 /* Check if every parameter in PARMS has the same value in
1852 tip_last_parms. This may destruct tip_last_parms 2017 tip_last_parms. This may destruct tip_last_parms which,
1853 which, however, will be recreated below. */ 2018 however, will be recreated below. */
1854 for (tail = parms; CONSP (tail); tail = XCDR (tail)) 2019 for (tail = parms; CONSP (tail); tail = XCDR (tail))
1855 { 2020 {
1856 elt = XCAR (tail); 2021 elt = XCAR (tail);
@@ -1876,8 +2041,9 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1876 call2 (Qassq_delete_all, parm, tip_last_parms); 2041 call2 (Qassq_delete_all, parm, tip_last_parms);
1877 } 2042 }
1878 2043
1879 /* Now check if there's a parameter left in tip_last_parms with a 2044 /* Now check if every parameter in what is left of
1880 non-nil value. */ 2045 tip_last_parms with a non-nil value has an association in
2046 PARMS. */
1881 for (tail = tip_last_parms; CONSP (tail); tail = XCDR (tail)) 2047 for (tail = tip_last_parms; CONSP (tail); tail = XCDR (tail))
1882 { 2048 {
1883 elt = XCAR (tail); 2049 elt = XCAR (tail);
@@ -1903,10 +2069,6 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1903 tip_last_string = string; 2069 tip_last_string = string;
1904 tip_last_parms = parms; 2070 tip_last_parms = parms;
1905 2071
1906 /* Block input until the tip has been fully drawn, to avoid crashes
1907 when drawing tips in menus. */
1908 block_input ();
1909
1910 if (NILP (tip_frame) || !FRAME_LIVE_P (XFRAME (tip_frame))) 2072 if (NILP (tip_frame) || !FRAME_LIVE_P (XFRAME (tip_frame)))
1911 { 2073 {
1912 /* Add default values to frame parameters. */ 2074 /* Add default values to frame parameters. */
@@ -1917,21 +2079,16 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1917 if (NILP (Fassq (Qborder_width, parms))) 2079 if (NILP (Fassq (Qborder_width, parms)))
1918 parms = Fcons (Fcons (Qborder_width, make_fixnum (1)), parms); 2080 parms = Fcons (Fcons (Qborder_width, make_fixnum (1)), parms);
1919 if (NILP (Fassq (Qborder_color, parms))) 2081 if (NILP (Fassq (Qborder_color, parms)))
1920 parms = Fcons (Fcons (Qborder_color, build_string ("lightyellow")), 2082 parms = Fcons (Fcons (Qborder_color, build_string ("lightyellow")), parms);
1921 parms);
1922 if (NILP (Fassq (Qbackground_color, parms))) 2083 if (NILP (Fassq (Qbackground_color, parms)))
1923 parms = Fcons (Fcons (Qbackground_color, build_string ("lightyellow")), 2084 parms = Fcons (Fcons (Qbackground_color, build_string ("lightyellow")),
1924 parms); 2085 parms);
1925 2086
1926 /* Create a frame for the tooltip and record it in the global 2087 /* Create a frame for the tooltip, and record it in the global
1927 variable tip_frame. */ 2088 variable tip_frame. */
1928 2089 if (NILP (tip_frame = haiku_create_tip_frame (parms)))
1929 if (NILP (tip_frame = haiku_create_frame (parms, 1))) 2090 /* Creating the tip frame failed. */
1930 { 2091 return unbind_to (count, Qnil);
1931 /* Creating the tip frame failed. */
1932 unblock_input ();
1933 return unbind_to (count, Qnil);
1934 }
1935 } 2092 }
1936 2093
1937 tip_f = XFRAME (tip_frame); 2094 tip_f = XFRAME (tip_frame);
@@ -1971,11 +2128,11 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1971 2128
1972 w->pixel_width = w->total_cols * FRAME_COLUMN_WIDTH (tip_f); 2129 w->pixel_width = w->total_cols * FRAME_COLUMN_WIDTH (tip_f);
1973 w->pixel_height = w->total_lines * FRAME_LINE_HEIGHT (tip_f); 2130 w->pixel_height = w->total_lines * FRAME_LINE_HEIGHT (tip_f);
1974 FRAME_TOTAL_COLS (tip_f) = WINDOW_TOTAL_COLS (w); 2131 FRAME_TOTAL_COLS (tip_f) = w->total_cols;
1975 adjust_frame_glyphs (tip_f); 2132 adjust_frame_glyphs (tip_f);
1976 2133
1977 /* Insert STRING into the root window's buffer and fit the frame to 2134 /* Insert STRING into root window's buffer and fit the frame to the
1978 the buffer. */ 2135 buffer. */
1979 count_1 = SPECPDL_INDEX (); 2136 count_1 = SPECPDL_INDEX ();
1980 old_buffer = current_buffer; 2137 old_buffer = current_buffer;
1981 set_buffer_internal_1 (XBUFFER (w->contents)); 2138 set_buffer_internal_1 (XBUFFER (w->contents));
@@ -1996,22 +2153,28 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
1996 /* Add the frame's internal border to calculated size. */ 2153 /* Add the frame's internal border to calculated size. */
1997 width = XFIXNUM (Fcar (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f); 2154 width = XFIXNUM (Fcar (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f);
1998 height = XFIXNUM (Fcdr (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f); 2155 height = XFIXNUM (Fcdr (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f);
2156
1999 /* Calculate position of tooltip frame. */ 2157 /* Calculate position of tooltip frame. */
2000 compute_tip_xy (tip_f, parms, dx, dy, width, height, &root_x, &root_y); 2158 compute_tip_xy (tip_f, parms, dx, dy, width, height, &root_x, &root_y);
2001 BWindow_resize (FRAME_HAIKU_WINDOW (tip_f), width, height); 2159
2002 haiku_set_offset (tip_f, root_x, root_y, 1); 2160 /* Show tooltip frame. */
2003 BWindow_set_tooltip_decoration (FRAME_HAIKU_WINDOW (tip_f)); 2161 block_input ();
2004 BView_set_view_cursor (FRAME_HAIKU_VIEW (tip_f), 2162 void *wnd = FRAME_HAIKU_WINDOW (tip_f);
2005 FRAME_OUTPUT_DATA (XFRAME (frame))->current_cursor); 2163 BWindow_resize (wnd, width, height);
2006 SET_FRAME_VISIBLE (tip_f, 1); 2164 BView_resize_to (FRAME_HAIKU_VIEW (tip_f), width, height);
2007 BWindow_set_visible (FRAME_HAIKU_WINDOW (tip_f), 1); 2165 BWindow_set_offset (wnd, root_x, root_y);
2166 BWindow_set_visible (wnd, true);
2167 SET_FRAME_VISIBLE (tip_f, true);
2168 FRAME_PIXEL_WIDTH (tip_f) = width;
2169 FRAME_PIXEL_HEIGHT (tip_f) = height;
2170 BWindow_sync (wnd);
2171 unblock_input ();
2008 2172
2009 w->must_be_updated_p = true; 2173 w->must_be_updated_p = true;
2010 flush_frame (tip_f);
2011 update_single_window (w); 2174 update_single_window (w);
2175 flush_frame (tip_f);
2012 set_buffer_internal_1 (old_buffer); 2176 set_buffer_internal_1 (old_buffer);
2013 unbind_to (count_1, Qnil); 2177 unbind_to (count_1, Qnil);
2014 unblock_input ();
2015 windows_or_buffers_changed = old_windows_or_buffers_changed; 2178 windows_or_buffers_changed = old_windows_or_buffers_changed;
2016 2179
2017 start_timer: 2180 start_timer:
@@ -2459,6 +2622,7 @@ syms_of_haikufns (void)
2459 DEFSYM (Qalways, "always"); 2622 DEFSYM (Qalways, "always");
2460 DEFSYM (Qnot_useful, "not-useful"); 2623 DEFSYM (Qnot_useful, "not-useful");
2461 DEFSYM (Qwhen_mapped, "when-mapped"); 2624 DEFSYM (Qwhen_mapped, "when-mapped");
2625 DEFSYM (Qtooltip_reuse_hidden_frame, "tooltip-reuse-hidden-frame");
2462 2626
2463 defsubr (&Sx_hide_tip); 2627 defsubr (&Sx_hide_tip);
2464 defsubr (&Sxw_display_color_p); 2628 defsubr (&Sxw_display_color_p);
@@ -2508,14 +2672,6 @@ syms_of_haikufns (void)
2508 doc: /* SKIP: real doc in xfns.c. */); 2672 doc: /* SKIP: real doc in xfns.c. */);
2509 Vx_max_tooltip_size = Fcons (make_fixnum (80), make_fixnum (40)); 2673 Vx_max_tooltip_size = Fcons (make_fixnum (80), make_fixnum (40));
2510 2674
2511 DEFVAR_BOOL ("haiku-use-system-tooltips", haiku_use_system_tooltips,
2512 doc: /* When non-nil, Emacs will display tooltips using the App Kit.
2513This can avoid a great deal of consing that does not play
2514well with the Haiku memory allocator, but comes with the
2515disadvantage of not being able to use special display properties
2516within tooltips. */);
2517 haiku_use_system_tooltips = 1;
2518
2519#ifdef USE_BE_CAIRO 2675#ifdef USE_BE_CAIRO
2520 DEFVAR_LISP ("cairo-version-string", Vcairo_version_string, 2676 DEFVAR_LISP ("cairo-version-string", Vcairo_version_string,
2521 doc: /* Version info for cairo. */); 2677 doc: /* Version info for cairo. */);