summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qioseventdispatcher.mm
Commit message (Collapse)AuthorAgeFilesLines
* iOS: Improve logging during application startupTor Arne Vestbø2017-11-291-5/+7
| | | | | Change-Id: I15c1980d7c532c94b34e612bb781c8ed5bf096a0 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* iOS: Deliver all QWindowSystemInterface events synchronouslyTor Arne Vestbø2017-11-281-0/+2
| | | | | | | | | | | | | | | | | | | | | On iOS we want all delivery of events from the system to be handled synchronously, as that's what the system expects. We don't need to add a delivery template argument to each function in QWindowSystemInterface that we want to delivery synchronously; that's only needed for functions that a platform normally sends asynch, but in some cases want to delivery synchronously. For always delivering events synchronously we just need to change the default delivery method. The only events affected by this are the screen changes, and window state change, which were not synchronous before, but should be. All other events were already synchronous, though either explicit delivery, of a flush. Change-Id: Ib20ca342d1c076be0fbcf018c83735a416769cfe Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Factor out usage of a private symbol by the iOS platform plugin.Jake Petroules2016-02-191-1/+1
| | | | | | | | This fixes a link error due to symbol visibility when the iOS platform plugin is built as a shared library. Change-Id: I0b454c5c5033c6b598cede11ce5e3a85e5704c4a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Use Q_UNLIKELY for every qFatal()/qCritical()Marc Mutz2015-11-291-2/+2
| | | | | | | | | | | | | | | | | | | | | If, after checking a condition, we issue a qFatal() or a qCritical(), by definition that check is unlikely to be true. Tell the compiler so it can move the error handling code out of the normal code path to increase the effective icache size. Moved conditional code around where possible so that we could always use Q_UNLIKELY, instead of having to revert to Q_LIKELY here and there. In some cases, simplified the expressions newly wrapped in Q_UNLIKELY as a drive-by. Change-Id: I67537d62b04bc6977d69254690c5ebbdf98bfd6d Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Make the CoreFoundation event dispatcher depend on QtCore onlyMorten Johan Sørvig2015-10-131-0/+21
| | | | | | | | | | In anticipation of moving it to QtCore. The call to QWindowSystemInterface::sendWindowSystemEvents() has been moved to QIOSEventDispatcher by making processPostedEvents() virtual. Change-Id: I9e03be4153a9f5f34e9a0ac942cdff572a44c318 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* iOS: Use LC_MAIN to wrap user main() instead of mangling object filesTor Arne Vestbø2015-06-291-14/+3
| | | | | | | | | | | | | | | | With iOS 6.0 and above the LC_MAIN load command is available, which allows dyld to call the application entrypoint directly instead of going through _start in crt.o. By passing -e to the linker we can change this entrypoint to our wrapper that sets up the separate stack before entering the native iOS runloop through UIApplicationMain. As before, we call the user's main() from applicationDidFinishLaunching. By using LC_MAIN instead of messing with the object files we open up the possibility of generating Bitcode instead of object code, which can be useful for link-time optimizations, either locally or by Apple. Change-Id: If2153bc919581cd93dfa10fb6ff1c305b3e39a52 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
* iOS: Clean up style in Objective-C message signaturesTor Arne Vestbø2015-05-241-3/+3
| | | | | | | | | | - Space between class/instance signifier - No space between return type and message name - No space in message arguments Change-Id: Ie25e0be3c134586c44bb82bf7075f6eb153388a9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
* iOS: Only use root level native runloop if at first level of processEventsTor Arne Vestbø2015-03-101-12/+8
| | | | | | | | | | | | | | | We used to support calling QEventLoop::exec() from within a processEvent recursion and still jump down to the root native runloop, but this does not work as intended due to how QEventDispatcherCoreFoundation uses flags in its ProcessEventsState for e.g. deferred wake up or timer updates. The logic in QEventDispatcherCoreFoundation assumes that the next recursion to processEvents will be handled by itself, so that it can interpret the flags in ProcessEventsState. The iOS event dispatcher subclass, QIOSEventDispatcher, does neither of these things, and should only be used from a 'clean' state. Change-Id: I44fa156feecc45772806002465c35bef0797ead2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
* Fixed license headersJani Heikkinen2015-02-171-1/+1
| | | | | Change-Id: Ibebe1318d1c2de97601aa07269705c87737083ee Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-22/+14
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* iOS: Update integrated event dispatcher to support 64-bit x86Tor Arne Vestbø2014-11-051-2/+7
| | | | | | | | | Needed so that we can build simulator builds for x86_64 as well as i386. The function call alignment is the same, but we need to use the 64-bit versions of the instruction and operands. Change-Id: I62cc78e23b5e0923382d19570ce18f558894e6a0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* iOS: update qtmn doc to use the actual function nameRichard Moe Gustavsen2014-10-271-3/+3
| | | | | Change-Id: I62b656a317298ec40117017d74fca1be262a66b7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: Make room for zero-terminator when building argv from NSProcessInfoTor Arne Vestbø2014-10-251-2/+8
| | | | | | | | | | | | [NSString lengthOfBytesUsingEncoding] only returns the number of bytes required for the actual string, not including the zero terminator, so when we then used cStringUsingEncoding to fill the malloced buffer with data, we overwrote the byte after our buffer with 0, resulting in random and hard to reproduce crashes at application startup, seemingly depending on the application name. Change-Id: I35d261bea5924e917475b0270bfa280bfb0c787a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Use in-place string renaming to rename main() instead of ldTor Arne Vestbø2014-01-061-2/+2
| | | | | | | | | | | | | | | Processing the object file with ld strips away debug information for the main() function, resulting in the debugger not being able to break on specific lines of the function. It also causes issues when externing sybols in main's object file. We revert back to the approach of using the strings in-line in the object file (which is why we keep the name the same length, 'qtmn'). Task-number: QTBUG-35553 Change-Id: I8b0acee36f48ecfefa2e4fd008a842365713d985 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* iOS: move infoPlistValue to qiosglobalRichard Moe Gustavsen2013-12-041-7/+0
| | | | | Change-Id: If237f08683290105413dc47923e23a496765bb22 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: Fix logic for determining whether to exit the root event loopTor Arne Vestbø2013-10-301-30/+8
| | | | | | | | | | | | | | | Instead of trying to hook into various places where we might be in a situation where the root event loop should exit, and then enabling the runloop-observer, we always keep the observer active, and then do the relevant checks whenever the run-loop exits. The reason for checking if the event loop is running is that iOS will enter and exit the root runloop as part of normal operation, eg due to flicking a scroll view and switching the runloop mode, so we need to ensure that we're actually supposed to exit the root event loop. Change-Id: I9b84b47ee45e0c9e2b1d2ebb5a432ea92700b324 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Wrap user's main by renaming symbol and relying on weak linkingTor Arne Vestbø2013-10-171-3/+14
| | | | | | | | | | | | | | | This approach is similar to the earlier apprach of defining main=qt_main when building the user's sources, but uses the linker to rename the symbol instead, which is less fragile than using the preprocessor. To keep the hybrid usecase unaffected by our wrapper logic we declare both our main wrapper and a fallback qt_main as weak symbols, which ensures that when the user's application links in our plugin the real main/qt_main provided by the user is preferred over our weak symbols. Change-Id: Ic76f3ba8932430c4b13a1d3a40b8ed2322fe5eea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* iOS: Mark argument as unused for release buildsTor Arne Vestbø2013-10-171-0/+1
| | | | | Change-Id: I73497a6c16236f912646c9fbe9b136ff760ce4f7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Generalize jumping event-dispatcher to handle QEventLoop:exec()Tor Arne Vestbø2013-10-091-36/+30
| | | | | | | | | | | | | | | | | | | | | We already supported re-entering QApplication::exec(), so adding support for handling a generalized QEventLoop::exec() was nothing more than removing the qApplication->in_exec condition in processEvents() and the QThreadData::current()->quitNow condition when interrupting the event loop. Everything else is just renaming and rewording, now that the feature is not specific to QApplication::exec(). This means dialogs such as QFileDialog opened in the main() function will show something on screen, as we then fall back to the iOS root run-loop handling, while at the same time supporting QApplication exec once the dialog closes. We still don't hadle recursive QEventLoop:exec() at the root level, as that would require multiple stacks and detailed application knowledge about when to create them. Change-Id: I334a362d85796341a343ce82f3104ff5866bdc3f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Handle qApp re-exec after application termination from iOS' sideTor Arne Vestbø2013-10-091-2/+13
| | | | | | | | | If the user for some reason spins a new QApplication event loop after an initial one has been exited as a result of the application being terminated by iOS we need to prevent further event loops from starting. Change-Id: Ief8a69cebacebd5be63a1aca87a2a1babc809879 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* iOS: Use PROT_READ, not PROT_NONE, for custom stack memory guardTor Arne Vestbø2013-10-031-1/+3
| | | | | | | | | This allows V4 and other garbage collectors to pass through our custom stack during the mark-phase without triggering access violations. Change-Id: Icafcf4df3537c628c641fe694bb9fe2016519a83 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* iOS: Interleave Qt application main() with iOS startup sequenceTor Arne Vestbø2013-09-131-0/+522
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our previous event loop integration had two unfortunate flaws: 1. We would call qt_user_main() from a timer, after returning from didFinishLaunchingWithOptions. This had the effect of showing the iOS application window long before the Qt application UI had been set up, resulting in a 1-2 second flash of black/pink between the launch image disappearing and the actual application showing. 2. We spun a nested event loop, where our implementation of the different event loop modes did not perfectly match the Apple implementation. This resulted in scrolling being busted in some cases such as when showing the virtual keyboard for Emoji characters. These two issues have now been solved by calling the user's main() from didFinishLaunchingWithOptions. Normally this would not work, as the user's main would call QApplication::exec() at the end of their main(), which would block and we would never return back from the didFinishLaunchingWithOptions callback, resulting in no UI on screen. We work around this by longjmp'ing out of QApplication::exec(), back into didFinishLaunchingWithOptions, so that it can return. Again, this would normally not work, as the call stack where QApplication and friends would live would get smashed as the application continued executing. We work around this by allocating a block of stack space at the start of main(), which we then redirect the stack pointer to before calling the user's main. This results in the whole stack of the user's main() and below being preserved, even if we longjmp out of the call stack (which then restores the stack pointer). This approach should work fine together with garbage-collection as well, since the mark-and-sweep phase will walk the stack from the stack pointer to the stack base, including sections of the stack that were part of qt_user_main() and live in the reserved area. One case where GC will fail though is if it happens as part of the qt_user_main() call, where the GC will not mark anything in the 'real' callstack below UIApplicationMain(), but this is not expected to happen. The size of the reserved stack can be controlled through the Info.plist key 'QtRunLoopIntegrationStackSize', as well as the 'QtRunLoopIntegrationDisableSeparateStack' key to disable the separate stack approach completely. This will fall back to the old approach. The amount of stack space used by the user's main can be determined by enabling a special debugging mode, using the 'QtRunLoopIntegrationDebugStackUsage' key. Change-Id: I2af7a6cfe1a006a80fd220ed83d8a66d4c45b523 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move iOS event dispatcher from platform plugin to platform support.Ian Dean2013-06-131-322/+0
| | | | | | | | Move iOS event dispatcher from platform plugin to platform support, so that it can be used by multiple iOS platform plugins. Change-Id: I9041b2de5e00e5fe8f30af2dfd922b4f5c594802 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: Implement socket notifiers.Morten Johan Sørvig2013-02-271-4/+6
| | | | | | | | | | | | | | | Create the QCFSocketNotifier class in platform support which contains shared socket notifier support for the Cocoa and iOS plugins. Remove the old code from the Cocoa plugin. The Cocoa code had one QCocoaEventDispatcher-specific call: maybeCancelWaitForMoreEvents. Create a forwarding function that is passed to QCFSocketNotifier. Change-Id: Ibf9bd4745ba4f577a55f13d0cc00f5ae04447405 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: remove warning from unused function in QIOSEventDispatcherRichard Moe Gustavsen2013-02-271-1/+1
| | | | | | | | From the documentation for QAbstractEventDispatcher::flush(), this function does only make sense for X11. Change-Id: I7f445b67b283f60c9a30ac00837beb44e8205d8b Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* iOS: Ensure UIApplicationMain is started before QApplication by wrapping main()Tor Arne Vestbø2013-02-271-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the typical Qt app the developer will have an existing main() that looks something like: int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); return app.exec(); } To support this, we provide our own 'main' function in the qtmain static library that we link into the application, which calls UIApplicationMain and redirects to the 'main' function of the application after the event loop has started spinning. For this to work, the applications 'main' function needs to manually be renamed 'qt_main' for now. In a later patch, this renaming will happen automatically by redefining main from either a header file, or more likely, from the Makefile created by qmake. For the case of an iOS developer wanting to use Qt in their existing app the main will look something like: int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } This is supported right now by just linking in libqios.a without libqiosmain.a. QGuiApplication should then be created e.g inside the native apps application delegate (but QGuiApplication::exec should not be called). In the future, we plan to but use a wrapper library that brings in all the Qt dependencies into one single static library. This library will not link against qtmain, so there won't be a symbol clash if the -ObjC linker option is used. We should then add the required magic to the future Objective-C convenience wrapper for QML to bring up a QGuiApplication, which would allow using Qt from storyboards and NIBs. This would also be the place to inject our own application delegate into the mix, while proxying the delegate callbacks to the user's application delegate. Change-Id: Iba5ade114b27216be8285f36100fd735a08b9d59 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: support stand-alone qApp->processEvents callsRichard Moe Gustavsen2013-02-271-2/+7
| | | | | | | | Rough implementation to support stand-alone processEvent calls. We probably need to revisit this code to fix corner-cases later on. Change-Id: I72d5639dab599b4d0017aaa52b922f4185a50337 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: implement QEventLoop support in the event dispatcherRichard Moe Gustavsen2013-02-271-2/+6
| | | | | | | | | | | With this patch you can now expect the following code to work: QEventLoop l; QTimer::singleShot(1000, &l, SLOT(quit())); l.exec(); Change-Id: Ic73e37affaadf8a859787d84ac02c15621ac7a29 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: support killing timersRichard Moe Gustavsen2013-02-271-12/+42
| | | | | | | Implement the remaining timer functions in the event dispatcher Change-Id: Ie323962c898a2ee95ea60a8ca63b93cbd4544fd1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: call UIApplicationMain from event dispatcher, and add application delegateRichard Moe Gustavsen2013-02-271-36/+22
| | | | | | | | | This change will let you call QApplication::exec() instead of UiApplicationMain from main. Also added an application delegate that we will need sooner or later for catching application activation events. Change-Id: I4edba5ce2059a804782d67c160755fc0e2e5267d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: QIOSEventDispatcher: implement timer supportRichard Moe Gustavsen2013-02-271-17/+119
| | | | | Change-Id: I1966a64e6535f32005681db37b4fe5d89dafc70c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: QIOSEventDispatcher: add runloop source for processing eventsRichard Moe Gustavsen2013-02-271-6/+55
| | | | | Change-Id: I6cd649a493dab9a982d71921f19d2a9252fc14b0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: fix build issue, dont link against cocoaRichard Moe Gustavsen2013-02-261-1/+1
| | | | | | | | | Make sure the libraries dont depend on Cocoa. This will be picked up by libtool, and make all apps and examples link against cocoa too (which will ofcourse fail) Change-Id: I5654bb08c4ed376fc7ee74da422d903270a8af38 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* iOS: copy brute-force port of Qt4 uikit plugin into Qt5.Richard Moe Gustavsen2013-02-261-0/+154
The plugin has been renamed from uikit to ios. Other than that, the plugin will now build, but do nothing. Most of the Qt4 code is preserved, with a rough translation into the Qt5 qpa API. A lot of code has simply been commented out so far, and most lacking at the moment is the event dispatcher which will need to be rewritten, and the opengl paint device implementation. But it should suffice as a starting ground. Also: The plugin will currently not automatically build when building Qt, this needs to be enabled from configure first. Change-Id: I0d229a453a8477618e06554655bffc5505203b44 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>