const int hostPosDiffX = hostPos.x() - grabTouchPoint->getHostPos().x();
const int hostPosDiffY = hostPos.y() - grabTouchPoint->getHostPos().y();
- /* bounds checking */
- // TODO:
+ /* out of bounds checking */
+ const QRect screenRect(QPoint(0, 0),
+ ((DisplayBase *)parent->getParent())->getGeometry().size());
+ const QRegion screenRegion =
+ ((DisplayBase *)parent->getParent())->getMask();
+
+ for (int i = 0; i < touchPointList.count(); i++) {
+ point = touchPointList.at(i);
+ if (point != NULL) {
+ if (screenRegion.isNull() == false &&
+ screenRegion.contains(QPoint(
+ point->getHostPos().x() + hostPosDiffX,
+ point->getHostPos().y() + hostPosDiffY)) == false) {
+ /* do nothing */
+ return;
+ } else if (screenRect.contains(
+ point->getHostPos().x() + hostPosDiffX,
+ point->getHostPos().y() + hostPosDiffY, false) == false) {
+ /* do nothing */
+ return;
+ }
+ }
+ }
/* move whole touch points */
for (int i = 0; i < touchPointList.count(); i++) {
point = touchPointList.at(i);
if (point != NULL) {
- QPoint hostMovedPos(
+ const QPoint hostMovedPos(
point->getHostPos().x() + hostPosDiffX,
point->getHostPos().y() + hostPosDiffY);
- QPoint guestMovedPos =
+ const QPoint guestMovedPos =
((DisplayBase *)parent->getParent())->getGuestPos(hostMovedPos);
point->updatePos(hostMovedPos, guestMovedPos);
virtio_touchscreen_event(guestPos.x(), guestPos.y(),
grabTouchPoint->getID() - 1, 1);
- /* bounds checking */
- // TODO:
+ /* out of bounds checking */
+ const QRect screenRect(QPoint(0, 0),
+ ((DisplayBase *)parent->getParent())->getGeometry().size());
+ const QRegion screenRegion =
+ ((DisplayBase *)parent->getParent())->getMask();
+
+ for (int i = 0; i < touchPointList.count(); i++) {
+ point = touchPointList.at(i);
+ if (point != NULL && point != grabTouchPoint) {
+ if (screenRegion.isNull() == false &&
+ screenRegion.contains(QPoint(
+ point->getHostPos().x() - hostPosDiffX,
+ point->getHostPos().y() - hostPosDiffY)) == false) {
+ /* do nothing */
+ return;
+ } else if (screenRect.contains(
+ point->getHostPos().x() - hostPosDiffX,
+ point->getHostPos().y() - hostPosDiffY, false) == false) {
+ /* do nothing */
+ return;
+ }
+ }
+ }
/* move other points */
for (int i = 0; i < touchPointList.count(); i++) {
point = touchPointList.at(i);
if (point != NULL && point != grabTouchPoint) {
- QPoint hostMovedPos(
+ const QPoint hostMovedPos(
point->getHostPos().x() - hostPosDiffX,
point->getHostPos().y() - hostPosDiffY);
- QPoint guestMovedPos =
+ const QPoint guestMovedPos =
((DisplayBase *)parent->getParent())->getGuestPos(hostMovedPos);
point->updatePos(hostMovedPos, guestMovedPos);