comparison src/EmacsFrame.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents 5460287a3327
children d0c14ea98592 6f2158fa75ed
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
38 #include "console-x-impl.h" 38 #include "console-x-impl.h"
39 #include "glyphs-x.h" 39 #include "glyphs-x.h"
40 #include "objects-x.h" 40 #include "objects-x.h"
41 41
42 #include <X11/Shell.h> 42 #include <X11/Shell.h>
43 #include <X11/Xmu/CharSet.h>
43 #include "EmacsFrameP.h" 44 #include "EmacsFrameP.h"
44 #include "EmacsManager.h" /* for EmacsManagerChangeSize */ 45 #include "EmacsManager.h" /* for EmacsManagerChangeSize */
45 #include "xmu.h" 46 #include "../lwlib/xt-wrappers.h"
46 47
47 static void EmacsFrameClassInitialize (void); 48 static void EmacsFrameClassInitialize (void);
48 static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *); 49 static void EmacsFrameInitialize (Widget, Widget, ArgList, Cardinal *);
49 static void EmacsFrameRealize (Widget, XtValueMask*, XSetWindowAttributes*); 50 static void EmacsFrameRealize (Widget, XtValueMask*, XSetWindowAttributes*);
50 static void EmacsFrameResize (Widget widget); 51 static void EmacsFrameResize (Widget widget);
58 59
59 #undef XtOffset 60 #undef XtOffset
60 #define XtOffset(p_type,field) \ 61 #define XtOffset(p_type,field) \
61 ((Cardinal) (((char *) (&(((p_type)0)->field))) - ((char *)0))) 62 ((Cardinal) (((char *) (&(((p_type)0)->field))) - ((char *)0)))
62 #define offset(field) XtOffset (EmacsFrame, emacs_frame.field) 63 #define offset(field) XtOffset (EmacsFrame, emacs_frame.field)
63 64 #define res(name,_class,intrepr,type,member,extrepr,value) \
65 Xt_RESOURCE (name, _class, intrepr, type, offset(member), extrepr, value)
64 static XtResource resources[] = { 66 static XtResource resources[] = {
65 { XtNgeometry, XtCGeometry, 67 res (XtNgeometry, XtCGeometry, XtRString, String, geometry, XtRString, 0),
66 XtRString, sizeof (String), 68 res (XtNiconic, XtCIconic, XtRBoolean, Boolean, iconic, XtRImmediate, False),
67 offset (geometry), XtRString, (XtPointer) 0 }, 69
68 { XtNiconic, XtCIconic, 70 res (XtNemacsFrame, XtCEmacsFrame, XtRPointer, XtPointer,
69 XtRBoolean, sizeof (Boolean), 71 frame, XtRImmediate, 0),
70 offset (iconic), XtRImmediate, (XtPointer) False }, 72 res (XtNmenubar, XtCMenubar, XtRBoolean, Boolean,
71 73 menubar_p, XtRImmediate, True),
72 { XtNemacsFrame, XtCEmacsFrame, 74 res (XtNinitiallyUnmapped, XtCInitiallyUnmapped, XtRBoolean, Boolean,
73 XtRPointer, sizeof (XtPointer), 75 initially_unmapped, XtRImmediate, False),
74 offset (frame), XtRImmediate, 0 }, 76 res (XtNminibuffer, XtCMinibuffer, XtRBoolean, Boolean,
75 { XtNmenubar, XtCMenubar, 77 minibuffer, XtRImmediate, True),
76 XtRBoolean, sizeof (Boolean), 78 res (XtNunsplittable, XtCUnsplittable, XtRBoolean, Boolean,
77 offset (menubar_p), XtRImmediate, (XtPointer) True }, 79 unsplittable, XtRImmediate, False),
78 { XtNinitiallyUnmapped, XtCInitiallyUnmapped, 80 res (XtNinternalBorderWidth, XtCInternalBorderWidth, XtRInt, int,
79 XtRBoolean, sizeof (Boolean), 81 internal_border_width, XtRImmediate, 4),
80 offset (initially_unmapped), XtRImmediate, (XtPointer) False },
81 { XtNminibuffer, XtCMinibuffer,
82 XtRBoolean, sizeof (Boolean),
83 offset (minibuffer), XtRImmediate, (XtPointer) True },
84 { XtNunsplittable, XtCUnsplittable,
85 XtRBoolean, sizeof (Boolean),
86 offset (unsplittable), XtRImmediate, (XtPointer) False },
87 { XtNinternalBorderWidth, XtCInternalBorderWidth,
88 XtRInt, sizeof (int),
89 offset (internal_border_width), XtRImmediate, (XtPointer)4 },
90 #ifdef HAVE_SCROLLBARS 82 #ifdef HAVE_SCROLLBARS
91 { XtNscrollBarWidth, XtCScrollBarWidth, 83 res (XtNscrollBarWidth, XtCScrollBarWidth, XtRInt, int,
92 XtRInt, sizeof (int), 84 scrollbar_width, XtRImmediate, -1),
93 offset (scrollbar_width), XtRImmediate, (XtPointer)-1 }, 85 res (XtNscrollBarHeight, XtCScrollBarHeight, XtRInt, int,
94 { XtNscrollBarHeight, XtCScrollBarHeight, 86 scrollbar_height, XtRImmediate, -1),
95 XtRInt, sizeof (int), 87 res (XtNscrollBarPlacement, XtCScrollBarPlacement, XtRScrollBarPlacement,
96 offset (scrollbar_height), XtRImmediate, (XtPointer)-1 }, 88 unsigned char, scrollbar_placement, XtRImmediate,
97 { XtNscrollBarPlacement, XtCScrollBarPlacement,
98 XtRScrollBarPlacement, sizeof (unsigned char),
99 offset (scrollbar_placement), XtRImmediate,
100 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ 89 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \
101 defined (LWLIB_SCROLLBARS_ATHENA3D) 90 defined (LWLIB_SCROLLBARS_ATHENA3D)
102 (XtPointer) XtBOTTOM_RIGHT 91 XtBOTTOM_RIGHT
103 #else 92 #else
104 (XtPointer) XtBOTTOM_LEFT 93 XtBOTTOM_LEFT
105 #endif 94 #endif
106 }, 95 ),
107 #endif /* HAVE_SCROLLBARS */ 96 #endif /* HAVE_SCROLLBARS */
108 97
109 #ifdef HAVE_TOOLBARS 98 #ifdef HAVE_TOOLBARS
110 { XtNtopToolBarHeight, XtCTopToolBarHeight, 99 res (XtNtopToolBarHeight, XtCTopToolBarHeight, XtRInt, int,
111 XtRInt, sizeof (int), 100 top_toolbar_height, XtRImmediate, -1),
112 offset (top_toolbar_height), XtRImmediate, (XtPointer)-1 }, 101 res (XtNbottomToolBarHeight, XtCBottomToolBarHeight, XtRInt, int,
113 { XtNbottomToolBarHeight, XtCBottomToolBarHeight, 102 bottom_toolbar_height, XtRImmediate, -1),
114 XtRInt, sizeof (int), 103 res (XtNleftToolBarWidth, XtCLeftToolBarWidth, XtRInt, int,
115 offset (bottom_toolbar_height), XtRImmediate, (XtPointer)-1 }, 104 left_toolbar_width, XtRImmediate, -1),
116 { XtNleftToolBarWidth, XtCLeftToolBarWidth, 105 res (XtNrightToolBarWidth, XtCRightToolBarWidth, XtRInt, int,
117 XtRInt, sizeof (int), 106 right_toolbar_width, XtRImmediate, -1),
118 offset (left_toolbar_width), XtRImmediate, (XtPointer)-1 }, 107 res (XtNtopToolBarBorderWidth, XtCTopToolBarBorderWidth, XtRInt, int,
119 { XtNrightToolBarWidth, XtCRightToolBarWidth, 108 top_toolbar_border_width, XtRImmediate, -1),
120 XtRInt, sizeof (int), 109 res (XtNbottomToolBarBorderWidth, XtCBottomToolBarBorderWidth, XtRInt, int,
121 offset (right_toolbar_width), XtRImmediate, (XtPointer)-1 }, 110 bottom_toolbar_border_width, XtRImmediate, -1),
122 { XtNtopToolBarBorderWidth, XtCTopToolBarBorderWidth, 111 res (XtNleftToolBarBorderWidth, XtCLeftToolBarBorderWidth, XtRInt,
123 XtRInt, sizeof (int), 112 int, left_toolbar_border_width, XtRImmediate, -1),
124 offset (top_toolbar_border_width), XtRImmediate, (XtPointer)-1 }, 113 res (XtNrightToolBarBorderWidth, XtCRightToolBarBorderWidth, XtRInt,
125 { XtNbottomToolBarBorderWidth, XtCBottomToolBarBorderWidth, 114 int, right_toolbar_border_width, XtRImmediate, -1),
126 XtRInt, sizeof (int), 115 res (XtNtoolBarShadowThickness, XtCToolBarShadowThickness, XtRDimension,
127 offset (bottom_toolbar_border_width), XtRImmediate, (XtPointer)-1 }, 116 Dimension, toolbar_shadow_thickness, XtRImmediate, 2),
128 { XtNleftToolBarBorderWidth, XtCLeftToolBarBorderWidth,
129 XtRInt, sizeof (int),
130 offset (left_toolbar_border_width), XtRImmediate, (XtPointer)-1 },
131 { XtNrightToolBarBorderWidth, XtCRightToolBarBorderWidth,
132 XtRInt, sizeof (int),
133 offset (right_toolbar_border_width), XtRImmediate, (XtPointer)-1 },
134 { XtNtoolBarShadowThickness, XtCToolBarShadowThickness,
135 XtRDimension, sizeof (Dimension),
136 offset (toolbar_shadow_thickness), XtRImmediate, (XtPointer)2 },
137 #endif /* HAVE_TOOLBARS */ 117 #endif /* HAVE_TOOLBARS */
138 118
139 { XtNinterline, XtCInterline, 119 res (XtNinterline, XtCInterline, XtRInt, int,
140 XtRInt, sizeof (int), 120 interline, XtRImmediate, 0),
141 offset (interline), XtRImmediate, (XtPointer)0 }, 121 res (XtNfont, XtCFont, XtRFontStruct, XFontStruct *,
142 { 122 font, XtRImmediate, 0),
143 XtNfont, XtCFont, 123 res (XtNforeground, XtCForeground, XtRPixel, Pixel,
144 XtRFontStruct, sizeof (XFontStruct *), 124 foreground_pixel, XtRString, "Black"),
145 offset(font), XtRImmediate, (XtPointer)0 125 res (XtNbackground, XtCBackground, XtRPixel, Pixel,
146 }, 126 background_pixel, XtRString, "Gray80"),
147 { XtNforeground, XtCForeground, 127 res (XtNcursorColor, XtCForeground, XtRPixel, Pixel,
148 XtRPixel, sizeof (Pixel), 128 cursor_color, XtRString, "XtDefaultForeground"),
149 offset(foreground_pixel), XtRString, (XtPointer) "Black" }, 129 res (XtNbarCursor, XtCBarCursor, XtRBoolean, Boolean,
150 { XtNbackground, XtCBackground, 130 bar_cursor, XtRImmediate, 0),
151 XtRPixel, sizeof (Pixel), 131 res (XtNvisualBell, XtCVisualBell, XtRBoolean, Boolean,
152 offset(background_pixel), XtRString, (XtPointer) "Gray80" }, 132 visual_bell, XtRImmediate, 0),
153 { XtNcursorColor, XtCForeground, 133 res (XtNbellVolume, XtCBellVolume, XtRInt, int,
154 XtRPixel, sizeof (Pixel), 134 bell_volume, XtRImmediate, 0),
155 offset(cursor_color), XtRString, (XtPointer) "XtDefaultForeground" }, 135 res (XtNuseBackingStore, XtCUseBackingStore, XtRBoolean, Boolean,
156 { XtNbarCursor, XtCBarCursor, 136 use_backing_store, XtRImmediate, 0),
157 XtRBoolean, sizeof (Boolean), 137 res (XtNpreferredWidth, XtCPreferredWidth, XtRDimension, Dimension,
158 offset (bar_cursor), XtRImmediate, (XtPointer)0 }, 138 preferred_width, XtRImmediate, 0),
159 { XtNvisualBell, XtCVisualBell, 139 res (XtNpreferredHeight, XtCPreferredHeight, XtRDimension, Dimension,
160 XtRBoolean, sizeof (Boolean), 140 preferred_height, XtRImmediate, 0),
161 offset (visual_bell), XtRImmediate, (XtPointer)0 },
162 { XtNbellVolume, XtCBellVolume,
163 XtRInt, sizeof (int),
164 offset (bell_volume), XtRImmediate, (XtPointer)0 },
165 { XtNuseBackingStore, XtCUseBackingStore,
166 XtRBoolean, sizeof (Boolean),
167 offset (use_backing_store), XtRImmediate, (XtPointer)0 },
168 { XtNpreferredWidth, XtCPreferredWidth,
169 XtRDimension, sizeof (Dimension),
170 offset (preferred_width), XtRImmediate, (XtPointer)0 },
171 { XtNpreferredHeight, XtCPreferredHeight,
172 XtRDimension, sizeof (Dimension),
173 offset (preferred_height), XtRImmediate, (XtPointer)0 },
174 }; 141 };
175 142
176 #undef offset 143 #undef offset
177 144
178 /* Xt is stupid and dumb. 145 /* Xt is stupid and dumb.
179 Xt is stupid and dumb. 146 Xt is stupid and dumb.
180 Xt is stupid and dumb. */ 147 Xt is stupid and dumb. */
181 148
182 static XtActionsRec 149 static XtActionsRec
183 emacsFrameActionsTable [] = { 150 emacsFrameActionsTable [] = {
184 {"mapping", (XtActionProc) emacs_Xt_mapping_action}, 151 { (String) "mapping", (XtActionProc) emacs_Xt_mapping_action},
185 }; 152 };
186 153
187 static char 154 static char
188 emacsFrameTranslations [] = "\ 155 emacsFrameTranslations [] = "\
189 <Mapping>: mapping()\n\ 156 <Mapping>: mapping()\n\
198 #ifdef LWLIB_USES_MOTIF 165 #ifdef LWLIB_USES_MOTIF
199 /* superclass */ (WidgetClass) &xmPrimitiveClassRec, 166 /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
200 #else 167 #else
201 /* superclass */ &widgetClassRec, 168 /* superclass */ &widgetClassRec,
202 #endif 169 #endif
203 /* class_name */ "EmacsFrame", 170 /* class_name */ (String) "EmacsFrame",
204 /* widget_size */ sizeof (EmacsFrameRec), 171 /* widget_size */ sizeof (EmacsFrameRec),
205 /* class_initialize */ EmacsFrameClassInitialize, 172 /* class_initialize */ EmacsFrameClassInitialize,
206 /* class_part_initialize */ 0, 173 /* class_part_initialize */ 0,
207 /* class_inited */ FALSE, 174 /* class_inited */ FALSE,
208 /* initialize */ EmacsFrameInitialize, 175 /* initialize */ EmacsFrameInitialize,
358 update_various_frame_slots (ew); 325 update_various_frame_slots (ew);
359 326
360 pixel_to_char_size (f, ew->core.width, ew->core.height, &columns, &rows); 327 pixel_to_char_size (f, ew->core.width, ew->core.height, &columns, &rows);
361 change_frame_size (f, rows, columns, 0); 328 change_frame_size (f, rows, columns, 0);
362 329
363 /* Now we tell the EmacsShell that we've changed the size of the non-fixed 330 /* The code below is just plain wrong. If the EmacsShell or EmacsManager
364 portion of the frame. Note that, if we the resize occurred as a result 331 needs to know, they should just ask. If needed information is being
365 of EmacsFrameSetCharSize(), this information will be stored twice. 332 updated here, then we should set a dirty flag and have it updated on an
366 This is not a big deal, as storing this information doesn't actually 333 as-needed basis.
367 do anything until the next resize. */ 334 For now, conditionalize so people can get work done if this breaks
368 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) 335 something. */
369 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows); 336 if (wedge_metacity) /* cf. x_set_frame_size */
370 337 {
371 /* Kick the manager so that it knows we've changed size. */ 338 /* Now we tell the EmacsShell that we've changed the size of the
372 req.request_mode = 0; 339 non-fixed portion of the frame. Note that, if the resize occurred
373 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl); 340 as a result of EmacsFrameSetCharSize(), this information will be
374 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width, 341 stored twice. This is not a big deal, as storing this information
375 repl.height); 342 doesn't actually do anything until the next resize. */
343 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
344 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows);
345
346 /* Kick the manager so that it knows we've changed size.
347 #### No, no, no! If this does anything at all, it will involve
348 changing the manager's size. That's not something that a child
349 widget should initialize as part of a purely informational
350 method!! */
351 req.request_mode = 0;
352 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
353 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f),
354 repl.width, repl.height);
355 }
376 } 356 }
377 357
378 static Boolean 358 static Boolean
379 EmacsFrameSetValues (Widget cur_widget, Widget UNUSED (req_widget), 359 EmacsFrameSetValues (Widget cur_widget, Widget UNUSED (req_widget),
380 Widget new_widget, ArgList argv, Cardinal *argc) 360 Widget new_widget, ArgList argv, Cardinal *argc)
638 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) 618 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
639 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows); 619 x_wm_set_variable_size (FRAME_X_SHELL_WIDGET (f), columns, rows);
640 620
641 { 621 {
642 Arg al [2]; 622 Arg al [2];
643 XtSetArg (al [0], XtNwidth, pixel_width); 623 Xt_SET_ARG (al [0], XtNwidth, pixel_width);
644 XtSetArg (al [1], XtNheight, pixel_height); 624 Xt_SET_ARG (al [1], XtNheight, pixel_height);
645 XtSetValues ((Widget) ew, al, countof (al)); 625 XtSetValues ((Widget) ew, al, countof (al));
646 } 626 }
647 } 627 }