Mercurial > hg > xemacs-beta
annotate src/frame.c @ 5127:a9c41067dd88 ben-lisp-object
more cleanups, terminology clarification, lots of doc work
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Introduction to Allocation):
* internals/internals.texi (Integers and Characters):
* internals/internals.texi (Allocation from Frob Blocks):
* internals/internals.texi (lrecords):
* internals/internals.texi (Low-level allocation):
Rewrite section on allocation of Lisp objects to reflect the new
reality. Remove references to nonexistent XSETINT and XSETCHAR.
modules/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c (allocate_pgconn):
* postgresql/postgresql.c (allocate_pgresult):
* postgresql/postgresql.h (struct Lisp_PGconn):
* postgresql/postgresql.h (struct Lisp_PGresult):
* ldap/eldap.c (allocate_ldap):
* ldap/eldap.h (struct Lisp_LDAP):
Same changes as in src/ dir. See large log there in ChangeLog,
but basically:
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
../hlo/src/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (old_alloc_sized_lcrecord):
* alloc.c (very_old_free_lcrecord):
* alloc.c (copy_lisp_object):
* alloc.c (zero_sized_lisp_object):
* alloc.c (zero_nonsized_lisp_object):
* alloc.c (lisp_object_storage_size):
* alloc.c (free_normal_lisp_object):
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC):
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT):
* alloc.c (Fcons):
* alloc.c (noseeum_cons):
* alloc.c (make_float):
* alloc.c (make_bignum):
* alloc.c (make_bignum_bg):
* alloc.c (make_ratio):
* alloc.c (make_ratio_bg):
* alloc.c (make_ratio_rt):
* alloc.c (make_bigfloat):
* alloc.c (make_bigfloat_bf):
* alloc.c (size_vector):
* alloc.c (make_compiled_function):
* alloc.c (Fmake_symbol):
* alloc.c (allocate_extent):
* alloc.c (allocate_event):
* alloc.c (make_key_data):
* alloc.c (make_button_data):
* alloc.c (make_motion_data):
* alloc.c (make_process_data):
* alloc.c (make_timeout_data):
* alloc.c (make_magic_data):
* alloc.c (make_magic_eval_data):
* alloc.c (make_eval_data):
* alloc.c (make_misc_user_data):
* alloc.c (Fmake_marker):
* alloc.c (noseeum_make_marker):
* alloc.c (size_string_direct_data):
* alloc.c (make_uninit_string):
* alloc.c (make_string_nocopy):
* alloc.c (mark_lcrecord_list):
* alloc.c (alloc_managed_lcrecord):
* alloc.c (free_managed_lcrecord):
* alloc.c (sweep_lcrecords_1):
* alloc.c (malloced_storage_size):
* buffer.c (allocate_buffer):
* buffer.c (compute_buffer_usage):
* buffer.c (DEFVAR_BUFFER_LOCAL_1):
* buffer.c (nuke_all_buffer_slots):
* buffer.c (common_init_complex_vars_of_buffer):
* buffer.h (struct buffer_text):
* buffer.h (struct buffer):
* bytecode.c:
* bytecode.c (make_compiled_function_args):
* bytecode.c (size_compiled_function_args):
* bytecode.h (struct compiled_function_args):
* casetab.c (allocate_case_table):
* casetab.h (struct Lisp_Case_Table):
* charset.h (struct Lisp_Charset):
* chartab.c (fill_char_table):
* chartab.c (Fmake_char_table):
* chartab.c (make_char_table_entry):
* chartab.c (copy_char_table_entry):
* chartab.c (Fcopy_char_table):
* chartab.c (put_char_table):
* chartab.h (struct Lisp_Char_Table_Entry):
* chartab.h (struct Lisp_Char_Table):
* console-gtk-impl.h (struct gtk_device):
* console-gtk-impl.h (struct gtk_frame):
* console-impl.h (struct console):
* console-msw-impl.h (struct Lisp_Devmode):
* console-msw-impl.h (struct mswindows_device):
* console-msw-impl.h (struct msprinter_device):
* console-msw-impl.h (struct mswindows_frame):
* console-msw-impl.h (struct mswindows_dialog_id):
* console-stream-impl.h (struct stream_console):
* console-stream.c (stream_init_console):
* console-tty-impl.h (struct tty_console):
* console-tty-impl.h (struct tty_device):
* console-tty.c (allocate_tty_console_struct):
* console-x-impl.h (struct x_device):
* console-x-impl.h (struct x_frame):
* console.c (allocate_console):
* console.c (nuke_all_console_slots):
* console.c (DEFVAR_CONSOLE_LOCAL_1):
* console.c (common_init_complex_vars_of_console):
* data.c (make_weak_list):
* data.c (make_weak_box):
* data.c (make_ephemeron):
* database.c:
* database.c (struct Lisp_Database):
* database.c (allocate_database):
* database.c (finalize_database):
* device-gtk.c (allocate_gtk_device_struct):
* device-impl.h (struct device):
* device-msw.c:
* device-msw.c (mswindows_init_device):
* device-msw.c (msprinter_init_device):
* device-msw.c (finalize_devmode):
* device-msw.c (allocate_devmode):
* device-tty.c (allocate_tty_device_struct):
* device-x.c (allocate_x_device_struct):
* device.c:
* device.c (nuke_all_device_slots):
* device.c (allocate_device):
* dialog-msw.c (handle_question_dialog_box):
* elhash.c:
* elhash.c (struct Lisp_Hash_Table):
* elhash.c (finalize_hash_table):
* elhash.c (make_general_lisp_hash_table):
* elhash.c (Fcopy_hash_table):
* elhash.h (htentry):
* emacs.c (main_1):
* eval.c:
* eval.c (size_multiple_value):
* event-stream.c (finalize_command_builder):
* event-stream.c (allocate_command_builder):
* event-stream.c (free_command_builder):
* event-stream.c (event_stream_generate_wakeup):
* event-stream.c (event_stream_resignal_wakeup):
* event-stream.c (event_stream_disable_wakeup):
* event-stream.c (event_stream_wakeup_pending_p):
* events.h (struct Lisp_Timeout):
* events.h (struct command_builder):
* extents-impl.h:
* extents-impl.h (struct extent_auxiliary):
* extents-impl.h (struct extent_info):
* extents-impl.h (set_extent_no_chase_aux_field):
* extents-impl.h (set_extent_no_chase_normal_field):
* extents.c:
* extents.c (gap_array_marker):
* extents.c (gap_array):
* extents.c (extent_list_marker):
* extents.c (extent_list):
* extents.c (stack_of_extents):
* extents.c (gap_array_make_marker):
* extents.c (extent_list_make_marker):
* extents.c (allocate_extent_list):
* extents.c (SLOT):
* extents.c (mark_extent_auxiliary):
* extents.c (allocate_extent_auxiliary):
* extents.c (attach_extent_auxiliary):
* extents.c (size_gap_array):
* extents.c (finalize_extent_info):
* extents.c (allocate_extent_info):
* extents.c (uninit_buffer_extents):
* extents.c (allocate_soe):
* extents.c (copy_extent):
* extents.c (vars_of_extents):
* extents.h:
* faces.c (allocate_face):
* faces.h (struct Lisp_Face):
* faces.h (struct face_cachel):
* file-coding.c:
* file-coding.c (finalize_coding_system):
* file-coding.c (sizeof_coding_system):
* file-coding.c (Fcopy_coding_system):
* file-coding.h (struct Lisp_Coding_System):
* file-coding.h (MARKED_SLOT):
* fns.c (size_bit_vector):
* font-mgr.c:
* font-mgr.c (finalize_fc_pattern):
* font-mgr.c (print_fc_pattern):
* font-mgr.c (Ffc_pattern_p):
* font-mgr.c (Ffc_pattern_create):
* font-mgr.c (Ffc_name_parse):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* font-mgr.c (Ffc_pattern_add):
* font-mgr.c (Ffc_pattern_del):
* font-mgr.c (Ffc_pattern_get):
* font-mgr.c (fc_config_create_using):
* font-mgr.c (fc_strlist_to_lisp_using):
* font-mgr.c (fontset_to_list):
* font-mgr.c (Ffc_config_p):
* font-mgr.c (Ffc_config_up_to_date):
* font-mgr.c (Ffc_config_build_fonts):
* font-mgr.c (Ffc_config_get_cache):
* font-mgr.c (Ffc_config_get_fonts):
* font-mgr.c (Ffc_config_set_current):
* font-mgr.c (Ffc_config_get_blanks):
* font-mgr.c (Ffc_config_get_rescan_interval):
* font-mgr.c (Ffc_config_set_rescan_interval):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_app_font_clear):
* font-mgr.c (size):
* font-mgr.c (Ffc_config_substitute):
* font-mgr.c (Ffc_font_render_prepare):
* font-mgr.c (Ffc_font_match):
* font-mgr.c (Ffc_font_sort):
* font-mgr.c (finalize_fc_config):
* font-mgr.c (print_fc_config):
* font-mgr.h:
* font-mgr.h (struct fc_pattern):
* font-mgr.h (XFC_PATTERN):
* font-mgr.h (struct fc_config):
* font-mgr.h (XFC_CONFIG):
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-impl.h (struct frame):
* frame-msw.c (mswindows_init_frame_1):
* frame-x.c (allocate_x_frame_struct):
* frame.c (nuke_all_frame_slots):
* frame.c (allocate_frame_core):
* gc.c:
* gc.c (GC_CHECK_NOT_FREE):
* glyphs.c (finalize_image_instance):
* glyphs.c (allocate_image_instance):
* glyphs.c (Fcolorize_image_instance):
* glyphs.c (allocate_glyph):
* glyphs.c (unmap_subwindow_instance_cache_mapper):
* glyphs.c (register_ignored_expose):
* glyphs.h (struct Lisp_Image_Instance):
* glyphs.h (struct Lisp_Glyph):
* glyphs.h (struct glyph_cachel):
* glyphs.h (struct expose_ignore):
* gui.c (allocate_gui_item):
* gui.h (struct Lisp_Gui_Item):
* keymap.c (struct Lisp_Keymap):
* keymap.c (make_keymap):
* lisp.h:
* lisp.h (struct Lisp_String_Direct_Data):
* lisp.h (struct Lisp_String_Indirect_Data):
* lisp.h (struct Lisp_Vector):
* lisp.h (struct Lisp_Bit_Vector):
* lisp.h (DECLARE_INLINE_LISP_BIT_VECTOR):
* lisp.h (struct weak_box):
* lisp.h (struct ephemeron):
* lisp.h (struct weak_list):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER):
* lrecord.h (struct lcrecord_list):
* lstream.c (finalize_lstream):
* lstream.c (sizeof_lstream):
* lstream.c (Lstream_new):
* lstream.c (Lstream_delete):
* lstream.h (struct lstream):
* marker.c:
* marker.c (finalize_marker):
* marker.c (compute_buffer_marker_usage):
* mule-charset.c:
* mule-charset.c (make_charset):
* mule-charset.c (compute_charset_usage):
* objects-impl.h (struct Lisp_Color_Instance):
* objects-impl.h (struct Lisp_Font_Instance):
* objects-tty-impl.h (struct tty_color_instance_data):
* objects-tty-impl.h (struct tty_font_instance_data):
* objects-tty.c (tty_initialize_color_instance):
* objects-tty.c (tty_initialize_font_instance):
* objects.c (finalize_color_instance):
* objects.c (Fmake_color_instance):
* objects.c (finalize_font_instance):
* objects.c (Fmake_font_instance):
* objects.c (reinit_vars_of_objects):
* opaque.c:
* opaque.c (sizeof_opaque):
* opaque.c (make_opaque_ptr):
* opaque.c (free_opaque_ptr):
* opaque.h:
* opaque.h (Lisp_Opaque):
* opaque.h (Lisp_Opaque_Ptr):
* print.c (printing_unreadable_lcrecord):
* print.c (external_object_printer):
* print.c (debug_p4):
* process.c (finalize_process):
* process.c (make_process_internal):
* procimpl.h (struct Lisp_Process):
* rangetab.c (Fmake_range_table):
* rangetab.c (Fcopy_range_table):
* rangetab.h (struct Lisp_Range_Table):
* scrollbar.c:
* scrollbar.c (create_scrollbar_instance):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h (struct scrollbar_instance):
* specifier.c (finalize_specifier):
* specifier.c (sizeof_specifier):
* specifier.c (set_specifier_caching):
* specifier.h (struct Lisp_Specifier):
* specifier.h (struct specifier_caching):
* symeval.h:
* symeval.h (SYMBOL_VALUE_MAGIC_P):
* symeval.h (DEFVAR_SYMVAL_FWD):
* symsinit.h:
* syntax.c (init_buffer_syntax_cache):
* syntax.h (struct syntax_cache):
* toolbar.c:
* toolbar.c (allocate_toolbar_button):
* toolbar.c (update_toolbar_button):
* toolbar.h (struct toolbar_button):
* tooltalk.c (struct Lisp_Tooltalk_Message):
* tooltalk.c (make_tooltalk_message):
* tooltalk.c (struct Lisp_Tooltalk_Pattern):
* tooltalk.c (make_tooltalk_pattern):
* ui-gtk.c:
* ui-gtk.c (allocate_ffi_data):
* ui-gtk.c (emacs_gtk_object_finalizer):
* ui-gtk.c (allocate_emacs_gtk_object_data):
* ui-gtk.c (allocate_emacs_gtk_boxed_data):
* ui-gtk.h:
* window-impl.h (struct window):
* window-impl.h (struct window_mirror):
* window.c (finalize_window):
* window.c (allocate_window):
* window.c (new_window_mirror):
* window.c (mark_window_as_deleted):
* window.c (make_dummy_parent):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
Overall point of this change and previous ones in this repository:
(1) Introduce new, clearer terminology: everything other than int
or char is a "record" object, which comes in two types: "normal
objects" and "frob-block objects". Fix up all places that
referred to frob-block objects as "simple", "basic", etc.
(2) Provide an advertised interface for doing operations on Lisp
objects, including creating new types, that is clean and
consistent in its naming, uses the above-referenced terms and
avoids referencing "lrecords", "old lcrecords", etc., which should
hide under the surface.
(3) Make the size_in_bytes and finalizer methods take a
Lisp_Object rather than a void * for consistency with other methods.
(4) Separate finalizer method into finalizer and disksaver, so
that normal finalize methods don't have to worry about disksaving.
Other specifics:
(1) Renaming:
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
implementation->basic_p -> implementation->frob_block_p
ALLOCATE_FIXED_TYPE_AND_SET_IMPL -> ALLOC_FROB_BLOCK_LISP_OBJECT
*FCCONFIG*, wrap_fcconfig -> *FC_CONFIG*, wrap_fc_config
*FCPATTERN*, wrap_fcpattern -> *FC_PATTERN*, wrap_fc_pattern
(the last two changes make the naming of these macros consistent
with the naming of all other macros, since the objects are named
fc-config and fc-pattern with a hyphen)
(2) Lots of documentation fixes in lrecord.h.
(3) Eliminate macros for copying, freeing, zeroing objects, getting
their storage size. Instead, new functions:
zero_sized_lisp_object()
zero_nonsized_lisp_object()
lisp_object_storage_size()
free_normal_lisp_object()
(copy_lisp_object() already exists)
LISP_OBJECT_FROB_BLOCK_P() (actually a macro)
Eliminated:
free_lrecord()
zero_lrecord()
copy_lrecord()
copy_sized_lrecord()
old_copy_lcrecord()
old_copy_sized_lcrecord()
old_zero_lcrecord()
old_zero_sized_lcrecord()
LISP_OBJECT_STORAGE_SIZE()
COPY_SIZED_LISP_OBJECT()
COPY_SIZED_LCRECORD()
COPY_LISP_OBJECT()
ZERO_LISP_OBJECT()
FREE_LISP_OBJECT()
(4) Catch the remaining places where lrecord stuff was used directly
and use the advertised interface, e.g. alloc_sized_lrecord() ->
ALLOC_SIZED_LISP_OBJECT().
(5) Make certain statically-declared pseudo-objects
(buffer_local_flags, console_local_flags) have their lheader
initialized correctly, so things like copy_lisp_object() can work
on them. Make extent_auxiliary_defaults a proper heap object
Vextent_auxiliary_defaults, and make extent auxiliaries dumpable
so that this object can be dumped. allocate_extent_auxiliary()
now just creates the object, and attach_extent_auxiliary()
creates an extent auxiliary and attaches to an extent, like the
old allocate_extent_auxiliary().
(6) Create EXTENT_AUXILIARY_SLOTS macro, similar to the foo-slots.h
files but in a macro instead of a file. The purpose is to avoid
duplication when iterating over all the slots in an extent auxiliary.
Use it.
(7) In lstream.c, don't zero out object after allocation because
allocation routines take care of this.
(8) In marker.c, fix a mistake in computing marker overhead.
(9) In print.c, clean up printing_unreadable_lcrecord(),
external_object_printer() to avoid lots of ifdef NEW_GC's.
(10) Separate toolbar-button allocation into a separate
allocate_toolbar_button() function for use in the example code
in lrecord.h.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Mar 2010 04:08:17 -0600 |
parents | 2a462149bd6a |
children | 7be849cb8828 |
rev | line source |
---|---|
428 | 1 /* Generic frame functions. |
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | |
5043 | 3 Copyright (C) 1995, 1996, 2002, 2003, 2005, 2010 Ben Wing. |
428 | 4 Copyright (C) 1995 Sun Microsystems, Inc. |
5 | |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: FSF 19.30. */ | |
24 | |
25 /* This file has been Mule-ized. */ | |
26 | |
5043 | 27 /* About window and frame geometry [ben]: |
28 | |
29 Here is an ASCII diagram: | |
30 | |
5046 | 31 +------------------------------------------------------------------------| |
32 | window-manager decoration | | |
33 | +--------------------------------------------------------------------+ | | |
34 | | menubar | | | |
35 | ###################################################################### | | |
36 | # toolbar # | | |
37 | #--------------------------------------------------------------------# | | |
38 | # | gutter | # | | |
39 | # |--------------------------------------------------------------| # | | |
40 | # | | internal border width | | # | | |
41 | # | | ******************************************************** | | # | | |
42 |w# | | * |s|v* |s* | | #w| | |
43 |i# | | * |c|e* |c* | | #i| | |
44 |n# | | * |r|r* |r* | | #n| | |
45 |d# | | * |o|t* |o* | | #d| | |
46 |o# | | * text area |l|.* text area |l* | | #o| | |
47 |w# | |i* |l| * |l*i| | #w| | |
48 |-# | |n* |b|d* |b*n| | #-| | |
49 |m# | |t* |a|i* |a*t| | #m| | |
50 |a# | |.* |r|v* |r*.| | #a| | |
51 |n# t| | *-------------------------+-|i*----------------------+-* | |t #n| | |
52 |a# o|g|b* scrollbar | |d* scrollbar | *b|g|o #a| | |
53 |g# o|u|o*-------------------------+-|e*----------------------+-*o|u|o #g| | |
54 |e# l|t|r* modeline |r* modeline *r|t|l #e| | |
55 |r# b|t|d********************************************************d|t|b #r| | |
56 | # a|e|e* =..texttexttex....= |s|v* |s*e|e|a # | | |
57 |d# r|r|r*o m=..texttexttextt..=o m|c|e* |c*r|r|r #d| | |
58 |e# | | *u a=.exttexttextte...=u a|r|r* |r* | | #e| | |
59 |c# | |w*t r=....texttexttex..=t r|o|t* |o*w| | #c| | |
60 |o# | |i*s g= etc. =s g|l|.* text area |l*i| | #o| | |
61 |r# | |d*i i= =i i|l| * |l*d| | #r| | |
62 |a# | |t*d n= =d n|b|d* |b*t| | #a| | |
63 |t# | |h*e = inner text area =e |a|i* |a*h| | #t| | |
64 |i# | | * = = |r|v* |r* | | #i| | |
65 |o# | | *---===================---+-|i*----------------------+-* | | #o| | |
66 |n# | | * scrollbar | |d* scrollbar | * | | #n| | |
67 | # | | *-------------------------+-|e*----------------------+-* | | # | | |
68 | # | | * modeline |r* modeline * | | # | | |
69 | # | | ******************************************************** | | # | | |
70 | # | | * minibuffer * | | # | | |
71 | # | | ******************************************************** | | # | | |
72 | # | | internal border width | | # | | |
73 | # |--------------------------------------------------------------| # | | |
74 | # | gutter | # | | |
75 | #--------------------------------------------------------------------# | | |
76 | # toolbar # | | |
77 | ###################################################################### | | |
78 | window manager decoration | | |
79 +------------------------------------------------------------------------+ | |
5043 | 80 |
81 # = boundary of client area; * = window boundaries, boundary of paned area | |
82 = = boundary of inner text area; . = inside margin area | |
83 | |
84 Note in particular what happens at the corners, where a "corner box" | |
85 occurs. Top and bottom toolbars take precedence over left and right | |
86 toolbars, extending out horizontally into the corner boxes. Gutters | |
87 work the same way. The corner box where the scrollbars meet, however, | |
88 is assigned to neither scrollbar, and is known as the "dead box"; it is | |
89 an area that must be cleared specially. | |
90 | |
91 THE FRAME | |
92 --------- | |
93 | |
94 The "top-level window area" is the entire area of a top-level window (or | |
95 "frame"). The "client area" (a term from MS Windows) is the area of a | |
96 top-level window that XEmacs draws into and manages with redisplay. | |
97 This includes the toolbar, scrollbars, gutters, dividers, text area, | |
98 modeline and minibuffer. It does not include the menubar, title or | |
99 outer borders. The "non-client area" is the area of a top-level window | |
100 outside of the client area and includes the menubar, title and outer | |
101 borders. Internally, all frame coordinates are relative to the client | |
102 area. | |
103 | |
104 | |
105 THE NON-CLIENT AREA | |
106 ------------------- | |
107 | |
108 Under X, the non-client area is split into two parts: | |
109 | |
110 (1) The outer layer is the window-manager decorations: The title and | |
111 borders. These are controlled by the window manager, a separate process | |
112 that controls the desktop, the location of icons, etc. When a process | |
113 tries to create a window, the window manager intercepts this action and | |
114 "reparents" the window, placing another window around it which contains | |
115 the window decorations, including the title bar, outer borders used for | |
116 resizing, etc. The window manager also implements any actions involving | |
117 the decorations, such as the ability to resize a window by dragging its | |
118 borders, move a window by dragging its title bar, etc. If there is no | |
119 window manager or you kill it, windows will have no decorations (and | |
120 will lose them if they previously had any) and you will not be able to | |
121 move or resize them. | |
122 | |
123 (2) Inside of the window-manager decorations is the "shell", which is | |
124 managed by the toolkit and widget libraries your program is linked with. | |
125 The code in *-x.c uses the Xt toolkit and various possible widget | |
126 libraries built on top of Xt, such as Motif, Athena, the "Lucid" | |
127 widgets, etc. Another possibility is GTK (*-gtk.c), which implements | |
128 both the toolkit and widgets. Under Xt, the "shell" window is an | |
129 EmacsShell widget, containing an EmacsManager widget of the same size, | |
130 which in turn contains a menubar widget and an EmacsFrame widget, inside | |
131 of which is the client area. (The division into EmacsShell and | |
132 EmacsManager is due to the complex and screwy geometry-management system | |
133 in Xt [and X more generally]. The EmacsShell handles negotation with | |
134 the window manager; the place of the EmacsManager widget is normally | |
135 assumed by a widget that manages the geometry of its child widgets, but | |
136 the EmacsManager widget just lets the XEmacs redisplay mechanism do the | |
137 positioning.) | |
138 | |
139 Under Windows, the non-client area is managed by the window system. | |
140 There is no division such as under X. Part of the window-system API | |
141 (USER.DLL) of Win32 includes functions to control the menubars, title, | |
142 etc. and implements the move and resize behavior. There *is* an | |
143 equivalent of the window manager, called the "shell", but it manages | |
144 only the desktop, not the windows themselves. The normal shell under | |
145 Windows is EXPLORER.EXE; if you kill this, you will lose the bar | |
146 containing the "Start" menu and tray and such, but the windows | |
147 themselves will not be affected or lose their decorations. | |
148 | |
149 | |
150 THE CLIENT AREA | |
151 --------------- | |
152 | |
153 Inside of the client area is the toolbars, the gutters (where the buffer | |
154 tabs are displayed), the minibuffer, the internal border width, and one | |
155 or more non-overlapping "windows" (this is old Emacs terminology, from | |
156 before the time when frames existed at all; the standard terminology for | |
157 this would be "pane"). Each window can contain a modeline, horizontal | |
158 and/or vertical scrollbars, and (for non-rightmost windows) a vertical | |
159 divider, surrounding a text area. | |
160 | |
161 The dimensions of the toolbars and gutters are determined by the formula | |
162 (THICKNESS + 2 * BORDER-THICKNESS), where "thickness" is a cover term | |
163 for height or width, as appropriate. The height and width come from | |
164 `default-toolbar-height' and `default-toolbar-width' and the specific | |
165 versions of these (`top-toolbar-height', `left-toolbar-width', etc.). | |
166 The border thickness comes from `default-toolbar-border-height' and | |
167 `default-toolbar-border-width', and the specific versions of these. The | |
168 gutter works exactly equivalently. | |
169 | |
170 Note that for any particular toolbar or gutter, it will only be | |
171 displayed if [a] its visibility specifier (`default-toolbar-visible-p' | |
172 etc.) is non-nil; [b] its thickness (`default-toolbar-height' etc.) is | |
173 greater than 0; [c] its contents (`default-toolbar' etc.) are non-nil. | |
174 | |
175 The position-specific toolbars interact with the default specifications | |
176 as follows: If the value for a position-specific specifier is not | |
177 defined in a particular domain (usually a window), and the position of | |
178 that specifier is set as the default position (using | |
179 `default-toolbar-position'), then the value from the corresponding | |
180 default specifier in that domain will be used. The gutters work the | |
181 same. | |
182 | |
183 | |
184 THE PANED AREA | |
185 -------------- | |
186 | |
187 The area occupied by the "windows" is called the paned area. Note that | |
188 this includes the minibuffer, which is just another window but is | |
189 special-cased in XEmacs. Each window can include a horizontal and/or | |
190 vertical scrollbar, a modeline and a vertical divider to its right, as | |
191 well as the text area. Only non-rightmost windows can include a | |
192 vertical divider. (The minibuffer normally does not include either | |
193 modeline or scrollbars.) | |
194 | |
195 Note that, because the toolbars and gutters are controlled by | |
196 specifiers, and specifiers can have window-specific and buffer-specific | |
197 values, the size of the paned area can change depending on which window | |
198 is selected: In other words, if the selected window or buffer changes, | |
199 the entire paned area for the frame may change. | |
200 | |
201 | |
202 TEXT AREAS, FRINGES, MARGINS | |
203 ---------------------------- | |
204 | |
205 The space occupied by a window can be divided into the text area and the | |
206 fringes. The fringes include the modeline, scrollbars and vertical | |
207 divider on the right side (if any); inside of this is the text area, | |
208 where the text actually occurs. Note that a window may or may not | |
209 contain any of the elements that are part of the fringe -- this is | |
210 controlled by specifiers, e.g. `has-modeline-p', | |
211 `horizontal-scrollbar-visible-p', `vertical-scrollbar-visible-p', | |
212 `vertical-divider-always-visible-p', etc. | |
213 | |
214 In addition, it is possible to set margins in the text area using the | |
215 specifiers `left-margin-width' and `right-margin-width'. When this is | |
216 done, only the "inner text area" (the area inside of the margins) will | |
217 be used for normal display of text; the margins will be used for glyphs | |
218 with a layout policy of `outside-margin' (as set on an extent containing | |
219 the glyph by `set-extent-begin-glyph-layout' or | |
220 `set-extent-end-glyph-layout'). However, the calculation of the text | |
221 area size (e.g. in the function `window-text-area-width') includes the | |
222 margins. Which margin is used depends on whether a glyph has been set | |
223 as the begin-glyph or end-glyph of an extent (`set-extent-begin-glyph' | |
224 etc.), using the left and right margins, respectively. | |
225 | |
226 Technically, the margins outside of the inner text area are known as the | |
227 "outside margins". The "inside margins" are in the inner text area and | |
228 constitute the whitespace between the outside margins and the first or | |
229 last non-whitespace character in a line; their width can vary from line | |
230 to line. Glyphs will be placed in the inside margin if their layout | |
231 policy is `inside-margin' or `whitespace', with `whitespace' glyphs on | |
232 the inside and `inside-margin' glyphs on the outside. Inside-margin | |
233 glyphs can spill over into the outside margin if `use-left-overflow' or | |
234 `use-right-overflow', respectively, is non-nil. | |
235 | |
236 See the Lisp Reference manual, under Annotations, for more details. | |
237 | |
238 | |
239 THE DISPLAYABLE AREA | |
240 -------------------- | |
241 | |
242 The "displayable area" is not so much an actual area as a convenient | |
243 fiction. It is the area used to convert between pixel and character | |
244 dimensions for frames. The character dimensions for a frame (e.g. as | |
245 returned by `frame-width' and `frame-height' and set by | |
246 `set-frame-width' and `set-frame-height') are determined from the | |
247 displayable area by dividing by the pixel size of the default font as | |
248 instantiated in the frame. (For proportional fonts, the "average" width | |
249 is used. Under Windows, this is a built-in property of the fonts. | |
250 Under X, this is based on the width of the lowercase 'n', or if this is | |
251 zero then the width of the default character. [We prefer 'n' to the | |
252 specified default character because many X fonts have a default | |
253 character with a zero or otherwise non-representative width.]) | |
254 | |
255 The displayable area is essentially the "theoretical" paned area of the | |
256 frame excluding the rightmost and bottom-most scrollbars. In this | |
257 context, "theoretical" means that all calculations on based on | |
258 frame-level values for toolbar, gutter and scrollbar thicknesses. | |
259 Because these thicknesses are controlled by specifiers, and specifiers | |
260 can have window-specific and buffer-specific values, these calculations | |
261 may or may not reflect the actual size of the paned area or of the | |
262 scrollbars when any particular window is selected. Note also that the | |
263 "displayable area" may not even be contiguous! In particular, if the | |
264 frame-level value of the horizontal scrollbar height is non-zero, then | |
265 the displayable area includes the paned area above and below the bottom | |
266 horizontal scrollbar but not the scrollbar itself. | |
267 | |
268 As a further twist, the character-dimension calculations are adjusted so | |
269 that the truncation and continuation glyphs (see `truncation-glyph' and | |
270 `continuation-glyph') count as a single character even if they are wider | |
271 than the default font width. (Technically, the character width is | |
272 computed from the displayable-area width by subtracting the maximum of | |
273 the truncation-glyph width, continuation-glyph width and default-font | |
274 width before dividing by the default-font width, and then adding 1 to | |
275 the result.) (The ultimate motivation for this kludge as well as the | |
276 subtraction of the scrollbars, but not the minibuffer or bottom-most | |
277 modeline, is to maintain compatibility with TTY's.) | |
278 | |
279 Despite all these concerns and kludges, however, the "displayable area" | |
280 concept works well in practice and mostly ensures that by default the | |
281 frame will actually fit 79 characters + continuation/truncation glyph. | |
282 | |
283 | |
284 WHICH FUNCTIONS USE WHICH? | |
285 -------------------------- | |
286 | |
287 [1] Top-level window area: | |
288 | |
289 set-frame-position | |
290 `left' and `top' frame properties | |
291 | |
292 [2] Client area: | |
293 | |
294 frame-pixel-*, set-frame-pixel-* | |
295 | |
296 [3] Paned area: | |
297 | |
298 window-pixel-edges | |
299 event-x-pixel, event-y-pixel, event-properties, make-event | |
300 | |
301 [4] Displayable area: | |
302 | |
303 frame-width, frame-height and other all functions specifying frame size | |
304 in characters | |
305 frame-displayable-pixel-* | |
306 | |
307 --ben | |
308 | |
309 */ | |
310 | |
428 | 311 #include <config.h> |
312 #include "lisp.h" | |
313 | |
314 #include "buffer.h" /* for Vbuffer_alist */ | |
315 #include "console.h" | |
872 | 316 #include "device-impl.h" |
428 | 317 #include "events.h" |
318 #include "extents.h" | |
319 #include "faces.h" | |
872 | 320 #include "frame-impl.h" |
428 | 321 #include "glyphs.h" |
322 #include "gutter.h" | |
323 #include "menubar.h" | |
2681 | 324 #include "process.h" /* for egetenv */ |
428 | 325 #include "redisplay.h" |
326 #include "scrollbar.h" | |
800 | 327 #include "toolbar.h" |
428 | 328 #include "window.h" |
329 | |
330 Lisp_Object Vselect_frame_hook, Qselect_frame_hook; | |
331 Lisp_Object Vdeselect_frame_hook, Qdeselect_frame_hook; | |
332 Lisp_Object Vcreate_frame_hook, Qcreate_frame_hook; | |
333 Lisp_Object Vdelete_frame_hook, Qdelete_frame_hook; | |
334 Lisp_Object Vmouse_enter_frame_hook, Qmouse_enter_frame_hook; | |
335 Lisp_Object Vmouse_leave_frame_hook, Qmouse_leave_frame_hook; | |
336 Lisp_Object Vmap_frame_hook, Qmap_frame_hook; | |
337 Lisp_Object Vunmap_frame_hook, Qunmap_frame_hook; | |
338 int allow_deletion_of_last_visible_frame; | |
339 Lisp_Object Vadjust_frame_function; | |
340 Lisp_Object Vmouse_motion_handler; | |
341 Lisp_Object Vsynchronize_minibuffers; | |
342 Lisp_Object Qsynchronize_minibuffers; | |
343 Lisp_Object Qbuffer_predicate; | |
344 Lisp_Object Qmake_initial_minibuffer_frame; | |
345 Lisp_Object Qcustom_initialize_frame; | |
346 | |
347 /* We declare all these frame properties here even though many of them | |
348 are currently only used in frame-x.c, because we should generalize | |
349 them. */ | |
350 | |
351 Lisp_Object Qminibuffer; | |
352 Lisp_Object Qunsplittable; | |
353 Lisp_Object Qinternal_border_width; | |
354 Lisp_Object Qtop_toolbar_shadow_color; | |
355 Lisp_Object Qbottom_toolbar_shadow_color; | |
356 Lisp_Object Qbackground_toolbar_color; | |
357 Lisp_Object Qtop_toolbar_shadow_pixmap; | |
358 Lisp_Object Qbottom_toolbar_shadow_pixmap; | |
359 Lisp_Object Qtoolbar_shadow_thickness; | |
360 Lisp_Object Qscrollbar_placement; | |
361 Lisp_Object Qinter_line_space; | |
362 Lisp_Object Qvisual_bell; | |
363 Lisp_Object Qbell_volume; | |
364 Lisp_Object Qpointer_background; | |
365 Lisp_Object Qpointer_color; | |
366 Lisp_Object Qtext_pointer; | |
367 Lisp_Object Qspace_pointer; | |
368 Lisp_Object Qmodeline_pointer; | |
369 Lisp_Object Qgc_pointer; | |
370 Lisp_Object Qinitially_unmapped; | |
371 Lisp_Object Quse_backing_store; | |
372 Lisp_Object Qborder_color; | |
373 Lisp_Object Qborder_width; | |
374 | |
375 Lisp_Object Qframep, Qframe_live_p; | |
376 Lisp_Object Qdelete_frame; | |
377 | |
378 Lisp_Object Qframe_title_format, Vframe_title_format; | |
379 Lisp_Object Qframe_icon_title_format, Vframe_icon_title_format; | |
380 | |
381 Lisp_Object Vdefault_frame_name; | |
382 Lisp_Object Vdefault_frame_plist; | |
383 | |
384 Lisp_Object Vframe_icon_glyph; | |
385 | |
386 Lisp_Object Qhidden; | |
387 | |
388 Lisp_Object Qvisible, Qiconic, Qinvisible, Qvisible_iconic, Qinvisible_iconic; | |
389 Lisp_Object Qnomini, Qvisible_nomini, Qiconic_nomini, Qinvisible_nomini; | |
390 Lisp_Object Qvisible_iconic_nomini, Qinvisible_iconic_nomini; | |
391 | |
442 | 392 Lisp_Object Qset_specifier, Qset_face_property; |
428 | 393 Lisp_Object Qface_property_instance; |
394 | |
395 Lisp_Object Qframe_property_alias; | |
396 | |
397 /* If this is non-nil, it is the frame that make-frame is currently | |
398 creating. We can't set the current frame to this in case the | |
399 debugger goes off because it would try and display to it. However, | |
400 there are some places which need to reference it which have no | |
401 other way of getting it if it isn't the selected frame. */ | |
402 Lisp_Object Vframe_being_created; | |
403 Lisp_Object Qframe_being_created; | |
404 | |
405 static void store_minibuf_frame_prop (struct frame *f, Lisp_Object val); | |
1125 | 406 |
5043 | 407 typedef enum |
408 { | |
1125 | 409 DISPLAYABLE_PIXEL_TO_CHAR, |
5043 | 410 CHAR_TO_DISPLAYABLE_PIXEL, |
1125 | 411 TOTAL_PIXEL_TO_CHAR, |
412 CHAR_TO_TOTAL_PIXEL, | |
5043 | 413 TOTAL_PIXEL_TO_DISPLAYABLE_PIXEL, |
414 DISPLAYABLE_PIXEL_TO_TOTAL_PIXEL, | |
415 } | |
416 pixel_to_char_mode_t; | |
417 | |
418 enum frame_size_type | |
419 { | |
420 SIZE_TOTAL_PIXEL, | |
421 SIZE_DISPLAYABLE_PIXEL, | |
422 SIZE_CHAR_CELL, | |
423 SIZE_FRAME_UNIT, | |
424 }; | |
1125 | 425 |
426 static void frame_conversion_internal (struct frame *f, | |
5043 | 427 enum frame_size_type source, |
428 int source_width, int source_height, | |
429 enum frame_size_type dest, | |
430 int *dest_width, int *dest_height); | |
431 static void get_frame_char_size (struct frame *f, int *out_width, | |
432 int *out_height); | |
433 static void get_frame_displayable_pixel_size (struct frame *f, int *out_width, | |
434 int *out_height); | |
435 | |
438 | 436 static struct display_line title_string_display_line; |
437 /* Used by generate_title_string. Global because they get used so much that | |
438 the dynamic allocation time adds up. */ | |
867 | 439 static Ichar_dynarr *title_string_ichar_dynarr; |
428 | 440 |
441 | |
1204 | 442 |
3092 | 443 #ifndef NEW_GC |
1204 | 444 extern const struct sized_memory_description gtk_frame_data_description; |
445 extern const struct sized_memory_description mswindows_frame_data_description; | |
446 extern const struct sized_memory_description x_frame_data_description; | |
3092 | 447 #endif /* not NEW_GC */ |
1204 | 448 |
449 static const struct memory_description frame_data_description_1 []= { | |
3092 | 450 #ifdef NEW_GC |
451 #ifdef HAVE_GTK | |
452 { XD_LISP_OBJECT, gtk_console }, | |
453 #endif | |
454 #ifdef HAVE_MS_WINDOWS | |
455 { XD_LISP_OBJECT, mswindows_console }, | |
456 #endif | |
457 #ifdef HAVE_X_WINDOWS | |
458 { XD_LISP_OBJECT, x_console }, | |
459 #endif | |
460 #else /* not NEW_GC */ | |
1204 | 461 #ifdef HAVE_GTK |
2551 | 462 { XD_BLOCK_PTR, gtk_console, 1, { >k_frame_data_description} }, |
1204 | 463 #endif |
464 #ifdef HAVE_MS_WINDOWS | |
2551 | 465 { XD_BLOCK_PTR, mswindows_console, 1, { &mswindows_frame_data_description} }, |
1204 | 466 #endif |
467 #ifdef HAVE_X_WINDOWS | |
2551 | 468 { XD_BLOCK_PTR, x_console, 1, { &x_frame_data_description} }, |
1204 | 469 #endif |
3092 | 470 #endif /* not NEW_GC */ |
1204 | 471 { XD_END } |
472 }; | |
473 | |
474 static const struct sized_memory_description frame_data_description = { | |
475 sizeof (void *), frame_data_description_1 | |
476 }; | |
477 | |
3092 | 478 #ifdef NEW_GC |
479 static const struct memory_description expose_ignore_description_1 [] = { | |
480 { XD_LISP_OBJECT, offsetof (struct expose_ignore, next) }, | |
481 { XD_END } | |
482 }; | |
483 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
484 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("expose-ignore", expose_ignore, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
485 0, expose_ignore_description_1, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
486 struct expose_ignore); |
3092 | 487 #else /* not NEW_GC */ |
1204 | 488 extern const struct sized_memory_description expose_ignore_description; |
489 | |
490 static const struct memory_description expose_ignore_description_1 [] = { | |
2367 | 491 { XD_BLOCK_PTR, offsetof (struct expose_ignore, next), |
2551 | 492 1, { &expose_ignore_description } }, |
1204 | 493 { XD_END } |
494 }; | |
495 | |
496 const struct sized_memory_description expose_ignore_description = { | |
497 sizeof (struct expose_ignore), | |
498 expose_ignore_description_1 | |
499 }; | |
3092 | 500 #endif /* not NEW_GC */ |
1204 | 501 |
502 static const struct memory_description display_line_dynarr_pointer_description_1 []= { | |
2551 | 503 { XD_BLOCK_PTR, 0, 1, { &display_line_dynarr_description} }, |
1204 | 504 { XD_END } |
505 }; | |
506 | |
507 static const struct sized_memory_description display_line_dynarr_pointer_description = { | |
508 sizeof (display_line_dynarr *), display_line_dynarr_pointer_description_1 | |
509 }; | |
510 | |
511 static const struct memory_description frame_description [] = { | |
512 { XD_INT, offsetof (struct frame, frametype) }, | |
513 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (struct frame, x) }, | |
514 #define MARKED_SLOT_ARRAY(slot, size) \ | |
515 { XD_LISP_OBJECT_ARRAY, offsetof (struct frame, slot), size }, | |
516 #include "frameslots.h" | |
517 | |
3092 | 518 #ifdef NEW_GC |
519 { XD_LISP_OBJECT, offsetof (struct frame, subwindow_exposures) }, | |
520 { XD_LISP_OBJECT, offsetof (struct frame, subwindow_exposures_tail) }, | |
521 #else /* not NEW_GC */ | |
2367 | 522 { XD_BLOCK_PTR, offsetof (struct frame, subwindow_exposures), |
2551 | 523 1, { &expose_ignore_description } }, |
2367 | 524 { XD_BLOCK_PTR, offsetof (struct frame, subwindow_exposures_tail), |
2551 | 525 1, { &expose_ignore_description } }, |
3092 | 526 #endif /* not NEW_GC */ |
1204 | 527 |
528 #ifdef HAVE_SCROLLBARS | |
529 { XD_LISP_OBJECT, offsetof (struct frame, sb_vcache) }, | |
530 { XD_LISP_OBJECT, offsetof (struct frame, sb_hcache) }, | |
531 #endif /* HAVE_SCROLLBARS */ | |
532 | |
2367 | 533 { XD_BLOCK_ARRAY, offsetof (struct frame, current_display_lines), |
2551 | 534 4, { &display_line_dynarr_pointer_description } }, |
2367 | 535 { XD_BLOCK_ARRAY, offsetof (struct frame, desired_display_lines), |
2551 | 536 4, { &display_line_dynarr_pointer_description } }, |
1204 | 537 |
2367 | 538 { XD_BLOCK_PTR, offsetof (struct frame, framemeths), 1, |
2551 | 539 { &console_methods_description } }, |
4207 | 540 { XD_UNION, offsetof (struct frame, frame_data), |
2551 | 541 XD_INDIRECT (0, 0), { &frame_data_description } }, |
1204 | 542 { XD_END } |
543 }; | |
544 | |
428 | 545 static Lisp_Object |
546 mark_frame (Lisp_Object obj) | |
547 { | |
548 struct frame *f = XFRAME (obj); | |
549 | |
1204 | 550 #define MARKED_SLOT(x) mark_object (f->x); |
428 | 551 #include "frameslots.h" |
552 | |
553 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */ | |
554 MAYBE_FRAMEMETH (f, mark_frame, (f)); | |
555 | |
617 | 556 #ifdef HAVE_SCROLLBARS |
557 if (f->sb_vcache) | |
558 mark_object (wrap_scrollbar_instance (f->sb_vcache)); | |
559 if (f->sb_hcache) | |
560 mark_object (wrap_scrollbar_instance (f->sb_hcache)); | |
561 #endif | |
562 | |
563 mark_gutters (f); | |
564 | |
428 | 565 return Qnil; |
566 } | |
567 | |
568 static void | |
2286 | 569 print_frame (Lisp_Object obj, Lisp_Object printcharfun, |
570 int UNUSED (escapeflag)) | |
428 | 571 { |
572 struct frame *frm = XFRAME (obj); | |
573 | |
574 if (print_readably) | |
4846 | 575 printing_unreadable_lcrecord (obj, XSTRING_DATA (frm->name)); |
428 | 576 |
800 | 577 write_fmt_string (printcharfun, "#<%s-frame ", !FRAME_LIVE_P (frm) ? "dead" : |
578 FRAME_TYPE_NAME (frm)); | |
428 | 579 print_internal (frm->name, printcharfun, 1); |
800 | 580 write_fmt_string (printcharfun, " 0x%x>", frm->header.uid); |
428 | 581 } |
582 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
583 DEFINE_NODUMP_LISP_OBJECT ("frame", frame, |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
584 mark_frame, print_frame, 0, 0, 0, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
585 frame_description, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
586 struct frame); |
428 | 587 |
588 static void | |
589 nuke_all_frame_slots (struct frame *f) | |
590 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
591 zero_nonsized_lisp_object (wrap_frame (f)); |
617 | 592 |
1204 | 593 #define MARKED_SLOT(x) f->x = Qnil; |
428 | 594 #include "frameslots.h" |
595 } | |
596 | |
597 /* Allocate a new frame object and set all its fields to reasonable | |
598 values. The root window is created but the minibuffer will be done | |
599 later. */ | |
600 | |
601 static struct frame * | |
602 allocate_frame_core (Lisp_Object device) | |
603 { | |
604 /* This function can GC */ | |
605 Lisp_Object root_window; | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
606 Lisp_Object frame = ALLOC_NORMAL_LISP_OBJECT (frame); |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
607 struct frame *f = XFRAME (frame); |
428 | 608 |
609 nuke_all_frame_slots (f); | |
610 | |
611 f->device = device; | |
612 f->framemeths = XDEVICE (device)->devmeths; | |
1204 | 613 f->frametype = get_console_variant (XDEVICE_TYPE (device)); |
428 | 614 f->buffer_alist = Fcopy_sequence (Vbuffer_alist); |
615 | |
616 root_window = allocate_window (); | |
617 XWINDOW (root_window)->frame = frame; | |
618 | |
619 /* 10 is arbitrary, | |
620 Just so that there is "something there." | |
621 Correct size will be set up later with change_frame_size. */ | |
622 | |
623 f->width = 10; | |
624 f->height = 10; | |
625 | |
626 XWINDOW (root_window)->pixel_width = 10; | |
627 XWINDOW (root_window)->pixel_height = 9; | |
628 | |
629 f->root_window = root_window; | |
630 f->selected_window = root_window; | |
631 f->last_nonminibuf_window = root_window; | |
632 | |
633 /* cache of subwindows visible on frame */ | |
442 | 634 f->subwindow_instance_cache = make_weak_list (WEAK_LIST_SIMPLE); |
428 | 635 |
636 /* associated exposure ignore list */ | |
637 f->subwindow_exposures = 0; | |
638 f->subwindow_exposures_tail = 0; | |
639 | |
442 | 640 FRAME_SET_PAGENUMBER (f, 1); |
641 | |
853 | 642 note_object_created (root_window); |
643 | |
428 | 644 /* Choose a buffer for the frame's root window. */ |
645 XWINDOW (root_window)->buffer = Qt; | |
646 { | |
647 Lisp_Object buf; | |
648 | |
649 buf = Fcurrent_buffer (); | |
650 /* If buf is a 'hidden' buffer (i.e. one whose name starts with | |
651 a space), try to find another one. */ | |
867 | 652 if (string_ichar (Fbuffer_name (buf), 0) == ' ') |
428 | 653 buf = Fother_buffer (buf, Qnil, Qnil); |
440 | 654 Fset_window_buffer (root_window, buf, Qnil); |
428 | 655 } |
656 | |
657 return f; | |
658 } | |
659 | |
660 static void | |
661 setup_normal_frame (struct frame *f) | |
662 { | |
663 Lisp_Object mini_window; | |
793 | 664 Lisp_Object frame = wrap_frame (f); |
665 | |
428 | 666 |
667 mini_window = allocate_window (); | |
668 XWINDOW (f->root_window)->next = mini_window; | |
669 XWINDOW (mini_window)->prev = f->root_window; | |
670 XWINDOW (mini_window)->mini_p = Qt; | |
671 XWINDOW (mini_window)->frame = frame; | |
672 f->minibuffer_window = mini_window; | |
673 f->has_minibuffer = 1; | |
674 | |
853 | 675 note_object_created (mini_window); |
676 | |
428 | 677 XWINDOW (mini_window)->buffer = Qt; |
440 | 678 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); |
428 | 679 } |
680 | |
681 /* Make a frame using a separate minibuffer window on another frame. | |
682 MINI_WINDOW is the minibuffer window to use. nil means use the | |
683 default-minibuffer-frame. */ | |
684 | |
685 static void | |
686 setup_frame_without_minibuffer (struct frame *f, Lisp_Object mini_window) | |
687 { | |
688 /* This function can GC */ | |
689 Lisp_Object device = f->device; | |
690 | |
691 if (!NILP (mini_window)) | |
692 CHECK_LIVE_WINDOW (mini_window); | |
693 | |
694 if (!NILP (mini_window) | |
695 && !EQ (DEVICE_CONSOLE (XDEVICE (device)), | |
696 FRAME_CONSOLE (XFRAME (XWINDOW (mini_window)->frame)))) | |
563 | 697 invalid_argument ("frame and minibuffer must be on the same console", Qunbound); |
428 | 698 |
442 | 699 /* Do not create a default minibuffer frame on printer devices. */ |
700 if (NILP (mini_window) | |
701 && DEVICE_DISPLAY_P (XDEVICE (FRAME_DEVICE (f)))) | |
428 | 702 { |
703 struct console *con = XCONSOLE (FRAME_CONSOLE (f)); | |
704 /* Use default-minibuffer-frame if possible. */ | |
705 if (!FRAMEP (con->default_minibuffer_frame) | |
706 || ! FRAME_LIVE_P (XFRAME (con->default_minibuffer_frame))) | |
707 { | |
708 /* If there's no minibuffer frame to use, create one. */ | |
709 con->default_minibuffer_frame | |
710 = call1 (Qmake_initial_minibuffer_frame, device); | |
711 } | |
712 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window; | |
713 } | |
714 | |
715 /* Install the chosen minibuffer window, with proper buffer. */ | |
442 | 716 if (!NILP (mini_window)) |
717 { | |
718 store_minibuf_frame_prop (f, mini_window); | |
719 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); | |
720 } | |
721 else | |
722 f->minibuffer_window = Qnil; | |
428 | 723 } |
724 | |
725 /* Make a frame containing only a minibuffer window. */ | |
726 | |
727 static void | |
728 setup_minibuffer_frame (struct frame *f) | |
729 { | |
730 /* This function can GC */ | |
731 /* First make a frame containing just a root window, no minibuffer. */ | |
732 Lisp_Object mini_window; | |
793 | 733 Lisp_Object frame = wrap_frame (f); |
734 | |
428 | 735 |
736 f->no_split = 1; | |
737 f->has_minibuffer = 1; | |
738 | |
739 /* Now label the root window as also being the minibuffer. | |
740 Avoid infinite looping on the window chain by marking next pointer | |
741 as nil. */ | |
742 | |
743 mini_window = f->minibuffer_window = f->root_window; | |
744 XWINDOW (mini_window)->mini_p = Qt; | |
745 XWINDOW (mini_window)->next = Qnil; | |
746 XWINDOW (mini_window)->prev = Qnil; | |
747 XWINDOW (mini_window)->frame = frame; | |
748 | |
749 /* Put the proper buffer in that window. */ | |
750 | |
440 | 751 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); |
428 | 752 } |
753 | |
754 static Lisp_Object | |
755 make_sure_its_a_fresh_plist (Lisp_Object foolist) | |
756 { | |
757 if (CONSP (Fcar (foolist))) | |
758 { | |
759 /* looks like an alist to me. */ | |
760 foolist = Fcopy_alist (foolist); | |
761 foolist = Fdestructive_alist_to_plist (foolist); | |
762 } | |
763 else | |
764 foolist = Fcopy_sequence (foolist); | |
765 | |
766 return foolist; | |
767 } | |
768 | |
558 | 769 static Lisp_Object |
546 | 770 restore_frame_list_to_its_unbesmirched_state (Lisp_Object kawnz) |
771 { | |
772 Lisp_Object lissed = XCDR (kawnz); | |
773 if (!EQ (lissed, Qunbound)) | |
774 DEVICE_FRAME_LIST (XDEVICE (XCAR (kawnz))) = lissed; | |
775 return Qnil; | |
4207 | 776 } |
546 | 777 |
428 | 778 DEFUN ("make-frame", Fmake_frame, 0, 2, "", /* |
779 Create and return a new frame, displaying the current buffer. | |
780 Runs the functions listed in `create-frame-hook' after frame creation. | |
781 | |
782 Optional argument PROPS is a property list (a list of alternating | |
783 keyword-value specifications) of properties for the new frame. | |
784 \(An alist is accepted for backward compatibility but should not | |
785 be passed in.) | |
786 | |
787 See `set-frame-properties', `default-x-frame-plist', and | |
788 `default-tty-frame-plist' for the specially-recognized properties. | |
789 */ | |
790 (props, device)) | |
791 { | |
792 struct frame *f; | |
793 struct device *d; | |
794 Lisp_Object frame = Qnil, name = Qnil, minibuf; | |
795 struct gcpro gcpro1, gcpro2, gcpro3; | |
546 | 796 int speccount = specpdl_depth (), speccount2; |
428 | 797 int first_frame_on_device = 0; |
798 int first_frame_on_console = 0; | |
546 | 799 Lisp_Object besmirched_cons = Qnil; |
771 | 800 int frame_name_is_defaulted = 1; |
428 | 801 |
802 d = decode_device (device); | |
793 | 803 device = wrap_device (d); |
428 | 804 |
805 /* PROPS and NAME may be freshly-created, so make sure to GCPRO. */ | |
806 GCPRO3 (frame, props, name); | |
807 | |
808 props = make_sure_its_a_fresh_plist (props); | |
809 if (DEVICE_SPECIFIC_FRAME_PROPS (d)) | |
810 /* Put the device-specific props before the more general ones so | |
811 that they override them. */ | |
812 props = nconc2 (props, | |
813 make_sure_its_a_fresh_plist | |
814 (*DEVICE_SPECIFIC_FRAME_PROPS (d))); | |
815 props = nconc2 (props, make_sure_its_a_fresh_plist (Vdefault_frame_plist)); | |
816 Fcanonicalize_lax_plist (props, Qnil); | |
817 | |
818 name = Flax_plist_get (props, Qname, Qnil); | |
819 if (!NILP (name)) | |
771 | 820 { |
821 CHECK_STRING (name); | |
822 frame_name_is_defaulted = 0; | |
823 } | |
2681 | 824 else if (!initialized) |
825 { | |
826 /* We leave Vdefault_frame_name alone here so that it'll remain Qnil | |
827 in the dumped executable, and we can choose it at runtime. */ | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
828 name = build_ascstring ("XEmacs"); |
2681 | 829 } |
4207 | 830 else if (NILP (Vdefault_frame_name)) |
831 { | |
2681 | 832 if (egetenv ("USE_EMACS_AS_DEFAULT_APPLICATION_CLASS")) |
833 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
834 Vdefault_frame_name = build_ascstring ("emacs"); |
2681 | 835 } |
4207 | 836 else |
2681 | 837 { |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
838 Vdefault_frame_name = build_ascstring ("XEmacs"); |
2681 | 839 } |
840 } | |
841 | |
842 if (NILP(name) && STRINGP(Vdefault_frame_name)) | |
843 { | |
844 name = Vdefault_frame_name; | |
845 } | |
428 | 846 |
867 | 847 if (!NILP (Fstring_match (make_string ((const Ibyte *) "\\.", 2), name, |
428 | 848 Qnil, Qnil))) |
563 | 849 syntax_error (". not allowed in frame names", name); |
428 | 850 |
851 f = allocate_frame_core (device); | |
793 | 852 frame = wrap_frame (f); |
428 | 853 |
854 specbind (Qframe_being_created, name); | |
855 f->name = name; | |
856 | |
771 | 857 FRAMEMETH (f, init_frame_1, (f, props, frame_name_is_defaulted)); |
428 | 858 |
859 minibuf = Flax_plist_get (props, Qminibuffer, Qunbound); | |
860 if (UNBOUNDP (minibuf)) | |
861 { | |
862 /* If minibuf is unspecified, then look for a minibuffer X resource. */ | |
863 /* #### Not implemented any more. We need to fix things up so | |
864 that we search out all X resources and append them to the end of | |
865 props, above. This is the only way in general to assure | |
866 coherent behavior for all frame properties/resources/etc. */ | |
867 } | |
868 else | |
869 props = Flax_plist_remprop (props, Qminibuffer); | |
870 | |
871 if (EQ (minibuf, Qnone) || NILP (minibuf)) | |
872 setup_frame_without_minibuffer (f, Qnil); | |
873 else if (EQ (minibuf, Qonly)) | |
874 setup_minibuffer_frame (f); | |
875 else if (WINDOWP (minibuf)) | |
876 setup_frame_without_minibuffer (f, minibuf); | |
877 else if (EQ (minibuf, Qt) || UNBOUNDP (minibuf)) | |
878 setup_normal_frame (f); | |
879 else | |
563 | 880 invalid_argument ("Invalid value for `minibuffer'", minibuf); |
428 | 881 |
882 update_frame_window_mirror (f); | |
883 | |
4968 | 884 /* #### Do we need to be calling reset_face_cachels here, and then again |
885 down below? */ | |
428 | 886 if (initialized && !DEVICE_STREAM_P (d)) |
887 { | |
888 if (!NILP (f->minibuffer_window)) | |
4207 | 889 reset_face_cachels (XWINDOW (f->minibuffer_window)); |
428 | 890 reset_face_cachels (XWINDOW (f->root_window)); |
891 } | |
892 | |
893 /* If no frames on this device formerly existed, say this is the | |
894 first frame. It kind of assumes that frameless devices don't | |
895 exist, but it shouldn't be too harmful. */ | |
896 if (NILP (DEVICE_FRAME_LIST (d))) | |
897 first_frame_on_device = 1; | |
898 | |
546 | 899 /* It's possible for one of the init methods below to signal an error; |
900 in that case, let's make sure the device isn't besmirched by | |
901 having a half-initialized frame attached to it */ | |
902 speccount2 = specpdl_depth (); | |
903 record_unwind_protect (restore_frame_list_to_its_unbesmirched_state, | |
904 besmirched_cons = | |
905 Fcons (device, DEVICE_FRAME_LIST (d))); | |
906 | |
428 | 907 /* This *must* go before the init_*() methods. Those functions |
908 call Lisp code, and if any of them causes a warning to be displayed | |
909 and the *Warnings* buffer to be created, it won't get added to | |
910 the frame-specific version of the buffer-alist unless the frame | |
911 is accessible from the device. */ | |
912 | |
913 #if 0 | |
914 DEVICE_FRAME_LIST (d) = nconc2 (DEVICE_FRAME_LIST (d), Fcons (frame, Qnil)); | |
915 #endif | |
916 DEVICE_FRAME_LIST (d) = Fcons (frame, DEVICE_FRAME_LIST (d)); | |
917 RESET_CHANGED_SET_FLAGS; | |
918 | |
853 | 919 note_object_created (frame); |
920 | |
428 | 921 /* Now make sure that the initial cached values are set correctly. |
922 Do this after the init_frame method is called because that may | |
923 do things (e.g. create widgets) that are necessary for the | |
924 specifier value-changed methods to work OK. */ | |
925 recompute_all_cached_specifiers_in_frame (f); | |
926 | |
927 if (!DEVICE_STREAM_P (d)) | |
928 { | |
929 init_frame_faces (f); | |
930 | |
931 #ifdef HAVE_SCROLLBARS | |
932 /* Finish up resourcing the scrollbars. */ | |
933 init_frame_scrollbars (f); | |
934 #endif | |
935 | |
936 #ifdef HAVE_TOOLBARS | |
937 /* Create the initial toolbars. We have to do this after the frame | |
938 methods are called because it may potentially call some things itself | |
939 which depend on the normal frame methods having initialized | |
940 things. */ | |
941 init_frame_toolbars (f); | |
942 #endif | |
4968 | 943 /* Added this assert recently (2-1-10); seems there should be only |
944 two windows, root and minibufer. Probably we should just be | |
945 calling reset_*_cachels on the root window directly instead of the | |
946 selected window, but I want to make sure they are always the | |
947 same. --ben */ | |
948 assert (EQ (FRAME_SELECTED_WINDOW (f), f->root_window)); | |
428 | 949 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); |
950 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); | |
4968 | 951 if (!NILP (f->minibuffer_window)) |
952 { | |
953 reset_face_cachels (XWINDOW (f->minibuffer_window)); | |
954 reset_glyph_cachels (XWINDOW (f->minibuffer_window)); | |
955 } | |
442 | 956 |
5043 | 957 change_frame_size (f, f->width, f->height, 0); |
428 | 958 } |
959 | |
960 MAYBE_FRAMEMETH (f, init_frame_2, (f, props)); | |
961 Fset_frame_properties (frame, props); | |
962 MAYBE_FRAMEMETH (f, init_frame_3, (f)); | |
963 | |
964 /* Hallelujah, praise the lord. */ | |
965 f->init_finished = 1; | |
966 | |
546 | 967 XCDR (besmirched_cons) = Qunbound; |
968 | |
771 | 969 unbind_to (speccount2); |
546 | 970 |
428 | 971 /* If this is the first frame on the device, make it the selected one. */ |
972 if (first_frame_on_device && NILP (DEVICE_SELECTED_FRAME (d))) | |
973 set_device_selected_frame (d, frame); | |
974 | |
975 /* If at startup or if the current console is a stream console | |
976 (usually also at startup), make this console the selected one | |
977 so that messages show up on it. */ | |
978 if (NILP (Fselected_console ()) || | |
979 CONSOLE_STREAM_P (XCONSOLE (Fselected_console ()))) | |
980 Fselect_console (DEVICE_CONSOLE (d)); | |
981 | |
982 first_frame_on_console = | |
983 (first_frame_on_device && | |
984 XINT (Flength (CONSOLE_DEVICE_LIST (XCONSOLE (DEVICE_CONSOLE (d))))) | |
985 == 1); | |
986 | |
987 /* #### all this calling of frame methods at various odd times | |
988 is somewhat of a mess. It's necessary to do it this way due | |
989 to strange console-type-specific things that need to be done. */ | |
990 MAYBE_FRAMEMETH (f, after_init_frame, (f, first_frame_on_device, | |
991 first_frame_on_console)); | |
992 | |
442 | 993 if (!DEVICE_STREAM_P (d)) |
994 { | |
995 /* Now initialise the gutters. This won't change the frame size, | |
4207 | 996 but is needed as input to the layout that change_frame_size |
997 will eventually do. Unfortunately gutter sizing code relies | |
998 on the frame in question being visible so we can't do this | |
999 earlier. */ | |
442 | 1000 init_frame_gutters (f); |
1001 | |
5043 | 1002 change_frame_size (f, f->width, f->height, 0); |
442 | 1003 } |
1004 | |
428 | 1005 if (first_frame_on_device) |
1006 { | |
1007 if (first_frame_on_console) | |
1008 va_run_hook_with_args (Qcreate_console_hook, 1, DEVICE_CONSOLE (d)); | |
1009 va_run_hook_with_args (Qcreate_device_hook, 1, device); | |
1010 } | |
1011 va_run_hook_with_args (Qcreate_frame_hook, 1, frame); | |
1012 | |
1013 /* Initialize custom-specific stuff. */ | |
1014 if (!UNBOUNDP (symbol_function (XSYMBOL (Qcustom_initialize_frame)))) | |
1015 call1 (Qcustom_initialize_frame, frame); | |
1016 | |
1204 | 1017 UNGCPRO; |
771 | 1018 unbind_to (speccount); |
428 | 1019 |
1020 return frame; | |
1021 } | |
1022 | |
1023 | |
1024 /* this function should be used in most cases when a Lisp function is passed | |
1025 a FRAME argument. Use this unless you don't accept nil == current frame | |
1026 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you | |
1027 allow dead frames. Note that very few functions should accept dead | |
1028 frames. It could be argued that functions should just do nothing when | |
1029 given a dead frame, but the presence of a dead frame usually indicates | |
1030 an oversight in the Lisp code that could potentially lead to strange | |
1031 results and so it is better to catch the error early. | |
1032 | |
1033 If you only accept X frames, use decode_x_frame(), which does what this | |
1034 function does but also makes sure the frame is an X frame. */ | |
1035 | |
1036 struct frame * | |
1037 decode_frame (Lisp_Object frame) | |
1038 { | |
1039 if (NILP (frame)) | |
1040 return selected_frame (); | |
1041 | |
1042 CHECK_LIVE_FRAME (frame); | |
1043 return XFRAME (frame); | |
1044 } | |
1045 | |
1046 struct frame * | |
1047 decode_frame_or_selected (Lisp_Object cdf) | |
1048 { | |
1049 if (CONSOLEP (cdf)) | |
1050 cdf = CONSOLE_SELECTED_DEVICE (decode_console (cdf)); | |
1051 if (DEVICEP (cdf)) | |
1052 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); | |
1053 return decode_frame (cdf); | |
1054 } | |
1055 | |
872 | 1056 Lisp_Object |
1057 frame_device (struct frame *f) | |
1058 { | |
1059 return FRAME_DEVICE (f); | |
1060 } | |
1061 | |
1062 int | |
1063 frame_live_p (struct frame *f) | |
1064 { | |
1065 return FRAME_LIVE_P (f); | |
1066 } | |
1067 | |
428 | 1068 |
1069 void | |
1070 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
1071 { | |
1072 /* Invalidate cached value of needs_vertical_divider_p in | |
1073 every and all windows */ | |
1074 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
1075 } | |
1076 | |
1077 /* | |
1078 * Frame size may change due to changes in scrollbars, toolbars, | |
1079 * default font etc. These changes are applied early in redisplay | |
1080 * frame. | |
1081 */ | |
1082 void | |
1083 adjust_frame_size (struct frame *f) | |
1084 { | |
1318 | 1085 /* This can call Lisp. */ |
428 | 1086 int keep_char_size = 0; |
793 | 1087 Lisp_Object frame = wrap_frame (f); |
1088 | |
428 | 1089 if (!f->size_slipped) |
1090 return; | |
1091 | |
1092 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
1093 Then, write an Vadjust_frame_function which will return t for TTY | |
1094 frames. Another solution is frame_size_fixed_p method for TTYs, | |
1095 which always returned yes it's fixed. | |
1096 */ | |
1097 if (!FRAME_WIN_P (f)) | |
1098 { | |
1099 CLEAR_FRAME_SIZE_SLIPPED (f); | |
1100 return; | |
1101 } | |
1102 | |
1103 /* frame_size_fixed_p tells that frame size cannot currently | |
1104 be changed change due to external conditions */ | |
1105 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
1106 { | |
1107 if (NILP (Vadjust_frame_function)) | |
1108 keep_char_size = 1; | |
1109 else if (EQ (Vadjust_frame_function, Qt)) | |
1110 keep_char_size = 0; | |
1111 else | |
1112 keep_char_size = | |
853 | 1113 NILP (call1_trapping_problems ("Error in adjust-frame-function", |
1114 Vadjust_frame_function, frame, | |
1115 0)); | |
428 | 1116 |
1117 if (keep_char_size) | |
1118 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
1119 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
1120 } | |
1121 | |
1122 if (!keep_char_size) | |
1123 { | |
1124 int height, width; | |
5043 | 1125 pixel_to_frame_unit_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), |
428 | 1126 &width, &height); |
5043 | 1127 change_frame_size (f, width, height, 0); |
428 | 1128 CLEAR_FRAME_SIZE_SLIPPED (f); |
1129 } | |
1130 } | |
1131 | |
1132 /* | |
1133 * This is a "specifier changed in frame" handler for various specifiers | |
1134 * changing which causes frame size adjustment | |
1135 */ | |
1136 void | |
2286 | 1137 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, |
1138 Lisp_Object UNUSED (oldval)) | |
428 | 1139 { |
1140 MARK_FRAME_SIZE_SLIPPED(f); | |
1141 } | |
1142 | |
1143 DEFUN ("framep", Fframep, 1, 1, 0, /* | |
1144 Return non-nil if OBJECT is a frame. | |
1145 Also see `frame-live-p'. | |
1146 Note that FSF Emacs kludgily returns a value indicating what type of | |
1147 frame this is. Use the cleaner function `frame-type' for that. | |
1148 */ | |
1149 (object)) | |
1150 { | |
1151 return FRAMEP (object) ? Qt : Qnil; | |
1152 } | |
1153 | |
1154 DEFUN ("frame-live-p", Fframe_live_p, 1, 1, 0, /* | |
1155 Return non-nil if OBJECT is a frame which has not been deleted. | |
1156 */ | |
1157 (object)) | |
1158 { | |
1159 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; | |
1160 } | |
1161 | |
1162 | |
1163 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* | |
1164 Select FRAME and give it the window system focus. | |
1165 This function is not affected by the value of `focus-follows-mouse'. | |
1166 */ | |
1167 (frame)) | |
1168 { | |
1169 CHECK_LIVE_FRAME (frame); | |
1170 | |
1171 MAYBE_DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (frame))), focus_on_frame, | |
1172 (XFRAME (frame))); | |
1173 /* FRAME will be selected by the time we receive the next event. | |
1174 However, it is better to select it explicitly now, in case the | |
1175 Lisp code depends on frame being selected. */ | |
1176 Fselect_frame (frame); | |
1177 return Qnil; | |
1178 } | |
1179 | |
1180 /* Called from Fselect_window() */ | |
1181 void | |
1182 select_frame_1 (Lisp_Object frame) | |
1183 { | |
1184 struct frame *f = XFRAME (frame); | |
1185 Lisp_Object old_selected_frame = Fselected_frame (Qnil); | |
1186 | |
1187 if (EQ (frame, old_selected_frame)) | |
1188 return; | |
1189 | |
1190 /* now select the frame's device */ | |
1191 set_device_selected_frame (XDEVICE (FRAME_DEVICE (f)), frame); | |
1192 select_device_1 (FRAME_DEVICE (f)); | |
1193 | |
1194 update_frame_window_mirror (f); | |
1195 } | |
1196 | |
1197 DEFUN ("select-frame", Fselect_frame, 1, 1, 0, /* | |
1198 Select the frame FRAME. | |
1199 Subsequent editing commands apply to its selected window. | |
1200 The selection of FRAME lasts until the next time the user does | |
1201 something to select a different frame, or until the next time this | |
1202 function is called. | |
1203 | |
1204 Note that this does not actually cause the window-system focus to be | |
1205 set to this frame, or the `select-frame-hook' or `deselect-frame-hook' | |
1206 to be run, until the next time that XEmacs is waiting for an event. | |
1207 | |
1208 Also note that when focus-follows-mouse is non-nil, the frame | |
1209 selection is temporary and is reverted when the current command | |
1210 terminates, much like the buffer selected by `set-buffer'. In order | |
1211 to effect a permanent focus change, use `focus-frame'. | |
1212 */ | |
1213 (frame)) | |
1214 { | |
1215 CHECK_LIVE_FRAME (frame); | |
1216 | |
1217 /* select the frame's selected window. This will call | |
1218 selected_frame_1(). */ | |
1219 Fselect_window (FRAME_SELECTED_WINDOW (XFRAME (frame)), Qnil); | |
1220 | |
1221 /* Nothing should be depending on the return value of this function. | |
1222 But, of course, there is stuff out there which is. */ | |
1223 return frame; | |
1224 } | |
1225 | |
1226 /* use this to retrieve the currently selected frame. You should use | |
1227 this in preference to Fselected_frame (Qnil) unless you are prepared | |
1228 to handle the possibility of there being no selected frame (this | |
1229 happens at some points during startup). */ | |
1230 | |
1231 struct frame * | |
1232 selected_frame (void) | |
1233 { | |
1234 Lisp_Object device = Fselected_device (Qnil); | |
1235 Lisp_Object frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); | |
1236 if (NILP (frame)) | |
563 | 1237 gui_error ("No frames exist on device", device); |
428 | 1238 return XFRAME (frame); |
1239 } | |
1240 | |
1241 /* use this instead of XFRAME (DEVICE_SELECTED_FRAME (d)) to catch | |
1242 the possibility of there being no frames on the device (just created). | |
1243 There is no point doing this inside of redisplay because errors | |
2500 | 1244 cause an ABORT(), indicating a flaw in the logic, and error_check_frame() |
428 | 1245 will catch this just as well. */ |
1246 | |
1247 struct frame * | |
1248 device_selected_frame (struct device *d) | |
1249 { | |
1250 Lisp_Object frame = DEVICE_SELECTED_FRAME (d); | |
1251 if (NILP (frame)) | |
1252 { | |
793 | 1253 Lisp_Object device = wrap_device (d); |
1254 | |
563 | 1255 gui_error ("No frames exist on device", device); |
428 | 1256 } |
1257 return XFRAME (frame); | |
1258 } | |
1259 | |
1260 #if 0 /* FSFmacs */ | |
1261 | |
826 | 1262 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* |
428 | 1263 Handle a switch-frame event EVENT. |
1264 Switch-frame events are usually bound to this function. | |
1265 A switch-frame event tells Emacs that the window manager has requested | |
1266 that the user's events be directed to the frame mentioned in the event. | |
1267 This function selects the selected window of the frame of EVENT. | |
1268 | |
1269 If EVENT is frame object, handle it as if it were a switch-frame event | |
1270 to that frame. | |
1271 */ | |
1272 (frame, no_enter)) | |
1273 { | |
1274 /* Preserve prefix arg that the command loop just cleared. */ | |
1275 XCONSOLE (Vselected_console)->prefix_arg = Vcurrent_prefix_arg; | |
1276 #if 0 /* unclean! */ | |
1277 run_hook (Qmouse_leave_buffer_hook); | |
1278 #endif | |
1279 return do_switch_frame (frame, no_enter, 0); | |
1280 } | |
1281 | |
1282 /* A load of garbage. */ | |
826 | 1283 DEFUN ("ignore-event", Fignore_event, 0, 0, "", /* |
428 | 1284 Do nothing, but preserve any prefix argument already specified. |
1285 This is a suitable binding for iconify-frame and make-frame-visible. | |
1286 */ | |
1287 ()) | |
1288 { | |
1289 struct console *c = XCONSOLE (Vselected_console); | |
1290 | |
1291 c->prefix_arg = Vcurrent_prefix_arg; | |
1292 return Qnil; | |
1293 } | |
1294 | |
1295 #endif /* 0 */ | |
1296 | |
1297 DEFUN ("selected-frame", Fselected_frame, 0, 1, 0, /* | |
1298 Return the frame that is now selected on device DEVICE. | |
1299 If DEVICE is not specified, the selected device will be used. | |
1300 If no frames exist on the device, nil is returned. | |
1301 */ | |
1302 (device)) | |
1303 { | |
1304 if (NILP (device) && NILP (Fselected_device (Qnil))) | |
1305 return Qnil; /* happens early in temacs */ | |
1306 return DEVICE_SELECTED_FRAME (decode_device (device)); | |
1307 } | |
1308 | |
1309 Lisp_Object | |
1310 frame_first_window (struct frame *f) | |
1311 { | |
1312 Lisp_Object w = f->root_window; | |
1313 | |
1314 while (1) | |
1315 { | |
1316 if (! NILP (XWINDOW (w)->hchild)) | |
1317 w = XWINDOW (w)->hchild; | |
1318 else if (! NILP (XWINDOW (w)->vchild)) | |
1319 w = XWINDOW (w)->vchild; | |
1320 else | |
1321 break; | |
1322 } | |
1323 | |
1324 return w; | |
1325 } | |
1326 | |
1327 DEFUN ("active-minibuffer-window", Factive_minibuffer_window, 0, 0, 0, /* | |
1328 Return the currently active minibuffer window, or nil if none. | |
1329 */ | |
1330 ()) | |
1331 { | |
1332 return minibuf_level ? minibuf_window : Qnil; | |
1333 } | |
1334 | |
1335 DEFUN ("last-nonminibuf-frame", Flast_nonminibuf_frame, 0, 1, 0, /* | |
1336 Return the most-recently-selected non-minibuffer-only frame on CONSOLE. | |
1337 This will always be the same as (selected-frame device) unless the | |
1338 selected frame is a minibuffer-only frame. | |
1339 CONSOLE defaults to the selected console if omitted. | |
1340 */ | |
1341 (console)) | |
1342 { | |
1343 Lisp_Object result; | |
1344 | |
793 | 1345 console = wrap_console (decode_console (console)); |
428 | 1346 /* Just in case the machinations in delete_frame_internal() resulted |
1347 in the last-nonminibuf-frame getting out of sync, make sure and | |
1348 return the selected frame if it's acceptable. */ | |
1349 result = Fselected_frame (CONSOLE_SELECTED_DEVICE (XCONSOLE (console))); | |
1350 if (!NILP (result) && !FRAME_MINIBUF_ONLY_P (XFRAME (result))) | |
1351 return result; | |
1352 return CONSOLE_LAST_NONMINIBUF_FRAME (XCONSOLE (console)); | |
1353 } | |
1354 | |
1355 DEFUN ("frame-root-window", Fframe_root_window, 0, 1, 0, /* | |
1356 Return the root-window of FRAME. | |
1357 If omitted, FRAME defaults to the currently selected frame. | |
1358 */ | |
1359 (frame)) | |
1360 { | |
1361 struct frame *f = decode_frame (frame); | |
1362 return FRAME_ROOT_WINDOW (f); | |
1363 } | |
1364 | |
1365 DEFUN ("frame-selected-window", Fframe_selected_window, 0, 1, 0, /* | |
1366 Return the selected window of frame object FRAME. | |
1367 If omitted, FRAME defaults to the currently selected frame. | |
1368 */ | |
1369 (frame)) | |
1370 { | |
1371 struct frame *f = decode_frame (frame); | |
1372 return FRAME_SELECTED_WINDOW (f); | |
1373 } | |
1374 | |
1375 void | |
1376 set_frame_selected_window (struct frame *f, Lisp_Object window) | |
1377 { | |
1378 assert (XFRAME (WINDOW_FRAME (XWINDOW (window))) == f); | |
1379 f->selected_window = window; | |
1380 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f)) | |
1381 { | |
1382 if (!EQ (f->last_nonminibuf_window, window)) | |
1383 { | |
442 | 1384 #ifdef HAVE_TOOLBARS |
428 | 1385 MARK_TOOLBAR_CHANGED; |
442 | 1386 #endif |
428 | 1387 MARK_GUTTER_CHANGED; |
1388 } | |
1389 f->last_nonminibuf_window = window; | |
1390 } | |
1391 } | |
1392 | |
1393 DEFUN ("set-frame-selected-window", Fset_frame_selected_window, 2, 2, 0, /* | |
460 | 1394 Set the selected window of FRAME to WINDOW. |
428 | 1395 If FRAME is nil, the selected frame is used. |
1396 If FRAME is the selected frame, this makes WINDOW the selected window. | |
1397 */ | |
1398 (frame, window)) | |
1399 { | |
793 | 1400 frame = wrap_frame (decode_frame (frame)); |
428 | 1401 CHECK_LIVE_WINDOW (window); |
1402 | |
1403 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window)))) | |
563 | 1404 invalid_argument ("In `set-frame-selected-window', WINDOW is not on FRAME", Qunbound); |
428 | 1405 |
1406 if (XFRAME (frame) == selected_frame ()) | |
1407 return Fselect_window (window, Qnil); | |
1408 | |
1409 set_frame_selected_window (XFRAME (frame), window); | |
1410 return window; | |
1411 } | |
1412 | |
1413 | |
1414 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | |
1415 Return the device that FRAME is on. | |
1416 If omitted, FRAME defaults to the currently selected frame. | |
1417 */ | |
1418 (frame)) | |
1419 { | |
1420 return FRAME_DEVICE (decode_frame (frame)); | |
1421 } | |
1422 | |
1423 int | |
1424 is_surrogate_for_selected_frame (struct frame *f) | |
1425 { | |
1426 struct device *d = XDEVICE (f->device); | |
1427 struct frame *dsf = device_selected_frame (d); | |
1428 | |
1429 /* Can't be a surrogate for ourselves. */ | |
1430 if (f == dsf) | |
1431 return 0; | |
1432 | |
1433 if (!FRAME_HAS_MINIBUF_P (dsf) && | |
1434 f == XFRAME (WINDOW_FRAME (XWINDOW (FRAME_MINIBUF_WINDOW (dsf))))) | |
1435 return 1; | |
1436 else | |
1437 return 0; | |
1438 } | |
1439 | |
1440 static int | |
444 | 1441 frame_matches_frame_spec (Lisp_Object frame, Lisp_Object type) |
428 | 1442 { |
1443 struct frame *f = XFRAME (frame); | |
1444 | |
1445 if (WINDOWP (type)) | |
1446 { | |
1447 CHECK_LIVE_WINDOW (type); | |
1448 | |
1449 if (EQ (FRAME_MINIBUF_WINDOW (f), type) | |
1450 /* Check that F either is, or has forwarded | |
1451 its focus to, TYPE's frame. */ | |
1452 && (EQ (WINDOW_FRAME (XWINDOW (type)), frame) | |
1453 || EQ (WINDOW_FRAME (XWINDOW (type)), | |
1454 FRAME_FOCUS_FRAME (f)))) | |
1455 return 1; | |
1456 else | |
1457 return 0; | |
1458 } | |
1459 | |
1460 #if 0 /* FSFmacs */ | |
1461 if (EQ (type, Qvisible) || EQ (type, Qiconic) || EQ (type, Qvisible_iconic) | |
1462 || EQ (type, Qvisible_nomini) || EQ (type, Qiconic_nomini) | |
1463 || EQ (type, Qvisible_iconic_nomini)) | |
1464 FRAME_SAMPLE_VISIBILITY (f); | |
1465 #endif | |
1466 | |
1467 if (NILP (type)) | |
1468 type = Qnomini; | |
1469 if (ZEROP (type)) | |
1470 type = Qvisible_iconic; | |
1471 | |
1472 if (EQ (type, Qvisible)) | |
1473 return FRAME_VISIBLE_P (f); | |
1474 if (EQ (type, Qiconic)) | |
1475 return FRAME_ICONIFIED_P (f); | |
1476 if (EQ (type, Qinvisible)) | |
1477 return !FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f); | |
1478 if (EQ (type, Qvisible_iconic)) | |
1479 return FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f); | |
1480 if (EQ (type, Qinvisible_iconic)) | |
1481 return !FRAME_VISIBLE_P (f); | |
1482 | |
1483 if (EQ (type, Qnomini)) | |
1484 return !FRAME_MINIBUF_ONLY_P (f); | |
1485 if (EQ (type, Qvisible_nomini)) | |
1486 return FRAME_VISIBLE_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
1487 if (EQ (type, Qiconic_nomini)) | |
1488 return FRAME_ICONIFIED_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
1489 if (EQ (type, Qinvisible_nomini)) | |
1490 return !FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f) && | |
1491 !FRAME_MINIBUF_ONLY_P (f); | |
1492 if (EQ (type, Qvisible_iconic_nomini)) | |
1493 return ((FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) | |
1494 && !FRAME_MINIBUF_ONLY_P (f)); | |
1495 if (EQ (type, Qinvisible_iconic_nomini)) | |
1496 return !FRAME_VISIBLE_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
1497 | |
1498 return 1; | |
1499 } | |
1500 | |
1501 int | |
444 | 1502 device_matches_device_spec (Lisp_Object device, Lisp_Object device_spec) |
428 | 1503 { |
444 | 1504 if (EQ (device_spec, Qwindow_system)) |
428 | 1505 return DEVICE_WIN_P (XDEVICE (device)); |
444 | 1506 if (DEVICEP (device_spec)) |
1507 return EQ (device, device_spec); | |
1508 if (CONSOLEP (device_spec)) | |
1509 return EQ (DEVICE_CONSOLE (XDEVICE (device)), device_spec); | |
1510 if (valid_console_type_p (device_spec)) | |
1511 return EQ (DEVICE_TYPE (XDEVICE (device)), device_spec); | |
428 | 1512 return 1; |
1513 } | |
1514 | |
1515 /* Return the next frame in the frame list after FRAME. | |
444 | 1516 WHICH-FRAMES and WHICH-DEVICES control which frames and devices |
428 | 1517 are considered; see `next-frame'. */ |
1518 | |
1519 Lisp_Object | |
444 | 1520 next_frame (Lisp_Object frame, Lisp_Object which_frames, Lisp_Object which_devices) |
428 | 1521 { |
442 | 1522 Lisp_Object first = Qnil; |
1523 Lisp_Object devcons, concons; | |
1524 int passed = 0; | |
1525 | |
1526 CHECK_LIVE_FRAME (frame); | |
1527 | |
1528 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
1529 { | |
1530 Lisp_Object device = XCAR (devcons); | |
1531 Lisp_Object frmcons; | |
1532 | |
444 | 1533 if (!device_matches_device_spec (device, which_devices)) |
442 | 1534 { |
1535 if (EQ (device, FRAME_DEVICE (XFRAME (frame)))) | |
1536 passed = 1; | |
1537 continue; | |
1538 } | |
1539 | |
1540 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | |
1541 { | |
1542 Lisp_Object f = XCAR (frmcons); | |
1543 | |
1544 if (passed) | |
1545 { | |
444 | 1546 if (frame_matches_frame_spec (f, which_frames)) |
442 | 1547 return f; |
1548 } | |
1549 else | |
1550 { | |
1551 if (EQ (frame, f)) | |
1552 { | |
1553 passed = 1; | |
1554 } | |
1555 else | |
1556 { | |
444 | 1557 if (NILP (first) && frame_matches_frame_spec (f, which_frames)) |
442 | 1558 first = f; |
1559 } | |
1560 } | |
1561 } | |
1562 } | |
1563 | |
1564 if (NILP (first)) | |
1565 /* We went through the whole frame list without finding a single | |
1566 acceptable frame. Return the original frame. */ | |
1567 return frame; | |
1568 else | |
1569 /* There were no acceptable frames in the list after FRAME; otherwise, | |
1570 we would have returned directly from the loop. Since FIRST is the last | |
1571 acceptable frame in the list, return it. */ | |
1572 return first; | |
428 | 1573 } |
1574 | |
1575 /* Return the previous frame in the frame list before FRAME. | |
444 | 1576 WHICH-FRAMES and WHICH-DEVICES control which frames and devices |
428 | 1577 are considered; see `next-frame'. */ |
1578 | |
1579 Lisp_Object | |
444 | 1580 previous_frame (Lisp_Object frame, Lisp_Object which_frames, Lisp_Object which_devices) |
428 | 1581 { |
1582 Lisp_Object devcons, concons; | |
442 | 1583 Lisp_Object last = Qnil; |
1584 | |
428 | 1585 CHECK_LIVE_FRAME (frame); |
1586 | |
1587 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
1588 { | |
1589 Lisp_Object device = XCAR (devcons); | |
1590 Lisp_Object frmcons; | |
1591 | |
444 | 1592 if (!device_matches_device_spec (device, which_devices)) |
442 | 1593 { |
1594 if (EQ (device, FRAME_DEVICE (XFRAME (frame))) | |
1595 && !NILP (last)) | |
1596 return last; | |
1597 continue; | |
1598 } | |
428 | 1599 |
1600 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | |
1601 { | |
1602 Lisp_Object f = XCAR (frmcons); | |
1603 | |
442 | 1604 if (EQ (frame, f)) |
1605 { | |
1606 if (!NILP (last)) | |
1607 return last; | |
1608 } | |
1609 else | |
1610 { | |
444 | 1611 if (frame_matches_frame_spec (f, which_frames)) |
442 | 1612 last = f; |
1613 } | |
428 | 1614 } |
1615 } | |
1616 | |
442 | 1617 if (NILP (last)) |
428 | 1618 /* We went through the whole frame list without finding a single |
1619 acceptable frame. Return the original frame. */ | |
1620 return frame; | |
1621 else | |
1622 /* There were no acceptable frames in the list before FRAME; otherwise, | |
442 | 1623 we would have returned directly from the loop. Since LAST is the last |
428 | 1624 acceptable frame in the list, return it. */ |
442 | 1625 return last; |
428 | 1626 } |
1627 | |
1628 DEFUN ("next-frame", Fnext_frame, 0, 3, 0, /* | |
1629 Return the next frame of the right type in the frame list after FRAME. | |
444 | 1630 WHICH-FRAMES controls which frames are eligible to be returned; all |
428 | 1631 others will be skipped. Note that if there is only one eligible |
1632 frame, then `next-frame' called repeatedly will always return | |
1633 the same frame, and if there is no eligible frame, then FRAME is | |
1634 returned. | |
1635 | |
444 | 1636 Possible values for WHICH-FRAMES are |
428 | 1637 |
3025 | 1638 `visible' Consider only frames that are visible. |
1639 `iconic' Consider only frames that are iconic. | |
1640 `invisible' Consider only frames that are invisible | |
4207 | 1641 (this is different from iconic). |
3025 | 1642 `visible-iconic' Consider frames that are visible or iconic. |
1643 `invisible-iconic' Consider frames that are invisible or iconic. | |
1644 `nomini' Consider all frames except minibuffer-only ones. | |
1645 `visible-nomini' Like `visible' but omits minibuffer-only frames. | |
1646 `iconic-nomini' Like `iconic' but omits minibuffer-only frames. | |
1647 `invisible-nomini' Like `invisible' but omits minibuffer-only frames. | |
1648 `visible-iconic-nomini' Like `visible-iconic' but omits minibuffer-only | |
4207 | 1649 frames. |
3025 | 1650 `invisible-iconic-nomini' Like `invisible-iconic' but omits minibuffer-only |
4207 | 1651 frames. |
3025 | 1652 any other value Consider all frames. |
1653 | |
1654 If WHICH-FRAMES is omitted, `nomini' is used. A value for WHICH-FRAMES | |
1655 of 0 (a number) is treated like `iconic', for backwards compatibility. | |
444 | 1656 |
1657 If WHICH-FRAMES is a window, include only its own frame and any frame | |
1658 now using that window as the minibuffer. | |
1659 | |
1660 The optional third argument WHICH-DEVICES further clarifies on which | |
1661 devices to search for frames as specified by WHICH-FRAMES. | |
1662 If nil or omitted, search all devices on FRAME's console. | |
1663 If a device, only search that device. | |
1664 If a console, search all devices on that console. | |
1665 If a device type, search all devices of that type. | |
1666 If `window-system', search all window-system devices. | |
1667 Any other non-nil value means search all devices. | |
428 | 1668 */ |
444 | 1669 (frame, which_frames, which_devices)) |
428 | 1670 { |
793 | 1671 frame = wrap_frame (decode_frame (frame)); |
428 | 1672 |
444 | 1673 return next_frame (frame, which_frames, which_devices); |
428 | 1674 } |
1675 | |
1676 DEFUN ("previous-frame", Fprevious_frame, 0, 3, 0, /* | |
1677 Return the next frame of the right type in the frame list after FRAME. | |
444 | 1678 WHICH-FRAMES controls which frames are eligible to be returned; all |
428 | 1679 others will be skipped. Note that if there is only one eligible |
1680 frame, then `previous-frame' called repeatedly will always return | |
1681 the same frame, and if there is no eligible frame, then FRAME is | |
1682 returned. | |
1683 | |
444 | 1684 See `next-frame' for an explanation of the WHICH-FRAMES and WHICH-DEVICES |
428 | 1685 arguments. |
1686 */ | |
444 | 1687 (frame, which_frames, which_devices)) |
428 | 1688 { |
793 | 1689 frame = wrap_frame (decode_frame (frame)); |
428 | 1690 |
444 | 1691 return previous_frame (frame, which_frames, which_devices); |
428 | 1692 } |
1693 | |
1694 /* Return any frame for which PREDICATE is non-zero, or return Qnil | |
1695 if there aren't any. */ | |
1696 | |
1697 Lisp_Object | |
1698 find_some_frame (int (*predicate) (Lisp_Object, void *), | |
1699 void *closure) | |
1700 { | |
1701 Lisp_Object framecons, devcons, concons; | |
1702 | |
1703 FRAME_LOOP_NO_BREAK (framecons, devcons, concons) | |
1704 { | |
1705 Lisp_Object frame = XCAR (framecons); | |
1706 | |
1707 if ((predicate) (frame, closure)) | |
1708 return frame; | |
1709 } | |
1710 | |
1711 return Qnil; | |
1712 } | |
1713 | |
1714 | |
1715 | |
1716 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ | |
1717 | |
1718 /* Return 1 if it is ok to delete frame F; | |
1719 0 if all frames aside from F are invisible. | |
1720 (Exception: if F is a stream frame, it's OK to delete if | |
1721 any other frames exist.) */ | |
1722 | |
442 | 1723 int |
1724 other_visible_frames (struct frame *f) | |
428 | 1725 { |
793 | 1726 Lisp_Object frame = wrap_frame (f); |
1727 | |
428 | 1728 if (FRAME_STREAM_P (f)) |
442 | 1729 return !EQ (frame, next_frame (frame, Qt, Qt)); |
1730 return !EQ (frame, next_frame (frame, Qvisible_iconic_nomini, Qt)); | |
428 | 1731 } |
1732 | |
1733 /* Delete frame F. | |
1734 | |
1735 If FORCE is non-zero, allow deletion of the only frame. | |
1736 | |
1737 If CALLED_FROM_DELETE_DEVICE is non-zero, then, if | |
1738 deleting the last frame on a device, just delete it, | |
1739 instead of calling `delete-device'. | |
1740 | |
1741 If FROM_IO_ERROR is non-zero, then the frame is gone due | |
1742 to an I/O error. This affects what happens if we exit | |
1743 (we do an emergency exit instead of `save-buffers-kill-emacs'.) | |
1744 */ | |
1745 | |
1746 void | |
1747 delete_frame_internal (struct frame *f, int force, | |
1748 int called_from_delete_device, | |
1749 int from_io_error) | |
1750 { | |
1751 /* This function can GC */ | |
1752 int minibuffer_selected; | |
1753 struct device *d; | |
1754 struct console *con; | |
1755 Lisp_Object frame; | |
1756 Lisp_Object device; | |
1757 Lisp_Object console; | |
1758 struct gcpro gcpro1; | |
1313 | 1759 int depth; |
428 | 1760 |
1761 /* OK to delete an already deleted frame. */ | |
853 | 1762 if (!FRAME_LIVE_P (f)) |
428 | 1763 return; |
1764 | |
793 | 1765 frame = wrap_frame (f); |
853 | 1766 |
1767 if (!force) | |
1768 check_allowed_operation (OPERATION_DELETE_OBJECT, frame, Qnil); | |
1769 | |
428 | 1770 GCPRO1 (frame); |
1771 | |
1772 device = FRAME_DEVICE (f); | |
1773 d = XDEVICE (device); | |
1774 console = DEVICE_CONSOLE (d); | |
1775 con = XCONSOLE (console); | |
1776 | |
545 | 1777 if (!called_from_delete_device |
1778 && !DEVICE_IMPL_FLAG (d, XDEVIMPF_FRAMELESS_OK)) | |
428 | 1779 { |
1780 /* If we're deleting the only non-minibuffer frame on the | |
1781 device, delete the device. */ | |
1782 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f)))) | |
1783 { | |
1784 delete_device_internal (d, force, 0, from_io_error); | |
1785 UNGCPRO; | |
1786 return; | |
1787 } | |
1788 } | |
1789 | |
1790 /* In FSF, delete-frame will not normally allow you to delete the | |
1791 last visible frame. This was too annoying, so we changed it to the | |
1792 only frame. However, this would let people shoot themselves by | |
1793 deleting all frames which were either visible or iconified and thus | |
1794 losing any way of communicating with the still running XEmacs process. | |
1795 So we put it back. */ | |
1796 if (!force && !allow_deletion_of_last_visible_frame && | |
442 | 1797 !other_visible_frames (f)) |
563 | 1798 invalid_operation ("Attempt to delete the sole visible or iconified frame", Qunbound); |
428 | 1799 |
1800 /* Does this frame have a minibuffer, and is it the surrogate | |
1801 minibuffer for any other frame? */ | |
1802 if (FRAME_HAS_MINIBUF_P (f)) | |
1803 { | |
1804 Lisp_Object frmcons, devcons, concons; | |
1805 | |
1806 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | |
1807 { | |
2552 | 1808 Lisp_Object this_frame = XCAR (frmcons); |
1809 | |
1810 if (! EQ (this_frame, frame) | |
428 | 1811 && EQ (frame, (WINDOW_FRAME |
1812 (XWINDOW | |
2552 | 1813 (FRAME_MINIBUF_WINDOW (XFRAME (this_frame))))))) |
428 | 1814 { |
1815 /* We've found another frame whose minibuffer is on | |
1816 this frame. */ | |
563 | 1817 gui_error |
428 | 1818 ("Attempt to delete a surrogate minibuffer frame", frame); |
1819 } | |
1820 } | |
1821 } | |
1822 | |
1823 /* Test for popup frames hanging around. */ | |
1824 /* Deletion of a parent frame with popups is deadly. */ | |
1825 { | |
1826 Lisp_Object frmcons, devcons, concons; | |
1827 | |
1828 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | |
1829 { | |
2552 | 1830 Lisp_Object this_frame = XCAR (frmcons); |
1831 | |
1832 | |
1833 if (! EQ (this_frame, frame)) | |
428 | 1834 { |
1835 struct device *devcons_d = XDEVICE (XCAR (devcons)); | |
1836 if (EQ (frame, DEVMETH_OR_GIVEN (devcons_d, get_frame_parent, | |
2552 | 1837 (XFRAME (this_frame)), |
428 | 1838 Qnil))) |
1839 /* We've found a popup frame whose parent is this frame. */ | |
563 | 1840 gui_error |
428 | 1841 ("Attempt to delete a frame with live popups", frame); |
1842 } | |
1843 } | |
1844 } | |
1845 | |
1846 /* Before here, we haven't made any dangerous changes (just checked for | |
1847 error conditions). Now run the delete-frame-hook. Remember that | |
1848 user code there could do any number of dangerous things, including | |
1849 signalling an error. */ | |
1850 | |
1851 va_run_hook_with_args (Qdelete_frame_hook, 1, frame); | |
1852 | |
1853 if (!FRAME_LIVE_P (f)) /* Make sure the delete-frame-hook didn't */ | |
1854 { /* go ahead and delete anything. */ | |
1855 UNGCPRO; | |
1856 return; | |
1857 } | |
1858 | |
1859 /* Call the delete-device-hook and delete-console-hook now if | |
1860 appropriate, before we do any dangerous things -- they too could | |
1861 signal an error. */ | |
1862 if (XINT (Flength (DEVICE_FRAME_LIST (d))) == 1) | |
1863 { | |
1864 va_run_hook_with_args (Qdelete_device_hook, 1, device); | |
1865 if (!FRAME_LIVE_P (f)) /* Make sure the delete-device-hook didn't */ | |
1866 { /* go ahead and delete anything. */ | |
1867 UNGCPRO; | |
1868 return; | |
1869 } | |
1870 | |
1871 if (XINT (Flength (CONSOLE_DEVICE_LIST (con))) == 1) | |
1872 { | |
1873 va_run_hook_with_args (Qdelete_console_hook, 1, console); | |
1874 if (!FRAME_LIVE_P (f)) /* Make sure the delete-console-hook didn't */ | |
1875 { /* go ahead and delete anything. */ | |
1876 UNGCPRO; | |
1877 return; | |
1878 } | |
1879 } | |
1880 } | |
1881 | |
1882 minibuffer_selected = EQ (minibuf_window, Fselected_window (Qnil)); | |
1883 | |
1884 /* If we were focused on this frame, then we're not any more. | |
1885 Assume that we lost the focus; that way, the call to | |
1886 Fselect_frame() below won't end up making us explicitly | |
1887 focus on another frame, which is generally undesirable in | |
1888 a point-to-type world. If our mouse ends up sitting over | |
1889 another frame, we will receive a FocusIn event and end up | |
1890 making that frame the selected frame. | |
1891 | |
1892 #### This may not be an ideal solution in a click-to-type | |
1893 world (in that case, we might want to explicitly choose | |
1894 another frame to have the focus, rather than relying on | |
1895 the WM, which might focus on a frame in a different app | |
1896 or focus on nothing at all). But there's no easy way | |
1897 to detect which focus model we're running on, and the | |
1898 alternative is more heinous. */ | |
1899 | |
1900 if (EQ (frame, DEVICE_FRAME_WITH_FOCUS_REAL (d))) | |
1901 DEVICE_FRAME_WITH_FOCUS_REAL (d) = Qnil; | |
1902 if (EQ (frame, DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d))) | |
1903 DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d) = Qnil; | |
1904 if (EQ (frame, DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d))) | |
1905 DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d) = Qnil; | |
1906 | |
1907 /* Don't allow the deleted frame to remain selected. | |
1908 Note that in the former scheme of things, this would | |
1909 have caused us to regain the focus. This no longer | |
1910 applies (see above); I think the new behavior is more | |
1911 logical. If someone disagrees, it can always be | |
1912 changed (or a new user variable can be introduced, ugh.) */ | |
1913 if (EQ (frame, DEVICE_SELECTED_FRAME (d))) | |
1914 { | |
1915 Lisp_Object next; | |
1916 | |
1917 /* If this is a popup frame, select its parent if possible. | |
1918 Otherwise, find another visible frame; if none, just take any frame. | |
4207 | 1919 First try the same device, then the same console. */ |
428 | 1920 |
1921 next = DEVMETH_OR_GIVEN (d, get_frame_parent, (f), Qnil); | |
1922 if (NILP (next) || EQ (next, frame) || ! FRAME_LIVE_P (XFRAME (next))) | |
442 | 1923 next = next_frame (frame, Qvisible, device); |
428 | 1924 if (NILP (next) || EQ (next, frame)) |
442 | 1925 next = next_frame (frame, Qvisible, console); |
1926 if (NILP (next) || EQ (next, frame)) | |
1927 next = next_frame (frame, Qvisible, Qt); | |
428 | 1928 if (NILP (next) || EQ (next, frame)) |
442 | 1929 next = next_frame (frame, Qt, device); |
428 | 1930 if (NILP (next) || EQ (next, frame)) |
442 | 1931 next = next_frame (frame, Qt, console); |
428 | 1932 if (NILP (next) || EQ (next, frame)) |
442 | 1933 next = next_frame (frame, Qt, Qt); |
428 | 1934 |
1935 /* if we haven't found another frame at this point | |
1936 then there aren't any. */ | |
1937 if (NILP (next) || EQ (next, frame)) | |
1938 ; | |
1939 else | |
1940 { | |
1941 int did_select = 0; | |
1942 /* if this is the global selected frame, select another one. */ | |
1943 if (EQ (frame, Fselected_frame (Qnil))) | |
1944 { | |
1945 Fselect_frame (next); | |
1946 did_select = 1; | |
1947 } | |
1948 /* | |
1949 * If the new frame we just selected is on a different | |
1950 * device then we still need to change DEVICE_SELECTED_FRAME(d) | |
1951 * to a live frame, if there are any left on this device. | |
1952 */ | |
1953 if (!EQ (device, FRAME_DEVICE(XFRAME(next)))) | |
1954 { | |
442 | 1955 Lisp_Object next_f = next_frame (frame, Qt, device); |
428 | 1956 if (NILP (next_f) || EQ (next_f, frame)) |
440 | 1957 set_device_selected_frame (d, Qnil); |
428 | 1958 else |
1959 set_device_selected_frame (d, next_f); | |
1960 } | |
1961 else if (! did_select) | |
1962 set_device_selected_frame (d, next); | |
1963 | |
1964 } | |
1965 } | |
1966 | |
1967 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
1968 if (EQ (f->minibuffer_window, minibuf_window)) | |
1969 { | |
1970 struct frame *sel_frame = selected_frame (); | |
1971 Fset_window_buffer (sel_frame->minibuffer_window, | |
440 | 1972 XWINDOW (minibuf_window)->buffer, Qt); |
428 | 1973 minibuf_window = sel_frame->minibuffer_window; |
1974 | |
1975 /* If the dying minibuffer window was selected, | |
1976 select the new one. */ | |
1977 if (minibuffer_selected) | |
1978 Fselect_window (minibuf_window, Qnil); | |
1979 } | |
1980 | |
1981 /* After this point, no errors must be allowed to occur. */ | |
1982 | |
1313 | 1983 /* Checking for QUIT can run all sorts of weird code and may be deadly |
1984 so don't let it happen. */ | |
1985 depth = begin_dont_check_for_quit (); | |
1986 | |
428 | 1987 #ifdef HAVE_MENUBARS |
1988 free_frame_menubars (f); | |
1989 #endif | |
1990 #ifdef HAVE_SCROLLBARS | |
1991 free_frame_scrollbars (f); | |
1992 #endif | |
1993 #ifdef HAVE_TOOLBARS | |
1994 free_frame_toolbars (f); | |
1995 #endif | |
1996 free_frame_gutters (f); | |
442 | 1997 /* Unfortunately deleting the frame will also delete the parent of |
1998 all of the subwindow instances current on the frame. I think this | |
1999 can lead to bad things when trying to finalize the | |
2000 instances. Thus we loop over all instance caches calling the | |
2001 finalize method for each instance. */ | |
2002 free_frame_subwindow_instances (f); | |
428 | 2003 |
2004 /* This must be done before the window and window_mirror structures | |
2005 are freed. The scrollbar information is attached to them. */ | |
2006 MAYBE_FRAMEMETH (f, delete_frame, (f)); | |
2007 | |
2008 /* Mark all the windows that used to be on FRAME as deleted, and then | |
2009 remove the reference to them. */ | |
2010 delete_all_subwindows (XWINDOW (f->root_window)); | |
2011 f->root_window = Qnil; | |
2012 | |
2013 /* clear out the cached glyph information */ | |
442 | 2014 f->subwindow_instance_cache = Qnil; |
428 | 2015 |
2016 /* Remove the frame now from the list. This way, any events generated | |
2017 on this frame by the maneuvers below will disperse themselves. */ | |
2018 | |
2019 /* This used to be Fdelq(), but that will cause a seg fault if the | |
2020 QUIT checker happens to get invoked, because the frame list is in | |
2021 an inconsistent state. */ | |
2022 d->frame_list = delq_no_quit (frame, d->frame_list); | |
2023 RESET_CHANGED_SET_FLAGS; | |
2024 | |
2025 f->visible = 0; | |
2026 | |
617 | 2027 free_window_mirror (XWINDOW_MIRROR (f->root_mirror)); |
853 | 2028 |
428 | 2029 /* free_line_insertion_deletion_costs (f); */ |
2030 | |
2031 /* If we've deleted the last non-minibuf frame, then try to find | |
2032 another one. */ | |
2033 if (EQ (frame, CONSOLE_LAST_NONMINIBUF_FRAME (con))) | |
2034 { | |
2035 Lisp_Object frmcons, devcons; | |
2036 | |
2037 set_console_last_nonminibuf_frame (con, Qnil); | |
2038 | |
2039 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
2040 { | |
2041 Lisp_Object ecran = XCAR (frmcons); | |
2042 if (!FRAME_MINIBUF_ONLY_P (XFRAME (ecran))) | |
2043 { | |
2044 set_console_last_nonminibuf_frame (con, ecran); | |
2045 goto double_break_1; | |
2046 } | |
2047 } | |
2048 } | |
2049 double_break_1: | |
2050 | |
2051 #if 0 | |
2052 /* The following test is degenerate FALSE */ | |
2053 if (called_from_delete_device < 0) | |
2054 /* then we're being called from delete-console, and we shouldn't | |
2055 try to find another default-minibuffer frame for the console. | |
2056 */ | |
2057 con->default_minibuffer_frame = Qnil; | |
2058 #endif | |
2059 | |
2060 /* If we've deleted this console's default_minibuffer_frame, try to | |
2061 find another one. Prefer minibuffer-only frames, but also notice | |
2062 frames with other windows. */ | |
2063 if (EQ (frame, con->default_minibuffer_frame)) | |
2064 { | |
2065 Lisp_Object frmcons, devcons; | |
2066 /* The last frame we saw with a minibuffer, minibuffer-only or not. */ | |
2067 Lisp_Object frame_with_minibuf; | |
2068 /* Some frame we found on the same console, or nil if there are none. */ | |
2069 Lisp_Object frame_on_same_console; | |
2070 | |
2071 frame_on_same_console = Qnil; | |
2072 frame_with_minibuf = Qnil; | |
2073 | |
2074 set_console_last_nonminibuf_frame (con, Qnil); | |
2075 | |
2076 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
2077 { | |
2552 | 2078 Lisp_Object this_frame; |
428 | 2079 struct frame *f1; |
2080 | |
2552 | 2081 this_frame = XCAR (frmcons); |
2082 f1 = XFRAME (this_frame); | |
428 | 2083 |
2084 /* Consider only frames on the same console | |
2085 and only those with minibuffers. */ | |
2086 if (FRAME_HAS_MINIBUF_P (f1)) | |
2087 { | |
2552 | 2088 frame_with_minibuf = this_frame; |
428 | 2089 if (FRAME_MINIBUF_ONLY_P (f1)) |
2090 goto double_break_2; | |
2091 } | |
2092 | |
2552 | 2093 frame_on_same_console = this_frame; |
428 | 2094 } |
2095 double_break_2: | |
2096 | |
2097 if (!NILP (frame_on_same_console)) | |
2098 { | |
2099 /* We know that there must be some frame with a minibuffer out | |
2100 there. If this were not true, all of the frames present | |
2101 would have to be minibuffer-less, which implies that at some | |
2102 point their minibuffer frames must have been deleted, but | |
2103 that is prohibited at the top; you can't delete surrogate | |
2104 minibuffer frames. */ | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
2105 assert (!NILP (frame_with_minibuf)); |
428 | 2106 |
2107 con->default_minibuffer_frame = frame_with_minibuf; | |
2108 } | |
2109 else | |
2110 /* No frames left on this console--say no minibuffer either. */ | |
2111 con->default_minibuffer_frame = Qnil; | |
2112 } | |
2113 | |
617 | 2114 /* Nobody should be accessing anything in this object any more, and |
2115 making all Lisp_Objects Qnil allows for better GC'ing in case a | |
2116 pointer to the dead frame continues to hang around. Zero all | |
2117 other structs in case someone tries to access something through | |
2118 them. */ | |
2119 | |
2120 nuke_all_frame_slots (f); | |
428 | 2121 f->framemeths = dead_console_methods; |
1204 | 2122 f->frametype = dead_console; |
617 | 2123 |
853 | 2124 note_object_deleted (frame); |
2125 | |
1313 | 2126 unbind_to (depth); |
2127 | |
428 | 2128 UNGCPRO; |
2129 } | |
2130 | |
2131 void | |
2132 io_error_delete_frame (Lisp_Object frame) | |
2133 { | |
2134 delete_frame_internal (XFRAME (frame), 1, 0, 1); | |
2135 } | |
2136 | |
2137 DEFUN ("delete-frame", Fdelete_frame, 0, 2, "", /* | |
2138 Delete FRAME, permanently eliminating it from use. | |
2139 If omitted, FRAME defaults to the selected frame. | |
2140 A frame may not be deleted if its minibuffer is used by other frames. | |
2141 Normally, you cannot delete the last non-minibuffer-only frame (you must | |
2142 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional | |
2143 second argument FORCE is non-nil, you can delete the last frame. (This | |
2144 will automatically call `save-buffers-kill-emacs'.) | |
2145 */ | |
2146 (frame, force)) | |
2147 { | |
2148 /* This function can GC */ | |
2149 struct frame *f; | |
2150 | |
2151 if (NILP (frame)) | |
2152 { | |
2153 f = selected_frame (); | |
793 | 2154 frame = wrap_frame (f); |
428 | 2155 } |
2156 else | |
2157 { | |
2158 CHECK_FRAME (frame); | |
2159 f = XFRAME (frame); | |
2160 } | |
2161 | |
2162 delete_frame_internal (f, !NILP (force), 0, 0); | |
2163 return Qnil; | |
2164 } | |
2165 | |
2166 | |
2167 /* Return mouse position in character cell units. */ | |
2168 | |
2169 static int | |
2170 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, | |
2171 int *x, int *y) | |
2172 { | |
2173 switch (DEVMETH_OR_GIVEN (d, get_mouse_position, (d, frame, x, y), -1)) | |
2174 { | |
2175 case 1: | |
2176 return 1; | |
2177 | |
2178 case 0: | |
2179 *frame = Qnil; | |
2180 break; | |
2181 | |
2182 case -1: | |
2183 *frame = DEVICE_SELECTED_FRAME (d); | |
2184 break; | |
2185 | |
2186 default: | |
2500 | 2187 ABORT (); /* method is incorrectly written */ |
428 | 2188 } |
2189 | |
2190 return 0; | |
2191 } | |
2192 | |
2193 DEFUN ("mouse-pixel-position", Fmouse_pixel_position, 0, 1, 0, /* | |
2194 Return a list (WINDOW X . Y) giving the current mouse window and position. | |
442 | 2195 The position is given in pixel units, where (0, 0) is the upper-left corner |
2196 of the window. | |
428 | 2197 |
2198 When the cursor is not over a window, the return value is a list (nil nil). | |
2199 | |
2200 DEVICE specifies the device on which to read the mouse position, and | |
2201 defaults to the selected device. If the device is a mouseless terminal | |
442 | 2202 or XEmacs hasn't been programmed to read its mouse position, it returns |
428 | 2203 the device's selected window for WINDOW and nil for X and Y. |
2204 */ | |
2205 (device)) | |
2206 { | |
2207 struct device *d = decode_device (device); | |
2208 Lisp_Object frame; | |
2209 Lisp_Object window = Qnil; | |
2210 Lisp_Object x = Qnil; | |
2211 Lisp_Object y = Qnil; | |
2212 int intx, inty; | |
2213 | |
2214 if (mouse_pixel_position_1 (d, &frame, &intx, &inty) > 0) | |
2215 { | |
2216 struct window *w = | |
2217 find_window_by_pixel_pos (intx, inty, XFRAME (frame)->root_window); | |
2218 if (w) | |
2219 { | |
793 | 2220 window = wrap_window (w); |
428 | 2221 |
2222 /* Adjust the position to be relative to the window. */ | |
2223 intx -= w->pixel_left; | |
2224 inty -= w->pixel_top; | |
793 | 2225 x = make_int (intx); |
2226 y = make_int (inty); | |
428 | 2227 } |
2228 } | |
2229 else if (FRAMEP (frame)) | |
2230 window = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
2231 | |
2232 return Fcons (window, Fcons (x, y)); | |
2233 } | |
2234 | |
2235 DEFUN ("mouse-position", Fmouse_position, 0, 1, 0, /* | |
2236 Return a list (WINDOW X . Y) giving the current mouse window and position. | |
2237 The position is of a character under cursor, where (0, 0) is the upper-left | |
2238 corner of the window. | |
2239 | |
2240 When the cursor is not over a character, or not over a window, the return | |
2241 value is a list (nil nil). | |
2242 | |
2243 DEVICE specifies the device on which to read the mouse position, and | |
2244 defaults to the selected device. If the device is a mouseless terminal | |
2245 or Emacs hasn't been programmed to read its mouse position, it returns | |
2246 the device's selected window for WINDOW and nil for X and Y. | |
2247 */ | |
2248 (device)) | |
2249 { | |
2250 struct device *d = decode_device (device); | |
2251 struct window *w; | |
2252 Lisp_Object frame, window = Qnil, lisp_x = Qnil, lisp_y = Qnil; | |
2253 int x, y, obj_x, obj_y; | |
665 | 2254 Charbpos charbpos, closest; |
428 | 2255 Charcount modeline_closest; |
2256 Lisp_Object obj1, obj2; | |
2257 | |
2258 if (mouse_pixel_position_1 (d, &frame, &x, &y) > 0) | |
2259 { | |
2260 int res = pixel_to_glyph_translation (XFRAME (frame), x, y, &x, &y, | |
665 | 2261 &obj_x, &obj_y, &w, &charbpos, |
428 | 2262 &closest, &modeline_closest, |
2263 &obj1, &obj2); | |
2264 if (res == OVER_TEXT) | |
2265 { | |
2266 lisp_x = make_int (x); | |
2267 lisp_y = make_int (y); | |
793 | 2268 window = wrap_window (w); |
428 | 2269 } |
2270 } | |
2271 else if (FRAMEP (frame)) | |
2272 window = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
2273 | |
2274 return Fcons (window, Fcons (lisp_x, lisp_y)); | |
2275 } | |
2276 | |
2277 DEFUN ("mouse-position-as-motion-event", Fmouse_position_as_motion_event, 0, 1, 0, /* | |
2278 Return the current mouse position as a motion event. | |
2279 This allows you to call the standard event functions such as | |
2280 `event-over-toolbar-p' to determine where the mouse is. | |
2281 | |
2282 DEVICE specifies the device on which to read the mouse position, and | |
2283 defaults to the selected device. If the mouse position can't be determined | |
2284 \(e.g. DEVICE is a TTY device), nil is returned instead of an event. | |
2285 */ | |
2286 (device)) | |
2287 { | |
2288 struct device *d = decode_device (device); | |
2289 Lisp_Object frame; | |
2290 int intx, inty; | |
2291 | |
2292 if (mouse_pixel_position_1 (d, &frame, &intx, &inty)) | |
2293 { | |
2294 Lisp_Object event = Fmake_event (Qnil, Qnil); | |
934 | 2295 XSET_EVENT_TYPE (event, pointer_motion_event); |
2296 XSET_EVENT_CHANNEL (event, frame); | |
1204 | 2297 XSET_EVENT_MOTION_X (event, intx); |
2298 XSET_EVENT_MOTION_Y (event, inty); | |
428 | 2299 return event; |
2300 } | |
2301 else | |
2302 return Qnil; | |
2303 } | |
2304 | |
2305 DEFUN ("set-mouse-position", Fset_mouse_position, 3, 3, 0, /* | |
2306 Move the mouse pointer to the center of character cell (X,Y) in WINDOW. | |
2307 Note, this is a no-op for an X frame that is not visible. | |
2308 If you have just created a frame, you must wait for it to become visible | |
2309 before calling this function on it, like this. | |
2310 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
2311 Note also: Warping the mouse is contrary to the ICCCM, so be very sure | |
2312 that the behavior won't end up being obnoxious! | |
2313 */ | |
2314 (window, x, y)) | |
2315 { | |
2316 struct window *w; | |
2317 int pix_x, pix_y; | |
2318 | |
2319 CHECK_LIVE_WINDOW (window); | |
2320 CHECK_INT (x); | |
2321 CHECK_INT (y); | |
2322 | |
2323 /* Warping the mouse will cause EnterNotify and Focus events under X. */ | |
2324 w = XWINDOW (window); | |
2325 glyph_to_pixel_translation (w, XINT (x), XINT (y), &pix_x, &pix_y); | |
2326 | |
2327 MAYBE_FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, pix_x, pix_y)); | |
2328 | |
2329 return Qnil; | |
2330 } | |
2331 | |
2332 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, 3, 3, 0, /* | |
2333 Move the mouse pointer to pixel position (X,Y) in WINDOW. | |
2334 Note, this is a no-op for an X frame that is not visible. | |
2335 If you have just created a frame, you must wait for it to become visible | |
2336 before calling this function on it, like this. | |
2337 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
2338 */ | |
2339 (window, x, y)) | |
2340 { | |
2341 struct window *w; | |
2342 | |
2343 CHECK_LIVE_WINDOW (window); | |
2344 CHECK_INT (x); | |
2345 CHECK_INT (y); | |
2346 | |
2347 /* Warping the mouse will cause EnterNotify and Focus events under X. */ | |
2348 w = XWINDOW (window); | |
2349 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); | |
2350 | |
2351 return Qnil; | |
2352 } | |
2353 | |
2354 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* | |
2355 Make the frame FRAME visible (assuming it is an X-window). | |
2356 If omitted, FRAME defaults to the currently selected frame. | |
2357 Also raises the frame so that nothing obscures it. | |
2358 */ | |
2359 (frame)) | |
2360 { | |
2361 struct frame *f = decode_frame (frame); | |
2362 | |
2363 MAYBE_FRAMEMETH (f, make_frame_visible, (f)); | |
2364 return frame; | |
2365 } | |
2366 | |
2367 DEFUN ("make-frame-invisible", Fmake_frame_invisible, 0, 2, 0, /* | |
2368 Unconditionally removes frame from the display (assuming it is an X-window). | |
2369 If omitted, FRAME defaults to the currently selected frame. | |
2370 If what you want to do is iconify the frame (if the window manager uses | |
2371 icons) then you should call `iconify-frame' instead. | |
2372 Normally you may not make FRAME invisible if all other frames are invisible | |
2373 and uniconified, but if the second optional argument FORCE is non-nil, | |
2374 you may do so. | |
2375 */ | |
2376 (frame, force)) | |
2377 { | |
2378 struct frame *f, *sel_frame; | |
2379 struct device *d; | |
2380 | |
2381 f = decode_frame (frame); | |
2382 d = XDEVICE (FRAME_DEVICE (f)); | |
2383 sel_frame = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
2384 | |
2385 if (NILP (force) && !other_visible_frames (f)) | |
563 | 2386 invalid_operation ("Attempt to make invisible the sole visible or iconified frame", Qunbound); |
428 | 2387 |
2388 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
2389 if (EQ (f->minibuffer_window, minibuf_window)) | |
2390 { | |
2391 Fset_window_buffer (sel_frame->minibuffer_window, | |
440 | 2392 XWINDOW (minibuf_window)->buffer, Qt); |
428 | 2393 minibuf_window = sel_frame->minibuffer_window; |
2394 } | |
2395 | |
2396 MAYBE_FRAMEMETH (f, make_frame_invisible, (f)); | |
2397 | |
2398 return Qnil; | |
2399 } | |
2400 | |
2401 DEFUN ("iconify-frame", Ficonify_frame, 0, 1, "", /* | |
2402 Make the frame FRAME into an icon, if the window manager supports icons. | |
2403 If omitted, FRAME defaults to the currently selected frame. | |
2404 */ | |
2405 (frame)) | |
2406 { | |
2407 struct frame *f, *sel_frame; | |
2408 struct device *d; | |
2409 | |
2410 f = decode_frame (frame); | |
2411 d = XDEVICE (FRAME_DEVICE (f)); | |
2412 sel_frame = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
2413 | |
2414 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
2415 if (EQ (f->minibuffer_window, minibuf_window)) | |
2416 { | |
2417 Fset_window_buffer (sel_frame->minibuffer_window, | |
440 | 2418 XWINDOW (minibuf_window)->buffer, Qt); |
428 | 2419 minibuf_window = sel_frame->minibuffer_window; |
2420 } | |
2421 | |
2422 MAYBE_FRAMEMETH (f, iconify_frame, (f)); | |
2423 | |
2424 return Qnil; | |
2425 } | |
2426 | |
2427 DEFUN ("deiconify-frame", Fdeiconify_frame, 0, 1, 0, /* | |
2428 Open (de-iconify) the iconified frame FRAME. | |
2429 Under X, this is currently the same as `make-frame-visible'. | |
2430 If omitted, FRAME defaults to the currently selected frame. | |
2431 Also raises the frame so that nothing obscures it. | |
2432 */ | |
2433 (frame)) | |
2434 { | |
2435 return Fmake_frame_visible (frame); | |
2436 } | |
2437 | |
3025 | 2438 /* FSF returns `icon' for iconized frames. What a crock! */ |
428 | 2439 |
2440 DEFUN ("frame-visible-p", Fframe_visible_p, 0, 1, 0, /* | |
2441 Return non NIL if FRAME is now "visible" (actually in use for display). | |
2442 A frame that is not visible is not updated, and, if it works through a | |
2443 window system, may not show at all. | |
2444 N.B. Under X "visible" means Mapped. It the window is mapped but not | |
3025 | 2445 actually visible on screen then `frame-visible-p' returns `hidden'. |
428 | 2446 */ |
2447 (frame)) | |
2448 { | |
2449 struct frame *f = decode_frame (frame); | |
2450 int visible = FRAMEMETH_OR_GIVEN (f, frame_visible_p, (f), f->visible); | |
2451 return visible ? ( visible > 0 ? Qt : Qhidden ) : Qnil; | |
2452 } | |
2453 | |
2454 DEFUN ("frame-totally-visible-p", Fframe_totally_visible_p, 0, 1, 0, /* | |
2455 Return t if frame is not obscured by any other window system windows. | |
2456 Always returns t for tty frames. | |
2457 */ | |
2458 (frame)) | |
2459 { | |
2460 struct frame *f = decode_frame (frame); | |
2461 return (FRAMEMETH_OR_GIVEN (f, frame_totally_visible_p, (f), f->visible) | |
2462 ? Qt : Qnil); | |
2463 } | |
2464 | |
2465 DEFUN ("frame-iconified-p", Fframe_iconified_p, 0, 1, 0, /* | |
2466 Return t if FRAME is iconified. | |
2467 Not all window managers use icons; some merely unmap the window, so this | |
2468 function is not the inverse of `frame-visible-p'. It is possible for a | |
2469 frame to not be visible and not be iconified either. However, if the | |
2470 frame is iconified, it will not be visible. | |
2471 */ | |
2472 (frame)) | |
2473 { | |
2474 struct frame *f = decode_frame (frame); | |
2475 if (f->visible) | |
2476 return Qnil; | |
2477 f->iconified = FRAMEMETH_OR_GIVEN (f, frame_iconified_p, (f), 0); | |
2478 return f->iconified ? Qt : Qnil; | |
2479 } | |
2480 | |
2481 DEFUN ("visible-frame-list", Fvisible_frame_list, 0, 1, 0, /* | |
2482 Return a list of all frames now "visible" (being updated). | |
2483 If DEVICE is specified only frames on that device will be returned. | |
460 | 2484 Note that under virtual window managers not all these frames are |
2485 necessarily really updated. | |
428 | 2486 */ |
2487 (device)) | |
2488 { | |
2489 Lisp_Object devcons, concons; | |
2490 struct frame *f; | |
2491 Lisp_Object value; | |
2492 | |
2493 value = Qnil; | |
2494 | |
2495 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
2496 { | |
2497 assert (DEVICEP (XCAR (devcons))); | |
2498 | |
2499 if (NILP (device) || EQ (device, XCAR (devcons))) | |
2500 { | |
2501 Lisp_Object frmcons; | |
2502 | |
2503 DEVICE_FRAME_LOOP (frmcons, XDEVICE (XCAR (devcons))) | |
2504 { | |
2505 Lisp_Object frame = XCAR (frmcons); | |
2506 f = XFRAME (frame); | |
2507 if (FRAME_VISIBLE_P(f)) | |
2508 value = Fcons (frame, value); | |
2509 } | |
2510 } | |
2511 } | |
2512 | |
2513 return value; | |
2514 } | |
2515 | |
2516 | |
2517 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* | |
2518 Bring FRAME to the front, so it occludes any frames it overlaps. | |
2519 If omitted, FRAME defaults to the currently selected frame. | |
2520 If FRAME is invisible, make it visible. | |
2521 If Emacs is displaying on an ordinary terminal or some other device which | |
2522 doesn't support multiple overlapping frames, this function does nothing. | |
2523 */ | |
2524 (frame)) | |
2525 { | |
2526 struct frame *f = decode_frame (frame); | |
2527 | |
2528 /* Do like the documentation says. */ | |
2529 Fmake_frame_visible (frame); | |
2530 MAYBE_FRAMEMETH (f, raise_frame, (f)); | |
2531 return Qnil; | |
2532 } | |
2533 | |
2534 DEFUN ("lower-frame", Flower_frame, 0, 1, "", /* | |
2535 Send FRAME to the back, so it is occluded by any frames that overlap it. | |
2536 If omitted, FRAME defaults to the currently selected frame. | |
2537 If Emacs is displaying on an ordinary terminal or some other device which | |
2538 doesn't support multiple overlapping frames, this function does nothing. | |
2539 */ | |
2540 (frame)) | |
2541 { | |
2542 struct frame *f = decode_frame (frame); | |
2543 | |
2544 MAYBE_FRAMEMETH (f, lower_frame, (f)); | |
2545 return Qnil; | |
2546 } | |
2547 | |
442 | 2548 |
2549 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | |
2550 Disable frame FRAME, so that it cannot have the focus or receive user input. | |
2551 This is normally used during modal dialog boxes. | |
2552 WARNING: Be very careful not to wedge XEmacs! | |
2553 Use an `unwind-protect' that re-enables the frame to avoid this. | |
2554 */ | |
2555 (frame)) | |
2556 { | |
2557 struct frame *f = decode_frame (frame); | |
2558 | |
2559 f->disabled = 1; | |
2560 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
2561 return Qnil; | |
2562 } | |
2563 | |
2564 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
2565 Enable frame FRAME, so that it can have the focus and receive user input. | |
2566 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
2567 */ | |
2568 (frame)) | |
2569 { | |
2570 struct frame *f = decode_frame (frame); | |
2571 f->disabled = 0; | |
2572 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
2573 return Qnil; | |
2574 } | |
2575 | |
428 | 2576 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', |
2577 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
442 | 2578 |
2579 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* | |
2580 Return current page number for the print job FRAME. | |
2581 */ | |
2582 (frame)) | |
2583 { | |
2584 CHECK_PRINTER_FRAME (frame); | |
2585 return make_int (FRAME_PAGENUMBER (XFRAME (frame))); | |
2586 } | |
2587 | |
2588 DEFUN ("print-job-eject-page", Fprint_job_eject_page, 1, 1, 0, /* | |
2589 Eject page in the print job FRAME. | |
2590 */ | |
2591 (frame)) | |
2592 { | |
2593 struct frame *f; | |
2594 | |
2595 CHECK_PRINTER_FRAME (frame); | |
2596 f = XFRAME (frame); | |
2597 FRAMEMETH (f, eject_page, (f)); | |
2598 FRAME_SET_PAGENUMBER (f, 1 + FRAME_PAGENUMBER (f)); | |
2599 f->clear = 1; | |
2600 | |
2601 return Qnil; | |
2602 } | |
428 | 2603 |
2604 | |
2605 /***************************************************************************/ | |
2606 /* frame properties */ | |
2607 /***************************************************************************/ | |
2608 | |
2609 static void | |
2610 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) | |
2611 { | |
1318 | 2612 /* This can call Lisp. */ |
793 | 2613 Lisp_Object frame = wrap_frame (f); |
2614 | |
428 | 2615 if (WINDOWP (val)) |
2616 { | |
2617 if (! MINI_WINDOW_P (XWINDOW (val))) | |
563 | 2618 gui_error |
428 | 2619 ("Surrogate minibuffer windows must be minibuffer windows", |
2620 val); | |
2621 | |
2622 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) | |
563 | 2623 gui_error |
428 | 2624 ("Can't change the surrogate minibuffer of a frame with its own minibuffer", frame); |
2625 | |
2626 /* Install the chosen minibuffer window, with proper buffer. */ | |
2627 f->minibuffer_window = val; | |
2628 } | |
2629 else if (EQ (val, Qt)) | |
2630 { | |
2631 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) | |
563 | 2632 gui_error |
428 | 2633 ("Frame already has its own minibuffer", frame); |
2634 else | |
2635 { | |
2636 setup_normal_frame (f); | |
2637 f->mirror_dirty = 1; | |
2638 | |
2639 update_frame_window_mirror (f); | |
2640 internal_set_frame_size (f, f->width, f->height, 1); | |
2641 } | |
2642 } | |
2643 } | |
2644 | |
2645 #if 0 | |
2646 | |
2647 /* possible code if you want to have symbols such as `default-background' | |
2648 map to setting the background of `default', etc. */ | |
2649 | |
2650 static int | |
2651 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out, | |
2652 Lisp_Object *face_prop_out) | |
2653 { | |
2654 Lisp_Object list = Vbuilt_in_face_specifiers; | |
793 | 2655 Lisp_Object s; |
428 | 2656 |
2657 if (!SYMBOLP (sym)) | |
2658 return 0; | |
2659 | |
2660 s = symbol_name (XSYMBOL (sym)); | |
2661 | |
2662 while (!NILP (list)) | |
2663 { | |
2664 Lisp_Object prop = Fcar (list); | |
793 | 2665 Lisp_Object prop_name; |
428 | 2666 |
2667 if (!SYMBOLP (prop)) | |
2668 continue; | |
2669 prop_name = symbol_name (XSYMBOL (prop)); | |
793 | 2670 if (XSTRING_LENGTH (s) > XSTRING_LENGTH (prop_name) + 1 |
2671 && !memcmp (XSTRING_DATA (prop_name), | |
2672 XSTRING_DATA (s) + XSTRING_LENGTH (s) | |
2673 - XSTRING_LENGTH (prop_name), | |
2674 XSTRING_LENGTH (prop_name)) | |
2675 && XSTRING_DATA (s)[XSTRING_LENGTH (s) - XSTRING_LENGTH (prop_name) | |
428 | 2676 - 1] == '-') |
2677 { | |
2678 Lisp_Object face = | |
793 | 2679 Ffind_face (make_string (XSTRING_DATA (s), |
2680 XSTRING_LENGTH (s) | |
2681 - XSTRING_LENGTH (prop_name) | |
428 | 2682 - 1)); |
2683 if (!NILP (face)) | |
2684 { | |
2685 *face_out = face; | |
2686 *face_prop_out = prop; | |
2687 return 1; | |
2688 } | |
2689 } | |
2690 | |
2691 list = Fcdr (list); | |
2692 } | |
2693 | |
2694 return 0; | |
2695 } | |
2696 | |
2697 #endif /* 0 */ | |
2698 | |
2699 static Lisp_Object | |
2700 get_property_alias (Lisp_Object prop) | |
2701 { | |
2702 while (1) | |
2703 { | |
2704 Lisp_Object alias = Qnil; | |
2705 | |
2706 if (SYMBOLP (prop)) | |
2707 alias = Fget (prop, Qframe_property_alias, Qnil); | |
2708 if (NILP (alias)) | |
2709 break; | |
2710 prop = alias; | |
2711 QUIT; | |
2712 } | |
2713 | |
2714 return prop; | |
2715 } | |
2716 | |
2717 /* #### Using this to modify the internal border width has no effect | |
2718 because the change isn't propagated to the windows. Are there | |
2719 other properties which this claims to handle, but doesn't? | |
2720 | |
2721 But of course. This stuff needs more work, but it's a lot closer | |
2722 to sanity now than before with the horrible frame-params stuff. */ | |
2723 | |
2724 DEFUN ("set-frame-properties", Fset_frame_properties, 2, 2, 0, /* | |
2725 Change some properties of a frame. | |
2726 PLIST is a property list. | |
2727 You can also change frame properties individually using `set-frame-property', | |
2728 but it may be more efficient to change many properties at once. | |
2729 | |
2730 Frame properties can be retrieved using `frame-property' or `frame-properties'. | |
2731 | |
2732 The following symbols etc. have predefined meanings: | |
2733 | |
2734 name Name of the frame. Used with X resources. | |
2735 Unchangeable after creation. | |
2736 | |
2737 height Height of the frame, in lines. | |
2738 | |
2739 width Width of the frame, in characters. | |
2740 | |
2741 minibuffer Gives the minibuffer behavior for this frame. Either | |
2742 t (frame has its own minibuffer), `only' (frame is | |
442 | 2743 a minibuffer-only frame), `none' (frame has no minibuffer) |
2744 or a window (frame uses that window, which is on another | |
2745 frame, as the minibuffer). | |
428 | 2746 |
2747 unsplittable If non-nil, frame cannot be split by `display-buffer'. | |
2748 | |
2749 current-display-table, menubar-visible-p, left-margin-width, | |
2750 right-margin-width, minimum-line-ascent, minimum-line-descent, | |
2751 use-left-overflow, use-right-overflow, scrollbar-width, scrollbar-height, | |
2752 default-toolbar, top-toolbar, bottom-toolbar, left-toolbar, right-toolbar, | |
2753 default-toolbar-height, default-toolbar-width, top-toolbar-height, | |
2754 bottom-toolbar-height, left-toolbar-width, right-toolbar-width, | |
2755 default-toolbar-visible-p, top-toolbar-visible-p, bottom-toolbar-visible-p, | |
2756 left-toolbar-visible-p, right-toolbar-visible-p, toolbar-buttons-captioned-p, | |
2757 top-toolbar-border-width, bottom-toolbar-border-width, | |
2758 left-toolbar-border-width, right-toolbar-border-width, | |
442 | 2759 modeline-shadow-thickness, has-modeline-p, |
2760 default-gutter, top-gutter, bottom-gutter, left-gutter, right-gutter, | |
2761 default-gutter-height, default-gutter-width, top-gutter-height, | |
2762 bottom-gutter-height, left-gutter-width, right-gutter-width, | |
2763 default-gutter-visible-p, top-gutter-visible-p, bottom-gutter-visible-p, | |
2764 left-gutter-visible-p, right-gutter-visible-p, top-gutter-border-width, | |
2765 bottom-gutter-border-width, left-gutter-border-width, right-gutter-border-width, | |
428 | 2766 [Giving the name of any built-in specifier variable is |
2767 equivalent to calling `set-specifier' on the specifier, | |
2768 with a locale of FRAME. Giving the name to `frame-property' | |
2769 calls `specifier-instance' on the specifier.] | |
2770 | |
2771 text-pointer-glyph, nontext-pointer-glyph, modeline-pointer-glyph, | |
2772 selection-pointer-glyph, busy-pointer-glyph, toolbar-pointer-glyph, | |
2773 menubar-pointer-glyph, scrollbar-pointer-glyph, gc-pointer-glyph, | |
2774 octal-escape-glyph, control-arrow-glyph, invisible-text-glyph, | |
2775 hscroll-glyph, truncation-glyph, continuation-glyph | |
2776 [Giving the name of any glyph variable is equivalent to | |
2777 calling `set-glyph-image' on the glyph, with a locale | |
2778 of FRAME. Giving the name to `frame-property' calls | |
2779 `glyph-image-instance' on the glyph.] | |
2780 | |
2781 [default foreground], [default background], [default font], | |
2782 [modeline foreground], [modeline background], [modeline font], | |
2783 etc. | |
2784 [Giving a vector of a face and a property is equivalent | |
2785 to calling `set-face-property' on the face and property, | |
2786 with a locale of FRAME. Giving the vector to | |
2787 `frame-property' calls `face-property-instance' on the | |
2788 face and property.] | |
2789 | |
2790 Finally, if a frame property symbol has the property `frame-property-alias' | |
2791 on it, then the value will be used in place of that symbol when looking | |
2792 up and setting frame property values. This allows you to alias one | |
2793 frame property name to another. | |
2794 | |
2795 See the variables `default-x-frame-plist', `default-tty-frame-plist' | |
2796 and `default-mswindows-frame-plist' for a description of the properties | |
2797 recognized for particular types of frames. | |
2798 */ | |
2799 (frame, plist)) | |
2800 { | |
1318 | 2801 /* This can call Lisp. */ |
428 | 2802 struct frame *f = decode_frame (frame); |
2803 Lisp_Object tail; | |
2804 Lisp_Object *tailp; | |
2805 struct gcpro gcpro1, gcpro2; | |
2806 | |
793 | 2807 frame = wrap_frame (f); |
428 | 2808 GCPRO2 (frame, plist); |
2809 Fcheck_valid_plist (plist); | |
2810 plist = Fcopy_sequence (plist); | |
2811 Fcanonicalize_lax_plist (plist, Qnil); | |
2812 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) | |
2813 { | |
2814 Lisp_Object prop = Fcar (tail); | |
2815 Lisp_Object val = Fcar (Fcdr (tail)); | |
2816 | |
2817 prop = get_property_alias (prop); | |
2818 | |
2819 #if 0 | |
2820 /* mly wants this, but it's not reasonable to change the name of a | |
2821 frame after it has been created, because the old name was used | |
2822 for resource lookup. */ | |
2823 if (EQ (prop, Qname)) | |
4207 | 2824 { |
2825 CHECK_STRING (val); | |
2826 f->name = val; | |
2827 } | |
428 | 2828 #endif /* 0 */ |
2829 if (EQ (prop, Qminibuffer)) | |
2830 store_minibuf_frame_prop (f, val); | |
2831 if (EQ (prop, Qunsplittable)) | |
2832 f->no_split = !NILP (val); | |
2833 if (EQ (prop, Qbuffer_predicate)) | |
2834 f->buffer_predicate = val; | |
2835 if (SYMBOLP (prop) && EQ (Fbuilt_in_variable_type (prop), | |
2836 Qconst_specifier)) | |
2837 call3 (Qset_specifier, Fsymbol_value (prop), val, frame); | |
2838 if (SYMBOLP (prop) && !NILP (Fget (prop, Qconst_glyph_variable, Qnil))) | |
2839 call3 (Qset_glyph_image, Fsymbol_value (prop), val, frame); | |
2840 if (VECTORP (prop) && XVECTOR_LENGTH (prop) == 2) | |
2841 { | |
2842 Lisp_Object face_prop = XVECTOR_DATA (prop)[1]; | |
2843 CHECK_SYMBOL (face_prop); | |
2844 call4 (Qset_face_property, | |
2845 Fget_face (XVECTOR_DATA (prop)[0]), | |
2846 face_prop, val, frame); | |
2847 } | |
2848 } | |
2849 | |
2850 MAYBE_FRAMEMETH (f, set_frame_properties, (f, plist)); | |
2851 for (tailp = &plist; !NILP (*tailp);) | |
2852 { | |
2853 Lisp_Object *next_tailp; | |
2854 Lisp_Object next; | |
2855 Lisp_Object prop; | |
2856 | |
2857 next = Fcdr (*tailp); | |
2858 CHECK_CONS (next); | |
2859 next_tailp = &XCDR (next); | |
2860 prop = Fcar (*tailp); | |
2861 | |
2862 prop = get_property_alias (prop); | |
2863 | |
2864 if (EQ (prop, Qminibuffer) | |
2865 || EQ (prop, Qunsplittable) | |
2866 || EQ (prop, Qbuffer_predicate) | |
2867 || EQ (prop, Qheight) | |
2868 || EQ (prop, Qwidth) | |
2869 || (SYMBOLP (prop) && EQ (Fbuilt_in_variable_type (prop), | |
2870 Qconst_specifier)) | |
2871 || (SYMBOLP (prop) && !NILP (Fget (prop, Qconst_glyph_variable, | |
2872 Qnil))) | |
2873 || (VECTORP (prop) && XVECTOR_LENGTH (prop) == 2) | |
2874 || FRAMEMETH_OR_GIVEN (f, internal_frame_property_p, (f, prop), 0)) | |
2875 *tailp = *next_tailp; | |
2876 tailp = next_tailp; | |
2877 } | |
2878 | |
2879 f->plist = nconc2 (plist, f->plist); | |
2880 Fcanonicalize_lax_plist (f->plist, Qnil); | |
2881 UNGCPRO; | |
2882 return Qnil; | |
2883 } | |
2884 | |
2885 DEFUN ("frame-property", Fframe_property, 2, 3, 0, /* | |
2886 Return FRAME's value for property PROPERTY. | |
444 | 2887 Return DEFAULT if there is no such property. |
428 | 2888 See `set-frame-properties' for the built-in property names. |
2889 */ | |
2890 (frame, property, default_)) | |
2891 { | |
2892 struct frame *f = decode_frame (frame); | |
2893 Lisp_Object value; | |
2894 | |
793 | 2895 frame = wrap_frame (f); |
428 | 2896 |
2897 property = get_property_alias (property); | |
2898 | |
2899 if (EQ (Qname, property)) return f->name; | |
2900 | |
2901 if (EQ (Qheight, property) || EQ (Qwidth, property)) | |
2902 { | |
5043 | 2903 int width, height; |
2904 get_frame_char_size (f, &width, &height); | |
2905 return make_int (EQ (Qheight, property) ? height : width); | |
428 | 2906 } |
2907 | |
2908 /* NOTE: FSF returns Qnil instead of Qt for FRAME_HAS_MINIBUF_P. | |
2909 This is over-the-top bogosity, because it's inconsistent with | |
2910 the semantics of `minibuffer' when passed to `make-frame'. | |
2911 Returning Qt makes things consistent. */ | |
2912 if (EQ (Qminibuffer, property)) | |
2913 return (FRAME_MINIBUF_ONLY_P (f) ? Qonly : | |
2914 FRAME_HAS_MINIBUF_P (f) ? Qt : | |
2915 FRAME_MINIBUF_WINDOW (f)); | |
2916 if (EQ (Qunsplittable, property)) | |
2917 return FRAME_NO_SPLIT_P (f) ? Qt : Qnil; | |
2918 if (EQ (Qbuffer_predicate, property)) | |
2919 return f->buffer_predicate; | |
2920 | |
2921 if (SYMBOLP (property)) | |
2922 { | |
2923 if (EQ (Fbuilt_in_variable_type (property), Qconst_specifier)) | |
2924 return Fspecifier_instance (Fsymbol_value (property), | |
2925 frame, default_, Qnil); | |
2926 if (!NILP (Fget (property, Qconst_glyph_variable, Qnil))) | |
2927 { | |
2928 Lisp_Object glyph = Fsymbol_value (property); | |
2929 CHECK_GLYPH (glyph); | |
2930 return Fspecifier_instance (XGLYPH_IMAGE (glyph), | |
2931 frame, default_, Qnil); | |
2932 } | |
2933 } | |
2934 | |
2935 if (VECTORP (property) && XVECTOR_LENGTH (property) == 2) | |
2936 { | |
2937 Lisp_Object face_prop = XVECTOR_DATA (property)[1]; | |
2938 CHECK_SYMBOL (face_prop); | |
2939 return call3 (Qface_property_instance, | |
2940 Fget_face (XVECTOR_DATA (property)[0]), | |
2941 face_prop, frame); | |
2942 } | |
2943 | |
2944 if (HAS_FRAMEMETH_P (f, frame_property)) | |
2945 if (!UNBOUNDP (value = FRAMEMETH (f, frame_property, (f, property)))) | |
2946 return value; | |
2947 | |
2948 if (!UNBOUNDP (value = external_plist_get (&f->plist, property, 1, ERROR_ME))) | |
2949 return value; | |
2950 | |
2951 return default_; | |
2952 } | |
2953 | |
2954 DEFUN ("frame-properties", Fframe_properties, 0, 1, 0, /* | |
2955 Return a property list of the properties of FRAME. | |
2956 Do not modify this list; use `set-frame-property' instead. | |
2957 */ | |
2958 (frame)) | |
2959 { | |
2960 struct frame *f = decode_frame (frame); | |
2961 Lisp_Object result = Qnil; | |
2962 struct gcpro gcpro1; | |
2963 | |
2964 GCPRO1 (result); | |
2965 | |
793 | 2966 frame = wrap_frame (f); |
428 | 2967 |
2968 /* #### for the moment (since old code uses `frame-parameters'), | |
2969 we call `copy-sequence' on f->plist. That allows frame-parameters | |
2970 to destructively convert the plist into an alist, which is more | |
2971 efficient than doing it non-destructively. At some point we | |
2972 should remove the call to copy-sequence. */ | |
2973 result = Fcopy_sequence (f->plist); | |
2974 | |
2975 /* #### should we be adding all the specifiers and glyphs? | |
2976 That would entail having a list of them all. */ | |
2977 if (HAS_FRAMEMETH_P (f, frame_properties)) | |
2978 result = nconc2 (FRAMEMETH (f, frame_properties, (f)), result); | |
2979 | |
2980 if (!NILP (f->buffer_predicate)) | |
2981 result = cons3 (Qbuffer_predicate, f->buffer_predicate, result); | |
2982 | |
2983 if (FRAME_NO_SPLIT_P (f)) | |
2984 result = cons3 (Qunsplittable, Qt, result); | |
2985 | |
2986 /* NOTE: FSF returns Qnil instead of Qt for FRAME_HAS_MINIBUF_P. | |
2987 This is over-the-top bogosity, because it's inconsistent with | |
2988 the semantics of `minibuffer' when passed to `make-frame'. | |
2989 Returning Qt makes things consistent. */ | |
2990 result = cons3 (Qminibuffer, | |
2991 (FRAME_MINIBUF_ONLY_P (f) ? Qonly : | |
2992 FRAME_HAS_MINIBUF_P (f) ? Qt : | |
2993 FRAME_MINIBUF_WINDOW (f)), | |
2994 result); | |
2995 { | |
2996 int width, height; | |
5043 | 2997 get_frame_char_size (f, &width, &height); |
428 | 2998 result = cons3 (Qwidth , make_int (width), result); |
2999 result = cons3 (Qheight, make_int (height), result); | |
3000 } | |
3001 | |
3002 result = cons3 (Qname, f->name, result); | |
3003 | |
3004 UNGCPRO; | |
3005 return result; | |
3006 } | |
3007 | |
3008 | |
3009 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* | |
1125 | 3010 Return the total height in pixels of FRAME. |
428 | 3011 */ |
3012 (frame)) | |
3013 { | |
3014 return make_int (decode_frame (frame)->pixheight); | |
3015 } | |
3016 | |
1125 | 3017 DEFUN ("frame-displayable-pixel-height", Fframe_displayable_pixel_height, 0, 1, 0, /* |
3018 Return the height of the displayable area in pixels of FRAME. | |
3019 */ | |
3020 (frame)) | |
3021 { | |
3022 struct frame *f = decode_frame (frame); | |
5043 | 3023 int width, height; |
3024 | |
3025 get_frame_displayable_pixel_size (f, &width, &height); | |
3026 return make_int (height); | |
1125 | 3027 } |
3028 | |
428 | 3029 DEFUN ("frame-pixel-width", Fframe_pixel_width, 0, 1, 0, /* |
1125 | 3030 Return the total width in pixels of FRAME. |
428 | 3031 */ |
3032 (frame)) | |
3033 { | |
3034 return make_int (decode_frame (frame)->pixwidth); | |
3035 } | |
3036 | |
1125 | 3037 DEFUN ("frame-displayable-pixel-width", Fframe_displayable_pixel_width, 0, 1, 0, /* |
3038 Return the width of the displayable area in pixels of FRAME. | |
3039 */ | |
3040 (frame)) | |
3041 { | |
3042 struct frame *f = decode_frame (frame); | |
5043 | 3043 int width, height; |
3044 | |
3045 get_frame_displayable_pixel_size (f, &width, &height); | |
3046 return make_int (width); | |
1125 | 3047 } |
3048 | |
428 | 3049 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* |
3050 Return the name of FRAME (defaulting to the selected frame). | |
3051 This is not the same as the `title' of the frame. | |
3052 */ | |
3053 (frame)) | |
3054 { | |
3055 return decode_frame (frame)->name; | |
3056 } | |
3057 | |
3058 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
3059 Return FRAME's tick counter, incremented for each change to the frame. | |
3060 Each frame has a tick counter which is incremented each time the frame | |
3061 is resized, a window is resized, added, or deleted, a face is changed, | |
3062 `set-window-buffer' or `select-window' is called on a window in the | |
3063 frame, the window-start of a window in the frame has changed, or | |
3064 anything else interesting has happened. It wraps around occasionally. | |
3065 No argument or nil as argument means use selected frame as FRAME. | |
3066 */ | |
3067 (frame)) | |
3068 { | |
3069 return make_int (decode_frame (frame)->modiff); | |
3070 } | |
3071 | |
5043 | 3072 void |
428 | 3073 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) |
3074 { | |
1318 | 3075 /* This can call Lisp. See mswindows_set_frame_size(). */ |
428 | 3076 /* An explicit size change cancels any pending frame size adjustment */ |
1318 | 3077 CLEAR_FRAME_SIZE_SLIPPED (f); |
428 | 3078 |
3079 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
5043 | 3080 change_frame_size (f, cols, rows, 0); |
428 | 3081 else |
3082 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
3083 } | |
3084 | |
3085 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* | |
3086 Specify that the frame FRAME has LINES lines. | |
3087 Optional third arg non-nil means that redisplay should use LINES lines | |
3088 but that the idea of the actual height of the frame should not be changed. | |
3089 */ | |
444 | 3090 (frame, lines, pretend)) |
428 | 3091 { |
1318 | 3092 /* This can call Lisp. */ |
428 | 3093 struct frame *f = decode_frame (frame); |
5043 | 3094 int cwidth, cheight; |
3095 int guwidth, guheight; | |
3096 | |
444 | 3097 CHECK_INT (lines); |
5043 | 3098 get_frame_char_size (f, &cwidth, &cheight); |
3099 cheight = XINT (lines); | |
3100 frame_conversion_internal (f, SIZE_CHAR_CELL, cwidth, cheight, | |
3101 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3102 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3103 return wrap_frame (f); | |
428 | 3104 } |
3105 | |
863 | 3106 DEFUN ("set-frame-pixel-height", Fset_frame_pixel_height, 2, 3, 0, /* |
1125 | 3107 Specify that the frame FRAME is a total of HEIGHT pixels tall. |
863 | 3108 Optional third arg non-nil means that redisplay should be HEIGHT pixels tall |
3109 but that the idea of the actual height of the frame should not be changed. | |
3110 */ | |
3111 (frame, height, pretend)) | |
3112 { | |
1318 | 3113 /* This can call Lisp. */ |
863 | 3114 struct frame *f = decode_frame (frame); |
5043 | 3115 int pwidth, pheight; |
3116 int guwidth, guheight; | |
3117 | |
863 | 3118 CHECK_INT (height); |
5043 | 3119 pheight = XINT (height); |
3120 pwidth = FRAME_PIXWIDTH (f); | |
3121 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pwidth, pheight, | |
3122 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3123 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3124 return wrap_frame (f); | |
863 | 3125 } |
3126 | |
1125 | 3127 DEFUN ("set-frame-displayable-pixel-height", Fset_frame_displayable_pixel_height, 2, 3, 0, /* |
3128 Specify that the displayable area of frame FRAME is HEIGHT pixels tall. | |
3129 Optional third arg non-nil means that redisplay should be HEIGHT pixels tall | |
3130 but that the idea of the actual height of the frame should not be changed. | |
3131 */ | |
3132 (frame, height, pretend)) | |
3133 { | |
1318 | 3134 /* This can call Lisp. */ |
1125 | 3135 struct frame *f = decode_frame (frame); |
5043 | 3136 int pwidth, pheight; |
3137 int guwidth, guheight; | |
3138 | |
1125 | 3139 CHECK_INT (height); |
5043 | 3140 get_frame_displayable_pixel_size (f, &pwidth, &pheight); |
3141 pheight = XINT (height); | |
3142 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, pwidth, pheight, | |
3143 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3144 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3145 return wrap_frame (f); | |
1125 | 3146 } |
3147 | |
3148 | |
428 | 3149 DEFUN ("set-frame-width", Fset_frame_width, 2, 3, 0, /* |
3150 Specify that the frame FRAME has COLS columns. | |
3151 Optional third arg non-nil means that redisplay should use COLS columns | |
3152 but that the idea of the actual width of the frame should not be changed. | |
3153 */ | |
3154 (frame, cols, pretend)) | |
3155 { | |
1318 | 3156 /* This can call Lisp. */ |
428 | 3157 struct frame *f = decode_frame (frame); |
5043 | 3158 int cwidth, cheight; |
3159 int guwidth, guheight; | |
3160 | |
428 | 3161 CHECK_INT (cols); |
5043 | 3162 get_frame_char_size (f, &cwidth, &cheight); |
3163 cwidth = XINT (cols); | |
3164 frame_conversion_internal (f, SIZE_CHAR_CELL, cwidth, cheight, | |
3165 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3166 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3167 return wrap_frame (f); | |
428 | 3168 } |
3169 | |
863 | 3170 DEFUN ("set-frame-pixel-width", Fset_frame_pixel_width, 2, 3, 0, /* |
1125 | 3171 Specify that the frame FRAME is a total of WIDTH pixels wide. |
863 | 3172 Optional third arg non-nil means that redisplay should be WIDTH wide |
3173 but that the idea of the actual height of the frame should not be changed. | |
3174 */ | |
3175 (frame, width, pretend)) | |
3176 { | |
1318 | 3177 /* This can call Lisp. */ |
863 | 3178 struct frame *f = decode_frame (frame); |
5043 | 3179 int pwidth, pheight; |
3180 int guwidth, guheight; | |
3181 | |
863 | 3182 CHECK_INT (width); |
5043 | 3183 pwidth = XINT (width); |
3184 pheight = FRAME_PIXHEIGHT (f); | |
3185 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pwidth, pheight, | |
3186 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3187 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3188 return wrap_frame (f); | |
1125 | 3189 } |
3190 | |
3191 DEFUN ("set-frame-displayable-pixel-width", Fset_frame_displayable_pixel_width, 2, 3, 0, /* | |
3192 Specify that the displayable area of frame FRAME is WIDTH pixels wide. | |
3193 Optional third arg non-nil means that redisplay should be WIDTH wide | |
3194 but that the idea of the actual height of the frame should not be changed. | |
3195 */ | |
3196 (frame, width, pretend)) | |
3197 { | |
1318 | 3198 /* This can call Lisp. */ |
1125 | 3199 struct frame *f = decode_frame (frame); |
5043 | 3200 int pwidth, pheight; |
3201 int guwidth, guheight; | |
3202 | |
1125 | 3203 CHECK_INT (width); |
5043 | 3204 get_frame_displayable_pixel_size (f, &pwidth, &pheight); |
3205 pwidth = XINT (width); | |
3206 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, pwidth, pheight, | |
3207 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3208 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3209 return wrap_frame (f); | |
863 | 3210 } |
3211 | |
428 | 3212 DEFUN ("set-frame-size", Fset_frame_size, 3, 4, 0, /* |
444 | 3213 Set the size of FRAME to COLS by ROWS, measured in characters. |
428 | 3214 Optional fourth arg non-nil means that redisplay should use COLS by ROWS |
3215 but that the idea of the actual size of the frame should not be changed. | |
3216 */ | |
3217 (frame, cols, rows, pretend)) | |
3218 { | |
1318 | 3219 /* This can call Lisp. */ |
428 | 3220 struct frame *f = decode_frame (frame); |
5043 | 3221 int guwidth, guheight; |
3222 | |
428 | 3223 CHECK_INT (cols); |
3224 CHECK_INT (rows); | |
5043 | 3225 frame_conversion_internal (f, SIZE_CHAR_CELL, XINT (cols), XINT (rows), |
3226 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3227 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3228 return wrap_frame (f); | |
428 | 3229 } |
3230 | |
863 | 3231 DEFUN ("set-frame-pixel-size", Fset_frame_pixel_size, 3, 4, 0, /* |
1125 | 3232 Set the total size of FRAME to WIDTH by HEIGHT, measured in pixels. |
863 | 3233 Optional fourth arg non-nil means that redisplay should use WIDTH by HEIGHT |
3234 but that the idea of the actual size of the frame should not be changed. | |
3235 */ | |
3236 (frame, width, height, pretend)) | |
3237 { | |
1318 | 3238 /* This can call Lisp. */ |
863 | 3239 struct frame *f = decode_frame (frame); |
5043 | 3240 int guwidth, guheight; |
3241 | |
863 | 3242 CHECK_INT (width); |
3243 CHECK_INT (height); | |
5043 | 3244 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, XINT (width), XINT (height), |
3245 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3246 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3247 return wrap_frame (f); | |
1125 | 3248 } |
3249 | |
3250 DEFUN ("set-frame-displayable-pixel-size", Fset_frame_displayable_pixel_size, 3, 4, 0, /* | |
3251 Set the displayable size of FRAME to WIDTH by HEIGHT, measured in pixels. | |
3252 Optional fourth arg non-nil means that redisplay should use WIDTH by HEIGHT | |
3253 but that the idea of the actual size of the frame should not be changed. | |
3254 */ | |
3255 (frame, width, height, pretend)) | |
3256 { | |
1318 | 3257 /* This can call Lisp. */ |
1125 | 3258 struct frame *f = decode_frame (frame); |
5043 | 3259 int guwidth, guheight; |
3260 | |
1125 | 3261 CHECK_INT (width); |
3262 CHECK_INT (height); | |
5043 | 3263 frame_conversion_internal (f, SIZE_DISPLAYABLE_PIXEL, |
3264 XINT (width), XINT (height), | |
3265 SIZE_FRAME_UNIT, &guwidth, &guheight); | |
3266 internal_set_frame_size (f, guwidth, guheight, !NILP (pretend)); | |
3267 return wrap_frame (f); | |
863 | 3268 } |
3269 | |
428 | 3270 DEFUN ("set-frame-position", Fset_frame_position, 3, 3, 0, /* |
3271 Set position of FRAME in pixels to XOFFSET by YOFFSET. | |
3272 This is actually the position of the upper left corner of the frame. | |
3273 Negative values for XOFFSET or YOFFSET are interpreted relative to | |
3274 the rightmost or bottommost possible position (that stays within the screen). | |
3275 */ | |
3276 (frame, xoffset, yoffset)) | |
3277 { | |
3278 struct frame *f = decode_frame (frame); | |
3279 CHECK_INT (xoffset); | |
3280 CHECK_INT (yoffset); | |
3281 | |
3282 MAYBE_FRAMEMETH (f, set_frame_position, (f, XINT (xoffset), XINT (yoffset))); | |
3283 | |
3284 return Qt; | |
3285 } | |
3286 | |
3287 | |
3288 | |
3289 /* Frame size conversion functions moved here from EmacsFrame.c | |
3290 because they're generic and really don't belong in that file. | |
3291 Function get_default_char_pixel_size() removed because it's | |
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5046
diff
changeset
|
3292 exactly the same as default_face_width_and_height(). |
5043 | 3293 |
3294 Convert between total pixel size, displayable pixel size and | |
3295 character-cell size. Variables are either "in" or "out" | |
3296 depending on the value of PIXEL_TO_CHAR. | |
3297 */ | |
428 | 3298 static void |
5043 | 3299 frame_conversion_internal_1 (struct frame *f, |
3300 pixel_to_char_mode_t pixel_to_char, | |
3301 int *total_pixel_width, int *total_pixel_height, | |
3302 int *disp_pixel_width, int *disp_pixel_height, | |
3303 int *char_width, int *char_height) | |
428 | 3304 { |
5043 | 3305 int cpw, cph; |
428 | 3306 int egw; |
3307 int obw, obh, bdr; | |
3308 Lisp_Object frame, window; | |
3309 | |
793 | 3310 frame = wrap_frame (f); |
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5046
diff
changeset
|
3311 default_face_width_and_height (frame, &cpw, &cph); |
428 | 3312 |
3313 window = FRAME_SELECTED_WINDOW (f); | |
3314 | |
5045 | 3315 /* #### It really seems like we should also be subtracting out the |
3316 theoretical gutter width and height, just like we do for toolbars. | |
3317 There is currently a bug where if you call `set-frame-pixel-width' | |
3318 on MS Windows (at least, possibly also X) things get confused and | |
3319 the top of the root window overlaps the top gutter instead of being | |
3320 below it. This gets fixed next time you resize the frame using the | |
3321 mouse. Possibly this is caused by not handling the gutter height | |
3322 here? */ | |
438 | 3323 egw = max (glyph_width (Vcontinuation_glyph, window), |
3324 glyph_width (Vtruncation_glyph, window)); | |
428 | 3325 egw = max (egw, cpw); |
3326 bdr = 2 * f->internal_border_width; | |
3327 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) + | |
3328 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) + | |
3329 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) + | |
3330 2 * FRAME_THEORETICAL_RIGHT_TOOLBAR_BORDER_WIDTH (f); | |
3331 obh = FRAME_SCROLLBAR_HEIGHT (f) + FRAME_THEORETICAL_TOP_TOOLBAR_HEIGHT (f) + | |
3332 FRAME_THEORETICAL_BOTTOM_TOOLBAR_HEIGHT (f) + | |
3333 2 * FRAME_THEORETICAL_TOP_TOOLBAR_BORDER_WIDTH (f) + | |
3334 2 * FRAME_THEORETICAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f); | |
3335 | |
863 | 3336 /* Convert to chars so that the displayable area is pixel_width x |
3337 pixel_height. | |
3338 | |
3339 #### Consider rounding up to 0.5 characters to avoid adding too | |
3340 much space. */ | |
1125 | 3341 switch (pixel_to_char) |
863 | 3342 { |
1125 | 3343 case DISPLAYABLE_PIXEL_TO_CHAR: |
863 | 3344 if (char_width) |
5043 | 3345 *char_width = ROUND_UP (*disp_pixel_width, cpw) / cpw; |
863 | 3346 if (char_height) |
5043 | 3347 *char_height = ROUND_UP (*disp_pixel_height, cph) / cph; |
3348 break; | |
3349 case CHAR_TO_DISPLAYABLE_PIXEL: | |
3350 if (disp_pixel_width) | |
3351 *disp_pixel_width = *char_width * cpw; | |
3352 if (disp_pixel_height) | |
3353 *disp_pixel_height = *char_height * cph; | |
1125 | 3354 break; |
3355 case TOTAL_PIXEL_TO_CHAR: | |
3356 /* Convert to chars so that the total frame size is pixel_width x | |
3357 pixel_height. */ | |
428 | 3358 if (char_width) |
5043 | 3359 *char_width = 1 + ((*total_pixel_width - egw) - bdr - obw) / cpw; |
428 | 3360 if (char_height) |
5043 | 3361 *char_height = (*total_pixel_height - bdr - obh) / cph; |
1125 | 3362 break; |
3363 case CHAR_TO_TOTAL_PIXEL: | |
5043 | 3364 if (total_pixel_width) |
3365 *total_pixel_width = (*char_width - 1) * cpw + egw + bdr + obw; | |
3366 if (total_pixel_height) | |
3367 *total_pixel_height = *char_height * cph + bdr + obh; | |
1125 | 3368 break; |
5043 | 3369 case TOTAL_PIXEL_TO_DISPLAYABLE_PIXEL: |
3370 /* Convert to chars so that the total frame size is pixel_width x | |
3371 pixel_height. */ | |
3372 if (disp_pixel_width) | |
3373 *disp_pixel_width = cpw + (*total_pixel_width - egw) - bdr - obw; | |
3374 if (disp_pixel_height) | |
3375 *disp_pixel_height = *total_pixel_height - bdr - obh; | |
3376 break; | |
3377 case DISPLAYABLE_PIXEL_TO_TOTAL_PIXEL: | |
3378 if (total_pixel_width) | |
3379 *total_pixel_width = *disp_pixel_width - cpw + egw + bdr + obw; | |
3380 if (total_pixel_height) | |
3381 *total_pixel_height = *disp_pixel_height + bdr + obh; | |
1125 | 3382 break; |
428 | 3383 } |
3384 } | |
3385 | |
5043 | 3386 |
3387 static enum frame_size_type | |
3388 canonicalize_frame_size_type (enum frame_size_type type, int pixgeom) | |
3389 { | |
3390 if (type == SIZE_FRAME_UNIT) | |
3391 { | |
3392 if (pixgeom) | |
3393 type = SIZE_DISPLAYABLE_PIXEL; | |
3394 else | |
3395 type = SIZE_CHAR_CELL; | |
3396 } | |
3397 return type; | |
3398 } | |
3399 | |
3400 /* Basic frame conversion function. Convert source size to destination | |
3401 size, where either of them can be in total pixels, displayable pixels, | |
3402 frame units or character-cell units. */ | |
3403 | |
3404 static void | |
3405 frame_conversion_internal (struct frame *f, | |
3406 enum frame_size_type source, | |
3407 int source_width, int source_height, | |
3408 enum frame_size_type dest, | |
3409 int *dest_width, int *dest_height) | |
3410 { | |
3411 int pixgeom = window_system_pixelated_geometry (wrap_frame (f)); | |
3412 dest = canonicalize_frame_size_type (dest, pixgeom); | |
3413 source = canonicalize_frame_size_type (source, pixgeom); | |
3414 if (source == dest) | |
3415 { | |
3416 *dest_width = source_width; | |
3417 *dest_height = source_height; | |
3418 } | |
3419 else if (source == SIZE_TOTAL_PIXEL && dest == SIZE_CHAR_CELL) | |
3420 frame_conversion_internal_1 (f, TOTAL_PIXEL_TO_CHAR, | |
3421 &source_width, &source_height, 0, 0, | |
3422 dest_width, dest_height); | |
3423 else if (source == SIZE_DISPLAYABLE_PIXEL && dest == SIZE_CHAR_CELL) | |
3424 frame_conversion_internal_1 (f, DISPLAYABLE_PIXEL_TO_CHAR, 0, 0, | |
3425 &source_width, &source_height, | |
3426 dest_width, dest_height); | |
3427 else if (source == SIZE_TOTAL_PIXEL && dest == SIZE_DISPLAYABLE_PIXEL) | |
3428 frame_conversion_internal_1 (f, TOTAL_PIXEL_TO_DISPLAYABLE_PIXEL, | |
3429 &source_width, &source_height, | |
3430 dest_width, dest_height, 0, 0); | |
3431 else if (dest == SIZE_TOTAL_PIXEL && source == SIZE_CHAR_CELL) | |
3432 frame_conversion_internal_1 (f, CHAR_TO_TOTAL_PIXEL, | |
3433 dest_width, dest_height, 0, 0, | |
3434 &source_width, &source_height); | |
3435 else if (dest == SIZE_DISPLAYABLE_PIXEL && source == SIZE_CHAR_CELL) | |
3436 frame_conversion_internal_1 (f, CHAR_TO_DISPLAYABLE_PIXEL, 0, 0, | |
3437 dest_width, dest_height, | |
3438 &source_width, &source_height); | |
3439 else if (dest == SIZE_TOTAL_PIXEL && source == SIZE_DISPLAYABLE_PIXEL) | |
3440 frame_conversion_internal_1 (f, DISPLAYABLE_PIXEL_TO_TOTAL_PIXEL, | |
3441 dest_width, dest_height, | |
3442 &source_width, &source_height, 0, 0); | |
3443 else | |
3444 { | |
3445 ABORT (); | |
3446 if (dest_width) | |
3447 *dest_width = 0; | |
3448 if (dest_height) | |
3449 *dest_height = 0; | |
3450 } | |
3451 } | |
3452 | |
3453 /* This takes the size in pixels of the client area, and returns the number | |
428 | 3454 of characters that will fit there, taking into account the internal |
3455 border width, and the pixel width of the line terminator glyphs (which | |
3456 always count as one "character" wide, even if they are not the same size | |
3457 as the default character size of the default font). The frame scrollbar | |
3458 width and left and right toolbar widths are also subtracted out of the | |
3459 available width. The frame scrollbar height and top and bottom toolbar | |
3460 heights are subtracted out of the available height. | |
3461 | |
3462 Therefore the result is not necessarily a multiple of anything in | |
3463 particular. */ | |
5043 | 3464 |
428 | 3465 void |
3466 pixel_to_char_size (struct frame *f, int pixel_width, int pixel_height, | |
3467 int *char_width, int *char_height) | |
3468 { | |
5043 | 3469 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pixel_width, pixel_height, |
3470 SIZE_CHAR_CELL, char_width, char_height); | |
428 | 3471 } |
3472 | |
5043 | 3473 /* Given a character size, this returns the minimum pixel size of the |
3474 client area necessary to display that many characters, taking into | |
3475 account the internal border width, scrollbar height and width, toolbar | |
3476 heights and widths and the size of the line terminator glyphs (assuming | |
3477 the line terminators take up exactly one character position). | |
428 | 3478 |
3479 Therefore the result is not necessarily a multiple of anything in | |
3480 particular. */ | |
5043 | 3481 |
428 | 3482 void |
3483 char_to_pixel_size (struct frame *f, int char_width, int char_height, | |
3484 int *pixel_width, int *pixel_height) | |
3485 { | |
5043 | 3486 frame_conversion_internal (f, SIZE_CHAR_CELL, char_width, char_height, |
3487 SIZE_TOTAL_PIXEL, pixel_width, pixel_height); | |
428 | 3488 } |
3489 | |
5043 | 3490 /* Versions of the above that operate in "frame units" instead of |
3491 characters. frame units are the same as characters except on | |
3492 MS Windows and MS Printer frames, where they are displayable-area | |
3493 pixels. */ | |
3494 | |
3495 void | |
3496 pixel_to_frame_unit_size (struct frame *f, int pixel_width, int pixel_height, | |
3497 int *frame_unit_width, int *frame_unit_height) | |
3498 { | |
3499 frame_conversion_internal (f, SIZE_TOTAL_PIXEL, pixel_width, pixel_height, | |
3500 SIZE_FRAME_UNIT, frame_unit_width, | |
3501 frame_unit_height); | |
3502 } | |
3503 | |
3504 void | |
3505 frame_unit_to_pixel_size (struct frame *f, int frame_unit_width, | |
3506 int frame_unit_height, | |
3507 int *pixel_width, int *pixel_height) | |
3508 { | |
3509 frame_conversion_internal (f, SIZE_FRAME_UNIT, frame_unit_width, | |
3510 frame_unit_height, | |
3511 SIZE_TOTAL_PIXEL, pixel_width, pixel_height); | |
3512 } | |
3513 | |
428 | 3514 void |
3515 round_size_to_char (struct frame *f, int in_width, int in_height, | |
3516 int *out_width, int *out_height) | |
3517 { | |
3518 int char_width; | |
3519 int char_height; | |
3520 pixel_to_char_size (f, in_width, in_height, &char_width, &char_height); | |
3521 char_to_pixel_size (f, char_width, char_height, out_width, out_height); | |
3522 } | |
3523 | |
5043 | 3524 /* Get the frame size in character cells, recalculating on the fly. |
3525 #### The logic of this function follows former logic elsewhere, | |
3526 which used FRAME_PIXWIDTH() on pixelated-geometry systems but | |
3527 FRAME_WIDTH() on non-pixelated-geometry systems. Not clear why not | |
3528 always just use one or the other. | |
3529 | |
3530 Why don't we just use FRAME_CHARWIDTH() etc. in get_frame_char_size()? | |
3531 That wouldn't work because change_frame_size_1() depends on the | |
3532 following function to *set* the values of FRAME_CHARWIDTH() etc. | |
3533 | |
3534 But elsewhere I suppose we could use it. | |
3535 */ | |
3536 | |
3537 static void | |
3538 get_frame_char_size (struct frame *f, int *out_width, int *out_height) | |
428 | 3539 { |
5043 | 3540 if (window_system_pixelated_geometry (wrap_frame (f))) |
3541 pixel_to_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
3542 out_width, out_height); | |
3543 else | |
3544 { | |
3545 *out_width = FRAME_WIDTH (f); | |
3546 *out_height = FRAME_HEIGHT (f); | |
3547 } | |
428 | 3548 } |
3549 | |
5043 | 3550 static void |
3551 get_frame_displayable_pixel_size (struct frame *f, int *out_width, | |
3552 int *out_height) | |
428 | 3553 { |
5043 | 3554 frame_conversion_internal (f, SIZE_FRAME_UNIT, FRAME_WIDTH (f), |
3555 FRAME_HEIGHT (f), SIZE_DISPLAYABLE_PIXEL, | |
3556 out_width, out_height); | |
428 | 3557 } |
3558 | |
5045 | 3559 /* Change the frame height and/or width. Values passed in are in |
3560 frame units (character cells on X/GTK, displayable-area pixels | |
3561 on MS Windows or generally on pixelated-geometry window systems). */ | |
428 | 3562 static void |
5043 | 3563 change_frame_size_1 (struct frame *f, int newwidth, int newheight) |
428 | 3564 { |
3565 int new_pixheight, new_pixwidth; | |
5043 | 3566 int real_font_height, real_font_width; |
428 | 3567 |
3568 /* #### Chuck -- shouldn't we be checking to see if the frame | |
3569 is being "changed" to its existing size, and do nothing if so? */ | |
3570 /* No, because it would hose toolbar updates. The toolbar | |
3571 update code relies on this function to cause window `top' and | |
3572 `left' coordinates to be recomputed even though no frame size | |
3573 change occurs. --kyle */ | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
3574 assert (!in_display && !hold_frame_size_changes); |
428 | 3575 |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3576 /* We no longer allow bogus values passed in. */ |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3577 assert (newheight && newwidth); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3578 |
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5046
diff
changeset
|
3579 default_face_width_and_height (wrap_frame (f), &real_font_width, |
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5046
diff
changeset
|
3580 &real_font_height); |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3581 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3582 frame_conversion_internal (f, SIZE_FRAME_UNIT, newwidth, newheight, |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3583 SIZE_TOTAL_PIXEL, &new_pixwidth, |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3584 &new_pixheight); |
428 | 3585 |
3586 /* This size-change overrides any pending one for this frame. */ | |
4307 | 3587 f->size_change_pending = 0; |
428 | 3588 FRAME_NEW_HEIGHT (f) = 0; |
3589 FRAME_NEW_WIDTH (f) = 0; | |
3590 | |
5045 | 3591 /* We need to remove the boundaries of the paned area (see top of file) |
3592 from the total-area pixel size, which is what we have now. | |
3593 | |
3594 #### We should also be subtracting the internal borders. */ | |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3595 new_pixheight -= |
5045 | 3596 (FRAME_REAL_TOP_TOOLBAR_BOUNDS (f) |
3597 + FRAME_REAL_BOTTOM_TOOLBAR_BOUNDS (f) | |
3598 + FRAME_TOP_GUTTER_BOUNDS (f) | |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3599 + FRAME_BOTTOM_GUTTER_BOUNDS (f)); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3600 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3601 new_pixwidth -= |
5045 | 3602 (FRAME_REAL_LEFT_TOOLBAR_BOUNDS (f) |
3603 + FRAME_REAL_RIGHT_TOOLBAR_BOUNDS (f) | |
3604 + FRAME_LEFT_GUTTER_BOUNDS (f) | |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3605 + FRAME_RIGHT_GUTTER_BOUNDS (f)); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3606 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3607 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3608 = FRAME_TOP_BORDER_END (f) + FRAME_TOP_GUTTER_BOUNDS (f); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3609 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3610 if (FRAME_HAS_MINIBUF_P (f) |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3611 && ! FRAME_MINIBUF_ONLY_P (f)) |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3612 /* Frame has both root and minibuffer. */ |
428 | 3613 { |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3614 /* |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3615 * Leave the minibuffer height the same if the frame has |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3616 * been initialized, and the minibuffer height is tall |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3617 * enough to display at least one line of text in the default |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3618 * font, and the old minibuffer height is a multiple of the |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3619 * default font height. This should cause the minibuffer |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3620 * height to be recomputed on font changes but not for |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3621 * other frame size changes, which seems reasonable. |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3622 */ |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3623 int old_minibuf_height = |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3624 XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3625 int minibuf_height = |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3626 f->init_finished && (old_minibuf_height % real_font_height) == 0 ? |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3627 max(old_minibuf_height, real_font_height) : |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3628 real_font_height; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3629 set_window_pixheight (FRAME_ROOT_WINDOW (f), |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3630 /* - font_height for minibuffer */ |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3631 new_pixheight - minibuf_height, 0); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3632 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3633 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top = |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3634 FRAME_TOP_BORDER_END (f) + |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3635 FRAME_TOP_GUTTER_BOUNDS (f) + |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3636 FRAME_BOTTOM_GUTTER_BOUNDS (f) + |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3637 new_pixheight - minibuf_height; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3638 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3639 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0); |
428 | 3640 } |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3641 else |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3642 /* Frame has just one top-level window. */ |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3643 set_window_pixheight (FRAME_ROOT_WINDOW (f), new_pixheight, 0); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3644 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3645 FRAME_HEIGHT (f) = newheight; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3646 if (FRAME_TTY_P (f)) |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3647 f->pixheight = newheight; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3648 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3649 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3650 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3651 set_window_pixwidth (FRAME_ROOT_WINDOW (f), new_pixwidth, 0); |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3652 |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3653 if (FRAME_HAS_MINIBUF_P (f)) |
428 | 3654 { |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3655 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left = |
442 | 3656 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3657 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), new_pixwidth, 0); |
428 | 3658 } |
3659 | |
5044
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3660 FRAME_WIDTH (f) = newwidth; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3661 if (FRAME_TTY_P (f)) |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3662 f->pixwidth = newwidth; |
e84a30b0e4a2
remove duplicative code in change_frame_size()
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
3663 |
5045 | 3664 /* #### On MS Windows, this references FRAME_PIXWIDTH() and FRAME_PIXHEIGHT(). |
3665 I'm not sure we can count on those values being set. Instead we should | |
3666 use the total pixel size we got near the top by calling | |
3667 frame_conversion_internal(). We should inline the logic in | |
3668 get_frame_char_size() here and change that function so it just looks | |
3669 at FRAME_CHARWIDTH() and FRAME_CHARHEIGHT(). */ | |
5043 | 3670 get_frame_char_size (f, &FRAME_CHARWIDTH (f), &FRAME_CHARHEIGHT (f)); |
428 | 3671 |
3672 MARK_FRAME_TOOLBARS_CHANGED (f); | |
442 | 3673 MARK_FRAME_GUTTERS_CHANGED (f); |
428 | 3674 MARK_FRAME_CHANGED (f); |
3675 f->echo_area_garbaged = 1; | |
3676 } | |
3677 | |
3678 void | |
5043 | 3679 change_frame_size (struct frame *f, int newwidth, int newheight, int delay) |
428 | 3680 { |
3681 /* sometimes we get passed a size that's too small (esp. when a | |
3682 client widget gets resized, since we have no control over this). | |
3683 So deal. */ | |
5047
07dcc7000bbf
put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents:
5046
diff
changeset
|
3684 check_frame_size (f, &newwidth, &newheight); |
428 | 3685 |
450 | 3686 /* Unconditionally mark that the frame has changed size. This is |
3687 because many things need to know after the | |
3688 fact. f->size_change_pending will get reset below. The most that | |
3689 can happen is that we will cycle through redisplay once more | |
3690 --andy. */ | |
3691 MARK_FRAME_SIZE_CHANGED (f); | |
3692 | |
3092 | 3693 #ifdef NEW_GC |
3694 if (delay || hold_frame_size_changes) | |
3695 #else /* not NEW_GC */ | |
1318 | 3696 if (delay || hold_frame_size_changes || gc_in_progress) |
3092 | 3697 #endif /* not NEW_GC */ |
428 | 3698 { |
3699 f->new_width = newwidth; | |
3700 f->new_height = newheight; | |
3701 return; | |
3702 } | |
3703 | |
3704 /* For TTY frames, it's like one, like all ... | |
3705 Can't have two TTY frames of different sizes on the same device. */ | |
3706 if (FRAME_TTY_P (f)) | |
3707 { | |
3708 Lisp_Object frmcons; | |
3709 | |
3710 DEVICE_FRAME_LOOP (frmcons, XDEVICE (FRAME_DEVICE (f))) | |
5043 | 3711 change_frame_size_1 (XFRAME (XCAR (frmcons)), newwidth, newheight); |
428 | 3712 } |
3713 else | |
5043 | 3714 change_frame_size_1 (f, newwidth, newheight); |
428 | 3715 } |
3716 | |
3717 | |
438 | 3718 /* The caller is responsible for freeing the returned string. */ |
867 | 3719 static Ibyte * |
438 | 3720 generate_title_string (struct window *w, Lisp_Object format_str, |
3721 face_index findex, int type) | |
3722 { | |
3723 struct display_line *dl; | |
3724 struct display_block *db; | |
3725 int elt = 0; | |
3726 | |
3727 dl = &title_string_display_line; | |
3728 db = get_display_block_from_line (dl, TEXT); | |
3729 Dynarr_reset (db->runes); | |
3730 | |
3731 generate_formatted_string_db (format_str, Qnil, w, dl, db, findex, 0, | |
4207 | 3732 -1, type); |
438 | 3733 |
867 | 3734 Dynarr_reset (title_string_ichar_dynarr); |
438 | 3735 while (elt < Dynarr_length (db->runes)) |
3736 { | |
3737 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) | |
867 | 3738 Dynarr_add (title_string_ichar_dynarr, |
438 | 3739 Dynarr_atp (db->runes, elt)->object.chr.ch); |
3740 elt++; | |
3741 } | |
3742 | |
3743 return | |
867 | 3744 convert_ichar_string_into_malloced_string |
4967 | 3745 (Dynarr_begin (title_string_ichar_dynarr), |
867 | 3746 Dynarr_length (title_string_ichar_dynarr), 0); |
438 | 3747 } |
3748 | |
428 | 3749 void |
3750 update_frame_title (struct frame *f) | |
3751 { | |
3752 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
3753 Lisp_Object title_format; | |
3754 Lisp_Object icon_format; | |
867 | 3755 Ibyte *title; |
428 | 3756 |
3757 /* We don't change the title for the minibuffer unless the frame | |
3758 only has a minibuffer. */ | |
3759 if (MINI_WINDOW_P (w) && !FRAME_MINIBUF_ONLY_P (f)) | |
3760 return; | |
3761 | |
3762 /* And we don't want dead buffers to blow up on us. */ | |
3763 if (!BUFFER_LIVE_P (XBUFFER (w->buffer))) | |
3764 return; | |
3765 | |
3766 title = NULL; | |
3767 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer); | |
3768 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer); | |
3769 | |
867 | 3770 if (HAS_FRAMEMETH_P (f, set_title_from_ibyte)) |
428 | 3771 { |
438 | 3772 title = generate_title_string (w, title_format, |
3773 DEFAULT_INDEX, CURRENT_DISP); | |
867 | 3774 FRAMEMETH (f, set_title_from_ibyte, (f, title)); |
428 | 3775 } |
3776 | |
867 | 3777 if (HAS_FRAMEMETH_P (f, set_icon_name_from_ibyte)) |
428 | 3778 { |
3779 if (!EQ (icon_format, title_format) || !title) | |
3780 { | |
3781 if (title) | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4968
diff
changeset
|
3782 xfree (title); |
428 | 3783 |
438 | 3784 title = generate_title_string (w, icon_format, |
3785 DEFAULT_INDEX, CURRENT_DISP); | |
428 | 3786 } |
867 | 3787 FRAMEMETH (f, set_icon_name_from_ibyte, (f, title)); |
428 | 3788 } |
3789 | |
3790 if (title) | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4968
diff
changeset
|
3791 xfree (title); |
428 | 3792 } |
3793 | |
3794 | |
3795 DEFUN ("set-frame-pointer", Fset_frame_pointer, 2, 2, 0, /* | |
3796 Set the mouse pointer of FRAME to the given pointer image instance. | |
3797 You should not call this function directly. Instead, set one of | |
3798 the variables `text-pointer-glyph', `nontext-pointer-glyph', | |
3799 `modeline-pointer-glyph', `selection-pointer-glyph', | |
3800 `busy-pointer-glyph', or `toolbar-pointer-glyph'. | |
3801 */ | |
3802 (frame, image_instance)) | |
3803 { | |
3804 struct frame *f = decode_frame (frame); | |
3805 CHECK_POINTER_IMAGE_INSTANCE (image_instance); | |
3806 if (!EQ (f->pointer, image_instance)) | |
3807 { | |
3808 f->pointer = image_instance; | |
3809 MAYBE_FRAMEMETH (f, set_frame_pointer, (f)); | |
3810 } | |
3811 return Qnil; | |
3812 } | |
3813 | |
3814 | |
3815 void | |
3816 update_frame_icon (struct frame *f) | |
3817 { | |
3818 if (f->icon_changed || f->windows_changed) | |
3819 { | |
3820 Lisp_Object frame; | |
3821 Lisp_Object new_icon; | |
3822 | |
793 | 3823 frame = wrap_frame (f); |
428 | 3824 new_icon = glyph_image_instance (Vframe_icon_glyph, frame, |
3825 ERROR_ME_WARN, 0); | |
3826 if (!EQ (new_icon, f->icon)) | |
3827 { | |
3828 f->icon = new_icon; | |
3829 MAYBE_FRAMEMETH (f, set_frame_icon, (f)); | |
3830 } | |
3831 } | |
3832 | |
3833 f->icon_changed = 0; | |
3834 } | |
3835 | |
3836 static void | |
2286 | 3837 icon_glyph_changed (Lisp_Object UNUSED (glyph), Lisp_Object UNUSED (property), |
3838 Lisp_Object UNUSED (locale)) | |
428 | 3839 { |
3840 MARK_ICON_CHANGED; | |
3841 } | |
3842 | |
3843 | |
438 | 3844 /***************************************************************************/ |
3845 /* */ | |
3846 /* initialization */ | |
3847 /* */ | |
3848 /***************************************************************************/ | |
3849 | |
3850 void | |
3851 init_frame (void) | |
3852 { | |
3853 #ifndef PDUMP | |
3854 if (!initialized) | |
3855 #endif | |
3856 { | |
867 | 3857 title_string_ichar_dynarr = Dynarr_new (Ichar); |
4207 | 3858 DISPLAY_LINE_INIT (title_string_display_line); |
438 | 3859 } |
3860 } | |
3861 | |
428 | 3862 void |
3863 syms_of_frame (void) | |
3864 { | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
3865 INIT_LISP_OBJECT (frame); |
3092 | 3866 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
3867 INIT_LISP_OBJECT (expose_ignore); |
3092 | 3868 #endif /* NEW_GC */ |
442 | 3869 |
563 | 3870 DEFSYMBOL (Qdelete_frame_hook); |
3871 DEFSYMBOL (Qselect_frame_hook); | |
3872 DEFSYMBOL (Qdeselect_frame_hook); | |
3873 DEFSYMBOL (Qcreate_frame_hook); | |
3874 DEFSYMBOL (Qcustom_initialize_frame); | |
3875 DEFSYMBOL (Qmouse_enter_frame_hook); | |
3876 DEFSYMBOL (Qmouse_leave_frame_hook); | |
3877 DEFSYMBOL (Qmap_frame_hook); | |
3878 DEFSYMBOL (Qunmap_frame_hook); | |
3879 | |
3880 DEFSYMBOL (Qframep); | |
3881 DEFSYMBOL (Qframe_live_p); | |
3882 DEFSYMBOL (Qdelete_frame); | |
3883 DEFSYMBOL (Qsynchronize_minibuffers); | |
3884 DEFSYMBOL (Qbuffer_predicate); | |
3885 DEFSYMBOL (Qframe_being_created); | |
3886 DEFSYMBOL (Qmake_initial_minibuffer_frame); | |
3887 | |
3888 DEFSYMBOL (Qframe_title_format); | |
3889 DEFSYMBOL (Qframe_icon_title_format); | |
3890 | |
3891 DEFSYMBOL (Qhidden); | |
3892 DEFSYMBOL (Qvisible); | |
3893 DEFSYMBOL (Qiconic); | |
3894 DEFSYMBOL (Qinvisible); | |
3895 DEFSYMBOL (Qvisible_iconic); | |
3896 DEFSYMBOL (Qinvisible_iconic); | |
3897 DEFSYMBOL (Qnomini); | |
3898 DEFSYMBOL (Qvisible_nomini); | |
3899 DEFSYMBOL (Qiconic_nomini); | |
3900 DEFSYMBOL (Qinvisible_nomini); | |
3901 DEFSYMBOL (Qvisible_iconic_nomini); | |
3902 DEFSYMBOL (Qinvisible_iconic_nomini); | |
3903 | |
3904 DEFSYMBOL (Qminibuffer); | |
3905 DEFSYMBOL (Qunsplittable); | |
3906 DEFSYMBOL (Qinternal_border_width); | |
3907 DEFSYMBOL (Qtop_toolbar_shadow_color); | |
3908 DEFSYMBOL (Qbottom_toolbar_shadow_color); | |
3909 DEFSYMBOL (Qbackground_toolbar_color); | |
3910 DEFSYMBOL (Qtop_toolbar_shadow_pixmap); | |
3911 DEFSYMBOL (Qbottom_toolbar_shadow_pixmap); | |
3912 DEFSYMBOL (Qtoolbar_shadow_thickness); | |
3913 DEFSYMBOL (Qscrollbar_placement); | |
3914 DEFSYMBOL (Qinter_line_space); | |
428 | 3915 /* Qiconic already in this function. */ |
563 | 3916 DEFSYMBOL (Qvisual_bell); |
3917 DEFSYMBOL (Qbell_volume); | |
3918 DEFSYMBOL (Qpointer_background); | |
3919 DEFSYMBOL (Qpointer_color); | |
3920 DEFSYMBOL (Qtext_pointer); | |
3921 DEFSYMBOL (Qspace_pointer); | |
3922 DEFSYMBOL (Qmodeline_pointer); | |
3923 DEFSYMBOL (Qgc_pointer); | |
3924 DEFSYMBOL (Qinitially_unmapped); | |
3925 DEFSYMBOL (Quse_backing_store); | |
3926 DEFSYMBOL (Qborder_color); | |
3927 DEFSYMBOL (Qborder_width); | |
428 | 3928 /* Qwidth, Qheight, Qleft, Qtop in general.c */ |
563 | 3929 DEFSYMBOL (Qset_specifier); |
3930 DEFSYMBOL (Qset_face_property); | |
3931 DEFSYMBOL (Qface_property_instance); | |
3932 DEFSYMBOL (Qframe_property_alias); | |
428 | 3933 |
3934 DEFSUBR (Fmake_frame); | |
3935 DEFSUBR (Fframep); | |
3936 DEFSUBR (Fframe_live_p); | |
3937 #if 0 /* FSFmacs */ | |
3938 DEFSUBR (Fignore_event); | |
3939 #endif | |
3940 DEFSUBR (Ffocus_frame); | |
3941 DEFSUBR (Fselect_frame); | |
3942 DEFSUBR (Fselected_frame); | |
3943 DEFSUBR (Factive_minibuffer_window); | |
3944 DEFSUBR (Flast_nonminibuf_frame); | |
3945 DEFSUBR (Fframe_root_window); | |
3946 DEFSUBR (Fframe_selected_window); | |
3947 DEFSUBR (Fset_frame_selected_window); | |
3948 DEFSUBR (Fframe_device); | |
3949 DEFSUBR (Fnext_frame); | |
3950 DEFSUBR (Fprevious_frame); | |
3951 DEFSUBR (Fdelete_frame); | |
3952 DEFSUBR (Fmouse_position); | |
3953 DEFSUBR (Fmouse_pixel_position); | |
3954 DEFSUBR (Fmouse_position_as_motion_event); | |
3955 DEFSUBR (Fset_mouse_position); | |
3956 DEFSUBR (Fset_mouse_pixel_position); | |
3957 DEFSUBR (Fmake_frame_visible); | |
3958 DEFSUBR (Fmake_frame_invisible); | |
3959 DEFSUBR (Ficonify_frame); | |
3960 DEFSUBR (Fdeiconify_frame); | |
3961 DEFSUBR (Fframe_visible_p); | |
3962 DEFSUBR (Fframe_totally_visible_p); | |
3963 DEFSUBR (Fframe_iconified_p); | |
3964 DEFSUBR (Fvisible_frame_list); | |
3965 DEFSUBR (Fraise_frame); | |
3966 DEFSUBR (Flower_frame); | |
442 | 3967 DEFSUBR (Fdisable_frame); |
3968 DEFSUBR (Fenable_frame); | |
428 | 3969 DEFSUBR (Fframe_property); |
3970 DEFSUBR (Fframe_properties); | |
3971 DEFSUBR (Fset_frame_properties); | |
3972 DEFSUBR (Fframe_pixel_height); | |
1125 | 3973 DEFSUBR (Fframe_displayable_pixel_height); |
428 | 3974 DEFSUBR (Fframe_pixel_width); |
1125 | 3975 DEFSUBR (Fframe_displayable_pixel_width); |
428 | 3976 DEFSUBR (Fframe_name); |
3977 DEFSUBR (Fframe_modified_tick); | |
3978 DEFSUBR (Fset_frame_height); | |
3979 DEFSUBR (Fset_frame_width); | |
3980 DEFSUBR (Fset_frame_size); | |
863 | 3981 DEFSUBR (Fset_frame_pixel_height); |
1125 | 3982 DEFSUBR (Fset_frame_displayable_pixel_height); |
863 | 3983 DEFSUBR (Fset_frame_pixel_width); |
1125 | 3984 DEFSUBR (Fset_frame_displayable_pixel_width); |
863 | 3985 DEFSUBR (Fset_frame_pixel_size); |
1125 | 3986 DEFSUBR (Fset_frame_displayable_pixel_size); |
428 | 3987 DEFSUBR (Fset_frame_position); |
3988 DEFSUBR (Fset_frame_pointer); | |
442 | 3989 DEFSUBR (Fprint_job_page_number); |
3990 DEFSUBR (Fprint_job_eject_page); | |
428 | 3991 } |
3992 | |
3993 void | |
3994 vars_of_frame (void) | |
3995 { | |
3996 /* */ | |
3997 Vframe_being_created = Qnil; | |
3998 staticpro (&Vframe_being_created); | |
3999 | |
4000 #ifdef HAVE_CDE | |
4001 Fprovide (intern ("cde")); | |
4002 #endif | |
4003 | |
4004 #if 0 /* FSFmacs stupidity */ | |
4005 xxDEFVAR_LISP ("emacs-iconified", &Vemacs_iconified /* | |
4006 Non-nil if all of emacs is iconified and frame updates are not needed. | |
4007 */ ); | |
4008 Vemacs_iconified = Qnil; | |
4009 #endif | |
4010 | |
4011 DEFVAR_LISP ("select-frame-hook", &Vselect_frame_hook /* | |
4012 Function or functions to run just after a new frame is given the focus. | |
4013 Note that calling `select-frame' does not necessarily set the focus: | |
4014 The actual window-system focus will not be changed until the next time | |
4015 that XEmacs is waiting for an event, and even then, the window manager | |
4016 may refuse the focus-change request. | |
4017 */ ); | |
4018 Vselect_frame_hook = Qnil; | |
4019 | |
4020 DEFVAR_LISP ("deselect-frame-hook", &Vdeselect_frame_hook /* | |
4021 Function or functions to run just before a frame loses the focus. | |
4022 See `select-frame-hook'. | |
4023 */ ); | |
4024 Vdeselect_frame_hook = Qnil; | |
4025 | |
4026 DEFVAR_LISP ("delete-frame-hook", &Vdelete_frame_hook /* | |
4027 Function or functions to call when a frame is deleted. | |
4028 One argument, the about-to-be-deleted frame. | |
4029 */ ); | |
4030 Vdelete_frame_hook = Qnil; | |
4031 | |
4032 DEFVAR_LISP ("create-frame-hook", &Vcreate_frame_hook /* | |
4033 Function or functions to call when a frame is created. | |
4034 One argument, the newly-created frame. | |
4035 */ ); | |
4036 Vcreate_frame_hook = Qnil; | |
4037 | |
4038 DEFVAR_LISP ("mouse-enter-frame-hook", &Vmouse_enter_frame_hook /* | |
4039 Function or functions to call when the mouse enters a frame. | |
4040 One argument, the frame. | |
4041 Be careful not to make assumptions about the window manager's focus model. | |
4042 In most cases, the `deselect-frame-hook' is more appropriate. | |
4043 */ ); | |
4044 Vmouse_enter_frame_hook = Qnil; | |
4045 | |
4046 DEFVAR_LISP ("mouse-leave-frame-hook", &Vmouse_leave_frame_hook /* | |
4047 Function or functions to call when the mouse leaves a frame. | |
4048 One argument, the frame. | |
4049 Be careful not to make assumptions about the window manager's focus model. | |
4050 In most cases, the `select-frame-hook' is more appropriate. | |
4051 */ ); | |
4052 Vmouse_leave_frame_hook = Qnil; | |
4053 | |
4054 DEFVAR_LISP ("map-frame-hook", &Vmap_frame_hook /* | |
4055 Function or functions to call when a frame is mapped. | |
4056 One argument, the frame. | |
4057 */ ); | |
4058 Vmap_frame_hook = Qnil; | |
4059 | |
4060 DEFVAR_LISP ("unmap-frame-hook", &Vunmap_frame_hook /* | |
4061 Function or functions to call when a frame is unmapped. | |
4062 One argument, the frame. | |
4063 */ ); | |
4064 Vunmap_frame_hook = Qnil; | |
4065 | |
4066 DEFVAR_BOOL ("allow-deletion-of-last-visible-frame", | |
4067 &allow_deletion_of_last_visible_frame /* | |
4068 *Non-nil means to assume the force option to delete-frame. | |
4069 */ ); | |
4070 allow_deletion_of_last_visible_frame = 0; | |
4071 | |
4072 DEFVAR_LISP ("adjust-frame-function", &Vadjust_frame_function /* | |
4073 Function or constant controlling adjustment of frame. | |
4074 When scrollbars, toolbars, default font etc. change in frame, the frame | |
4075 needs to be adjusted. The adjustment is controlled by this variable. | |
4076 Legal values are: | |
4077 nil to keep character frame size unchanged when possible (resize) | |
4078 t to keep pixel size unchanged (never resize) | |
4079 function symbol or lambda form. This function must return boolean | |
4080 value which is treated as above. Function is passed one parameter, | |
4081 the frame being adjusted. It function should not modify or delete | |
4082 the frame. | |
4083 */ ); | |
4084 Vadjust_frame_function = Qnil; | |
4085 | |
4086 DEFVAR_LISP ("mouse-motion-handler", &Vmouse_motion_handler /* | |
3577 | 4087 Handler for motion events. Must be a function taking one argument, the event. |
428 | 4088 For most applications, you should use `mode-motion-hook' instead of this. |
3577 | 4089 The default value is `default-mouse-motion-handler'. |
4090 | |
4091 Note that this is NOT a hook variable, so there is no standard way to remove | |
4092 actions from it. Instead, when adding a new kind of action, a hook variable | |
4093 should be defined and initialized to the current value of this variable, then | |
4094 this variable set to a function that runs the new hook. To disable the new | |
4095 actions, use `remove-hook' rather than setting `mouse-motion-handler'. | |
4096 | |
4097 `mouse-motion-hook' in the balloon-help library exemplifies this pattern. | |
428 | 4098 */ ); |
4099 Vmouse_motion_handler = Qnil; | |
4100 | |
4101 DEFVAR_LISP ("synchronize-minibuffers",&Vsynchronize_minibuffers /* | |
4102 Set to t if all minibuffer windows are to be synchronized. | |
4103 This will cause echo area messages to appear in the minibuffers of all | |
4104 visible frames. | |
4105 */ ); | |
4106 Vsynchronize_minibuffers = Qnil; | |
4107 | |
4108 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /* | |
442 | 4109 Controls the title of the window-system window of the selected frame. |
428 | 4110 This is the same format as `modeline-format' with the exception that |
4111 %- is ignored. | |
4112 */ ); | |
442 | 4113 /* #### I would change this unilaterally but for the wrath of the Kyles |
4114 of the world. */ | |
4115 #ifdef WIN32_NATIVE | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
4116 Vframe_title_format = build_ascstring ("%b - XEmacs"); |
442 | 4117 #else |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
4118 Vframe_title_format = build_ascstring ("%S: %b"); |
442 | 4119 #endif |
428 | 4120 |
4121 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /* | |
4122 Controls the title of the icon corresponding to the selected frame. | |
4123 See also the variable `frame-title-format'. | |
4124 */ ); | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
4125 Vframe_icon_title_format = build_ascstring ("%b"); |
428 | 4126 |
4127 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /* | |
4128 The default name to assign to newly-created frames. | |
442 | 4129 This can be overridden by arguments to `make-frame'. This must be a string. |
4130 This is used primarily for picking up X resources, and is *not* the title | |
4131 of the frame. (See `frame-title-format'.) | |
2681 | 4132 |
4133 Previous to 21.5.21, this defaulted to `emacs'; since that release, it has | |
4134 defaulted to `XEmacs'. In the short term you can restore the old default by | |
4135 setting the environment variable USE_EMACS_AS_DEFAULT_APPLICATION_CLASS | |
4136 (which does affect the frame name, despite what it's called) to some value | |
4137 before starting XEmacs, but this is deprecated. | |
428 | 4138 */ ); |
2681 | 4139 Vdefault_frame_name = Qnil; |
428 | 4140 |
4141 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /* | |
4142 Plist of default values for frame creation, other than the first one. | |
4143 These may be set in your init file, like this: | |
4144 | |
4145 \(setq default-frame-plist '(width 80 height 55)) | |
4146 | |
2747 | 4147 Predefined properties are described in `set-frame-properties'. |
4148 | |
428 | 4149 The properties may be in alist format for backward compatibility |
4150 but you should not rely on this behavior. | |
4151 | |
4152 These override values given in window system configuration data, | |
2747 | 4153 including X Windows' defaults database. |
4154 | |
4155 Values for the first Emacs frame are taken from `initial-frame-plist'. | |
4156 Since the first X frame is created before loading your .emacs file, you | |
4157 may wish use the X resource database to avoid flashing. | |
4158 | |
428 | 4159 For values specific to the separate minibuffer frame, see |
2747 | 4160 `minibuffer-frame-plist'. See also the variables `default-x-frame-plist' |
4161 and `default-tty-frame-plist', which are like `default-frame-plist' | |
4162 except that they apply only to X or tty frames, respectively \(whereas | |
4163 `default-frame-plist' applies to all types of frames). | |
428 | 4164 */ ); |
4165 Vdefault_frame_plist = Qnil; | |
4166 | |
4167 DEFVAR_LISP ("frame-icon-glyph", &Vframe_icon_glyph /* | |
4168 Icon glyph used to iconify a frame. | |
4169 */ ); | |
4170 } | |
4171 | |
4172 void | |
4173 complex_vars_of_frame (void) | |
4174 { | |
4175 Vframe_icon_glyph = allocate_glyph (GLYPH_ICON, icon_glyph_changed); | |
4176 } |