removing variables config.screen*
authorphillbush <phillbush@cock.li>
Thu, 30 Jul 2020 03:25:55 +0000 (00:25 -0300)
committerphillbush <phillbush@cock.li>
Thu, 30 Jul 2020 03:25:55 +0000 (00:25 -0300)
Makefile
xmenu.c
xmenu.h

index 7430e09..58079ce 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ all: ${PROG}
 ${PROG}: ${OBJS}
        ${CC} -o $@ ${OBJS} ${LDFLAGS}
 
 ${PROG}: ${OBJS}
        ${CC} -o $@ ${OBJS} ${LDFLAGS}
 
-${OBJS}: config.h
+${OBJS}: config.h ${PROG}.h
 
 .c.o:
        ${CC} ${CFLAGS} -c $<
 
 .c.o:
        ${CC} ${CFLAGS} -c $<
diff --git a/xmenu.c b/xmenu.c
index 4d1c223..bc66235 100644 (file)
--- a/xmenu.c
+++ b/xmenu.c
@@ -30,7 +30,7 @@ static void ealloccolor(const char *s, XftColor *color);
 static void initmonitor(void);
 static void initresources(void);
 static void initdc(void);
 static void initmonitor(void);
 static void initresources(void);
 static void initdc(void);
-static void initconfig(void);
+static void initiconsize(void);
 static void initatoms(void);
 
 /* structure builders, and their helper routines */
 static void initatoms(void);
 
 /* structure builders, and their helper routines */
@@ -160,7 +160,7 @@ main(int argc, char *argv[])
        initmonitor();
        initresources();
        initdc();
        initmonitor();
        initresources();
        initdc();
-       initconfig();
+       initiconsize();
        initatoms();
 
        /* set window class */
        initatoms();
 
        /* set window class */
@@ -390,12 +390,10 @@ initdc(void)
        dc.gc = XCreateGC(dpy, rootwin, 0, NULL);
 }
 
        dc.gc = XCreateGC(dpy, rootwin, 0, NULL);
 }
 
-/* calculate configuration values that are not set manually */
+/* calculate icon size */
 static void
 static void
-initconfig(void)
+initiconsize(void)
 {
 {
-       config.screenw = DisplayWidth(dpy, screen);
-       config.screenh = DisplayHeight(dpy, screen);
        config.iconsize = config.height_pixels - config.iconpadding * 2;
 }
 
        config.iconsize = config.height_pixels - config.iconpadding * 2;
 }
 
@@ -741,7 +739,7 @@ setupmenupos(struct Menu *menu)
 
                if (pflag || (config.posy > mon.y && mon.y + mon.h - config.posy >= height))
                        menu->y = config.posy;
 
                if (pflag || (config.posy > mon.y && mon.y + mon.h - config.posy >= height))
                        menu->y = config.posy;
-               else if (config.screenh > height)
+               else if (mon.y + mon.h > height)
                        menu->y = mon.y + mon.h - height;
        } else {                    /* else, calculate in respect to parent menu */
                int parentwidth;
                        menu->y = mon.y + mon.h - height;
        } else {                    /* else, calculate in respect to parent menu */
                int parentwidth;
diff --git a/xmenu.h b/xmenu.h
index 04a4ddf..bf5cb80 100644 (file)
--- a/xmenu.h
+++ b/xmenu.h
@@ -42,7 +42,6 @@ struct Config {
 
        /* the value below is computed by xmenu */
        int iconsize;
 
        /* the value below is computed by xmenu */
        int iconsize;
-       int screenw, screenh;   /* screen width and height */
 };
 
 /* draw context structure */
 };
 
 /* draw context structure */