summaryrefslogtreecommitdiff
path: root/x-window-list.c
diff options
context:
space:
mode:
authorPatrick <devnull@mailinator.com>2015-10-15 15:38:05 +0800
committerPatrick <devnull@mailinator.com>2015-10-15 15:38:05 +0800
commit00195baff8d1c3bea711a37852d26fc04edf0b2d (patch)
treeb4428090feb5e90ed7bba233dcb90ef8ac6941c3 /x-window-list.c
parent72197fa6a8a48682d54bd81d41ab5a00d56fd167 (diff)
switch to defined style standard
Diffstat (limited to 'x-window-list.c')
-rw-r--r--x-window-list.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/x-window-list.c b/x-window-list.c
index ef53d38..36ece4b 100644
--- a/x-window-list.c
+++ b/x-window-list.c
@@ -16,8 +16,8 @@ If not, see http://creativecommons.org/publicdomain/zero/1.0/ */
#include <stdlib.h>
typedef struct Config {
- _Bool is_switch; // list windows or switch to dst window?
- unsigned int dst;
+ _Bool is_switch; // list windows or switch to dst window?
+ unsigned int dst;
} Config;
/* static int cmp(Window **a, Window **b) {
@@ -27,54 +27,54 @@ typedef struct Config {
} */
void x_window_list(Config cfg, Display *dpy, Window *wins, unsigned int nwins) {
- Window *viewables[nwins], *w;
- unsigned int vc = 0;
+ Window *viewables[nwins], *w;
+ unsigned int vc = 0;
- // get list of viewable windows
- for (w = wins + nwins - 1; w >= wins; w--) {
- XWindowAttributes attr;
+ // get list of viewable windows
+ for (w = wins + nwins - 1; w >= wins; w--) {
+ XWindowAttributes attr;
- XGetWindowAttributes(dpy, *w, &attr);
- if (attr.map_state == IsViewable) {
- viewables[vc++] = w;
- }
- }
- viewables[vc] = NULL;
+ XGetWindowAttributes(dpy, *w, &attr);
+ if (attr.map_state == IsViewable) {
+ viewables[vc++] = w;
+ }
+ }
+ viewables[vc] = NULL;
- // list them out
- for (int i=0; i < vc; i++) {
- XTextProperty name;
- XClassHint hint;
- w = viewables[i];
+ // list them out
+ for (int i=0; i < vc; i++) {
+ XTextProperty name;
+ XClassHint hint;
+ w = viewables[i];
- XGetClassHint(dpy, *w, &hint);
- XGetWMName(dpy, *w, &name);
- printf("%02d 0x%-12x %s - %s\n", i, (unsigned int)*w, hint.res_name, name.value);
- if (cfg.is_switch && i == cfg.dst) {
- XRaiseWindow(dpy, *w);
- XSetInputFocus(dpy, *w, RevertToPointerRoot, CurrentTime);
- }
- }
+ XGetClassHint(dpy, *w, &hint);
+ XGetWMName(dpy, *w, &name);
+ printf("%02d 0x%-12x %s - %s\n", i, (unsigned int)*w, hint.res_name, name.value);
+ if (cfg.is_switch && i == cfg.dst) {
+ XRaiseWindow(dpy, *w);
+ XSetInputFocus(dpy, *w, RevertToPointerRoot, CurrentTime);
+ }
+ }
}
int main(int argc, char **argv) {
- Display *dpy;
- Window root, parent, *wins;
- unsigned int nwins = 0;
- Config c = { .is_switch = 0, .dst = 0 };
+ Display *dpy;
+ Window root, parent, *wins;
+ unsigned int nwins = 0;
+ Config c = { .is_switch = 0, .dst = 0 };
- if (argc > 1) {
- c.is_switch = 1;
- c.dst = atoi(argv[1]);
- }
+ if (argc > 1) {
+ c.is_switch = 1;
+ c.dst = atoi(argv[1]);
+ }
- if ((dpy = XOpenDisplay(NULL)) == NULL)
- return 1;
+ if ((dpy = XOpenDisplay(NULL)) == NULL)
+ return 1;
- XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins);
- if (nwins == 0)
- return 0;
+ XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins);
+ if (nwins == 0)
+ return 0;
- x_window_list(c, dpy, wins, nwins);
- return 0;
+ x_window_list(c, dpy, wins, nwins);
+ return 0;
}