From 0379a2447167b942601056994a61b12238b4c68c Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Mon, 22 Nov 2021 08:38:20 +0500 Subject: [PATCH] Move screen to separate func --- src/dwm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dwm.c b/src/dwm.c index 5a4ab60..58b95c9 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -192,6 +192,7 @@ static void restack(Monitor *m); static void run(); static void scan(); static void scheme_destroy(); +static void screen_init(); static int sendevent(Client *c, Atom proto); static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); @@ -308,6 +309,8 @@ int dwm_main(const char *const new_program_title) fatal("cannot create atoms"); } + screen_init(); + // Old code. if (!setup()) { @@ -1646,6 +1649,13 @@ void scheme_destroy() } } +void screen_init() +{ + screen.x_screen = DefaultScreen(dpy); + screen.sizes.w = DisplayWidth(dpy, screen.x_screen); + screen.sizes.h = DisplayHeight(dpy, screen.x_screen); +} + void sendmon(Client *c, Monitor *m) { if (c->mon == m) @@ -1791,10 +1801,6 @@ bool setup() { XSetWindowAttributes wa; - /* init screen */ - screen.x_screen = DefaultScreen(dpy); - screen.sizes.w = DisplayWidth(dpy, screen.x_screen); - screen.sizes.h = DisplayHeight(dpy, screen.x_screen); root = RootWindow(dpy, screen.x_screen); drw = drw_create(dpy, screen.x_screen, root, screen.sizes.w, screen.sizes.h); if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))