Commit 2635fb75 authored by Thomas Jaeger's avatar Thomas Jaeger Committed by Alexander Larsson
parent abf7742b
......@@ -135,7 +135,8 @@ gdk_input_device_new (GdkDisplay *display,
gdkdev->info.has_cursor = 0;
gdkdev->needs_update = FALSE;
gdkdev->claimed = FALSE;
gdkdev->button_state = 0;
memset(gdkdev->button_state, 0, sizeof (gdkdev->button_state));
gdkdev->button_count = 0;
class = device->inputclassinfo;
for (i=0;i<device->num_classes;i++)
......@@ -556,15 +557,24 @@ _gdk_input_common_other_event (GdkEvent *event,
{
XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
g_return_val_if_fail (xdbe->button < 256, FALSE);
if (xdbe->type == gdkdev->buttonpress_type)
{
event->button.type = GDK_BUTTON_PRESS;
gdkdev->button_state |= 1 << xdbe->button;
if (!(gdkdev->button_state[xdbe->button/8] & 1 << (xdbe->button%8)))
{
gdkdev->button_state[xdbe->button/8] |= 1 << (xdbe->button%8);
gdkdev->button_count++;
}
}
else
{
event->button.type = GDK_BUTTON_RELEASE;
gdkdev->button_state &= ~(1 << xdbe->button);
if (gdkdev->button_state[xdbe->button/8] & 1 << (xdbe->button%8))
{
gdkdev->button_state[xdbe->button/8] &= ~(1 << (xdbe->button%8));
gdkdev->button_count--;
}
}
event->button.device = &gdkdev->info;
event->button.window = window;
......
......@@ -369,10 +369,11 @@ _gdk_input_grab_pointer (GdkWindow *window,
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice &&
((gdkdev->button_state != 0) || need_ungrab))
((gdkdev->button_count != 0) || need_ungrab))
{
XUngrabDevice (display_impl->xdisplay, gdkdev->xdevice, time);
gdkdev->button_state = 0;
memset(gdkdev->button_state, 0, sizeof (gdkdev->button_state));
gdkdev->button_count = 0;
}
tmp_list = tmp_list->next;
......
......@@ -89,7 +89,8 @@ struct _GdkDevicePrivate
gint needs_update;
/* Mask of buttons (used for button grabs) */
gint button_state;
char button_state[32];
gint button_count;
/* true if we've claimed the device as active. (used only for XINPUT_GXI) */
gint claimed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment