From 4b8dcffcc0146a729ca324bdd8b67f07078353b8 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 9 Mar 2020 21:17:29 -0400 Subject: [PATCH] switched to using default screen --- build.sh | 2 +- cursor.c | 4 ++-- disp.c | 12 +++--------- lwm.c | 28 +++++++++++----------------- lwm.h | 4 ++-- manage.c | 6 +----- 6 files changed, 20 insertions(+), 36 deletions(-) diff --git a/build.sh b/build.sh index 623d39d..dffa823 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,2 @@ #!/bin/sh -cc -g -o lwm *.c -I. -I/usr/X11/include/ -L/usr/X11/lib -lX11 -lICE -lSM +cc -Wall -Wextra -g -o lwm *.c -I. -I/usr/X11/include/ -L/usr/X11/lib -lX11 -lICE -lSM diff --git a/cursor.c b/cursor.c index 4839b01..83920c8 100644 --- a/cursor.c +++ b/cursor.c @@ -46,12 +46,12 @@ static CursorMapping cursor_mappings[] = { }; extern void -initialiseCursors(int screen) { +initialiseCursors(void) { XColor red, white, exact; Colormap cmp; int i; - cmp = DefaultColormap(dpy, screen); + cmp = DefaultColormap(dpy, DefaultScreen(dpy)); XAllocNamedColor(dpy, cmp, "red", &red, &exact); XAllocNamedColor(dpy, cmp, "white", &white, &exact); diff --git a/disp.c b/disp.c index bcafd91..36266d4 100644 --- a/disp.c +++ b/disp.c @@ -83,12 +83,6 @@ static Disp disps[] = {NoExpose, 0}, }; -/** - * pending it the client in which an action has been started by a mouse press - * and we are waiting for the button to be released before performing the action - */ -static Client *pending=NULL; - extern void dispatch(XEvent * ev) { Disp * p; @@ -132,7 +126,6 @@ static void buttonpress(XEvent *ev) { Client *c; XButtonEvent *e = &ev->xbutton; - int quarter; /* If we're getting it already, we're not in the market for more. */ if (mode != wm_idle) { @@ -188,6 +181,7 @@ buttonpress(XEvent *ev) { static void buttonrelease(XEvent *ev) { + (void)ev; mode = wm_idle; } @@ -218,7 +212,6 @@ maprequest(XEvent *ev) { c = Client_Get(e->window); if (c == 0 || c->window != e->window) { - int screen; scanWindowTree(); c = Client_Get(e->window); if (c == 0 || c->window != e->window) { @@ -230,7 +223,7 @@ maprequest(XEvent *ev) { switch (c->state) { case WithdrawnState: if (c->parent == root) { - manage(c, 0); + manage(c); break; } if (c->framed == True) { @@ -571,6 +564,7 @@ reshaping_motionnotify(XEvent* ev) { int pointer_x; int pointer_y; + (void)ev; if (mode != wm_reshaping || !current) return; Window wroot, child; diff --git a/lwm.c b/lwm.c index e5bb131..b118fde 100644 --- a/lwm.c +++ b/lwm.c @@ -65,8 +65,7 @@ Atom wm_take_focus; char *argv0; -static void initScreens(void); -static void initScreen(int); +static void initScreen(void); /*ARGSUSED*/ extern int @@ -74,6 +73,7 @@ main(int argc, char *argv[]) { XEvent ev; argv0 = argv[0]; mode = wm_initialising; + (void)argc; /* Open a connection to the X server. */ dpy = XOpenDisplay(NULL); @@ -109,9 +109,12 @@ main(int argc, char *argv[]) { font_set_ext = XExtentsOfFontSet(font_set); } - initScreens(); - + /* Go through the screens one-by-one, initialising them. */ + initialiseCursors(); + initScreen(); + scanWindowTree(); mode = wm_idle; + for (;;) { XNextEvent(dpy, &ev); @@ -167,7 +170,7 @@ scanWindowTree(void) { c->border = attr.border_width; if (attr.map_state == IsViewable) { c->internal_state = IPendingReparenting; - manage(c, 1); + manage(c); } } } @@ -195,28 +198,19 @@ titleWidth(XFontSet font_set, Client *c) { name = c->name; namelen = c->namelen; if (name == NULL) return 0; - Xutf8TextExtents(font_set, name, namelen, - &ink, &logical); + Xutf8TextExtents(font_set, name, namelen, &ink, &logical); return logical.width; } static void -initScreens(void) { - /* Go through the screens one-by-one, initialising them. */ - initialiseCursors(0); - initScreen(0); - scanWindowTree(); -} - -static void -initScreen(int screen) { +initScreen(void) { XGCValues gv; XSetWindowAttributes attr; XColor colour, exact; - int len; /* Find the root window. */ + int screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); display_width = DisplayWidth(dpy, screen); display_height = DisplayHeight(dpy, screen); diff --git a/lwm.h b/lwm.h index 5ccfd8a..aed2bdb 100644 --- a/lwm.h +++ b/lwm.h @@ -146,7 +146,7 @@ extern int Client_HasFlags(Client*, int); /* cursor.c */ extern Cursor getEdgeCursor(Edge edge); -extern void initialiseCursors(int); +extern void initialiseCursors(void); /* disp.c */ extern void dispatch(XEvent *); @@ -159,5 +159,5 @@ extern void panic(char*); /* manage.c */ extern void getWindowName(Client *); extern void getNormalHints(Client *); -extern void manage(Client *, int); +extern void manage(Client *); diff --git a/manage.c b/manage.c index 74ef902..1a62618 100644 --- a/manage.c +++ b/manage.c @@ -33,7 +33,7 @@ static int getWindowState(Window, int *); /*ARGSUSED*/ void -manage(Client * c, int mapped) +manage(Client * c) { int state; XWMHints * hints; @@ -45,10 +45,6 @@ manage(Client * c, int mapped) int n; int p; - /* Where auto-placement is going to put the next window. */ - static int auto_x = 100; - static int auto_y = 100; - /* is this window to have a frame? */ c->framed = True; -- 2.54.0