0
|
1 /* The emacs frame widget.
|
|
2 Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1993-1995 Sun Microsystems, Inc.
|
|
4 Copyright (C) 1995 Ben Wing.
|
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
|
25 /* #### Note to potential hackers: Don't mess with this unless you're
|
|
26 sure you know what you're doing! Xt is a lot more subtle than
|
|
27 you may think. */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31
|
|
32 #include "console-x.h"
|
|
33 #include "glyphs-x.h"
|
|
34 #include "objects-x.h"
|
|
35 #include <X11/Shell.h>
|
|
36 #include "EmacsFrameP.h"
|
|
37 #include "EmacsManager.h" /* for EmacsManagerChangeSize */
|
|
38 #include "xmu.h"
|
|
39
|
|
40 #include "faces.h"
|
|
41 #include "frame.h"
|
|
42 #include "toolbar.h"
|
|
43 #include "redisplay.h"
|
|
44 #include "window.h"
|
|
45
|
|
46 static void EmacsFrameClassInitialize (void);
|
|
47 static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *);
|
|
48 static void EmacsFrameRealize (Widget, XtValueMask*, XSetWindowAttributes*);
|
|
49 static void EmacsFrameResize (Widget widget);
|
|
50 static Boolean EmacsFrameSetValues (Widget, Widget, Widget,
|
|
51 ArgList, Cardinal *);
|
|
52 static XtGeometryResult EmacsFrameQueryGeometry (Widget, XtWidgetGeometry*,
|
|
53 XtWidgetGeometry*);
|
|
54
|
|
55 extern void
|
185
|
56 emacs_Xt_mapping_action (Widget w, XEvent* event);
|
0
|
57
|
|
58 #undef XtOffset
|
|
59 #define XtOffset(p_type,field) \
|
|
60 ((Cardinal) (((char *) (&(((p_type)0)->field))) - ((char *)0)))
|
|
61 #define offset(field) XtOffset(EmacsFrame, emacs_frame.field)
|
|
62
|
|
63 static XtResource resources[] = {
|
|
64 {XtNgeometry, XtCGeometry, XtRString, sizeof(String),
|
|
65 offset (geometry), XtRString, (XtPointer) 0},
|
|
66 {XtNiconic, XtCIconic, XtRBoolean, sizeof(Boolean),
|
|
67 offset (iconic), XtRImmediate, (XtPointer) False},
|
|
68
|
|
69 {XtNemacsFrame, XtCEmacsFrame, XtRPointer, sizeof (XtPointer),
|
|
70 offset (frame), XtRImmediate, 0},
|
|
71 {XtNmenubar, XtCMenubar, XtRBoolean, sizeof (Boolean),
|
|
72 offset (menubar_p), XtRImmediate, (XtPointer) True},
|
|
73 {XtNinitiallyUnmapped, XtCInitiallyUnmapped, XtRBoolean, sizeof (Boolean),
|
|
74 offset (initially_unmapped), XtRImmediate, (XtPointer) False},
|
|
75 {XtNminibuffer, XtCMinibuffer, XtRBoolean, sizeof (Boolean),
|
|
76 offset (minibuffer), XtRImmediate, (XtPointer) True},
|
|
77 {XtNunsplittable, XtCUnsplittable, XtRBoolean, sizeof (Boolean),
|
|
78 offset (unsplittable), XtRImmediate, (XtPointer) False},
|
|
79 {XtNinternalBorderWidth, XtCInternalBorderWidth, XtRInt, sizeof (int),
|
|
80 offset (internal_border_width), XtRImmediate, (XtPointer)4},
|
|
81 #ifdef HAVE_SCROLLBARS
|
|
82 {XtNscrollBarWidth, XtCScrollBarWidth, XtRInt, sizeof (int),
|
|
83 offset (scrollbar_width), XtRImmediate, (XtPointer)-1},
|
|
84 {XtNscrollBarHeight, XtCScrollBarHeight, XtRInt, sizeof (int),
|
|
85 offset (scrollbar_height), XtRImmediate, (XtPointer)-1},
|
|
86 {XtNscrollBarPlacement, XtCScrollBarPlacement, XtRScrollBarPlacement,
|
|
87 sizeof(unsigned char), offset(scrollbar_placement), XtRImmediate,
|
82
|
88 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \
|
|
89 defined (LWLIB_SCROLLBARS_ATHENA3D)
|
0
|
90 (XtPointer) XtBOTTOM_RIGHT
|
|
91 #else
|
|
92 (XtPointer) XtBOTTOM_LEFT
|
|
93 #endif
|
|
94 },
|
|
95 #endif /* HAVE_SCROLLBARS */
|
|
96 #ifdef HAVE_TOOLBARS
|
|
97 {XtNtopToolBarHeight, XtCTopToolBarHeight, XtRInt, sizeof (int),
|
|
98 offset (top_toolbar_height), XtRImmediate, (XtPointer)-1},
|
|
99 {XtNbottomToolBarHeight, XtCBottomToolBarHeight, XtRInt, sizeof (int),
|
|
100 offset (bottom_toolbar_height), XtRImmediate, (XtPointer)-1},
|
|
101 {XtNleftToolBarWidth, XtCLeftToolBarWidth, XtRInt, sizeof (int),
|
|
102 offset (left_toolbar_width), XtRImmediate, (XtPointer)-1},
|
|
103 {XtNrightToolBarWidth, XtCRightToolBarWidth, XtRInt, sizeof (int),
|
|
104 offset (right_toolbar_width), XtRImmediate, (XtPointer)-1},
|
215
|
105 {XtNtopToolBarBorderWidth, XtCTopToolBarBorderWidth, XtRInt,
|
|
106 sizeof (int),
|
|
107 offset (top_toolbar_border_width), XtRImmediate, (XtPointer)-1},
|
|
108 {XtNbottomToolBarBorderWidth, XtCBottomToolBarBorderWidth, XtRInt,
|
|
109 sizeof (int),
|
|
110 offset (bottom_toolbar_border_width), XtRImmediate, (XtPointer)-1},
|
|
111 {XtNleftToolBarBorderWidth, XtCLeftToolBarBorderWidth, XtRInt,
|
|
112 sizeof (int),
|
|
113 offset (left_toolbar_border_width), XtRImmediate, (XtPointer)-1},
|
|
114 {XtNrightToolBarBorderWidth, XtCRightToolBarBorderWidth, XtRInt,
|
|
115 sizeof (int),
|
|
116 offset (right_toolbar_border_width), XtRImmediate, (XtPointer)-1},
|
0
|
117 {XtNtopToolBarShadowColor, XtCTopToolBarShadowColor, XtRPixel, sizeof(Pixel),
|
183
|
118 offset(top_toolbar_shadow_pixel), XtRString, "#000000"},
|
0
|
119 {XtNbottomToolBarShadowColor, XtCBottomToolBarShadowColor, XtRPixel,
|
183
|
120 sizeof(Pixel), offset(bottom_toolbar_shadow_pixel), XtRString, "#000000"},
|
0
|
121 {XtNbackgroundToolBarColor, XtCBackgroundToolBarColor, XtRPixel,
|
183
|
122 sizeof(Pixel), offset(background_toolbar_pixel), XtRString, "Gray75"},
|
0
|
123 {XtNtopToolBarShadowPixmap, XtCTopToolBarShadowPixmap, XtRPixmap,
|
|
124 sizeof (Pixmap), offset(top_toolbar_shadow_pixmap), XtRImmediate,
|
|
125 (XtPointer)None},
|
|
126 {XtNbottomToolBarShadowPixmap, XtCBottomToolBarShadowPixmap, XtRPixmap,
|
|
127 sizeof (Pixmap), offset(bottom_toolbar_shadow_pixmap), XtRImmediate,
|
|
128 (XtPointer)None},
|
|
129 {XtNtoolBarShadowThickness, XtCToolBarShadowThickness, XtRDimension,
|
|
130 sizeof (Dimension), offset (toolbar_shadow_thickness), XtRImmediate,
|
|
131 (XtPointer)2},
|
|
132 #endif /* HAVE_TOOLBARS */
|
|
133 {XtNinterline, XtCInterline, XtRInt, sizeof (int),
|
|
134 offset (interline), XtRImmediate, (XtPointer)0},
|
|
135 {
|
|
136 #ifdef I18N4
|
|
137 XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
|
|
138 #else
|
|
139 XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
|
|
140 #endif
|
|
141 offset(font), XtRImmediate, (XtPointer)0
|
|
142 },
|
|
143 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
|
183
|
144 offset(foreground_pixel), XtRString, "XtDefaultForeground"},
|
215
|
145 {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
|
|
146 offset(background_pixel), XtRImmediate, (XtPointer)-1},
|
0
|
147 {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel),
|
183
|
148 offset(cursor_color), XtRString, "XtDefaultForeground"},
|
0
|
149 {XtNbarCursor, XtCBarCursor, XtRBoolean, sizeof (Boolean),
|
|
150 offset (bar_cursor), XtRImmediate, (XtPointer)0},
|
|
151 {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof (Boolean),
|
|
152 offset (visual_bell), XtRImmediate, (XtPointer)0},
|
|
153 {XtNbellVolume, XtCBellVolume, XtRInt, sizeof (int),
|
|
154 offset (bell_volume), XtRImmediate, (XtPointer)0},
|
|
155 {XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, sizeof (Boolean),
|
|
156 offset (use_backing_store), XtRImmediate, (XtPointer)0},
|
|
157 {XtNpreferredWidth, XtCPreferredWidth, XtRDimension, sizeof (Dimension),
|
|
158 offset (preferred_width), XtRImmediate, (XtPointer)0},
|
|
159 {XtNpreferredHeight, XtCPreferredHeight, XtRDimension, sizeof (Dimension),
|
|
160 offset (preferred_height), XtRImmediate, (XtPointer)0},
|
|
161 };
|
|
162
|
|
163 #undef offset
|
|
164
|
|
165 /* Xt is stupid and dumb.
|
|
166 Xt is stupid and dumb.
|
|
167 Xt is stupid and dumb. */
|
|
168
|
|
169 static XtActionsRec
|
|
170 emacsFrameActionsTable [] = {
|
183
|
171 {"mapping", (XtActionProc) emacs_Xt_mapping_action},
|
0
|
172 };
|
|
173
|
|
174 static char
|
|
175 emacsFrameTranslations [] = "\
|
|
176 <Mapping>: mapping()\n\
|
|
177 ";
|
|
178
|
|
179 /* If we're running under Motif, make this widget a subclass
|
|
180 of XmPrimitive. It's not clear this is necessary, but it
|
|
181 may make focus behavior work better. */
|
|
182
|
|
183 EmacsFrameClassRec emacsFrameClassRec = {
|
|
184 { /* core fields */
|
|
185 #ifdef LWLIB_USES_MOTIF
|
|
186 /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
|
|
187 #else
|
|
188 /* superclass */ &widgetClassRec,
|
|
189 #endif
|
183
|
190 /* class_name */ "EmacsFrame",
|
0
|
191 /* widget_size */ sizeof(EmacsFrameRec),
|
|
192 /* class_initialize */ EmacsFrameClassInitialize,
|
|
193 /* class_part_initialize */ 0,
|
|
194 /* class_inited */ FALSE,
|
|
195 /* initialize */ EmacsFrameInitialize,
|
|
196 /* initialize_hook */ 0,
|
|
197 /* realize */ EmacsFrameRealize,
|
|
198 /* actions */ emacsFrameActionsTable,
|
|
199 /* num_actions */ XtNumber (emacsFrameActionsTable),
|
|
200 /* resources */ resources,
|
|
201 /* resource_count */ XtNumber(resources),
|
|
202 /* xrm_class */ NULLQUARK,
|
|
203 /* compress_motion */ TRUE,
|
|
204 /* compress_exposure */ TRUE,
|
|
205 /* compress_enterleave */ TRUE,
|
|
206 /* visible_interest */ FALSE,
|
|
207 /* destroy */ NULL,
|
|
208 /* resize */ EmacsFrameResize,
|
|
209 /* expose */ XtInheritExpose,
|
|
210 /* set_values */ EmacsFrameSetValues,
|
|
211 /* set_values_hook */ 0,
|
|
212 /* set_values_almost */ XtInheritSetValuesAlmost,
|
|
213 /* get_values_hook */ 0,
|
|
214 /* accept_focus */ XtInheritAcceptFocus,
|
|
215 /* version */ XtVersion,
|
|
216 /* callback_private */ 0,
|
|
217 /* tm_table */ emacsFrameTranslations,
|
|
218 /* query_geometry */ EmacsFrameQueryGeometry,
|
|
219 /* display_accelerator */ XtInheritDisplayAccelerator,
|
|
220 /* extension */ 0
|
|
221 },
|
|
222 #ifdef LWLIB_USES_MOTIF
|
|
223 { /* XmPrimitiveClassPart
|
|
224 */
|
|
225 (XtWidgetProc) _XtInherit, /* border_highlight */
|
|
226 (XtWidgetProc) _XtInherit, /* border_unhighlight */
|
|
227 /* Setting the following to NULL causes PrimitiveInitialize()
|
|
228 not to add traversal (TAB etc. to switch focus) and
|
|
229 focus-in/out (border highlight/unhighlight) translations.
|
|
230 If you want those translations, use the value XtInheritTranslations
|
|
231 instead. Doing this, however, will interfere with Emacs
|
|
232 focus handling (which highlights/unhighlights the text cursor),
|
|
233 and will lead to strange display results around the border of the
|
|
234 widget. */
|
|
235 NULL, /* translations */
|
|
236 NULL, /* arm_and_activate */
|
|
237 NULL, /* get resources */
|
|
238 0, /* num get_resources */
|
|
239 NULL, /* extension */
|
|
240 },
|
|
241 #endif /* LWLIB_USES_MOTIF */
|
|
242 {
|
|
243 0
|
|
244 }
|
|
245 };
|
|
246 WidgetClass emacsFrameClass = (WidgetClass) &emacsFrameClassRec;
|
|
247
|
|
248 static void
|
|
249 update_various_frame_slots (EmacsFrame ew)
|
|
250 {
|
|
251 ew->emacs_frame.frame->pixheight = ew->core.height;
|
|
252 ew->emacs_frame.frame->pixwidth = ew->core.width;
|
|
253 ew->emacs_frame.frame->internal_border_width =
|
|
254 ew->emacs_frame.internal_border_width;
|
|
255 }
|
|
256
|
183
|
257 static void
|
0
|
258 EmacsFrameInitialize (Widget request, Widget new,
|
|
259 ArgList dum1, Cardinal *dum2)
|
|
260 {
|
|
261 EmacsFrame ew = (EmacsFrame)new;
|
|
262 struct frame *f = ew->emacs_frame.frame;
|
|
263
|
|
264 if (!f)
|
|
265 fatal ("can't create an emacs frame widget without a frame.");
|
|
266 }
|
|
267
|
|
268 void emacs_Xt_event_handler (Widget wid /* unused */,
|
|
269 XtPointer closure /* unused */,
|
|
270 XEvent *event,
|
|
271 Boolean *continue_to_dispatch /* unused */);
|
|
272
|
|
273 static void
|
|
274 EmacsFrameRealize (Widget widget, XtValueMask *mask,
|
|
275 XSetWindowAttributes *attrs)
|
|
276 {
|
|
277 EmacsFrame ew = (EmacsFrame) widget;
|
|
278 struct frame *f = ew->emacs_frame.frame;
|
|
279 Widget shell_widget = FRAME_X_SHELL_WIDGET (f);
|
|
280
|
2
|
281 attrs->event_mask =
|
|
282 ExposureMask |
|
|
283 VisibilityChangeMask |
|
|
284 PropertyChangeMask |
|
|
285 StructureNotifyMask |
|
|
286 SubstructureNotifyMask |
|
|
287 /*SubstructureRedirectMask |*/ /* Only for WMs! */
|
|
288 KeyPressMask |
|
|
289 KeyReleaseMask |
|
|
290 ButtonPressMask |
|
|
291 ButtonReleaseMask |
|
|
292 FocusChangeMask |
|
|
293 PointerMotionHintMask |
|
|
294 PointerMotionMask |
|
|
295 LeaveWindowMask |
|
|
296 EnterWindowMask;
|
|
297
|
0
|
298
|
|
299 #ifdef I18N4
|
|
300 /* Make sure that events wanted by the input method are selected. */
|
|
301 attrs->event_mask |= input_method_event_mask;
|
|
302 #endif
|
|
303
|
|
304 *mask |= CWEventMask;
|
|
305
|
|
306 if (ew->emacs_frame.use_backing_store)
|
|
307 {
|
|
308 attrs->backing_store = Always;
|
|
309 *mask |= CWBackingStore;
|
|
310 }
|
|
311 XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask,
|
|
312 attrs);
|
|
313
|
|
314 /* snarf the events we want. */
|
|
315 XtInsertEventHandler (widget, attrs->event_mask, TRUE,
|
|
316 emacs_Xt_event_handler, NULL, XtListHead);
|
|
317 /* some events (e.g. map-notify and WM_DELETE_WINDOW) get sent
|
|
318 directly to the shell, and the above event handler won't see
|
|
319 them. So add a handler to get them. These events don't
|
|
320 propagate, so there's no danger of them being seen twice. */
|
|
321 XtInsertEventHandler (shell_widget,
|
|
322 EnterWindowMask | LeaveWindowMask |
|
|
323 VisibilityChangeMask | StructureNotifyMask |
|
|
324 KeyPressMask,
|
|
325 TRUE, emacs_Xt_event_handler, NULL, XtListHead);
|
|
326
|
|
327 #ifdef EXTERNAL_WIDGET
|
|
328 /* #### Not sure if this special case is necessary */
|
|
329 if (!FRAME_X_EXTERNAL_WINDOW_P (f))
|
|
330 #endif
|
|
331 /* This is necessary under Motif in order to make it possible to click in
|
|
332 a buffer and move focus out of a dialog box or control panel and back
|
|
333 into emacs-land; also necessary so that you can still type chars
|
|
334 if the cursor is over the menubar or scrollbar. */
|
|
335 lw_set_keyboard_focus (shell_widget, FRAME_X_TEXT_WIDGET (f));
|
|
336 }
|
|
337
|
|
338 /* DO NOT CALL THIS FUNCTION! Only Xt is supposed to do this. */
|
|
339
|
|
340 static void
|
|
341 EmacsFrameResize (Widget widget)
|
|
342 {
|
|
343 EmacsFrame ew = (EmacsFrame)widget;
|
|
344 struct frame *f = ew->emacs_frame.frame;
|
|
345 int columns;
|
|
346 int rows;
|
|
347 XtWidgetGeometry req, repl;
|
183
|
348
|
0
|
349 pixel_to_char_size (f, ew->core.width, ew->core.height, &columns, &rows);
|
|
350 update_various_frame_slots (ew);
|
|
351 change_frame_size (f, rows, columns, 0);
|
|
352
|
|
353 /* Now we tell the EmacsShell that we've changed the size of the non-fixed
|
|
354 portion of the frame. Note that, if we the resize occurred as a result
|
|
355 of EmacsFrameSetCharSize(), this information will be stored twice.
|
|
356 This is not a big deal, as storing this information doesn't actually
|
|
357 do anything until the next resize. */
|
|
358 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
|
|
359 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows);
|
|
360
|
|
361 /* Kick the manager so that it knows we've changed size. */
|
|
362 req.request_mode = 0;
|
|
363 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
|
|
364 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width,
|
|
365 repl.height);
|
|
366 }
|
|
367
|
|
368 static Boolean
|
|
369 EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget,
|
|
370 ArgList dum1, Cardinal *dum2)
|
|
371 {
|
|
372 EmacsFrame cur = (EmacsFrame) cur_widget;
|
|
373 EmacsFrame new = (EmacsFrame) new_widget;
|
|
374 Lisp_Object frame = Qnil;
|
|
375
|
|
376 XSETFRAME (frame, new->emacs_frame.frame);
|
|
377 in_resource_setting++;
|
|
378 /* This function does not need to do much. Pretty much everything
|
|
379 interesting will get done in the resize method, which will
|
|
380 (if necessary) get called by Xt when this function returns
|
|
381 (see below).
|
|
382 */
|
|
383
|
|
384 /* #### This function will not work if it is not called from
|
|
385 update_EmacsFrame(), called from SET_FACE_PROPERTY().
|
|
386 The code located there should be moved inside of here instead,
|
|
387 so that things work if either SET_FACE_PROPERTY() is
|
|
388 called or XtSetValues() is called.
|
|
389 */
|
|
390
|
|
391 if (cur->emacs_frame.iconic != new->emacs_frame.iconic &&
|
|
392 FRAME_X_TOP_LEVEL_FRAME_P (new->emacs_frame.frame))
|
|
393 x_wm_set_shell_iconic_p (FRAME_X_SHELL_WIDGET (new->emacs_frame.frame),
|
|
394 new->emacs_frame.iconic);
|
|
395
|
|
396 if (!in_specifier_change_function)
|
|
397 {
|
|
398 /* If we got here, then we were likely called as a result of
|
|
399 the EditRes protocol, so go ahead and change scrollbar-width
|
|
400 and scrollbar-height. Otherwise, we're merely mirroring
|
|
401 a change made to scrollbar-width etc. so don't do anything
|
|
402 special. */
|
|
403 #ifdef HAVE_SCROLLBARS
|
|
404 if (cur->emacs_frame.scrollbar_width !=
|
|
405 new->emacs_frame.scrollbar_width)
|
|
406 Fadd_spec_to_specifier
|
|
407 (Vscrollbar_width,
|
|
408 make_int (new->emacs_frame.scrollbar_width),
|
|
409 frame, Qnil, Qnil);
|
|
410 if (cur->emacs_frame.scrollbar_height !=
|
|
411 new->emacs_frame.scrollbar_height)
|
|
412 Fadd_spec_to_specifier
|
|
413 (Vscrollbar_height,
|
|
414 make_int (new->emacs_frame.scrollbar_height),
|
|
415 frame, Qnil, Qnil);
|
183
|
416 #endif /* HAVE_SCROLLBARS */
|
0
|
417 #ifdef HAVE_TOOLBARS
|
|
418 if (cur->emacs_frame.top_toolbar_height !=
|
|
419 new->emacs_frame.top_toolbar_height)
|
|
420 Fadd_spec_to_specifier
|
|
421 (Vtoolbar_size[TOP_TOOLBAR],
|
|
422 make_int (new->emacs_frame.top_toolbar_height),
|
|
423 frame, Qnil, Qnil);
|
|
424 if (cur->emacs_frame.bottom_toolbar_height !=
|
|
425 new->emacs_frame.bottom_toolbar_height)
|
|
426 Fadd_spec_to_specifier
|
|
427 (Vtoolbar_size[BOTTOM_TOOLBAR],
|
|
428 make_int (new->emacs_frame.bottom_toolbar_height),
|
|
429 frame, Qnil, Qnil);
|
|
430 if (cur->emacs_frame.left_toolbar_width !=
|
|
431 new->emacs_frame.left_toolbar_width)
|
|
432 Fadd_spec_to_specifier
|
|
433 (Vtoolbar_size[LEFT_TOOLBAR],
|
|
434 make_int (new->emacs_frame.left_toolbar_width),
|
|
435 frame, Qnil, Qnil);
|
|
436 if (cur->emacs_frame.right_toolbar_width !=
|
|
437 new->emacs_frame.right_toolbar_width)
|
|
438 Fadd_spec_to_specifier
|
|
439 (Vtoolbar_size[RIGHT_TOOLBAR],
|
|
440 make_int (new->emacs_frame.right_toolbar_width),
|
|
441 frame, Qnil, Qnil);
|
215
|
442 if (cur->emacs_frame.top_toolbar_border_width !=
|
|
443 new->emacs_frame.top_toolbar_border_width)
|
|
444 Fadd_spec_to_specifier
|
|
445 (Vtoolbar_border_width[TOP_TOOLBAR],
|
|
446 make_int (new->emacs_frame.top_toolbar_border_width),
|
|
447 frame, Qnil, Qnil);
|
|
448 if (cur->emacs_frame.bottom_toolbar_border_width !=
|
|
449 new->emacs_frame.bottom_toolbar_border_width)
|
|
450 Fadd_spec_to_specifier
|
|
451 (Vtoolbar_border_width[BOTTOM_TOOLBAR],
|
|
452 make_int (new->emacs_frame.bottom_toolbar_border_width),
|
|
453 frame, Qnil, Qnil);
|
|
454 if (cur->emacs_frame.left_toolbar_border_width !=
|
|
455 new->emacs_frame.left_toolbar_border_width)
|
|
456 Fadd_spec_to_specifier
|
|
457 (Vtoolbar_border_width[LEFT_TOOLBAR],
|
|
458 make_int (new->emacs_frame.left_toolbar_border_width),
|
|
459 frame, Qnil, Qnil);
|
|
460 if (cur->emacs_frame.right_toolbar_border_width !=
|
|
461 new->emacs_frame.right_toolbar_border_width)
|
|
462 Fadd_spec_to_specifier
|
|
463 (Vtoolbar_border_width[RIGHT_TOOLBAR],
|
|
464 make_int (new->emacs_frame.right_toolbar_border_width),
|
|
465 frame, Qnil, Qnil);
|
183
|
466 #endif /* HAVE_TOOLBARS */
|
0
|
467 }
|
|
468 in_resource_setting--;
|
|
469
|
|
470 return False;
|
|
471
|
|
472 /* Note that if either (a) we return True, or (b) the width or
|
|
473 height has changed, an Expose event will be generated. The Xt
|
|
474 manual says you should not return True if the width or height has
|
|
475 changed, because then two Expose events will be generated.
|
|
476
|
|
477 In any case, there is no need to return True because
|
|
478 SET_FACE_PROPERTY(), which does the resource
|
|
479 setting, automatically forces a redisplay as necessary. */
|
|
480 }
|
|
481
|
|
482 static XtGeometryResult
|
|
483 EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request,
|
|
484 XtWidgetGeometry *result)
|
|
485 {
|
|
486 EmacsFrame ew = (EmacsFrame) widget;
|
|
487 int mask = request->request_mode;
|
|
488 Dimension width, height;
|
|
489 int ok_width_int, ok_height_int;
|
|
490 Dimension ok_width, ok_height;
|
|
491
|
|
492 /* We have a definite preference for what size we would like
|
|
493 to be.
|
|
494
|
|
495 1) If a preferred size was specified for us, use it.
|
|
496 (This is not currently used)
|
|
497 2) If a proposed size was given, round it to the nearest
|
|
498 multiple of the default char size and return it.
|
|
499 3) Otherwise, take our current size and round it to the
|
|
500 nearest multiple of the default char size. */
|
|
501
|
|
502 width = mask & CWWidth ? request->width : ew->core.width;
|
|
503 height = mask & CWHeight ? request->height : ew->core.height;
|
|
504 round_size_to_char (ew->emacs_frame.frame, width, height,
|
|
505 &ok_width_int, &ok_height_int);
|
|
506 ok_width = (Dimension) ok_width_int;
|
|
507 ok_height = (Dimension) ok_height_int;
|
|
508 if (ew->emacs_frame.preferred_width)
|
|
509 ok_width = ew->emacs_frame.preferred_width;
|
|
510 if (ew->emacs_frame.preferred_height)
|
|
511 ok_height = ew->emacs_frame.preferred_height;
|
|
512 result->request_mode |= CWWidth | CWHeight;
|
|
513 result->width = ok_width;
|
|
514 result->height = ok_height;
|
|
515 if (((mask & CWWidth) && ok_width != request->width)
|
|
516 || ((mask & CWHeight) && ok_height != request->height))
|
|
517 return XtGeometryAlmost;
|
|
518 else
|
|
519 return XtGeometryYes;
|
|
520 }
|
|
521
|
16
|
522 /* Xt string-to-scrollbar-placement converter */
|
|
523 /* ### Convert this to a `new-style' converter (See XtAddTypeConverter) */
|
0
|
524
|
|
525 /* This variable cannot be a stack variable. */
|
|
526 static unsigned char cvt_string_scrollbar_placement;
|
|
527
|
|
528 /* ARGSUSED */
|
|
529 static void
|
183
|
530 Xt_StringToScrollBarPlacement (XrmValuePtr args, /* unused */
|
|
531 Cardinal *num_args, /* unused */
|
|
532 XrmValuePtr fromVal,
|
|
533 XrmValuePtr toVal)
|
0
|
534 {
|
|
535 XrmQuark q;
|
183
|
536 char *lowerName = (char *) alloca (strlen ((char *) fromVal->addr) + 1);
|
|
537
|
70
|
538 XmuCopyISOLatin1Lowered (lowerName, (char *) fromVal->addr);
|
|
539 q = XrmStringToQuark (lowerName);
|
183
|
540
|
70
|
541 toVal->size = sizeof (cvt_string_scrollbar_placement);
|
185
|
542 toVal->addr = (XPointer) &cvt_string_scrollbar_placement;
|
70
|
543
|
183
|
544 if (q == XrmStringToQuark ("top_left"))
|
|
545 cvt_string_scrollbar_placement = XtTOP_LEFT;
|
|
546 else if (q == XrmStringToQuark ("bottom_left"))
|
|
547 cvt_string_scrollbar_placement = XtBOTTOM_LEFT;
|
|
548 else if (q == XrmStringToQuark ("top_right"))
|
|
549 cvt_string_scrollbar_placement = XtTOP_RIGHT;
|
|
550 else if (q == XrmStringToQuark ("bottom_right"))
|
|
551 cvt_string_scrollbar_placement = XtBOTTOM_RIGHT;
|
|
552 else
|
80
|
553 {
|
183
|
554 XtStringConversionWarning (fromVal->addr, "scrollBarPlacement");
|
|
555 toVal->addr = NULL;
|
|
556 toVal->size = 0;
|
80
|
557 }
|
0
|
558 }
|
|
559
|
|
560 static void
|
|
561 EmacsFrameClassInitialize (void)
|
|
562 {
|
|
563 XtAddConverter (XtRString, XtRScrollBarPlacement,
|
183
|
564 Xt_StringToScrollBarPlacement, NULL, 0);
|
0
|
565 }
|
|
566
|
|
567 /********************* Special entrypoints *******************/
|
|
568
|
|
569 void
|
|
570 EmacsFrameRecomputeCellSize (Widget w)
|
|
571 {
|
|
572 EmacsFrame ew = (EmacsFrame) w;
|
|
573 int cw, ch;
|
|
574 struct frame *f = ew->emacs_frame.frame;
|
|
575
|
|
576 if (! XtIsSubclass (w, emacsFrameClass))
|
|
577 abort ();
|
|
578
|
|
579 default_face_height_and_width (make_frame (f), &ch, &cw);
|
|
580 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
|
|
581 x_wm_set_cell_size (FRAME_X_SHELL_WIDGET (f), cw, ch);
|
|
582 }
|
|
583
|
|
584 /* Set the size of the widget to have the number of rows and columns
|
|
585 specified. This both causes the X window to change and the
|
|
586 internal frame structures to get modified to match. */
|
|
587
|
|
588 void
|
|
589 EmacsFrameSetCharSize (Widget widget, int columns, int rows)
|
|
590 {
|
|
591 EmacsFrame ew = (EmacsFrame) widget;
|
|
592 int pixel_width, pixel_height;
|
|
593 struct frame *f = ew->emacs_frame.frame;
|
165
|
594 Arg al [2];
|
0
|
595
|
|
596 if (columns < 3)
|
|
597 columns = 3; /* no way buddy */
|
|
598 if (rows < 1)
|
|
599 rows = 1;
|
|
600
|
|
601 char_to_pixel_size (f, columns, rows, &pixel_width, &pixel_height);
|
|
602
|
|
603 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
|
|
604 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows);
|
|
605
|
165
|
606 XtSetArg (al [0], XtNwidth, (Dimension) pixel_width);
|
|
607 XtSetArg (al [1], XtNheight, (Dimension) pixel_height);
|
|
608 XtSetValues ((Widget) ew, al, 2);
|
0
|
609 }
|