Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: ewins.c ewins.h finders.c ipc.c Log Message: Move/rename some functions. =================================================================== RCS file: /cvs/e/e16/e/src/ewins.c,v retrieving revision 1.190 retrieving revision 1.191 diff -u -3 -r1.190 -r1.191 --- ewins.c 17 Jan 2007 01:10:43 -0000 1.190 +++ ewins.c 4 Mar 2007 23:25:11 -0000 1.191 @@ -1900,6 +1900,101 @@ EWinChanges.flags = 0; } +EWin ** +EwinListTransients(const EWin * ewin, int *num, int group) +{ + EWin *const *ewins, **lst, *ew; + int i, j, n; + + j = 0; + lst = NULL; + + if (EwinGetTransientCount(ewin) <= 0) + goto done; + + ewins = EwinListGetAll(&n); + + /* Find regular transients */ + for (i = 0; i < n; i++) + { + ew = ewins[i]; + + /* Skip self-reference */ + if (ew == ewin) + continue; + + if (EwinGetTransientFor(ew) == EwinGetClientXwin(ewin)) + { + lst = EREALLOC(EWin *, lst, j + 1); + lst[j++] = ew; + } + } + + if (!group) + goto done; + + /* Group transients (if ewin is not a transient) */ + if (EwinIsTransient(ewin)) + goto done; + + for (i = 0; i < n; i++) + { + ew = ewins[i]; + + /* Skip self-reference */ + if (ew == ewin) + continue; + + if (EwinGetTransientFor(ew) == VRoot.xwin && + EwinGetWindowGroup(ew) == EwinGetWindowGroup(ewin)) + { + lst = EREALLOC(EWin *, lst, j + 1); + lst[j++] = ew; + } + } + + done: + *num = j; + return lst; +} + +EWin ** +EwinListTransientFor(const EWin * ewin, int *num) +{ + EWin *const *ewins, **lst, *ew; + int i, j, n; + + j = 0; + lst = NULL; + + if (!EwinIsTransient(ewin)) + goto done; + + ewins = EwinListGetAll(&n); + for (i = 0; i < n; i++) + { + ew = ewins[i]; + + /* Skip self-reference */ + if (ew == ewin) + continue; + + /* Regular parent or if root trans, top level group members */ + if ((EwinGetTransientFor(ewin) == EwinGetClientXwin(ew)) || + (!EwinIsTransient(ew) && + EwinGetTransientFor(ewin) == VRoot.xwin && + EwinGetWindowGroup(ew) == EwinGetWindowGroup(ewin))) + { + lst = EREALLOC(EWin *, lst, j + 1); + lst[j++] = ew; + } + } + + done: + *num = j; + return lst; +} + void EwinsEventsConfigure(int mode) { =================================================================== RCS file: /cvs/e/e16/e/src/ewins.h,v retrieving revision 1.65 retrieving revision 1.66 diff -u -3 -r1.65 -r1.66 --- ewins.h 13 Jan 2007 19:14:27 -0000 1.65 +++ ewins.h 4 Mar 2007 23:25:11 -0000 1.66 @@ -376,6 +376,9 @@ void EwinChange(EWin * ewin, unsigned int flag); +EWin **EwinListTransients(const EWin * ewin, int *num, int group); +EWin **EwinListTransientFor(const EWin * ewin, int *num); + void EwinsEventsConfigure(int mode); void EwinsSetFree(void); void EwinsShowDesktop(int on); @@ -436,8 +439,8 @@ EWin *EwinFindByFrame(Window win); EWin *EwinFindByClient(Window win); EWin *EwinFindByChildren(Window win); -EWin **EwinListTransients(const EWin * ewin, int *num, int group); -EWin **EwinListTransientFor(const EWin * ewin, int *num); +EWin **EwinsFindByExpr(const char *match, int *pnum, int *pflags); +EWin *EwinFindByExpr(const char *match); /* icccm.c (for now) */ #if USE_XSYNC =================================================================== RCS file: /cvs/e/e16/e/src/finders.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -3 -r1.54 -r1.55 --- finders.c 17 Jan 2007 01:10:43 -0000 1.54 +++ finders.c 4 Mar 2007 23:25:11 -0000 1.55 @@ -24,6 +24,8 @@ #include "borders.h" #include "ewins.h" #include "groups.h" +#include <ctype.h> +#include <string.h> EWin * EwinFindByPtr(const EWin * ewin) @@ -97,6 +99,136 @@ } EWin ** +EwinsFindByExpr(const char *match, int *pnum, int *pflags) +{ + EWin *ewin, **lst; + EWin *const *ewins; + int type; + int i, num, len, nfound, match_one, flags; + + if (pnum) + *pnum = 0; + + if (!match || !match[0]) + return NULL; + + ewin = NULL; + flags = 0; + + if (!strcmp(match, "*") || !strcmp(match, "=") || !strcmp(match, "current")) + { + ewin = GetContextEwin(); + if (!ewin) + ewin = GetFocusEwin(); + if (match[0] == '=') + flags = 1; /* Nogroup */ + goto do_one; + } + + if (isdigit(match[0])) + { + unsigned int win; + + sscanf(match, "%x", &win); + ewin = EwinFindByChildren(win); + goto do_one; + } + + match_one = 1; + if (!strcmp(match, "all")) + { + type = 'a'; + match_one = 0; + flags = 1; /* Nogroup */ + } + else if (match[0] == '=') + { + type = 's'; + match++; + flags = 1; /* Nogroup */ + } + else if (strchr(match, '*')) + { + type = 'w'; + match_one = 0; + flags = 1; /* Nogroup */ + } + else + { + type = 's'; + } + + len = strlen(match); + if (len <= 0) + return NULL; + + ewins = EwinListGetAll(&num); + if (!ewins) + return NULL; + + nfound = 0; + lst = NULL; + for (i = 0; i < num; i++) + { + ewin = ewins[i]; + + if (type == 'a') /* All */ + { + } + else if (type == 'w') /* Wildcard */ + { + if (!matchregexp(match, EwinGetIcccmName(ewin))) + continue; + } + else /* Match name (substring) */ + { + const char *name; + + name = EwinGetIcccmName(ewin); + if (!name) + continue; + if (!strcasestr(name, match)) + continue; + } + nfound++; + lst = EREALLOC(EWin *, lst, nfound); + lst[nfound - 1] = ewin; + if (match_one) + break; + } + goto done; + + do_one: + if (!ewin) + return NULL; + nfound = 1; + lst = EMALLOC(EWin *, 1); + if (!lst) + return NULL; + lst[0] = ewin; + + done: + if (pnum) + *pnum = nfound; + if (pflags) + *pflags = flags; + return lst; +} + +EWin * +EwinFindByExpr(const char *match) +{ + EWin *ewin, **lst; + + lst = EwinsFindByExpr(match, NULL, NULL); + if (!lst) + return NULL; + ewin = lst[0]; + Efree(lst); + return ewin; +} + +EWin ** ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup, int *pnum) { @@ -189,99 +321,4 @@ } *pnum = gwcnt; return gwins; -} - -EWin ** -EwinListTransients(const EWin * ewin, int *num, int group) -{ - EWin *const *ewins, **lst, *ew; - int i, j, n; - - j = 0; - lst = NULL; - - if (EwinGetTransientCount(ewin) <= 0) - goto done; - - ewins = EwinListGetAll(&n); - - /* Find regular transients */ - for (i = 0; i < n; i++) - { - ew = ewins[i]; - - /* Skip self-reference */ - if (ew == ewin) - continue; - - if (EwinGetTransientFor(ew) == EwinGetClientXwin(ewin)) - { - lst = EREALLOC(EWin *, lst, j + 1); - lst[j++] = ew; - } - } - - if (!group) - goto done; - - /* Group transients (if ewin is not a transient) */ - if (EwinIsTransient(ewin)) - goto done; - - for (i = 0; i < n; i++) - { - ew = ewins[i]; - - /* Skip self-reference */ - if (ew == ewin) - continue; - - if (EwinGetTransientFor(ew) == VRoot.xwin && - EwinGetWindowGroup(ew) == EwinGetWindowGroup(ewin)) - { - lst = EREALLOC(EWin *, lst, j + 1); - lst[j++] = ew; - } - } - - done: - *num = j; - return lst; -} - -EWin ** -EwinListTransientFor(const EWin * ewin, int *num) -{ - EWin *const *ewins, **lst, *ew; - int i, j, n; - - j = 0; - lst = NULL; - - if (!EwinIsTransient(ewin)) - goto done; - - ewins = EwinListGetAll(&n); - for (i = 0; i < n; i++) - { - ew = ewins[i]; - - /* Skip self-reference */ - if (ew == ewin) - continue; - - /* Regular parent or if root trans, top level group members */ - if ((EwinGetTransientFor(ewin) == EwinGetClientXwin(ew)) || - (!EwinIsTransient(ew) && - EwinGetTransientFor(ewin) == VRoot.xwin && - EwinGetWindowGroup(ew) == EwinGetWindowGroup(ewin))) - { - lst = EREALLOC(EWin *, lst, j + 1); - lst[j++] = ew; - } - } - - done: - *num = j; - return lst; } =================================================================== RCS file: /cvs/e/e16/e/src/ipc.c,v retrieving revision 1.294 retrieving revision 1.295 diff -u -3 -r1.294 -r1.295 --- ipc.c 25 Feb 2007 20:08:44 -0000 1.294 +++ ipc.c 4 Mar 2007 23:25:11 -0000 1.295 @@ -36,7 +36,6 @@ #include "snaps.h" #include "timers.h" #include "xwin.h" -#include <ctype.h> #define SS(s) ((s) ? (s) : NoText) static const char NoText[] = "-NONE-"; @@ -92,136 +91,6 @@ bufsiz += len; } -static EWin ** -IpcFindEwins(const char *match, int *pnum, int *pflags) -{ - EWin *ewin, **lst; - EWin *const *ewins; - int type; - int i, num, len, nfound, match_one, flags; - - if (pnum) - *pnum = 0; - - if (!match || !match[0]) - return NULL; - - ewin = NULL; - flags = 0; - - if (!strcmp(match, "*") || !strcmp(match, "=") || !strcmp(match, "current")) - { - ewin = GetContextEwin(); - if (!ewin) - ewin = GetFocusEwin(); - if (match[0] == '=') - flags = 1; /* Nogroup */ - goto do_one; - } - - if (isdigit(match[0])) - { - unsigned int win; - - sscanf(match, "%x", &win); - ewin = EwinFindByChildren(win); - goto do_one; - } - - match_one = 1; - if (!strcmp(match, "all")) - { - type = 'a'; - match_one = 0; - flags = 1; /* Nogroup */ - } - else if (match[0] == '=') - { - type = 's'; - match++; - flags = 1; /* Nogroup */ - } - else if (strchr(match, '*')) - { - type = 'w'; - match_one = 0; - flags = 1; /* Nogroup */ - } - else - { - type = 's'; - } - - len = strlen(match); - if (len <= 0) - return NULL; - - ewins = EwinListGetAll(&num); - if (!ewins) - return NULL; - - nfound = 0; - lst = NULL; - for (i = 0; i < num; i++) - { - ewin = ewins[i]; - - if (type == 'a') /* All */ - { - } - else if (type == 'w') /* Wildcard */ - { - if (!matchregexp(match, EwinGetIcccmName(ewin))) - continue; - } - else /* Match name (substring) */ - { - const char *name; - - name = EwinGetIcccmName(ewin); - if (!name) - continue; - if (!strcasestr(name, match)) - continue; - } - nfound++; - lst = EREALLOC(EWin *, lst, nfound); - lst[nfound - 1] = ewin; - if (match_one) - break; - } - goto done; - - do_one: - if (!ewin) - return NULL; - nfound = 1; - lst = EMALLOC(EWin *, 1); - if (!lst) - return NULL; - lst[0] = ewin; - - done: - if (pnum) - *pnum = nfound; - if (pflags) - *pflags = flags; - return lst; -} - -static EWin * -IpcFindEwin(const char *match) -{ - EWin *ewin, **lst; - - lst = IpcFindEwins(match, NULL, NULL); - if (!lst) - return NULL; - ewin = lst[0]; - Efree(lst); - return ewin; -} - static int SetEwinBoolean(const char *txt, char *item, const char *value, int set) { @@ -454,7 +323,7 @@ if (!match || !match[0]) match = "all"; - lst = IpcFindEwins(match, &num, NULL); + lst = EwinsFindByExpr(match, &num, NULL); if (!lst) { IpcPrintf("No windows matching %s\n", match); @@ -972,7 +841,7 @@ return; } - lst = IpcFindEwins(match, &num, &flags); + lst = EwinsFindByExpr(match, &num, &flags); if (!lst) { IpcPrintf("No windows matching %s\n", match); @@ -1245,7 +1114,7 @@ sscanf(params, "%1000s", match); - lst = IpcFindEwins(match, &num, NULL); + lst = EwinsFindByExpr(match, &num, NULL); if (!lst) { IpcPrintf("No windows matching %s\n", match); @@ -1302,8 +1171,8 @@ sscanf(params, "%100s %100s", param1, param2); - ewin = IpcFindEwin(param1); - enew = IpcFindEwin(param2); + ewin = EwinFindByExpr(param1); + enew = EwinFindByExpr(param2); if (!ewin || !enew) IpcPrintf("No matching client or target EWin found\n"); else ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs