2
* @OPENGROUP_COPYRIGHT@
4
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
5
* Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
6
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
7
* the full copyright text.
9
* This software is subject to an open license. It may only be
10
* used on, with or for operating systems which are themselves open
11
* source systems. You must contact The Open Group for a license
12
* allowing distribution and sublicensing of this software on, with,
13
* or for operating systems which are not Open Source programs.
15
* See http://www.opengroup.org/openmotif/license for full
16
* details of the license agreement. Any use, reproduction, or
17
* distribution of the program constitutes recipient's acceptance of
20
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
21
* PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
* KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
23
* WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
24
* OR FITNESS FOR A PARTICULAR PURPOSE
26
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
27
* NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
28
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
30
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
33
* EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGES.
41
static char rcsid[] = "$TOG: wsmStruct.c /main/7 1997/05/02 10:04:46 dbl $"
50
#include "wsmStruct.h"
55
extern AtomStruct atoms;
56
extern Space *space_list;
57
extern Space *all_space;
58
extern Space *current_space;
59
extern WorkWindow *work_windows;
60
extern XrmQuark *space_qlist;
61
extern XrmQuark *window_attribq;
62
extern XrmQuark *icon_attribq;
63
extern XrmQuark *global_attribq;
64
extern WSMAttribute *window_attrib_list;
65
extern WSMAttribute *icon_attrib_list;
66
extern WSMAttribute *global_attrib_list;
67
extern int num_window_attrib;
68
extern int num_icon_attrib;
69
extern int num_global_attrib;
70
extern Boolean diffs_allowed;
73
extern Boolean connected;
75
static char* GetWMName(
78
static char* GetWMClient(
81
static char* GetWMRole(
84
static char* GetWMCount(
87
XrmQuarkList GetSpecifierQList(
91
void AddWindowToSpace(
95
char *Get_SM_CLIENT_ID(
99
char *Get_WM_WINDOW_ROLE(
103
Colormap default_cmap = 0;
106
/**********************************************************************/
107
/* INTERNAL STRUCTURE CODE */
108
/**********************************************************************/
112
/*------------------------------------------------------------------
115
------------------------------------------------------------------*/
117
CreateSpace(XrmQuark name, char *str)
119
WorkWindowList *w_list;
121
s = (Space*)XtMalloc(sizeof(Space));
124
if (all_space->w_list != NULL)
126
w_list = all_space->w_list;
127
while (w_list != NULL)
129
AddWindowToSpace(s,w_list->work_win);
130
w_list = w_list->next;
134
strcpy(s->name, str);
135
strcpy(s->background,"None");
136
strcpy(s->pixmap_name,"None");
139
s->pixmap_label = None;
140
if (space_list == NULL)
148
while (s2->next != NULL)
155
/*------------------------------------------------------------------
158
------------------------------------------------------------------*/
160
SetSpacePixel(Space *s, char *name)
162
Boolean retval = True;
166
if (default_cmap == 0)
167
default_cmap = DefaultColormap(dsp,0);
168
if (XAllocNamedColor(dsp,default_cmap,name,&a_color, &def_color)==0)
170
s->pixel = a_color.pixel;
171
strcpy(s->background,name);
180
/*------------------------------------------------------------------
183
------------------------------------------------------------------*/
185
SpacePixelSet(Space *s)
187
if (strcmp("None",s->background) == 0)
189
if (s->pixmap != None)
196
/*------------------------------------------------------------------
199
------------------------------------------------------------------*/
201
SetSpacePixmap(Space *s, char *name)
203
unsigned int width, height;
204
Window root = XRootWindowOfScreen(XtScreen(shell));
206
s -> pixmap = XmGetPixmapByDepth(XtScreen(shell), name,
207
BlackPixel(XtDisplay(shell), 0),
208
WhitePixel(XtDisplay(shell), 0),
209
DefaultDepth(dsp, 0));
210
if (s -> pixmap == XmUNSPECIFIED_PIXMAP)
212
fprintf(stderr, "can't get pixmap for %s\n", name);
216
s->background[0] = '"';
217
s->background[1] = '\0';
218
strcat(s->background,name);
219
PRINT("s->background is %s\n",name);
225
/*------------------------------------------------------------------
228
------------------------------------------------------------------*/
230
SpacePixmapSet(Space *s)
232
if (strcmp("None",s->background) == 0)
234
if (s->pixmap == None)
242
/*------------------------------------------------------------------
245
------------------------------------------------------------------*/
247
SetSpaceLabelPixmap(Space *s, char *name)
249
unsigned int width, height;
254
Window root = XRootWindowOfScreen(XtScreen(shell));
256
PRINT("setting space %s label pixmap to %s\n", s->name,name);
257
if (strcmp(name,"None") == 0 || strcmp(name,"none")== 0)
259
status = XReadBitmapFile(dsp,root,name,&width,&height,&bitmap,
260
(int *)NULL, (int *)NULL);
262
if (status == BitmapOpenFailed)
264
fprintf(stderr, "can't open file %s\n", name);
267
else if (status == BitmapFileInvalid)
269
fprintf(stderr, "bad bitmap format file: %s\n", name);
272
else if (status == BitmapNoMemory)
274
fprintf(stderr, "insufficient memory for bitmap file: %s\n", name);
277
values.foreground = BlackPixel(XtDisplay(shell),0);
278
values.background = WhitePixel(XtDisplay(shell),0);
279
gc = XCreateGC(dsp,root,GCForeground|GCBackground,&values);
280
if (s->pixmap_label != None) XFreePixmap(dsp,s->pixmap_label);
281
s->pixmap_label = XCreatePixmap(dsp,root,width,height,
282
(unsigned int)DefaultDepth(dsp,0));
283
XCopyPlane(dsp,bitmap,s->pixmap_label,gc,0,0,width,height,0,0,
285
/* s->pixmap = XCreatePixmapFromBitmapData(dsp,root,name,width,height,
286
BlackPixel(XtDisplay(shell),0),
287
WhitePixel(XtDisplay(shell),0),
290
DefaultScreen(dsp)));*/
291
strcpy(s->pixmap_name,name);
292
PRINT("s->pixmap_name is %s\n",name);
299
/*------------------------------------------------------------------
302
------------------------------------------------------------------*/
304
SpaceLabelPixmapSet(Space *s)
306
if (s->pixmap_label == None)
314
/*------------------------------------------------------------------
315
CreateInternalStructure
317
------------------------------------------------------------------*/
319
CreateInternalStructure(WorkWindow *w_window,XrmQuark *rooms_qlist)
323
Boolean in_current_space = False;
324
if (w_window->all_workspaces)
326
/* create internal structures */
327
for (j=0, space = space_list; space !=NULL; space = space->next, j++)
329
if (space == current_space)
330
in_current_space = True;
331
AddSpaceToWindow(space, w_window);
332
AddWindowToSpace(space, w_window);
335
else if (rooms_qlist == NULL)
337
AddSpaceToWindow(current_space,w_window);
338
AddWindowToSpace(current_space,w_window);
339
in_current_space = True;
343
/* create internal structures */
344
for (j=0; rooms_qlist[j] != NULLQUARK; j++)
346
space = GetSpace(rooms_qlist[j]);
348
space = CreateSpace(rooms_qlist[j], XrmQuarkToString(rooms_qlist[j]));
349
if (space == current_space)
350
in_current_space = True;
351
AddSpaceToWindow(space, w_window);
352
AddWindowToSpace(space, w_window);
356
if (w_window->all_workspaces)
357
AddWindowToSpace(all_space,w_window);
358
return in_current_space;
361
/*------------------------------------------------------------------
364
------------------------------------------------------------------*/
366
CreateWorkWindow(Window window)
371
w = GetWorkWindow(window);
373
/* if wsm already knows about this window then just
374
set mapped = True and return the window */
381
w = (WorkWindow *)XtMalloc(sizeof(WorkWindow));
385
switch (_WSMGetConfigFormatType(window))
388
w->attrib_qlist = global_attribq;
389
w->attrib_list = global_attrib_list;
390
w->num_attrib_list = num_global_attrib;
391
w->all_workspaces = True;
392
w->specifier_qlist = GetSpecifierQList(0,False);
393
w->name = GetWMName(0,False);
397
w->attrib_qlist = window_attribq;
398
w->attrib_list = window_attrib_list;
399
w->num_attrib_list = num_window_attrib;
400
w->all_workspaces = False;
401
w->specifier_qlist = GetSpecifierQList(window,False);
402
w->name = GetWMName(window,False);
406
w->attrib_qlist = icon_attribq;
407
w->attrib_list = icon_attrib_list;
408
w->num_attrib_list = num_icon_attrib;
409
w->all_workspaces = True;
410
w->specifier_qlist = GetSpecifierQList(window, True);
411
w->name = GetWMName(window,True);
420
w->last_space = NULL;
424
w->win_data = (WSMWinData*)XtMalloc(w->num_attrib_list*sizeof(WSMWinData));
425
for (i = 0; i < w->num_attrib_list; i++)
427
w->win_data[i].nameq = w->attrib_qlist[i];
428
w->win_data[i].type = WSM_NONE;
429
w->win_data[i].data.value = -1;
431
if (work_windows == NULL)
436
while (w2->next != NULL)
442
if (w->all_workspaces)
444
CreateInternalStructure(w,NULL);
445
UpdateBothList(all_space);
448
if (_WSMGetConfigFormatType(window) == WSM_WINDOW_FMT)
450
PRINT("XSelectInput ");
452
XSelectInput(dsp,window,StructureNotifyMask);
460
/*------------------------------------------------------------------
463
------------------------------------------------------------------*/
465
ReCreateWorkWindow(Window window)
470
w = GetWorkWindow(window);
473
return CreateWorkWindow(window);
475
switch (_WSMGetConfigFormatType(window))
478
w->attrib_qlist = global_attribq;
479
w->attrib_list = global_attrib_list;
480
w->num_attrib_list = num_global_attrib;
484
w->attrib_qlist = window_attribq;
485
w->attrib_list = window_attrib_list;
486
w->num_attrib_list = num_window_attrib;
490
w->attrib_qlist = icon_attribq;
491
w->attrib_list = icon_attrib_list;
492
w->num_attrib_list = num_icon_attrib;
499
XtFree((XtPointer)w->win_data);
500
w->win_data = (WSMWinData*)XtMalloc(w->num_attrib_list*sizeof(WSMWinData));
501
for (i = 0; i < w->num_attrib_list; i++)
503
w->win_data[i].nameq = w->attrib_qlist[i];
504
w->win_data[i].type = WSM_NONE;
505
w->win_data[i].data.value = -1;
513
/*------------------------------------------------------------------
516
------------------------------------------------------------------*/
518
GetSpace(XrmQuark name)
524
if (s->nameq == name)
528
PRINT("returning NULL space\n");
534
/*------------------------------------------------------------------
537
------------------------------------------------------------------*/
539
GetSpaceFromName(char *name)
545
if (strcmp(s->name,name)== 0)
549
PRINT("returning NULL space\n");
556
/*------------------------------------------------------------------
559
------------------------------------------------------------------*/
566
for (i = 0, s = space_list; s != NULL; s = s->next, i++);
571
/*------------------------------------------------------------------
574
------------------------------------------------------------------*/
576
GetWorkWindowID(Space *s,int wsm_index)
579
WorkWindowList *w_list = s->w_list;
581
while (w_list != NULL)
583
if (_WSMGetConfigFormatType(w_list->work_win->window) == WSM_WINDOW_FMT)
586
return w_list->work_win;
589
w_list = w_list->next;
597
/*------------------------------------------------------------------
600
------------------------------------------------------------------*/
602
GetSpaceFromID(int wsm_index)
607
if (s == NULL) return NULL;
609
for (j = 0; j < wsm_index; j++)
622
/*------------------------------------------------------------------
625
------------------------------------------------------------------*/
627
GetSpaceID(Space *space)
632
for (j = 0, s = space_list; s != NULL; s = s->next, j++)
643
/*------------------------------------------------------------------
646
------------------------------------------------------------------*/
648
GetWorkWindow(Window window)
654
if (w->window == window)
666
/*------------------------------------------------------------------
669
------------------------------------------------------------------*/
673
GetWorkWindowClient(Window window, WorkWindow*** w_windows, int *num_w_windows)
675
GetWorkWindowClient(window)
677
WorkWindow ***w_windows;
681
WorkWindow *w, *i_window;
684
Boolean found = False;
689
if (w->window == window)
698
if (!found) return False;
700
i_window = GetIconWorkWindow(win);
702
if (i_window == NULL)
703
w_wins = (WorkWindow*) XtMalloc(sizeof(WorkWindow*));
705
w_wins = (WorkWindow*) XtMalloc(2*sizeof(WorkWindow*));
707
w_wins[num_w++] = main_w;
708
if (i_window != NULL)
709
w_wins[num_w++] = i_window;
711
client_id = main_w->specifier_qlist[0];
712
count = main_w->specifier_qlist[2];
717
if (w->specifier_qlist[0] == client_id && w->specifier_qlist[2] == count)
719
w_wins = (WorkWidnow*) XtRealloc(w_wins,(num_w+1) * sizeof(WorkWindow*));
726
*num_w_windows = num_w;
735
/*------------------------------------------------------------------
736
GetWorkWindowClientIDs
738
------------------------------------------------------------------*/
741
GetWorkWindowClientIDs(int main_pos, Space *s, int **w_ids, int *num_wids)
743
WorkWindowList *w_list;
746
Boolean found = False;
749
XrmQuark client_id, count;
753
while (w_list != NULL)
755
if (_WSMGetConfigFormatType(w_list->work_win->window) == WSM_WINDOW_FMT)
759
main_w = w_list->work_win;
765
w_list = w_list->next;
768
if (!found) return False;
770
wids = (int*) XtMalloc(sizeof(int));
772
wids[num_w++] = main_pos;
774
client_id = main_w->specifier_qlist[0];
775
count = main_w->specifier_qlist[2];
779
while (w_list != NULL)
781
if (_WSMGetConfigFormatType(w_list->work_win->window) == WSM_WINDOW_FMT)
783
if (w_list->work_win->specifier_qlist[0] == client_id
784
&& w_list->work_win->specifier_qlist[2] == count
785
&& w_list->work_win != main_w)
787
wids = (int*) XtRealloc((char*)wids,(num_w+1) * sizeof(int));
793
w_list = w_list->next;
805
/*------------------------------------------------------------------
808
------------------------------------------------------------------*/
810
GetIconWorkWindow(Window window)
816
if (w->window == (window | ~WIN_MASK))
820
PRINT("returning NULL icon window\n");
825
/*------------------------------------------------------------------
828
------------------------------------------------------------------*/
830
AddSpaceToWindow(Space *s,
831
WorkWindow *w_window)
833
SpaceList *s_list, *s_list2;
835
s_list = (SpaceList*)XtMalloc(sizeof(SpaceList));
838
if (w_window->s_list == NULL)
840
w_window->s_list = s_list;
844
s_list2 = w_window->s_list;
845
if (s_list2->space == s)
847
XtFree((char*)s_list);
850
while (s_list2->next != NULL)
852
s_list2 = s_list2->next;
853
if (s_list2->space == s)
855
XtFree((char*)s_list);
859
s_list2->next = s_list;
862
if ((w_window->s_list != NULL) && (w_window->s_list->next != NULL) &&
863
(w_window->mapped) &&
864
(_WSMGetConfigFormatType(w_window->window) == WSM_WINDOW_FMT))
866
EnableDeleteCommand(w_window->window);
869
UpdateButtons(w_window);
873
/*------------------------------------------------------------------
876
------------------------------------------------------------------*/
878
AddWindowToSpace(Space *s,
879
WorkWindow *w_window)
881
WorkWindowList *w_list,*w_list2;
883
w_list = (WorkWindowList*)XtMalloc(sizeof(WorkWindowList));
885
w_list->work_win = w_window;
886
w_list->sib_win = NULL;
887
if (s->w_list == NULL)
892
if (w_list2->work_win == w_window)
894
XtFree((char*)w_list);
897
while (w_list2->next != NULL)
899
w_list2 = w_list2->next;
900
if (w_list2->work_win == w_window)
902
XtFree((char*)w_list);
906
w_list2->next = w_list;
912
/*------------------------------------------------------------------
913
RemoveWorkWindowFromSpace
915
------------------------------------------------------------------*/
917
RemoveWorkWindowFromSpace(Space *s,
918
WorkWindow *w_window)
920
WorkWindowList *w_list,*pw_list;
924
while (w_list !=NULL)
926
if (w_list->work_win == w_window)
928
if (pw_list == w_list)
929
s->w_list = s->w_list->next;
931
pw_list->next = w_list->next;
932
XtFree((XtPointer)w_list);
936
if (w_list->sib_win == w_window)
937
w_list->sib_win = NULL;
939
w_list = w_list->next;
947
/*------------------------------------------------------------------
948
RemoveSpaceFromWindow
950
------------------------------------------------------------------*/
952
RemoveSpaceFromWindow(Space *s,
953
WorkWindow *w_window)
955
SpaceList *s_list,*ps_list;
957
s_list = w_window->s_list;
959
while (s_list !=NULL)
961
if (s_list->space == s)
963
if (ps_list == s_list)
964
w_window->s_list = w_window->s_list->next;
966
ps_list->next = s_list->next;
967
XtFree((XtPointer)s_list);
969
if (w_window->s_list != NULL)
970
if (w_window->s_list->next == NULL)
971
DisableDeleteCommand(w_window->window);
975
s_list = s_list->next;
977
if (w_window->s_list != NULL)
978
if (w_window->s_list->next == NULL)
979
DisableDeleteCommand(w_window->window);
981
UpdateButtons(w_window);
986
/*------------------------------------------------------------------
989
------------------------------------------------------------------*/
991
RemoveWorkWindow(WorkWindow *w_window, Boolean purge)
994
WorkWindow *pre_window, *post_window;
995
pre_window = w_window->prev;
996
post_window = w_window->next;
997
s_list = w_window->s_list;
998
while (s_list != NULL)
1000
RemoveWorkWindowFromSpace(s_list->space, w_window);
1001
s_list = s_list->next;
1004
if (w_window->all_workspaces)
1005
RemoveWorkWindowFromSpace(all_space,w_window);
1007
if (work_windows == w_window)
1008
work_windows = w_window->next;
1009
if (pre_window != NULL)
1010
pre_window->next = post_window;
1011
if (post_window != NULL)
1012
post_window->prev = pre_window;
1015
(void) PurgeAllWindowConfiguration(shell,
1016
w_window->specifier_qlist,
1017
w_window->attrib_qlist);
1020
XtFree((XtPointer)w_window->win_data);
1021
XtFree((XtPointer)w_window);
1024
/*------------------------------------------------------------------
1027
------------------------------------------------------------------*/
1030
RemoveSpace(Space *space)
1032
WorkWindowList *w_list, *destroy_list;
1035
w_list = space->w_list;
1036
while (w_list != NULL)
1038
RemoveSpaceFromWindow(space,w_list->work_win);
1039
destroy_list = w_list;
1040
w_list = w_list->next;
1041
XtFree((char*)destroy_list);
1051
space_list = s->next;
1059
XtFree((XtPointer)space);
1062
/*------------------------------------------------------------------
1065
------------------------------------------------------------------*/
1067
IsWorkWindowInSpace(WorkWindow *w,Space *s)
1069
WorkWindowList *w_list;
1071
if (w->all_workspaces && s!= all_space) return True;
1073
while (w_list != NULL)
1075
if (w_list->work_win == w)
1077
w_list = w_list->next;
1083
/*------------------------------------------------------------------
1086
------------------------------------------------------------------*/
1088
IsSpaceInWorkWindow(Space *s, WorkWindow *w)
1092
if (w->all_workspaces && s!= all_space) return True;
1094
while (s_list !=NULL)
1096
if (s_list->space == s)
1098
s_list = s_list->next;
1104
/*------------------------------------------------------------------
1107
------------------------------------------------------------------*/
1108
void InitializeWsm()
1110
atoms.save_property = XmInternAtom(XtDisplay(shell),"WM_SAVE_YOURSELF",False);
1111
atoms.protocols_property = XmInternAtom(XtDisplay(shell),"WM_PROTOCOLS",False);
1112
atoms.sm_client_id_property = XmInternAtom(XtDisplay(shell),"_MOTIF_SM_CLIENT_ID",False);
1113
atoms.wm_role_property = XmInternAtom(XtDisplay(shell),"_MOTIF_WM_WINDOW_ROLE",False);
1114
atoms.wm_client_leader = XmInternAtom(XtDisplay(shell),"WM_CLIENT_LEADER",False);
1116
all_space = (Space *)XtMalloc(sizeof(Space));
1117
all_space->nameq = XrmStringToQuark("all");
1118
all_space->w_list = NULL;
1119
all_space->next = NULL;
1121
current_space = NULL;
1126
/*------------------------------------------------------------------
1129
------------------------------------------------------------------*/
1131
void CompleteRestartWSM()
1134
WorkWindowList *w_list, *destroy_w_list;
1135
WorkWindow *w, *destroy_w;
1136
SpaceList *s_list, *destroy_s_list;
1143
while (w_list != NULL)
1145
destroy_w_list = w_list;
1146
w_list = w_list->next;
1147
XtFree((XtPointer)destroy_w_list);
1153
w_list = all_space->w_list;
1154
while (w_list != NULL)
1156
destroy_w_list=w_list;
1157
w_list = w_list->next;
1158
XtFree((XtPointer)destroy_w_list);
1161
all_space->w_list = NULL;
1162
all_space->next = NULL;
1169
while (s_list != NULL)
1171
destroy_s_list = s_list;
1172
s_list = s_list->next;
1173
XtFree((XtPointer)destroy_s_list);
1176
XtFree((XtPointer)destroy_w);
1179
work_windows = NULL;
1181
PRINT("Restarting WSM\n");
1190
for (w = work_windows; w != NULL; w = w->next)
1196
void FinishRestartWSM()
1200
for (w = work_windows; w != NULL; w = w->next)
1202
if (w->used == False)
1204
RemoveWorkWindow(w,False);
1208
/*------------------------------------------------------------------
1211
------------------------------------------------------------------*/
1213
GetWSMWindow(WorkWindow *w_window)
1216
return (w_window->window);
1222
/*------------------------------------------------------------------
1225
------------------------------------------------------------------*/
1227
SetWorkWindowValues(WorkWindow *w, Boolean all_workspaces, Boolean linked)
1229
if (all_workspaces && !(w->all_workspaces))
1231
AddWindowToSpace(all_space,w);
1232
UpdateBothList(all_space);
1235
else if (!all_workspaces && w->all_workspaces)
1237
RemoveWorkWindowFromSpace(all_space,w);
1238
UpdateBothList(all_space);
1241
w->all_workspaces = all_workspaces;
1248
/*------------------------------------------------------------------
1251
------------------------------------------------------------------*/
1255
WorkWindowList *w_list = current_space->w_list;
1256
while (w_list!= NULL)
1258
w_list->work_win->mapped = False;
1259
w_list = w_list->next;
1263
/*------------------------------------------------------------------
1266
------------------------------------------------------------------*/
1268
UnmapWorkWindow(WorkWindow *w_window)
1270
w_window->mapped = False;
1273
/*------------------------------------------------------------------
1276
------------------------------------------------------------------*/
1278
MapWorkWindow(WorkWindow *w_window)
1280
w_window->mapped = True;
1284
/**********************************************************************/
1285
/* This is for testing purposes. */
1286
/**********************************************************************/
1294
p = &s[strlen(s)-1]; /* point to last char */
1295
while((*p <= ' ') && p >= s) p--;
1304
translate_for_database(char *s)
1306
int length = strlen(s);
1310
for (i = 0; i < length; i++)
1320
GetWMName(Window window, Boolean is_icon)
1322
XTextProperty textProperty;
1327
str = (char*) XtMalloc((strlen("Global") +1) * sizeof(char));
1328
strcpy(str,"Global");
1331
if(XGetWMName(dsp, (window & WIN_MASK), &textProperty)) {
1332
if (textProperty.encoding == XA_STRING) {
1333
if (textProperty.value) {
1334
str = (String)textProperty.value;
1340
str = (char*)XtRealloc(str,(strlen(str)+2 )* sizeof(char));
1357
GetWMClient(Window window, Boolean is_icon)
1361
unsigned long nitems, after;
1365
status = XGetWindowProperty(dsp,
1366
(window & WIN_MASK),
1367
atoms.sm_client_id_property,
1375
(unsigned char **)&str);
1377
if (status == Success)
1379
if (str == NULL) return (NULL);
1380
translate_for_database(str);
1383
str = (char*) XtRealloc((char*)str,(strlen(str)+2) * sizeof(char));
1391
* if there's no clientID on this window, then see if it points
1392
* to a client leader that has a clientID.
1398
/* check for CLIENT_LEADER property. */
1399
status = XGetWindowProperty(dsp,
1400
(window & WIN_MASK),
1401
atoms.wm_client_leader,
1409
(unsigned char **)&leader);
1410
if (status == Success)
1412
if ((leader == None) || (leader == window))
1415
return (GetWMClient(leader, is_icon));
1420
/* Old-style client - no WM_CLIENT_ID property */
1432
GetWMRole(Window window, Boolean is_icon)
1436
unsigned long nitems, after;
1440
status = XGetWindowProperty(dsp,
1441
(window & WIN_MASK),
1442
atoms.wm_role_property,
1450
(unsigned char **)&str);
1452
if (status == Success)
1454
if (str == NULL) return (NULL);
1455
translate_for_database(str);
1458
str = (char*) XtRealloc((char*)str,(strlen(str)+2) * sizeof(char));
1473
GetWMCount(XrmQuark client, XrmQuark role)
1480
for (w = work_windows; w!= NULL; w = w->next)
1482
if (w->specifier_qlist[0] == client && w->specifier_qlist[1] == role)
1485
str = (String) XtMalloc(4*sizeof(char));
1489
sprintf(str,"%d",count);
1495
GetSpecifierQList(Window window, Boolean is_icon)
1497
XrmQuark *specifier;
1502
specifier = (XrmQuark*)XtMalloc(4*sizeof(XrmQuark));
1506
client = GetWMClient(window, is_icon);
1508
client = GetWMName(window,is_icon);
1509
role = GetWMRole(window, is_icon);
1511
role = GetWMName(window,is_icon);
1512
specifier[0] = XrmStringToQuark(client);
1513
specifier[1] = XrmStringToQuark(role);
1514
count = GetWMCount(specifier[0],specifier[1]);
1515
specifier[2] = XrmStringToQuark(count);
1516
specifier[3] = NULLQUARK;
1517
XtFree((XtPointer)client);
1518
XtFree((XtPointer)role);
1519
XtFree((XtPointer)count);
1523
specifier[0] = XrmStringToQuark("Global");
1524
specifier[1] = NULLQUARK;