commit 674bb7c0db701a64760627861ca2898aedd037d0
parent d1214b9a2a52eae0fe748d79962d0df8e2701e8b
Author: Bastien Dejean <nihilhill@gmail.com>
Date: Thu, 7 Apr 2016 18:21:22 +0200
Remove support for pointer motions
Diffstat:
5 files changed, 8 insertions(+), 141 deletions(-)
diff --git a/doc/sxhkd.1 b/doc/sxhkd.1
@@ -2,12 +2,12 @@
.\" Title: sxhkd
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 03/15/2016
+.\" Date: 04/07/2016
.\" Manual: Sxhkd Manual
-.\" Source: Sxhkd 0.5.6
+.\" Source: Sxhkd 0.5.6-1-gd1214b9
.\" Language: English
.\"
-.TH "SXHKD" "1" "03/15/2016" "Sxhkd 0\&.5\&.6" "Sxhkd Manual"
+.TH "SXHKD" "1" "04/07/2016" "Sxhkd 0\&.5\&.6\-1\-gd1214b9" "Sxhkd Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -69,25 +69,10 @@ Read the main configuration from the given file\&.
Redirect the commands output to the given file\&.
.RE
.PP
-\fB\-o\fR \fIMOTION_SOCKET\fR
-.RS 4
-Write motion messages to the given SOCKET\&.
-.RE
-.PP
-\fB\-g\fR \fIMOTION_MSG_TPL\fR
-.RS 4
-Motion messages template\&.
-.RE
-.PP
\fB\-s\fR \fISTATUS_FIFO\fR
.RS 4
Output status information to the given FIFO\&.
.RE
-.PP
-\fB\-f\fR \fIFREQUENCY\fR
-.RS 4
-Set the maximum frequency for motion events\&.
-.RE
.SH "BEHAVIOR"
.sp
\fBsxhkd\fR is a daemon that listens to keyboard events and execute commands\&.
@@ -176,7 +161,7 @@ If \fB@\fR is added at the beginning of the keysym, the command will be run on k
.sp
If \fB~\fR is added at the beginning of the keysym, the captured event will be replayed for the other clients\&.
.sp
-Mouse hotkeys can be defined by using one of the following special keysym names: \fIbutton1\fR, \fIbutton2\fR, \fIbutton3\fR, \&..., \fIbutton24\fR\&.
+Pointer hotkeys can be defined by using one of the following special keysym names: \fIbutton1\fR, \fIbutton2\fR, \fIbutton3\fR, \&..., \fIbutton24\fR\&.
.sp
The hotkey and the command may contain sequences of the form \fI{STRING_1,\&...,STRING_N}\fR\&.
.sp
@@ -210,15 +195,6 @@ super + alt + {0\-9}
super + {alt,ctrl,alt + ctrl} + XF86Eject
sudo systemctl {suspend,reboot,poweroff}
-~button1
- bspc pointer \-g focus
-
-super + button{1\-3}
- ; bspc pointer \-g {move,resize_side,resize_corner}
-
-super + @button{1\-3}
- bspc pointer \-u
-
super + {_,shift + }{h,j,k,l}
bspc node \-{f,s} {west,south,north,east}
@@ -228,9 +204,6 @@ super + {_,shift + }{h,j,k,l}
super + o ; {e,w,m}
{gvim,firefox,thunderbird}
-super + m : {h,j,k,l}
- xdo move {\-x \-5,\-y +5,\-y \-5,\-x +5}
-
super + alt + control + {h,j,k,l} ; {0\-9}
bspc node @{west,south,north,east} \-r 0\&.{0\-9}
diff --git a/doc/sxhkd.1.txt b/doc/sxhkd.1.txt
@@ -42,17 +42,9 @@ Options
*-r* _REDIR_FILE_::
Redirect the commands output to the given file.
-*-o* _MOTION_SOCKET_::
- Write motion messages to the given SOCKET.
-
-*-g* _MOTION_MSG_TPL_::
- Motion messages template.
-
*-s* _STATUS_FIFO_::
Output status information to the given FIFO.
-*-f* _FREQUENCY_::
- Set the maximum frequency for motion events.
Behavior
--------
@@ -110,7 +102,7 @@ If *@* is added at the beginning of the keysym, the command will be run on key r
If *~* is added at the beginning of the keysym, the captured event will be replayed for the other clients.
-Mouse hotkeys can be defined by using one of the following special keysym names: _button1_, _button2_, _button3_, …, _button24_.
+Pointer hotkeys can be defined by using one of the following special keysym names: _button1_, _button2_, _button3_, …, _button24_.
The hotkey and the command may contain sequences of the form '{STRING_1,…,STRING_N}'.
@@ -144,15 +136,6 @@ super + alt + {0-9}
super + {alt,ctrl,alt + ctrl} + XF86Eject
sudo systemctl {suspend,reboot,poweroff}
-~button1
- bspc pointer -g focus
-
-super + button{1-3}
- ; bspc pointer -g {move,resize_side,resize_corner}
-
-super + @button{1-3}
- bspc pointer -u
-
super + {_,shift + }{h,j,k,l}
bspc node -{f,s} {west,south,north,east}
@@ -162,9 +145,6 @@ super + {_,shift + }{h,j,k,l}
super + o ; {e,w,m}
{gvim,firefox,thunderbird}
-super + m : {h,j,k,l}
- xdo move {-x -5,-y +5,-y -5,-x +5}
-
super + alt + control + {h,j,k,l} ; {0-9}
bspc node @{west,south,north,east} -r 0.{0-9}
diff --git a/grab.c b/grab.c
@@ -79,7 +79,7 @@ void grab_key_button_checked(xcb_keycode_t keycode, xcb_button_t button, uint16_
if (button == XCB_NONE)
err = xcb_request_check(dpy, xcb_grab_key_checked(dpy, true, root, modfield, keycode, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC));
else
- err = xcb_request_check(dpy, xcb_grab_button_checked(dpy, true, root, XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_MOTION, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, button, modfield));
+ err = xcb_request_check(dpy, xcb_grab_button_checked(dpy, true, root, XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, button, modfield));
unsigned int value = (button == XCB_NONE ? keycode : button);
char *type = (button == XCB_NONE ? "key" : "button");
if (err != NULL) {
diff --git a/sxhkd.c b/sxhkd.c
@@ -29,7 +29,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
-#include <sys/socket.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
@@ -40,28 +39,21 @@ int main(int argc, char *argv[])
{
char opt;
char *fifo_path = NULL;
- char *socket_path = NULL;
status_fifo = NULL;
config_path = NULL;
mapping_count = 0;
timeout = TIMEOUT;
grabbed = false;
- sock_address.sun_family = AF_UNIX;
- sock_address.sun_path[0] = 0;
- snprintf(motion_msg_tpl, sizeof(motion_msg_tpl), "%s", MOTION_MSG_TPL);
- unsigned int max_freq = 0;
- motion_interval = 0;
- last_motion_time = 0;
redir_fd = -1;
- while ((opt = getopt(argc, argv, "vhm:t:c:r:s:f:o:g:")) != (char)-1) {
+ while ((opt = getopt(argc, argv, "hvm:t:c:r:s:")) != (char)-1) {
switch (opt) {
case 'v':
printf("%s\n", VERSION);
exit(EXIT_SUCCESS);
break;
case 'h':
- printf("sxhkd [-h|-v|-m COUNT|-t TIMEOUT|-c CONFIG_FILE|-r REDIR_FILE|-s STATUS_FIFO|-o MOTION_SOCKET|-g MOTION_MSG_TPL] [EXTRA_CONFIG ...]\n");
+ printf("sxhkd [-h|-v|-m COUNT|-t TIMEOUT|-c CONFIG_FILE|-r REDIR_FILE|-s STATUS_FIFO] [EXTRA_CONFIG ...]\n");
exit(EXIT_SUCCESS);
break;
case 'm':
@@ -82,16 +74,6 @@ int main(int argc, char *argv[])
case 's':
fifo_path = optarg;
break;
- case 'o':
- socket_path = optarg;
- break;
- case 'g':
- snprintf(motion_msg_tpl, sizeof(motion_msg_tpl), "%s", optarg);
- break;
- case 'f':
- if (sscanf(optarg, "%u", &max_freq) != 1)
- warn("Can't parse maximum pointer frequency.\n");
- break;
}
}
@@ -108,23 +90,6 @@ int main(int argc, char *argv[])
snprintf(config_file, sizeof(config_file), "%s", config_path);
}
- if (socket_path == NULL) {
- socket_path = getenv(SOCKET_ENV);
- }
-
- if (socket_path == NULL) {
- char *host = NULL;
- int dn = 0, sn = 0;
- if (xcb_parse_display(NULL, &host, &dn, &sn) != 0) {
- snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), SOCKET_PATH_TPL, host, dn, sn);
- } else {
- warn("Failed to set motion socket address.");
- }
- free(host);
- } else {
- snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", socket_path);
- }
-
if (fifo_path != NULL) {
int fifo_fd = open(fifo_path, O_RDWR | O_NONBLOCK);
if (fifo_fd != -1)
@@ -133,9 +98,6 @@ int main(int argc, char *argv[])
warn("Couldn't open status fifo.\n");
}
- if (max_freq != 0)
- motion_interval = 1000.0 / max_freq;
-
signal(SIGINT, hold);
signal(SIGHUP, hold);
signal(SIGTERM, hold);
@@ -176,9 +138,6 @@ int main(int argc, char *argv[])
case XCB_BUTTON_RELEASE:
key_button_event(evt, event_type);
break;
- case XCB_MOTION_NOTIFY:
- motion_notify(evt);
- break;
case XCB_MAPPING_NOTIFY:
mapping_notify(evt);
break;
@@ -264,42 +223,6 @@ void key_button_event(xcb_generic_event_t *evt, uint8_t event_type)
xcb_flush(dpy);
}
-void motion_notify(xcb_generic_event_t *evt)
-{
- xcb_motion_notify_event_t *e = (xcb_motion_notify_event_t *) evt;
- PRINTF("motion notify %X %X %u %i %i\n", e->child, e->detail, e->state, e->root_x, e->root_y);
- if (motion_interval > 0 && (e->time - last_motion_time) < motion_interval)
- return;
- last_motion_time = e->time;
- char msg[MAXLEN];
- int fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd == -1) {
- return;
- }
- if (connect(fd, (struct sockaddr *) &sock_address, sizeof(sock_address)) == -1) {
- close(fd);
- return;
- }
- int len = sizeof(msg), i = 0;
- for (int j = 0, c = motion_msg_tpl[j]; c && i < len; j++, c = motion_msg_tpl[j]) {
- if (c == ' ') {
- msg[i++] = 0;
- } else if (c == 'X') {
- i += snprintf(msg+i, len-i, "%i", e->root_x);
- } else if (c == 'Y') {
- i += snprintf(msg+i, len-i, "%i", e->root_y);
- } else {
- msg[i++] = c;
- }
- }
- if (i >= len) {
- i--;
- }
- msg[i] = 0;
- send(fd, msg, i+1, 0);
- close(fd);
-}
-
void mapping_notify(xcb_generic_event_t *evt)
{
if (!mapping_count)
diff --git a/sxhkd.h b/sxhkd.h
@@ -28,7 +28,6 @@
#include <xcb/xcb_keysyms.h>
#include <stdio.h>
#include <stdbool.h>
-#include <sys/un.h>
#include "types.h"
#include "helpers.h"
@@ -36,9 +35,6 @@
#define SXHKD_SHELL_ENV "SXHKD_SHELL"
#define SHELL_ENV "SHELL"
#define CONFIG_PATH "sxhkd/sxhkdrc"
-#define SOCKET_ENV "BSPWM_SOCKET"
-#define SOCKET_PATH_TPL "/tmp/bspwm%s_%i_%i-socket"
-#define MOTION_MSG_TPL "pointer -t X Y"
#define HOTKEY_PREFIX 'H'
#define COMMAND_PREFIX 'C'
#define TIMEOUT_PREFIX 'T'
@@ -55,13 +51,9 @@ char **extra_confs;
int num_extra_confs;
int redir_fd;
FILE *status_fifo;
-struct sockaddr_un sock_address;
-char motion_msg_tpl[MAXLEN];
char progress[3 * MAXLEN];
int mapping_count;
int timeout;
-double motion_interval;
-xcb_timestamp_t last_motion_time;
hotkey_t *hotkeys_head, *hotkeys_tail;
bool running, grabbed, toggle_grab, reload, bell, chained, locked;
@@ -72,7 +64,6 @@ uint16_t caps_lock;
uint16_t scroll_lock;
void key_button_event(xcb_generic_event_t *evt, uint8_t event_type);
-void motion_notify(xcb_generic_event_t *evt);
void mapping_notify(xcb_generic_event_t *evt);
void setup(void);
void cleanup(void);