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
|
|
56 emacs_Xt_mapping_action (Widget w, XMappingEvent* event);
|
|
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,
|
16
|
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},
|
|
105 {XtNtopToolBarShadowColor, XtCTopToolBarShadowColor, XtRPixel, sizeof(Pixel),
|
2
|
106 offset(top_toolbar_shadow_pixel), XtRString, (String) "Gray90"},
|
0
|
107 {XtNbottomToolBarShadowColor, XtCBottomToolBarShadowColor, XtRPixel,
|
|
108 sizeof(Pixel), offset(bottom_toolbar_shadow_pixel), XtRString,
|
2
|
109 (String) "Gray40"},
|
0
|
110 {XtNbackgroundToolBarColor, XtCBackgroundToolBarColor, XtRPixel,
|
|
111 sizeof(Pixel), offset(background_toolbar_pixel), XtRString,
|
2
|
112 (String) "Gray75"},
|
0
|
113 {XtNtopToolBarShadowPixmap, XtCTopToolBarShadowPixmap, XtRPixmap,
|
|
114 sizeof (Pixmap), offset(top_toolbar_shadow_pixmap), XtRImmediate,
|
|
115 (XtPointer)None},
|
|
116 {XtNbottomToolBarShadowPixmap, XtCBottomToolBarShadowPixmap, XtRPixmap,
|
|
117 sizeof (Pixmap), offset(bottom_toolbar_shadow_pixmap), XtRImmediate,
|
|
118 (XtPointer)None},
|
|
119 {XtNtoolBarShadowThickness, XtCToolBarShadowThickness, XtRDimension,
|
|
120 sizeof (Dimension), offset (toolbar_shadow_thickness), XtRImmediate,
|
|
121 (XtPointer)2},
|
|
122 #endif /* HAVE_TOOLBARS */
|
|
123 {XtNinterline, XtCInterline, XtRInt, sizeof (int),
|
|
124 offset (interline), XtRImmediate, (XtPointer)0},
|
|
125 {
|
|
126 #ifdef I18N4
|
|
127 XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
|
|
128 #else
|
|
129 XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
|
|
130 #endif
|
|
131 offset(font), XtRImmediate, (XtPointer)0
|
|
132 },
|
|
133 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
|
2
|
134 offset(foreground_pixel), XtRString, (String) "XtDefaultForeground"},
|
0
|
135 {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel),
|
2
|
136 offset(cursor_color), XtRString, (String) "XtDefaultForeground"},
|
0
|
137 {XtNbarCursor, XtCBarCursor, XtRBoolean, sizeof (Boolean),
|
|
138 offset (bar_cursor), XtRImmediate, (XtPointer)0},
|
|
139 {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof (Boolean),
|
|
140 offset (visual_bell), XtRImmediate, (XtPointer)0},
|
|
141 {XtNbellVolume, XtCBellVolume, XtRInt, sizeof (int),
|
|
142 offset (bell_volume), XtRImmediate, (XtPointer)0},
|
|
143 {XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, sizeof (Boolean),
|
|
144 offset (use_backing_store), XtRImmediate, (XtPointer)0},
|
|
145 {XtNpreferredWidth, XtCPreferredWidth, XtRDimension, sizeof (Dimension),
|
|
146 offset (preferred_width), XtRImmediate, (XtPointer)0},
|
|
147 {XtNpreferredHeight, XtCPreferredHeight, XtRDimension, sizeof (Dimension),
|
|
148 offset (preferred_height), XtRImmediate, (XtPointer)0},
|
|
149 };
|
|
150
|
|
151 #undef offset
|
|
152
|
|
153 /* Xt is stupid and dumb.
|
|
154 Xt is stupid and dumb.
|
|
155 Xt is stupid and dumb. */
|
|
156
|
|
157 static XtActionsRec
|
|
158 emacsFrameActionsTable [] = {
|
2
|
159 {(String) "mapping", (XtActionProc) emacs_Xt_mapping_action},
|
0
|
160 };
|
|
161
|
|
162 static char
|
|
163 emacsFrameTranslations [] = "\
|
|
164 <Mapping>: mapping()\n\
|
|
165 ";
|
|
166
|
|
167 /* If we're running under Motif, make this widget a subclass
|
|
168 of XmPrimitive. It's not clear this is necessary, but it
|
|
169 may make focus behavior work better. */
|
|
170
|
|
171 EmacsFrameClassRec emacsFrameClassRec = {
|
|
172 { /* core fields */
|
|
173 #ifdef LWLIB_USES_MOTIF
|
|
174 /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
|
|
175 #else
|
|
176 /* superclass */ &widgetClassRec,
|
|
177 #endif
|
2
|
178 /* class_name */ (String) "EmacsFrame",
|
0
|
179 /* widget_size */ sizeof(EmacsFrameRec),
|
|
180 /* class_initialize */ EmacsFrameClassInitialize,
|
|
181 /* class_part_initialize */ 0,
|
|
182 /* class_inited */ FALSE,
|
|
183 /* initialize */ EmacsFrameInitialize,
|
|
184 /* initialize_hook */ 0,
|
|
185 /* realize */ EmacsFrameRealize,
|
|
186 /* actions */ emacsFrameActionsTable,
|
|
187 /* num_actions */ XtNumber (emacsFrameActionsTable),
|
|
188 /* resources */ resources,
|
|
189 /* resource_count */ XtNumber(resources),
|
|
190 /* xrm_class */ NULLQUARK,
|
|
191 /* compress_motion */ TRUE,
|
|
192 /* compress_exposure */ TRUE,
|
|
193 /* compress_enterleave */ TRUE,
|
|
194 /* visible_interest */ FALSE,
|
|
195 /* destroy */ NULL,
|
|
196 /* resize */ EmacsFrameResize,
|
|
197 /* expose */ XtInheritExpose,
|
|
198 /* set_values */ EmacsFrameSetValues,
|
|
199 /* set_values_hook */ 0,
|
|
200 /* set_values_almost */ XtInheritSetValuesAlmost,
|
|
201 /* get_values_hook */ 0,
|
|
202 /* accept_focus */ XtInheritAcceptFocus,
|
|
203 /* version */ XtVersion,
|
|
204 /* callback_private */ 0,
|
|
205 /* tm_table */ emacsFrameTranslations,
|
|
206 /* query_geometry */ EmacsFrameQueryGeometry,
|
|
207 /* display_accelerator */ XtInheritDisplayAccelerator,
|
|
208 /* extension */ 0
|
|
209 },
|
|
210 #ifdef LWLIB_USES_MOTIF
|
|
211 { /* XmPrimitiveClassPart
|
|
212 */
|
|
213 (XtWidgetProc) _XtInherit, /* border_highlight */
|
|
214 (XtWidgetProc) _XtInherit, /* border_unhighlight */
|
|
215 /* Setting the following to NULL causes PrimitiveInitialize()
|
|
216 not to add traversal (TAB etc. to switch focus) and
|
|
217 focus-in/out (border highlight/unhighlight) translations.
|
|
218 If you want those translations, use the value XtInheritTranslations
|
|
219 instead. Doing this, however, will interfere with Emacs
|
|
220 focus handling (which highlights/unhighlights the text cursor),
|
|
221 and will lead to strange display results around the border of the
|
|
222 widget. */
|
|
223 NULL, /* translations */
|
|
224 NULL, /* arm_and_activate */
|
|
225 NULL, /* get resources */
|
|
226 0, /* num get_resources */
|
|
227 NULL, /* extension */
|
|
228 },
|
|
229 #endif /* LWLIB_USES_MOTIF */
|
|
230 {
|
|
231 0
|
|
232 }
|
|
233 };
|
|
234 WidgetClass emacsFrameClass = (WidgetClass) &emacsFrameClassRec;
|
|
235
|
|
236 static void
|
|
237 update_various_frame_slots (EmacsFrame ew)
|
|
238 {
|
|
239 ew->emacs_frame.frame->pixheight = ew->core.height;
|
|
240 ew->emacs_frame.frame->pixwidth = ew->core.width;
|
|
241 ew->emacs_frame.frame->internal_border_width =
|
|
242 ew->emacs_frame.internal_border_width;
|
|
243 }
|
|
244
|
|
245 static void
|
|
246 EmacsFrameInitialize (Widget request, Widget new,
|
|
247 ArgList dum1, Cardinal *dum2)
|
|
248 {
|
|
249 EmacsFrame ew = (EmacsFrame)new;
|
|
250 struct frame *f = ew->emacs_frame.frame;
|
|
251
|
|
252 if (!f)
|
|
253 fatal ("can't create an emacs frame widget without a frame.");
|
|
254 }
|
|
255
|
|
256 void emacs_Xt_event_handler (Widget wid /* unused */,
|
|
257 XtPointer closure /* unused */,
|
|
258 XEvent *event,
|
|
259 Boolean *continue_to_dispatch /* unused */);
|
|
260
|
|
261 static void
|
|
262 EmacsFrameRealize (Widget widget, XtValueMask *mask,
|
|
263 XSetWindowAttributes *attrs)
|
|
264 {
|
|
265 EmacsFrame ew = (EmacsFrame) widget;
|
|
266 struct frame *f = ew->emacs_frame.frame;
|
|
267 Widget shell_widget = FRAME_X_SHELL_WIDGET (f);
|
|
268
|
2
|
269 attrs->event_mask =
|
|
270 ExposureMask |
|
|
271 VisibilityChangeMask |
|
|
272 PropertyChangeMask |
|
|
273 StructureNotifyMask |
|
|
274 SubstructureNotifyMask |
|
|
275 /*SubstructureRedirectMask |*/ /* Only for WMs! */
|
|
276 KeyPressMask |
|
|
277 KeyReleaseMask |
|
|
278 ButtonPressMask |
|
|
279 ButtonReleaseMask |
|
|
280 FocusChangeMask |
|
|
281 PointerMotionHintMask |
|
|
282 PointerMotionMask |
|
|
283 LeaveWindowMask |
|
|
284 EnterWindowMask;
|
|
285
|
0
|
286
|
|
287 #ifdef I18N4
|
|
288 /* Make sure that events wanted by the input method are selected. */
|
|
289 attrs->event_mask |= input_method_event_mask;
|
|
290 #endif
|
|
291
|
|
292 *mask |= CWEventMask;
|
|
293
|
|
294 if (ew->emacs_frame.use_backing_store)
|
|
295 {
|
|
296 attrs->backing_store = Always;
|
|
297 *mask |= CWBackingStore;
|
|
298 }
|
|
299 XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask,
|
|
300 attrs);
|
|
301
|
|
302 /* snarf the events we want. */
|
|
303 XtInsertEventHandler (widget, attrs->event_mask, TRUE,
|
|
304 emacs_Xt_event_handler, NULL, XtListHead);
|
|
305 /* some events (e.g. map-notify and WM_DELETE_WINDOW) get sent
|
|
306 directly to the shell, and the above event handler won't see
|
|
307 them. So add a handler to get them. These events don't
|
|
308 propagate, so there's no danger of them being seen twice. */
|
|
309 XtInsertEventHandler (shell_widget,
|
|
310 EnterWindowMask | LeaveWindowMask |
|
|
311 VisibilityChangeMask | StructureNotifyMask |
|
|
312 KeyPressMask,
|
|
313 TRUE, emacs_Xt_event_handler, NULL, XtListHead);
|
|
314
|
|
315 #ifdef EXTERNAL_WIDGET
|
|
316 /* #### Not sure if this special case is necessary */
|
|
317 if (!FRAME_X_EXTERNAL_WINDOW_P (f))
|
|
318 #endif
|
|
319 /* This is necessary under Motif in order to make it possible to click in
|
|
320 a buffer and move focus out of a dialog box or control panel and back
|
|
321 into emacs-land; also necessary so that you can still type chars
|
|
322 if the cursor is over the menubar or scrollbar. */
|
|
323 lw_set_keyboard_focus (shell_widget, FRAME_X_TEXT_WIDGET (f));
|
|
324 }
|
|
325
|
|
326 /* DO NOT CALL THIS FUNCTION! Only Xt is supposed to do this. */
|
|
327
|
|
328 static void
|
|
329 EmacsFrameResize (Widget widget)
|
|
330 {
|
|
331 EmacsFrame ew = (EmacsFrame)widget;
|
|
332 struct frame *f = ew->emacs_frame.frame;
|
|
333 int columns;
|
|
334 int rows;
|
|
335 XtWidgetGeometry req, repl;
|
|
336
|
|
337 pixel_to_char_size (f, ew->core.width, ew->core.height, &columns, &rows);
|
|
338 update_various_frame_slots (ew);
|
|
339 change_frame_size (f, rows, columns, 0);
|
|
340
|
|
341 /* Now we tell the EmacsShell that we've changed the size of the non-fixed
|
|
342 portion of the frame. Note that, if we the resize occurred as a result
|
|
343 of EmacsFrameSetCharSize(), this information will be stored twice.
|
|
344 This is not a big deal, as storing this information doesn't actually
|
|
345 do anything until the next resize. */
|
|
346 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
|
|
347 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows);
|
|
348
|
|
349 /* Kick the manager so that it knows we've changed size. */
|
|
350 req.request_mode = 0;
|
|
351 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
|
|
352 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width,
|
|
353 repl.height);
|
|
354 }
|
|
355
|
|
356 static Boolean
|
|
357 EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget,
|
|
358 ArgList dum1, Cardinal *dum2)
|
|
359 {
|
|
360 EmacsFrame cur = (EmacsFrame) cur_widget;
|
|
361 EmacsFrame new = (EmacsFrame) new_widget;
|
|
362 Lisp_Object frame = Qnil;
|
|
363
|
|
364 XSETFRAME (frame, new->emacs_frame.frame);
|
|
365 in_resource_setting++;
|
|
366 /* This function does not need to do much. Pretty much everything
|
|
367 interesting will get done in the resize method, which will
|
|
368 (if necessary) get called by Xt when this function returns
|
|
369 (see below).
|
|
370 */
|
|
371
|
|
372 /* #### This function will not work if it is not called from
|
|
373 update_EmacsFrame(), called from SET_FACE_PROPERTY().
|
|
374 The code located there should be moved inside of here instead,
|
|
375 so that things work if either SET_FACE_PROPERTY() is
|
|
376 called or XtSetValues() is called.
|
|
377 */
|
|
378
|
|
379 if (cur->emacs_frame.iconic != new->emacs_frame.iconic &&
|
|
380 FRAME_X_TOP_LEVEL_FRAME_P (new->emacs_frame.frame))
|
|
381 x_wm_set_shell_iconic_p (FRAME_X_SHELL_WIDGET (new->emacs_frame.frame),
|
|
382 new->emacs_frame.iconic);
|
|
383
|
|
384 if (!in_specifier_change_function)
|
|
385 {
|
|
386 /* If we got here, then we were likely called as a result of
|
|
387 the EditRes protocol, so go ahead and change scrollbar-width
|
|
388 and scrollbar-height. Otherwise, we're merely mirroring
|
|
389 a change made to scrollbar-width etc. so don't do anything
|
|
390 special. */
|
|
391 #ifdef HAVE_SCROLLBARS
|
|
392 if (cur->emacs_frame.scrollbar_width !=
|
|
393 new->emacs_frame.scrollbar_width)
|
|
394 Fadd_spec_to_specifier
|
|
395 (Vscrollbar_width,
|
|
396 make_int (new->emacs_frame.scrollbar_width),
|
|
397 frame, Qnil, Qnil);
|
|
398 if (cur->emacs_frame.scrollbar_height !=
|
|
399 new->emacs_frame.scrollbar_height)
|
|
400 Fadd_spec_to_specifier
|
|
401 (Vscrollbar_height,
|
|
402 make_int (new->emacs_frame.scrollbar_height),
|
|
403 frame, Qnil, Qnil);
|
|
404 #endif
|
|
405 #ifdef HAVE_TOOLBARS
|
|
406 if (cur->emacs_frame.top_toolbar_height !=
|
|
407 new->emacs_frame.top_toolbar_height)
|
|
408 Fadd_spec_to_specifier
|
|
409 (Vtoolbar_size[TOP_TOOLBAR],
|
|
410 make_int (new->emacs_frame.top_toolbar_height),
|
|
411 frame, Qnil, Qnil);
|
|
412 if (cur->emacs_frame.bottom_toolbar_height !=
|
|
413 new->emacs_frame.bottom_toolbar_height)
|
|
414 Fadd_spec_to_specifier
|
|
415 (Vtoolbar_size[BOTTOM_TOOLBAR],
|
|
416 make_int (new->emacs_frame.bottom_toolbar_height),
|
|
417 frame, Qnil, Qnil);
|
|
418 if (cur->emacs_frame.left_toolbar_width !=
|
|
419 new->emacs_frame.left_toolbar_width)
|
|
420 Fadd_spec_to_specifier
|
|
421 (Vtoolbar_size[LEFT_TOOLBAR],
|
|
422 make_int (new->emacs_frame.left_toolbar_width),
|
|
423 frame, Qnil, Qnil);
|
|
424 if (cur->emacs_frame.right_toolbar_width !=
|
|
425 new->emacs_frame.right_toolbar_width)
|
|
426 Fadd_spec_to_specifier
|
|
427 (Vtoolbar_size[RIGHT_TOOLBAR],
|
|
428 make_int (new->emacs_frame.right_toolbar_width),
|
|
429 frame, Qnil, Qnil);
|
|
430 #endif
|
|
431 }
|
|
432 in_resource_setting--;
|
|
433
|
|
434 return False;
|
|
435
|
|
436 /* Note that if either (a) we return True, or (b) the width or
|
|
437 height has changed, an Expose event will be generated. The Xt
|
|
438 manual says you should not return True if the width or height has
|
|
439 changed, because then two Expose events will be generated.
|
|
440
|
|
441 In any case, there is no need to return True because
|
|
442 SET_FACE_PROPERTY(), which does the resource
|
|
443 setting, automatically forces a redisplay as necessary. */
|
|
444 }
|
|
445
|
|
446 static XtGeometryResult
|
|
447 EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request,
|
|
448 XtWidgetGeometry *result)
|
|
449 {
|
|
450 EmacsFrame ew = (EmacsFrame) widget;
|
|
451 int mask = request->request_mode;
|
|
452 Dimension width, height;
|
|
453 int ok_width_int, ok_height_int;
|
|
454 Dimension ok_width, ok_height;
|
|
455
|
|
456 /* We have a definite preference for what size we would like
|
|
457 to be.
|
|
458
|
|
459 1) If a preferred size was specified for us, use it.
|
|
460 (This is not currently used)
|
|
461 2) If a proposed size was given, round it to the nearest
|
|
462 multiple of the default char size and return it.
|
|
463 3) Otherwise, take our current size and round it to the
|
|
464 nearest multiple of the default char size. */
|
|
465
|
|
466 width = mask & CWWidth ? request->width : ew->core.width;
|
|
467 height = mask & CWHeight ? request->height : ew->core.height;
|
|
468 round_size_to_char (ew->emacs_frame.frame, width, height,
|
|
469 &ok_width_int, &ok_height_int);
|
|
470 ok_width = (Dimension) ok_width_int;
|
|
471 ok_height = (Dimension) ok_height_int;
|
|
472 if (ew->emacs_frame.preferred_width)
|
|
473 ok_width = ew->emacs_frame.preferred_width;
|
|
474 if (ew->emacs_frame.preferred_height)
|
|
475 ok_height = ew->emacs_frame.preferred_height;
|
|
476 result->request_mode |= CWWidth | CWHeight;
|
|
477 result->width = ok_width;
|
|
478 result->height = ok_height;
|
|
479 if (((mask & CWWidth) && ok_width != request->width)
|
|
480 || ((mask & CWHeight) && ok_height != request->height))
|
|
481 return XtGeometryAlmost;
|
|
482 else
|
|
483 return XtGeometryYes;
|
|
484 }
|
|
485
|
16
|
486 /* Xt string-to-scrollbar-placement converter */
|
|
487 /* ### Convert this to a `new-style' converter (See XtAddTypeConverter) */
|
0
|
488
|
|
489 /* This variable cannot be a stack variable. */
|
|
490 static unsigned char cvt_string_scrollbar_placement;
|
|
491
|
|
492 /* ARGSUSED */
|
|
493 static void
|
16
|
494 _CvtStringToScrollBarPlacement (XrmValuePtr args, /* unused */
|
|
495 Cardinal *num_args, /* unused */
|
|
496 XrmValuePtr fromVal,
|
|
497 XrmValuePtr toVal)
|
0
|
498 {
|
16
|
499 #define done(address, type) \
|
|
500 toVal->size = sizeof(type); \
|
|
501 toVal->addr = (XtPointer) address; \
|
|
502 return /* `;' supplied by caller */
|
|
503
|
0
|
504 XrmQuark q;
|
|
505 char lowerName[1000];
|
|
506
|
|
507 XmuCopyISOLatin1Lowered (lowerName, (char*)fromVal->addr);
|
|
508 q = XrmStringToQuark(lowerName);
|
|
509 if (q == XrmStringToQuark ("top_left"))
|
|
510 {
|
|
511 cvt_string_scrollbar_placement = XtTOP_LEFT;
|
|
512 done (&cvt_string_scrollbar_placement, unsigned char);
|
|
513 }
|
|
514 if (q == XrmStringToQuark ("bottom_left"))
|
|
515 {
|
|
516 cvt_string_scrollbar_placement = XtBOTTOM_LEFT;
|
|
517 done (&cvt_string_scrollbar_placement, unsigned char);
|
|
518 }
|
|
519 if (q == XrmStringToQuark ("top_right"))
|
|
520 {
|
|
521 cvt_string_scrollbar_placement = XtTOP_RIGHT;
|
|
522 done (&cvt_string_scrollbar_placement, unsigned char);
|
|
523 }
|
|
524 if (q == XrmStringToQuark ("bottom_right"))
|
|
525 {
|
|
526 cvt_string_scrollbar_placement = XtBOTTOM_RIGHT;
|
|
527 done (&cvt_string_scrollbar_placement, unsigned char);
|
|
528 }
|
|
529 XtStringConversionWarning (fromVal->addr, "scrollBarPlacement");
|
|
530 toVal->addr = NULL;
|
|
531 toVal->size = 0;
|
16
|
532 #undef done
|
0
|
533 }
|
|
534
|
|
535 static void
|
|
536 EmacsFrameClassInitialize (void)
|
|
537 {
|
|
538 XtAddConverter (XtRString, XtRScrollBarPlacement,
|
|
539 _CvtStringToScrollBarPlacement, NULL, 0);
|
|
540 }
|
|
541
|
|
542 /********************* Special entrypoints *******************/
|
|
543
|
|
544 void
|
|
545 EmacsFrameRecomputeCellSize (Widget w)
|
|
546 {
|
|
547 EmacsFrame ew = (EmacsFrame) w;
|
|
548 int cw, ch;
|
|
549 struct frame *f = ew->emacs_frame.frame;
|
|
550
|
|
551 if (! XtIsSubclass (w, emacsFrameClass))
|
|
552 abort ();
|
|
553
|
|
554 default_face_height_and_width (make_frame (f), &ch, &cw);
|
|
555 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
|
|
556 x_wm_set_cell_size (FRAME_X_SHELL_WIDGET (f), cw, ch);
|
|
557 }
|
|
558
|
|
559 /* Set the size of the widget to have the number of rows and columns
|
|
560 specified. This both causes the X window to change and the
|
|
561 internal frame structures to get modified to match. */
|
|
562
|
|
563 void
|
|
564 EmacsFrameSetCharSize (Widget widget, int columns, int rows)
|
|
565 {
|
|
566 EmacsFrame ew = (EmacsFrame) widget;
|
|
567 int pixel_width, pixel_height;
|
|
568 struct frame *f = ew->emacs_frame.frame;
|
|
569
|
|
570 if (columns < 3)
|
|
571 columns = 3; /* no way buddy */
|
|
572 if (rows < 1)
|
|
573 rows = 1;
|
|
574
|
|
575 char_to_pixel_size (f, columns, rows, &pixel_width, &pixel_height);
|
|
576
|
|
577 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
|
|
578 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows);
|
|
579
|
|
580 XtVaSetValues ((Widget) ew,
|
|
581 XtNwidth, (Dimension) pixel_width,
|
|
582 XtNheight, (Dimension) pixel_height,
|
|
583 0);
|
|
584 }
|