Commit a2f89b40e54e2abc854af42453160488ff22499f

  • avatar
  • Peter Hutterer <peter.hutterer @wh…t.net> (Committer)
  • Tue Dec 22 05:01:47 CET 2009
  • avatar
  • Ping Cheng <pingc @wa…m.com> (Author)
  • Tue Dec 22 01:52:28 CET 2009
Remove area overlap check for area property

Temporarily change the area to the new coordinates, do the range overlap
check and then change it back to the original. This is needed since
otherwise the area overlap check always fails (since the new area will be
mostly identical to the current one).

New behaviour: all four coordinates set to -1 reset the area to the
defaults.

Signed-off-by: Ping Cheng <pinglinux@gmail.com>
  
304304 if (property == prop_tablet_area)
305305 {
306306 INT32 *values = (INT32*)prop->data;
307 WacomToolArea area;
307 WacomToolAreaPtr area = priv->toolarea;
308308
309309 if (prop->size != 4 || prop->format != 32)
310310 return BadValue;
311311
312 area.topX = values[0];
313 area.topY = values[1];
314 area.bottomX = values[2];
315 area.bottomY = values[3];
312 /* value validation is unnecessary since we let utility programs, such as
313 * xsetwacom and userland control panel take care of the validation role.
314 * when all four values are set to -1, it is an area reset (xydefault) */
315 if ((values[0] != -1) || (values[1] != -1) ||
316 (values[2] != -1) || (values[3] != -1))
317 {
318 WacomToolArea tmp_area = *area;
316319
317 /* FIXME: this will always be the case? */
318 if (WcmAreaListOverlap(&area, priv->tool->arealist))
319 return BadValue;
320 area->topX = values[0];
321 area->topY = values[1];
322 area->bottomX = values[2];
323 area->bottomY = values[3];
320324
325 /* validate the area */
326 if (WcmAreaListOverlap(area, priv->tool->arealist))
327 {
328 *area = tmp_area;
329 return BadValue;
330 }
331 *area = tmp_area;
332 }
333
321334 if (!checkonly)
322335 {
323 /* Invalid range resets axis to defaults */
324 if (values[0] >= values[2])
336 if ((values[0] == -1) && (values[1] == -1) &&
337 (values[2] == -1) && (values[3] == -1))
325338 {
326339 values[0] = 0;
327 if (!IsTouch(priv))
340 values[1] = 0;
341 if (!IsTouch(priv))
328342 values[2] = common->wcmMaxX;
329 else
343 else
330344 values[2] = common->wcmMaxTouchX;
331 }
332
333 if (values[1] >= values[3])
334 {
335 values[1] = 0;
336 if (!IsTouch(priv))
345 if (!IsTouch(priv))
337346 values[3] = common->wcmMaxY;
338 else
347 else
339348 values[3] = common->wcmMaxTouchY;
340349 }
341350
342 priv->topX = values[0];
343 priv->topY = values[1];
344 priv->bottomX = values[2];
345 priv->bottomY = values[3];
351 priv->topX = area->topX = values[0];
352 priv->topY = area->topY = values[1];
353 priv->bottomX = area->bottomX = values[2];
354 priv->bottomY = area->bottomY = values[3];
346355 xf86WcmInitialCoordinates(local, 0);
347356 xf86WcmInitialCoordinates(local, 1);
348357 }