--- /dev/null
+#define curs_invisible_width 8
+#define curs_invisible_height 8
+
+static unsigned char curs_invisible_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+#define curs_windows_width 11
+#define curs_windows_height 19
+
+static unsigned char curs_windows_bits[] = {
+ 0xfe, 0x07, 0xfc, 0x07, 0xfa, 0x07, 0xf6, 0x07, 0xee, 0x07, 0xde, 0x07,
+ 0xbe, 0x07, 0x7e, 0x07, 0xfe, 0x06, 0xfe, 0x05, 0x3e, 0x00, 0xb6, 0x07,
+ 0x6a, 0x07, 0x6c, 0x07, 0xde, 0x06, 0xdf, 0x06, 0xbf, 0x05, 0xbf, 0x05,
+ 0x7f, 0x06 };
+
+#define mask_windows_width 11
+#define mask_windows_height 19
+
+static unsigned char mask_windows_bits[] = {
+ 0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00,
+ 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x07, 0x7f, 0x00,
+ 0xf7, 0x00, 0xf3, 0x00, 0xe1, 0x01, 0xe0, 0x01, 0xc0, 0x03, 0xc0, 0x03,
+ 0x80, 0x01 };
#include <security/pam_appl.h>
+#include "cursors.h"
+
static char passwd[256];
/*
int main(int argc, char *argv[])
{
- char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
char buf[32];
char *username;
int num, screen;
bool tiling = false;
char xpm_image_path[256];
char color[7] = "ffffff"; // white
- Cursor invisible;
+
+ unsigned char *curs = NULL;
+ unsigned char *mask = NULL;
+ unsigned int curs_w, curs_h;
+
+ Cursor cursor;
Display *dpy;
KeySym ksym;
- Pixmap pmap;
+ Pixmap px_curs;
+ Pixmap px_mask;
Window root, w;
- XColor black, dummy;
+ XColor black, white, dummy;
XEvent ev;
XSetWindowAttributes wa;
{"image", required_argument, NULL, 'i'},
{"color", required_argument, NULL, 'c'},
{"tiling", no_argument, NULL, 't'},
+ {"pointer", required_argument, NULL , 'p'},
{NULL, no_argument, NULL, 0}
};
+ curs = curs_invisible_bits;
+ mask = curs_invisible_bits;
+ curs_w = curs_invisible_width;
+ curs_h = curs_invisible_height;
- while ((opt = getopt_long(argc, argv, "vnbdi:c:t", long_options, &optind)) != -1) {
+ while ((opt = getopt_long(argc, argv, "vnbdi:c:tp:", long_options, &optind)) != -1) {
switch (opt) {
case 'v':
errx(0, "i3lock-"VERSION", © 2009 Michael Stapelberg\n"
case 't':
tiling = true;
break;
+ case 'p':
+ if (!strcmp(optarg, "default")) {
+ curs = NULL;
+ break;
+ }
+ if (!strcmp(optarg, "win")) {
+ curs = curs_windows_bits;
+ mask = mask_windows_bits;
+ curs_w = curs_windows_width;
+ curs_h = curs_windows_height;
+ break;
+ }
+ break;
default:
- errx(1, "i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color] [-t]\n");
+ errx(1, "i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color] [-t] [-p win|default]\n");
}
}
0, DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixel, &wa);
XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "black", &black, &dummy);
- pmap = XCreateBitmapFromData(dpy, w, curs, 8, 8);
- invisible = XCreatePixmapCursor(dpy, pmap, pmap, &black, &black, 0, 0);
- XDefineCursor(dpy, w, invisible);
+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "white", &white, &dummy);
+ if (curs != NULL) {
+ px_curs = XCreateBitmapFromData(dpy, w, (char*) curs, curs_w, curs_h);
+ px_mask = XCreateBitmapFromData(dpy, w, (char*) mask, curs_w, curs_h);
+ cursor = XCreatePixmapCursor(dpy, px_curs, px_mask, &white, &black, 0, 0);
+ XDefineCursor(dpy, w, cursor);
+ } else {
+ px_curs = 0;
+ px_mask = 0;
+ cursor = 0;
+ }
XMapRaised(dpy, w);
if (xpm_image && file_exists(xpm_image_path)) {
for(len = 1000; len; len--) {
if(XGrabPointer(dpy, root, False, ButtonPressMask | ButtonReleaseMask,
- GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
+ GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime) == GrabSuccess)
break;
usleep(1000);
}
break;
}
}
+
XUngrabPointer(dpy, CurrentTime);
- XFreePixmap(dpy, pmap);
+ if (px_curs != 0) {
+ XFreePixmap(dpy, px_curs);
+ XFreePixmap(dpy, px_mask);
+ }
XDestroyWindow(dpy, w);
XCloseDisplay(dpy);
return 0;