Some screensavers in the Win / Mac world let you set hot corners and cold
corners, which respectively immediately activate the screen saver and
inhibit it.
I'm working on a program that lets you do this with X11. It almost
works. The problem is that it only notices if the corner belongs to the root
window -- if another window is covering the root, my program doesn't get
notified of the PointerMotion event.
Since it's so tiny, i've attached it. I was wondering if anyone could take a
quick look. I imagine it would be a simple fix; but i've never programmed in
X before, and i'm sort of figuring it out as i go along by ripping apart
other programs.
Thanks
/* By Mike Schiraldi [EMAIL PROTECTED] */
/* Compile with -Wall -L/usr/X11R6/lib -lX11 */
#include stdlib.h
#include stdio.h
#include unistd.h
#include string.h
#include X11/Xlib.h
#include X11/Xutil.h
int
main(int argc, char **argv)
{
Display *display;
Screen *screen;
Window root;
int height;
int width;
int i;
char * commands[4] = {NULL, NULL, NULL, NULL};
if (argc 2) {
usage:
fprintf (stderr,
Specify commands for, respectively, the northwest, northeast, southwest, and
southeast corners of the screen. Use - for no command. For example:
%s - 'script1.sh' 'script2.sh' -
will run script1.sh when the pointer is in the northeast corner and script2.sh
when it's in the southwest.
Written by Mike Schiraldi [EMAIL PROTECTED]\n, argv[0]);
exit(1);
}
if (strcmp (argv[1], -h) == 0) goto usage;
if (strcmp (argv[1], -help) == 0) goto usage;
if (strcmp (argv[1], --help) == 0) goto usage;
if (strcmp (argv[1], -v) == 0) goto usage;
if (strcmp (argv[1], -version) == 0) goto usage;
if (strcmp (argv[1], --version) == 0) goto usage;
for (i = 1; i = 4 i argc; i++) {
if (strcmp (argv[i], -) != 0)
commands[i - 1] = argv[i];
}
if ((display = XOpenDisplay(NULL)) == NULL) {
fprintf(stderr, %s: can't open %s\en, argv[0], XDisplayName(NULL));
exit(1);
}
root = DefaultRootWindow (display);
screen = XDefaultScreenOfDisplay(display);
height = XHeightOfScreen(screen) - 1;
width = XWidthOfScreen(screen) - 1;
XSelectInput (display, root, PointerMotionMask);
while (1) {
int x, y, rv;
char * command;
Window junk1, junk2;
int junk3, junk4;
unsigned int junk5;
XEvent junk6;
XNextEvent(display, junk6);
fprintf (stderr, Pointer motion!\n);
rv = XQueryPointer (display, root, junk1, junk2, x, y,
junk3, junk4, junk5);
if (!rv) {
fprintf (stderr, XQueryPointer failed. Send me an email about it.\n);
}
if (x == 0 y == 0) {
command = commands[0];
} else if (x == width y == 0) {
command = commands[1];
} else if (x == 0 y == height) {
command = commands[2];
} else if (x == width y == height) {
command = commands[3];
} else {
command = NULL;
}
if (command) {
fprintf (stderr, Running %s\n, command);
}
}
exit(1);
}