aboutsummaryrefslogtreecommitdiffstats
path: root/screen.c
diff options
context:
space:
mode:
authorokan2020-02-27 14:56:39 +0000
committerWynn Wolf Arbor2020-03-18 14:30:58 +0100
commitd8f3547b8f545b439d9df7b41cfe872ce6c8f42d (patch)
tree1be865226e709457b823835f42a3ed338801f74a /screen.c
parenta4006dcef17be430ad3cc2c2a63ea1de75a20d62 (diff)
downloadcwm-d8f3547b8f545b439d9df7b41cfe872ce6c8f42d.tar.gz
Unrelated style fixes, consistency changes and sorting, appropriate dosage/removal of wrappers, simplification of name queue, client cycle joins other kb/mb bound functions.
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/screen.c b/screen.c
index 390dfe4..70d3c98 100644
--- a/screen.c
+++ b/screen.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: screen.c,v 1.94 2020/01/22 19:58:35 okan Exp $
+ * $OpenBSD: screen.c,v 1.95 2020/02/27 14:56:39 okan Exp $
*/
#include <sys/types.h>
@@ -33,14 +33,14 @@
#include "calmwm.h"
static struct geom screen_apply_gap(struct screen_ctx *, struct geom);
+static void screen_scan(struct screen_ctx *, Window);
void
screen_init(int which)
{
struct screen_ctx *sc;
- Window *wins, w0, w1, active = None;
+ Window active = None;
XSetWindowAttributes rootattr;
- unsigned int nwins, w;
sc = xmalloc(sizeof(*sc));
@@ -77,13 +77,7 @@ screen_init(int which)
XChangeWindowAttributes(X_Dpy, sc->rootwin,
(CWEventMask | CWCursor), &rootattr);
- /* Deal with existing clients. */
- if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) {
- for (w = 0; w < nwins; w++)
- (void)client_init(wins[w], sc, (active == wins[w]));
-
- XFree(wins);
- }
+ screen_scan(sc, active);
screen_updatestackingorder(sc);
if (Conf.xrandr)
@@ -94,6 +88,20 @@ screen_init(int which)
XSync(X_Dpy, False);
}
+static void
+screen_scan(struct screen_ctx *sc, Window active)
+{
+ Window *wins, w0, w1;
+ unsigned int nwins, i;
+
+ if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) {
+ for (i = 0; i < nwins; i++)
+ (void)client_init(wins[i], sc, (active == wins[i]));
+
+ XFree(wins);
+ }
+}
+
struct screen_ctx *
screen_find(Window win)
{
@@ -101,10 +109,10 @@ screen_find(Window win)
TAILQ_FOREACH(sc, &Screenq, entry) {
if (sc->rootwin == win)
- return(sc);
+ return sc;
}
warnx("%s: failure win 0x%lx", __func__, win);
- return(NULL);
+ return NULL;
}
void
@@ -138,11 +146,11 @@ region_find(struct screen_ctx *sc, int x, int y)
break;
}
}
- return(rc);
+ return rc;
}
struct geom
-screen_area(struct screen_ctx *sc, int x, int y, enum apply_gap apply_gap)
+screen_area(struct screen_ctx *sc, int x, int y, int apply_gap)
{
struct region_ctx *rc;
struct geom area = sc->view;
@@ -156,7 +164,7 @@ screen_area(struct screen_ctx *sc, int x, int y, enum apply_gap apply_gap)
}
if (apply_gap)
area = screen_apply_gap(sc, area);
- return(area);
+ return area;
}
void
@@ -226,7 +234,7 @@ screen_apply_gap(struct screen_ctx *sc, struct geom geom)
geom.w -= (sc->gap.left + sc->gap.right);
geom.h -= (sc->gap.top + sc->gap.bottom);
- return(geom);
+ return geom;
}
/* Bring back clients which are beyond the screen. */