summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Move QCocoaGLContext initialization into dedicated methodTor Arne Vestbø2019-07-173-7/+15
| | | | | Change-Id: I9dc2c400c3d26e9fcfaac04b61c1503229f59dba Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fix warnings as errors on macOS with new Xcode 10.2.1Alexandru Croitor2019-07-121-4/+4
| | | | | | | | | A switch statement was comparing enum values of a different enum. Change-Id: I578f79b15b1007afaa64cd3a2a80d6a75d3bed77 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
* macOS: show QSystemTrayIcon message icons in notification popupsVolker Hilsheimer2019-07-111-1/+6
| | | | | | | | | | | | | | | The icon provided was ignored, even though NSUserNotification provides the option to specify a contentImage. The message popping up will show that image on the right side of the notification; it will not repace the application icon on the left side. [ChangeLog][Widgets][QSystemTrayIcon] On macOS, show the icon passed into showMessage in the notification popup Change-Id: I8ecda7f893006e74a4f35f37ddc07063ebfe4e83 Fixes: QTBUG-76916 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: lower the splash screen when a modal dialog blocks itVolker Hilsheimer2019-06-261-0/+19
| | | | | | | | | | | | | | This fixes the usability issue of a modal dialog showing up behind a splash screen, not visible to the user, but blocking user input and the application startup sequence until discarded. [ChangeLog][QtWidgets][QSlashScreen] On macOS, lower the splash screen when a modal dialog is shown to make sure the user sees the dialog. Change-Id: Ibae768f76909d930cb25dcf5cee31edc5f15c29a Fixes: QTBUG-49576 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* NSMenuItem/NSMenu - set the submenu properlyTimur Pocheptsov2019-06-214-0/+24
| | | | | | | | | | | | | | | | | | ... in case the submenu is set from a slot, attached to the aboutToShow() signal. Normally, with a 'statically' pre-populated menu, we set 'submenu' property on a menu item from 'updateItem' callback in our menu delegate. After that, AppKit calls our delegate's willOpen call back and this is where we emit 'aboutToShow'. Unfortunately, if an application tries to create a nested menu 'dynamically' at this point, it never becomes 'submenu' of the item, since 'updateItem' was already handled at this point. We catch this case in QCocoaMenuItem and call setAttachedItem if needed. Fixes: QTBUG-76060 Change-Id: I676bf1d8529b9ddbfc90e4dff422b39668b7a5fa Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: prevent duplicate backing store scalingMorten Johan Sørvig2019-06-191-2/+3
| | | | | | | | | | | | | | m_requestedSize is already scaled by the QtGui scale factor (e.g. as set by QT_SCALE_FACTOR). Multiplying by QWindow::devicePixelRatio() then applies this factor again. Use QPlatformWindow::devicePixelRatio() instead, which returns the platform scale factor. Change-Id: I133e99d84f4718215fda9ef0cf81a113b51db2c7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Invalidate window shadow after QNSWindowBackingStore resizeTor Arne Vestbø2019-06-183-10/+30
| | | | | | | | | | | The window shadow rendered by AppKit is based on the shape/content of the NSWindow surface. If the backingstore is partially transparent, we need to invalidate the window shadow after each resize (and subsequent flush) of the backingstore. Change-Id: I451370af5a8c0c25faea26beb3faa2483a33a5cf Fixes: QTBUG-74560 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Cocoa: always send queued user input eventsMorten Johan Sørvig2019-03-212-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | User input events will be queued if processEvents() is called with the ExcludeUserInputEvents flag. User code then expect that the queued events will be sent when the corresponding exec() call returns. We were sending queued user input event at the beginning of processEvents(). However, the cocoa event dispatcher also has a mode where it makes a blocking call to [NSApp run], in which case processEvents() never returns during event processing. This means we don’t get to call the queued-event-sending code. Factor out the queued-event-sending code to a new sendQueuedUserInputEvents() function. Call it from postedEventsSourceCallback() to make sure the queue is emptied after the ExcludeUserInputEvents processEvents() call is done. Task-number: QTBUG-69687 Change-Id: I4ff554ef4d39a69356736c33a650886b56bfdb4c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* macOS: Introduce QMacKeyValueObserver and use in theme and styleTor Arne Vestbø2019-06-072-48/+10
| | | | | | Change-Id: I2d21c883628933543ae5a66b694ff7503119bc4a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Fix QMouseEvent::buttonMikhail Svetkin2019-05-281-3/+2
| | | | | | | | | | cocoaButton2QtButton(NSEvent *event) did not handle NSEventTypeLeftMouseDragged, NSEventTypeRightMouseDragged, NSEventTypeOtherMouseDragged. Task-number: QTBUG-74763 Change-Id: I9f48230599f16400b49edbff392f712eb1fff782 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Use QMacNotificationObserver over manual notification handlingTor Arne Vestbø2019-05-292-3/+6
| | | | | | | | | This also fixes a bug where we were implicitly capturing this inside the block, which meant that we would crash if the theme was recreated. The capture is now tied to the lifetime of QCocoaTheme. Change-Id: I37df8e6c0b33bf41e76d66be3cf29576041a7546 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* macOS: Fix reported mouse event buttonsMikhail Svetkin2019-06-031-4/+3
| | | | | | | | | | | | Use m_buttons instead of currentlyPressedMouseButtons. The latter returns the state of devices combined with synthesized events at the moment, independent of which events have been delivered via the event stream, so this method is not suitable for tracking. Task-number: QTBUG-74057 Task-number: QTBUG-74121 Change-Id: Iabf99ada6c3d25a995c9ddf895059b70833a9051 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* macOS: Enable VK_MVK_macos_surface on the instanceLaszlo Agocs2019-05-301-1/+1
| | | | | | | | | | | | | | Reports say some systems get "Failed to find vkCreateMacOSSurfaceMVK" even though MoltenVK and the corresponding extensionare there. While not reproducable on single GPU Intel systems, it could be that not enabling the extension on the Vulkan instance is causing this. Not opting in to the extension is incorrect in theory anyway. So fix it in cocoa as well, similarly to how other platform plugins do this already. Task-number: QTBUG-76117 Change-Id: I75220f3582a700ce0037003086123d3d38524648 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Rename QMacScopedObserver to the more fittingly QMacNotificationObserverTor Arne Vestbø2019-05-294-7/+7
| | | | | | Change-Id: I1d8280fe88871572a3a27e612de49717b3b9ef77 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QMenu: show shortcuts in context menus by defaultRichard Moe Gustavsen2019-05-151-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change c2c3452ba introduced a new API in Qt to let QPA inform whether or not shortcuts should be shown in context menus. This was set to false by default, since by observation, this seemed to be the most common behavior across platforms. The problem is that it left no way for the application to override it; The attribute Qt::AA_DontShowShortcutsInContextMenus simply doesn't work when shortcuts are always off. And for some application, showing shortcuts is not just a matter of look-and-feel, but also important information to be able to use the application the way intended. This patch reverts the behavior back to how it was in Qt-5.9, where shortcuts where shown by default (except on macOS where we still keep them off). It's no so much because the "always off" logic is wrong, but because there is no (easy) way/work-around for an app developer to switch them back on (until Qt-5.13, where a new API is introduced to fix the situation: b1a9a77). And this lack of API can be a show-stopper for some when upgrading from e.g 5.9 LTS to 5.12 LTS. This downside of this patch, OTOH, is that it can cause more change that what is normally wanted in a patch release. But out of two evils, this is the best option. Those that wan't to hide shortcuts can set AA_DontShowShortcutsInContextMenus to true, which now will work. [ChangeLog][QtWidgets][QMenu] Shortcuts are again shown by default in context menus, except on macOS. They can be forced off by setting AA_DontShowShortcutsInContextMenus to true. Fixes: QTBUG-69452 Change-Id: Ibcc371395944ac5b19b1d20889940da271bf73d5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* macOS: Guard against display on non-main threadsTor Arne Vestbø2019-05-131-0/+9
| | | | | | | | | | | | | | AppKit will in some cases ask our view to display on secondary threads if we call APIs that are only supposed to be called on the main thread, such as -[NSOpenGLContext setView:] or -[NSOpenGLContext update]. Forwarding this display-request is bad, as QtGui expects all window system events to come on the main thread, and we can easily deadlock client code such as the Qt Quick threaded renderer. Change-Id: I1daeabf1dca6ca8ba908d3998b444a2089681e3a Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Deliver geometry changes when content view changes frameTor Arne Vestbø2019-05-101-3/+5
| | | | | | | | | | | | | | | | | This was disabled in 9f22ac0aa0254f20f9b26aec7b124d74141fdfcd under the assumption that the windowDidResize callback was sufficient, but in the situation when macOS native tabs are enabled, AppKit will report the wrong geometry for the first windowDidResize callback when a new tab is created. We could potentially remove the geometry change in windowDidResize, as the viewDidChangeFrame callback should be enough for content views, but this is something that needs more investigation. Change-Id: I85045507da1a01b4a906e6f88301f3321c660943 Fixes: QTBUG-75482 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Implement QCALayerBackingStore::toImage()Tor Arne Vestbø2019-05-102-0/+16
| | | | | | | | | | | It's not part of the QBackingStore API, but clients such as the Qt Quick software renderer access it through the platform backingstore, to grab the window. Change-Id: I203484ce13a5f8fb6815d27ab07f874fa9d16b8c Fixes: QTBUG-75467 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Deliver and handle screen change unconditionallyTor Arne Vestbø2019-05-081-17/+28
| | | | | | | | | | | | | | | | | | | We can't rely on the previous screen and current screen to accurately reflect whether or not the window has been moved from one screen to another, or if the window just stayed on the same screen but the screen was reconfigured by macOS. The reasons for this are many-fold, but include factors such as Qt using the screen of the top level window to resolve the screen of the child windows, and AppKit delivering screen change events in an order that makes things harder to track. The result is that we need to always send screen change events, for all windows, including child windows, and we also need to restart the display link by re-requesting an update request if needed, so that child windows that are running animations will continue to animate on the new screen. Change-Id: I0b87849c41323e92c08f5115842be067fa8f8490 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Always respond to cursorUpdate by applying custom cursor if setTor Arne Vestbø2019-05-081-4/+7
| | | | | | | | | | Calling super will push the default arrow cursor, so we should only do that if our own cursor has been unset. Change-Id: I71d8934e7eab2b15e150730e2282e7063ada305a Fixes: QTBUG-75552 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Guard backingstore composeAndFlush with QT_NO_OPENGLTor Arne Vestbø2019-05-072-0/+4
| | | | | | | Fixes: QTBUG-75612 Change-Id: I0e90a84697c1eb055c4150f2519829977fce7244 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: don’t crash when wrapping foreign viewsMorten Johan Sørvig2019-05-071-1/+3
| | | | | | | | | window.contentView can be of any NSView subclass. Get to the QCocoaWindow via QCocoaNSWindow instead. Change-Id: I8c761fd22e6078b075d8dd035ad767b9e4cb6da2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Move off deprecated handleFrameStrutMouseEvent APITor Arne Vestbø2019-05-071-3/+28
| | | | | | | Change-Id: Id95c096700a8bfa733d8620064c2a37eb19cc3db Fixes: QTBUG-72741 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix dnd regression c427ba53aa0ee1a71aa670783f65bcfd230da653Mikhail Svetkin2019-05-051-0/+19
| | | | | | | | | | | Qt starts drag-and-drop on a mouse button press event. Cococa in this case won't send the matching release event, so we have to synthesize it here. Task-number: QTBUG-72417 Change-Id: I645b6a2733c1ea11ac4545cf3405f826af45fa47 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* fix compilation with various -no-feature-* optionsNick Shaforostov2019-05-051-1/+2
| | | | | Change-Id: Ic1975db497613e3efe50be4246c167efe10d8e31 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Gracefully handle devicePixelRatio mismatch in QCALayerBackingStoreTor Arne Vestbø2019-04-192-3/+21
| | | | | | | | | | | | If the client of the backingstore fails to pick up dpr changes, and tries to flush the backingstore without a repaint, we will end up flushing a back-buffer with a stale dpr. Detect when this happens, warn the user, and smooth out the situation by adjusting the layer accordingly. Change-Id: If4596a8976a3902252c81d8e28c7aeb9fdd908bf Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: set layer.delegate when setting a layerMorten Johan Sørvig2019-04-101-0/+1
| | | | | | | Fixes flicker with Qt 5.12.2 on macOS 10.14.4. Change-Id: Ibb866d4339ecafae5fb573a653a2fb0f6238d704 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* macOS: Disable explicit layerContentsPlacementTor Arne Vestbø2019-04-031-0/+2
| | | | | | | | | | | | | | | | It was needed to allow lazy resize of the backingstore IOSurfaces, but that feature hasn't been enabled yet, and explicitly setting the layer's contents placement to NSViewLayerContentsPlacementTopLeft resulted in the layer animating when the window was moved from screens of different scale factors. We need to investigate this further, but in the meantime fix the visual regression by disabling the explicit layer contents placement. Change-Id: I63ea1eab9cf3fa6480e88844918ed98e6aa72620 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Use the correct text color for QPalette::ButtonText color roleYan Shapochnik2019-03-251-0/+3
| | | | | | | | Fixes the text color displayed in the QToolBar on macOS Mojave dark mode Change-Id: Ic4415295e314a8fc1c4fbb58964386e0563b8d44 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Cocoa: Clear the shortcut used when hiding a native menu entryAndy Shaw2019-03-211-0/+3
| | | | | | | | | | The shortcut needs to be cleared if the native menu entry is being hidden due to the fact it was changed. Otherwise it will not show the shortcut anymore as it sees it as in-use. Change-Id: Ifb10db855766e4de71db06ea006f6d63497f3193 Fixes: QTBUG-74113 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Move screen maintenance functions from QPlatformIntegration to QWSITor Arne Vestbø2019-03-191-3/+3
| | | | | | | | | | | | | | | QWindowSystemInterface is the de facto API for any plumbing going from the platform plugin to QtGui. Having the functions as protected members of QPlatformIntegration was idiosyncratic, and resulted in awkward workarounds to be able to call the functions from outside of the QPlatformIntegration subclass. The functions in QPlatformIntegration have been left in, but deprecated so that platform plugins outside of qtbase have a chance to move over to the new QWSI API before they are removed. Change-Id: I327fec460db6b0faaf0ae2a151c20aa30dbe7182 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* macOS: Add IOSurface based backingstore for layer-backed viewsTor Arne Vestbø2019-03-147-113/+769
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The naïve approach used for layer-backing in the past caused a detach of the backingstore QImage on each beginPaint, since the image was assigned to the layer via a CGImageRef that participated in the QImage implicit sharing (and had to, so we couldn't get around that). We now use IOSurfaces, wrapped in a QPlatformGraphicsBuffer abstraction. The surfaces can be assigned to the layer's content the same way images could, but allows us to reason more closely about whether or a buffer is in use, and increases the chance that we will have a zero-copy path to the screen. Unless the window has requested a surface format with single buffering we use a dynamic swap chain of buffers. In most situations there will be two buffers in play, one assigned to the layer and one ready to paint to, but during resize and some other situations the buffers will grow temporarily to accommodate the increased back-pressure. Since QBackingStore is documented as having single-buffer behavior, we take care to persist content between the buffers before every swap. By doing this before swapping, instead of before each paint, we can avoid preserving areas that will be painted to anyways, and will in many situations (such as blinking cursors e.g.) end up not persisting anything. The RasterGL surface case is handled by reading out the buffer data and doing a manual texture upload. In the future we can support direct texture access via CGLTexImageIOSurface2D, but this requires QPlatformBackingStore::composeAndFlush to learn how to support other targets than GL_TEXTURE_2D, as CGLTexImageIOSurface2D only works with GL_TEXTURE_RECTANGLE_ARB targets. Fixes: QTBUG-48763 Fixes: QTBUG-72360 Fixes: QTBUG-71162 Change-Id: Ica12f69b244e54d0fd31c929730d15657c286af8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Improve mouse loggingTor Arne Vestbø2019-03-053-10/+35
| | | | | Change-Id: Icc81f73e728d9b3669afc37b0c1ef73588f24749 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Modernize qnsview_dragging.mmTor Arne Vestbø2019-03-051-55/+45
| | | | | | | Style fixes, modern Objective-C usage, and use of convenience APIs. Change-Id: I04801b0b5f0d2213b4bcf1b0158fc32e57432d28 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Initialize QNSView mouse related members with other mouse logicTor Arne Vestbø2019-03-022-9/+13
| | | | | | Change-Id: I4ff67028823d62ed67bf4303a58bee127bd76501 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Decouple screen property updates from application delegateTor Arne Vestbø2019-02-203-12/+4
| | | | | | | Change-Id: I489c37131bf715d45f147964de4a8cd8c02adbcb Fixes: QTBUG-72966 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove special handling for hiding tool windows on application hideTor Arne Vestbø2019-02-202-36/+5
| | | | | | | | | | | | | | The code was needed when we had QCocoaWindow::hide(), that guarded the ordering out by checking the visible state of the NSWindow. We no longer have that method, and setVisible doesn't have the same guard. Added a comment in setVisible to prevent future travelers from adding logic that introduces the same situation. Change-Id: I0514619a303daceb1cd7d334f0de4bfce6c3e96f Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Set up platform window reference before initializing QNSWindow/PanelTor Arne Vestbø2019-02-184-25/+39
| | | | | | | | | Initializing the window will end up in [NSWindow _commonAwake], which calls many of the getters. We need to set up the platform window reference first, so we can properly reflect the window's state during initialization. Change-Id: I5349273b1930ee8a57dc518db74be90d2426f61c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Implement QNSWindow/QNSPanel mixin using preprocessor includesTor Arne Vestbø2019-02-182-103/+75
| | | | | | | | | | | | | | We want to share the implementation between the two classes, but Objective-C doesn't natively have a mixin-feature. Instead of using dynamic super-calls at runtime (which worked fine, but added complexity), we now do the mixin at compile time using the preprocessor. The dynamic-super feature is left in, in case we need it in other areas in the future. Change-Id: I95dfa7f18cba86cc518e963dd018944ef113ac06 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Remove redundant tracking of modal sessions in QCocoaWindowTor Arne Vestbø2019-02-184-7/+9
| | | | | Change-Id: I43a40889b0731e4b480155256fc51eaa836e62a3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Modernize worksWhenModal handlingTor Arne Vestbø2019-02-185-59/+27
| | | | | | | The code in QCocoaEventDispatcher was dead and could be removed. Change-Id: I0c57e64791045d65033376c096220983059028ba Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Simplify QCocoaWindow::setVisibleTor Arne Vestbø2019-02-181-32/+18
| | | | | | | | | We don't need all the checks for the event dispatcher, it should always be there. Change-Id: Ib89a9c1c5524b49c2d85fae12425d19ced960597 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Remove dead code in window activation handlingTor Arne Vestbø2019-02-181-24/+0
| | | | | | Change-Id: I321ab68b51c4ba63204c0e15fec74164e2c93d34 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Add auto-release pool during QCocoaScreen::deliverUpdateRequests()Tor Arne Vestbø2019-02-121-0/+2
| | | | | | | | | Checking the application's keyWindow will autorelease the window, and there's no root pool in place when called from the display-link thread. Change-Id: Ic43164ad6397c92b858fb549f7a00e28b6110849 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove screen-update disable during resizeTor Arne Vestbø2019-02-121-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was needed as a workaround for the window border and window content becoming out of sync when we were drawing and flushing to the layer from another thread using OpenGL. Since we've disabled ThreadedOpenGL we can remove this workaround for now. The workaround also had other problems, as windowWillResize: did not turn out to be a reliable signal to know when a window was about to resize. Since we override windowWillUseStandardFrame:, we would not get the callback when zooming windows. Conversely, if we removed the windowWillUseStandardFrame: override, we would get a single callback for windowWillResize:, and then multiple callbacks that the window had resized. In addition, windowWillResize: is not only used as a callback, but also as a way to let the window delegate restrict the size, so it's called when e.g. AppKit determines the standard frame of the window -- an operation that doesn't involve an actual resize operation. If we re-introduce a workaround using screen-update disabling we need a better hook than windowWillResize:, and we need to track when we disable screen updates so that we can pair them up with corresponding screen update enables, otherwise we'll get log messages in the console about "SLSReenableUpdate: unbalanced enable/disable update". Change-Id: Ifca8892083c8666976391a4ada8f8d1471493943 Fixes: QTBUG-73726 Task-number: QTBUG-69321 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Don't rely on QGuiApplication::instance() during CVDisplayLink callbackTor Arne Vestbø2019-02-121-4/+1
| | | | | | | | | The display-link callback comes in on a secondary thread, so there's a possible race in using QGuiApplication::instance() to check whether or not we're on the main thread. Change-Id: Ic26bca8f5f54847a1e1b11dc92e786693c86e9de Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Add explicit auto-release pool for requestActivateWindowTor Arne Vestbø2019-02-121-3/+3
| | | | | | | | | | The API is often called from main before entering the event loop, and the making the window first responder and key will autorelease both the window and view. Change-Id: Ie2a7dc14652015cbe802b57696e4a82d564e2dc0 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Don't send redundant geometry change events for top level windowsTor Arne Vestbø2019-02-111-0/+3
| | | | | | | | Top level windows already get their geometry changes via windowDidMove and windowDidResize. Change-Id: Ie6370aa290ef48c8b3ac770e77adb57ce43cbb47 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Treat default swapInterval (-1) as vsync-enabled display-linkTor Arne Vestbø2019-02-113-6/+12
| | | | | Change-Id: I6d3d241d3813bfac36155ad219d4a338cb1ef6f7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Simplify mouse trackingTor Arne Vestbø2019-02-112-33/+25
| | | | | | | | | | We don't need to react to updateTrackingAreas, as we only have a single tracking area that we can add once and forget. By asking AppKit to track all events in the visible rect, we can also pass a zero-rect for the tracking area. Change-Id: I2545712adc49b51904d5adc11f1faca36901b49d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>