From 16ff36d67b048b85b35b1955ae2c6535f14b4498 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 20 Nov 2021 22:14:57 +0500 Subject: [PATCH] Improve code of func "wintomon" --- src/dwm.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/dwm.c b/src/dwm.c index 7197ae8..f0e9de8 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -1739,13 +1739,18 @@ Client *wintoclient(Window w) Monitor *wintomon(Window w) { - int x, y; - Client *c; + { + int x = 0, y = 0; + if (w == root && getrootptr(&x, &y)) { + return recttomon(x, y, 1, 1); + } + } + + { + Client *c = wintoclient(w); + if (c) return c->mon; + } - if (w == root && getrootptr(&x, &y)) - return recttomon(x, y, 1, 1); - if ((c = wintoclient(w))) - return c->mon; return selmon; }