1
by Claude Lecommandeur
CTWM version 1.1 |
1 |
/*
|
2 |
* Copyright 1989 Massachusetts Institute of Technology
|
|
3 |
*
|
|
4 |
* Permission to use, copy, modify, and distribute this software and its
|
|
5 |
* documentation for any purpose and without fee is hereby granted, provided
|
|
6 |
* that the above copyright notice appear in all copies and that both that
|
|
7 |
* copyright notice and this permission notice appear in supporting
|
|
8 |
* documentation, and that the name of M.I.T. not be used in advertising
|
|
9 |
* or publicity pertaining to distribution of the software without specific,
|
|
10 |
* written prior permission. M.I.T. makes no representations about the
|
|
11 |
* suitability of this software for any purpose. It is provided "as is"
|
|
12 |
* without express or implied warranty.
|
|
13 |
*
|
|
14 |
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
|
15 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
|
|
16 |
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
17 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
18 |
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
1
by Claude Lecommandeur
CTWM version 1.1 |
19 |
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
20 |
*/
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
21 |
/*
|
11
by Claude Lecommandeur
CTWM version 3.2p1 |
22 |
* [ ctwm ]
|
23 |
*
|
|
24 |
* Copyright 1992 Claude Lecommandeur.
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
25 |
*
|
11
by Claude Lecommandeur
CTWM version 3.2p1 |
26 |
* Permission to use, copy, modify and distribute this software [ctwm] and
|
27 |
* its documentation for any purpose is hereby granted without fee, provided
|
|
28 |
* that the above copyright notice appear in all copies and that both that
|
|
29 |
* copyright notice and this permission notice appear in supporting documen-
|
|
30 |
* tation, and that the name of Claude Lecommandeur not be used in adverti-
|
|
31 |
* sing or publicity pertaining to distribution of the software without
|
|
32 |
* specific, written prior permission. Claude Lecommandeur make no represen-
|
|
33 |
* tations about the suitability of this software for any purpose. It is
|
|
34 |
* provided "as is" without express or implied warranty.
|
|
35 |
*
|
|
36 |
* Claude Lecommandeur DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
37 |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
38 |
* EVENT SHALL Claude Lecommandeur BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
39 |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
|
40 |
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41 |
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42 |
* PERFORMANCE OF THIS SOFTWARE.
|
|
43 |
*
|
|
44 |
* Author: Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ]
|
|
45 |
*/
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
46 |
|
47 |
/***********************************************************************
|
|
48 |
*
|
|
49 |
* $XConsortium: iconmgr.c,v 1.48 91/09/10 15:27:07 dave Exp $
|
|
50 |
*
|
|
51 |
* Icon Manager routines
|
|
52 |
*
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
53 |
* 09-Mar-89 Tom LaStrange File Created
|
1
by Claude Lecommandeur
CTWM version 1.1 |
54 |
*
|
55 |
* Do the necessary modification to be integrated in ctwm.
|
|
56 |
* Can no longer be used for the standard twm.
|
|
57 |
*
|
|
58 |
* 22-April-92 Claude Lecommandeur.
|
|
59 |
*
|
|
60 |
*
|
|
61 |
***********************************************************************/
|
|
62 |
||
63 |
#include <stdio.h> |
|
324.1.7
by Matthew Fuller
XmuCompareISOLatin1 -> strcasecmp. We can reture Xmu includes for |
64 |
#include <string.h> |
65 |
#include <strings.h> |
|
320.1.6
by Matthew Fuller
Mechanical rename of twm.h to ctwm.h now that the name is cleared. |
66 |
#include "ctwm.h" |
17
by Claude Lecommandeur
CTWM version 3.5 |
67 |
#ifdef VMS
|
68 |
#include <decw$include/Xatom.h> |
|
69 |
#else
|
|
70 |
#include <X11/Xatom.h> |
|
71 |
#endif
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
72 |
#include "util.h" |
73 |
#include "parse.h" |
|
74 |
#include "screen.h" |
|
75 |
#include "resize.h" |
|
240.1.3
by Rhialto
4 - Added the remaining OnTopPriority changes from Stefan Monnier |
76 |
#include "otp.h" |
1
by Claude Lecommandeur
CTWM version 1.1 |
77 |
#include "add_window.h" |
78 |
#ifdef macII
|
|
79 |
int strcmp(); /* missing from string.h in AUX 2.0 */ |
|
80 |
#endif
|
|
81 |
||
333
by Matthew Fuller
Revert r331 turning these back into vars, but move them into iconmgr |
82 |
const int siconify_width = 11; |
83 |
const int siconify_height = 11; |
|
84 |
int iconmgr_textx = /*siconify_width*/11 + 11; |
|
85 |
static char siconify_bits[] = { |
|
86 |
0xff, 0x07, 0x01, 0x04, 0x0d, 0x05, 0x9d, 0x05, 0xb9, 0x04, 0x51, 0x04, |
|
87 |
0xe9, 0x04, 0xcd, 0x05, 0x85, 0x05, 0x01, 0x04, 0xff, 0x07 |
|
88 |
};
|
|
89 |
||
322.1.16
by Matthew Fuller
Staticize vars. |
90 |
static WList *Active = NULL; |
91 |
static WList *Current = NULL; |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
92 |
WList *DownIconManager = NULL; |
93 |
||
94 |
/***********************************************************************
|
|
95 |
*
|
|
96 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
97 |
* CreateIconManagers - creat all the icon manager windows
|
98 |
* for this screen.
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
99 |
*
|
100 |
* Returned Value:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
101 |
* none
|
1
by Claude Lecommandeur
CTWM version 1.1 |
102 |
*
|
103 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
104 |
* none
|
1
by Claude Lecommandeur
CTWM version 1.1 |
105 |
*
|
106 |
***********************************************************************
|
|
107 |
*/
|
|
108 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
109 |
void CreateIconManagers(void) |
1
by Claude Lecommandeur
CTWM version 1.1 |
110 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
111 |
IconMgr *p, *q; |
112 |
int mask; |
|
113 |
char str[100]; |
|
114 |
char str1[100]; |
|
115 |
Pixel background; |
|
116 |
char *icon_name; |
|
117 |
WorkSpace *ws; |
|
118 |
XWMHints wmhints; |
|
119 |
XSizeHints sizehints; |
|
120 |
int gravity; |
|
121 |
int bw; |
|
122 |
||
123 |
if(Scr->NoIconManagers) { |
|
124 |
return; |
|
125 |
}
|
|
126 |
||
127 |
if(Scr->use3Diconmanagers) { |
|
128 |
iconmgr_textx += Scr->IconManagerShadowDepth; |
|
129 |
}
|
|
130 |
if(Scr->siconifyPm == None) { |
|
131 |
Scr->siconifyPm = XCreatePixmapFromBitmapData(dpy, Scr->Root, |
|
333
by Matthew Fuller
Revert r331 turning these back into vars, but move them into iconmgr |
132 |
siconify_bits, siconify_width, siconify_height, 1, 0, 1); |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
133 |
}
|
134 |
||
135 |
ws = Scr->workSpaceMgr.workSpaceList; |
|
136 |
for(q = Scr->iconmgr; q != NULL; q = q->nextv) { |
|
137 |
for(p = q; p != NULL; p = p->next) { |
|
315
by Matthew Fuller
Use snprintf() instead of sprintf() here to ensure we don't wander off |
138 |
snprintf(str, sizeof(str), "%s Icon Manager", p->name); |
139 |
snprintf(str1, sizeof(str1), "%s Icons", p->name); |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
140 |
if(p->icon_name) { |
141 |
icon_name = p->icon_name; |
|
142 |
}
|
|
143 |
else { |
|
144 |
icon_name = str1; |
|
145 |
}
|
|
146 |
||
147 |
if(!p->geometry || !strlen(p->geometry)) { |
|
148 |
p->geometry = "+0+0"; |
|
149 |
}
|
|
150 |
mask = XParseGeometry(p->geometry, &JunkX, &JunkY, |
|
151 |
(unsigned int *) &p->width, (unsigned int *)&p->height); |
|
152 |
||
153 |
bw = LookInList(Scr->NoBorder, str, NULL) ? 0 : |
|
154 |
(Scr->ThreeDBorderWidth ? Scr->ThreeDBorderWidth : Scr->BorderWidth); |
|
155 |
||
156 |
if(mask & XNegative) { |
|
157 |
JunkX += Scr->rootw - p->width - 2 * bw; |
|
158 |
gravity = (mask & YNegative) ? SouthEastGravity : NorthEastGravity; |
|
159 |
}
|
|
160 |
else { |
|
161 |
gravity = (mask & YNegative) ? SouthWestGravity : NorthWestGravity; |
|
162 |
}
|
|
163 |
if(mask & YNegative) { |
|
164 |
JunkY += Scr->rooth - p->height - 2 * bw; |
|
165 |
}
|
|
166 |
||
167 |
background = Scr->IconManagerC.back; |
|
168 |
GetColorFromList(Scr->IconManagerBL, p->name, (XClassHint *)NULL, |
|
169 |
&background); |
|
170 |
||
171 |
if(p->width < 1) { |
|
172 |
p->width = 1; |
|
173 |
}
|
|
174 |
if(p->height < 1) { |
|
175 |
p->height = 1; |
|
176 |
}
|
|
177 |
p->w = XCreateSimpleWindow(dpy, Scr->Root, |
|
178 |
JunkX, JunkY, p->width, p->height, 1, |
|
179 |
Scr->Black, background); |
|
180 |
||
181 |
XSetStandardProperties(dpy, p->w, str, icon_name, None, NULL, 0, NULL); |
|
182 |
||
183 |
/* Scr->workSpaceMgr.activeWSPC = ws; */
|
|
184 |
wmhints.initial_state = NormalState; |
|
185 |
wmhints.input = True; |
|
186 |
wmhints.flags = InputHint | StateHint; |
|
187 |
XSetWMHints(dpy, p->w, &wmhints); |
|
188 |
p->twm_win = AddWindow(p->w, ADD_WINDOW_ICON_MANAGER, p, Scr->currentvs); |
|
189 |
/*
|
|
190 |
* SetupOccupation() called from AddWindow() doesn't setup
|
|
191 |
* occupation for icon managers, nor clear vs if occupation lacks.
|
|
192 |
*
|
|
193 |
* There is no Scr->currentvs->wsw->currentwspc set up this
|
|
194 |
* early, so we can't check with that; the best check we can do
|
|
195 |
* is use ws->number. This may be incorrect when re-starting
|
|
196 |
* ctwm.
|
|
197 |
*/
|
|
198 |
if(ws) { |
|
199 |
p->twm_win->occupation = 1 << ws->number; |
|
200 |
if(ws->number > 0) { |
|
201 |
p->twm_win->vs = NULL; |
|
202 |
}
|
|
203 |
}
|
|
204 |
else { |
|
205 |
p->twm_win->occupation = 1; |
|
206 |
}
|
|
240.1.24
by Olaf 'Rhialto' Seibert
Prevent all icon manager windows from appearing in workspace #0. |
207 |
#ifdef DEBUG_ICONMGR
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
208 |
fprintf(stderr, |
209 |
"CreateIconManagers: IconMgr %p: x=%d y=%d w=%d h=%d occupation=%x\n", |
|
210 |
p, JunkX, JunkY, p->width, p->height, p->twm_win->occupation); |
|
240.1.24
by Olaf 'Rhialto' Seibert
Prevent all icon manager windows from appearing in workspace #0. |
211 |
#endif
|
9
by Claude Lecommandeur
CTWM version 3.1 |
212 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
213 |
sizehints.flags = PWinGravity; |
214 |
sizehints.win_gravity = gravity; |
|
215 |
XSetWMSizeHints(dpy, p->w, &sizehints, XA_WM_NORMAL_HINTS); |
|
216 |
||
217 |
p->twm_win->mapped = FALSE; |
|
218 |
SetMapStateProp(p->twm_win, WithdrawnState); |
|
219 |
if(p->twm_win && p->twm_win->wmhints && |
|
220 |
(p->twm_win->wmhints->initial_state == IconicState)) { |
|
221 |
p->twm_win->isicon = TRUE; |
|
222 |
}
|
|
223 |
else if(!Scr->NoIconManagers && Scr->ShowIconManager) { |
|
224 |
p->twm_win->isicon = FALSE; |
|
225 |
}
|
|
226 |
else { |
|
227 |
p->twm_win->isicon = TRUE; |
|
228 |
}
|
|
229 |
}
|
|
230 |
if(ws != NULL) { |
|
231 |
ws = ws->next; |
|
232 |
}
|
|
233 |
}
|
|
234 |
||
235 |
if(Scr->workSpaceManagerActive) { |
|
236 |
Scr->workSpaceMgr.workSpaceList->iconmgr = Scr->iconmgr; |
|
237 |
}
|
|
238 |
||
239 |
for(q = Scr->iconmgr; q != NULL; q = q->nextv) { |
|
240 |
for(p = q; p != NULL; p = p->next) { |
|
241 |
GrabButtons(p->twm_win); |
|
242 |
GrabKeys(p->twm_win); |
|
243 |
}
|
|
244 |
}
|
|
5
by Claude Lecommandeur
CTWM version 2.1 |
245 |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
246 |
}
|
247 |
||
248 |
/***********************************************************************
|
|
249 |
*
|
|
250 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
251 |
* AllocateIconManager - allocate a new icon manager
|
1
by Claude Lecommandeur
CTWM version 1.1 |
252 |
*
|
253 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
254 |
* name - the name of this icon manager
|
255 |
* icon_name - the name of the associated icon
|
|
256 |
* geom - a geometry string to eventually parse
|
|
257 |
* columns - the number of columns this icon manager has
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
258 |
*
|
259 |
***********************************************************************
|
|
260 |
*/
|
|
261 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
262 |
IconMgr *AllocateIconManager(char *name, char *icon_name, char *geom, |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
263 |
int columns) |
1
by Claude Lecommandeur
CTWM version 1.1 |
264 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
265 |
IconMgr *p; |
1
by Claude Lecommandeur
CTWM version 1.1 |
266 |
|
267 |
#ifdef DEBUG_ICONMGR
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
268 |
fprintf(stderr, "AllocateIconManager\n"); |
269 |
fprintf(stderr, " name=\"%s\" icon_name=\"%s\", geom=\"%s\", col=%d\n", |
|
270 |
name, icon_name, geom, columns); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
271 |
#endif
|
272 |
||
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
273 |
if(Scr->NoIconManagers) { |
274 |
return NULL; |
|
275 |
}
|
|
276 |
||
277 |
if(columns < 1) { |
|
278 |
columns = 1; |
|
279 |
}
|
|
318.1.1
by Matthew Fuller
Switch this malloc to a calloc, take out now-unnecessary |
280 |
p = calloc(1, sizeof(IconMgr)); |
281 |
p->name = name; |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
282 |
p->icon_name = icon_name; |
318.1.1
by Matthew Fuller
Switch this malloc to a calloc, take out now-unnecessary |
283 |
p->geometry = geom; |
284 |
p->columns = columns; |
|
285 |
p->scr = Scr; |
|
286 |
p->width = 150; |
|
287 |
p->height = 10; |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
288 |
|
289 |
if(Scr->iconmgr == NULL) { |
|
290 |
Scr->iconmgr = p; |
|
291 |
Scr->iconmgr->lasti = p; |
|
292 |
}
|
|
293 |
else { |
|
294 |
Scr->iconmgr->lasti->next = p; |
|
295 |
p->prev = Scr->iconmgr->lasti; |
|
296 |
Scr->iconmgr->lasti = p; |
|
297 |
}
|
|
298 |
return(p); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
299 |
}
|
300 |
||
301 |
/***********************************************************************
|
|
302 |
*
|
|
303 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
304 |
* MoveIconManager - move the pointer around in an icon manager
|
1
by Claude Lecommandeur
CTWM version 1.1 |
305 |
*
|
306 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
307 |
* dir - one of the following:
|
308 |
* F_FORWICONMGR - forward in the window list
|
|
309 |
* F_BACKICONMGR - backward in the window list
|
|
310 |
* F_UPICONMGR - up one row
|
|
311 |
* F_DOWNICONMGR - down one row
|
|
312 |
* F_LEFTICONMGR - left one column
|
|
313 |
* F_RIGHTICONMGR - right one column
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
314 |
*
|
315 |
* Special Considerations:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
316 |
* none
|
1
by Claude Lecommandeur
CTWM version 1.1 |
317 |
*
|
318 |
***********************************************************************
|
|
319 |
*/
|
|
320 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
321 |
void MoveIconManager(int dir) |
1
by Claude Lecommandeur
CTWM version 1.1 |
322 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
323 |
IconMgr *ip; |
324 |
WList *tmp = NULL; |
|
325 |
int cur_row, cur_col, new_row, new_col; |
|
326 |
int row_inc, col_inc; |
|
327 |
int got_it; |
|
328 |
||
329 |
if(!Current) { |
|
330 |
return; |
|
331 |
}
|
|
332 |
||
333 |
cur_row = Current->row; |
|
334 |
cur_col = Current->col; |
|
335 |
ip = Current->iconmgr; |
|
336 |
||
337 |
row_inc = 0; |
|
338 |
col_inc = 0; |
|
339 |
got_it = FALSE; |
|
340 |
||
341 |
switch(dir) { |
|
342 |
case F_FORWICONMGR: |
|
343 |
if((tmp = Current->next) == NULL) { |
|
344 |
tmp = ip->first; |
|
345 |
}
|
|
346 |
got_it = TRUE; |
|
347 |
break; |
|
348 |
||
349 |
case F_BACKICONMGR: |
|
350 |
if((tmp = Current->prev) == NULL) { |
|
351 |
tmp = ip->last; |
|
352 |
}
|
|
353 |
got_it = TRUE; |
|
354 |
break; |
|
355 |
||
356 |
case F_UPICONMGR: |
|
357 |
row_inc = -1; |
|
358 |
break; |
|
359 |
||
360 |
case F_DOWNICONMGR: |
|
361 |
row_inc = 1; |
|
362 |
break; |
|
363 |
||
364 |
case F_LEFTICONMGR: |
|
365 |
col_inc = -1; |
|
366 |
break; |
|
367 |
||
368 |
case F_RIGHTICONMGR: |
|
369 |
col_inc = 1; |
|
370 |
break; |
|
371 |
}
|
|
372 |
||
373 |
/* If got_it is FALSE ast this point then we got a left, right,
|
|
374 |
* up, or down, command. We will enter this loop until we find
|
|
375 |
* a window to warp to.
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
376 |
*/
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
377 |
new_row = cur_row; |
378 |
new_col = cur_col; |
|
379 |
||
380 |
while(!got_it) { |
|
381 |
new_row += row_inc; |
|
382 |
new_col += col_inc; |
|
383 |
if(new_row < 0) { |
|
384 |
new_row = ip->cur_rows - 1; |
|
385 |
}
|
|
386 |
if(new_col < 0) { |
|
387 |
new_col = ip->cur_columns - 1; |
|
388 |
}
|
|
389 |
if(new_row >= ip->cur_rows) { |
|
390 |
new_row = 0; |
|
391 |
}
|
|
392 |
if(new_col >= ip->cur_columns) { |
|
393 |
new_col = 0; |
|
394 |
}
|
|
395 |
||
396 |
/* Now let's go through the list to see if there is an entry with this
|
|
397 |
* new position
|
|
398 |
*/
|
|
399 |
for(tmp = ip->first; tmp != NULL; tmp = tmp->next) { |
|
400 |
if(tmp->row == new_row && tmp->col == new_col) { |
|
401 |
got_it = TRUE; |
|
402 |
break; |
|
403 |
}
|
|
404 |
}
|
|
405 |
}
|
|
406 |
||
407 |
if(!got_it) { |
|
408 |
fprintf(stderr, |
|
409 |
"%s: unable to find window (%d, %d) in icon manager\n", |
|
410 |
ProgramName, new_row, new_col); |
|
411 |
return; |
|
412 |
}
|
|
413 |
||
414 |
if(tmp == NULL) { |
|
415 |
return; |
|
416 |
}
|
|
417 |
||
418 |
/* raise the frame so the icon manager is visible */
|
|
419 |
if(ip->twm_win->mapped) { |
|
420 |
OtpRaise(ip->twm_win, WinWin); |
|
421 |
XWarpPointer(dpy, None, tmp->icon, 0, 0, 0, 0, 5, 5); |
|
422 |
}
|
|
423 |
else { |
|
424 |
if(tmp->twm->title_height) { |
|
425 |
int tbx = Scr->TBInfo.titlex; |
|
426 |
int x = tmp->twm->highlightxr; |
|
427 |
XWarpPointer(dpy, None, tmp->twm->title_w, 0, 0, 0, 0, |
|
428 |
tbx + (x - tbx) / 2, |
|
429 |
Scr->TitleHeight / 4); |
|
430 |
}
|
|
431 |
else { |
|
432 |
XWarpPointer(dpy, None, tmp->twm->w, 0, 0, 0, 0, 5, 5); |
|
433 |
}
|
|
434 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
435 |
}
|
436 |
||
437 |
/***********************************************************************
|
|
438 |
*
|
|
439 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
440 |
* MoveMappedIconManager - move the pointer around in an icon manager
|
14
by Claude Lecommandeur
CTWM version 3.4 |
441 |
*
|
442 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
443 |
* dir - one of the following:
|
444 |
* F_FORWMAPICONMGR - forward in the window list
|
|
445 |
* F_BACKMAPICONMGR - backward in the window list
|
|
14
by Claude Lecommandeur
CTWM version 3.4 |
446 |
*
|
447 |
* Special Considerations:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
448 |
* none
|
14
by Claude Lecommandeur
CTWM version 3.4 |
449 |
*
|
450 |
***********************************************************************
|
|
451 |
*/
|
|
452 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
453 |
void MoveMappedIconManager(int dir) |
14
by Claude Lecommandeur
CTWM version 3.4 |
454 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
455 |
IconMgr *ip; |
456 |
WList *tmp = NULL; |
|
457 |
WList *orig = NULL; |
|
458 |
int got_it; |
|
459 |
||
460 |
if(!Current) { |
|
461 |
Current = Active; |
|
462 |
}
|
|
463 |
if(!Current) { |
|
464 |
return; |
|
465 |
}
|
|
466 |
||
467 |
ip = Current->iconmgr; |
|
468 |
||
469 |
got_it = 0; |
|
470 |
tmp = Current; |
|
471 |
orig = Current; |
|
472 |
||
473 |
while(!got_it) { |
|
474 |
switch(dir) { |
|
475 |
case F_FORWMAPICONMGR: |
|
476 |
if((tmp = tmp->next) == NULL) { |
|
477 |
tmp = ip->first; |
|
478 |
}
|
|
479 |
break; |
|
480 |
||
481 |
case F_BACKMAPICONMGR: |
|
482 |
if((tmp = tmp->prev) == NULL) { |
|
483 |
tmp = ip->last; |
|
484 |
}
|
|
485 |
break; |
|
486 |
}
|
|
487 |
if(tmp->twm->mapped) { |
|
488 |
got_it = 1; |
|
489 |
break; |
|
490 |
}
|
|
491 |
if(tmp == orig) { |
|
492 |
break; |
|
493 |
}
|
|
494 |
}
|
|
495 |
||
496 |
if(!got_it) { |
|
497 |
fprintf(stderr, "%s: unable to find open window in icon manager\n", |
|
498 |
ProgramName); |
|
499 |
return; |
|
500 |
}
|
|
501 |
||
502 |
if(tmp == NULL) { |
|
503 |
return; |
|
504 |
}
|
|
505 |
||
506 |
/* raise the frame so the icon manager is visible */
|
|
507 |
if(ip->twm_win->mapped) { |
|
508 |
OtpRaise(ip->twm_win, WinWin); |
|
509 |
XWarpPointer(dpy, None, tmp->icon, 0, 0, 0, 0, 5, 5); |
|
510 |
}
|
|
511 |
else { |
|
512 |
if(tmp->twm->title_height) { |
|
513 |
XWarpPointer(dpy, None, tmp->twm->title_w, 0, 0, 0, 0, |
|
514 |
tmp->twm->title_width / 2, |
|
515 |
Scr->TitleHeight / 4); |
|
516 |
}
|
|
517 |
else { |
|
518 |
XWarpPointer(dpy, None, tmp->twm->w, 0, 0, 0, 0, 5, 5); |
|
519 |
}
|
|
520 |
}
|
|
14
by Claude Lecommandeur
CTWM version 3.4 |
521 |
}
|
522 |
||
523 |
/***********************************************************************
|
|
524 |
*
|
|
525 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
526 |
* JumpIconManager - jump from one icon manager to another,
|
527 |
* possibly even on another screen
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
528 |
*
|
529 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
530 |
* dir - one of the following:
|
531 |
* F_NEXTICONMGR - go to the next icon manager
|
|
532 |
* F_PREVICONMGR - go to the previous one
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
533 |
*
|
534 |
***********************************************************************
|
|
535 |
*/
|
|
536 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
537 |
void JumpIconManager(register int dir) |
1
by Claude Lecommandeur
CTWM version 1.1 |
538 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
539 |
IconMgr *ip, *tmp_ip = NULL; |
540 |
int got_it = FALSE; |
|
541 |
ScreenInfo *sp; |
|
542 |
int screen; |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
543 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
544 |
if(!Current) { |
545 |
return; |
|
546 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
547 |
|
548 |
||
549 |
#define ITER(i) (dir == F_NEXTICONMGR ? (i)->next : (i)->prev)
|
|
550 |
#define IPOFSP(sp) (dir == F_NEXTICONMGR ? sp->iconmgr : sp->iconmgr->lasti)
|
|
551 |
#define TEST(ip) if ((ip)->count != 0 && (ip)->twm_win->mapped) \
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
552 |
{ got_it = TRUE; break; }
|
553 |
||
554 |
ip = Current->iconmgr; |
|
555 |
for(tmp_ip = ITER(ip); tmp_ip; tmp_ip = ITER(tmp_ip)) { |
|
556 |
TEST(tmp_ip); |
|
557 |
}
|
|
558 |
||
559 |
if(!got_it) { |
|
560 |
int origscreen = ip->scr->screen; |
|
561 |
int inc = (dir == F_NEXTICONMGR ? 1 : -1); |
|
562 |
||
563 |
for(screen = origscreen + inc; ; screen += inc) { |
|
564 |
if(screen >= NumScreens) { |
|
565 |
screen = 0; |
|
566 |
}
|
|
567 |
else if(screen < 0) { |
|
568 |
screen = NumScreens - 1; |
|
569 |
}
|
|
570 |
||
571 |
sp = ScreenList[screen]; |
|
572 |
if(sp) { |
|
573 |
for(tmp_ip = IPOFSP(sp); tmp_ip; tmp_ip = ITER(tmp_ip)) { |
|
574 |
TEST(tmp_ip); |
|
575 |
}
|
|
576 |
}
|
|
577 |
if(got_it || screen == origscreen) { |
|
578 |
break; |
|
579 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
580 |
}
|
581 |
}
|
|
582 |
||
583 |
#undef ITER
|
|
584 |
#undef IPOFSP
|
|
585 |
#undef TEST
|
|
586 |
||
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
587 |
if(!got_it) { |
588 |
XBell(dpy, 0); |
|
589 |
return; |
|
590 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
591 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
592 |
/* raise the frame so it is visible */
|
593 |
OtpRaise(tmp_ip->twm_win, WinWin); |
|
594 |
if(tmp_ip->active) { |
|
595 |
XWarpPointer(dpy, None, tmp_ip->active->icon, 0, 0, 0, 0, 5, 5); |
|
596 |
}
|
|
597 |
else { |
|
598 |
XWarpPointer(dpy, None, tmp_ip->w, 0, 0, 0, 0, 5, 5); |
|
599 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
600 |
}
|
601 |
||
602 |
/***********************************************************************
|
|
603 |
*
|
|
604 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
605 |
* AddIconManager - add a window to an icon manager
|
1
by Claude Lecommandeur
CTWM version 1.1 |
606 |
*
|
607 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
608 |
* tmp_win - the TwmWindow structure
|
1
by Claude Lecommandeur
CTWM version 1.1 |
609 |
*
|
610 |
***********************************************************************
|
|
611 |
*/
|
|
612 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
613 |
WList *AddIconManager(TwmWindow *tmp_win) |
1
by Claude Lecommandeur
CTWM version 1.1 |
614 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
615 |
WList *tmp, *old; |
616 |
IconMgr *ip; |
|
617 |
||
318.1.3
by Matthew Fuller
Break up a couple conditionals and add some comments through the first |
618 |
/* Some window types don't wind up in icon managers ever */
|
619 |
if(tmp_win->iconmgr || tmp_win->transient || tmp_win->wspmgr |
|
318.1.8
by Matthew Fuller
OK, astyle really wants this pushed over, so give in. |
620 |
|| tmp_win->w == Scr->workSpaceMgr.occupyWindow->w) { |
318.1.3
by Matthew Fuller
Break up a couple conditionals and add some comments through the first |
621 |
return NULL; |
622 |
}
|
|
623 |
||
624 |
/* Icon managers can be shut off wholesale in the config */
|
|
625 |
if(Scr->NoIconManagers) { |
|
626 |
return NULL; |
|
627 |
}
|
|
628 |
||
629 |
/* Config could declare not to IMify this type of window in two ways */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
630 |
if(LookInList(Scr->IconMgrNoShow, tmp_win->full_name, &tmp_win->class)) { |
631 |
return NULL; |
|
632 |
}
|
|
318.1.2
by Matthew Fuller
Minor rewrapping of lines in AddIconManager(). No functional change. |
633 |
if(Scr->IconManagerDontShow |
634 |
&& !LookInList(Scr->IconMgrShow, tmp_win->full_name, &tmp_win->class)) { |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
635 |
return NULL; |
636 |
}
|
|
318.1.3
by Matthew Fuller
Break up a couple conditionals and add some comments through the first |
637 |
|
638 |
/* Dredge up the appropriate IM */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
639 |
if((ip = (IconMgr *)LookInList(Scr->IconMgrs, tmp_win->full_name, |
640 |
&tmp_win->class)) == NULL) { |
|
641 |
if(Scr->workSpaceManagerActive) { |
|
642 |
ip = Scr->workSpaceMgr.workSpaceList->iconmgr; |
|
643 |
}
|
|
644 |
else { |
|
645 |
ip = Scr->iconmgr; |
|
646 |
}
|
|
647 |
}
|
|
648 |
||
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
649 |
/* IM's exist in all workspaces, so loop through WSen */
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
650 |
tmp = NULL; |
651 |
old = tmp_win->iconmanagerlist; |
|
652 |
while(ip != NULL) { |
|
318.1.4
by Matthew Fuller
These two vars are only used inside this scope, so narrow them in. |
653 |
int h; |
318.1.5
by Matthew Fuller
This is also only used in here. |
654 |
unsigned long valuemask; /* mask for create windows */ |
318.1.4
by Matthew Fuller
These two vars are only used inside this scope, so narrow them in. |
655 |
XSetWindowAttributes attributes; /* attributes for create windows */ |
656 |
||
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
657 |
/* Is the window in this workspace? */
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
658 |
if((tmp_win->occupation & ip->twm_win->occupation) == 0) { |
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
659 |
/* Nope, skip onward */
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
660 |
ip = ip->nextv; |
661 |
continue; |
|
662 |
}
|
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
663 |
|
664 |
/* Yep, create entry and stick it in */
|
|
665 |
tmp = calloc(1, sizeof(WList)); |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
666 |
tmp->iconmgr = ip; |
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
667 |
tmp->twm = tmp_win; |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
668 |
|
669 |
InsertInIconManager(ip, tmp, tmp_win); |
|
670 |
||
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
671 |
/* IM color settings, shared worldwide */
|
672 |
tmp->cp.fore = Scr->IconManagerC.fore; |
|
673 |
tmp->cp.back = Scr->IconManagerC.back; |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
674 |
tmp->highlight = Scr->IconManagerHighlight; |
675 |
||
318.1.2
by Matthew Fuller
Minor rewrapping of lines in AddIconManager(). No functional change. |
676 |
GetColorFromList(Scr->IconManagerFL, tmp_win->full_name, |
677 |
&tmp_win->class, &tmp->cp.fore); |
|
678 |
GetColorFromList(Scr->IconManagerBL, tmp_win->full_name, |
|
679 |
&tmp_win->class, &tmp->cp.back); |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
680 |
GetColorFromList(Scr->IconManagerHighlightL, tmp_win->full_name, |
681 |
&tmp_win->class, &tmp->highlight); |
|
682 |
||
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
683 |
/* Pop! */
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
684 |
if(Scr->use3Diconmanagers) { |
685 |
if(!Scr->BeNiceToColormap) { |
|
686 |
GetShadeColors(&tmp->cp); |
|
687 |
}
|
|
688 |
tmp->iconifypm = Create3DIconManagerIcon(tmp->cp); |
|
689 |
}
|
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
690 |
|
691 |
/* Refigure the height of the whole IM */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
692 |
h = Scr->IconManagerFont.avg_height |
693 |
+ 2 * (ICON_MGR_OBORDER + ICON_MGR_OBORDER); |
|
333
by Matthew Fuller
Revert r331 turning these back into vars, but move them into iconmgr |
694 |
if(h < (siconify_height + 4)) { |
695 |
h = siconify_height + 4; |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
696 |
}
|
697 |
||
698 |
ip->height = h * ip->count; |
|
699 |
tmp->me = ip->count; |
|
700 |
tmp->x = -1; |
|
701 |
tmp->y = -1; |
|
702 |
tmp->height = -1; |
|
703 |
tmp->width = -1; |
|
704 |
||
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
705 |
|
706 |
/* Make a window for this row in the IM */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
707 |
valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor); |
708 |
attributes.background_pixel = tmp->cp.back; |
|
709 |
attributes.border_pixel = tmp->cp.back; |
|
710 |
attributes.event_mask = (KeyPressMask | ButtonPressMask | |
|
711 |
ButtonReleaseMask | ExposureMask); |
|
712 |
if(Scr->IconManagerFocus) { |
|
713 |
attributes.event_mask |= (EnterWindowMask | LeaveWindowMask); |
|
714 |
}
|
|
715 |
attributes.cursor = Scr->IconMgrCursor; |
|
716 |
tmp->w = XCreateWindow(dpy, ip->w, 0, 0, (unsigned int) 1, |
|
717 |
(unsigned int) h, (unsigned int) 0, |
|
718 |
CopyFromParent, (unsigned int) CopyFromParent, |
|
318.1.2
by Matthew Fuller
Minor rewrapping of lines in AddIconManager(). No functional change. |
719 |
(Visual *) CopyFromParent, |
720 |
valuemask, &attributes); |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
721 |
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
722 |
|
723 |
/* Setup the icon for it too */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
724 |
valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor); |
725 |
attributes.background_pixel = tmp->cp.back; |
|
726 |
attributes.border_pixel = Scr->Black; |
|
318.1.2
by Matthew Fuller
Minor rewrapping of lines in AddIconManager(). No functional change. |
727 |
attributes.event_mask = (ButtonReleaseMask | ButtonPressMask |
728 |
| ExposureMask); |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
729 |
attributes.cursor = Scr->ButtonCursor; |
730 |
/* The precise location will be set it in PackIconManager. */
|
|
731 |
tmp->icon = XCreateWindow(dpy, tmp->w, 0, 0, |
|
333
by Matthew Fuller
Revert r331 turning these back into vars, but move them into iconmgr |
732 |
(unsigned int) siconify_width, |
733 |
(unsigned int) siconify_height, |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
734 |
(unsigned int) 0, CopyFromParent, |
735 |
(unsigned int) CopyFromParent, |
|
736 |
(Visual *) CopyFromParent, |
|
737 |
valuemask, &attributes); |
|
738 |
||
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
739 |
|
740 |
/* Bump housekeeping for the IM */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
741 |
ip->count += 1; |
742 |
PackIconManager(ip); |
|
743 |
if(Scr->WindowMask) { |
|
744 |
XRaiseWindow(dpy, Scr->WindowMask); |
|
745 |
}
|
|
746 |
XMapWindow(dpy, tmp->w); |
|
747 |
||
748 |
XSaveContext(dpy, tmp->w, TwmContext, (XPointer) tmp_win); |
|
749 |
XSaveContext(dpy, tmp->w, ScreenContext, (XPointer) Scr); |
|
750 |
XSaveContext(dpy, tmp->icon, TwmContext, (XPointer) tmp_win); |
|
751 |
XSaveContext(dpy, tmp->icon, ScreenContext, (XPointer) Scr); |
|
752 |
||
753 |
if(!ip->twm_win->isicon) { |
|
754 |
if(visible(ip->twm_win)) { |
|
755 |
SetMapStateProp(ip->twm_win, NormalState); |
|
756 |
XMapWindow(dpy, ip->w); |
|
757 |
XMapWindow(dpy, ip->twm_win->frame); |
|
758 |
}
|
|
759 |
ip->twm_win->mapped = TRUE; |
|
760 |
}
|
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
761 |
|
762 |
||
763 |
/*
|
|
764 |
* Stick this entry on the head of our list of "IM entries we
|
|
765 |
* created", and loop around to the next WS for this IM.
|
|
766 |
*/
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
767 |
tmp->nextv = old; |
768 |
old = tmp; |
|
769 |
ip = ip->nextv; |
|
770 |
}
|
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
771 |
|
772 |
/* If we didn't create at least one thing, we're done here */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
773 |
if(tmp == NULL) { |
774 |
return NULL; |
|
775 |
}
|
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
776 |
|
777 |
/* Stash where the window is IM-listed */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
778 |
tmp_win->iconmanagerlist = tmp; |
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
779 |
|
780 |
/* ??? */
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
781 |
if(! visible(tmp->iconmgr->twm_win)) { |
782 |
old = tmp; |
|
783 |
tmp = tmp->nextv; |
|
784 |
while(tmp != NULL) { |
|
785 |
if(visible(tmp->iconmgr->twm_win)) { |
|
786 |
break; |
|
787 |
}
|
|
788 |
old = tmp; |
|
789 |
tmp = tmp->nextv; |
|
790 |
}
|
|
791 |
if(tmp != NULL) { |
|
792 |
old->nextv = tmp->nextv; |
|
793 |
tmp->nextv = tmp_win->iconmanagerlist; |
|
794 |
tmp_win->iconmanagerlist = tmp; |
|
795 |
}
|
|
796 |
}
|
|
318.1.6
by Matthew Fuller
Add a few more comments, and rearrange a couple lines. Should be no |
797 |
|
318.1.7
by Matthew Fuller
Less bad engrish. |
798 |
/* Hand back the list places we added */
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
799 |
return tmp_win->iconmanagerlist; |
1
by Claude Lecommandeur
CTWM version 1.1 |
800 |
}
|
801 |
||
802 |
/***********************************************************************
|
|
803 |
*
|
|
804 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
805 |
* InsertInIconManager - put an allocated entry into an icon
|
806 |
* manager
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
807 |
*
|
808 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
809 |
* ip - the icon manager pointer
|
810 |
* tmp - the entry to insert
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
811 |
*
|
812 |
***********************************************************************
|
|
813 |
*/
|
|
814 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
815 |
void InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win) |
1
by Claude Lecommandeur
CTWM version 1.1 |
816 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
817 |
WList *tmp1; |
818 |
int added; |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
819 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
820 |
added = FALSE; |
821 |
if(ip->first == NULL) { |
|
822 |
ip->first = tmp; |
|
823 |
tmp->prev = NULL; |
|
824 |
ip->last = tmp; |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
825 |
added = TRUE; |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
826 |
}
|
827 |
else if(Scr->SortIconMgr) { |
|
828 |
for(tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) { |
|
829 |
int compresult; |
|
830 |
if(Scr->CaseSensitive) { |
|
831 |
compresult = strcmp(tmp_win->icon_name, tmp1->twm->icon_name); |
|
832 |
}
|
|
833 |
else { |
|
324.1.7
by Matthew Fuller
XmuCompareISOLatin1 -> strcasecmp. We can reture Xmu includes for |
834 |
compresult = strcasecmp(tmp_win->icon_name, tmp1->twm->icon_name); |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
835 |
}
|
836 |
if(compresult < 0) { |
|
837 |
tmp->next = tmp1; |
|
838 |
tmp->prev = tmp1->prev; |
|
839 |
tmp1->prev = tmp; |
|
840 |
if(tmp->prev == NULL) { |
|
841 |
ip->first = tmp; |
|
842 |
}
|
|
843 |
else { |
|
844 |
tmp->prev->next = tmp; |
|
845 |
}
|
|
846 |
added = TRUE; |
|
847 |
break; |
|
848 |
}
|
|
849 |
}
|
|
850 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
851 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
852 |
if(!added) { |
853 |
ip->last->next = tmp; |
|
854 |
tmp->prev = ip->last; |
|
855 |
ip->last = tmp; |
|
856 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
857 |
}
|
858 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
859 |
void RemoveFromIconManager(IconMgr *ip, WList *tmp) |
1
by Claude Lecommandeur
CTWM version 1.1 |
860 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
861 |
if(tmp->prev == NULL) { |
862 |
ip->first = tmp->next; |
|
863 |
}
|
|
864 |
else { |
|
865 |
tmp->prev->next = tmp->next; |
|
866 |
}
|
|
867 |
||
868 |
if(tmp->next == NULL) { |
|
869 |
ip->last = tmp->prev; |
|
870 |
}
|
|
871 |
else { |
|
872 |
tmp->next->prev = tmp->prev; |
|
873 |
}
|
|
874 |
||
875 |
/* pebl: If the list was the current and tmp was the last in the list
|
|
876 |
reset current list */
|
|
877 |
if(Current == tmp) { |
|
878 |
Current = ip->first; |
|
879 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
880 |
}
|
881 |
||
882 |
/***********************************************************************
|
|
883 |
*
|
|
884 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
885 |
* RemoveIconManager - remove a window from the icon manager
|
1
by Claude Lecommandeur
CTWM version 1.1 |
886 |
*
|
887 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
888 |
* tmp_win - the TwmWindow structure
|
1
by Claude Lecommandeur
CTWM version 1.1 |
889 |
*
|
890 |
***********************************************************************
|
|
891 |
*/
|
|
892 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
893 |
void RemoveIconManager(TwmWindow *tmp_win) |
1
by Claude Lecommandeur
CTWM version 1.1 |
894 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
895 |
IconMgr *ip; |
896 |
WList *tmp, *tmp1, *save; |
|
897 |
||
898 |
if(tmp_win->iconmanagerlist == NULL) { |
|
899 |
return; |
|
900 |
}
|
|
901 |
||
902 |
tmp = tmp_win->iconmanagerlist; |
|
903 |
tmp1 = NULL; |
|
904 |
||
905 |
while(tmp != NULL) { |
|
906 |
ip = tmp->iconmgr; |
|
907 |
if((tmp_win->occupation & ip->twm_win->occupation) != 0) { |
|
908 |
tmp1 = tmp; |
|
909 |
tmp = tmp->nextv; |
|
910 |
continue; |
|
911 |
}
|
|
912 |
RemoveFromIconManager(ip, tmp); |
|
913 |
||
914 |
XDeleteContext(dpy, tmp->icon, TwmContext); |
|
915 |
XDeleteContext(dpy, tmp->icon, ScreenContext); |
|
916 |
XDestroyWindow(dpy, tmp->icon); |
|
917 |
XDeleteContext(dpy, tmp->w, TwmContext); |
|
918 |
XDeleteContext(dpy, tmp->w, ScreenContext); |
|
919 |
XDestroyWindow(dpy, tmp->w); |
|
920 |
ip->count -= 1; |
|
921 |
||
922 |
PackIconManager(ip); |
|
923 |
||
924 |
if(ip->count == 0) { |
|
925 |
XUnmapWindow(dpy, ip->twm_win->frame); |
|
926 |
ip->twm_win->mapped = FALSE; |
|
927 |
}
|
|
928 |
if(tmp1 == NULL) { |
|
929 |
tmp_win->iconmanagerlist = tmp_win->iconmanagerlist->nextv; |
|
930 |
}
|
|
931 |
else { |
|
932 |
tmp1->nextv = tmp->nextv; |
|
933 |
}
|
|
934 |
||
935 |
save = tmp; |
|
936 |
tmp = tmp->nextv; |
|
937 |
free((char *) save); |
|
938 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
939 |
}
|
940 |
||
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
941 |
void CurrentIconManagerEntry(WList *current) |
10
by Claude Lecommandeur
CTWM version 3.1p3 |
942 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
943 |
Current = current; |
10
by Claude Lecommandeur
CTWM version 3.1p3 |
944 |
}
|
945 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
946 |
void ActiveIconManager(WList *active) |
1
by Claude Lecommandeur
CTWM version 1.1 |
947 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
948 |
active->active = TRUE; |
949 |
Active = active; |
|
950 |
Active->iconmgr->active = active; |
|
951 |
Current = Active; |
|
952 |
DrawIconManagerBorder(active, False); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
953 |
}
|
954 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
955 |
void NotActiveIconManager(WList *active) |
1
by Claude Lecommandeur
CTWM version 1.1 |
956 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
957 |
active->active = FALSE; |
958 |
DrawIconManagerBorder(active, False); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
959 |
}
|
960 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
961 |
void DrawIconManagerBorder(WList *tmp, int fill) |
1
by Claude Lecommandeur
CTWM version 1.1 |
962 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
963 |
if(Scr->use3Diconmanagers) { |
964 |
Draw3DBorder(tmp->w, 0, 0, tmp->width, tmp->height, |
|
965 |
Scr->IconManagerShadowDepth, tmp->cp, |
|
966 |
(tmp->active && Scr->Highlight ? on : off), |
|
967 |
fill, False); |
|
968 |
}
|
|
969 |
else { |
|
970 |
XSetForeground(dpy, Scr->NormalGC, tmp->cp.fore); |
|
971 |
XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 2, 2, tmp->width - 5, |
|
972 |
tmp->height - 5); |
|
973 |
||
974 |
XSetForeground(dpy, Scr->NormalGC, |
|
975 |
(tmp->active && Scr->Highlight |
|
976 |
? tmp->highlight : tmp->cp.back)); |
|
977 |
||
978 |
XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 0, 0, tmp->width - 1, |
|
979 |
tmp->height - 1); |
|
980 |
XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 1, 1, tmp->width - 3, |
|
981 |
tmp->height - 3); |
|
982 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
983 |
}
|
984 |
||
985 |
/***********************************************************************
|
|
986 |
*
|
|
987 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
988 |
* SortIconManager - sort the dude
|
1
by Claude Lecommandeur
CTWM version 1.1 |
989 |
*
|
990 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
991 |
* ip - a pointer to the icon manager struture
|
1
by Claude Lecommandeur
CTWM version 1.1 |
992 |
*
|
993 |
***********************************************************************
|
|
994 |
*/
|
|
995 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
996 |
void SortIconManager(IconMgr *ip) |
1
by Claude Lecommandeur
CTWM version 1.1 |
997 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
998 |
WList *tmp1, *tmp2; |
999 |
int done; |
|
1000 |
||
1001 |
if(ip == NULL) { |
|
1002 |
ip = Active->iconmgr; |
|
1003 |
}
|
|
1004 |
||
1005 |
done = FALSE; |
|
1006 |
do { |
|
1007 |
for(tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) { |
|
1008 |
int compresult; |
|
1009 |
if((tmp2 = tmp1->next) == NULL) { |
|
1010 |
done = TRUE; |
|
1011 |
break; |
|
1012 |
}
|
|
1013 |
if(Scr->CaseSensitive) { |
|
1014 |
compresult = strcmp(tmp1->twm->icon_name, tmp2->twm->icon_name); |
|
1015 |
}
|
|
1016 |
else { |
|
324.1.7
by Matthew Fuller
XmuCompareISOLatin1 -> strcasecmp. We can reture Xmu includes for |
1017 |
compresult = strcasecmp(tmp1->twm->icon_name, tmp2->twm->icon_name); |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1018 |
}
|
1019 |
if(compresult > 0) { |
|
1020 |
/* take it out and put it back in */
|
|
1021 |
RemoveFromIconManager(ip, tmp2); |
|
1022 |
InsertInIconManager(ip, tmp2, tmp2->twm); |
|
1023 |
break; |
|
1024 |
}
|
|
1025 |
}
|
|
1026 |
}
|
|
1027 |
while(!done); |
|
1028 |
PackIconManager(ip); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
1029 |
}
|
1030 |
||
1031 |
/***********************************************************************
|
|
1032 |
*
|
|
1033 |
* Procedure:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1034 |
* PackIconManager - pack the icon manager windows following
|
1035 |
* an addition or deletion
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
1036 |
*
|
1037 |
* Inputs:
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1038 |
* ip - a pointer to the icon manager struture
|
1
by Claude Lecommandeur
CTWM version 1.1 |
1039 |
*
|
1040 |
***********************************************************************
|
|
1041 |
*/
|
|
1042 |
||
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1043 |
void PackIconManagers(void) |
240.1.2
by Rhialto
3 - Selected a number of cleanups from Stefan Monnier |
1044 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1045 |
TwmWindow *twm_win; |
1046 |
||
1047 |
for(twm_win = Scr->FirstWindow; twm_win != NULL; twm_win = twm_win->next) { |
|
1048 |
if(twm_win->iconmgrp) { |
|
1049 |
PackIconManager(twm_win->iconmgrp); |
|
1050 |
}
|
|
1051 |
}
|
|
240.1.2
by Rhialto
3 - Selected a number of cleanups from Stefan Monnier |
1052 |
}
|
1053 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
1054 |
void PackIconManager(IconMgr *ip) |
1
by Claude Lecommandeur
CTWM version 1.1 |
1055 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1056 |
int newwidth, i, row, col, maxcol, colinc, rowinc, wheight, wwidth; |
1057 |
int new_x, new_y; |
|
1058 |
int savewidth; |
|
1059 |
WList *tmp; |
|
1060 |
int mask; |
|
1061 |
unsigned int JunkW, JunkH; |
|
1062 |
||
1063 |
wheight = Scr->IconManagerFont.avg_height |
|
1064 |
+ 2 * (ICON_MGR_OBORDER + ICON_MGR_IBORDER); |
|
333
by Matthew Fuller
Revert r331 turning these back into vars, but move them into iconmgr |
1065 |
if(wheight < (siconify_height + 4)) { |
1066 |
wheight = siconify_height + 4; |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1067 |
}
|
1068 |
||
1069 |
wwidth = ip->width / ip->columns; |
|
1070 |
||
1071 |
rowinc = wheight; |
|
1072 |
colinc = wwidth; |
|
1073 |
||
1074 |
row = 0; |
|
1075 |
col = ip->columns; |
|
1076 |
maxcol = 0; |
|
1077 |
for(i = 0, tmp = ip->first; tmp != NULL; i++, tmp = tmp->next) { |
|
1078 |
tmp->me = i; |
|
1079 |
if(++col >= ip->columns) { |
|
1080 |
col = 0; |
|
1081 |
row += 1; |
|
1082 |
}
|
|
1083 |
if(col > maxcol) { |
|
1084 |
maxcol = col; |
|
1085 |
}
|
|
1086 |
||
1087 |
new_x = col * colinc; |
|
1088 |
new_y = (row - 1) * rowinc; |
|
1089 |
||
1090 |
/* if the position or size has not changed, don't touch it */
|
|
1091 |
if(tmp->x != new_x || tmp->y != new_y || |
|
1092 |
tmp->width != wwidth || tmp->height != wheight) { |
|
1093 |
XMoveResizeWindow(dpy, tmp->w, new_x, new_y, wwidth, wheight); |
|
1094 |
if(tmp->height != wheight) |
|
1095 |
XMoveWindow(dpy, tmp->icon, ICON_MGR_OBORDER + ICON_MGR_IBORDER, |
|
333
by Matthew Fuller
Revert r331 turning these back into vars, but move them into iconmgr |
1096 |
(wheight - siconify_height) / 2); |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1097 |
|
1098 |
tmp->row = row - 1; |
|
1099 |
tmp->col = col; |
|
1100 |
tmp->x = new_x; |
|
1101 |
tmp->y = new_y; |
|
1102 |
tmp->width = wwidth; |
|
1103 |
tmp->height = wheight; |
|
1104 |
}
|
|
1105 |
}
|
|
1106 |
maxcol += 1; |
|
1107 |
||
1108 |
ip->cur_rows = row; |
|
1109 |
ip->cur_columns = maxcol; |
|
1110 |
ip->height = row * rowinc; |
|
1111 |
if(ip->height == 0) { |
|
1112 |
ip->height = rowinc; |
|
1113 |
}
|
|
1114 |
newwidth = maxcol * colinc; |
|
1115 |
if(newwidth == 0) { |
|
1116 |
newwidth = colinc; |
|
1117 |
}
|
|
1118 |
||
1119 |
XResizeWindow(dpy, ip->w, newwidth, ip->height); |
|
1120 |
||
1121 |
mask = XParseGeometry(ip->geometry, &JunkX, &JunkY, &JunkW, &JunkH); |
|
1122 |
if(mask & XNegative) { |
|
1123 |
ip->twm_win->frame_x += ip->twm_win->frame_width - newwidth - |
|
1124 |
2 * ip->twm_win->frame_bw3D; |
|
1125 |
}
|
|
1126 |
if(mask & YNegative) { |
|
1127 |
ip->twm_win->frame_y += ip->twm_win->frame_height - ip->height - |
|
1128 |
2 * ip->twm_win->frame_bw3D - ip->twm_win->title_height; |
|
1129 |
}
|
|
1130 |
savewidth = ip->width; |
|
1131 |
if(ip->twm_win) |
|
1132 |
SetupWindow(ip->twm_win, |
|
1133 |
ip->twm_win->frame_x, ip->twm_win->frame_y, |
|
1134 |
newwidth + 2 * ip->twm_win->frame_bw3D, |
|
1135 |
ip->height + ip->twm_win->title_height + 2 * ip->twm_win->frame_bw3D, -1); |
|
1136 |
ip->width = savewidth; |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
1137 |
}
|
240.1.24
by Olaf 'Rhialto' Seibert
Prevent all icon manager windows from appearing in workspace #0. |
1138 |
|
1139 |
void dump_iconmanager(IconMgr *mgr, char *label) |
|
1140 |
{
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
1141 |
fprintf(stderr, "IconMgr %s %p name='%s' geom='%s'\n", |
1142 |
label, |
|
1143 |
mgr, |
|
1144 |
mgr->name, |
|
1145 |
mgr->geometry); |
|
1146 |
fprintf(stderr, "next = %p, prev = %p, lasti = %p, nextv = %p\n", |
|
1147 |
mgr->next, |
|
1148 |
mgr->prev, |
|
1149 |
mgr->lasti, |
|
1150 |
mgr->nextv); |
|
240.1.24
by Olaf 'Rhialto' Seibert
Prevent all icon manager windows from appearing in workspace #0. |
1151 |
}
|