2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2008-2009 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 EwinFindByPtr(const EWin * ewin)
38 ewins = EwinListGetAll(&num);
39 for (i = 0; i < num; i++)
48 EwinFindByClient(Window win)
53 ewins = EwinListGetAll(&num);
54 for (i = 0; i < num; i++)
56 if (win == EwinGetClientXwin(ewins[i]))
63 EwinFindByChildren(Window win)
68 ewins = EwinListGetAll(&num);
69 for (i = 0; i < num; i++)
71 if ((win == EwinGetClientXwin(ewins[i])) ||
72 (win == EwinGetContainerXwin(ewins[i])))
78 for (j = 0; j < ewins[i]->border->num_winparts; j++)
79 if (win == WinGetXwin(ewins[i]->bits[j].win))
89 EwinsFindByExpr(const char *match, int *pnum, int *pflags)
94 int i, num, len, nfound, match_one, flags;
99 if (!match || !match[0])
105 if (!strcmp(match, "*") || !strcmp(match, "=") || !strcmp(match, "current"))
107 ewin = GetContextEwin();
109 ewin = GetFocusEwin();
111 flags = 1; /* Nogroup */
115 if (isdigit(match[0]))
119 sscanf(match, "%x", &win);
120 ewin = EwinFindByChildren(win);
125 if (!strcmp(match, "all"))
129 flags = 1; /* Nogroup */
131 else if (match[0] == '=')
135 flags = 1; /* Nogroup */
137 else if (strchr(match, '*'))
141 flags = 1; /* Nogroup */
152 ewins = EwinListGetAll(&num);
158 for (i = 0; i < num; i++)
162 if (type == 'a') /* All */
165 else if (type == 'w') /* Wildcard */
167 if (!matchregexp(match, EwinGetIcccmName(ewin)))
170 else /* Match name (substring) */
174 name = EwinGetIcccmName(ewin);
177 if (!Estrcasestr(name, match))
181 lst = EREALLOC(EWin *, lst, nfound);
182 lst[nfound - 1] = ewin;
192 lst = EMALLOC(EWin *, 1);
206 EwinFindByExpr(const char *match)
210 lst = EwinsFindByExpr(match, NULL, NULL);
219 ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup,
237 if (nogroup || ewin->num_groups <= 0)
240 ewins = EwinListGetAll(&num);
241 if (ewins == NULL) /* Should not be possible */
244 /* Loop through window stack, bottom up */
245 for (i = num - 1; i >= 0; i--)
252 /* To get consistent behaviour, limit groups to a single desktop for now: */
253 if (EoGetDesk(ew) != EoGetDesk(ewin))
256 grp = EwinsInGroup(ewin, ew);
262 case GROUP_ACTION_SET_WINDOW_BORDER:
263 if (!grp->cfg.set_border)
266 case GROUP_ACTION_ICONIFY:
267 if (!grp->cfg.iconify)
270 case GROUP_ACTION_MOVE:
274 case GROUP_ACTION_STACKING:
278 case GROUP_ACTION_STICK:
282 case GROUP_ACTION_SHADE:
286 case GROUP_ACTION_KILL:
295 gwins = EREALLOC(EWin *, gwins, gwcnt + 1);
303 gwins = EMALLOC(EWin *, 1);
304 gwins[0] = (EWin *) ewin;