aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickevents_p_p.h
Commit message (Collapse)AuthorAgeFilesLines
...
* | QQuickEventPoint::invalidate(): set m_pointId to zeroShawn Rutledge2016-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | One reason is that if event->pointById(someKnownId) returns true, a handler may assume that the point is still valid. So either pointById needs to check the valid flag, or we must reset the pointId so that it won't be found. Change-Id: I20e93f058737a77ed801f0148ab7525ab880902d Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | QQuickPointerEvent and EventPoint: add localize(QQuickItem *)Shawn Rutledge2016-09-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | During delivery we need to call QQuickItem::mapFromScene(point->scenePos()) so let's do it as early as possible and store the result right in the EventPoint. That way the pos() property can be made available, for the benefit of QML/JS signal handlers and also for C++ handlers. Change-Id: I2706ffd6bc51a449eeba64f69c9ffdfb913c5ca6 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | add QQuickEventPoint::sceneGrabPos propertyShawn Rutledge2016-08-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Some handlers need to track total movement of the points from the time that the gesture begins. So far it seems that will always be the same as the moment that the handler decides to grab; so it's enough to store a copy of the current position when the grab occurs. Also change setGrabber to call either setItemGrabber or setPointerHandlerGrabber so that we only need to add new features like this one in two places instead of three. Change-Id: Ia944bf27302fc305a21957e8b02174909c024a90 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | add QQuickEventPoint::scenePressPos propertyShawn Rutledge2016-08-261-0/+3
| | | | | | | | | | | | | | It's important for some handlers to track the total movement so far. Change-Id: If729c48731725aa035c32d203d719ea80df83078 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | QQuickEventPoint::reset: pass scenePos and velocity as const referencesShawn Rutledge2016-08-241-1/+1
| | | | | | | | | | Change-Id: Ife4dff906e17f92bcbfa2003ceb9f77e42cbb6ff Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | QQuickEventPoint::grabber: allow grabbing either an item or a handlerShawn Rutledge2016-08-231-8/+16
| | | | | | | | | | | | | | QQuickPointerHandler and QQuickItem have only QObject in common. Change-Id: I8fb68cc1779f42049db1e0eb5ff60019a1c674d3 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | add QQuickEventPoint::velocity propertyShawn Rutledge2016-08-231-1/+4
| | | | | | | | | | Change-Id: Ifc3fc767546fc8d18ebaba0a07a1143239c2e194 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
* | Make ctor and dtor of QQuickPointerDevice privateJan Arve Saether2016-08-181-13/+16
|/ | | | | | | | | Since its used in a Q_GLOBAL_STATIC which requires its type to have a public ctor, we have to delegate the ctor to a subclass (named ConstructableQQuickPointerDevice). Change-Id: I51932f16254f6ec6e512c78b280b307d6e0a300e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickEventPoint: replace Qt::TouchPointState with State enumShawn Rutledge2016-08-051-3/+12
| | | | | | | | This allows extension later on, and makes it clear that the state is for any kind of point, not just a touchpoint. Change-Id: I1f8aaa01ea65ac1731645129fedcf7a51ee66e77 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Remove silly newlinesFrederik Gladhorn2016-08-051-1/+0
| | | | | Change-Id: I35bd1aa524705c8c6541428b2737b992de2ad05d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove unused functionFrederik Gladhorn2016-08-051-1/+0
| | | | | Change-Id: I604fe1470bfab831e31d129d3b734213273fc333 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Move m_synthMouseEvent into TouchPointerEventFrederik Gladhorn2016-08-051-3/+6
| | | | | | | The mouse pointer event doesn't need it. Change-Id: I68999f79a0d979cf414b11a2e6b4863df1a1e817 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add missing Q_OBJECT macrosFrederik Gladhorn2016-08-041-0/+2
| | | | | Change-Id: I5f58f53a10b11906c1f784f1cab96ec761d8d588 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Merge branch 'dev' into wip/pointerhandlerFrederik Gladhorn2016-08-041-0/+8
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/quick/items/qquickwindow.cpp: we need the fix for QTBUG-31861 but now using QQuickPointerMouseEvent src/quick/items/qquickwindow_p.h: hover events need timestamps (e4f7ab42) tests/auto/quick/qquickwindow/tst_qquickwindow.cpp: added test for QTBUG-31861 Change-Id: Ic120513b69b318df3ba62d8174c276cbf6b7b55e
* | QQuickEvents: de-inline a few more functionsShawn Rutledge2016-08-041-25/+5
| | | | | | | | | | | | | | | | Touching this header results in rebuilding a lot of stuff, and these functions are likely to need further modification. Change-Id: Idc99255fc8e20a190c31b5e3d47dd005f4573434 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::timestampFrederik Gladhorn2016-08-031-0/+2
| | | | | | | | | | Change-Id: Ib2c99d25e5922c5146b82d1e00c9e97b621eaa81 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Pass pointer event into sendFilteredTouchEventFrederik Gladhorn2016-08-031-1/+1
| | | | | | | | | | Change-Id: Id8709b45af135df5f16558c4b611409bc134ea63 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Remove const of device getter in QQuickPointerEventFrederik Gladhorn2016-08-021-2/+2
| | | | | | | | | | | | | | Makes it possible to assign QQuickPointerDevice from the PointerEvent. Change-Id: Ica5182175eea210f5fe090807ed54467be11b031 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | add QQuickPointerEvent::setAccepted/isAccepted to avoid mouse/touch castingShawn Rutledge2016-08-021-0/+2
| | | | | | | | | | | | | | | | | | This makes deliverMouseEvent() slightly more generic: the only place we now care about it being a mouse event is to be able to call sendEvent() with the original event. Change-Id: Ibd1660bb45b6f8b3a5b9926aeb3dc85ff2e41d0f Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Stop copying mouse events when delivering themFrederik Gladhorn2016-08-021-1/+1
| | | | | | | | | | | | | | Reduce allocations of events, just refill the local pos. Change-Id: I2948faf0e302bff315e482f2c1432fe0def19bc5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Make QQuickEventPoint::grabber a QPointer internallyFrederik Gladhorn2016-07-311-4/+5
| | | | | | | | | | | | | | | | | | Accessing the grabbers was always dangerous. The present code only works because it iterates over all current QQuickItems and doesn't even try to deal with things being deleted inbetween. Change-Id: Id85791dcbd87ec8c5027f9c1376cb39e5779cabe Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::isPressEventFrederik Gladhorn2016-07-291-0/+3
| | | | | | | | | | Change-Id: Ied358da23baabfad7e1f75e48a459f1bd5425102 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Touch handling: remove acceptedNewPointsFrederik Gladhorn2016-07-261-1/+1
| | | | | | | | | | | | | | | | We keep track of the state inside the individual points, simplify the code. Change-Id: I6716f3ad9bc21ab066888a3b373719c5e4f30af2 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::unacceptedPressedPointScenePositionsFrederik Gladhorn2016-07-261-0/+1
| | | | | | | | | | Change-Id: Iecbd4e35faf733c6be84f760d4636d772188283c Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::unacceptedPointScenePositionsFrederik Gladhorn2016-07-261-0/+1
| | | | | | | | | | | | | | | | Returns a list of scene points for all points that have not been accepted yet. Change-Id: I218e0c779d236e1b5d7d16fe1537adf454b94035 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Keep track of grabbing inside QQuickEventPointFrederik Gladhorn2016-07-251-0/+4
| | | | | | | | | | | | | | | | | | With this we can get rid of "itemForTouchPointId" which kept track of the individual grabbing of touch points. The new approach allows big cleanups and makes understanding the code easier. Change-Id: I19f7cda1b430e088ada707b2e75d97ca8dbadcc5 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Initialize m_pointCount in QQuickPointerTouchEventFrederik Gladhorn2016-07-251-1/+1
| | | | | | | | | | Change-Id: Id9d602a4312db3877e21e449fcd2bbb3b58e1ced Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::grabbersFrederik Gladhorn2016-07-241-0/+3
| | | | | | | | | | | | | | Returns a list of all items that grabbed a point of the event before. Change-Id: Ifa7e6cc7486c4e1a7446a6bf3d4e62d19983ecf7 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Move mouseGrabberItem into the QQuickPointerEventFrederik Gladhorn2016-07-231-0/+4
| | | | | | | | | | | | | | | | The idea is to manage the "grab" for mouse and touch points inside the pointer event, instead of having awkward extra state in the window. Change-Id: I4011c66c163159b0315bf8e284d8e1c7c460f108 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Use Q_GLOBAL_STATIC instead of static members of QWindowPrivateJan Arve Saether2016-07-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | Having the members static in QWindowPrivate only gives the benefit of tidyness, but there's still the problem of initialization order and thread-safety. Q_GLOBAL_STATIC solves those issues for us. Change-Id: I8e1279959d0bb2b16fd720cb7f4e9afb6eda6355 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Improve encapsuation of touch/mouse event specific thingsFrederik Gladhorn2016-07-211-8/+16
| | | | | | | | | | | | | | This makes it easy to avoid casts when using the classes. Change-Id: I27bd1244bffb3a7d2cdb4572c229333e4c499d9b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Hierarchy for touch and mouse pointer eventsFrederik Gladhorn2016-07-211-31/+69
| | | | | | | | | | Change-Id: Ie84e39918d9657b29df697be7b0e5198298c48ba Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Move forward declarations to the top of the headerFrederik Gladhorn2016-07-191-3/+3
| | | | | | | | | | Change-Id: I58af7a1603bca3a17713e4cb674ae004e2d6eda9 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | add QDebug operators for QQuickPointerEvent, Point and DeviceShawn Rutledge2016-07-191-0/+5
| | | | | | | | | | Change-Id: I25c521856cd6d73daeddacb4ae998e4de9109448 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickEventPoint: be a QObject-child of QQuickPointerEventShawn Rutledge2016-07-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | The points are conceptually children, so this will help take care of memory management. It's also useful to be able to emit or pass a QQuickEventPoint without losing the context of the event it came from. To this end, a pointerEvent() accessor is added, which simply does the static_cast for you. Change-Id: I71e57655cf1a0e7d741c4099c7eb9fc3a9a76446 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Merge remote-tracking branch 'origin/dev' into HEADFrederik Gladhorn2016-07-181-0/+17
|\| | | | | | | Change-Id: I931a7b264c68c40e16d9467b48173311aef74bd0
| * move QQuickCloseEvent from qquickwindow_p.h to qquickevents_p_p.hShawn Rutledge2016-07-151-0/+17
| | | | | | | | | | | | | | It seems to be the same sort of persistent event for exposure to QML. Change-Id: I4ebc48422ee517f37e300629b6d100f68b9703b3 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Be consistent about constFrederik Gladhorn2016-07-151-2/+2
| | | | | | | | | | | | | | | | The functions should be const, but the returned point not. This allows accepting the points. Change-Id: Iedbe8f3be38d672b33eea352f959b6e2bb6bc4fc Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::allPointsAcceptedFrederik Gladhorn2016-07-151-0/+1
| | | | | | | | | | | | | | | | Convenience method to decide if the event is completely accepted or further delivery makes sense. Change-Id: I389a975cca2966962848203f69ec7f2e307a210a Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickWindow: keep a collection of devices which own event instancesShawn Rutledge2016-07-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | That will allow the event instances to hold state, even between events. So now every QQuickWindow has its own set of them, per device. Hopefully that means we won't have any trouble delivering events in parallel in case each window has its own thread. Otherwise maybe it's slightly wasteful in multi-window apps. Change-Id: I766b580e1c177255905cc04b5de7d33ae503c6fd Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | qquickevents_p_p.h: move declaration of device below QQuickPointerEventShawn Rutledge2016-07-151-86/+87
| | | | | | | | | | | | | | | | In a following patch, the device will own the event instance by value, so it needs to be defined first. Change-Id: Id1520257115889198c3e9ff20c56028c0b6d4bd2 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickEventPoint: keep the timestamps, remember when pressedShawn Rutledge2016-07-151-5/+13
| | | | | | | | | | | | | | Some handlers will care for how long the point has been held so far. Change-Id: I390d92988619054918fcdecd4b092ca9b4cfdea0 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickEventPoint *QQuickPointerEvent::pointById(int)Shawn Rutledge2016-07-151-0/+1
| | | | | | | | | | Change-Id: Id6a41545036b7fe37d5b486789f77642a4241d9a Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Add QQuickPointerEvent::syntheticMouseEventFrederik Gladhorn2016-07-151-1/+5
| | | | | | | | | | | | | | It makes it easier to send synthetic mouse events for touch. Change-Id: Ibb8e2737e3245ae7438708aa170ec1f888e770d8 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickPointerDevice::CapabilityFlag: enforce sync with QTouchDeviceShawn Rutledge2016-07-141-4/+4
| | | | | | | | | | | | | | | | The first few values in QQuickPointerDevice::CapabilityFlag must be kept in sync with QTouchDevice::CapabilityFlag, so make it explicit. Change-Id: I0c1147319e057df26a8a732a4e494b762a1f5301 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickPointerEvent: cleanup of docs and file organizationFrederik Gladhorn2016-07-131-27/+9
| | | | | | | | | | | | Change-Id: I104edaabc35a073e14e8c66cd268ecd3782ed361 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickPointerEvent: store pointCount separatelyFrederik Gladhorn2016-07-131-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 649b309ea9ed7d03aa74565d51edb416c23460d9 it was correct that the pool did not need to be static, because the whole event is a singleton; but it allowed the actual m_touchPoints vector to keep growing, rather than resizing to the current number of points. When one finger is pressed, then two, then one is released, pointCount must go from 1 -> 2 -> 1. And yet we'd like to avoid heap-allocating a fresh QQuickEventTouchPoint object every time a touchpoint is pressed. The choices are then to 1) exploit implementation details of QVector to allow its count() to be different than its stored size but still guarantee that every pointer it stores points to a long-lived QQuickEventTouchPoint (the docs do say "Since Qt 5.6, resize() doesn't shrink the capacity anymore"), which is what we thought we were doing; 2) store the pointCount in a separate variable, so that the prefix of m_touchPoints are the valid ones while the remainder is the "pool", or 3) hold a separate reusable pool of touchpoints. The separate m_pointCount is cheaper than the pool, so let's go with option 2. Change-Id: Ic59b5393e9f4b05e4ec27db15d6f06253aa820d5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | QQuickPointerEvent: make bool test functions public; use for bool testsShawn Rutledge2016-07-131-9/+7
| | | | | | | | | | | | | | Maybe if (isTouchEvent()) is more efficient than if (asTouchEvent()). Change-Id: Ie3e216ff5c9b512abc4a25690f98cb948e8b5399 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Don't store Qt::TouchPointState in 4 bitsShawn Rutledge2016-07-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | It's not enough on Windows: it gets sign-extended, so 0x08 becomes -8 as an int, in comparisons. The result was that touchpoints were never released. Anyway we hardly have to worry about this now that we're not copying the event points. Change-Id: I0d47a0974a9cf5bc9a090a15948d112df32403eb Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | add QQuickPointerEvent::touchEventForItemShawn Rutledge2016-07-121-1/+9
| | | | | | | | | | | | | | | | | | It's similar to QQuickWindowPrivate::touchEventWithPoints(), and is used in the same way when delivering a QQuickPointerEvent by sending a QTouchEvent to the item's event() method. Change-Id: I0d181eaf924bfdad2db2de9d8acf85d0345aec3e Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>