annotate src/widget.c @ 5653:db6bea4e5345

(forward-paragraph): Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Fri, 21 Jan 1994 16:30:21 +0000
parents 93bb7e0935ba
children 3929b3fb37ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 /* The emacs frame widget.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 /* Emacs 19 face widget ported by Fred Pierresteguy */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 #include <stdio.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 #include "config.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 #include "lisp.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include "xterm.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #include "frame.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 #include "dispextern.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 #include <X11/StringDefs.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 #include <X11/IntrinsicP.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 #include <X11/cursorfont.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 #include "widgetprv.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 #include <X11/Shell.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 #include <X11/ShellP.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 #define max(a, b) ((a) > (b) ? (a) : (b))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 /* This sucks: this is the first default that x-faces.el tries. This won't
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 be used unless neither the "Emacs.EmacsFrame" resource nor the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 "Emacs.EmacsFrame" resource is set; the frame
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 may have the wrong default size if this font doesn't exist, but some other
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 font that x-faces.el does. The workaround is to specify some font in the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 resource database; I don't know a solution other than duplicating the font-
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 searching code from x-faces.el in this file.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 This also means that if "Emacs.EmacsFrame" is specified as a non-
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 existent font, then Xt is going to substitute "XtDefaultFont" for it,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 which is a different size than this one. The solution for this is to
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 make x-faces.el try to use XtDefaultFont. The problem with that is that
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 XtDefaultFont is almost certainly variable-width.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 #### Perhaps we could have this code explicitly set XtDefaultFont to this?
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 #define DEFAULT_FACE_FONT "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 static void EmacsFrameDestroy (Widget);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 static void EmacsFrameRealize (Widget, XtValueMask*, XSetWindowAttributes*);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 void EmacsFrameResize (Widget widget);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 static Boolean EmacsFrameSetValues (Widget, Widget, Widget,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ArgList, Cardinal *);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 static XtGeometryResult EmacsFrameQueryGeometry (Widget, XtWidgetGeometry*,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 XtWidgetGeometry*);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 #undef XtOffset
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 #define XtOffset(p_type,field) \
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ((Cardinal) (((char *) (&(((p_type)0)->field))) - ((char *)0)))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 #define offset(field) XtOffset(EmacsFrame, emacs_frame.field)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 static XtResource resources[] = {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 {XtNgeometry, XtCGeometry, XtRString, sizeof(String),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 offset (geometry), XtRString, (XtPointer) 0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 {XtNiconic, XtCIconic, XtRBoolean, sizeof(Boolean),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 offset (iconic), XtRImmediate, (XtPointer) False},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 {XtNemacsFrame, XtCEmacsFrame, XtRPointer, sizeof (XtPointer),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 offset (frame), XtRImmediate, 0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 {XtNminibuffer, XtCMinibuffer, XtRInt, sizeof (int),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 offset (minibuffer), XtRImmediate, (XtPointer)0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 {XtNunsplittable, XtCUnsplittable, XtRBoolean, sizeof (Boolean),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 offset (unsplittable), XtRImmediate, (XtPointer)0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 {XtNinternalBorderWidth, XtCInternalBorderWidth, XtRInt, sizeof (int),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 offset (internal_border_width), XtRImmediate, (XtPointer)4},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 {XtNinterline, XtCInterline, XtRInt, sizeof (int),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 offset (interline), XtRImmediate, (XtPointer)0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 offset(font),XtRString, DEFAULT_FACE_FONT},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 offset(foreground_pixel), XtRString, "XtDefaultForeground"},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 offset(cursor_color), XtRString, "XtDefaultForeground"},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 {XtNbarCursor, XtCBarCursor, XtRBoolean, sizeof (Boolean),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 offset (bar_cursor), XtRImmediate, (XtPointer)0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof (Boolean),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 offset (visual_bell), XtRImmediate, (XtPointer)0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 {XtNbellVolume, XtCBellVolume, XtRInt, sizeof (int),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 offset (bell_volume), XtRImmediate, (XtPointer)0},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 };
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 #undef offset
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 /*
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 static XtActionsRec
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 emacsFrameActionsTable [] = {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 {"keypress", key_press},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 {"focus_in", emacs_frame_focus_handler},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 {"focus_out", emacs_frame_focus_handler},
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 };
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 static char
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 emacsFrameTranslations [] = "\
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 <KeyPress>: keypress()\n\
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 <FocusIn>: focus_in()\n\
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 <FocusOut>: focus_out()\n\
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ";
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 EmacsFrameClassRec emacsFrameClassRec = {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 { /* core fields */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 /* superclass */ &widgetClassRec,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 /* class_name */ "EmacsFrame",
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 /* widget_size */ sizeof(EmacsFrameRec),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 /* class_initialize */ 0,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 /* class_part_initialize */ 0,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 /* class_inited */ FALSE,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 /* initialize */ EmacsFrameInitialize,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 /* initialize_hook */ 0,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 /* realize */ EmacsFrameRealize,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 /* actions */ 0, /*emacsFrameActionsTable*/
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 /* num_actions */ 0, /*XtNumber (emacsFrameActionsTable)*/
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 /* resources */ resources,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 /* resource_count */ XtNumber(resources),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 /* xrm_class */ NULLQUARK,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 /* compress_motion */ TRUE,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 /* compress_exposure */ TRUE,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 /* compress_enterleave */ TRUE,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 /* visible_interest */ FALSE,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 /* destroy */ EmacsFrameDestroy,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 /* resize */ EmacsFrameResize,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 /* expose */ XtInheritExpose,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 /* set_values */ EmacsFrameSetValues,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 /* set_values_hook */ 0,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 /* set_values_almost */ XtInheritSetValuesAlmost,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 /* get_values_hook */ 0,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 /* accept_focus */ XtInheritAcceptFocus,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 /* version */ XtVersion,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 /* callback_private */ 0,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 /* tm_table */ 0, /*emacsFrameTranslations*/
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 /* query_geometry */ EmacsFrameQueryGeometry,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 /* display_accelerator */ XtInheritDisplayAccelerator,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 /* extension */ 0
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 };
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 WidgetClass emacsFrameClass = (WidgetClass) &emacsFrameClassRec;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 get_default_char_pixel_size (EmacsFrame ew, int* pixel_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 int* pixel_height)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 /*
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 *pixel_width = XTextWidth (ew->emacs_frame.font, "n", 1);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 *pixel_height =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ew->emacs_frame.font->ascent + ew->emacs_frame.font->descent;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 struct frame* f = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 *pixel_width = FONT_WIDTH (f->display.x->font);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 *pixel_height = FONT_HEIGHT (f->display.x->font);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 pixel_to_char_size (EmacsFrame ew,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 Dimension pixel_width, Dimension pixel_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 int* char_width, int* char_height)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 struct frame* f = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 *char_width = PIXEL_TO_CHAR_WIDTH (f, pixel_width);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 *char_height = PIXEL_TO_CHAR_HEIGHT (f, pixel_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 char_to_pixel_size (EmacsFrame ew, int char_width, int char_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 Dimension* pixel_width, Dimension* pixel_height)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 struct frame* f = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 *pixel_width = CHAR_TO_PIXEL_WIDTH (f, char_width);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 *pixel_height = CHAR_TO_PIXEL_HEIGHT (f, char_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 round_size_to_char (EmacsFrame ew,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 Dimension in_width, Dimension in_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 Dimension* out_width, Dimension* out_height)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 int char_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 int char_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 pixel_to_char_size (ew, in_width, in_height, &char_width, &char_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 char_to_pixel_size (ew, char_width, char_height, out_width, out_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 static Widget
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 get_wm_shell (Widget w)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 Widget wmshell;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 for (wmshell = XtParent (w);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 wmshell && !XtIsWMShell (wmshell);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 wmshell = XtParent (wmshell));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 return wmshell;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 mark_shell_size_user_specified (Widget wmshell)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 if (! XtIsWMShell (wmshell)) abort ();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 /* This is kind of sleazy, but I can't see how else to tell it to make it
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 mark the WM_SIZE_HINTS size as user specified when appropriate. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 /* Can't have static frame locals because of some broken compilers.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 Normally, initializing a variable like this doesn't work in emacs,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 but it's ok in this file because it must come after lastfile (and
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 thus have its data not go into text space) because Xt needs to
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 write to initialized data objects too.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 static Boolean first_frame_p = True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 set_frame_size (EmacsFrame ew)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 /* The widget hierarchy is
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 argv[0] emacsShell pane Frame-NAME
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ApplicationShell EmacsShell Paned EmacsFrame
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 We accept geometry specs in this order:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 *Frame-NAME.geometry
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 *EmacsFrame.geometry
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 Emacs.geometry
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 Other possibilities for widget hierarchies might be
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 argv[0] frame pane Frame-NAME
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 ApplicationShell EmacsShell Paned EmacsFrame
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 or
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 argv[0] Frame-NAME pane Frame-NAME
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ApplicationShell EmacsShell Paned EmacsFrame
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 or
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 argv[0] Frame-NAME pane emacsTextPane
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ApplicationShell EmacsFrame Paned EmacsTextPane
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 With the current setup, the text-display-area is the part which is
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 an emacs "frame", since that's the only part managed by emacs proper
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (the menubar and the parent of the menubar and all that sort of thing
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 are managed by lwlib.)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 The EmacsShell widget is simply a replacement for the Shell widget
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 which is able to deal with using an externally-supplied window instead
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 of always creating its own. It is not actually emacs specific, and
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 should possibly have class "Shell" instead of "EmacsShell" to simplify
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 the resources.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 /* Geometry of the AppShell */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 int app_flags = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 int app_x = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 int app_y = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 unsigned int app_w = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 unsigned int app_h = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 /* Geometry of the EmacsFrame */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 int frame_flags = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 int frame_x = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 int frame_y = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 unsigned int frame_w = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 unsigned int frame_h = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 /* Hairily merged geometry */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 int x = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 int y = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 unsigned int w = ew->emacs_frame.frame->width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 unsigned int h = ew->emacs_frame.frame->height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 int flags = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 Widget wmshell = get_wm_shell ((Widget) ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 Widget app_shell = XtParent ((Widget) wmshell);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 if (! XtIsSubclass (wmshell, shellWidgetClass)) abort ();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 if (! XtIsSubclass (app_shell, shellWidgetClass)) abort ();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 /* If the EmacsFrame doesn't have a geometry but the shell does,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 treat that as the geometry of the frame. (Is this bogus?
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 I'm not sure.) */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 if (ew->emacs_frame.geometry == 0)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 XtVaGetValues (wmshell, XtNgeometry, &ew->emacs_frame.geometry, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 /* If the Shell is iconic, then the EmacsFrame is iconic. (Is
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 this bogus? I'm not sure.) */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 if (!ew->emacs_frame.iconic)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 XtVaGetValues (wmshell, XtNiconic, &ew->emacs_frame.iconic, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 char *geom = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 XtVaGetValues (app_shell, XtNgeometry, &geom, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 if (geom)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 app_flags = XParseGeometry (geom, &app_x, &app_y, &app_w, &app_h);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 if (ew->emacs_frame.geometry)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 frame_flags = XParseGeometry (ew->emacs_frame.geometry,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 &frame_x, &frame_y,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 &frame_w, &frame_h);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 if (first_frame_p)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 /* If this is the first frame created:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 ====================================
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 - Use the ApplicationShell's size/position, if specified.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (This is "Emacs.geometry", or the "-geometry" command line arg.)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 - Else use the EmacsFrame's size/position.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (This is "*Frame-NAME.geometry")
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 - If the AppShell is iconic, the frame should be iconic.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 AppShell comes first so that -geometry always applies to the first
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 frame created, even if there is an "every frame" entry in the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 resource database.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 if (app_flags & (XValue | YValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 x = app_x; y = app_y;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 flags |= (app_flags & (XValue | YValue | XNegative | YNegative));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 else if (frame_flags & (XValue | YValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 x = frame_x; y = frame_y;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 flags |= (frame_flags & (XValue | YValue | XNegative | YNegative));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 if (app_flags & (WidthValue | HeightValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 w = app_w; h = app_h;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 flags |= (app_flags & (WidthValue | HeightValue));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 else if (frame_flags & (WidthValue | HeightValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 w = frame_w; h = frame_h;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 flags |= (frame_flags & (WidthValue | HeightValue));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 /* If the AppShell is iconic, then the EmacsFrame is iconic. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 if (!ew->emacs_frame.iconic)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 XtVaGetValues (app_shell, XtNiconic, &ew->emacs_frame.iconic, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 first_frame_p = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 /* If this is not the first frame created:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 ========================================
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 - use the EmacsFrame's size/position if specified
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 - Otherwise, use the ApplicationShell's size, but not position.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 So that means that one can specify the position of the first frame
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 with "Emacs.geometry" or `-geometry'; but can only specify the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 position of subsequent frames with "*Frame-NAME.geometry".
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 AppShell comes second so that -geometry does not apply to subsequent
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 frames when there is an "every frame" entry in the resource db,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 but does apply to the first frame.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 if (frame_flags & (XValue | YValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 x = frame_x; y = frame_y;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 flags |= (frame_flags & (XValue | YValue | XNegative | YNegative));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 if (frame_flags & (WidthValue | HeightValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 w = frame_w; h = frame_h;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 flags |= (frame_flags & (WidthValue | HeightValue));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 else if (app_flags & (WidthValue | HeightValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 w = app_w;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 h = app_h;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 flags |= (app_flags & (WidthValue | HeightValue));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 struct frame* frame = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 Dimension pixel_width, pixel_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 char shell_position [32];
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 /* Take into account the size of the scrollbar */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 frame->display.x->vertical_scroll_bar_extra
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 = (FRAME_HAS_VERTICAL_SCROLL_BARS (frame)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 ? VERTICAL_SCROLL_BAR_PIXEL_WIDTH (frame)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 : 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 change_frame_size (frame, h, w, 1, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 ew->core.width = pixel_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 ew->core.height = pixel_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 /* If a position was specified, assign it to the shell widget.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (Else WM won't do anything with it.)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 if (flags & (XValue | YValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 /* the tricky things with the sign is to make sure that
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 -0 is printed -0. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 int len;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 char *tem;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 sprintf (shell_position, "=%c%d%c%d",
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 flags & XNegative ? '-' : '+', x < 0 ? -x : x,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 flags & YNegative ? '-' : '+', y < 0 ? -y : y);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 len = strlen (shell_position) + 1;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 tem = (char *) xmalloc (len);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 strncpy (tem, shell_position, len);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 XtVaSetValues (wmshell, XtNgeometry, tem, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 else if (flags & (WidthValue | HeightValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 int len;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 char *tem;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 sprintf (shell_position, "=%dx%d", pixel_width, pixel_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 len = strlen (shell_position) + 1;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 tem = (char *) xmalloc (len);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 strncpy (tem, shell_position, len);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 XtVaSetValues (wmshell, XtNgeometry, tem, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 /* If the geometry spec we're using has W/H components, mark the size
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 in the WM_SIZE_HINTS as user specified. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 if (flags & (WidthValue | HeightValue))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 mark_shell_size_user_specified (wmshell);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 /* Also assign the iconic status of the frame to the Shell, so that
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 the WM sees it. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 XtVaSetValues (wmshell, XtNiconic, ew->emacs_frame.iconic, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 update_wm_hints (EmacsFrame ew)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 Widget wmshell = get_wm_shell ((Widget)ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 int cw;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 int ch;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 Dimension rounded_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 Dimension rounded_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 int char_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 int char_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 int base_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 int base_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 int min_rows = 0, min_cols = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 check_frame_size (ew->emacs_frame.frame, &min_rows, &min_cols);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 pixel_to_char_size (ew, ew->core.width, ew->core.height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 &char_width, &char_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 char_to_pixel_size (ew, char_width, char_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 &rounded_width, &rounded_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 get_default_char_pixel_size (ew, &cw, &ch);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 base_width = (wmshell->core.width - ew->core.width
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 + (rounded_width - (char_width * cw)));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 base_height = (wmshell->core.height - ew->core.height
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 + (rounded_height - (char_height * ch)));
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 /* This is kind of sleazy, but I can't see how else to tell it to
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 make it mark the WM_SIZE_HINTS size as user specified.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 /* ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize;*/
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 XtVaSetValues (wmshell,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 XtNbaseWidth, base_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 XtNbaseHeight, base_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 XtNwidthInc, cw,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 XtNheightInc, ch,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 XtNminWidth, base_width + min_cols * cw,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 XtNminHeight, base_height + min_rows * ch,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 create_frame_gcs (EmacsFrame ew)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 struct frame* s = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 s->display.x->normal_gc =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 s->display.x->reverse_gc =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 s->display.x->cursor_gc =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 setup_frame_gcs (EmacsFrame ew)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 XGCValues gc_values;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 struct frame* s = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 Pixmap blank_stipple, blank_tile;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 static char cursor_bits[] =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 };
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 /* We have to initialize all of our GCs to have a stipple/tile, otherwise
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 XGetGCValues returns uninitialized data when we query the stipple
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (instead of None or something sensible) and it makes things hard.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 This should be fixed for real by not querying the GCs but instead having
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 some GC-based cache instead of the current face-based cache which doesn't
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 effectively cache all of the GC settings we need to use.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 blank_stipple =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 XCreateBitmapFromData (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 cursor_bits, 2, 2);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 /* use fg = 0, bg = 1 below, but it's irrelevant since this pixmap should
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 never actually get used as a background tile!
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 blank_tile =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 XCreatePixmapFromBitmapData (XtDisplay(ew),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 RootWindowOfScreen (XtScreen (ew)),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 cursor_bits, 2, 2, 0, 1, ew->core.depth);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 /* Normal video */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 gc_values.font = ew->emacs_frame.font->fid;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 gc_values.foreground = ew->emacs_frame.foreground_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 gc_values.background = ew->core.background_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 gc_values.graphics_exposures = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 gc_values.stipple = blank_stipple;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 gc_values.tile = blank_tile;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 XChangeGC (XtDisplay (ew), s->display.x->normal_gc,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (GCFont | GCForeground | GCBackground | GCGraphicsExposures
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 | GCStipple | GCTile),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 &gc_values);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 /* Reverse video style. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 gc_values.font = ew->emacs_frame.font->fid;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 gc_values.foreground = ew->core.background_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 gc_values.background = ew->emacs_frame.foreground_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 gc_values.graphics_exposures = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 gc_values.stipple = blank_stipple;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 gc_values.tile = blank_tile;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 XChangeGC (XtDisplay (ew), s->display.x->reverse_gc,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (GCFont | GCForeground | GCBackground | GCGraphicsExposures
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 | GCStipple | GCTile),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 &gc_values);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 /* Cursor has to have an empty stipple. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 gc_values.font = ew->emacs_frame.font->fid;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 gc_values.foreground = ew->core.background_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 gc_values.background = ew->emacs_frame.cursor_color;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 gc_values.graphics_exposures = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 gc_values.tile = blank_tile;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 gc_values.stipple =
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 XCreateBitmapFromData (XtDisplay (ew),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 RootWindowOfScreen (XtScreen (ew)),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 cursor_bits, 16, 16);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 XChangeGC (XtDisplay (ew), s->display.x->cursor_gc,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (GCFont | GCForeground | GCBackground | GCGraphicsExposures
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 | GCStipple | GCTile),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 &gc_values);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 update_various_frame_slots (EmacsFrame ew)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 struct x_display* x = ew->emacs_frame.frame->display.x;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 x->pixel_height = ew->core.height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 x->pixel_width = ew->core.width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 x->internal_border_width = ew->emacs_frame.internal_border_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 update_from_various_frame_slots (EmacsFrame ew)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 struct x_display* x = ew->emacs_frame.frame->display.x;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 ew->core.height = x->pixel_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 ew->core.width = x->pixel_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 ew->core.background_pixel = x->background_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 ew->emacs_frame.internal_border_width = x->internal_border_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 ew->emacs_frame.font = x->font;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 ew->emacs_frame.foreground_pixel = x->foreground_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 ew->emacs_frame.cursor_color = x->cursor_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 ew->core.border_pixel = x->border_pixel;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 EmacsFrameInitialize (Widget request, Widget new,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 ArgList dum1, Cardinal *dum2)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 EmacsFrame ew = (EmacsFrame)new;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 if (!ew->emacs_frame.frame)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 fprintf (stderr,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 "can't create an emacs frame widget without a frame\n");
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 exit (1);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 #if 0 /* done in xfns.c */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 /* If the "Emacs.EmacsFrame.{default,Face}.{attributeFont,AttributeFont}"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 resource is set, then it always overrides "Emacs.EmacsFrame.{font,Font}".
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 It's unfortunate that we have to do this, but we need to know the font
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 size for frame-sizing purposes before the faces get initialized. If
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 the "default.attributeFont" isn't set, then we use the font of this
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 EmacsFrame itself, defaulting to XtDefaultFont. Up in the lisp code,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 the "default" face will use the frame's font if its own is not set,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 so everything stays in sync -- it's not possible for the frame's font
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 and the default face's font to be different.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 XFontStruct *f = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 XtResource face_res;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 face_res.resource_name = "attributeFont";
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 face_res.resource_class = "AttributeFont";
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 face_res.resource_type = XtRFontStruct;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 face_res.resource_size = sizeof (XFontStruct *);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 face_res.resource_offset = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 face_res.default_type = XtRImmediate;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 face_res.default_addr = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 XtGetSubresources ((Widget) ew, (XtPointer) &f, "default", "Face",
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 &face_res, 1, NULL, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 if (f)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 ew->emacs_frame.font = f;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 else if (! ew->emacs_frame.font)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 fprintf (stderr, "emacs frame widget could not load a font\n");
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 exit (1);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 /* Update the font field in frame */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 ew->emacs_frame.frame->display.x->font = ew->emacs_frame.font;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 #endif
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 update_from_various_frame_slots (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 set_frame_size (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 /*create_frame_gcs (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 setup_frame_gcs (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 update_various_frame_slots (ew); */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 EmacsFrameRealize (Widget widget, XtValueMask *mask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 XSetWindowAttributes *attrs)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 EmacsFrame ew = (EmacsFrame)widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 attrs->event_mask = (KeyPressMask | ExposureMask | ButtonPressMask |
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 ButtonReleaseMask | StructureNotifyMask |
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 FocusChangeMask | PointerMotionHintMask |
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 PointerMotionMask | LeaveWindowMask | EnterWindowMask |
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 VisibilityChangeMask | PropertyChangeMask |
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 StructureNotifyMask | SubstructureNotifyMask |
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 SubstructureRedirectMask);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 *mask |= CWEventMask;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 attrs);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 update_wm_hints (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 extern void free_frame_faces (struct frame *);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 EmacsFrameDestroy (Widget widget)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 EmacsFrame ew = (EmacsFrame) widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 struct frame* s = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 if (! s) abort ();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 if (! s->display.x) abort ();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 if (! s->display.x->normal_gc) abort ();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 /* this would be called from Fdelete_frame() but it needs to free some
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 stuff after the widget has been finalized but before the widget has
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 been freed. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 free_frame_faces (s);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 /* need to be careful that the face-freeing code doesn't free these too */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 XFreeGC (XtDisplay (widget), s->display.x->normal_gc);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 XFreeGC (XtDisplay (widget), s->display.x->reverse_gc);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 XFreeGC (XtDisplay (widget), s->display.x->cursor_gc);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 EmacsFrameResize (Widget widget)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 EmacsFrame ew = (EmacsFrame)widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 struct frame *f = ew->emacs_frame.frame;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 int columns;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 int rows;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 change_frame_size (f, rows, columns, 1, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 update_wm_hints (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 Window win, child;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 int win_x, win_y;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 /* Find the position of the outside upper-left corner of
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 the window, in the root coordinate system. Don't
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 refer to the parent window here; we may be processing
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 this event after the window manager has changed our
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 parent, but before we have reached the ReparentNotify. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 XTranslateCoordinates (x_current_display,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 /* From-window, to-window. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 XtWindow(XtParent(ew)),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 ROOT_WINDOW,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 /* From-position, to-position. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 -f->display.x->widget->core.border_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 -f->display.x->widget->core.border_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 &win_x, &win_y,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 /* Child of win. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 &child);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 f->display.x->widget->core.x = win_x;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 f->display.x->widget->core.y = win_y;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 update_various_frame_slots (ew);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 static Boolean
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 ArgList dum1, Cardinal *dum2)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 EmacsFrame cur = (EmacsFrame)cur_widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 EmacsFrame new = (EmacsFrame)new_widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 Boolean needs_a_refresh = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 Boolean has_to_recompute_size;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 Boolean has_to_recompute_gcs;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 Boolean has_to_update_hints;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 int char_width, char_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 Dimension pixel_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 Dimension pixel_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 has_to_recompute_gcs = (cur->emacs_frame.font != new->emacs_frame.font
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 || (cur->emacs_frame.foreground_pixel
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 != new->emacs_frame.foreground_pixel)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 || (cur->core.background_pixel
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 != new->core.background_pixel)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 );
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 has_to_recompute_size = (cur->emacs_frame.font != new->emacs_frame.font
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 && cur->core.width == new->core.width
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 && cur->core.height == new->core.height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 has_to_update_hints = (cur->emacs_frame.font != new->emacs_frame.font);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 if (has_to_recompute_gcs)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 setup_frame_gcs (new);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 needs_a_refresh = True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 if (has_to_recompute_size)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 pixel_width = new->core.width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 pixel_height = new->core.height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 pixel_to_char_size (new, pixel_width, pixel_height, &char_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 &char_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 char_to_pixel_size (new, char_width, char_height, &pixel_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 &pixel_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 new->core.width = pixel_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 new->core.height = pixel_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 change_frame_size (new->emacs_frame.frame, char_height, char_width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 1, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 needs_a_refresh = True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 if (has_to_update_hints)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 update_wm_hints (new);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 update_various_frame_slots (new);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 /* #### This doesn't work, I haven't been able to find ANY kludge that
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 will let (x-create-frame '((iconic . t))) work. It seems that changes
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 to wm_shell's iconic slot have no effect after it has been realized,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 and calling XIconifyWindow doesn't work either (even thought the window
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 has been created.) Perhaps there is some property we could smash
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 directly, but I'm sick of this for now. Xt is a steaming pile of shit!
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 if (cur->emacs_frame.iconic != new->emacs_frame.iconic)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 Widget wmshell = get_wm_shell ((Widget) cur);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 XtVaSetValues (wmshell, XtNiconic, new->emacs_frame.iconic, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 return needs_a_refresh;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 static XtGeometryResult
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry* request,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 XtWidgetGeometry* result)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 EmacsFrame ew = (EmacsFrame)widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 int mask = request->request_mode;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 Dimension ok_width, ok_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 if (mask & (CWWidth | CWHeight))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 round_size_to_char (ew,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 (mask & CWWidth) ? request->width : ew->core.width,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 ((mask & CWHeight) ? request->height
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 : ew->core.height),
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 &ok_width, &ok_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 if ((mask & CWWidth) && (ok_width != request->width))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 result->request_mode |= CWWidth;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 result->width = ok_width;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 if ((mask & CWHeight) && (ok_height != request->height))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 result->request_mode |= CWHeight;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 result->height = ok_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 return result->request_mode ? XtGeometryAlmost : XtGeometryYes;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 #if 0
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 /* I don't know why this is necessary; Matthieu said he had to do
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 it to make the focus handlers work??
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 key_press (Widget w, XEvent* event, String *params, Cardinal *n_params)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 static void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 emacs_frame_focus_handler (Widget w, XEvent *event, String *params,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 Cardinal *n_params)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 emacs_Xt_focus_event_handler (event, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 #endif
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 /* Special entrypoints */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 void
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 EmacsFrameSetCharSize (Widget widget, int columns, int rows)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 EmacsFrame ew = (EmacsFrame) widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 Dimension pixel_width, pixel_height, granted_width, granted_height;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 XtGeometryResult result;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 if (columns < 3) columns = 3; /* no way buddy */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 if (rows < 3) rows = 3;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 char_to_pixel_size (ew, columns, rows, &pixel_width, &pixel_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 result = XtMakeResizeRequest ((Widget)ew,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 pixel_width, pixel_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 &granted_width, &granted_height);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 if (result == XtGeometryAlmost)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 XtMakeResizeRequest ((Widget) ew, granted_width, granted_height,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 NULL, NULL);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 /* damn Paned widget won't ever change its width. Force it. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 if (ew->core.width != pixel_width)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 XtVaSetValues (XtParent ((Widget) ew), XtNwidth, pixel_width, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 XtVaSetValues ((Widget) ew, XtNwidth, pixel_width, 0);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 }