dix: add ScrollInfo to DeviceChangedEvents
3304bbff9b
added smooth scrolling support for
pointer events and for XIQueryDevice but didn't add the matching parts to
XIDeviceChangedEvents.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
e3f6a76dd4
commit
8473e441b0
|
@ -43,8 +43,10 @@
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "eventstr.h"
|
#include "eventstr.h"
|
||||||
|
#include "exevents.h"
|
||||||
#include "exglobals.h"
|
#include "exglobals.h"
|
||||||
#include "eventconvert.h"
|
#include "eventconvert.h"
|
||||||
|
#include "inpututils.h"
|
||||||
#include "xiquerydevice.h"
|
#include "xiquerydevice.h"
|
||||||
#include "xkbsrv.h"
|
#include "xkbsrv.h"
|
||||||
|
|
||||||
|
@ -481,6 +483,40 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe
|
||||||
return info->length * 4;
|
return info->length * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
appendScrollInfo(DeviceChangedEvent *dce, xXIScrollInfo *info, int axisnumber)
|
||||||
|
{
|
||||||
|
if (dce->valuators[axisnumber].scroll.type == SCROLL_TYPE_NONE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
info->type = XIScrollClass;
|
||||||
|
info->length = sizeof(xXIScrollInfo)/4;
|
||||||
|
info->number = axisnumber;
|
||||||
|
switch(dce->valuators[axisnumber].scroll.type)
|
||||||
|
{
|
||||||
|
case SCROLL_TYPE_VERTICAL:
|
||||||
|
info->scroll_type = XIScrollTypeVertical;
|
||||||
|
break;
|
||||||
|
case SCROLL_TYPE_HORIZONTAL:
|
||||||
|
info->scroll_type = XIScrollTypeHorizontal;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", dce->valuators[axisnumber].scroll.type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
info->increment = double_to_fp3232(dce->valuators[axisnumber].scroll.increment);
|
||||||
|
info->sourceid = dce->sourceid;
|
||||||
|
|
||||||
|
info->flags = 0;
|
||||||
|
|
||||||
|
if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_DONT_EMULATE)
|
||||||
|
info->flags |= XIScrollFlagNoEmulation;
|
||||||
|
if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_PREFERRED)
|
||||||
|
info->flags |= XIScrollFlagPreferred;
|
||||||
|
|
||||||
|
return info->length * 4;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
|
eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
|
||||||
{
|
{
|
||||||
|
@ -496,8 +532,16 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
|
||||||
len += pad_to_int32(bits_to_bytes(dce->buttons.num_buttons));
|
len += pad_to_int32(bits_to_bytes(dce->buttons.num_buttons));
|
||||||
}
|
}
|
||||||
if (dce->num_valuators)
|
if (dce->num_valuators)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
len += sizeof(xXIValuatorInfo) * dce->num_valuators;
|
len += sizeof(xXIValuatorInfo) * dce->num_valuators;
|
||||||
|
|
||||||
|
for (i = 0; i < dce->num_valuators; i++)
|
||||||
|
if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE)
|
||||||
|
len += sizeof(xXIScrollInfo);
|
||||||
|
}
|
||||||
|
|
||||||
nkeys = (dce->keys.max_keycode > 0) ?
|
nkeys = (dce->keys.max_keycode > 0) ?
|
||||||
dce->keys.max_keycode - dce->keys.min_keycode + 1 : 0;
|
dce->keys.max_keycode - dce->keys.min_keycode + 1 : 0;
|
||||||
if (nkeys > 0)
|
if (nkeys > 0)
|
||||||
|
@ -543,6 +587,15 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
|
||||||
dcce->num_classes += dce->num_valuators;
|
dcce->num_classes += dce->num_valuators;
|
||||||
for (i = 0; i < dce->num_valuators; i++)
|
for (i = 0; i < dce->num_valuators; i++)
|
||||||
ptr += appendValuatorInfo(dce, (xXIValuatorInfo*)ptr, i);
|
ptr += appendValuatorInfo(dce, (xXIValuatorInfo*)ptr, i);
|
||||||
|
|
||||||
|
for (i = 0; i < dce->num_valuators; i++)
|
||||||
|
{
|
||||||
|
if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE)
|
||||||
|
{
|
||||||
|
dcce->num_classes++;
|
||||||
|
ptr += appendScrollInfo(dce, (xXIScrollInfo*)ptr, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*xi = (xEvent*)dcce;
|
*xi = (xEvent*)dcce;
|
||||||
|
|
|
@ -243,6 +243,7 @@ CreateClassesChangedEvent(InternalEvent* event,
|
||||||
dce->valuators[i].resolution = slave->valuator->axes[i].resolution;
|
dce->valuators[i].resolution = slave->valuator->axes[i].resolution;
|
||||||
dce->valuators[i].mode = slave->valuator->axes[i].mode;
|
dce->valuators[i].mode = slave->valuator->axes[i].mode;
|
||||||
dce->valuators[i].name = slave->valuator->axes[i].label;
|
dce->valuators[i].name = slave->valuator->axes[i].label;
|
||||||
|
dce->valuators[i].scroll = slave->valuator->axes[i].scroll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slave->key)
|
if (slave->key)
|
||||||
|
|
|
@ -153,6 +153,7 @@ struct _DeviceChangedEvent
|
||||||
uint32_t resolution; /**< Resolution counts/m */
|
uint32_t resolution; /**< Resolution counts/m */
|
||||||
uint8_t mode; /**< Relative or Absolute */
|
uint8_t mode; /**< Relative or Absolute */
|
||||||
Atom name; /**< Axis name */
|
Atom name; /**< Axis name */
|
||||||
|
ScrollInfo scroll; /**< Smooth scrolling info */
|
||||||
} valuators[MAX_VALUATORS];
|
} valuators[MAX_VALUATORS];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -748,6 +748,26 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case XIScrollClass:
|
||||||
|
{
|
||||||
|
xXIScrollInfo *s = (xXIScrollInfo*)any;
|
||||||
|
assert(s->length ==
|
||||||
|
bytes_to_int32(sizeof(xXIScrollInfo)));
|
||||||
|
|
||||||
|
assert(s->sourceid == in->sourceid);
|
||||||
|
assert(s->number < in->num_valuators);
|
||||||
|
switch(s->type)
|
||||||
|
{
|
||||||
|
case XIScrollTypeVertical:
|
||||||
|
assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL);
|
||||||
|
break;
|
||||||
|
case XIScrollTypeHorizontal:
|
||||||
|
assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (s->flags & XIScrollFlagPreferred)
|
||||||
|
assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
printf("Invalid class type.\n\n");
|
printf("Invalid class type.\n\n");
|
||||||
assert(1);
|
assert(1);
|
||||||
|
|
Loading…
Reference in New Issue