aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/devices.c50
-rw-r--r--xorg-server/dix/eventconvert.c14
-rw-r--r--xorg-server/dix/getevents.c312
-rw-r--r--xorg-server/dix/globals.c4
-rw-r--r--xorg-server/dix/grabs.c7
-rw-r--r--xorg-server/dix/inpututils.c130
-rw-r--r--xorg-server/dix/ptrveloc.c8
-rw-r--r--xorg-server/dix/window.c230
8 files changed, 383 insertions, 372 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index f10f7a08d..c1b04a8e6 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -261,8 +261,8 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
if (!dev)
return (DeviceIntPtr)NULL;
dev->id = devid;
- dev->public.processInputProc = (ProcessInputProc)NoopDDA;
- dev->public.realInputProc = (ProcessInputProc)NoopDDA;
+ dev->public.processInputProc = ProcessOtherEvent;
+ dev->public.realInputProc = ProcessOtherEvent;
dev->public.enqueueInputProc = EnqueueEvent;
dev->deviceProc = deviceProc;
dev->startup = autoStart;
@@ -272,6 +272,8 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+ XkbSetExtension(dev, ProcessKeyboardEvent);
+
dev->coreEvents = TRUE;
/* sprite defaults */
@@ -1106,18 +1108,6 @@ NumMotionEvents(void)
return inputInfo.pointer->valuator->numMotionEvents;
}
-void
-RegisterPointerDevice(DeviceIntPtr device)
-{
- RegisterOtherDevice(device);
-}
-
-void
-RegisterKeyboardDevice(DeviceIntPtr device)
-{
- RegisterOtherDevice(device);
-}
-
int
dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode)
{
@@ -1261,16 +1251,19 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
valc->numMotionEvents = numMotionEvents;
valc->motionHintWindow = NullWindow;
valc->numAxes = numAxes;
- valc->mode = mode;
valc->axes = (AxisInfoPtr)(valc + 1);
valc->axisVal = (double *)(valc->axes + numAxes);
+
+ if (mode & OutOfProximity)
+ InitProximityClassDeviceStruct(dev);
+
dev->valuator = valc;
AllocateMotionHistory(dev);
for (i=0; i<numAxes; i++) {
InitValuatorAxisStruct(dev, i, labels[i], NO_AXIS_LIMITS, NO_AXIS_LIMITS,
- 0, 0, 0);
+ 0, 0, 0, mode);
valc->axisVal[i]=0;
}
@@ -2367,8 +2360,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
event.valuators[i].min = master->valuator->axes[i].min_value;
event.valuators[i].max = master->valuator->axes[i].max_value;
event.valuators[i].resolution = master->valuator->axes[i].resolution;
- /* This should, eventually, be a per-axis mode */
- event.valuators[i].mode = master->valuator->mode;
+ event.valuators[i].mode = master->valuator->axes[i].mode;
event.valuators[i].name = master->valuator->axes[i].label;
}
}
@@ -2581,3 +2573,25 @@ AllocDevicePair (ClientPtr client, char* name,
return Success;
}
+/**
+ * Return Relative or Absolute for the device.
+ */
+int valuator_get_mode(DeviceIntPtr dev, int axis)
+{
+ return (dev->valuator->axes[axis].mode & DeviceMode);
+}
+
+/**
+ * Set the given mode for the axis. If axis is VALUATOR_MODE_ALL_AXES, then
+ * set the mode for all axes.
+ */
+void valuator_set_mode(DeviceIntPtr dev, int axis, int mode)
+{
+ if (axis != VALUATOR_MODE_ALL_AXES)
+ dev->valuator->axes[axis].mode = mode;
+ else {
+ int i;
+ for (i = 0; i < dev->valuator->numAxes; i++)
+ dev->valuator->axes[i].mode = mode;
+ }
+}
diff --git a/xorg-server/dix/eventconvert.c b/xorg-server/dix/eventconvert.c
index e891f0698..e45878a90 100644
--- a/xorg-server/dix/eventconvert.c
+++ b/xorg-server/dix/eventconvert.c
@@ -261,6 +261,12 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count)
}
num_events = (countValuators(ev, &first) + 5)/6; /* valuator ev */
+ if (num_events <= 0)
+ {
+ *count = 0;
+ return BadMatch;
+ }
+
num_events++; /* the actual event event */
*xi = calloc(num_events, sizeof(xEvent));
@@ -318,6 +324,12 @@ countValuators(DeviceEvent *ev, int *first)
for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++)
{
+ /* Assume mode of 0th valuator matches XI1 device mode. Stop when the
+ * event mode changes since XI1 can't handle mixed mode devices.
+ */
+ if (ev->valuators.mode[i] != ev->valuators.mode[0])
+ break;
+
if (BitIsOn(ev->valuators.mask, i))
{
if (first_valuator == -1)
@@ -440,7 +452,7 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe
info->value.frac = 0;
info->resolution = dce->valuators[axisnumber].resolution;
info->number = axisnumber;
- info->mode = dce->valuators[axisnumber].mode; /* Server doesn't have per-axis mode yet */
+ info->mode = dce->valuators[axisnumber].mode;
info->sourceid = dce->sourceid;
return info->length * 4;
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index 0933ac3da..d5d6a78b1 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -46,6 +46,7 @@
#include "mipointer.h"
#include "eventstr.h"
#include "eventconvert.h"
+#include "inpututils.h"
#include <X11/extensions/XKBproto.h>
#include "xkbsrv.h"
@@ -184,34 +185,38 @@ init_raw(DeviceIntPtr dev, RawDeviceEvent *event, Time ms, int type, int detail)
}
static void
-set_raw_valuators(RawDeviceEvent *event, int first, int num, int *valuators, int32_t* data)
+set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, int32_t* data)
{
int i;
- for (i = first; i < first + num; i++)
- SetBit(event->valuators.mask, i);
- memcpy(&data[first], valuators, num * sizeof(uint32_t));
+ for (i = 0; i < valuator_mask_size(mask); i++)
+ {
+ if (valuator_mask_isset(mask, i))
+ {
+ SetBit(event->valuators.mask, i);
+ data[i] = valuator_mask_get(mask, i);
+ }
+ }
}
static void
-set_valuators(DeviceIntPtr dev, DeviceEvent* event, int first_valuator,
- int num_valuators, int *valuators)
+set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
{
int i;
- for (i = first_valuator; i < first_valuator + num_valuators; i++)
+ for (i = 0; i < valuator_mask_size(mask); i++)
{
- SetBit(event->valuators.mask, i);
- if (dev->valuator->mode == Absolute)
- SetBit(event->valuators.mode, i);
- event->valuators.data_frac[i] =
- dev->last.remainder[i] * (1 << 16) * (1 << 16);
+ if (valuator_mask_isset(mask, i))
+ {
+ SetBit(event->valuators.mask, i);
+ if (dev->valuator->axes[i].mode == Absolute)
+ SetBit(event->valuators.mode, i);
+ event->valuators.data[i] = valuator_mask_get(mask, i);
+ event->valuators.data_frac[i] =
+ dev->last.remainder[i] * (1 << 16) * (1 << 16);
+ }
}
-
- memcpy(&event->valuators.data[first_valuator],
- valuators, num_valuators * sizeof(int32_t));
-
}
void
@@ -250,8 +255,7 @@ CreateClassesChangedEvent(EventList* event,
dce->valuators[i].min = slave->valuator->axes[i].min_value;
dce->valuators[i].max = slave->valuator->axes[i].max_value;
dce->valuators[i].resolution = slave->valuator->axes[i].resolution;
- /* This should, eventually, be a per-axis mode */
- dce->valuators[i].mode = slave->valuator->mode;
+ dce->valuators[i].mode = slave->valuator->axes[i].mode;
dce->valuators[i].name = slave->valuator->axes[i].label;
}
}
@@ -369,8 +373,15 @@ AllocateMotionHistory(DeviceIntPtr pDev)
*/
if (IsMaster(pDev))
size = sizeof(INT32) * 3 * MAX_VALUATORS;
- else
- size = sizeof(INT32) * pDev->valuator->numAxes;
+ else {
+ ValuatorClassPtr v = pDev->valuator;
+ int numAxes;
+ /* XI1 doesn't understand mixed mode devices */
+ for (numAxes = 0; numAxes < v->numAxes; numAxes++)
+ if (valuator_get_mode(pDev, numAxes) != valuator_get_mode(pDev, 0))
+ break;
+ size = sizeof(INT32) * numAxes;
+ }
size += sizeof(Time);
@@ -524,12 +535,12 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
* for SDs: [time] [val0] [val1] ... [valn]
* for MDs: [time] [min_val0] [max_val0] [val0] [min_val1] ... [valn]
*
- * For events that have some valuators unset (first_valuator > 0):
+ * For events that have some valuators unset:
* min_val == max_val == val == 0.
*/
static void
-updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
- int num_valuators, int *valuators)
+updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, ValuatorMask *mask,
+ int *valuators)
{
char *buff = (char *) pDev->valuator->motion;
ValuatorClassPtr v;
@@ -548,17 +559,22 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
buff += sizeof(Time);
memset(buff, 0, sizeof(INT32) * 3 * MAX_VALUATORS);
- buff += 3 * sizeof(INT32) * first_valuator;
- for (i = first_valuator; i < first_valuator + num_valuators; i++)
+ for (i = 0; i < v->numAxes; i++)
{
- if (i >= v->numAxes)
+ /* XI1 doesn't support mixed mode devices */
+ if (valuator_get_mode(pDev, i) != valuator_get_mode(pDev, 0))
break;
+ if (valuator_mask_size(mask) <= i || !valuator_mask_isset(mask, i))
+ {
+ buff += 3 * sizeof(INT32);
+ continue;
+ }
memcpy(buff, &v->axes[i].min_value, sizeof(INT32));
buff += sizeof(INT32);
memcpy(buff, &v->axes[i].max_value, sizeof(INT32));
buff += sizeof(INT32);
- memcpy(buff, &valuators[i - first_valuator], sizeof(INT32));
+ memcpy(buff, &valuators[i], sizeof(INT32));
buff += sizeof(INT32);
}
} else
@@ -571,9 +587,17 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
buff += sizeof(Time);
memset(buff, 0, sizeof(INT32) * pDev->valuator->numAxes);
- buff += sizeof(INT32) * first_valuator;
- memcpy(buff, valuators, sizeof(INT32) * num_valuators);
+ for (i = 0; i < MAX_VALUATORS; i++)
+ {
+ if (valuator_mask_size(mask) <= i || !valuator_mask_isset(mask, i))
+ {
+ buff += sizeof(INT32);
+ continue;
+ }
+ memcpy(buff, &valuators[i], sizeof(INT32));
+ buff += sizeof(INT32);
+ }
}
pDev->valuator->last_motion = (pDev->valuator->last_motion + 1) %
@@ -631,13 +655,17 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
* Clip every axis in the list of valuators to its bounds.
*/
static void
-clipValuators(DeviceIntPtr pDev, int first_valuator, int num_valuators,
- int *valuators)
+clipValuators(DeviceIntPtr pDev, ValuatorMask *mask)
{
int i;
- for (i = 0; i < num_valuators; i++)
- clipAxis(pDev, i + first_valuator, &(valuators[i]));
+ for (i = 0; i < valuator_mask_size(mask); i++)
+ if (valuator_mask_isset(mask, i))
+ {
+ int val = valuator_mask_get(mask, i);
+ clipAxis(pDev, i, &val);
+ valuator_mask_set(mask, i, val);
+ }
}
/**
@@ -680,36 +708,35 @@ UpdateFromMaster(EventListPtr events, DeviceIntPtr dev, int type, int *num_event
* @param dev The device which's pointer is to be moved.
* @param x Returns the x position of the pointer after the move.
* @param y Returns the y position of the pointer after the move.
- * @param first The first valuator in @valuators
- * @param num Total number of valuators in @valuators.
+ * @param mask Bit mask of valid valuators.
* @param valuators Valuator data for each axis between @first and
* @first+@num.
*/
static void
-moveAbsolute(DeviceIntPtr dev, int *x, int *y,
- int first, int num, int *valuators)
+moveAbsolute(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask)
{
int i;
-
- if (num >= 1 && first == 0)
- *x = *(valuators + 0);
+ if (valuator_mask_isset(mask, 0))
+ *x = valuator_mask_get(mask, 0);
else
*x = dev->last.valuators[0];
- if (first <= 1 && num >= (2 - first))
- *y = *(valuators + 1 - first);
+ if (valuator_mask_isset(mask, 1))
+ *y = valuator_mask_get(mask, 1);
else
*y = dev->last.valuators[1];
clipAxis(dev, 0, x);
clipAxis(dev, 1, y);
- i = (first > 2) ? 0 : 2;
- for (; i < num; i++)
+ for (i = 2; i < valuator_mask_size(mask); i++)
{
- dev->last.valuators[i + first] = valuators[i];
- clipAxis(dev, i, &dev->last.valuators[i + first]);
+ if (valuator_mask_isset(mask, i))
+ {
+ dev->last.valuators[i] = valuator_mask_get(mask, i);
+ clipAxis(dev, i, &dev->last.valuators[i]);
+ }
}
}
@@ -719,42 +746,44 @@ moveAbsolute(DeviceIntPtr dev, int *x, int *y,
* @param dev The device which's pointer is to be moved.
* @param x Returns the x position of the pointer after the move.
* @param y Returns the y position of the pointer after the move.
- * @param first The first valuator in @valuators
- * @param num Total number of valuators in @valuators.
+ * @param mask Bit mask of valid valuators.
* @param valuators Valuator data for each axis between @first and
* @first+@num.
*/
static void
-moveRelative(DeviceIntPtr dev, int *x, int *y,
- int first, int num, int *valuators)
+moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask)
{
int i;
*x = dev->last.valuators[0];
*y = dev->last.valuators[1];
- if (num >= 1 && first == 0)
- *x += *(valuators +0);
+ if (valuator_mask_isset(mask, 0))
+ *x += valuator_mask_get(mask, 0);
- if (first <= 1 && num >= (2 - first))
- *y += *(valuators + 1 - first);
+ if (valuator_mask_isset(mask, 1))
+ *y += valuator_mask_get(mask, 1);
/* if attached, clip both x and y to the defined limits (usually
* co-ord space limit). If it is attached, we need x/y to go over the
* limits to be able to change screens. */
- if(dev->u.master && dev->valuator->mode == Absolute) {
- clipAxis(dev, 0, x);
- clipAxis(dev, 1, y);
+ if(dev->u.master) {
+ if (valuator_get_mode(dev, 0) == Absolute)
+ clipAxis(dev, 0, x);
+ if (valuator_get_mode(dev, 1) == Absolute)
+ clipAxis(dev, 1, y);
}
/* calc other axes, clip, drop back into valuators */
- i = (first > 2) ? 0 : 2;
- for (; i < num; i++)
+ for (i = 2; i < valuator_mask_size(mask); i++)
{
- dev->last.valuators[i + first] += valuators[i];
- if (dev->valuator->mode == Absolute)
- clipAxis(dev, i, &dev->last.valuators[i + first]);
- valuators[i] = dev->last.valuators[i + first];
+ if (valuator_mask_isset(mask, i))
+ {
+ dev->last.valuators[i] += valuator_mask_get(mask, i);
+ if (valuator_get_mode(dev, i) == Absolute)
+ clipAxis(dev, i, &dev->last.valuators[i]);
+ valuator_mask_set(mask, i, dev->last.valuators[i]);
+ }
}
}
@@ -868,18 +897,18 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
* Update the motion history for the device and (if appropriate) for its
* master device.
* @param dev Slave device to update.
- * @param first First valuator to append to history.
+ * @param mask Bit mask of valid valuators to append to history.
* @param num Total number of valuators to append to history.
* @param ms Current time
*/
static void
-updateHistory(DeviceIntPtr dev, int first, int num, CARD32 ms)
+updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
{
- updateMotionHistory(dev, ms, first, num, &dev->last.valuators[first]);
+ updateMotionHistory(dev, ms, mask, dev->last.valuators);
if (dev->u.master)
{
DeviceIntPtr master = GetMaster(dev, MASTER_POINTER);
- updateMotionHistory(master, ms, first, num, &dev->last.valuators[first]);
+ updateMotionHistory(master, ms, mask, dev->last.valuators);
}
}
@@ -889,7 +918,10 @@ updateHistory(DeviceIntPtr dev, int first, int num, CARD32 ms)
*/
int
GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type, int key_code) {
- return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL);
+ ValuatorMask mask;
+
+ valuator_mask_zero(&mask);
+ return GetKeyboardValuatorEvents(events, pDev, type, key_code, &mask);
}
@@ -903,20 +935,18 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type, int key_code)
*/
int
GetKeyboardValuatorEvents(EventList *events, DeviceIntPtr pDev, int type,
- int key_code, int first_valuator,
- int num_valuators, int *valuators_in) {
+ int key_code, const ValuatorMask *mask_in) {
int num_events = 0;
CARD32 ms = 0;
DeviceEvent *event;
RawDeviceEvent *raw;
- int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
/* refuse events from disabled devices */
if (!pDev->enabled)
return 0;
if (!events ||!pDev->key || !pDev->focus || !pDev->kbdfeed ||
- num_valuators > MAX_VALUATORS ||
(type != KeyPress && type != KeyRelease) ||
(key_code < 8 || key_code > 255))
return 0;
@@ -941,17 +971,14 @@ GetKeyboardValuatorEvents(EventList *events, DeviceIntPtr pDev, int type,
events++;
num_events++;
- memcpy(valuators, valuators_in, num_valuators * sizeof(int));
+ valuator_mask_copy(&mask, mask_in);
init_raw(pDev, raw, ms, type, key_code);
- set_raw_valuators(raw, first_valuator, num_valuators, valuators,
- raw->valuators.data_raw);
+ set_raw_valuators(raw, &mask, raw->valuators.data_raw);
- if (num_valuators)
- clipValuators(pDev, first_valuator, num_valuators, valuators);
+ clipValuators(pDev, &mask);
- set_raw_valuators(raw, first_valuator, num_valuators, valuators,
- raw->valuators.data);
+ set_raw_valuators(raw, &mask, raw->valuators.data);
event = (DeviceEvent*) events->event;
init_event(pDev, event, ms);
@@ -966,10 +993,9 @@ GetKeyboardValuatorEvents(EventList *events, DeviceIntPtr pDev, int type,
set_key_up(pDev, key_code, KEY_POSTED);
}
- if (num_valuators)
- clipValuators(pDev, first_valuator, num_valuators, valuators);
+ clipValuators(pDev, &mask);
- set_valuators(pDev, event, first_valuator, num_valuators, valuators);
+ set_valuators(pDev, event, &mask);
return num_events;
}
@@ -1026,19 +1052,19 @@ FreeEventList(EventListPtr list, int num_events)
}
static void
-transformAbsolute(DeviceIntPtr dev, int v[MAX_VALUATORS])
+transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
{
struct pixman_f_vector p;
/* p' = M * p in homogeneous coordinates */
- p.v[0] = v[0];
- p.v[1] = v[1];
+ p.v[0] = valuator_mask_get(mask, 0);
+ p.v[1] = valuator_mask_get(mask, 1);
p.v[2] = 1.0;
pixman_f_transform_point(&dev->transform, &p);
- v[0] = lround(p.v[0]);
- v[1] = lround(p.v[1]);
+ valuator_mask_set(mask, 0, lround(p.v[0]));
+ valuator_mask_set(mask, 1, lround(p.v[1]));
}
/**
@@ -1059,8 +1085,7 @@ transformAbsolute(DeviceIntPtr dev, int v[MAX_VALUATORS])
*/
int
GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
- int flags, int first_valuator, int num_valuators,
- int *valuators_in) {
+ int flags, const ValuatorMask *mask_in) {
int num_events = 1;
CARD32 ms;
DeviceEvent *event;
@@ -1069,7 +1094,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
cx, cy; /* only screen coordinates */
float x_frac = 0.0, y_frac = 0.0, cx_frac, cy_frac;
ScreenPtr scr = miPointerGetScreen(pDev);
- int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
/* refuse events from disabled devices */
if (!pDev->enabled)
@@ -1077,13 +1102,14 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
ms = GetTimeInMillis(); /* before pointer update to help precision */
- if (!scr || !pDev->valuator || first_valuator < 0 ||
- num_valuators > MAX_VALUATORS ||
- ((num_valuators + first_valuator) > pDev->valuator->numAxes) ||
+ if (!scr || !pDev->valuator ||
(type != MotionNotify && type != ButtonPress && type != ButtonRelease) ||
(type != MotionNotify && !pDev->button) ||
- ((type == ButtonPress || type == ButtonRelease) && !buttons) ||
- (type == MotionNotify && num_valuators <= 0))
+ ((type == ButtonPress || type == ButtonRelease) && !buttons))
+ return 0;
+
+ if (type == MotionNotify &&
+ (!mask_in || valuator_mask_num_valuators(mask_in) <= 0))
return 0;
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
@@ -1092,54 +1118,68 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
events++;
num_events++;
- memcpy(valuators, valuators_in, num_valuators * sizeof(int));
+ valuator_mask_copy(&mask, mask_in);
init_raw(pDev, raw, ms, type, buttons);
- set_raw_valuators(raw, first_valuator, num_valuators, valuators,
- raw->valuators.data_raw);
+ set_raw_valuators(raw, &mask, raw->valuators.data_raw);
if (flags & POINTER_ABSOLUTE)
{
if (flags & POINTER_SCREEN) /* valuators are in screen coords */
{
+ int scaled;
- if (num_valuators >= 1 && first_valuator == 0)
- valuators[0] = rescaleValuatorAxis(valuators[0], 0.0, &x_frac, NULL,
- pDev->valuator->axes + 0,
- scr->width);
- if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
- valuators[1 - first_valuator] = rescaleValuatorAxis(valuators[1 - first_valuator], 0.0, &y_frac, NULL,
- pDev->valuator->axes + 1,
- scr->height);
+ if (valuator_mask_isset(&mask, 0))
+ {
+ scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 0),
+ 0.0, &x_frac, NULL,
+ pDev->valuator->axes + 0,
+ scr->width);
+ valuator_mask_set(&mask, 0, scaled);
+ }
+ if (valuator_mask_isset(&mask, 1))
+ {
+ scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 0),
+ 0.0, &y_frac, NULL,
+ pDev->valuator->axes + 1,
+ scr->height);
+ valuator_mask_set(&mask, 1, scaled);
+ }
}
- transformAbsolute(pDev, valuators);
- moveAbsolute(pDev, &x, &y, first_valuator, num_valuators, valuators);
+ transformAbsolute(pDev, &mask);
+ moveAbsolute(pDev, &x, &y, &mask);
} else {
if (flags & POINTER_ACCELERATE) {
- accelPointer(pDev, first_valuator, num_valuators, valuators, ms);
+ /* FIXME: Pointer acceleration only requires X and Y values. This
+ * should be converted to masked valuators. */
+ int vals[2];
+ vals[0] = valuator_mask_isset(&mask, 0) ?
+ valuator_mask_get(&mask, 0) : pDev->last.valuators[0];
+ vals[1] = valuator_mask_isset(&mask, 1) ?
+ valuator_mask_get(&mask, 1) : pDev->last.valuators[1];
+ accelPointer(pDev, 0, 2, vals, ms);
+
/* The pointer acceleration code modifies the fractional part
* in-place, so we need to extract this information first */
x_frac = pDev->last.remainder[0];
y_frac = pDev->last.remainder[1];
}
- moveRelative(pDev, &x, &y, first_valuator, num_valuators, valuators);
+ moveRelative(pDev, &x, &y, &mask);
}
- set_raw_valuators(raw, first_valuator, num_valuators, valuators,
- raw->valuators.data);
+ set_raw_valuators(raw, &mask, raw->valuators.data);
positionSprite(pDev, &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac);
- updateHistory(pDev, first_valuator, num_valuators, ms);
+ updateHistory(pDev, &mask, ms);
/* Update the valuators with the true value sent to the client*/
- if (num_valuators >= 1 && first_valuator == 0)
- valuators[0] = x;
- if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
- valuators[1 - first_valuator] = y;
+ if (valuator_mask_isset(&mask, 0))
+ valuator_mask_set(&mask, 0, x);
+ if (valuator_mask_isset(&mask, 1))
+ valuator_mask_set(&mask, 0, y);
- if (num_valuators)
- clipValuators(pDev, first_valuator, num_valuators, valuators);
+ clipValuators(pDev, &mask);
event = (DeviceEvent*) events->event;
init_event(pDev, event, ms);
@@ -1165,7 +1205,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
event->root_x_frac = cx_frac;
event->root_y_frac = cy_frac;
- set_valuators(pDev, event, first_valuator, num_valuators, valuators);
+ set_valuators(pDev, event, &mask);
return num_events;
}
@@ -1180,30 +1220,31 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
* place via GetMaximumEventsNum(), and for freeing it.
*/
int
-GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
- int first_valuator, int num_valuators, int *valuators_in)
+GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
{
- int num_events = 1;
+ int num_events = 1, i;
DeviceEvent *event;
- int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
/* refuse events from disabled devices */
if (!pDev->enabled)
return 0;
/* Sanity checks. */
- if (type != ProximityIn && type != ProximityOut)
+ if ((type != ProximityIn && type != ProximityOut) || !mask_in)
return 0;
if (!pDev->valuator)
return 0;
- /* Do we need to send a DeviceValuator event? */
- if ((pDev->valuator->mode & 1) == Relative)
- num_valuators = 0;
- /* You fail. */
- if (first_valuator < 0 || num_valuators > MAX_VALUATORS ||
- (num_valuators + first_valuator) > pDev->valuator->numAxes)
- return 0;
+ valuator_mask_copy(&mask, mask_in);
+
+ /* ignore relative axes for proximity. */
+ for (i = 0; i < valuator_mask_num_valuators(&mask); i++)
+ {
+ if (valuator_mask_isset(&mask, i) &&
+ valuator_get_mode(pDev, i) == Relative)
+ valuator_mask_unset(&mask, i);
+ }
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
@@ -1211,12 +1252,9 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
init_event(pDev, event, GetTimeInMillis());
event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
- if (num_valuators) {
- memcpy(valuators, valuators_in, num_valuators * sizeof(int));
- clipValuators(pDev, first_valuator, num_valuators, valuators);
- }
+ clipValuators(pDev, &mask);
- set_valuators(pDev, event, first_valuator, num_valuators, valuators);
+ set_valuators(pDev, event, &mask);
return num_events;
}
diff --git a/xorg-server/dix/globals.c b/xorg-server/dix/globals.c
index 622e50f81..d7e919e50 100644
--- a/xorg-server/dix/globals.c
+++ b/xorg-server/dix/globals.c
@@ -106,10 +106,6 @@ CARD32 defaultScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME;
CARD32 defaultScreenSaverInterval = DEFAULT_SCREEN_SAVER_INTERVAL;
int defaultScreenSaverBlanking = DEFAULT_SCREEN_SAVER_BLANKING;
int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES;
-#ifndef NOLOGOHACK
-int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER;
-#endif
-
#ifdef SCREENSAVER
Bool screenSaverSuspended = FALSE;
#endif
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c
index c588afc7c..a14181108 100644
--- a/xorg-server/dix/grabs.c
+++ b/xorg-server/dix/grabs.c
@@ -117,11 +117,8 @@ CreateGrab(
static void
FreeGrab(GrabPtr pGrab)
{
- if (pGrab->modifiersDetail.pMask != NULL)
- free(pGrab->modifiersDetail.pMask);
-
- if (pGrab->detail.pMask != NULL)
- free(pGrab->detail.pMask);
+ free(pGrab->modifiersDetail.pMask);
+ free(pGrab->detail.pMask);
if (pGrab->cursor)
FreeCursor(pGrab->cursor, (Cursor)0);
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c
index 39e65064a..80275bd40 100644
--- a/xorg-server/dix/inpututils.c
+++ b/xorg-server/dix/inpututils.c
@@ -35,6 +35,7 @@
#include "xace.h"
#include "xkbsrv.h"
#include "xkbstr.h"
+#include "inpututils.h"
/* Check if a button map change is okay with the device.
* Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -418,3 +419,132 @@ FreeInputAttributes(InputAttributes *attrs)
free(attrs);
}
+/**
+ * Alloc a valuator mask large enough for num_valuators.
+ */
+ValuatorMask*
+valuator_mask_new(int num_valuators)
+{
+ /* alloc a fixed size mask for now and ignore num_valuators. in the
+ * flying-car future, when we can dynamically alloc the masks and are
+ * not constrained by signals, we can start using num_valuators */
+ ValuatorMask *mask = calloc(1, sizeof(ValuatorMask));
+ mask->last_bit = -1;
+ return mask;
+}
+
+/**
+ * Sets a range of valuators between first_valuator and num_valuators with
+ * the data in the valuators array. All other values are set to 0.
+ */
+void
+valuator_mask_set_range(ValuatorMask *mask, int first_valuator, int num_valuators,
+ const int* valuators)
+{
+ int i;
+
+ valuator_mask_zero(mask);
+
+ for (i = first_valuator; i < min(first_valuator + num_valuators, MAX_VALUATORS); i++)
+ valuator_mask_set(mask, i, valuators[i - first_valuator]);
+}
+
+/**
+ * Reset mask to zero.
+ */
+void
+valuator_mask_zero(ValuatorMask *mask)
+{
+ memset(mask, 0, sizeof(*mask));
+ mask->last_bit = -1;
+}
+
+/**
+ * Returns the current size of the mask (i.e. the highest number of
+ * valuators currently set + 1).
+ */
+int
+valuator_mask_size(const ValuatorMask *mask)
+{
+ return mask->last_bit + 1;
+}
+
+/**
+ * Returns the number of valuators set in the given mask.
+ */
+int
+valuator_mask_num_valuators(const ValuatorMask *mask)
+{
+ return CountBits(mask->mask, min(mask->last_bit + 1, MAX_VALUATORS));
+}
+
+/**
+ * Return true if the valuator is set in the mask, or false otherwise.
+ */
+int
+valuator_mask_isset(const ValuatorMask *mask, int valuator)
+{
+ return mask->last_bit >= valuator && BitIsOn(mask->mask, valuator);
+}
+
+/**
+ * Set the valuator to the given data.
+ */
+void
+valuator_mask_set(ValuatorMask *mask, int valuator, int data)
+{
+ mask->last_bit = max(valuator, mask->last_bit);
+ SetBit(mask->mask, valuator);
+ mask->valuators[valuator] = data;
+}
+
+/**
+ * Return the requested valuator value. If the mask bit is not set for the
+ * given valuator, the returned value is undefined.
+ */
+int
+valuator_mask_get(const ValuatorMask *mask, int valuator)
+{
+ return mask->valuators[valuator];
+}
+
+/**
+ * Remove the valuator from the mask.
+ */
+void
+valuator_mask_unset(ValuatorMask *mask, int valuator)
+{
+ if (mask->last_bit >= valuator) {
+ int i, lastbit = -1;
+
+ ClearBit(mask->mask, valuator);
+ mask->valuators[valuator] = 0;
+
+ for (i = 0; i <= mask->last_bit; i++)
+ if (valuator_mask_isset(mask, i))
+ lastbit = max(lastbit, i);
+ mask->last_bit = lastbit;
+ }
+}
+
+void
+valuator_mask_copy(ValuatorMask *dest, const ValuatorMask *src)
+{
+ if (src)
+ memcpy(dest, src, sizeof(*dest));
+ else
+ valuator_mask_zero(dest);
+}
+
+int
+CountBits(const uint8_t *mask, int len)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < len; i++)
+ if (BitIsOn(mask, i))
+ ret++;
+
+ return ret;
+}
diff --git a/xorg-server/dix/ptrveloc.c b/xorg-server/dix/ptrveloc.c
index eeedb83dd..9a8737cf4 100644
--- a/xorg-server/dix/ptrveloc.c
+++ b/xorg-server/dix/ptrveloc.c
@@ -952,11 +952,9 @@ SetAccelerationProfile(
if(profile == NULL && profile_num != PROFILE_UNINITIALIZE)
return FALSE;
- if(vel->profile_private != NULL){
- /* Here one could free old profile-private data */
- free(vel->profile_private);
- vel->profile_private = NULL;
- }
+ /* Here one could free old profile-private data */
+ free(vel->profile_private);
+ vel->profile_private = NULL;
/* Here one could init profile-private data */
vel->Profile = profile;
vel->statistics.profile_number = profile_num;
diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c
index 485c3caea..399e08635 100644
--- a/xorg-server/dix/window.c
+++ b/xorg-server/dix/window.c
@@ -137,6 +137,8 @@ Equipment Corporation.
* ChangeWindowDeviceCursor
******/
+Bool bgNoneRoot = FALSE;
+
static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
@@ -463,6 +465,10 @@ InitRootWindow(WindowPtr pWin)
if (party_like_its_1989) {
MakeRootTile(pWin);
backFlag |= CWBackPixmap;
+ } else if (pScreen->canDoBGNoneRoot && bgNoneRoot) {
+ pWin->backgroundState = XaceBackgroundNoneState(pWin);
+ pWin->background.pixel = pScreen->whitePixel;
+ backFlag |= CWBackPixmap;
} else {
if (whiteRoot)
pWin->background.pixel = pScreen->whitePixel;
@@ -950,6 +956,26 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client)
return Success;
}
+static void
+SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2)
+{
+ /* following the protocol: "Changing the background of a root window to
+ * None or ParentRelative restores the default background pixmap" */
+ if (bgNoneRoot) {
+ pWin->backgroundState = XaceBackgroundNoneState(pWin);
+ pWin->background.pixel = pScreen->whitePixel;
+ }
+ else if (party_like_its_1989)
+ MakeRootTile(pWin);
+ else {
+ if (whiteRoot)
+ pWin->background.pixel = pScreen->whitePixel;
+ else
+ pWin->background.pixel = pScreen->blackPixel;
+ *index2 = CWBackPixel;
+ }
+}
+
/*****
* ChangeWindowAttributes
*
@@ -999,7 +1025,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap)(pWin->background.pixmap);
if (!pWin->parent)
- MakeRootTile(pWin);
+ SetRootWindowBackground(pWin, pScreen, &index2);
else {
pWin->backgroundState = XaceBackgroundNoneState(pWin);
pWin->background.pixel = pScreen->whitePixel;
@@ -1016,7 +1042,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
if (pWin->backgroundState == BackgroundPixmap)
(*pScreen->DestroyPixmap)(pWin->background.pixmap);
if (!pWin->parent)
- MakeRootTile(pWin);
+ SetRootWindowBackground(pWin, pScreen, &index2);
else
pWin->backgroundState = ParentRelative;
borderRelative = TRUE;
@@ -3087,13 +3113,6 @@ SendVisibilityNotify(WindowPtr pWin)
}
#define RANDOM_WIDTH 32
-
-#ifndef NOLOGOHACK
-static void DrawLogo(
- WindowPtr pWin
-);
-#endif
-
int
dixSaveScreens(ClientPtr client, int on, int mode)
{
@@ -3155,18 +3174,10 @@ dixSaveScreens(ClientPtr client, int on, int mode)
* for the root window, so miPaintWindow works
*/
screenIsSaved = SCREEN_SAVER_OFF;
-#ifndef NOLOGOHACK
- if (logoScreenSaver)
- (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE);
-#endif
(*pWin->drawable.pScreen->MoveWindow)(pWin,
(short)(-(rand() % RANDOM_WIDTH)),
(short)(-(rand() % RANDOM_WIDTH)),
pWin->nextSib, VTMove);
-#ifndef NOLOGOHACK
- if (logoScreenSaver)
- DrawLogo(pWin);
-#endif
screenIsSaved = SCREEN_SAVER_ON;
}
/*
@@ -3324,10 +3335,6 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
(*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap);
}
MapWindow(pWin, serverClient);
-#ifndef NOLOGOHACK
- if (kind == SCREEN_IS_TILED && logoScreenSaver)
- DrawLogo(pWin);
-#endif
return TRUE;
}
@@ -3673,184 +3680,3 @@ WindowParentHasDeviceCursor(WindowPtr pWin,
}
return FALSE;
}
-
-#ifndef NOLOGOHACK
-static void
-DrawLogo(WindowPtr pWin)
-{
- DrawablePtr pDraw;
- ScreenPtr pScreen;
- int x, y;
- unsigned int width, height, size;
- GC *pGC;
- int rc, thin, gap, d31;
- DDXPointRec poly[4];
- ChangeGCVal fore[2], back[2];
- xrgb rgb[2];
- BITS32 fmask, bmask;
- ColormapPtr cmap;
-
- pDraw = (DrawablePtr)pWin;
- pScreen = pDraw->pScreen;
- x = -pWin->origin.x;
- y = -pWin->origin.y;
- width = pScreen->width;
- height = pScreen->height;
- pGC = GetScratchGC(pScreen->rootDepth, pScreen);
- if (!pGC)
- return;
-
- if ((rand() % 100) <= 17) /* make the probability for white fairly low */
- fore[0].val = pScreen->whitePixel;
- else
- fore[0].val = pScreen->blackPixel;
- if (pWin->backgroundState == BackgroundPixel) {
- rc = dixLookupResourceByType((pointer *)&cmap, wColormap(pWin),
- RT_COLORMAP, serverClient, DixReadAccess);
- if (rc == Success) {
- Pixel querypixels[2];
-
- querypixels[0] = fore[0].val;
- querypixels[1] = pWin->background.pixel;
- QueryColors(cmap, 2, querypixels, rgb, serverClient);
- if ((rgb[0].red == rgb[1].red) &&
- (rgb[0].green == rgb[1].green) &&
- (rgb[0].blue == rgb[1].blue)) {
- if (fore[0].val == pScreen->blackPixel)
- fore[0].val = pScreen->whitePixel;
- else
- fore[0].val = pScreen->blackPixel;
- }
- }
- }
- fore[1].val = FillSolid;
- fmask = GCForeground|GCFillStyle;
- if (pWin->backgroundState == BackgroundPixel) {
- back[0].val = pWin->background.pixel;
- back[1].val = FillSolid;
- bmask = GCForeground|GCFillStyle;
- } else {
- back[0].val = 0;
- back[1].val = 0;
- ChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin, back);
- back[0].val = FillTiled;
- back[1].ptr = pWin->background.pixmap;
- bmask = GCFillStyle|GCTile;
- }
-
- /* should be the same as the reference function XmuDrawLogo() */
-
- size = width;
- if (height < width)
- size = height;
- size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
- size &= ~1;
- x += rand() % (width - size);
- y += rand() % (height - size);
-
-/*
- * Draw what will be the thin strokes.
- *
- * -----
- * / /
- * / /
- * / /
- * / /
- * /____/
- * d
- *
- * Point d is 9/44 (~1/5) of the way across.
- */
-
- thin = (size / 11);
- if (thin < 1) thin = 1;
- gap = (thin+3) / 4;
- d31 = thin + thin + gap;
- poly[0].x = x + size; poly[0].y = y;
- poly[1].x = x + size-d31; poly[1].y = y;
- poly[2].x = x + 0; poly[2].y = y + size;
- poly[3].x = x + d31; poly[3].y = y + size;
- ChangeGC(NullClient, pGC, fmask, fore);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase area not needed for lower thin stroke.
- *
- * ------
- * / /
- * / __ /
- * / / /
- * / / /
- * /__/__/
- */
-
- poly[0].x = x + d31/2; poly[0].y = y + size;
- poly[1].x = x + size / 2; poly[1].y = y + size/2;
- poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
- poly[3].x = x + d31; poly[3].y = y + size;
- ChangeGC(NullClient, pGC, bmask, back);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase area not needed for upper thin stroke.
- *
- * ------
- * / / /
- * /--/ /
- * / /
- * / /
- * /_____/
- */
-
- poly[0].x = x + size - d31/2; poly[0].y = y;
- poly[1].x = x + size / 2; poly[1].y = y + size/2;
- poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
- poly[3].x = x + size - d31; poly[3].y = y;
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Draw thick stroke.
- * Point b is 1/4 of the way across.
- *
- * b
- * -----
- * \ \
- * \ \
- * \ \
- * \ \
- * \____\
- */
-
- poly[0].x = x; poly[0].y = y;
- poly[1].x = x + size/4; poly[1].y = y;
- poly[2].x = x + size; poly[2].y = y + size;
- poly[3].x = x + size - size/4; poly[3].y = y + size;
- ChangeGC(NullClient, pGC, fmask, fore);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase to create gap.
- *
- * /
- * /
- * /
- * /
- * /
- */
-
- poly[0].x = x + size- thin; poly[0].y = y;
- poly[1].x = x + size-( thin+gap); poly[1].y = y;
- poly[2].x = x + thin; poly[2].y = y + size;
- poly[3].x = x + thin + gap; poly[3].y = y + size;
- ChangeGC(NullClient, pGC, bmask, back);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
- FreeScratchGC(pGC);
-}
-
-#endif