From 3425b16d521b8846b95df2b7d32a548d93341f3b Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 14 Nov 2010 21:29:32 +0000 Subject: xserver pixman libX11 libXext 14/11/2010 --- xorg-server/dix/devices.c | 50 ++++--- xorg-server/dix/eventconvert.c | 14 +- xorg-server/dix/getevents.c | 312 +++++++++++++++++++++++------------------ xorg-server/dix/globals.c | 4 - xorg-server/dix/grabs.c | 7 +- xorg-server/dix/inpututils.c | 130 +++++++++++++++++ xorg-server/dix/ptrveloc.c | 8 +- xorg-server/dix/window.c | 230 ++++-------------------------- 8 files changed, 383 insertions(+), 372 deletions(-) (limited to 'xorg-server/dix') 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; iaxisVal[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 #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 -- cgit v1.2.3 From 3a82f8a35b2c6d094cf9d0d5a3ccb9dd9b85f626 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 15 Nov 2010 09:43:51 +0000 Subject: xserver git update 15/11/2010 --- xorg-server/Xext/panoramiXprocs.c | 2 +- xorg-server/dix/Makefile.am | 1 + xorg-server/fb/Makefile.am | 2 +- xorg-server/fb/fb.h | 2 +- xorg-server/fb/fbcmap.c | 586 ----------------------------- xorg-server/hw/xfree86/common/xf86Config.c | 2 +- xorg-server/hw/xfree86/parser/Monitor.c | 7 - xorg-server/hw/xfree86/parser/xf86Parser.h | 1 - xorg-server/hw/xfree86/parser/xf86tokens.h | 1 - xorg-server/hw/xquartz/bundle/Makefile.am | 4 +- xorg-server/hw/xwin/winmouse.c | 1 + 11 files changed, 9 insertions(+), 600 deletions(-) delete mode 100644 xorg-server/fb/fbcmap.c (limited to 'xorg-server/dix') diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c index 067fb6cf7..615246bab 100644 --- a/xorg-server/Xext/panoramiXprocs.c +++ b/xorg-server/Xext/panoramiXprocs.c @@ -634,7 +634,7 @@ int PanoramiXTranslateCoords(ClientPtr client) rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; if((pDst == screenInfo.screens[0]->root) || - (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) + (pDst->drawable.id == screenInfo.screens[0]->screensaver.wid)) { rep.dstX += screenInfo.screens[0]->x; rep.dstY += screenInfo.screens[0]->y; diff --git a/xorg-server/dix/Makefile.am b/xorg-server/dix/Makefile.am index 8e6f7dd6a..5ff75c0ba 100644 --- a/xorg-server/dix/Makefile.am +++ b/xorg-server/dix/Makefile.am @@ -1,5 +1,6 @@ noinst_LTLIBRARIES = libdix.la libmain.la +AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS = $(DIX_CFLAGS) libmain_la_SOURCES = \ diff --git a/xorg-server/fb/Makefile.am b/xorg-server/fb/Makefile.am index 21ed7b624..0863d7c07 100644 --- a/xorg-server/fb/Makefile.am +++ b/xorg-server/fb/Makefile.am @@ -55,4 +55,4 @@ libfb_la_SOURCES = \ libwfb_la_SOURCES = $(libfb_la_SOURCES) -EXTRA_DIST = fbcmap.c fbcmap_mi.c +EXTRA_DIST = fbcmap_mi.c diff --git a/xorg-server/fb/fb.h b/xorg-server/fb/fb.h index 14c5ed137..cefd410dd 100644 --- a/xorg-server/fb/fb.h +++ b/xorg-server/fb/fb.h @@ -1262,7 +1262,7 @@ fbBltPlane (FbBits *src, Pixel planeMask); /* - * fbcmap.c + * fbcmap_mi.c */ extern _X_EXPORT int fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps); diff --git a/xorg-server/fb/fbcmap.c b/xorg-server/fb/fbcmap.c deleted file mode 100644 index 123b7f41d..000000000 --- a/xorg-server/fb/fbcmap.c +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Copyright © 1987 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include "scrnintstr.h" -#include "colormapst.h" -#include "resource.h" -#include "fb.h" - -#ifdef XFree86Server -#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!" -#endif - -static DevPrivateKeyRec cmapScrPrivateKeyRec; -#define cmapScrPrivateKey (&cmapScrPrivateKeyRec) - -#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) -#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) - -int -fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) -{ - /* By the time we are processing requests, we can guarantee that there - * is always a colormap installed */ - *pmaps = GetInstalledColormap(pScreen)->mid; - return 1; -} - - -void -fbInstallColormap(ColormapPtr pmap) -{ - ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen); - - if(pmap != oldpmap) - { - /* Uninstall pInstalledMap. No hardware changes required, just - * notify all interested parties. */ - if(oldpmap != (ColormapPtr)None) - WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); - /* Install pmap */ - SetInstalledColormap(pmap->pScreen, pmap); - WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); - } -} - -void -fbUninstallColormap(ColormapPtr pmap) -{ - ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen); - - if(pmap == curpmap) - { - if (pmap->mid != pmap->pScreen->defColormap) - { - dixLookupResourceByType((pointer *)&curpmap, - pmap->pScreen->defColormap, - RT_COLORMAP, - serverClient, DixInstallAccess); - (*pmap->pScreen->InstallColormap)(curpmap); - } - } -} - -void -fbResolveColor(unsigned short *pred, - unsigned short *pgreen, - unsigned short *pblue, - VisualPtr pVisual) -{ - int shift = 16 - pVisual->bitsPerRGBValue; - unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1; - - if ((pVisual->class | DynamicClass) == GrayScale) - { - /* rescale to gray then rgb bits */ - *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; - *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; - } - else - { - /* rescale to rgb bits */ - *pred = ((*pred >> shift) * 65535) / lim; - *pgreen = ((*pgreen >> shift) * 65535) / lim; - *pblue = ((*pblue >> shift) * 65535) / lim; - } -} - -Bool -fbInitializeColormap(ColormapPtr pmap) -{ - register unsigned i; - register VisualPtr pVisual; - unsigned lim, maxent, shift; - - pVisual = pmap->pVisual; - lim = (1 << pVisual->bitsPerRGBValue) - 1; - shift = 16 - pVisual->bitsPerRGBValue; - maxent = pVisual->ColormapEntries - 1; - if (pVisual->class == TrueColor) - { - unsigned limr, limg, limb; - - limr = pVisual->redMask >> pVisual->offsetRed; - limg = pVisual->greenMask >> pVisual->offsetGreen; - limb = pVisual->blueMask >> pVisual->offsetBlue; - for(i = 0; i <= maxent; i++) - { - /* rescale to [0..65535] then rgb bits */ - pmap->red[i].co.local.red = - ((((i * 65535) / limr) >> shift) * 65535) / lim; - pmap->green[i].co.local.green = - ((((i * 65535) / limg) >> shift) * 65535) / lim; - pmap->blue[i].co.local.blue = - ((((i * 65535) / limb) >> shift) * 65535) / lim; - } - } - else if (pVisual->class == StaticColor) - { - unsigned n; - unsigned r, g, b; - unsigned red, green, blue; - - for (n = 0; n*n*n < pVisual->ColormapEntries; n++) - ; - n--; - i = 0; - for (r = 0; r < n; r++) - { - red = (((r * 65535 / (n - 1)) >> shift) * 65535) / lim; - for (g = 0; g < n; g++) - { - green = (((g * 65535 / (n - 1)) >> shift) * 65535) / lim; - for (b = 0; b < n; b++) - { - blue = (((b * 65535 / (n - 1)) >> shift) * 65535) / lim; - pmap->red[i].co.local.red = red; - pmap->red[i].co.local.green = green; - pmap->red[i].co.local.blue = blue; - i++; - } - } - } - n = pVisual->ColormapEntries - i; - for (r = 0; r < n; r++) - { - red = (((r * 65535 / (n - 1)) >> shift) * 65535) / lim; - pmap->red[i].co.local.red = red; - pmap->red[i].co.local.green = red; - pmap->red[i].co.local.blue = red; - i++; - } - } - else if (pVisual->class == StaticGray) - { - for(i = 0; i <= maxent; i++) - { - /* rescale to [0..65535] then rgb bits */ - pmap->red[i].co.local.red = ((((i * 65535) / maxent) >> shift) - * 65535) / lim; - pmap->red[i].co.local.green = pmap->red[i].co.local.red; - pmap->red[i].co.local.blue = pmap->red[i].co.local.red; - } - } - return TRUE; -} - -/* When simulating DirectColor on PseudoColor hardware, multiple - entries of the colormap must be updated - */ - -#define AddElement(mask) { \ - pixel = red | green | blue; \ - for (i = 0; i < nresult; i++) \ - if (outdefs[i].pixel == pixel) \ - break; \ - if (i == nresult) \ - { \ - nresult++; \ - outdefs[i].pixel = pixel; \ - outdefs[i].flags = 0; \ - } \ - outdefs[i].flags |= (mask); \ - outdefs[i].red = pmap->red[red >> pVisual->offsetRed].co.local.red; \ - outdefs[i].green = pmap->green[green >> pVisual->offsetGreen].co.local.green; \ - outdefs[i].blue = pmap->blue[blue >> pVisual->offsetBlue].co.local.blue; \ -} - -int -fbExpandDirectColors (ColormapPtr pmap, - int ndef, - xColorItem *indefs, - xColorItem *outdefs) -{ - register int red, green, blue; - int maxred, maxgreen, maxblue; - int stepred, stepgreen, stepblue; - VisualPtr pVisual; - register int pixel; - register int nresult; - register int i; - - pVisual = pmap->pVisual; - - stepred = 1 << pVisual->offsetRed; - stepgreen = 1 << pVisual->offsetGreen; - stepblue = 1 << pVisual->offsetBlue; - maxred = pVisual->redMask; - maxgreen = pVisual->greenMask; - maxblue = pVisual->blueMask; - nresult = 0; - for (;ndef--; indefs++) - { - if (indefs->flags & DoRed) - { - red = indefs->pixel & pVisual->redMask; - for (green = 0; green <= maxgreen; green += stepgreen) - { - for (blue = 0; blue <= maxblue; blue += stepblue) - { - AddElement (DoRed) - } - } - } - if (indefs->flags & DoGreen) - { - green = indefs->pixel & pVisual->greenMask; - for (red = 0; red <= maxred; red += stepred) - { - for (blue = 0; blue <= maxblue; blue += stepblue) - { - AddElement (DoGreen) - } - } - } - if (indefs->flags & DoBlue) - { - blue = indefs->pixel & pVisual->blueMask; - for (red = 0; red <= maxred; red += stepred) - { - for (green = 0; green <= maxgreen; green += stepgreen) - { - AddElement (DoBlue) - } - } - } - } - return nresult; -} - -Bool -fbCreateDefColormap(ScreenPtr pScreen) -{ - unsigned short zero = 0, ones = 0xFFFF; - VisualPtr pVisual; - ColormapPtr cmap; - Pixel wp, bp; - - for (pVisual = pScreen->visuals; - pVisual->vid != pScreen->rootVisual; - pVisual++) - ; - - if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap, - (pVisual->class & DynamicClass) ? AllocNone : AllocAll, - 0) - != Success) - return FALSE; - wp = pScreen->whitePixel; - bp = pScreen->blackPixel; - if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) != - Success) || - (AllocColor(cmap, &zero, &zero, &zero, &bp, 0) != - Success)) - return FALSE; - pScreen->whitePixel = wp; - pScreen->blackPixel = bp; - (*pScreen->InstallColormap)(cmap); - return TRUE; -} - -extern int defaultColorVisualClass; - -#define _RZ(d) ((d + 2) / 3) -#define _RS(d) 0 -#define _RM(d) ((1 << _RZ(d)) - 1) -#define _GZ(d) ((d - _RZ(d) + 1) / 2) -#define _GS(d) _RZ(d) -#define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d)) -#define _BZ(d) (d - _RZ(d) - _GZ(d)) -#define _BS(d) (_RZ(d) + _GZ(d)) -#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d)) -#define _CE(d) (1 << _RZ(d)) - -#define MAX_PSEUDO_DEPTH 10 /* largest DAC size I know */ - -#define StaticGrayMask (1 << StaticGray) -#define GrayScaleMask (1 << GrayScale) -#define StaticColorMask (1 << StaticColor) -#define PseudoColorMask (1 << PseudoColor) -#define TrueColorMask (1 << TrueColor) -#define DirectColorMask (1 << DirectColor) - -#define ALL_VISUALS (StaticGrayMask|\ - GrayScaleMask|\ - StaticColorMask|\ - PseudoColorMask|\ - TrueColorMask|\ - DirectColorMask) - -#define LARGE_VISUALS (TrueColorMask|\ - DirectColorMask) - -typedef struct _fbVisuals { - struct _fbVisuals *next; - int depth; - int bitsPerRGB; - int visuals; - int count; - Pixel redMask, greenMask, blueMask; -} fbVisualsRec, *fbVisualsPtr; - -static const int fbVisualPriority[] = { - PseudoColor, DirectColor, GrayScale, StaticColor, TrueColor, StaticGray -}; - -#define NUM_PRIORITY 6 - -static fbVisualsPtr fbVisuals; - -static int -popCount (int i) -{ - int count; - - count = (i >> 1) & 033333333333; - count = i - count - ((count >> 1) & 033333333333); - count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */ - return count; -} - -/* - * Distance to least significant one bit - */ -static int -maskShift (Pixel p) -{ - int s; - - if (!p) return 0; - s = 0; - while (!(p & 1)) - { - s++; - p >>= 1; - } - return s; -} - -Bool -fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB, - Pixel redMask, Pixel greenMask, Pixel blueMask) -{ - fbVisualsPtr new, *prev, v; - - new = (fbVisualsPtr) malloc(sizeof *new); - if (!new) - return FALSE; - if (!redMask || !greenMask || !blueMask) - { - redMask = _RM(depth); - greenMask = _GM(depth); - blueMask = _BM(depth); - } - new->next = 0; - new->depth = depth; - new->visuals = visuals; - new->bitsPerRGB = bitsPerRGB; - new->redMask = redMask; - new->greenMask = greenMask; - new->blueMask = blueMask; - new->count = popCount (visuals); - for (prev = &fbVisuals; (v = *prev); prev = &v->next); - *prev = new; - return TRUE; -} - -Bool -fbHasVisualTypes (int depth) -{ - fbVisualsPtr v; - - for (v = fbVisuals; v; v = v->next) - if (v->depth == depth) - return TRUE; - return FALSE; -} - -Bool -fbSetVisualTypes (int depth, int visuals, int bitsPerRGB) -{ - return fbSetVisualTypesAndMasks (depth, visuals, bitsPerRGB, - _RM(depth), _GM(depth), _BM(depth)); -} - -/* - * Given a list of formats for a screen, create a list - * of visuals and depths for the screen which coorespond to - * the set which can be used with this version of fb. - */ - -Bool -fbInitVisuals (VisualPtr *visualp, - DepthPtr *depthp, - int *nvisualp, - int *ndepthp, - int *rootDepthp, - VisualID *defaultVisp, - unsigned long sizes, - int bitsPerRGB) -{ - int i, j = 0, k; - VisualPtr visual; - DepthPtr depth; - VisualID *vid; - int d, b; - int f; - int ndepth, nvisual; - int nvtype; - int vtype; - fbVisualsPtr visuals, nextVisuals; - - /* none specified, we'll guess from pixmap formats */ - if (!fbVisuals) - { - for (f = 0; f < screenInfo.numPixmapFormats; f++) - { - d = screenInfo.formats[f].depth; - b = screenInfo.formats[f].bitsPerPixel; - if (sizes & (1 << (b - 1))) - { - if (d > MAX_PSEUDO_DEPTH) - vtype = LARGE_VISUALS; - else if (d == 1) - vtype = StaticGrayMask; - else - vtype = ALL_VISUALS; - } - else - vtype = 0; - if (!fbSetVisualTypes (d, vtype, bitsPerRGB)) - return FALSE; - } - } - nvisual = 0; - ndepth = 0; - for (visuals = fbVisuals; visuals; visuals = nextVisuals) - { - nextVisuals = visuals->next; - ndepth++; - nvisual += visuals->count; - } - depth = (DepthPtr) malloc(ndepth * sizeof (DepthRec)); - visual = (VisualPtr) malloc(nvisual * sizeof (VisualRec)); - if (!depth || !visual) - { - free(depth); - free(visual); - return FALSE; - } - *depthp = depth; - *visualp = visual; - *ndepthp = ndepth; - *nvisualp = nvisual; - for (visuals = fbVisuals; visuals; visuals = nextVisuals) - { - nextVisuals = visuals->next; - d = visuals->depth; - vtype = visuals->visuals; - nvtype = visuals->count; - vid = NULL; - if (nvtype) - { - vid = (VisualID *) malloc(nvtype * sizeof (VisualID)); - if (!vid) - return FALSE; - } - depth->depth = d; - depth->numVids = nvtype; - depth->vids = vid; - depth++; - for (i = 0; i < NUM_PRIORITY; i++) { - if (! (vtype & (1 << fbVisualPriority[i]))) - continue; - visual->class = fbVisualPriority[i]; - visual->bitsPerRGBValue = visuals->bitsPerRGB; - visual->ColormapEntries = 1 << d; - visual->nplanes = d; - visual->vid = *vid = FakeClientID (0); - switch (visual->class) { - case PseudoColor: - case GrayScale: - case StaticGray: - case StaticColor: - visual->redMask = 0; - visual->greenMask = 0; - visual->blueMask = 0; - visual->offsetRed = 0; - visual->offsetGreen = 0; - visual->offsetBlue = 0; - break; - case DirectColor: - case TrueColor: - visual->ColormapEntries = _CE(d); - visual->redMask = visuals->redMask; - visual->greenMask = visuals->greenMask; - visual->blueMask = visuals->blueMask; - visual->offsetRed = maskShift (visuals->redMask); - visual->offsetGreen = maskShift (visuals->greenMask); - visual->offsetBlue = maskShift (visuals->blueMask); - } - vid++; - visual++; - } - free(visuals); - } - fbVisuals = NULL; - visual = *visualp; - depth = *depthp; - for (i = 0; i < ndepth; i++) - { - if (*rootDepthp && *rootDepthp != depth[i].depth) - continue; - for (j = 0; j < depth[i].numVids; j++) - { - for (k = 0; k < nvisual; k++) - if (visual[k].vid == depth[i].vids[j]) - break; - if (k == nvisual) - continue; - if (defaultColorVisualClass < 0 || - visual[k].class == defaultColorVisualClass) - break; - } - if (j != depth[i].numVids) - break; - } - if (i == ndepth) { - for (i = 0; i < ndepth; i++) - { - if (depth[i].numVids) - break; - } - if (i == ndepth) - return FALSE; - j = 0; - } - *rootDepthp = depth[i].depth; - *defaultVisp = depth[i].vids[j]; - return TRUE; -} diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index 7d930f0fe..c0cba2994 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -1094,7 +1094,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) const char *pointerMsg = NULL, *keyboardMsg = NULL; InputInfoPtr *devs, /* iterator */ indp; - InputInfoRec Pointer, Keyboard; + InputInfoRec Pointer = {}, Keyboard = {}; XF86ConfInputPtr confInput; XF86ConfInputRec defPtr, defKbd; int count = 0; diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c index 8ad7c2e79..24fe4ba0d 100644 --- a/xorg-server/hw/xfree86/parser/Monitor.c +++ b/xorg-server/hw/xfree86/parser/Monitor.c @@ -105,7 +105,6 @@ static xf86ConfigSymTabRec TimingTab[] = {TT_HSKEW, "hskew"}, {TT_BCAST, "bcast"}, {TT_VSCAN, "vscan"}, - {TT_CUSTOM, "CUSTOM"}, {-1, ""}, }; @@ -247,9 +246,6 @@ xf86parseModeLine (void) ptr->ml_vscan = val.num; ptr->ml_flags |= XF86CONF_VSCAN; break; - case TT_CUSTOM: - ptr->ml_flags |= XF86CONF_CUSTOM; - break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; @@ -370,9 +366,6 @@ xf86parseVerboseMode (void) case TT_DBLSCAN: ptr->ml_flags |= XF86CONF_DBLSCAN; break; - case TT_CUSTOM: - ptr->ml_flags |= XF86CONF_CUSTOM; - break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h index f8c9c3cde..bb7025dc4 100644 --- a/xorg-server/hw/xfree86/parser/xf86Parser.h +++ b/xorg-server/hw/xfree86/parser/xf86Parser.h @@ -119,7 +119,6 @@ XF86ConfModuleRec, *XF86ConfModulePtr; #define XF86CONF_NCSYNC 0x0100 #define XF86CONF_HSKEW 0x0200 /* hskew provided */ #define XF86CONF_BCAST 0x0400 -#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */ #define XF86CONF_VSCAN 0x1000 typedef struct diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h index 8c7ea1b28..d91755d7e 100644 --- a/xorg-server/hw/xfree86/parser/xf86tokens.h +++ b/xorg-server/hw/xfree86/parser/xf86tokens.h @@ -165,7 +165,6 @@ typedef enum { TT_HSKEW, TT_BCAST, TT_VSCAN, - TT_CUSTOM, /* Module tokens */ LOAD, diff --git a/xorg-server/hw/xquartz/bundle/Makefile.am b/xorg-server/hw/xquartz/bundle/Makefile.am index 3a09f7427..34598aa6a 100644 --- a/xorg-server/hw/xquartz/bundle/Makefile.am +++ b/xorg-server/hw/xquartz/bundle/Makefile.am @@ -12,7 +12,9 @@ install-data-hook: $(srcdir)/mk_bundke.sh $(srcdir) $(builddir) $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app install uninstall-hook: - $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app + $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Resources + $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Info.plist + $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/PkgInfo noinst_PRE = Info.plist.cpp noinst_DATA = $(noinst_PRE:plist.cpp=plist) diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c index e0c07809c..32bb49bf2 100644 --- a/xorg-server/hw/xwin/winmouse.c +++ b/xorg-server/hw/xwin/winmouse.c @@ -39,6 +39,7 @@ #include "inputstr.h" #include "exevents.h" /* for button/axes labels */ #include "xserver-properties.h" +#include "inpututils.h" /* Peek the internal button mapping */ static CARD8 const *g_winMouseButtonMap = NULL; -- cgit v1.2.3