Skip to content

Commit

Permalink
0.3.1 "rename project for X11"
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Dec 27, 2018
1 parent e8803cd commit c1d3bca
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Executable
hhpc
xhhpc

# Object files
*.o
Expand Down
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ CFLAGS ?= $(CFLAGS_COMMON)

CC ?= cc $(CFLAGS)

EXECUTABLE := hhpc
OBJECTS := hhpc.o
EXECUTABLE := xhhpc
OBJECTS := xhhpc.o

PREFIX = /usr/local
INSTALL = install

all: release

Expand All @@ -79,10 +82,10 @@ $(EXECUTABLE): $(OBJECTS)
$(CC) -c $< $(shell pkg-config --cflags x11) $(CFLAGS)

install:
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin
@cp -f hhpc ${DESTDIR}${PREFIX}/bin
@chmod 755 ${DESTDIR}${PREFIX}/bin/hhpc
$(INSTALL) -d $(PREFIX)/bin
$(INSTALL) -m 0755 $(EXECUTABLE) $(PREFIX)/bin
$(INSTALL) -d $(PREFIX)/share/man/man1
$(INSTALL) -m 0644 $(EXECUTABLE).1 $(PREFIX)/share/man/man1

clean:
rm -f $(EXECUTABLE) $(OBJECTS)
Expand Down
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
hhpc
====
xhhpc
=====

hhpc(1) is a utility that hides the mouse pointer in X11. The method it
xhhpc(1) is a utility that hides the mouse pointer in X11. The method it
uses to hide the cursor was taken from the hhp program found in
xmonad-utils. I found that after a while for some reason the original
hhp stopped hiding my mouse pointer, so I recreated it in C to make it
easier to debug. Should `hhpc` not work out for you, `unclutter` is a
good alternative. I created `hhpc` because `unclutter` doesn't seem to
easier to debug. Should `xhhpc` not work out for you, `unclutter` is a
good alternative. I created `xhhpc` because `unclutter` doesn't seem to
interoperate properly with hardware accelerated surfaces like those of
video players using VAAPI.

Expand All @@ -22,7 +22,7 @@ Running
-------

```sh
./hhpc <options>
./xhhpc <options>

-i <seconds>: amount of time to wait before hiding the cursor
-v: be verbose
Expand Down Expand Up @@ -50,12 +50,6 @@ versions of gcc as well, though I haven't tried. So if you have an
ancient compiler and the build fails, just edit the Makefile and try
leaving out the `-std=c99` flag.

Installing
---------

hhpc(1) is available in the AUR:
[hhpc-git](https://aur.archlinux.org/packages/hhpc-git/).

Building
--------

Expand All @@ -69,11 +63,11 @@ Then clone and build it.

```sh
$ git clone ...
$ cd hhpc
$ cd xhhpc
$ make
```

If everything goes well, there should appear a hhpc executable in the
If everything goes well, there should appear a xhhpc executable in the
current directory.

Todo
Expand Down
25 changes: 25 additions & 0 deletions xhhpc.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.TH XHHPC 1 "27 Dec 2018" "0.3.1" "User Manual"
.SH NAME
xhhpc \- hide the mouse pointer in X
.SH DESCRIPTION
\fBxhhpc\fP is a small program to hide the mouse pointer within X sessions.
.SH SYNOPSIS
.B xhhpc
.RI [ options ]
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-i
number of seconds to wait before hiding the pointer
.TP
.B \-v
turn on verbose mode.
.SH AUTHORS
Copyright (c) 2013 Nicolas Hillegeer <nicolas at hillegeer dot com>

All rights reserved.
.SH SEE ALSO
xorg (1)
38 changes: 19 additions & 19 deletions hhpc.c → xhhpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ static int setupSignals() {
sigemptyset(&act.sa_mask);

if (sigaction(SIGTERM, &act, NULL) == -1) {
perror("hhpc: could not register SIGTERM");
perror("xhhpc: could not register SIGTERM");
return 0;
}

if (sigaction(SIGHUP, &act, NULL) == -1) {
perror("hhpc: could not register SIGHUP");
perror("xhhpc: could not register SIGHUP");
return 0;
}

if (sigaction(SIGINT, &act, NULL) == -1) {
perror("hhpc: could not register SIGINT");
perror("xhhpc: could not register SIGINT");
return 0;
}

if (sigaction(SIGQUIT, &act, NULL) == -1) {
perror("hhpc: could not register SIGQUIT");
perror("xhhpc: could not register SIGQUIT");
return 0;
}

Expand Down Expand Up @@ -127,29 +127,29 @@ static int grabPointer(Display *dpy, Window win, Cursor cursor, unsigned int mas

switch (rc) {
case GrabSuccess:
if (gVerbose) fprintf(stderr, "hhpc: succesfully grabbed mouse pointer\n");
if (gVerbose) fprintf(stderr, "xhhpc: succesfully grabbed mouse pointer\n");
return 1;

case AlreadyGrabbed:
if (gVerbose) fprintf(stderr, "hhpc: XGrabPointer: already grabbed mouse pointer, retrying with delay\n");
if (gVerbose) fprintf(stderr, "xhhpc: XGrabPointer: already grabbed mouse pointer, retrying with delay\n");
delay(0, 500);
break;

case GrabFrozen:
if (gVerbose) fprintf(stderr, "hhpc: XGrabPointer: grab was frozen, retrying after delay\n");
if (gVerbose) fprintf(stderr, "xhhpc: XGrabPointer: grab was frozen, retrying after delay\n");
delay(0, 500);
break;

case GrabNotViewable:
fprintf(stderr, "hhpc: XGrabPointer: grab was not viewable, exiting\n");
fprintf(stderr, "xhhpc: XGrabPointer: grab was not viewable, exiting\n");
return 0;

case GrabInvalidTime:
fprintf(stderr, "hhpc: XGrabPointer: invalid time, exiting\n");
fprintf(stderr, "xhhpc: XGrabPointer: invalid time, exiting\n");
return 0;

default:
fprintf(stderr, "hhpc: XGrabPointer: could not grab mouse pointer (%d), exiting\n", rc);
fprintf(stderr, "xhhpc: XGrabPointer: could not grab mouse pointer (%d), exiting\n", rc);
return 0;
}
}
Expand All @@ -171,7 +171,7 @@ static void waitForMotion(Display *dpy, Window win, int timeout) {
working = 1;

if (!setupSignals()) {
fprintf(stderr, "hhpc: could not register signals, program will not exit cleanly\n");
fprintf(stderr, "xhhpc: could not register signals, program will not exit cleanly\n");
}

while (working && grabPointer(dpy, win, emptyCursor, mask)) {
Expand All @@ -196,7 +196,7 @@ static void waitForMotion(Display *dpy, Window win, int timeout) {
ready = select(xfd + 1, &fds, NULL, NULL, NULL);

if (ready > 0) {
if (gVerbose) fprintf(stderr, "hhpc: event received, ungrabbing and sleeping\n");
if (gVerbose) fprintf(stderr, "xhhpc: event received, ungrabbing and sleeping\n");

/* event received, replay event, release mouse, drain, sleep, regrab */
XAllowEvents(dpy, ReplayPointer, CurrentTime);
Expand All @@ -206,16 +206,16 @@ static void waitForMotion(Display *dpy, Window win, int timeout) {
while (XPending(dpy)) {
XMaskEvent(dpy, mask, &event);

if (gVerbose) fprintf(stderr, "hhpc: draining event\n");
if (gVerbose) fprintf(stderr, "xhhpc: draining event\n");
}

delay(timeout, 0);
}
else if (ready == 0) {
if (gVerbose) fprintf(stderr, "hhpc: timeout\n");
if (gVerbose) fprintf(stderr, "xhhpc: timeout\n");
}
else {
if (working) perror("hhpc: error while select()'ing");
if (working) perror("xhhpc: error while select()'ing");
}
}

Expand All @@ -238,7 +238,7 @@ static int parseOptions(int argc, char *argv[]) {
}

static void usage() {
printf("hhpc [-i] seconds [-v]\n");
printf("xhhpc [-i] seconds [-v]\n");
}

int main(int argc, char *argv[]) {
Expand All @@ -253,19 +253,19 @@ int main(int argc, char *argv[]) {
Display *dpy = XOpenDisplay(NULL);
if (!dpy) {
if (!displayName || strlen(displayName) == 0) {
fprintf(stderr, "hhpc: could not open display, DISPLAY environment variable not set, are you sure the X server is started?\n");
fprintf(stderr, "xhhpc: could not open display, DISPLAY environment variable not set, are you sure the X server is started?\n");
return 2;
}
else {
fprintf(stderr, "hhpc: could not open display %s, check if your X server is running and/or the DISPLAY environment value is correct\n", displayName);
fprintf(stderr, "xhhpc: could not open display %s, check if your X server is running and/or the DISPLAY environment value is correct\n", displayName);
return 1;
}
}

int scr = DefaultScreen(dpy);
Window rootwin = RootWindow(dpy, scr);

if (gVerbose) fprintf(stderr, "hhpc: got root window, screen = %d, display = %p, rootwin = %d\n", scr, (void *) dpy, (int) rootwin);
if (gVerbose) fprintf(stderr, "xhhpc: got root window, screen = %d, display = %p, rootwin = %d\n", scr, (void *) dpy, (int) rootwin);

waitForMotion(dpy, rootwin, gIdleTimeout);

Expand Down

0 comments on commit c1d3bca

Please sign in to comment.