parent
1a0917f4c2
commit
0ea436497d
95
src/ewins.c
95
src/ewins.c
|
@ -1900,6 +1900,101 @@ EwinChangesProcess(EWin * ewin)
|
||||||
EWinChanges.flags = 0;
|
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
|
void
|
||||||
EwinsEventsConfigure(int mode)
|
EwinsEventsConfigure(int mode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -376,6 +376,9 @@ void EwinUpdateOpacity(EWin * ewin);
|
||||||
|
|
||||||
void EwinChange(EWin * ewin, unsigned int flag);
|
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 EwinsEventsConfigure(int mode);
|
||||||
void EwinsSetFree(void);
|
void EwinsSetFree(void);
|
||||||
void EwinsShowDesktop(int on);
|
void EwinsShowDesktop(int on);
|
||||||
|
@ -436,8 +439,8 @@ EWin *EwinFindByPtr(const EWin * ewin);
|
||||||
EWin *EwinFindByFrame(Window win);
|
EWin *EwinFindByFrame(Window win);
|
||||||
EWin *EwinFindByClient(Window win);
|
EWin *EwinFindByClient(Window win);
|
||||||
EWin *EwinFindByChildren(Window win);
|
EWin *EwinFindByChildren(Window win);
|
||||||
EWin **EwinListTransients(const EWin * ewin, int *num, int group);
|
EWin **EwinsFindByExpr(const char *match, int *pnum, int *pflags);
|
||||||
EWin **EwinListTransientFor(const EWin * ewin, int *num);
|
EWin *EwinFindByExpr(const char *match);
|
||||||
|
|
||||||
/* icccm.c (for now) */
|
/* icccm.c (for now) */
|
||||||
#if USE_XSYNC
|
#if USE_XSYNC
|
||||||
|
|
227
src/finders.c
227
src/finders.c
|
@ -24,6 +24,8 @@
|
||||||
#include "borders.h"
|
#include "borders.h"
|
||||||
#include "ewins.h"
|
#include "ewins.h"
|
||||||
#include "groups.h"
|
#include "groups.h"
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
EWin *
|
EWin *
|
||||||
EwinFindByPtr(const EWin * ewin)
|
EwinFindByPtr(const EWin * ewin)
|
||||||
|
@ -96,6 +98,136 @@ EwinFindByChildren(Window win)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 **
|
EWin **
|
||||||
ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup,
|
ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup,
|
||||||
int *pnum)
|
int *pnum)
|
||||||
|
@ -190,98 +322,3 @@ ListWinGroupMembersForEwin(const EWin * ewin, int action, char nogroup,
|
||||||
*pnum = gwcnt;
|
*pnum = gwcnt;
|
||||||
return gwins;
|
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;
|
|
||||||
}
|
|
||||||
|
|
141
src/ipc.c
141
src/ipc.c
|
@ -36,7 +36,6 @@
|
||||||
#include "snaps.h"
|
#include "snaps.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
#include "xwin.h"
|
#include "xwin.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#define SS(s) ((s) ? (s) : NoText)
|
#define SS(s) ((s) ? (s) : NoText)
|
||||||
static const char NoText[] = "-NONE-";
|
static const char NoText[] = "-NONE-";
|
||||||
|
@ -92,136 +91,6 @@ IpcPrintf(const char *fmt, ...)
|
||||||
bufsiz += len;
|
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
|
static int
|
||||||
SetEwinBoolean(const char *txt, char *item, const char *value, int set)
|
SetEwinBoolean(const char *txt, char *item, const char *value, int set)
|
||||||
{
|
{
|
||||||
|
@ -454,7 +323,7 @@ IPC_WinList(const char *params, Client * c __UNUSED__)
|
||||||
if (!match || !match[0])
|
if (!match || !match[0])
|
||||||
match = "all";
|
match = "all";
|
||||||
|
|
||||||
lst = IpcFindEwins(match, &num, NULL);
|
lst = EwinsFindByExpr(match, &num, NULL);
|
||||||
if (!lst)
|
if (!lst)
|
||||||
{
|
{
|
||||||
IpcPrintf("No windows matching %s\n", match);
|
IpcPrintf("No windows matching %s\n", match);
|
||||||
|
@ -972,7 +841,7 @@ IPC_WinOps(const char *params, Client * c __UNUSED__)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lst = IpcFindEwins(match, &num, &flags);
|
lst = EwinsFindByExpr(match, &num, &flags);
|
||||||
if (!lst)
|
if (!lst)
|
||||||
{
|
{
|
||||||
IpcPrintf("No windows matching %s\n", match);
|
IpcPrintf("No windows matching %s\n", match);
|
||||||
|
@ -1245,7 +1114,7 @@ IPC_EwinInfo(const char *params, Client * c __UNUSED__)
|
||||||
|
|
||||||
sscanf(params, "%1000s", match);
|
sscanf(params, "%1000s", match);
|
||||||
|
|
||||||
lst = IpcFindEwins(match, &num, NULL);
|
lst = EwinsFindByExpr(match, &num, NULL);
|
||||||
if (!lst)
|
if (!lst)
|
||||||
{
|
{
|
||||||
IpcPrintf("No windows matching %s\n", match);
|
IpcPrintf("No windows matching %s\n", match);
|
||||||
|
@ -1302,8 +1171,8 @@ IPC_Reparent(const char *params, Client * c __UNUSED__)
|
||||||
|
|
||||||
sscanf(params, "%100s %100s", param1, param2);
|
sscanf(params, "%100s %100s", param1, param2);
|
||||||
|
|
||||||
ewin = IpcFindEwin(param1);
|
ewin = EwinFindByExpr(param1);
|
||||||
enew = IpcFindEwin(param2);
|
enew = EwinFindByExpr(param2);
|
||||||
if (!ewin || !enew)
|
if (!ewin || !enew)
|
||||||
IpcPrintf("No matching client or target EWin found\n");
|
IpcPrintf("No matching client or target EWin found\n");
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue