summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu OTHACEHE <m.othacehe@gmail.com>2016-12-07 10:03:57 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-12-08 17:48:14 +0100
commit2afbce75d61319e5fbbc7c8a1a4844870ef6a9e7 (patch)
tree44b3b1254323897f78301cbafbea475c39a80c69
parentd8fab39242f683f84027402d8b174ff68a581811 (diff)
downloadratpoison-2afbce75d61319e5fbbc7c8a1a4844870ef6a9e7.zip
Simplify scanwins function
Use find_screen_by_attr function, remove screen argument and a useless debug message.
-rw-r--r--src/main.c3
-rw-r--r--src/manage.c25
-rw-r--r--src/manage.h2
3 files changed, 14 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index ca5ebc8..cce4f94 100644
--- a/src/main.c
+++ b/src/main.c
@@ -743,9 +743,10 @@ main (int argc, char *argv[])
{
if (!rp_current_screen)
rp_current_screen = cur;
- scanwins (cur);
}
+ scanwins ();
+
if (read_startup_files (alt_rcfile) == -1)
return EXIT_FAILURE;
diff --git a/src/manage.c b/src/manage.c
index 8b62a30..2c12f09 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -447,37 +447,34 @@ unmanage (rp_window *w)
/* When starting up scan existing windows and start managing them. */
void
-scanwins(rp_screen *s)
+scanwins ()
{
rp_window *win;
XWindowAttributes attr;
unsigned int i, nwins;
Window dw1, dw2, *wins;
- XQueryTree(dpy, s->root, &dw1, &dw2, &wins, &nwins);
+ XQueryTree(dpy, rp_glob_screen.root, &dw1, &dw2, &wins, &nwins);
PRINT_DEBUG (("windows: %d\n", nwins));
for (i = 0; i < nwins; i++)
{
+ rp_screen *screen;
+
XGetWindowAttributes(dpy, wins[i], &attr);
if (is_rp_window_for_screen(wins[i])
|| attr.override_redirect == True
|| unmanaged_window (wins[i])) continue;
- {
- XWindowAttributes root_attr;
-
- XGetWindowAttributes (dpy, s->root, &root_attr);
- PRINT_DEBUG (("attrs: %d %d %d %d %d %d\n", root_attr.x, root_attr.y,
- s->left, s->top, s->left + s->width, s->top + s->height));}
- if (rp_have_xrandr
- && ((attr.x > s->left + s->width)
- || (attr.x < s->left)
- || (attr.y > s->top + s->height)
- || (attr.y < s->top))) continue;
+ screen = find_screen_by_attr (attr);
+ if (!screen)
+ {
+ PRINT_ERROR (("Unable to find a screen by window attributes\n"));
+ continue;
+ }
- win = add_to_window_list (s, wins[i]);
+ win = add_to_window_list (screen, wins[i]);
PRINT_DEBUG (("map_state: %s\n",
attr.map_state == IsViewable ? "IsViewable":
diff --git a/src/manage.h b/src/manage.h
index 6d5f1f5..22bb169 100644
--- a/src/manage.h
+++ b/src/manage.h
@@ -29,7 +29,7 @@ char *list_unmanaged_windows (void);
void add_unmanaged_window (char *name);
int unmanaged_window (Window w);
rp_screen* current_screen (void);
-void scanwins(rp_screen *s);
+void scanwins ();
void unmanage (rp_window *w);
int update_window_name (rp_window *win);
void update_normal_hints (rp_window *win);