Mercurial > hg > xemacs-beta
annotate src/extw-Xt.c @ 5090:0ca81354c4c7
Further frame-geometry cleanups
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-03-03 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Intro to Window and Frame Geometry):
* internals/internals.texi (The Paned Area):
* internals/internals.texi (The Displayable Area):
Update to make note of e.g. the fact that the bottom gutter is
actually above the minibuffer.
src/ChangeLog addition:
2010-03-03 Ben Wing <ben@xemacs.org>
* emacs.c:
* emacs.c (assert_equal_failed):
* lisp.h:
* lisp.h (assert_equal):
New fun assert_equal, asserting that two values == each other, and
printing out both values upon failure.
* frame-gtk.c (gtk_initialize_frame_size):
* frame-impl.h:
* frame-impl.h (FRAME_TOP_INTERNAL_BORDER_START):
* frame-impl.h (FRAME_BOTTOM_INTERNAL_BORDER_START):
* frame-impl.h (FRAME_LEFT_INTERNAL_BORDER_START):
* frame-impl.h (FRAME_PANED_TOP_EDGE):
* frame-impl.h (FRAME_NONPANED_SIZE):
* frame-x.c (x_initialize_frame_size):
* frame.c:
* gutter.c (get_gutter_coords):
* gutter.c (calculate_gutter_size):
* gutter.h:
* gutter.h (WINDOW_REAL_TOP_GUTTER_BOUNDS):
* gutter.h (FRAME_TOP_GUTTER_BOUNDS):
* input-method-xlib.c:
* input-method-xlib.c (XIM_SetGeometry):
* redisplay-output.c (clear_left_border):
* redisplay-output.c (clear_right_border):
* redisplay-output.c (redisplay_output_pixmap):
* redisplay-output.c (redisplay_clear_region):
* redisplay-output.c (redisplay_clear_top_of_window):
* redisplay-output.c (redisplay_clear_to_window_end):
* redisplay-xlike-inc.c (XLIKE_clear_frame):
* redisplay.c:
* redisplay.c (UPDATE_CACHE_RETURN):
* redisplay.c (pixel_to_glyph_translation):
* toolbar.c (update_frame_toolbars_geometry):
* window.c (Fwindow_pixel_edges):
Get rid of some redundant macros. Consistently use the
FRAME_TOP_*_START, FRAME_RIGHT_*_END, etc. format. Rename
FRAME_*_BORDER_* to FRAME_*_INTERNAL_BORDER_*. Comment out
FRAME_BOTTOM_* for gutters and the paned area due to the
uncertainty over where the paned area actually begins. (Eventually
we should probably move the gutters outside the minibuffer so that
the paned area is contiguous.) Use FRAME_PANED_* more often in the
code to make things clearer.
Update the diagram to show that the bottom gutter is inside the
minibuffer (!) and that there are "junk boxes" when you have left
and/or right gutters (dead boxes that are mistakenly left uncleared,
unlike the corresponding scrollbar dead boxes). Update the text
appropriately to cover the bottom gutter position, etc.
Rewrite gutter-geometry code to use the FRAME_*_GUTTER_* in place of
equivalent expressions referencing other frame elements, to make the
code more portable in case we move around the gutter location.
Cleanup FRAME_*_GUTTER_BOUNDS() in gutter.h.
Add some #### GEOM! comments where I think code is incorrect --
typically, it wasn't fixed up properly when the gutter was added.
Some cosmetic changes.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 03 Mar 2010 05:07:47 -0600 |
parents | 4fbcce3f6097 |
children | 2aa9cd456ae7 |
rev | line source |
---|---|
0 | 1 /* Common code between client and shell widgets -- Xt only. |
2 Copyright (C) 1993, 1994 Sun Microsystems, Inc. | |
3 | |
4 This library is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU Library General Public | |
6 License as published by the Free Software Foundation; either | |
7 version 2 of the License, or (at your option) any later version. | |
8 | |
9 This library is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 Library General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU Library General Public | |
15 License along with this library; if not, write to | |
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
17 Boston, MA 02111-1307, USA. */ | |
18 | |
19 /* Synched up with: Not in FSF. */ | |
20 | |
21 /* Written by Ben Wing, September 1993. */ | |
22 | |
23 #ifdef emacs | |
24 | |
25 #include <config.h> | |
26 | |
27 #ifndef EXTERNAL_WIDGET | |
28 ERROR! This ought not be getting compiled if EXTERNAL_WIDGET is undefined | |
29 #endif | |
30 | |
2110 | 31 EXTERN_C void fatal (const char *fmt, ...); |
0 | 32 #else /* not emacs */ |
33 static void fatal (char *msg); | |
34 #endif | |
35 | |
36 #include <X11/Intrinsic.h> | |
37 #include <X11/IntrinsicP.h> | |
38 #include <stdlib.h> | |
39 #include <stdio.h> | |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
40 #include "compiler.h" |
0 | 41 #include "extw-Xt.h" |
42 | |
43 #ifdef DEBUG_WIDGET | |
44 | |
45 static int geom_masks[] = { | |
46 CWX, CWY, CWWidth, CWHeight, CWBorderWidth, CWSibling, CWStackMode, | |
47 XtCWQueryOnly }; | |
48 static char *geom_mask_strings[] = { | |
49 "CWX", "CWY", "CWWidth", "CWHeight", "CWBorderWidth", | |
50 "CWSibling", "CWStackMode", "XtCWQueryOnly" }; | |
51 static int stack_modes[] = { | |
52 Below, TopIf, BottomIf, Opposite, XtSMDontChange }; | |
53 static char *stack_mode_strings[] = { | |
54 "Below", "TopIf", "BottomIf", "Opposite", "XtSMDontChange" }; | |
55 | |
56 static void | |
57 print_geometry_structure(XtWidgetGeometry *xwg) | |
58 { | |
59 int num = sizeof(geom_masks)/sizeof(int); | |
60 int i; | |
2108 | 61 |
0 | 62 printf (" masks:"); |
63 for (i=0; i<num; i++) | |
64 if (xwg->request_mode & geom_masks[i]) | |
65 printf (" %s", geom_mask_strings[i]); | |
66 printf ("\n"); | |
67 printf (" x:%d y:%d\n", xwg->x, xwg->y); | |
68 printf (" width:%d height:%d border_width:%d\n", xwg->width, | |
69 xwg->height, xwg->border_width); | |
70 printf (" sibling: %x\n", xwg->sibling); | |
71 printf (" stack_mode: "); | |
72 for (i=0, num=sizeof(stack_modes)/sizeof(int); i<num; i++) | |
73 if (xwg->stack_mode == stack_modes[i]) { | |
74 printf ("%s", stack_mode_strings[i]); | |
75 break; | |
76 } | |
77 printf ("\n"); | |
78 } | |
79 | |
80 static void | |
81 print_geometry_result (XtGeometryResult res) | |
82 { | |
83 printf ("result: %s\n", | |
84 res == XtGeometryYes ? "XtGeometryYes" : | |
85 res == XtGeometryNo ? "XtGeometryNo" : | |
86 res == XtGeometryAlmost ? "XtGeometryAlmost" : | |
87 res == XtGeometryDone ? "XtGeometryDone" : | |
88 "unknown"); | |
89 } | |
90 | |
91 #endif | |
92 | |
93 #ifndef emacs | |
94 | |
95 static void | |
96 fatal (char *msg) | |
97 { | |
98 fprintf (stderr, "%s", msg); | |
99 exit (1); | |
100 } | |
101 | |
102 #endif | |
103 | |
104 /* put a geometry specification in the specified property on the window | |
105 of the specified widget, and send a notification message to tell the | |
106 client-side widget about this. */ | |
107 | |
108 void | |
109 extw_send_geometry_value(Display *display, Window win, Atom property, | |
110 en_extw_notify type, XtWidgetGeometry *xwg, | |
111 long data0) | |
112 { | |
113 if (xwg != NULL) | |
114 XChangeProperty(display, win, property, | |
115 a_EXTW_WIDGET_GEOMETRY, 32, PropModeReplace, | |
116 (unsigned char *) xwg, sizeof(*xwg)/sizeof(int)); | |
117 extw_send_notify_3(display, win, type, data0, 0, 0); | |
118 } | |
119 | |
120 /* get the geometry specification stored in the specified property of the | |
121 specified widget's window. */ | |
122 | |
123 void | |
124 extw_get_geometry_value(Display *display, Window win, Atom property, | |
125 XtWidgetGeometry *xwg) | |
126 { | |
127 Atom dummy; | |
128 int format; | |
129 unsigned long nitems, bytes_after; | |
130 unsigned char *prop; | |
2108 | 131 |
0 | 132 if (XGetWindowProperty(display, win, property, 0, |
133 sizeof(*xwg)/4, False, a_EXTW_WIDGET_GEOMETRY, | |
134 &dummy, &format, &nitems, &bytes_after, | |
135 &prop) != Success) | |
136 goto error; | |
137 if (format != 8*sizeof(int) || bytes_after) { | |
138 XFree((char *) prop); | |
139 goto error; | |
140 } | |
141 *xwg = * (XtWidgetGeometry *) prop; | |
142 return; | |
143 | |
144 error: | |
145 fatal("Unable to retrieve property for widget-geometry"); | |
146 #if 0 | |
147 XtAppErrorMsg(XtWidgetToApplicationContext((Widget)w), | |
148 "invalidProperty","get_geometry_value",XtCXtToolkitError, | |
149 "Unable to retrieve property for widget-geometry", | |
150 (String *)NULL, (Cardinal *)NULL); | |
151 #endif | |
152 } | |
153 | |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
154 typedef struct |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
155 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
156 Widget w; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
157 unsigned long request_num; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
158 en_extw_notify type; |
0 | 159 } QueryStruct; |
160 | |
161 /* check if an event is of the sort we're looking for */ | |
162 | |
163 static Bool | |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
164 isMine(XEvent *event, QueryStruct *q) |
0 | 165 { |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
166 Widget w = q->w; |
2108 | 167 |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
168 if ( (event->xany.display != XtDisplay(w)) || (event->xany.window != XtWindow(w)) ) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
169 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
170 return FALSE; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
171 } |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
172 if (event->xany.serial >= q->request_num) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
173 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
174 if (event->type == ClientMessage && |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
175 event->xclient.message_type == a_EXTW_NOTIFY && |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
176 event->xclient.data.l[0] == 1 - extw_which_side && |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
177 event->xclient.data.l[1] == (int) q->type) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
178 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
179 return TRUE; |
0 | 180 } |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
181 } |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
182 return FALSE; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
183 } |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
184 |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
185 void responseTimeOut(XtPointer clientData, XtIntervalId * UNUSED (id)) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
186 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
187 Bool *expired=(Bool *)clientData; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
188 *expired=TRUE; |
0 | 189 } |
190 | |
191 /* wait for a ClientMessage of the specified type from the other widget, or | |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
192 time-out. isMine() determines whether an event matches. |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
193 Took out the call to _XtWaitForSomething and replaced it with public |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
194 Xt api's. |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
195 */ |
0 | 196 |
197 Bool | |
2108 | 198 extw_wait_for_response (Widget w, XEvent *event, unsigned long request_num, |
199 en_extw_notify type, unsigned long timeout) | |
0 | 200 { |
2108 | 201 XtAppContext app = XtWidgetToApplicationContext(w); |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
202 XtInputMask inputMask; |
2108 | 203 QueryStruct q; |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
204 Bool expired; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
205 XtIntervalId id; |
2108 | 206 |
207 q.w = w; | |
208 q.request_num = request_num; | |
209 q.type = type; | |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
210 expired=FALSE; |
0 | 211 |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
212 id=XtAppAddTimeOut(app, timeout, responseTimeOut,&expired); |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
213 while (!expired) |
2108 | 214 { |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
215 inputMask=XtAppPending(app); |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
216 if (inputMask & XtIMXEvent) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
217 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
218 XtAppNextEvent(app, event); |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
219 if (isMine(event,&q)) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
220 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
221 if (!expired) XtRemoveTimeOut(id); |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
222 return True; |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
223 } |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
224 else |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
225 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
226 /* Do Nothing and go back to waiting */ |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
227 } |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
228 } |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
229 if (inputMask & XtIMTimer) |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
230 { |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
231 /* Process the expired timer */ |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
232 XtAppProcessEvent(app,XtIMTimer); |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
233 } |
2108 | 234 } |
4331
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
235 /* Must have expired */ |
4fbcce3f6097
Don't use undocumented Xt functions in external widget.
Mike Sperber <sperber@deinprogramm.de>
parents:
2114
diff
changeset
|
236 return False; |
0 | 237 } |