diff --git a/abs-c.c b/abs-c.c index dc3cfc9..4fa876c 100644 --- a/abs-c.c +++ b/abs-c.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -362,17 +363,15 @@ int main(int argc, char *argv[]) { mlockall(MCL_CURRENT | MCL_FUTURE); struct pollfd pfd = {.fd=fd, .events=POLLIN}; - struct input_event ev_buf[64]; - - int x = 0, y = 0; int x_old = -1, y_old = -1; - bool active; + bool active = false; bool grabbed = false; if (config.enable_tosu == true) { tosu_init(); + active = tosu_get_absolute_state(); } else { printf("Tosu integration is disabled.\n"); @@ -397,7 +396,23 @@ int main(int argc, char *argv[]) { set_grab(fd, &grabbed, active); if (active == true) { - if (poll(&pfd, 1, -1) <= 0) + int poll_rc = poll(&pfd, 1, -1); + if (poll_rc == -1) { + if (errno == EINTR) { + if (stop) break; + continue; + } + perror("poll"); + break; + } + if (poll_rc == 0) + continue; + + if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { + fprintf(stderr, "poll: fatal revents=0x%x\n", pfd.revents); + break; + } + if (!(pfd.revents & POLLIN)) continue; struct input_event ev; diff --git a/tosuhandler.c b/tosuhandler.c index 09f4372..add1e59 100644 --- a/tosuhandler.c +++ b/tosuhandler.c @@ -11,7 +11,7 @@ #include // ---------------- CONFIG ---------------- -#define TOSU_URL "http://localhost:24050/json" +#define TOSU_URL "http://127.0.0.1:24050/json" #define POLL_INTERVAL_MS 500 // ---------------------------------------- @@ -153,6 +153,7 @@ static void *poll_thread_func(void *arg) { curl_easy_setopt(easy, CURLOPT_URL, TOSU_URL); curl_easy_setopt(easy, CURLOPT_TIMEOUT_MS, 500); curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(easy, CURLOPT_NOPROXY, "*"); curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, curl_write_cb); while (running) {