diff options
Diffstat (limited to 'src/frame.c')
-rw-r--r-- | src/frame.c | 621 |
1 files changed, 390 insertions, 231 deletions
diff --git a/src/frame.c b/src/frame.c index 4371ef7f064..03bbbfb4da2 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1,6 +1,6 @@ /* Generic frame functions. -Copyright (C) 1993-1995, 1997, 1999-2018 Free Software Foundation, Inc. +Copyright (C) 1993-1995, 1997, 1999-2019 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -53,11 +53,14 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #ifdef USE_X_TOOLKIT #include "widget.h" #endif +#include "pdumper.h" /* The currently selected frame. */ - Lisp_Object selected_frame; +/* The selected frame the last time window change functions were run. */ +Lisp_Object old_selected_frame; + /* A frame which is not just a mini-buffer, or NULL if there are no such frames. This is usually the most recent such frame that was selected. */ @@ -67,14 +70,14 @@ static struct frame *last_nonminibuf_frame; bool frame_garbaged; /* The default tool bar height for future frames. */ -#if defined USE_GTK || defined HAVE_NS +#ifdef HAVE_EXT_TOOL_BAR enum { frame_default_tool_bar_height = 0 }; #else int frame_default_tool_bar_height; #endif #ifdef HAVE_WINDOW_SYSTEM -static void x_report_frame_params (struct frame *, Lisp_Object *); +static void gui_report_frame_params (struct frame *, Lisp_Object *); #endif /* These setters are used only in this file, so they can be private. */ @@ -160,10 +163,8 @@ frame_size_history_add (struct frame *f, Lisp_Object fun_symbol, Fcons (list4 (frame, fun_symbol, ((width > 0) - ? list4 (make_fixnum (FRAME_TEXT_WIDTH (f)), - make_fixnum (FRAME_TEXT_HEIGHT (f)), - make_fixnum (width), - make_fixnum (height)) + ? list4i (FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), + width, height) : Qnil), rest), XCDR (frame_size_history))); @@ -481,7 +482,8 @@ keep_ratio (struct frame *f, struct frame *p, int old_width, int old_height, f->top_pos = pos_y; } - x_set_offset (f, pos_x, pos_y, -1); + if (FRAME_TERMINAL (f)->set_frame_offset_hook) + FRAME_TERMINAL (f)->set_frame_offset_hook (f, pos_x, pos_y, -1); } if (!CONSP (keep_ratio) || !NILP (Fcar (keep_ratio))) @@ -517,36 +519,37 @@ keep_ratio (struct frame *f, struct frame *p, int old_width, int old_height, * text size of F in pixels. A value of -1 means no change is requested * for that direction (but the frame may still have to be resized to * accommodate windows with their minimum sizes). This can either issue - * a request to resize the frame externally (via x_set_window_size), to + * a request to resize the frame externally (via set_window_size_hook), to * resize the frame internally (via resize_frame_windows) or do nothing * at all. * * The argument INHIBIT can assume the following values: * - * 0 means to unconditionally call x_set_window_size even if sizes + * 0 means to unconditionally call set_window_size_hook even if sizes * apparently do not change. Fx_create_frame uses this to pass the * initial size to the window manager. * - * 1 means to call x_set_window_size if the native frame size really + * 1 means to call set_window_size_hook if the native frame size really * changes. Fset_frame_size, Fset_frame_height, ... use this. * - * 2 means to call x_set_window_size provided frame_inhibit_resize + * 2 means to call set_window_size_hook provided frame_inhibit_resize * allows it. The menu and tool bar code use this ("3" won't work * here in general because menu and tool bar are often not counted in * the frame's text height). * - * 3 means call x_set_window_size if window minimum sizes must be - * preserved or frame_inhibit_resize allows it. x_set_left_fringe, - * x_set_scroll_bar_width, x_new_font ... use (or should use) this. + * 3 means call set_window_size_hook if window minimum sizes must be + * preserved or frame_inhibit_resize allows it. + * gui_set_left_fringe, gui_set_scroll_bar_width, gui_new_font + * ... use (or should use) this. * - * 4 means call x_set_window_size only if window minimum sizes must be - * preserved. x_set_right_divider_width, x_set_border_width and the - * code responsible for wrapping the tool bar use this. + * 4 means call set_window_size_hook only if window minimum sizes must + * be preserved. x_set_right_divider_width, x_set_border_width and + * the code responsible for wrapping the tool bar use this. * - * 5 means to never call x_set_window_size. change_frame_size uses + * 5 means to never call set_window_size_hook. change_frame_size uses * this. * - * Note that even when x_set_window_size is not called, individual + * Note that even when set_window_size_hook is not called, individual * windows may have to be resized (via `window--sanitize-window-sizes') * in order to support minimum size constraints. * @@ -569,7 +572,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, /* The following two values are calculated from the old frame pixel sizes and any "new" settings for tool bar, menu bar and internal borders. We do it this way to detect whether we have to call - x_set_window_size as consequence of the new settings. */ + set_window_size_hook as consequence of the new settings. */ int windows_width = FRAME_WINDOWS_WIDTH (f); int windows_height = FRAME_WINDOWS_HEIGHT (f); int min_windows_width, min_windows_height; @@ -644,7 +647,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f) - && f->can_x_set_window_size + && f->can_set_window_size && ((!inhibit_horizontal && (new_pixel_width != old_pixel_width || inhibit == 0 || inhibit == 2)) @@ -667,7 +670,12 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, list2 (inhibit_horizontal ? Qt : Qnil, inhibit_vertical ? Qt : Qnil)); - x_set_window_size (f, 0, new_text_width, new_text_height, 1); + if (FRAME_TERMINAL (f)->set_window_size_hook) + FRAME_TERMINAL (f)->set_window_size_hook (f, + 0, + new_text_width, + new_text_height, + 1); f->resized_p = true; return; @@ -711,7 +719,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f)) FrameCols (FRAME_TTY (f)) = new_cols; -#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS) +#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR) if (WINDOWP (f->tool_bar_window)) { XWINDOW (f->tool_bar_window)->pixel_width = new_windows_width; @@ -741,8 +749,8 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, frame_size_history_add (f, Qadjust_frame_size_3, new_text_width, new_text_height, - list4 (make_fixnum (old_pixel_width), make_fixnum (old_pixel_height), - make_fixnum (new_pixel_width), make_fixnum (new_pixel_height))); + list4i (old_pixel_width, old_pixel_height, + new_pixel_width, new_pixel_height)); /* Assign new sizes. */ FRAME_TEXT_WIDTH (f) = new_text_width; @@ -797,7 +805,8 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, static struct frame * allocate_frame (void) { - return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, face_cache, PVEC_FRAME); + return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, tool_bar_items, + PVEC_FRAME); } struct frame * @@ -825,7 +834,7 @@ make_frame (bool mini_p) f->wants_modeline = true; f->redisplay = true; f->garbaged = true; - f->can_x_set_window_size = false; + f->can_set_window_size = false; f->after_make_frame = false; f->inhibit_horizontal_resize = false; f->inhibit_vertical_resize = false; @@ -847,7 +856,7 @@ make_frame (bool mini_p) f->no_accept_focus = false; f->z_group = z_group_none; f->tooltip = false; -#if ! defined (USE_GTK) && ! defined (HAVE_NS) +#ifndef HAVE_EXT_TOOL_BAR f->last_tool_bar_item = -1; #endif #ifdef NS_IMPL_COCOA @@ -855,7 +864,8 @@ make_frame (bool mini_p) f->ns_transparent_titlebar = false; #endif #endif - + /* This one should never be zero. */ + f->change_stamp = 1; root_window = make_window (); rw = XWINDOW (root_window); if (mini_p) @@ -1048,10 +1058,7 @@ make_initial_frame (void) Lisp_Object frame; eassert (initial_kboard); - - /* The first call must initialize Vframe_list. */ - if (! (NILP (Vframe_list) || CONSP (Vframe_list))) - Vframe_list = Qnil; + eassert (NILP (Vframe_list) || CONSP (Vframe_list)); terminal = init_initial_terminal (); @@ -1089,7 +1096,7 @@ make_initial_frame (void) last_nonminibuf_frame = f; - f->can_x_set_window_size = true; + f->can_set_window_size = true; f->after_make_frame = true; return f; @@ -1118,6 +1125,7 @@ make_terminal_frame (struct terminal *terminal) f->terminal = terminal; f->terminal->reference_count++; #ifdef MSDOS + f->output_data.tty = &the_only_tty_output; f->output_data.tty->display_info = &the_only_display_info; if (!inhibit_window_system && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)) @@ -1290,7 +1298,7 @@ affects all frames on the same terminal device. */) for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem)) XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem)))); - f->can_x_set_window_size = true; + f->can_set_window_size = true; f->after_make_frame = true; return frame; @@ -1364,20 +1372,20 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor #else /* ! 0 */ /* Instead, apply it only to the frame we're pointing to. */ #ifdef HAVE_WINDOW_SYSTEM - if (track && FRAME_WINDOW_P (f)) + if (track && FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->get_focus_frame) { - Lisp_Object focus, xfocus; + Lisp_Object focus, gfocus; - xfocus = x_get_focus_frame (f); - if (FRAMEP (xfocus)) + gfocus = FRAME_TERMINAL (f)->get_focus_frame (f); + if (FRAMEP (gfocus)) { - focus = FRAME_FOCUS_FRAME (XFRAME (xfocus)); + focus = FRAME_FOCUS_FRAME (XFRAME (gfocus)); if ((FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) /* Redirect frame focus also when FRAME has its minibuffer window on the selected frame (see Bug#24500). */ || (NILP (focus) && EQ (FRAME_MINIBUF_WINDOW (f), sf->selected_window))) - Fredirect_frame_focus (xfocus, frame); + Fredirect_frame_focus (gfocus, frame); } } #endif /* HAVE_X_WINDOWS */ @@ -1451,7 +1459,8 @@ This function returns FRAME, or nil if FRAME has been deleted. */) return do_switch_frame (frame, 1, 0, norecord); } -DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "^e", +DEFUN ("handle-switch-frame", Fhandle_switch_frame, + Shandle_switch_frame, 1, 1, "^e", doc: /* Handle a switch-frame event EVENT. Switch-frame events are usually bound to this function. A switch-frame event is an event Emacs sends itself to @@ -1471,6 +1480,18 @@ DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, { return selected_frame; } + +DEFUN ("old-selected-frame", Fold_selected_frame, + Sold_selected_frame, 0, 0, 0, + doc: /* Return the old selected FRAME. +FRAME must be a live frame and defaults to the selected one. + +The return value is the frame selected the last time window change +functions were run. */) + (void) +{ + return old_selected_frame; +} DEFUN ("frame-list", Fframe_list, Sframe_list, 0, 0, 0, @@ -1837,6 +1858,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) Lisp_Object frames, frame1; int minibuffer_selected, is_tooltip_frame; bool nochild = !FRAME_PARENT_FRAME (f); + Lisp_Object minibuffer_child_frame = Qnil; if (!FRAME_LIVE_P (f)) return Qnil; @@ -1853,13 +1875,33 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* Softly delete all frames with this frame as their parent frame or as their `delete-before' frame parameter value. */ FOR_EACH_FRAME (frames, frame1) - if (FRAME_PARENT_FRAME (XFRAME (frame1)) == f + { + struct frame *f1 = XFRAME (frame1); + + if (EQ (frame1, frame) || FRAME_TOOLTIP_P (f1)) + continue; + else if (FRAME_PARENT_FRAME (f1) == f) + { + if (FRAME_HAS_MINIBUF_P (f1) && !FRAME_HAS_MINIBUF_P (f) + && EQ (FRAME_MINIBUF_WINDOW (f), FRAME_MINIBUF_WINDOW (f1))) + /* frame1 owns frame's minibuffer window so we must not + delete it here to avoid a surrogate minibuffer error. + Unparent frame1 and make it a top-level frame. */ + { + Fmodify_frame_parameters + (frame1, Fcons (Fcons (Qparent_frame, Qnil), Qnil)); + minibuffer_child_frame = frame1; + } + else + delete_frame (frame1, Qnil); + } + else if (nochild + && EQ (get_frame_param (XFRAME (frame1), Qdelete_before), frame)) /* Process `delete-before' parameter iff FRAME is not a child frame. This avoids that we enter an infinite chain of mixed dependencies. */ - || (nochild - && EQ (get_frame_param (XFRAME (frame1), Qdelete_before), frame))) - delete_frame (frame1, Qnil); + delete_frame (frame1, Qnil); + } /* Does this frame have a minibuffer, and is it the surrogate minibuffer for any other frame? */ @@ -2124,18 +2166,27 @@ delete_frame (Lisp_Object frame, Lisp_Object force) { struct frame *f1 = XFRAME (frame1); - /* Consider only frames on the same kboard - and only those with minibuffers. */ - if (kb == FRAME_KBOARD (f1) - && FRAME_HAS_MINIBUF_P (f1)) + /* Set frame_on_same_kboard to frame1 if it is on the same + keyboard. Set frame_with_minibuf to frame1 if it also + has a minibuffer. Leave the loop immediately if frame1 + is also minibuffer-only. + + Emacs 26 does _not_ set frame_on_same_kboard here when it + finds a minibuffer-only frame and subsequently fails to + set default_minibuffer_frame below. Not a great deal and + never noticed since make_frame_without_minibuffer creates + a new minibuffer frame in that case (which can be a minor + annoyance though). To consider for Emacs 26.3. */ + if (kb == FRAME_KBOARD (f1)) { - frame_with_minibuf = frame1; - if (FRAME_MINIBUF_ONLY_P (f1)) - break; + frame_on_same_kboard = frame1; + if (FRAME_HAS_MINIBUF_P (f1)) + { + frame_with_minibuf = frame1; + if (FRAME_MINIBUF_ONLY_P (f1)) + break; + } } - - if (kb == FRAME_KBOARD (f1)) - frame_on_same_kboard = frame1; } if (!NILP (frame_on_same_kboard)) @@ -2168,7 +2219,46 @@ delete_frame (Lisp_Object frame, Lisp_Object force) = Fcons (list3 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame), pending_funcalls); else - safe_call2 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame); + safe_call2 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame); + + if (!NILP (minibuffer_child_frame)) + /* If minibuffer_child_frame is non-nil, it was FRAME's minibuffer + child frame. Delete it unless it's also the minibuffer frame + of another frame in which case we make sure it's visible. */ + { + struct frame *f1 = XFRAME (minibuffer_child_frame); + + if (FRAME_LIVE_P (f1)) + { + Lisp_Object window1 = FRAME_ROOT_WINDOW (f1); + Lisp_Object frame2; + + FOR_EACH_FRAME (frames, frame2) + { + struct frame *f2 = XFRAME (frame2); + + if (EQ (frame2, minibuffer_child_frame) || FRAME_TOOLTIP_P (f2)) + continue; + else if (EQ (FRAME_MINIBUF_WINDOW (f2), window1)) + { + /* minibuffer_child_frame serves as minibuffer frame + for at least one other frame - so make it visible + and quit. */ + if (!FRAME_VISIBLE_P (f1) && !FRAME_ICONIFIED_P (f1)) + Fmake_frame_visible (minibuffer_child_frame); + + return Qnil; + } + } + + /* No other frame found that uses minibuffer_child_frame as + minibuffer frame. If FORCE is Qnoelisp or there are + other visible frames left, delete minibuffer_child_frame + since it presumably was used by FRAME only. */ + if (EQ (force, Qnoelisp) || other_frames (f1, false, !NILP (force))) + delete_frame (minibuffer_child_frame, Qnoelisp); + } + } return Qnil; } @@ -2501,11 +2591,8 @@ If omitted, FRAME defaults to the currently selected frame. */) { struct frame *f = decode_live_frame (frame); - /* I think this should be done with a hook. */ -#ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (f)) - x_make_frame_visible (f); -#endif + if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook) + FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, true); make_frame_visible_1 (f->root_window); @@ -2557,11 +2644,8 @@ displayed in the terminal. */) /* Don't allow minibuf_window to remain on an invisible frame. */ check_minibuf_window (frame, EQ (minibuf_window, selected_window)); - /* I think this should be done with a hook. */ -#ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (f)) - x_make_frame_invisible (f); -#endif + if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook) + FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, false); /* Make menu bar update for the Buffers and Frames menus. */ windows_or_buffers_changed = 16; @@ -2605,13 +2689,8 @@ for how to proceed. */) /* Don't allow minibuf_window to remain on an iconified frame. */ check_minibuf_window (frame, EQ (minibuf_window, selected_window)); - /* I think this should be done with a hook. */ - if (FRAME_WINDOW_P (f)) - { -#ifdef HAVE_WINDOW_SYSTEM - x_iconify_frame (f); -#endif - } + if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->iconify_frame_hook) + FRAME_TERMINAL (f)->iconify_frame_hook (f); return Qnil; } @@ -2673,7 +2752,7 @@ doesn't support multiple overlapping frames, this function selects FRAME. */) Fmake_frame_visible (frame); if (FRAME_TERMINAL (f)->frame_raise_lower_hook) - (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1); + (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, true); return Qnil; } @@ -2689,7 +2768,7 @@ doesn't support multiple overlapping frames, this function does nothing. */) struct frame *f = decode_live_frame (frame); if (FRAME_TERMINAL (f)->frame_raise_lower_hook) - (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0); + (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, false); return Qnil; } @@ -2758,7 +2837,9 @@ If there is no window system support, this function does nothing. */) (Lisp_Object frame, Lisp_Object noactivate) { #ifdef HAVE_WINDOW_SYSTEM - x_focus_frame (decode_window_system_frame (frame), !NILP (noactivate)); + struct frame *f = decode_window_system_frame (frame); + if (f && FRAME_TERMINAL (f)->focus_frame_hook) + FRAME_TERMINAL (f)->focus_frame_hook (f, !NILP (noactivate)); #endif return Qnil; } @@ -2829,7 +2910,7 @@ frame_name_fnn_p (char *str, ptrdiff_t len) } /* Set the name of the terminal frame. Also used by MSDOS frames. - Modeled after x_set_name which is used for WINDOW frames. */ + Modeled after *_set_name which is used for WINDOW frames. */ static void set_term_frame_name (struct frame *f, Lisp_Object name) @@ -2961,6 +3042,13 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) fset_buried_buffer_list (f, Fnreverse (list)); return; } + else if ((EQ (prop, Qscroll_bar_width) || EQ (prop, Qscroll_bar_height)) + && !NILP (val) && !RANGED_FIXNUMP (1, val, INT_MAX)) + { + Lisp_Object old_val = Fcdr (Fassq (prop, f->param_alist)); + + val = old_val; + } /* The tty color needed to be set before the frame's parameter alist was updated with the new value. This is not true any more, @@ -3074,7 +3162,7 @@ If FRAME is omitted or nil, return information on the currently selected frame. /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) - x_report_frame_params (f, &alist); + gui_report_frame_params (f, &alist); else #endif { @@ -3180,7 +3268,7 @@ list, but are otherwise ignored. */) /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) - x_set_frame_parameters (f, alist); + gui_set_frame_parameters (f, alist); else #endif #ifdef MSDOS @@ -3190,7 +3278,7 @@ list, but are otherwise ignored. */) #endif { - EMACS_INT length = XFIXNAT (Flength (alist)); + EMACS_INT length = list_length (alist); ptrdiff_t i; Lisp_Object *parms; Lisp_Object *values; @@ -3513,27 +3601,64 @@ bottom edge of FRAME's display. */) CHECK_TYPE_RANGED_INTEGER (int, x); CHECK_TYPE_RANGED_INTEGER (int, y); - /* I think this should be done with a hook. */ if (FRAME_WINDOW_P (f)) { #ifdef HAVE_WINDOW_SYSTEM - x_set_offset (f, XFIXNUM (x), XFIXNUM (y), 1); + if (FRAME_TERMINAL (f)->set_frame_offset_hook) + FRAME_TERMINAL (f)->set_frame_offset_hook (f, + XFIXNUM (x), + XFIXNUM (y), + 1); #endif } return Qt; } + +DEFUN ("frame-window-state-change", Fframe_window_state_change, + Sframe_window_state_change, 0, 1, 0, + doc: /* Return t if FRAME's window state change flag is set, nil otherwise. +FRAME must be a live frame and defaults to the selected one. + +If FRAME's window state change flag is set, the default values of +`window-state-change-functions' and `window-state-change-hook' will be +run during next redisplay, regardless of whether a window state change +actually occurred on FRAME or not. After that, the value of this flag +is reset. */) + (Lisp_Object frame) +{ + return FRAME_WINDOW_STATE_CHANGE (decode_live_frame (frame)) ? Qt : Qnil; +} + +DEFUN ("set-frame-window-state-change", Fset_frame_window_state_change, + Sset_frame_window_state_change, 0, 2, 0, + doc: /* Set FRAME's window state change flag according to ARG. +Set FRAME's window state change flag if ARG is non-nil, reset it +otherwise. + +If FRAME's window state change flag is set, the default values of +`window-state-change-functions' and `window-state-change-hook' will be +run during next redisplay, regardless of whether a window state change +actually occurred on FRAME or not. After that, the value of FRAME's +window state change flag is reset. */) + (Lisp_Object frame, Lisp_Object arg) +{ + struct frame *f = decode_live_frame (frame); + + return (FRAME_WINDOW_STATE_CHANGE (f) = !NILP (arg)) ? Qt : Qnil; +} + /*********************************************************************** Frame Parameters ***********************************************************************/ -/* Connect the frame-parameter names for X frames - to the ways of passing the parameter values to the window system. +/* Connect the frame-parameter names for frames to the ways of passing + the parameter values to the window system. - The name of a parameter, as a Lisp symbol, - has an `x-frame-parameter' property which is an integer in Lisp - that is an index in this table. */ + The name of a parameter, as a Lisp symbol, has a + `frame-parameter-pos' property which is an integer in Lisp that is + an index in this table. */ struct frame_parm_table { const char *name; @@ -3780,12 +3905,12 @@ frame_float (struct frame *f, Lisp_Object val, enum frame_float_type what, /* Change the parameters of frame F as specified by ALIST. If a parameter is not specially recognized, do nothing special; - otherwise call the `x_set_...' function for that parameter. + otherwise call the `gui_set_...' function for that parameter. Except for certain geometry properties, always call store_frame_param to store the new value in the parameter alist. */ void -x_set_frame_parameters (struct frame *f, Lisp_Object alist) +gui_set_frame_parameters (struct frame *f, Lisp_Object alist) { Lisp_Object tail, frame; @@ -3973,7 +4098,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) all. With the old setting it can get a Heisenbug when EmacsFrameResize intermittently provokes a delayed change_frame_size in the middle of adjust_frame_size. */ - /** || (f->can_x_set_window_size && (f->new_height || f->new_width))) **/ + /** || (f->can_set_window_size && (f->new_height || f->new_width))) **/ adjust_frame_size (f, width, height, 1, 0, Qx_set_frame_parameters); if ((!NILP (left) || !NILP (top)) @@ -4039,7 +4164,8 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) f->win_gravity = NorthWestGravity; /* Actually set that position, and convert to absolute. */ - x_set_offset (f, leftpos, toppos, -1); + if (FRAME_TERMINAL (f)->set_frame_offset_hook) + FRAME_TERMINAL (f)->set_frame_offset_hook (f, leftpos, toppos, -1); } if (fullscreen_change) @@ -4051,7 +4177,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) store_frame_param (f, Qfullscreen, fullscreen); if (!EQ (fullscreen, old_value)) - x_set_fullscreen (f, fullscreen, old_value); + gui_set_fullscreen (f, fullscreen, old_value); } @@ -4065,14 +4191,14 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) } -/* Insert a description of internally-recorded parameters of frame X +/* Insert a description of internally-recorded parameters of frame F into the parameter alist *ALISTPTR that is to be given to the user. Only parameters that are specific to the X window system and whose values are not correctly recorded in the frame's param_alist need to be considered here. */ void -x_report_frame_params (struct frame *f, Lisp_Object *alistptr) +gui_report_frame_params (struct frame *f, Lisp_Object *alistptr) { Lisp_Object tem; uprintmax_t w; @@ -4105,27 +4231,23 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) store_in_alist (alistptr, Qright_fringe, make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f))); store_in_alist (alistptr, Qscroll_bar_width, - (! FRAME_HAS_VERTICAL_SCROLL_BARS (f) - ? make_fixnum (0) - : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 + (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) /* nil means "use default width" for non-toolkit scroll bar. ruler-mode.el depends on this. */ : Qnil)); store_in_alist (alistptr, Qscroll_bar_height, - (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) - ? make_fixnum (0) - : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 + (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0 ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) /* nil means "use default height" for non-toolkit scroll bar. */ : Qnil)); - /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on - MS-Windows it returns a value whose type is HANDLE, which is - actually a pointer. Explicit casting avoids compiler + /* FRAME_NATIVE_WINDOW is not guaranteed to return an integer. + E.g., on MS-Windows it returns a value whose type is HANDLE, + which is actually a pointer. Explicit casting avoids compiler warnings. */ - w = (uintptr_t) FRAME_X_WINDOW (f); + w = (uintptr_t) FRAME_NATIVE_WINDOW (f); store_in_alist (alistptr, Qwindow_id, make_formatted_string (buf, "%"pMu, w)); #ifdef HAVE_X_WINDOWS @@ -4144,10 +4266,10 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) store_in_alist (alistptr, Qdisplay, XCAR (FRAME_DISPLAY_INFO (f)->name_list_element)); - if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window) + if (FRAME_OUTPUT_DATA (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window) tem = Qnil; else - tem = make_fixed_natnum ((uintptr_t) FRAME_X_OUTPUT (f)->parent_desc); + tem = make_fixed_natnum ((uintptr_t) FRAME_OUTPUT_DATA (f)->parent_desc); store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil)); store_in_alist (alistptr, Qparent_id, tem); store_in_alist (alistptr, Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)); @@ -4158,7 +4280,7 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) the previous value of that parameter, NEW_VALUE is the new value. */ void -x_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (NILP (new_value)) f->want_fullscreen = FULLSCREEN_NONE; @@ -4180,7 +4302,7 @@ x_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) the previous value of that parameter, NEW_VALUE is the new value. */ void -x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (NILP (new_value)) f->extra_line_spacing = 0; @@ -4206,7 +4328,7 @@ x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu the previous value of that parameter, NEW_VALUE is the new value. */ void -x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { Lisp_Object bgcolor; @@ -4236,7 +4358,7 @@ x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu void -x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { Lisp_Object font_object; int fontset = -1; @@ -4306,8 +4428,8 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) /* SPEC might be nil because ASCII_FONT's name doesn't parse according to stupid XLFD rules, which, for example, disallow font names that include a dash followed by a - number. So in those cases we simply request x_new_font - below to generate a new fontset. */ + number. So in those cases we simply call + set_new_font_hook below to generate a new fontset. */ if (NILP (spec) || ! font_match_p (spec, font_object)) fontset = -1; } @@ -4318,7 +4440,8 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) if (! NILP (Fequal (font_object, oldval))) return; - x_new_font (f, font_object, fontset); + if (FRAME_TERMINAL (f)->set_new_font_hook) + FRAME_TERMINAL (f)->set_new_font_hook (f, font_object, fontset); store_frame_param (f, Qfont, arg); #ifdef HAVE_X_WINDOWS store_frame_param (f, Qfont_parameter, font_param); @@ -4350,7 +4473,7 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) void -x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (! NILP (new_value) && !CONSP (new_value)) @@ -4398,14 +4521,14 @@ x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu Lisp_Object frame; XSETFRAME (frame, f); - x_set_font (f, Fframe_parameter (frame, Qfont), Qnil); + gui_set_font (f, Fframe_parameter (frame, Qfont), Qnil); face_change = true; windows_or_buffers_changed = 18; } } void -x_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { int unit = FRAME_COLUMN_WIDTH (f); int old_width = FRAME_LEFT_FRINGE_WIDTH (f); @@ -4420,7 +4543,7 @@ x_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value f->fringe_cols /* Round up. */ = (new_width + FRAME_RIGHT_FRINGE_WIDTH (f) + unit - 1) / unit; - if (FRAME_X_WINDOW (f) != 0) + if (FRAME_NATIVE_WINDOW (f) != 0) adjust_frame_size (f, -1, -1, 3, 0, Qleft_fringe); SET_FRAME_GARBAGED (f); @@ -4429,7 +4552,7 @@ x_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value void -x_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { int unit = FRAME_COLUMN_WIDTH (f); int old_width = FRAME_RIGHT_FRINGE_WIDTH (f); @@ -4444,7 +4567,7 @@ x_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu f->fringe_cols /* Round up. */ = (new_width + FRAME_LEFT_FRINGE_WIDTH (f) + unit - 1) / unit; - if (FRAME_X_WINDOW (f) != 0) + if (FRAME_NATIVE_WINDOW (f) != 0) adjust_frame_size (f, -1, -1, 3, 0, Qright_fringe); SET_FRAME_GARBAGED (f); @@ -4453,21 +4576,21 @@ x_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu void -x_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { CHECK_TYPE_RANGED_INTEGER (int, arg); if (XFIXNUM (arg) == f->border_width) return; - if (FRAME_X_WINDOW (f) != 0) + if (FRAME_NATIVE_WINDOW (f) != 0) error ("Cannot change the border width of a frame"); f->border_width = XFIXNUM (arg); } void -x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int old = FRAME_RIGHT_DIVIDER_WIDTH (f); CHECK_TYPE_RANGED_INTEGER (int, arg); @@ -4482,7 +4605,7 @@ x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) } void -x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int old = FRAME_BOTTOM_DIVIDER_WIDTH (f); CHECK_TYPE_RANGED_INTEGER (int, arg); @@ -4497,7 +4620,7 @@ x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval } void -x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval) +gui_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval) { Lisp_Object frame; XSETFRAME (frame, f); @@ -4511,25 +4634,25 @@ x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval) } void -x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { f->auto_raise = !NILP (arg); } void -x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { f->auto_lower = !NILP (arg); } void -x_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { f->no_split = !NILP (arg); } void -x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)) || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) @@ -4549,11 +4672,11 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval ? vertical_scroll_bar_right : vertical_scroll_bar_none); - /* We set this parameter before creating the X window for the - frame, so we can get the geometry right from the start. + /* We set this parameter before creating the native window for + the frame, so we can get the geometry right from the start. However, if the window hasn't been created yet, we shouldn't - call x_set_window_size. */ - if (FRAME_X_WINDOW (f)) + call set_window_size_hook. */ + if (FRAME_NATIVE_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qvertical_scroll_bars); SET_FRAME_GARBAGED (f); @@ -4561,7 +4684,7 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval } void -x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { #if USE_HORIZONTAL_SCROLL_BARS if ((NILP (arg) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)) @@ -4569,11 +4692,11 @@ x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldv { f->horizontal_scroll_bars = NILP (arg) ? false : true; - /* We set this parameter before creating the X window for the - frame, so we can get the geometry right from the start. + /* We set this parameter before creating the native window for + the frame, so we can get the geometry right from the start. However, if the window hasn't been created yet, we shouldn't - call x_set_window_size. */ - if (FRAME_X_WINDOW (f)) + call set_window_size_hook. */ + if (FRAME_NATIVE_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qhorizontal_scroll_bars); SET_FRAME_GARBAGED (f); @@ -4582,25 +4705,26 @@ x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldv } void -x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int unit = FRAME_COLUMN_WIDTH (f); - if (NILP (arg)) + if (RANGED_FIXNUMP (1, arg, INT_MAX) + && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) { - x_set_scroll_bar_default_width (f); - - if (FRAME_X_WINDOW (f)) + FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg); + FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit; + if (FRAME_NATIVE_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); SET_FRAME_GARBAGED (f); } - else if (RANGED_FIXNUMP (1, arg, INT_MAX) - && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) + else { - FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg); - FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit; - if (FRAME_X_WINDOW (f)) + if (FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook) + FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f); + + if (FRAME_NATIVE_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); SET_FRAME_GARBAGED (f); @@ -4611,26 +4735,27 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) } void -x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { #if USE_HORIZONTAL_SCROLL_BARS int unit = FRAME_LINE_HEIGHT (f); - if (NILP (arg)) + if (RANGED_FIXNUMP (1, arg, INT_MAX) + && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) { - x_set_scroll_bar_default_height (f); - - if (FRAME_X_WINDOW (f)) + FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg); + FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit; + if (FRAME_NATIVE_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); SET_FRAME_GARBAGED (f); } - else if (RANGED_FIXNUMP (1, arg, INT_MAX) - && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) + else { - FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg); - FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit; - if (FRAME_X_WINDOW (f)) + if (FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook) + FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f); + + if (FRAME_NATIVE_WINDOW (f)) adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); SET_FRAME_GARBAGED (f); @@ -4642,7 +4767,7 @@ x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval) } void -x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +gui_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { double alpha = 1.0; double newval[2]; @@ -4683,25 +4808,24 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) for (i = 0; i < 2; i++) f->alpha[i] = newval[i]; -#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) - block_input (); - x_set_frame_alpha (f); - unblock_input (); -#endif - - return; + if (FRAME_TERMINAL (f)->set_frame_alpha_hook) + { + block_input (); + FRAME_TERMINAL (f)->set_frame_alpha_hook (f); + unblock_input (); + } } /** - * x_set_no_special_glyphs: + * gui_set_no_special_glyphs: * * Set frame F's `no-special-glyphs' parameter which, if non-nil, * suppresses the display of truncation and continuation glyphs * outside fringes. */ void -x_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +gui_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (!EQ (new_value, old_value)) FRAME_NO_SPECIAL_GLYPHS (f) = !NILP (new_value); @@ -4713,7 +4837,8 @@ x_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object old /* Non-zero if mouse is grabbed on DPYINFO and we know the frame where it is. */ -bool x_mouse_grabbed (Display_Info *dpyinfo) +bool +gui_mouse_grabbed (Display_Info *dpyinfo) { return (dpyinfo->grabbed && dpyinfo->last_mouse_frame @@ -4724,7 +4849,7 @@ bool x_mouse_grabbed (Display_Info *dpyinfo) on DPYINFO using saved frame and mouse position. */ void -x_redo_mouse_highlight (Display_Info *dpyinfo) +gui_redo_mouse_highlight (Display_Info *dpyinfo) { if (dpyinfo->last_mouse_motion_frame && FRAME_LIVE_P (dpyinfo->last_mouse_motion_frame)) @@ -4806,11 +4931,13 @@ validate_x_resource_name (void) } } -/* Get specified attribute from resource database RDB. +/* Get a GUI resource, like Fx_get_resource, but for display DPYINFO. See Fx_get_resource below for other parameters. */ -static Lisp_Object -xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) +Lisp_Object +gui_display_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, + Lisp_Object class, Lisp_Object component, + Lisp_Object subclass) { CHECK_STRING (attribute); CHECK_STRING (class); @@ -4863,7 +4990,10 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li *nz++ = '.'; lispstpcpy (nz, attribute); - char *value = x_get_string_resource (rdb, name_key, class_key); + const char *value = + dpyinfo->terminal->get_string_resource_hook (&dpyinfo->rdb, + name_key, + class_key); SAFE_FREE(); if (value && *value) @@ -4888,28 +5018,17 @@ and the class is `Emacs.CLASS.SUBCLASS'. */) { check_window_system (NULL); - return xrdb_get_resource (check_x_display_info (Qnil)->xrdb, - attribute, class, component, subclass); -} - -/* Get an X resource, like Fx_get_resource, but for display DPYINFO. */ - -Lisp_Object -display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, - Lisp_Object class, Lisp_Object component, - Lisp_Object subclass) -{ - return xrdb_get_resource (dpyinfo->xrdb, - attribute, class, component, subclass); + return gui_display_get_resource (check_x_display_info (Qnil), + attribute, class, component, subclass); } #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK /* Used when C code wants a resource value. */ /* Called from oldXMenu/Create.c. */ -char * +const char * x_get_resource_string (const char *attribute, const char *class) { - char *result; + const char *result; struct frame *sf = SELECTED_FRAME (); ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name); USE_SAFE_ALLOCA; @@ -4926,7 +5045,7 @@ x_get_resource_string (const char *attribute, const char *class) esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); sprintf (class_key, "%s.%s", EMACS_CLASS, class); - result = x_get_string_resource (FRAME_DISPLAY_INFO (sf)->xrdb, + result = x_get_string_resource (&FRAME_DISPLAY_INFO (sf)->rdb, name_key, class_key); SAFE_FREE (); return result; @@ -4935,18 +5054,21 @@ x_get_resource_string (const char *attribute, const char *class) /* Return the value of parameter PARAM. - First search ALIST, then Vdefault_frame_alist, then the X defaults - database, using ATTRIBUTE as the attribute name and CLASS as its class. + First search ALIST, then Vdefault_frame_alist, then the GUI + resource database, using ATTRIBUTE as the attribute name and CLASS + as its class. Convert the resource to the type specified by desired_type. If no default is specified, return Qunbound. If you call - x_get_arg, make sure you deal with Qunbound in a reasonable way, - and don't let it get stored in any Lisp-visible variables! */ + gui_display_get_arg, make sure you deal with Qunbound in a + reasonable way, and don't let it get stored in any Lisp-visible + variables! */ Lisp_Object -x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, - const char *attribute, const char *class, enum resource_types type) +gui_display_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, + const char *attribute, const char *class, + enum resource_types type) { Lisp_Object tem; @@ -4976,7 +5098,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, { AUTO_STRING (at, attribute); AUTO_STRING (cl, class); - tem = display_x_get_resource (dpyinfo, at, cl, Qnil, Qnil); + tem = gui_display_get_resource (dpyinfo, at, cl, Qnil, Qnil); if (NILP (tem)) return Qunbound; @@ -5043,26 +5165,26 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, } static Lisp_Object -x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, - const char *attribute, const char *class, - enum resource_types type) +gui_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, + const char *attribute, const char *class, + enum resource_types type) { - return x_get_arg (FRAME_DISPLAY_INFO (f), - alist, param, attribute, class, type); + return gui_display_get_arg (FRAME_DISPLAY_INFO (f), + alist, param, attribute, class, type); } -/* Like x_frame_get_arg, but also record the value in f->param_alist. */ +/* Like gui_frame_get_arg, but also record the value in f->param_alist. */ Lisp_Object -x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, - Lisp_Object param, - const char *attribute, const char *class, - enum resource_types type) +gui_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, + Lisp_Object param, + const char *attribute, const char *class, + enum resource_types type) { Lisp_Object value; - value = x_get_arg (FRAME_DISPLAY_INFO (f), alist, param, - attribute, class, type); + value = gui_display_get_arg (FRAME_DISPLAY_INFO (f), alist, param, + attribute, class, type); if (! NILP (value) && ! EQ (value, Qunbound)) store_frame_param (f, param, value); @@ -5077,17 +5199,17 @@ x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, If that is not found either, use the value DEFLT. */ Lisp_Object -x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, - Lisp_Object deflt, const char *xprop, const char *xclass, - enum resource_types type) +gui_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, + Lisp_Object deflt, const char *xprop, const char *xclass, + enum resource_types type) { Lisp_Object tem; - tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type); + tem = gui_frame_get_arg (f, alist, prop, xprop, xclass, type); if (EQ (tem, Qunbound)) tem = deflt; AUTO_FRAME_ARG (arg, prop, tem); - x_set_frame_parameters (f, arg); + gui_set_frame_parameters (f, arg); return tem; } @@ -5262,7 +5384,8 @@ On Nextstep, this just calls `ns-parse-geometry'. */) #define DEFAULT_COLS 80 long -x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, int *x_width, int *x_height) +gui_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, + int *x_width, int *x_height) { Lisp_Object height, width, user_size, top, left, user_position; long window_prompting = 0; @@ -5295,9 +5418,9 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, int *x { int margin, relief; - relief = (tool_bar_button_relief >= 0 - ? tool_bar_button_relief - : DEFAULT_TOOL_BAR_BUTTON_RELIEF); + relief = (tool_bar_button_relief < 0 + ? DEFAULT_TOOL_BAR_BUTTON_RELIEF + : min (tool_bar_button_relief, 1000000)); if (RANGED_FIXNUMP (1, Vtool_bar_button_margin, INT_MAX)) margin = XFIXNAT (Vtool_bar_button_margin); @@ -5316,8 +5439,8 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, int *x override what we specify below. */ f->new_width = f->new_height = 0; - height = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); - width = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); + height = gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); + width = gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); if (!EQ (width, Qunbound) || !EQ (height, Qunbound)) { if (!EQ (width, Qunbound)) @@ -5394,16 +5517,18 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, int *x } } - user_size = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER); + user_size = gui_display_get_arg (dpyinfo, parms, Quser_size, 0, 0, + RES_TYPE_NUMBER); if (!NILP (user_size) && !EQ (user_size, Qunbound)) window_prompting |= USSize; else window_prompting |= PSize; } - top = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER); - left = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER); - user_position = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER); + top = gui_display_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER); + left = gui_display_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER); + user_position = gui_display_get_arg (dpyinfo, parms, Quser_position, 0, 0, + RES_TYPE_NUMBER); if (! EQ (top, Qunbound) || ! EQ (left, Qunbound)) { if (EQ (top, Qminus)) @@ -5544,8 +5669,8 @@ selected frame. This is useful when `make-pointer-invisible' is set. */) #ifdef HAVE_WINDOW_SYSTEM -# if (defined HAVE_NS \ - || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR))) +# if (defined USE_GTK || defined HAVE_NS || defined HAVE_XINERAMA \ + || defined HAVE_XRANDR) void free_monitors (struct MonitorInfo *monitors, int n_monitors) { @@ -5610,6 +5735,26 @@ make_monitor_attribute_list (struct MonitorInfo *monitors, Initialization ***********************************************************************/ +static void init_frame_once_for_pdumper (void); + +void +init_frame_once (void) +{ + staticpro (&Vframe_list); + staticpro (&selected_frame); + PDUMPER_IGNORE (last_nonminibuf_frame); + Vframe_list = Qnil; + selected_frame = Qnil; + pdumper_do_now_and_after_load (init_frame_once_for_pdumper); +} + +static void +init_frame_once_for_pdumper (void) +{ + PDUMPER_RESET_LV (Vframe_list, Qnil); + PDUMPER_RESET_LV (selected_frame, Qnil); +} + void syms_of_frame (void) { @@ -5941,6 +6086,19 @@ setting this variable does not change that frame's previous association. This variable is local to the current terminal and cannot be buffer-local. */); + DEFVAR_LISP ("resize-mini-frames", resize_mini_frames, + doc: /* Non-nil means resize minibuffer-only frames automatically. +If this is nil, do not resize minibuffer-only frames automatically. + +If this is a function, call that function with the minibuffer-only +frame that shall be resized as sole argument. The buffer of the root +window of that frame is the buffer whose text will be eventually shown +in the minibuffer window. + +Any other non-nil value means to resize minibuffer-only frames by +calling `fit-frame-to-buffer'. */); + resize_mini_frames = Qnil; + DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse, doc: /* Non-nil if window system changes focus when you move the mouse. You should set this variable to tell Emacs how your window manager @@ -6091,16 +6249,15 @@ making the child frame unresponsive to user actions, the default is to iconify the top level frame instead. */); iconify_child_frame = Qiconify_top_level; - staticpro (&Vframe_list); - defsubr (&Sframep); defsubr (&Sframe_live_p); defsubr (&Swindow_system); defsubr (&Sframe_windows_min_size); defsubr (&Smake_terminal_frame); - defsubr (&Shandle_switch_frame); defsubr (&Sselect_frame); + defsubr (&Shandle_switch_frame); defsubr (&Sselected_frame); + defsubr (&Sold_selected_frame); defsubr (&Sframe_list); defsubr (&Sframe_parent); defsubr (&Sframe_ancestor_p); @@ -6153,6 +6310,8 @@ iconify the top level frame instead. */); defsubr (&Sframe_position); defsubr (&Sset_frame_position); defsubr (&Sframe_pointer_visible_p); + defsubr (&Sframe_window_state_change); + defsubr (&Sset_frame_window_state_change); #ifdef HAVE_WINDOW_SYSTEM defsubr (&Sx_get_resource); |