Make it work
This commit is contained in:
+8
-8
@@ -17,18 +17,18 @@ void cleanup(void) {
|
||||
|
||||
// Keybind function to setup a key grab if the keycode is clicked along with the
|
||||
// MOD key
|
||||
void add_keybind(int key) {
|
||||
xcb_grab_key(conn, 0, scr->root, MOD, key, XCB_GRAB_MODE_ASYNC,
|
||||
void add_keybind(int key, int mod) {
|
||||
xcb_grab_key(conn, 0, scr->root, mod ? MOD : 0, key, XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_ASYNC);
|
||||
}
|
||||
|
||||
// Mousebind function to setup a mouse button grab if the button is clicked
|
||||
// along with the MOD key
|
||||
void add_mousebind(int button) {
|
||||
void add_mousebind(int button, int mod) {
|
||||
xcb_grab_button(conn, 0, scr->root,
|
||||
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,
|
||||
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, scr->root, XCB_NONE,
|
||||
button, MOD);
|
||||
button, mod ? MOD : 0);
|
||||
}
|
||||
|
||||
// Deploy function to initialize the X connection, set up event masks, and
|
||||
@@ -271,6 +271,8 @@ void ungrab_pointer(void) {
|
||||
Event wait_for_event(void) {
|
||||
Event ret = {0};
|
||||
|
||||
xcb_flush(conn);
|
||||
|
||||
xcb_generic_event_t *ev;
|
||||
ev = xcb_wait_for_event(conn);
|
||||
|
||||
@@ -318,14 +320,13 @@ Event wait_for_event(void) {
|
||||
|
||||
case XCB_BUTTON_PRESS: {
|
||||
xcb_button_press_event_t *e = (xcb_button_press_event_t *)ev;
|
||||
if (!e->child)
|
||||
break;
|
||||
ret.type = 6;
|
||||
ret.window = e->child;
|
||||
ret.is_root = e->child == scr->root;
|
||||
ret.x = e->event_x;
|
||||
ret.y = e->event_y;
|
||||
ret.btn = e->detail;
|
||||
ret.state = (e->state & MOD) != 0;
|
||||
} break;
|
||||
|
||||
case XCB_MOTION_NOTIFY: {
|
||||
@@ -350,7 +351,7 @@ Event wait_for_event(void) {
|
||||
ret.type = 9;
|
||||
ret.window = e->child;
|
||||
ret.btn = e->detail;
|
||||
ret.state = e->state;
|
||||
ret.state = (e->state & MOD) != 0;
|
||||
} break;
|
||||
|
||||
case XCB_KEY_RELEASE: {
|
||||
@@ -388,7 +389,6 @@ Event wait_for_event(void) {
|
||||
} break;
|
||||
}
|
||||
|
||||
xcb_flush(conn);
|
||||
free(ev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user