1 /*
2 * Motif
3 *
4 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
5 *
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
16 * details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
22 */
23 /*
24 * HISTORY
25 */
26 #ifdef REV_INFO
27 #ifndef lint
28 static char rcsid[] = "$TOG: wsmSend.c /main/7 1997/03/31 14:15:32 dbl $"
29 #endif
30 #endif
31 #include <stdio.h>
32 #include <Xm/Xm.h>
33
34 #include "wsm.h"
35 #include "wsmSend.h"
36 #include "xrmLib.h"
37 #include "wsmData.h"
38 #include "wsmDebug.h"
39 #include "wsmStruct.h"
40 #include "command_ui.h"
41
42
43
44 /* Globals */
45 extern AtomStruct atoms;
46 extern Boolean mwm_gone;
47 extern Window mwm_window;
48 extern Space *space_list;
49 extern Space *all_space;
50 extern Space *current_space;
51 extern WorkWindow *work_windows;
52 extern XrmQuark *space_qlist;
53 extern XrmQuark *window_attribq;
54 extern XrmQuark *icon_attribq;
55 extern XrmQuark *global_attribq;
56 extern IndexStruct wsm_index;
57 extern WSMAttribute *window_attrib_list;
58 extern WSMAttribute *icon_attrib_list;
59 extern WSMAttribute *global_attrib_list;
60 extern int num_window_attrib;
61 extern int num_icon_attrib;
62 extern int num_global_attrib;
63 extern Boolean diffs_allowed;
64 extern Widget shell;
65 extern Display *dsp;
66 extern Boolean connected;
67 extern char *file_name;
68 extern Boolean mwm_reconnect;
69 static XrmQuark linkedRoomQuark;
70
71 /*------------------------------------------------------------------
72 GetDataListStart
73
74 ------------------------------------------------------------------*/
75 static
76 void
GetDataListStart(WorkWindow * w_window,int i,XrmQuark room_q,Boolean diffs,WSMGetStateReply * get_state,WSMWinData ** data_list,int * num_data)77 GetDataListStart(WorkWindow *w_window,
78 int i,
79 XrmQuark room_q,
80 Boolean diffs,
81 WSMGetStateReply *get_state,
82 WSMWinData **data_list,
83 int *num_data)
84 {
85 XrmValue *attr_values;
86 /* get window attributes from database */
87 GetWindowConfigurationEntry(w_window->specifier_qlist,
88 w_window->attrib_qlist,
89 room_q,
90 &attr_values);
91 /* create set state request */
92 /* print_values(attr_values,w_window->attrib_qlist,
93 room_q, w_window->num_attrib_list);*/
94 /* use WSM_GET_STATE to initialize data structures */
95 /* fill in data_list and num_data for WSM_SET_STATE request */
96 if (get_state != NULL)
97 CreateStartWSMWinData(attr_values,
98 diffs,
99 get_state->win_info_list[i].data_list,
100 get_state->win_info_list[i].num_data_list,
101 w_window,
102 data_list,
103 num_data);
104 else
105 CreateStartWSMWinData(attr_values,
106 diffs,
107 NULL,
108 0,
109 w_window,
110 data_list,
111 num_data);
112
113 if (attr_values != NULL) XtFree((XtPointer)attr_values);
114
115 }
116
117
118 /*------------------------------------------------------------------
119 GetDataList
120
121 ------------------------------------------------------------------*/
122 static
123 void
GetDataList(WorkWindow * w_window,XrmQuark room_q,Boolean diffs,WSMWinData ** data_list,int * num_data)124 GetDataList(WorkWindow *w_window,
125 XrmQuark room_q,
126 Boolean diffs,
127 WSMWinData **data_list,
128 int *num_data)
129 {
130 XrmValue *attr_values;
131 /* get window configuration from database */
132 GetWindowConfigurationEntry(w_window->specifier_qlist,
133 w_window->attrib_qlist,
134 room_q,
135 &attr_values);
136 /* create set state request */
137 /* print_values(attr_values,w_window->attrib_qlist,
138 room_q, w_window->num_attrib_list);*/
139 /* fill in data_list and num_data for WSM_SET_STATE request */
140 CreateWSMWinData(attr_values,
141 diffs,
142 w_window,
143 data_list,
144 num_data);
145 if (attr_values != NULL)
146 XtFree((XtPointer)attr_values);
147 }
148
149
150
151 /*------------------------------------------------------------------
152 GetUnhideDataList
153
154 ------------------------------------------------------------------*/
155 static
156 void
GetUnhideDataList(WorkWindow * w_window,XrmQuark room_q,WSMWinData ** data_list,int * num_data)157 GetUnhideDataList(WorkWindow *w_window,
158 XrmQuark room_q,
159 WSMWinData **data_list,
160 int *num_data)
161 {
162 /* fill in data_list and num_data for WSM_SET_STATE request */
163 CreateUnhideWSMWinData(NULL,
164 w_window,
165 data_list,
166 num_data);
167
168 }
169
170 /*------------------------------------------------------------------
171 CreateStartStateRequest
172
173 ------------------------------------------------------------------*/
174 void
CreateStartStateRequest(WSMGetStateReply * get_state,WSMRequest * request)175 CreateStartStateRequest(WSMGetStateReply *get_state,
176 WSMRequest *request)
177 {
178 Window window;
179 int i;
180 XrmQuarkList rooms_qlist = NULL;
181 WSMWinData *xrm_data_list;
182 int num_xrm_data_list;
183 WorkWindow *w_window = NULL;
184 Boolean linked = False;
185 Boolean all_work = False;
186 int num_win;
187 WSMWinInfo *win_info;
188 Boolean in_current_space = False;
189 XrmQuark room_name = NULLQUARK;
190
191 /* print_reply_start_state(get_state);*/
192
193 PRINT("\nSTART STATE\n");
194 linkedRoomQuark = XrmStringToQuark("linkedRoom");
195 request->set_state.num_win_info_list = 0;
196 num_win = 0;
197 win_info = (WSMWinInfo*)XtMalloc((get_state->num_win_info_list)*sizeof(WSMWinInfo));
198 for (i = 0; i < get_state->num_win_info_list; i ++)
199 {
200 in_current_space = False;
201 window = get_state->win_info_list[i].window;
202 if (mwm_reconnect && (w_window = GetWorkWindow(window)) != NULL)
203 {
204 w_window->used = True;
205 if ( !IsWorkWindowInSpace(w_window,current_space))
206 CreateHideWSMWinData(diffs_allowed,
207 w_window,
208 &xrm_data_list,
209 &num_xrm_data_list);
210 else num_xrm_data_list = 0;
211 }
212 else
213 {
214 w_window = CreateWorkWindow(window);
215 /* get window's workspace resources from database */
216 if (GetWorkspaceResources(shell,
217 w_window->specifier_qlist,
218 &rooms_qlist,
219 &all_work,
220 &linked))
221 {
222 /* set the workspace values received from database */
223 SetWorkWindowValues(w_window,all_work,linked);
224 /* set links in internal structures */
225 in_current_space = CreateInternalStructure(w_window,rooms_qlist);
226 /* if its in current space or no diffs allowed,
227 get config info for WSM_SET_STATE */
228 if (in_current_space || !diffs_allowed)
229 {
230 if (linked) room_name = linkedRoomQuark;
231 else if (!diffs_allowed && !in_current_space)
232 room_name = rooms_qlist[0];
233 else room_name = current_space->nameq;
234 GetDataListStart(w_window,
235 i,
236 room_name,
237 diffs_allowed,
238 get_state,
239 &xrm_data_list,
240 &num_xrm_data_list);
241 /* set last space variable */
242 if (in_current_space) w_window->last_space = current_space;
243 /* if no diffs allowed && not in current space then set hide
244 info to True */
245 else
246 {
247 w_window->win_data[wsm_index.hide].data.value = 1;
248 xrm_data_list[wsm_index.hide].data.value = 1;
249 w_window->last_space = GetSpace(room_name);
250 }
251 }
252 /* else only send hide info in WSM_SET_STATE */
253 else
254 {
255 /* create set state request */
256 CreateStartHideWSMWinData(diffs_allowed,
257 get_state->win_info_list[i].data_list,
258 get_state->win_info_list[i].num_data_list,
259 w_window,
260 &xrm_data_list,
261 &num_xrm_data_list);
262 }
263 if (rooms_qlist != NULL)
264 XtFree((XtPointer)rooms_qlist);
265 }
266 /* nothing in the database */
267 else
268 {
269 CreateStartWSMWinData(NULL,
270 diffs_allowed,
271 get_state->win_info_list[i].data_list,
272 get_state->win_info_list[i].num_data_list,
273 w_window,
274 &xrm_data_list,
275 &num_xrm_data_list);
276 w_window->last_space = current_space;
277 in_current_space = CreateInternalStructure(w_window,NULL);
278 PRINT("nothing in database\n");
279 }
280 }
281 /* create WSM_SET_STATE win_info */
282 if (num_xrm_data_list > 0)
283 {
284 print_win_data(xrm_data_list,num_xrm_data_list);
285 win_info[num_win].data_list = xrm_data_list;
286 win_info[num_win].num_data_list = num_xrm_data_list;
287 win_info[num_win].window = GetWSMWindow(w_window);
288 num_win++;
289 }
290 }/* end for loop */
291
292 if (num_win ==0)
293 {
294 request->set_state.allocated = False;
295 request->set_state.num_win_info_list = 0;
296 request->any.type = WSM_SET_STATE;
297 PRINT("REQUEST: no window data\n");
298 XtFree((XtPointer)win_info);
299 }
300 else
301 {
302 /* create WSM_SET_STATE */
303 if (num_win != get_state->num_win_info_list)
304 win_info = (WSMWinInfo*)XtRealloc((char*)win_info,num_win*sizeof(WSMWinInfo));
305 request->set_state.allocated = True;
306 request->set_state.num_win_info_list = num_win;
307 request->set_state.win_info_list = win_info;
308 request->any.type = WSM_SET_STATE;
309 print_request(request);
310 }
311
312 if (mwm_reconnect)
313 FinishRestartWSM();
314 /* SaveState(get_state);*/
315
316 }
317
318
319 /*------------------------------------------------------------------
320 SaveState
321
322 ------------------------------------------------------------------*/
323 void
SaveState(WSMGetStateReply * get_state,Boolean diffs)324 SaveState(WSMGetStateReply *get_state, Boolean diffs)
325 {
326 int i;
327 XrmValue *value_list;
328 WorkWindow *w_window;
329 XrmQuark roomq;
330 Boolean no_save;
331 WSMWinData *hide_data;
332 PRINT("\n\nSAVE STATE\n");
333
334 /* If diffs = True then check to see if any of the windows
335 were unmapped since the last save state. (This is done
336 by setting mapped = False for every window in current space and then
337 turning mapped = True for each window sent over from window manager.
338 Anything not sent over by window manager must have been unmapped ) */
339 if (!diffs) UnmapCurrentSpace();
340 /* for each window, save its state in database and in internal
341 structures */
342 print_reply_start_state(get_state);
343 for (i = 0; i < get_state->num_win_info_list; i++)
344 {
345 w_window = GetWorkWindow(get_state->win_info_list[i].window);
346 if (w_window != NULL)
347 {
348 no_save = False;
349 print_window(w_window);
350 if (!diffs) MapWorkWindow(w_window);
351 if (_WSMGetConfigFormatType(w_window->window) == WSM_WINDOW_FMT)
352 {
353 hide_data = _WSMGetMatchingWinData(get_state->win_info_list[i].data_list,
354 get_state->win_info_list[i].num_data_list,
355 w_window->attrib_qlist[wsm_index.hide]);
356 if (hide_data)
357 {
358 if (hide_data->data.value == 1)
359 {
360 no_save = True;
361 }
362 }
363 }
364 if (!no_save)
365 {
366 /* update internal structures */
367 UpdateWinData(get_state->win_info_list[i].data_list,
368 get_state->win_info_list[i].num_data_list,
369 w_window->win_data,
370 w_window->num_attrib_list);
371
372 /* create XrmValues to store in database */
373 CreateValues(w_window,
374 get_state->win_info_list[i].data_list,
375 get_state->win_info_list[i].num_data_list,
376 &value_list);
377
378 /* store workspace resources */
379 SaveWorkspaceResources(shell,
380 w_window->specifier_qlist,
381 current_space->nameq,
382 NULLQUARK,
383 w_window->all_workspaces,
384 w_window->linked);
385 if (w_window->linked)
386 roomq = linkedRoomQuark;
387 else
388 roomq = current_space->nameq;
389 print_values(value_list,w_window->attrib_qlist,roomq, w_window->num_attrib_list);
390 /* store window resources */
391 SaveWindowConfiguration(w_window->specifier_qlist,
392 w_window->attrib_qlist,
393 roomq,
394 value_list);
395 FreeValues(w_window->num_attrib_list,value_list);
396 }
397 }
398 }
399 }
400
401
402 /*------------------------------------------------------------------
403 GetChangeSpaceRequest
404
405 ------------------------------------------------------------------*/
406 void
GetChangeSpaceRequest(Space * to_s,WSMRequest * request)407 GetChangeSpaceRequest(Space *to_s, WSMRequest *request)
408 {
409 WorkWindow *w_window;
410 WorkWindowList *w_list;
411 Boolean in_current_space = False;
412 Boolean in_to_space = False;
413 Boolean first = True;
414 int num_win;
415 WSMWinData *xrm_data_list;
416 int num_xrm_data_list;
417 WSMWinInfo *win_info = NULL;
418 XrmQuark room_name;
419
420 PRINT("\n\nCHANGE ROOM from %s to %s\n",
421 XrmQuarkToString(current_space->nameq),
422 XrmQuarkToString(to_s->nameq));
423
424 request->set_state.num_win_info_list = 0;
425 w_list = current_space->w_list;
426 /* loop through each window in current workspace */
427 while (w_list != NULL)
428 {
429 num_xrm_data_list = 0;
430 w_window = w_list->work_win;
431 /* only send info for mapped windows */
432 if (w_window->mapped)
433 {
434 print_window(w_window);
435 in_to_space = IsWorkWindowInSpace(w_window,to_s);
436 /* if the window is also in the room being switched to
437 then send new config info if window not linked, or send
438 stacking info if it is linked */
439 if (in_to_space)
440 {
441 if (!(w_window->linked) || !diffs_allowed )
442 {
443 GetDataList(w_window,
444 to_s->nameq,
445 diffs_allowed,
446 &xrm_data_list,
447 &num_xrm_data_list);
448 w_window->last_space = to_s;
449 }
450 /* if the window is linked, i only need to send stacked info */
451 else
452 {
453 GetUnhideDataList(w_window,
454 linkedRoomQuark,
455 &xrm_data_list,
456 &num_xrm_data_list);
457 }
458 }
459 /* if its not in the destination workspace, hide it */
460 if (!in_to_space)
461 {
462 CreateHideWSMWinData(diffs_allowed,
463 w_window,
464 &xrm_data_list,
465 &num_xrm_data_list);
466 }
467 /* if there is any info to send the window manager store it*/
468 if (num_xrm_data_list > 0)
469 {
470 print_win_data(xrm_data_list,num_xrm_data_list);
471 num_win = request->set_state.num_win_info_list;
472 request->set_state.num_win_info_list++;
473 if (first)
474 {
475 win_info = (WSMWinInfo*)XtMalloc(sizeof(WSMWinInfo));
476 first = False;
477 }
478 else win_info = (WSMWinInfo*)XtRealloc((char*)win_info,
479 (num_win+1)* sizeof(WSMWinInfo));
480 win_info[num_win].data_list = xrm_data_list;
481 win_info[num_win].num_data_list = num_xrm_data_list;
482 win_info[num_win].window = GetWSMWindow(w_window);
483 }
484 }
485 w_list = w_list->next;
486 }
487
488
489 w_list = to_s->w_list;
490 while (w_list != NULL)
491 {
492 num_xrm_data_list = 0;
493 w_window = w_list->work_win;
494 print_window(w_window);
495 if (w_window->mapped)
496 {
497 in_current_space = IsWorkWindowInSpace(w_window,current_space);
498 /* if it was in current space, it was taken care of in the above loop */
499 if (!in_current_space)
500 {
501 /* if the last configuration for the window was in the
502 destination workspace, i only need to send hide info */
503 if (diffs_allowed && (w_window->last_space == to_s ||
504 (w_window->linked && w_window->last_space != NULL)))
505 {
506 GetUnhideDataList(w_window,
507 to_s->nameq,
508 &xrm_data_list,
509 &num_xrm_data_list);
510 }
511 else
512 {
513 if (w_window->linked) room_name = linkedRoomQuark;
514 else room_name = to_s->nameq;
515 GetDataList(w_window,
516 room_name,
517 diffs_allowed,
518 &xrm_data_list,
519 &num_xrm_data_list);
520 w_window->last_space = to_s;
521 }
522 /* if there is any info to send to window manager */
523 if (num_xrm_data_list >0)
524 {
525 print_win_data(xrm_data_list,num_xrm_data_list);
526 num_win = request->set_state.num_win_info_list;
527 request->set_state.num_win_info_list++;
528 if (first)
529 {
530 win_info = (WSMWinInfo*)XtMalloc(sizeof(WSMWinInfo));
531 first = False;
532 }
533 else win_info = (WSMWinInfo*)XtRealloc((char*)win_info,
534 (num_win+1)* sizeof(WSMWinInfo));
535 win_info[num_win].data_list = xrm_data_list;
536 win_info[num_win].num_data_list = num_xrm_data_list;
537 win_info[num_win].window = GetWSMWindow(w_window);
538 }
539 }
540 }
541 w_list = w_list->next;
542 }
543 if (request->set_state.num_win_info_list > 0)
544 {
545 request->set_state.allocated = True;
546 request->set_state.win_info_list = win_info;
547 }
548 else
549 {
550 request->set_state.allocated = False;
551 request->set_state.win_info_list = NULL;
552 }
553 request->any.type = WSM_SET_STATE;
554 print_request(request);
555
556 current_space = to_s;
557 }
558
559
560
561
562 /*------------------------------------------------------------------
563 GetRegisterOldWindowReply
564
565 ------------------------------------------------------------------*/
566 void
GetRegisterOldWindowReply(WorkWindow * w_window,WSMReply * reply)567 GetRegisterOldWindowReply(WorkWindow *w_window,WSMReply *reply)
568 {
569 WSMWinData *xrm_data_list;
570 int num_xrm_data_list = 0;
571 Boolean in_current_space = False;
572
573 PRINT("\n\nREGISTER OLD WINDOW .....\n");
574 reply->any.type = WSM_REG_WINDOW;
575 reply->register_window.num_window_data = 0;
576 reply->register_window.window_data = NULL;
577
578 in_current_space = IsWorkWindowInSpace(w_window,current_space);
579 /* Display window in current room AND any rooms it was in previously.
580 If other behavior wanted, take this if statement out */
581 if (!in_current_space)
582 {
583 AddSpaceToWindow(current_space, w_window);
584 AddWindowToSpace(current_space, w_window);
585 in_current_space = True;
586 }
587 if (in_current_space)
588 {
589 if (!(w_window->linked) || !diffs_allowed)
590 {
591 GetDataList(w_window,
592 current_space->nameq,
593 diffs_allowed,
594 &xrm_data_list,
595 &num_xrm_data_list);
596 w_window->last_space = current_space;
597 }
598 /* if the window is linked (no stacked above info, i could remove this) */
599 else if (w_window->linked)
600 {
601 GetUnhideDataList(w_window,
602 linkedRoomQuark,
603 &xrm_data_list,
604 &num_xrm_data_list);
605 }
606 }
607 else
608 {
609 CreateHideWSMWinData(diffs_allowed,
610 w_window,
611 &xrm_data_list,
612 &num_xrm_data_list);
613 }
614 print_win_data(xrm_data_list,num_xrm_data_list);
615
616 reply->any.type = WSM_REG_WINDOW;
617 if (num_xrm_data_list > 0)
618 {
619 reply->register_window.allocated = True;
620 reply->register_window.num_window_data = num_xrm_data_list;
621 reply->register_window.window_data = xrm_data_list;
622 }
623 if (w_window->s_list != NULL)
624 if (w_window->s_list->next == NULL)
625 DisableDeleteCommand(w_window->window);
626 print_reply(reply);
627 }
628
629
630
631 /*------------------------------------------------------------------
632 GetRegisterWindowReply
633
634 ------------------------------------------------------------------*/
635 void
GetRegisterWindowReply(Window window,WSMReply * reply)636 GetRegisterWindowReply(Window window,WSMReply *reply)
637 {
638 WSMWinData *xrm_data_list;
639 int num_xrm_data_list = 0;
640 WorkWindow *w_window;
641 XrmQuarkList rooms_qlist;
642 Boolean all_workspaces, linked;
643 Boolean in_current_space = False;
644 Boolean new_window = True;
645 XrmQuark room_name = NULLQUARK;
646
647 PRINT("\n\nREGISTER WINDOW .....\n");
648 reply->any.type = WSM_REG_WINDOW;
649 reply->register_window.num_window_data = 0;
650
651 w_window = GetWorkWindow(window);
652 if (w_window == NULL)
653 w_window = CreateWorkWindow(window);
654 else new_window = False;
655 w_window->mapped = True;
656
657 print_window(w_window);
658
659 if (_WSMGetConfigFormatType(window) == WSM_WINDOW_FMT)
660 AddWindow(window);
661
662 if (!new_window)
663 {
664 GetRegisterOldWindowReply(w_window,reply);
665 return;
666 }
667
668
669 /* get window's workspace resources from database */
670 if (GetWorkspaceResources(shell,
671 w_window->specifier_qlist,
672 &rooms_qlist,
673 &all_workspaces,
674 &linked))
675 {
676 /* set the workspace values received from database */
677 SetWorkWindowValues(w_window,all_workspaces,linked);
678 /* create internal structures */
679 in_current_space = CreateInternalStructure(w_window,rooms_qlist);
680 if (!in_current_space)
681 {
682 AddSpaceToWindow(current_space, w_window);
683 AddWindowToSpace(current_space, w_window);
684 in_current_space = True;
685 }
686 /* if its in current space or no diffs allowed,
687 get config info for WSM_SET_STATE */
688 if (in_current_space || !diffs_allowed)
689 {
690 if (linked) room_name = linkedRoomQuark;
691 else if (!diffs_allowed && !in_current_space)
692 room_name = rooms_qlist[0];
693 else room_name = current_space->nameq;
694 GetDataListStart(w_window,
695 0,
696 room_name,
697 diffs_allowed,
698 NULL,
699 &xrm_data_list,
700 &num_xrm_data_list);
701 if (in_current_space)
702 {
703 w_window->win_data[wsm_index.hide].data.value = 0;
704 w_window->last_space = current_space;
705 }
706 else if (!diffs_allowed)
707 {
708 w_window->win_data[wsm_index.hide].data.value = 1;
709 xrm_data_list[wsm_index.hide].data.value = 1;
710 w_window->last_space = GetSpace(room_name);
711 }
712 }
713 /* else only send hide info in WSM_SET_STATE */
714 else
715 {
716 CreateStartHideWSMWinData(True,
717 NULL,
718 0,
719 w_window,
720 &xrm_data_list,
721 &num_xrm_data_list);
722 w_window->win_data[wsm_index.hide].type = WSM_VALUE_DATA;
723 w_window->win_data[wsm_index.hide].data.value = 1;
724 }
725 if (rooms_qlist != NULL)
726 XtFree((XtPointer)rooms_qlist);
727 print_win_data(xrm_data_list,num_xrm_data_list);
728
729 reply->any.type = WSM_REG_WINDOW;
730 reply->register_window.num_window_data = num_xrm_data_list;
731 reply->register_window.window_data = xrm_data_list;
732 print_reply(reply);
733 }
734 /* nothing in the database */
735 else
736 {
737 CreateStartWSMWinData(NULL,
738 True,
739 NULL,
740 0,
741 w_window,
742 &xrm_data_list,
743 &num_xrm_data_list);
744 CreateInternalStructure(w_window,NULL);
745 reply->any.type = WSM_REG_WINDOW;
746 reply->register_window.num_window_data = 0;
747 reply->register_window.window_data = NULL;
748 print_reply(reply);
749 w_window->last_space = current_space;
750 PRINT("nothing in database\n");
751 }
752 if (w_window->s_list != NULL)
753 if (w_window->s_list->next == NULL)
754 DisableDeleteCommand(w_window->window);
755 }
756
757
758 /*------------------------------------------------------------------
759 DealWithClientMessage
760
761 ------------------------------------------------------------------*/
762 void
DealWithClientMessage(Widget widget,XClientMessageEvent * ev)763 DealWithClientMessage(Widget widget,XClientMessageEvent *ev)
764 {
765 char **argv;
766 int argc = 3;
767
768 if (ev->type != ClientMessage)
769 return;
770 if (ev->message_type != atoms.protocols_property)
771 return;
772 if (ev->data.l[0] != atoms.save_property)
773 return;
774
775 SaveWsmToFile(file_name);
776 argv = (char**)XtMalloc(3*sizeof(char*));
777 argv[0] = "wsm";
778 argv[1] = "-f";
779 argv[2] = file_name;
780 XSetCommand(dsp,XtWindow(widget),argv,argc);
781 XtFree((char*)argv);
782 }
783
784
785 /*------------------------------------------------------------------
786 DealWithDestroyNotify
787
788 ------------------------------------------------------------------*/
789 void
DealWithDestroyNotify(Widget widget,XDestroyWindowEvent * ev)790 DealWithDestroyNotify(Widget widget,XDestroyWindowEvent *ev)
791 {
792 WorkWindow *w_window = GetWorkWindow(ev->window);
793 WorkWindow *i_window;
794
795 if (ev->window == mwm_window)
796 DealWithDestroyMwmNotify();
797 if (connected == False) return;
798 #ifdef DEBUG
799 PRINT("destroy 0x%x\n",ev->window);
800 #endif
801 if (w_window == NULL)
802 {
803 w_window = GetWorkWindow(ev->event);
804 if (w_window != NULL)
805 {
806 RemoveWorkWindow(w_window, False);
807 i_window = GetIconWorkWindow(w_window->window);
808 if (i_window != NULL)
809 RemoveWorkWindow(i_window,False);
810 }
811 }
812
813 else
814 {
815 RemoveWorkWindow(w_window,False);
816 i_window = GetIconWorkWindow(w_window->window);
817 if (i_window != NULL)
818 RemoveWorkWindow(i_window,False);
819 }
820 }
821
822
823
824
825 /*------------------------------------------------------------------
826 DealWithDestroyMwmNotify
827
828 ------------------------------------------------------------------*/
829 void
DealWithDestroyMwmNotify()830 DealWithDestroyMwmNotify()
831 {
832
833 if (connected == False) return;
834 RestartWSM();
835 mwm_gone = True;
836 PRINT("Mwm went away\n");
837 }
838
839
840
841
842 /*------------------------------------------------------------------
843 DealMapNotify
844
845 ------------------------------------------------------------------*/
846 void
DealWithMapNotify(Widget widget,XMapEvent * ev)847 DealWithMapNotify(Widget widget,XMapEvent *ev)
848 {
849 WorkWindow *w_window = GetWorkWindow(ev->window);
850
851 if (connected == False) return;
852
853 #ifdef DEBUG
854 PRINT("MapNotify\n");
855 #endif
856 if (w_window == NULL)
857 {
858 w_window = GetWorkWindow(ev->event);
859 if (w_window != NULL)
860 w_window->mapped = True;
861 }
862 else w_window->mapped = True;
863 }
864
865
866
867
868
869
870 /*------------------------------------------------------------------
871 DealUnmapNotify
872
873 ------------------------------------------------------------------*/
874 void
DealWithUnmapNotify(Widget widget,XUnmapEvent * ev)875 DealWithUnmapNotify(Widget widget,XUnmapEvent *ev)
876 {
877 WorkWindow *i_window;
878 WorkWindow *w_window = GetWorkWindow(ev->window);
879 #ifdef DEBUG
880 PRINT("UnapNotify\n");
881 #endif
882 if (connected == False) return;
883
884 if (w_window == NULL)
885 {
886 w_window = GetWorkWindow(ev->event);
887 if (w_window != NULL)
888 {
889 w_window->mapped = False;
890 /* RemoveWorkWindow(w_window, False);
891 i_window = GetIconWorkWindow(w_window->window);
892 if (i_window != NULL)
893 RemoveWorkWindow(i_window,False);
894 */
895 }
896 }
897 else
898 {
899 w_window->mapped = False;
900 /* RemoveWorkWindow(w_window, False);
901 i_window = GetIconWorkWindow(w_window->window);
902 if (i_window != NULL)
903 RemoveWorkWindow(i_window,False);
904 */
905 }
906 }
907
908
909
910 /*------------------------------------------------------------------
911 CreateSetState
912
913 ------------------------------------------------------------------*/
914 Boolean
CreateSetState(WSMWinData * data_list,int num_data_list,WSMWinData * data_list_i,int num_data_list_i,WorkWindow * w_window,WorkWindow * i_window,WSMRequest * request)915 CreateSetState(WSMWinData *data_list, int num_data_list,
916 WSMWinData *data_list_i, int num_data_list_i,
917 WorkWindow *w_window,
918 WorkWindow *i_window,
919 WSMRequest *request)
920 {
921 Boolean retval;
922 WSMWinInfo *win_info = NULL;
923 int count;
924 print_window(w_window);
925 print_win_data(data_list,num_data_list);
926 if (i_window != NULL)
927 {
928 print_window(i_window);
929 print_win_data(data_list_i,num_data_list_i);
930 }
931 count = 0;
932 retval = False;
933 if (num_data_list > 0 && num_data_list_i > 0)
934 win_info = (WSMWinInfo*)XtMalloc(2*sizeof(WSMWinInfo));
935 else if (num_data_list > 0 || num_data_list_i > 0)
936 win_info = (WSMWinInfo*)XtMalloc(sizeof(WSMWinInfo));
937 if (num_data_list > 0)
938 {
939 win_info[count].data_list = data_list;
940 win_info[count].num_data_list = num_data_list;
941 win_info[count].window = GetWSMWindow(w_window);
942 count++;
943 }
944 if (num_data_list_i > 0)
945 {
946 win_info[count].data_list = data_list_i;
947 win_info[count].num_data_list = num_data_list_i;
948 win_info[count].window = GetWSMWindow(i_window);
949 count++;
950 }
951 if (num_data_list > 0 || num_data_list_i > 0)
952 {
953 request->set_state.allocated = True;
954 request->any.type = WSM_SET_STATE;
955 request->set_state.win_info_list = win_info;
956 request->set_state.num_win_info_list = count;
957 retval = True;
958 }
959 else
960 {
961 request->set_state.allocated = True;
962 request->any.type = WSM_SET_STATE;
963 request->set_state.win_info_list = NULL;
964 request->set_state.num_win_info_list = 0;
965 }
966 return retval;
967 }
968
969
970
971 /*------------------------------------------------------------------
972 GetCopyWindowRequest
973
974 ------------------------------------------------------------------*/
975 Boolean
GetCopyWindowRequest(Window win,Space * from_s,Space * to_s,WSMRequest * request)976 GetCopyWindowRequest(Window win, Space *from_s, Space *to_s, WSMRequest *request)
977 {
978 WSMWinData *xrm_data_list;
979 WSMWinData *xrm_data_list_i;
980 int num_xrm_data_list = 0;
981 int num_xrm_data_list_i = 0;
982 WorkWindow *w_window;
983 WorkWindow *i_window;
984 XrmValue *attr_values = NULL;
985 XrmValue *attr_values_i = NULL;
986 Boolean retval = False;
987 XrmQuark room_nameq;
988
989 PRINT("COPY\n");
990 w_window = GetWorkWindow(win);
991 i_window = GetIconWorkWindow(win);
992
993 if (w_window != NULL && from_s != NULL && to_s != NULL
994 && IsWorkWindowInSpace(w_window,from_s))
995 {
996 if (w_window->linked) room_nameq = linkedRoomQuark;
997 else room_nameq = from_s->nameq;
998 GetWindowConfigurationEntry(w_window->specifier_qlist,
999 w_window->attrib_qlist,
1000 room_nameq,
1001 &attr_values);
1002 if (i_window != NULL)
1003 GetWindowConfigurationEntry(i_window->specifier_qlist,
1004 i_window->attrib_qlist,
1005 room_nameq,
1006 &attr_values_i);
1007 if (to_s == all_space)
1008 {
1009 CopyWindowToAllSpaces(w_window,i_window,attr_values, attr_values_i, from_s);
1010 }
1011 else
1012 {
1013 CopyWindowToSpace(w_window,i_window,attr_values,attr_values_i,to_s);
1014 }
1015 w_window->linked = False;
1016 SaveWorkspaceResources(shell,
1017 w_window->specifier_qlist,
1018 to_s->nameq,
1019 NULLQUARK,
1020 w_window->all_workspaces,
1021 w_window->linked);
1022 if (i_window != NULL)
1023 {
1024 i_window->linked = False;
1025 SaveWorkspaceResources(shell,
1026 i_window->specifier_qlist,
1027 to_s->nameq,
1028 NULLQUARK,
1029 i_window->all_workspaces,
1030 i_window->linked);
1031 }
1032 if ((to_s == current_space || to_s == all_space) && from_s != current_space && w_window->mapped)
1033 {
1034 CreateWSMWinData(attr_values,
1035 diffs_allowed,
1036 w_window,
1037 &xrm_data_list,
1038 &num_xrm_data_list);
1039 w_window->last_space = current_space;
1040 if (i_window != NULL)
1041 {
1042 CreateWSMWinData(attr_values_i,
1043 diffs_allowed,
1044 i_window,
1045 &xrm_data_list_i,
1046 &num_xrm_data_list_i);
1047 i_window->last_space = current_space;
1048 }
1049 retval = CreateSetState(xrm_data_list,num_xrm_data_list,
1050 xrm_data_list_i,num_xrm_data_list_i,
1051 w_window,
1052 i_window,
1053 request);
1054 }
1055 if (attr_values != NULL) XtFree((char*)attr_values);
1056 if (attr_values_i != NULL) XtFree((char*)attr_values_i);
1057 }
1058 if (retval) print_request(request);
1059 return retval;
1060 }
1061
1062
1063
1064 /*------------------------------------------------------------------
1065 CopyWindowToAllSpaces
1066
1067 ------------------------------------------------------------------*/
1068 void
CopyWindowToAllSpaces(WorkWindow * w_window,WorkWindow * i_window,XrmValue * attr_values,XrmValue * attr_values_i,Space * skip_space)1069 CopyWindowToAllSpaces(WorkWindow *w_window, WorkWindow *i_window,
1070 XrmValue *attr_values, XrmValue *attr_values_i,Space* skip_space)
1071 {
1072 Space *space;
1073 space = space_list;
1074 w_window->linked = False;
1075 while (space!= NULL)
1076 {
1077 if (space != skip_space)
1078 {
1079 SaveWindowConfiguration(w_window->specifier_qlist,
1080 w_window->attrib_qlist,
1081 space->nameq,
1082 attr_values);
1083 if (i_window != NULL)
1084 SaveWindowConfiguration(i_window->specifier_qlist,
1085 i_window->attrib_qlist,
1086 space->nameq,
1087 attr_values_i);
1088 SaveWorkspaceResources(shell,
1089 w_window->specifier_qlist,
1090 space->nameq,
1091 NULLQUARK,
1092 w_window->all_workspaces,
1093 w_window->linked);
1094 }
1095 if (!(IsWorkWindowInSpace(w_window,space)))
1096 {
1097 AddWindowToSpace(space,w_window);
1098 AddSpaceToWindow(space,w_window);
1099 }
1100 space = space->next;
1101 }
1102 if (!(IsWorkWindowInSpace(w_window,all_space)))
1103 AddWindowToSpace(all_space,w_window);
1104 w_window->all_workspaces = True;
1105 }
1106
1107
1108 /*------------------------------------------------------------------
1109 CopyWindowToSpace
1110
1111 ------------------------------------------------------------------*/
1112 void
CopyWindowToSpace(WorkWindow * w_window,WorkWindow * i_window,XrmValue * attr_values,XrmValue * attr_values_i,Space * space)1113 CopyWindowToSpace(WorkWindow *w_window, WorkWindow *i_window,
1114 XrmValue *attr_values, XrmValue *attr_values_i,
1115 Space *space)
1116 {
1117 SpaceList *s_list;
1118 if (w_window->linked)
1119 {
1120 /* break links and replace with copies */
1121 s_list = w_window->s_list;
1122 while (s_list != NULL)
1123 {
1124 SaveWindowConfiguration(w_window->specifier_qlist,
1125 w_window->attrib_qlist,
1126 s_list->space->nameq,
1127 attr_values);
1128 if (i_window != NULL)
1129 SaveWindowConfiguration(i_window->specifier_qlist,
1130 i_window->attrib_qlist,
1131 s_list->space->nameq,
1132 attr_values_i);
1133 s_list = s_list->next;
1134 }
1135 }
1136 SaveWindowConfiguration(w_window->specifier_qlist,
1137 w_window->attrib_qlist,
1138 space->nameq,
1139 attr_values);
1140 if (i_window != NULL)
1141 SaveWindowConfiguration(i_window->specifier_qlist,
1142 i_window->attrib_qlist,
1143 space->nameq,
1144 attr_values_i);
1145 if (!(IsWorkWindowInSpace(w_window,space)))
1146 {
1147 AddWindowToSpace(space,w_window);
1148 AddSpaceToWindow(space,w_window);
1149 }
1150 }
1151
1152
1153 /*------------------------------------------------------------------
1154 GetMoveWindowRequest
1155
1156 ------------------------------------------------------------------*/
1157 Boolean
GetMoveWindowRequest(Window win,Space * from_s,Space * to_s,WSMRequest * request)1158 GetMoveWindowRequest(Window win, Space *from_s, Space *to_s, WSMRequest *request)
1159 {
1160 WSMWinData *xrm_data_list, *xrm_data_list_i;
1161 int num_xrm_data_list = 0;
1162 int num_xrm_data_list_i = 0;
1163 WorkWindow *w_window;
1164 WorkWindow *i_window;
1165 XrmValue *attr_values = NULL;
1166 XrmValue *attr_values_i = NULL;
1167 Boolean retval = False;
1168
1169 PRINT("MOVE 0x%X \n", win);
1170 w_window = GetWorkWindow(win);
1171 i_window = GetIconWorkWindow(win);
1172
1173 if (w_window != NULL && from_s != NULL && to_s != NULL
1174 && IsWorkWindowInSpace(w_window,from_s))
1175 {
1176 /* if the window isn't linked, then save the "from" workspace
1177 configuration into t he "to" workspace */
1178 if (!(w_window->linked))
1179 {
1180 GetWindowConfigurationEntry(w_window->specifier_qlist,
1181 w_window->attrib_qlist,
1182 from_s->nameq,
1183 &attr_values);
1184 SaveWindowConfiguration(w_window->specifier_qlist,
1185 w_window->attrib_qlist,
1186 to_s->nameq,
1187 attr_values);
1188 if (i_window != NULL)
1189 {
1190 GetWindowConfigurationEntry(i_window->specifier_qlist,
1191 i_window->attrib_qlist,
1192 from_s->nameq,
1193 &attr_values_i);
1194 SaveWindowConfiguration(i_window->specifier_qlist,
1195 i_window->attrib_qlist,
1196 to_s->nameq,
1197 attr_values_i);
1198 }
1199 }
1200 /* if the window was in all workspaces, remove it from all_space */
1201 if (w_window->all_workspaces)
1202 {
1203 RemoveWorkWindowFromSpace(all_space,w_window);
1204 w_window->all_workspaces = False;
1205 }
1206 /* if the window wasn't in the "to" workspace, add it */
1207 if (!IsWorkWindowInSpace(w_window,to_s))
1208 {
1209 SaveWorkspaceResources(shell,
1210 w_window->specifier_qlist,
1211 to_s->nameq,
1212 from_s->nameq,
1213 w_window->all_workspaces,
1214 w_window->linked);
1215 AddWindowToSpace(to_s,w_window);
1216 AddSpaceToWindow(to_s,w_window);
1217 }
1218 /* if its necessary to send info to the window manager */
1219 if ((to_s == current_space || from_s == current_space) && w_window->mapped)
1220 {
1221 if (to_s == current_space)
1222 {
1223 /* if its linked then i need to get its configuration, otherwise i already
1224 got it above */
1225 if (w_window->linked)
1226 {
1227 GetWindowConfigurationEntry(w_window->specifier_qlist,
1228 w_window->attrib_qlist,
1229 linkedRoomQuark,
1230 &attr_values);
1231 if (i_window != NULL)
1232 GetWindowConfigurationEntry(i_window->specifier_qlist,
1233 i_window->attrib_qlist,
1234 linkedRoomQuark,
1235 &attr_values_i);
1236 }
1237 CreateWSMWinData(attr_values,
1238 True,
1239 w_window,
1240 &xrm_data_list,
1241 &num_xrm_data_list);
1242 w_window->last_space = current_space;
1243 if (i_window != NULL)
1244 {
1245 CreateWSMWinData(attr_values_i,
1246 True,
1247 i_window,
1248 &xrm_data_list_i,
1249 &num_xrm_data_list_i);
1250 i_window->last_space = current_space;
1251 }
1252 }
1253 else
1254 {
1255 CreateHideWSMWinData(diffs_allowed,
1256 w_window,
1257 &xrm_data_list,
1258 &num_xrm_data_list);
1259 }
1260 retval = CreateSetState(xrm_data_list,num_xrm_data_list,
1261 xrm_data_list_i,num_xrm_data_list_i,
1262 w_window,
1263 i_window,
1264 request);
1265 }
1266 /* get rid of the "from" workspace configuration */
1267 if (!w_window->linked)
1268 PurgeWindowConfiguration(shell,
1269 w_window->specifier_qlist,
1270 w_window->attrib_qlist,
1271 from_s->nameq);
1272 RemoveWorkWindowFromSpace(from_s, w_window);
1273 RemoveSpaceFromWindow(from_s, w_window);
1274 if (attr_values != NULL) XtFree((char*)attr_values);
1275 if (attr_values_i != NULL) XtFree((char*)attr_values_i);
1276 }
1277
1278 return retval;
1279 }
1280
1281
1282
1283
1284
1285 /*------------------------------------------------------------------
1286 GetDeleteWindowRequest
1287
1288 ------------------------------------------------------------------*/
1289 Boolean
GetDeleteWindowRequest(Window win,Space * from_s,WSMRequest * request)1290 GetDeleteWindowRequest(Window win, Space *from_s,WSMRequest *request)
1291 {
1292
1293 WSMWinInfo *win_info;
1294 WSMWinData *xrm_data_list;
1295 int num_xrm_data_list = 0;
1296 WorkWindow *w_window;
1297 Boolean retval = False;
1298
1299
1300 PRINT("DELETE 0x%X \n", win);
1301 w_window = GetWorkWindow(win);
1302
1303 if (w_window != NULL && from_s != NULL )
1304 {
1305 if (IsWorkWindowInSpace(w_window,from_s))
1306 {
1307 PurgeWindowConfiguration(shell,
1308 w_window->specifier_qlist,
1309 w_window->attrib_qlist,
1310 from_s->nameq);
1311 RemoveWorkWindowFromSpace(from_s, w_window);
1312 RemoveSpaceFromWindow(from_s, w_window);
1313 if (w_window->all_workspaces)
1314 {
1315 RemoveWorkWindowFromSpace(all_space,w_window);
1316 w_window->all_workspaces = False;
1317 }
1318 if (from_s == current_space && w_window->mapped)
1319 {
1320 CreateHideWSMWinData(diffs_allowed,
1321 w_window,
1322 &xrm_data_list,
1323 &num_xrm_data_list);
1324 print_win_data(xrm_data_list,num_xrm_data_list);
1325 if (num_xrm_data_list > 0)
1326 {
1327 win_info = (WSMWinInfo*)XtMalloc(sizeof(WSMWinInfo));
1328 win_info[0].data_list = xrm_data_list;
1329 win_info[0].num_data_list = num_xrm_data_list;
1330 win_info[0].window = GetWSMWindow(w_window);
1331 request->set_state.allocated = True;
1332 request->any.type = WSM_SET_STATE;
1333 request->set_state.win_info_list = win_info;
1334 request->set_state.num_win_info_list = 1;
1335 retval = True;
1336 }
1337 }
1338 }
1339 }
1340
1341 return retval;
1342 }
1343
1344
1345
1346 /*------------------------------------------------------------------
1347 GetLinkWindowRequest
1348
1349 ------------------------------------------------------------------*/
1350 Boolean
GetLinkWindowRequest(Window win,Space * from_s,Space * to_s,WSMRequest * request)1351 GetLinkWindowRequest(Window win, Space *from_s, Space *to_s, WSMRequest *request)
1352 {
1353 WSMWinData *xrm_data_list;
1354 int num_xrm_data_list = 0;
1355 WSMWinData *xrm_data_list_i;
1356 int num_xrm_data_list_i = 0;
1357 WorkWindow *w_window;
1358 WorkWindow *i_window;
1359 XrmValue *attr_values = NULL;
1360 XrmValue *attr_values_i = NULL;
1361 Boolean retval = False;
1362 Boolean in_space = False;
1363 Space *space;
1364
1365 w_window = GetWorkWindow(win);
1366 i_window = GetIconWorkWindow(win);
1367
1368 PRINT("LINK WINDOW ");
1369
1370 if (w_window != NULL && from_s != NULL && to_s != NULL)
1371 {
1372 #ifdef DEBUG
1373 print_window(w_window);
1374 #endif
1375 if (IsWorkWindowInSpace(w_window,from_s))
1376 {
1377 in_space = IsWorkWindowInSpace(w_window,to_s);
1378 if (in_space && w_window->linked) return False;
1379 if (!in_space)
1380 {
1381 /* if the window is being linked into all workspaces,
1382 look through all workspaces and also add it to all_space*/
1383 if (to_s == all_space)
1384 {
1385 space = space_list;
1386 while (space != NULL)
1387 {
1388 if (!IsWorkWindowInSpace(w_window,space))
1389 {
1390 AddWindowToSpace(space,w_window);
1391 AddSpaceToWindow(space,w_window);
1392 }
1393 space = space->next;
1394 }
1395 AddWindowToSpace(all_space,w_window);
1396 w_window->all_workspaces = True;
1397 }
1398 /* else just add it to a single workspace */
1399 else
1400 {
1401 AddWindowToSpace(to_s,w_window);
1402 AddSpaceToWindow(to_s,w_window);
1403 }
1404 }
1405 /* if the window wasn't linked then save the "from" configuration
1406 into the database as the linked configuration */
1407 if (!(w_window->linked))
1408 {
1409 GetWindowConfigurationEntry(w_window->specifier_qlist,
1410 w_window->attrib_qlist,
1411 from_s->nameq,
1412 &attr_values);
1413 SaveWindowConfiguration(w_window->specifier_qlist,
1414 w_window->attrib_qlist,
1415 linkedRoomQuark,
1416 attr_values);
1417 if (i_window != NULL)
1418 {
1419 GetWindowConfigurationEntry(i_window->specifier_qlist,
1420 i_window->attrib_qlist,
1421 from_s->nameq,
1422 &attr_values_i);
1423 SaveWindowConfiguration(i_window->specifier_qlist,
1424 i_window->attrib_qlist,
1425 linkedRoomQuark,
1426 attr_values_i);
1427 }
1428 if (attr_values != NULL) XtFree((char*)attr_values);
1429 if (attr_values_i != NULL) XtFree((char*)attr_values_i);
1430 attr_values = NULL;
1431 attr_values_i = NULL;
1432 }
1433 /* save workspace resources if they have changed */
1434 if (!in_space || !(w_window->linked) || to_s == all_space)
1435 {
1436 SaveWorkspaceResources(shell,
1437 w_window->specifier_qlist,
1438 to_s->nameq,
1439 NULLQUARK,
1440 w_window->all_workspaces,
1441 True);
1442 if (i_window)
1443 SaveWorkspaceResources(shell,
1444 i_window->specifier_qlist,
1445 to_s->nameq,
1446 NULLQUARK,
1447 i_window->all_workspaces,
1448 True);
1449 }
1450 /* send info to window manager if necessary */
1451 if ((to_s == current_space || to_s == all_space) && from_s != current_space && w_window->mapped)
1452 {
1453 if (w_window->linked)
1454 {
1455 GetWindowConfigurationEntry(w_window->specifier_qlist,
1456 w_window->attrib_qlist,
1457 linkedRoomQuark,
1458 &attr_values);
1459 if (i_window != NULL)
1460 GetWindowConfigurationEntry(i_window->specifier_qlist,
1461 i_window->attrib_qlist,
1462 linkedRoomQuark,
1463 &attr_values_i);
1464 }
1465 CreateWSMWinData(attr_values,
1466 diffs_allowed,
1467 w_window,
1468 &xrm_data_list,
1469 &num_xrm_data_list);
1470 w_window->last_space = current_space;
1471 if (i_window != NULL)
1472 {
1473 CreateWSMWinData(attr_values_i,
1474 diffs_allowed,
1475 i_window,
1476 &xrm_data_list_i,
1477 &num_xrm_data_list_i);
1478 i_window->last_space = current_space;
1479 }
1480 retval = CreateSetState(xrm_data_list,num_xrm_data_list,
1481 xrm_data_list_i,num_xrm_data_list_i,
1482 w_window,
1483 i_window,
1484 request);
1485 if (attr_values != NULL) XtFree((char*)attr_values);
1486 if (attr_values_i != NULL) XtFree((char*)attr_values_i);
1487 attr_values = NULL;
1488 attr_values_i = NULL;
1489 }
1490 w_window->linked = True;
1491 if (i_window != NULL) i_window->linked = True;
1492 }
1493 }
1494 PRINT("return\n");
1495 return retval;
1496 }
1497
1498
1499
1500
1501
1502 /*------------------------------------------------------------------
1503 GetManageAllWindowsRequest
1504
1505 ------------------------------------------------------------------*/
1506 Boolean
GetManageAllWindowsRequest(WSMRequest * request)1507 GetManageAllWindowsRequest(WSMRequest *request)
1508 {
1509 WSMWinInfo *win_info;
1510 WSMWinData *xrm_data_list;
1511 int num_xrm_data_list = 0;
1512 WorkWindow *w_window;
1513 int num_win;
1514
1515 PRINT("MANAGE WINDOWS ");
1516
1517 w_window = work_windows;
1518
1519 win_info = NULL;
1520 num_win = 0;
1521 for (w_window = work_windows; w_window!= NULL; w_window = w_window->next)
1522 {
1523 #ifdef DEBUG
1524 print_window(w_window);
1525 #endif
1526 if (_WSMGetConfigFormatType(w_window->window) == WSM_WINDOW_FMT)
1527 {
1528 if (!(IsWorkWindowInSpace(w_window,current_space)))
1529 {
1530 if (w_window->last_space != NULL && w_window->mapped)
1531 {
1532 GetUnhideDataList(w_window,
1533 w_window->last_space->nameq,
1534 &xrm_data_list,
1535 &num_xrm_data_list);
1536 if (num_xrm_data_list > 0)
1537 {
1538 print_win_data(xrm_data_list,num_xrm_data_list);
1539 if (win_info == NULL)
1540 win_info = (WSMWinInfo*)XtMalloc(sizeof(WSMWinInfo));
1541 else win_info = (WSMWinInfo*)XtRealloc((char*)win_info,
1542 (num_win+1)* sizeof(WSMWinInfo));
1543 win_info[num_win].data_list = xrm_data_list;
1544 win_info[num_win].num_data_list = num_xrm_data_list;
1545 win_info[num_win].window = GetWSMWindow(w_window);
1546 num_win++;
1547 }
1548 }
1549 }
1550 }
1551 }
1552 if (num_win ==0)
1553 {
1554 PRINT("MANAGE WINDOWS: no window data\n");
1555 return False;
1556 }
1557 else
1558 {
1559 request->set_state.allocated = True;
1560 request->set_state.num_win_info_list = num_win;
1561 request->set_state.win_info_list = win_info;
1562 request->any.type = WSM_SET_STATE;
1563 print_request(request);
1564 return True;
1565 }
1566 }
1567