Commit a2f89b40e54e2abc854af42453160488ff22499f
- Diff rendering mode:
- inline
- side by side
src/wcmXCommand.c
(32 / 23)
|   | |||
| 304 | 304 | if (property == prop_tablet_area) | |
| 305 | 305 | { | |
| 306 | 306 | INT32 *values = (INT32*)prop->data; | |
| 307 | WacomToolArea area; | ||
| 307 | WacomToolAreaPtr area = priv->toolarea; | ||
| 308 | 308 | ||
| 309 | 309 | if (prop->size != 4 || prop->format != 32) | |
| 310 | 310 | return BadValue; | |
| 311 | 311 | ||
| 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; | ||
| 316 | 319 | ||
| 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]; | ||
| 320 | 324 | ||
| 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 | |||
| 321 | 334 | if (!checkonly) | |
| 322 | 335 | { | |
| 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)) | ||
| 325 | 338 | { | |
| 326 | 339 | values[0] = 0; | |
| 327 | if (!IsTouch(priv)) | ||
| 340 | values[1] = 0; | ||
| 341 | if (!IsTouch(priv)) | ||
| 328 | 342 | values[2] = common->wcmMaxX; | |
| 329 | else | ||
| 343 | else | ||
| 330 | 344 | 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)) | ||
| 337 | 346 | values[3] = common->wcmMaxY; | |
| 338 | else | ||
| 347 | else | ||
| 339 | 348 | values[3] = common->wcmMaxTouchY; | |
| 340 | 349 | } | |
| 341 | 350 | ||
| 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]; | ||
| 346 | 355 | xf86WcmInitialCoordinates(local, 0); | |
| 347 | 356 | xf86WcmInitialCoordinates(local, 1); | |
| 348 | 357 | } |

