Mousegrabber: Correctly handle press/release events
When you run a mousegrabber, the C code calls this callback when the pointer is moved or when a button is pressed/released. However, the button state is totally bogus on press/release events, always claiming that the button that was pressed/released is the only button that is pressed (even for release events!). This commit fixes up the code so that the button state after the press/release event is passed to the mousegrabber callback function. Fixes: #280 Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
55bffbcc45
commit
18f6ab107f
12
event.c
12
event.c
|
@ -173,8 +173,18 @@ event_handle_button(xcb_button_press_event_t *ev)
|
|||
|
||||
globalconf.timestamp = ev->time;
|
||||
|
||||
if(event_handle_mousegrabber(ev->root_x, ev->root_y, 1 << (ev->detail - 1 + 8)))
|
||||
{
|
||||
/* ev->state contains the state before the event. Compute the state
|
||||
* after the event for the mousegrabber.
|
||||
*/
|
||||
uint16_t state = ev->state, change = 1 << (ev->detail - 1 + 8);
|
||||
if (XCB_EVENT_RESPONSE_TYPE(ev) == XCB_BUTTON_PRESS)
|
||||
state |= change;
|
||||
else
|
||||
state &= ~change;
|
||||
if(event_handle_mousegrabber(ev->root_x, ev->root_y, state))
|
||||
return;
|
||||
}
|
||||
|
||||
/* ev->state is
|
||||
* button status (8 bits) + modifiers status (8 bits)
|
||||
|
|
Loading…
Reference in New Issue