summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2011-07-16 17:27:53 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2011-07-16 17:27:53 +0000
commit8fd36ebc043b4a59324990af108a7e9a753acf84 (patch)
treed477a8cb15311dfb14f06027ca6661fb16160341
parent274637978ee822b42a77b595e5f7f702cc7e253f (diff)
Add a '-c' option to keep the X cursor visible while calibrating.
-rw-r--r--app/xtsscale/xtsscale.16
-rw-r--r--app/xtsscale/xtsscale.c25
2 files changed, 21 insertions, 10 deletions
diff --git a/app/xtsscale/xtsscale.1 b/app/xtsscale/xtsscale.1
index be9cae39a..1663fc70f 100644
--- a/app/xtsscale/xtsscale.1
+++ b/app/xtsscale/xtsscale.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: xtsscale.1,v 1.12 2011/07/16 17:21:41 matthieu Exp $
+.\" $OpenBSD: xtsscale.1,v 1.13 2011/07/16 17:27:52 matthieu Exp $
.\"
.\" Copyright (c) 2007 Robert Nagy <robert@openbsd.org>
.\" Copyright (c) 2009 Matthieu Herrb <matthieu@herrb.eu>
@@ -33,6 +33,7 @@
.Sh SYNOPSIS
.Nm xtsscale
.Bk -words
+.Op Fl c
.Op Fl D Ar display
.Op Fl d Ar device
.Op Fl o Ar output
@@ -45,6 +46,9 @@ will make the pointer act at the indicated location on the screen.
.Pp
The following options can be used:
.Bl -tag -width Ds
+.It Fl c
+keep the X cursor visible during calibration.
+Useful for indirect absolute devices like tablets.
.It Fl D Ar display
specify the X11 display to use.
.It Fl d Ar device
diff --git a/app/xtsscale/xtsscale.c b/app/xtsscale/xtsscale.c
index 8f825ac6c..1320edd68 100644
--- a/app/xtsscale/xtsscale.c
+++ b/app/xtsscale/xtsscale.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: xtsscale.c,v 1.18 2011/07/16 17:21:41 matthieu Exp $ */
+/* $OpenBSD: xtsscale.c,v 1.19 2011/07/16 17:27:52 matthieu Exp $ */
/*
* Copyright (c) 2007 Robert Nagy <robert@openbsd.org>
- * Copyright (c) 2009 Matthieu Herrb <matthieu@herrb.eu>
+ * Copyright (c) 2009,2011 Matthieu Herrb <matthieu@herrb.eu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -524,7 +524,8 @@ get_xrandr_config(Display *dpy, Window root, char *name,
void __dead
usage(void)
{
- fprintf(stderr, "usage: xtsscale [-D display][-d device][-o output]\n");
+ fprintf(stderr, "usage: xtsscale [-c][-D display]"
+ "[-d device][-o output]\n");
exit(2);
}
@@ -542,15 +543,19 @@ main(int argc, char *argv[], char *env[])
XDeviceInfo *info;
XDevice *device;
long calib_data[4];
+ unsigned long mask;
unsigned char swap;
- int ch;
+ int keep_cursor = 0, ch;
/* Crosshair placement */
int cpx[] = { 0, 0, 1, 1, 1 };
int cpy[] = { 0, 1, 0, 0, 1 };
- while ((ch = getopt(argc, argv, "D:d:o:v")) != -1) {
+ while ((ch = getopt(argc, argv, "cD:d:o:v")) != -1) {
switch (ch) {
+ case 'c':
+ keep_cursor++;
+ break;
case 'D':
display_name = optarg;
break;
@@ -654,13 +659,15 @@ main(int argc, char *argv[], char *env[])
xswa.override_redirect = True;
xswa.background_pixel = BlackPixel(display, screen);
xswa.event_mask = ExposureMask | KeyPressMask;
- xswa.cursor = create_empty_cursor();
-
+ mask = CWOverrideRedirect | CWBackPixel | CWEventMask;
+ if (!keep_cursor) {
+ xswa.cursor = create_empty_cursor();
+ mask |= CWCursor;
+ }
win = XCreateWindow(display, RootWindow(display, screen),
xpos, ypos, width, height, 0,
CopyFromParent, InputOutput, CopyFromParent,
- CWOverrideRedirect | CWBackPixel | CWEventMask |
- CWCursor, &xswa);
+ mask, &xswa);
render_init();
XMapWindow(display, win);
XGrabKeyboard(display, win, False, GrabModeAsync, GrabModeAsync,