[Pkg-wmaker-commits] [wmbattery] 222/241: wmbattery: Expand -g option to allow positions relative to right or bottom.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:38:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbattery.

commit c685f1e499d29bc52f76ccb3ade4a30f2d843226
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Wed May 13 23:38:52 2015 -0500

    wmbattery: Expand -g option to allow positions relative to right or bottom.
    
    Use '-' instead of '+', e.g., `wmbattery -g -0+0` will place wmbattery in
    the upper right hand corner of the screen.
    
    Thanks to Christoph Fritz for the feature request.
---
 wmbattery.1 |  2 +-
 wmbattery.c | 19 ++++---------------
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/wmbattery.1 b/wmbattery.1
index 605dc3b..7168cc2 100644
--- a/wmbattery.1
+++ b/wmbattery.1
@@ -70,7 +70,7 @@ Pause this many seconds between updates.
 .B \-d display
 Use the designated X display.
 .TP
-.B \-g +x+y
+.B \-g {+-}x{+-}y
 Specify geometry. This specifies position, not size.
 .TP
 .B \-b battnum
diff --git a/wmbattery.c b/wmbattery.c
index a7b752f..c3a8ca5 100644
--- a/wmbattery.c
+++ b/wmbattery.c
@@ -55,7 +55,7 @@ int screen;
 XpmIcon icon;
 Display *display;
 GC NormalGC;
-int pos[2] = {0, 0};
+char *user_geom = NULL;
 
 #ifdef HAVE__DEV_APM
 #define APM_STATUS_FILE "/dev/apm"
@@ -376,7 +376,6 @@ char *parse_commandline(int argc, char *argv[])
 {
 	int c = 0;
 	char *ret = NULL;
-	char *s;
 
 	while (c != -1) {
 		c = getopt(argc, argv, "hd:g:if:b:w:c:l:es:a:x:v");
@@ -385,7 +384,7 @@ char *parse_commandline(int argc, char *argv[])
 			printf("Usage: wmbattery [options]\n");
 			printf("\t-d <display>\tselects target display\n");
 			printf("\t-h\t\tdisplay this help\n");
-			printf("\t-g +x+y\t\tposition of the window\n");
+			printf("\t-g {+-}x{+-}y\tposition of the window\n");
 			printf("\t-i start\n");
 			printf("\t-b num\t\tnumber of battery to display\n");
 			printf("\t-w secs\t\tseconds between updates\n");
@@ -402,15 +401,7 @@ char *parse_commandline(int argc, char *argv[])
 			ret = strdup(optarg);
 			break;
 		case 'g':
-			s = strtok(optarg, "+");
-			if (s) {
-				pos[0] = atoi(s);
-				s = strtok(NULL, "+");
-				if (s)
-					pos[1] = atoi(s);
-				else
-					pos[0] = 0;
-			}
+			user_geom = strdup(optarg);
 			break;
 		case 'i':
 			initial_state = IconicState;
@@ -474,14 +465,12 @@ void make_window(char *display_name, int argc, char *argv[])
 	sizehints.flags = USSize | USPosition;
 	sizehints.x = 0;
 	sizehints.y = 0;
-	XWMGeometry(display, screen, "", NULL, borderwidth,
+	XWMGeometry(display, screen, user_geom, NULL, borderwidth,
 		    &sizehints, &sizehints.x, &sizehints.y,
 		    &sizehints.width, &sizehints.height, &dummy);
 
 	sizehints.width = 64;
 	sizehints.height = 64;
-	sizehints.x = pos[0];
-	sizehints.y = pos[1];
 	back_pix = WhitePixel(display, screen);
 	fore_pix = BlackPixel(display, screen);
 	win = XCreateSimpleWindow(display, root, sizehints.x, sizehints.y,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git



More information about the Pkg-wmaker-commits mailing list