Mercurial > hg > xemacs-beta
annotate src/EmacsManager.c @ 5554:a42e686a01bf
Automated merge with file:///Sources/xemacs-21.5-checked-out
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Wed, 24 Aug 2011 11:07:26 +0100 |
| parents | 308d34e9f07d |
| children |
| rev | line source |
|---|---|
| 428 | 1 /* Emacs manager widget. |
| 2 Copyright (C) 1993-1995 Sun Microsystems, Inc. | |
| 3 Copyright (C) 1995 Ben Wing. | |
| 4 | |
| 5 This file is part of XEmacs. | |
| 6 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4528
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 8 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4528
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4528
diff
changeset
|
10 option) any later version. |
| 428 | 11 |
| 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4528
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 19 |
| 20 /* Synched up with: Not in FSF. */ | |
| 21 | |
| 22 /* Written by Ben Wing, May, 1994. */ | |
| 23 | |
| 24 #include <config.h> | |
| 25 | |
| 26 #include <X11/StringDefs.h> | |
| 27 #include "EmacsManagerP.h" | |
| 28 #ifdef LWLIB_MENUBARS_MOTIF | |
| 1315 | 29 #include "xmotif.h" |
| 428 | 30 #include <Xm/RowColumn.h> |
| 31 #endif /* LWLIB_MENUBARS_MOTIF */ | |
| 2286 | 32 #include "compiler.h" |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
33 #include "../lwlib/xt-wrappers.h" |
| 428 | 34 |
| 35 /* For I, Emacs, am a kind god. Unlike the goddess Athena and the | |
| 36 Titan Motif, I require no ritual sacrifices to placate the lesser | |
| 37 daemons of geometry management. */ | |
| 38 | |
| 39 static XtResource resources[] = { | |
| 40 #define offset(field) XtOffset(EmacsManagerWidget, emacs_manager.field) | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
41 #define res(name,_class,intrepr,size,member,extrepr,value) \ |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
42 Xt_RESOURCE (name, _class, intrepr, size, offset(member), extrepr, value) |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
43 res (XtNresizeCallback, XtCCallback, XtRCallback, XtCallbackList, |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
44 resize_callback, XtRImmediate, 0), |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
45 res (XtNqueryGeometryCallback, XtCCallback, XtRCallback, XtCallbackList, |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
46 query_geometry_callback, XtRImmediate, 0), |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
47 res (XtNuserData, XtCUserData, XtRPointer, XtPointer, |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
48 user_data, XtRImmediate, 0), |
| 428 | 49 }; |
| 50 | |
| 51 /**************************************************************** | |
| 52 * | |
| 53 * Full class record constant | |
| 54 * | |
| 55 ****************************************************************/ | |
| 56 | |
| 57 static XtGeometryResult QueryGeometry (Widget wid, | |
| 58 XtWidgetGeometry *request, | |
| 59 XtWidgetGeometry *reply); | |
| 60 static void Resize (Widget w); | |
| 61 static XtGeometryResult GeometryManager (Widget w, XtWidgetGeometry *request, | |
| 62 XtWidgetGeometry *reply); | |
| 63 static void ChangeManaged (Widget w); | |
| 64 static void Realize (Widget w, Mask *valueMask, | |
| 65 XSetWindowAttributes *attributes); | |
| 66 static void ClassInitialize (void); | |
| 67 | |
| 68 EmacsManagerClassRec emacsManagerClassRec = { | |
| 69 { | |
| 70 /* core_class fields */ | |
| 71 #ifdef LWLIB_USES_MOTIF | |
| 72 /* superclass */ (WidgetClass) &xmManagerClassRec, | |
| 73 #else | |
| 74 /* superclass */ (WidgetClass) &compositeClassRec, | |
| 75 #endif | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
76 /* class_name */ (String) "EmacsManager", |
| 440 | 77 /* widget_size */ sizeof (EmacsManagerRec), |
| 428 | 78 /* class_initialize */ ClassInitialize, |
| 79 /* class_part_init */ NULL, | |
| 80 /* class_inited */ FALSE, | |
| 81 /* initialize */ NULL, | |
| 82 /* initialize_hook */ NULL, | |
| 83 /* realize */ Realize, | |
| 84 /* actions */ NULL, | |
| 85 /* num_actions */ 0, | |
| 86 /* resources */ resources, | |
| 87 /* num_resources */ XtNumber(resources), | |
| 88 /* xrm_class */ NULLQUARK, | |
| 89 /* compress_motion */ TRUE, | |
| 1294 | 90 /* compress_exposure */ XtExposeCompressMaximal | XtExposeNoRegion, |
| 428 | 91 /* compress_enterleave*/ TRUE, |
| 92 /* visible_interest */ FALSE, | |
| 93 /* destroy */ NULL, | |
| 94 /* resize */ Resize, | |
| 95 /* expose */ NULL, | |
| 96 /* set_values */ NULL, | |
| 97 /* set_values_hook */ NULL, | |
| 98 /* set_values_almost */ XtInheritSetValuesAlmost, | |
| 99 /* get_values_hook */ NULL, | |
| 100 /* accept_focus */ NULL, | |
| 101 /* version */ XtVersion, | |
| 102 /* callback_private */ NULL, | |
| 103 /* tm_table */ XtInheritTranslations, | |
| 104 /* query_geometry */ QueryGeometry, | |
| 105 /* display_accelerator*/ XtInheritDisplayAccelerator, | |
| 106 /* extension */ NULL | |
| 107 }, | |
| 108 { | |
| 109 /* composite_class fields */ | |
| 110 /* geometry_manager */ GeometryManager, | |
| 111 /* change_managed */ ChangeManaged, | |
| 112 /* insert_child */ XtInheritInsertChild, | |
| 113 /* delete_child */ XtInheritDeleteChild, | |
| 114 /* extension */ NULL | |
| 115 }, | |
| 116 #ifdef LWLIB_USES_MOTIF | |
| 117 { | |
| 118 /* constraint_class fields */ | |
| 119 NULL, /* resource list */ | |
| 120 0, /* num resources */ | |
| 121 0, /* constraint size */ | |
| 122 (XtInitProc)NULL, /* init proc */ | |
| 123 (XtWidgetProc)NULL, /* destroy proc */ | |
| 124 (XtSetValuesFunc)NULL, /* set values proc */ | |
| 125 NULL, /* extension */ | |
| 126 }, | |
| 127 { | |
| 128 /* manager_class fields */ | |
| 129 XtInheritTranslations, /* translations */ | |
| 130 NULL, /* syn_resources */ | |
| 131 0, /* num_syn_resources */ | |
| 132 NULL, /* syn_cont_resources */ | |
| 133 0, /* num_syn_cont_resources */ | |
| 134 XmInheritParentProcess, /* parent_process */ | |
| 135 NULL, /* extension */ | |
| 136 }, | |
| 137 #endif | |
| 138 { | |
| 139 /* emacs_manager_class fields */ | |
| 140 /* empty */ 0, | |
| 141 } | |
| 142 }; | |
| 143 | |
| 144 WidgetClass emacsManagerWidgetClass = (WidgetClass)&emacsManagerClassRec; | |
| 145 | |
| 146 /* What is my preferred size? A suggested size may be given. */ | |
| 147 | |
| 148 static XtGeometryResult | |
| 149 QueryGeometry (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) | |
| 150 { | |
| 151 EmacsManagerWidget emw = (EmacsManagerWidget) w; | |
| 152 EmacsManagerQueryGeometryStruct struc; | |
| 440 | 153 int request_mode = request->request_mode; |
| 428 | 154 |
| 440 | 155 struc.request_mode = request_mode; |
| 156 struc.proposed_width = (request_mode & CWWidth) ? request->width : 0; | |
| 157 struc.proposed_height = (request_mode & CWHeight) ? request->height : 0; | |
| 428 | 158 XtCallCallbackList (w, emw->emacs_manager.query_geometry_callback, &struc); |
| 159 reply->request_mode = CWWidth | CWHeight; | |
| 160 reply->width = struc.proposed_width; | |
| 161 reply->height = struc.proposed_height; | |
| 440 | 162 if (((request_mode & CWWidth) && (request->width != reply->width)) || |
| 163 ((request_mode & CWHeight) && (request->height != reply->height))) | |
| 428 | 164 return XtGeometryAlmost; |
| 165 return XtGeometryYes; | |
| 166 } | |
| 167 | |
| 168 static void | |
| 169 Resize (Widget w) | |
| 170 { | |
| 171 EmacsManagerWidget emw = (EmacsManagerWidget) w; | |
| 172 EmacsManagerResizeStruct struc; | |
| 173 | |
| 174 struc.width = w->core.width; | |
| 175 struc.height = w->core.height; | |
| 176 XtCallCallbackList (w, emw->emacs_manager.resize_callback, &struc); | |
| 177 } | |
| 178 | |
| 179 static XtGeometryResult | |
| 2286 | 180 GeometryManager (Widget w, XtWidgetGeometry *request, |
| 181 XtWidgetGeometry *UNUSED (reply)) | |
| 428 | 182 { |
| 183 /* Sure, any changes are fine. */ | |
| 184 | |
| 440 | 185 #ifdef LWLIB_MENUBARS_MOTIF |
| 428 | 186 /* The Motif menubar will merrily request a new size every time a |
| 187 child is added or deleted. Blow it off because it doesn't know | |
| 188 what it's talking about. */ | |
| 440 | 189 if (XtClass (w) != xmRowColumnWidgetClass) |
| 428 | 190 #endif /* LWLIB_MENUBARS_MOTIF */ |
| 191 { | |
| 440 | 192 if (request->request_mode & CWWidth) w->core.width = request->width; |
| 193 if (request->request_mode & CWHeight) w->core.height = request->height; | |
| 428 | 194 } |
| 440 | 195 if (request->request_mode & CWBorderWidth) |
| 196 w->core.border_width = request->border_width; | |
| 197 if (request->request_mode & CWX) w->core.x = request->x; | |
| 198 if (request->request_mode & CWY) w->core.y = request->y; | |
| 428 | 199 |
| 200 return XtGeometryYes; | |
| 201 } | |
| 202 | |
| 203 static void | |
| 204 ChangeManaged (Widget w) | |
| 205 { | |
| 206 if (!XtIsRealized (w)) | |
| 207 { | |
| 440 | 208 XtWidgetGeometry request, reply; |
| 428 | 209 |
| 210 /* find out how big we'd like to be ... */ | |
| 211 | |
| 440 | 212 request.request_mode = 0; |
| 213 XtQueryGeometry (w, &request, &reply); | |
| 214 EmacsManagerChangeSize (w, reply.width, reply.height); | |
| 428 | 215 } |
| 216 } | |
| 217 | |
| 218 static void | |
| 219 Realize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) | |
| 220 { | |
| 221 attributes->bit_gravity = NorthWestGravity; | |
| 222 *valueMask |= CWBitGravity; | |
| 223 | |
| 224 XtCreateWindow (w, (unsigned) InputOutput, (Visual *) CopyFromParent, | |
| 225 *valueMask, attributes); | |
| 226 } | |
| 227 | |
| 228 static void | |
| 229 ClassInitialize (void) | |
| 230 { | |
| 231 return; | |
| 232 } | |
| 233 | |
| 234 void | |
| 235 EmacsManagerChangeSize (Widget w, Dimension width, Dimension height) | |
| 236 { | |
| 237 if (width == 0) | |
| 238 width = w->core.width; | |
| 239 if (height == 0) | |
| 240 height = w->core.height; | |
| 241 | |
| 3381 | 242 /* #### AFAICT this gets called in two places. One is in ChangeManaged(), |
| 243 above. The other is in EmacsFrameResize(). Perhaps ChangeManaged() | |
| 244 should initiate resize requests, but EmacsFrameResize() should not. | |
| 245 Unfortunately, I've tried making this conditional on whether we're | |
| 246 called from EmacsFrameResize() or not, but that results in an infloop | |
| 247 via the callback to x_layout_widgets() in Resize(). Whee! */ | |
| 428 | 248 /* do nothing if we're already that size */ |
| 249 if (w->core.width != width || w->core.height != height) | |
| 2450 | 250 { |
| 251 XtGeometryResult result = | |
| 252 XtMakeResizeRequest (w, width, height, &w->core.width, &w->core.height); | |
| 253 if (result == XtGeometryNo) | |
| 254 return; | |
| 255 if (result == XtGeometryAlmost) | |
| 256 XtMakeResizeRequest (w, w->core.width, w->core.height, NULL, NULL); | |
| 257 Resize (w); | |
| 258 } | |
| 428 | 259 } |
| 260 | |
| 261 |
