]> git.mdlowis.com Git - proto/lwm.git/commitdiff
switched to using default screen
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 10 Mar 2020 01:17:29 +0000 (21:17 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 10 Mar 2020 01:17:29 +0000 (21:17 -0400)
build.sh
cursor.c
disp.c
lwm.c
lwm.h
manage.c

index 623d39d0cf49f77e3a7e67b77366fbe9d9d5567f..dffa823f891991d8cc12050673dfc6923dfd367e 100755 (executable)
--- 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
index 4839b01d9e0e39b1ca920e3df330958072621f09..83920c8093348a79ffb490f718ace29902ef7aad 100644 (file)
--- 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 bcafd91dd6dad90ebad15801796ad9b6dec4cef2..36266d4517a145eb4386adc1f5832b26834c1ed9 100644 (file)
--- 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 e5bb131a1f072514edd3be327bb316ce9e83aeb4..b118fde50dac58a332023f9077ea43b4d33a00ea 100644 (file)
--- 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 5ccfd8ae3ee3f4473f525b9c63a9c64f9c68083b..aed2bdb32abc64785a81d884dc0067a9e76e46e7 100644 (file)
--- 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 *);
 
index 74ef902f054d6ab8fa44eb22cfe9f6e63d222a4d..1a62618cf2d684c0652dd74dcdce79060025d9cd 100644 (file)
--- 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;