summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoascreen.mm
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Harden screen handling logic when reconfiguring displaysTor Arne Vestbø2019-11-291-63/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When connecting/disconnecting/reconfiguring screens Qt needs to know about the changes before they are propagated by the OS in other ways, so that we can reflect the changes in the list of QScreens as soon as they happen. Unfortunately the canonical notifications for this in AppKit, NSApplicationDidChangeScreenParametersNotification, is delivered after AppKit itself reacts to the change, which results in receiving NSWindowDidChangeScreenNotification, NSWindowWillMoveNotification, and others, while the list of QScreens is stale. To work around this we adopted the lower layer Quartz Display Services API in 3976df2805 to notify us when there are changes to the screen configuration. Unfortunately the window server on macOS is not consistent in how it orders events during screen reconfiguration, and we can't rely on the NSScreen list being up to date when we get our callbacks from Quartz. To work around this we still hook into Quartz, so that we get the callbacks as early as possible, but then track the state of the AppKit NSScreen list and update our own QScreens as soon as we see a change. We now also include sleeping displays in the list of QScreens, which matches the behavior of NSScreen.screens. Similarly we exclude displays that are mirroring another display. Task-number: QTBUG-80193 Change-Id: I6b1958d6ee61373b2861e05a0d971d2300596f3e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Don't skip display link delivery via GCD during live resizingTor Arne Vestbø2019-10-301-9/+0
| | | | | | | | | We now avoid flushing GL if the exposed size does not match the window size, so we don't need to halt update request delivery during resize. Change-Id: Iaa89e67d50c987757a586b5958e08edf71a5dd0c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Only skip screen reconfigure if primary screen changedTor Arne Vestbø2019-10-271-3/+2
| | | | | Change-Id: Ia5d208ace5086e8e92f95f859383773894a18768 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Extend QCocoaScreen loggingTor Arne Vestbø2019-10-271-3/+31
| | | | | Change-Id: I91f89ff336b3f48aea91e50860264bd8359805cb Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Class initialize QCocoaScreen membersTor Arne Vestbø2019-10-271-1/+1
| | | | | Change-Id: I163858400da28668b8a85241e9e6b1d989227a3e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Don't leak CFUUIDRefs when resolving NSScreen for platform screenTor Arne Vestbø2019-10-271-1/+1
| | | | | Change-Id: I5609071346ef44dc9f16359db451ea9b29dd2b0d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Remove assert that primary display always matches CGMainDisplayIDTor Arne Vestbø2019-10-271-4/+4
| | | | | | Fixes: QTBUG-78707 Change-Id: Ia517f543728c76dcf19558e9e68ed97db7cfaaa4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Track screens via Quartz Display Services instead of NSScreenTor Arne Vestbø2019-05-131-59/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Using NSScreen as the basis for tracking screens is not recommended, as the list of screens can be added, removed, or dynamically reconfigured at any time, and the NSScreen instance, or index in the NSScreen.screens array may not be stable. Quartz Display Services on the other hand tracks displays via a unique display ID, which typically remains constant until the machine is restarted. The lower level API also gives us earlier callbacks about screen changes than the corresponding NSApplicationDidChangeScreenParametersNotification does. By reacting to screen changes _before_ AppKit does, we can remove workarounds for receiving window move and screen change notifications before the screen was actually visibly reconfigured. The new approach also handles changes to the primary screen, which can happen if the user moves the menu bar in the macOS display arrangement pane. The device pixel ratio of the screen has been made into a cached property, like all the other properties of QCocoaScreen. This is more consistent, and allows us to qDebug the screen even when it has been removed and we no longer have access to resolve the properties from the associated Quarts display. Change-Id: I2d86c7629ed3bf5fb8c77f174712633752ae4079 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Set up platform window reference before initializing QNSWindow/PanelTor Arne Vestbø2019-02-181-2/+1
| | | | | | | | | 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: 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: 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: Treat default swapInterval (-1) as vsync-enabled display-linkTor Arne Vestbø2019-02-111-2/+2
| | | | | Change-Id: I6d3d241d3813bfac36155ad219d4a338cb1ef6f7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: make QScreen::grabWindow() fast againMorten Johan Sørvig2018-11-301-45/+50
| | | | | | | | | | | | | | | | | Commit 17b73b0d2b8 regressed performance by grabbing the entire screen and then copying the grab region. Move back to grabbing a minimal rectangle instead. Also handle multi-screen grabs at different device pixel ratios. Multi-screen grabbing is handled by grabbing each screen individually, and then stitching together the result. The returned pixmap is created using the highest DPR available, upscaling lower resolution parts as needed. Change-Id: I9d45c5f7ec7b342360b745f49ef2939dc588f40b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Make QScreen::grabWindow() work againMorten Johan Sørvig2018-11-111-2/+2
| | | | | | | | | Commit 17b73b0d2b8 introduced a regression where the grab rect position was added to the size when bounding to the display size. This is incorrect. Change-Id: I11d7ba7f53b96badfdead190ef9ddb525ed4ba99 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: set dpr on pixmap returned by grabWindow()Morten Johan Sørvig2018-11-111-0/+1
| | | | | | | | This matches the behavior of QScreen::grabWindow(), and gives the caller direct access to the scale factor. Change-Id: Ia3ed165a62eaa0f386f8b508ea6b1128ba6be604 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-081-1/+19
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoabackingstore.mm src/plugins/platforms/cocoa/qcocoascreen.mm Change-Id: Iac965aea4867059dbf7bc401b71e8e8b5b259afb
| * macOS: Update window geometries after screen properties changeTor Arne Vestbø2018-08-071-0/+14
| | | | | | | | | | | | | | Task-number: QTBUG-69794 Task-number: QTBUG-68140 Change-Id: I4d33bc2136478d779cc4ae8170c3421d9a7557cc Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | macOS: Make screen property changes more verbose and granularTor Arne Vestbø2018-08-031-5/+15
| | | | | | | | | | | | | | | | We only update the properties that have actually changed. Change-Id: If711530c6118d2550d5a0e968ee02c903b44fd04 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* | macOS: Deliver update request via CVDisplayLink if swapInterval > 0Tor Arne Vestbø2018-07-071-0/+204
| | | | | | | | | | | | | | | | We use GCD for marshaling the display link update over to the main thread, as Qt requires that the update request is delivered there. Change-Id: I318a5b8f27dc5094ce71244401308a4044c41b39 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Cocoa QPA: Clean up 0 as pointerGabriel de Dietrich2018-04-191-2/+2
| | | | | | | | | | | | | | | | We use nil for Objective-C null pointers and nullptr everywhere else, including CoreFoundation and similar opaque types. Change-Id: Id75c59413dec54bf4d8e83cf7ed0ff7f3d8bb480 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | macOS: Provide helper property for resolving the display ID of a screenTor Arne Vestbø2018-03-201-2/+10
| | | | | | | | | | Change-Id: I144bd33a2c122d53ea1435a53483a3d8b46fd093 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-02-231-13/+16
|\| | | | | | | Change-Id: I01dfc41e18333ac55954296cef8f01475adab27e
| * Cocoa: fix grabWindow when mixing highDPI and non-highDPI screensPablo Marcos Oltra2018-02-221-13/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | CGDisplayCreateImageForRect seems to have a weird behavior when mixing highDPI and non-highDPI screens since it may take part of the non-highDPI screen when the highDPI display is at the left or at the top of the main monitor. To workaround this issue, we capture the whole screen and then crop the image to the desired size. Task-number: QTBUG-47643 Change-Id: Ib2a3850a0a549964c7fe272abb563bd23518c234 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Clean up our Objective-C usageJake Petroules2018-02-201-1/+1
|/ | | | | | | | | | | | | | | | - Move ivars into @implementation - Use instancetype where applicable - Use dot notation for property access - Use subscript operator for dictionaries and arrays - Format selectors consistently - Use proper style for init methods - Use generics instead of void pointers where possible - Use "range for" loops instead of indexing - Replace or replace IBAction/IBOutlet with void Change-Id: I1667812a51d4dfe44ae80fe337cb1f4bc9699d92 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-11-231-0/+18
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/network/access/qhttp2protocolhandler_p.h src/network/kernel/kernel.pri src/network/ssl/qsslkey_qt.cpp src/plugins/platforms/cocoa/qcocoascreen.mm src/plugins/platforms/windows/accessible/iaccessible2.cpp src/plugins/platforms/windows/accessible/iaccessible2.h src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h src/widgets/widgets/qmenu_p.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/other/qaccessibility/tst_qaccessibility.cpp tests/auto/testlib/selftests/expected_cmptest.lightxml tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt tests/auto/testlib/selftests/expected_cmptest.xml Done-with: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I4217cc7d840cbae3e3dd28574741544469c4c6b9
| * macOS: Add logging of screen add/remove/changesTor Arne Vestbø2017-11-041-0/+18
| | | | | | | | | | Change-Id: Ic9c9ac307441dde98bb43d656466a03805746917 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | macOS: Simplify helpers for flipping between quadrant I and IVTor Arne Vestbø2017-11-081-43/+29
| | | | | | | | | | | | | | | | | | | | | | | | The different flip-functions have been replaced by a single function, qt_mac_flip, with overloads for points and rects. This function is primarily used to implement QCocoaScreen::map(To|From)Native, which most clients of qt_flip* have been moved to. This makes it clearer what kind of reference geometry we're flipping in relation to, and simplifies call-sites. Change-Id: I8a0862f94bb2c64a83a1c3168f984a195c0af6db Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | macOS: Replace deprecated CGDisplayIOServicePort functionTor Arne Vestbø2017-11-081-6/+33
|/ | | | | | | | | There's no replacement function from Apple's side, so we have to iterate the available displays and pick the right one based on the vendor, product and serial number. Change-Id: I437bee06bc6826c3214a701cd2c65f6109eeb3e7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Split QCocoaScreen out from qcocoaintegration.mmTor Arne Vestbø2017-10-051-0/+278
It's confusing to keep it along with an unrelated class. Let's keep it in its own file like for most other platform plugins. Change-Id: I449ee061ff9fd5dc7ef06cadd633414d6b16358f Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>