summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoahelpers.mm
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Add helper function for getting AppKit localized stringsTor Arne Vestbø2024-01-151-0/+9
| | | | | | | | | | If we for some reason can't look up AppKit, or if the table or string within that table is not found we will end up using the key as is. Pick-to: 6.7 Change-Id: I5d574288e421e586458266899ffdff90eeadec8f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Add logging category for menu machineryTor Arne Vestbø2023-03-201-0/+1
| | | | | | | | The machinery is quit fragile, so any logging will help here. Pick-to: 6.5 Change-Id: I1906c0e33b4afbf649a20bfe2aa7210b6822087e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Add dialog helper for native message boxesTor Arne Vestbø2022-11-151-0/+1
| | | | | | | | | | | | | | | | | The native implementation uses NSAlert, making a best effort to map the QMessageBox properties to the native dialog, falling back to the cross platform non-native dialog if the discrepancy is too big. The initial implementation focuses on the current state of the native dialog helper "protocol", but there's room for improvement here, which would allow even more dialog types and properties to be native. [ChangeLog][macOS] Message boxes such as QMessageBox now follow the platform look and feel by using native dialogs if possible. Change-Id: I4da33f99894194a7b301628cd1fbb44d646ddf18 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Plugins: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-05-021-1/+1
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: Id76add7e86b6dfb89f758a9efb0644067f0f44de Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Move QIOType wrapper for io_object_t to QtCoreTor Arne Vestbø2022-02-011-15/+0
| | | | | | | | | | Since we require C++17 now we can use auto for the retain and release template arguments, which allows us to get rid of the wrapper functions for IOObjectRetain and IOObjectRelease. Pick-to: 6.2 6.3 Change-Id: Ifc4bf0fe50dfd0eaf6bb2e143acce6df7df17bdc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* qcocoa: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ibf86b9b95715e20e8bf9c49a347f9c8ca0c04bb5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Correct QNSPanelContentsWrapper @end marker placementTor Arne Vestbø2021-08-201-1/+2
| | | | | | | | | The incorrect "scoping" of q_IOObjectRetain and q_IOObjectRelease luckily did not affect their functionality as QIOType helpers. Pick-to: 6.2 Change-Id: I9b9c2312464c7e6f8e2d2a5856e35efa99ec0c41 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Handle input source change notifications in QCocoaInputContextTor Arne Vestbø2021-08-191-0/+1
| | | | | | | | Instead of going via QNSView. Also add some logging. Pick-to: 6.2 Change-Id: Iabed7511572ef22597651efa8047f06227b28533 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Use helper method for querying input method parametersTor Arne Vestbø2021-08-191-0/+22
| | | | | | Pick-to: 6.2 Change-Id: I379d4ca20101899db2dfbd8f0c5a22f423e40d6b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Add logging for keyboard and complex text inputTor Arne Vestbø2021-08-161-0/+19
| | | | | | Pick-to: 6.2 Change-Id: I098829e051d4f63950b2e35ee6dd4def8d70cf01 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Register mouse devices on cocoaShawn Rutledge2021-08-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It would have been nice to ensure that a device is registered already in mouseEnteredImpl(); but in that context, NSEvent.deviceID is always 0, and we can't find out anything else about the device. QWindowSystemInterface::handleEnterEvent() doesn't currently take a QPointingDevice either. In handleMouseEvent() and scrollWheel(), deviceID seems unique for each trackpad or Magic Mouse, but 0 for any plain USB mouse. There, the first mouse that the user interacts with becomes primaryPointingDevice(): its deviceID is assigned to systemID (except if deviceID == 0, we use 1 instead, to avoid the auto-incrementing device ID assignment in the QInputDevicePrivate ctor.) When scrolling occurs, we update the capabilities to have PixelScroll if theEvent.hasPreciseScrollingDeltas. So over time, QInputDevice::devices() should build up to a complete list, with capabilities() also distinguishing plain mice from those that have the PixelScroll capability. And in the common case that the user has only one Apple pointing device, it becomes primaryPointingDevice(). Pick-to: 6.2 Task-number: QTBUG-46412 Task-number: QTBUG-63363 Task-number: QTBUG-72167 Change-Id: Id9771b4dfd765e49023bd57d42a2aa4d0635a3b2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* cocoa: move DEBUG_PASTEBOARD into logging categoryLiang Qi2021-05-051-0/+1
| | | | | | Pick-to: 5.15 6.1 Change-Id: I8f49c030588122adff3c0eab4189bfa7e6aeff09 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Plumb application quit through platform pluginTor Arne Vestbø2020-09-141-0/+1
| | | | | | | | | | | | | | | | | | If we have a platform plugin we ask the platform to quit, and if not we fall back to the base implementation of QCoreApplication that sends Quit events directly. This allows the platform to involve the rest of the system in the process. The platform will then come back with a spontaneous quit via QWSI::handleApplicationTermination(), which will then send the corresponding Quit even from QGuiApplication like normal. Task-number: QTBUG-45262 Task-number: QTBUG-33235 Task-number: QTBUG-72013 Task-number: QTBUG-59782 Change-Id: I0000aaf7192e4b905933c5da0e53901c6c88f26a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cocoa: Translate the buttons used for the native font and color dialogsAndy Shaw2020-08-191-5/+5
| | | | | | | | | | | Use the QPlatformDialogHelper standard buttons to get the translated button text as then this will already have been translated for those loading a translation. Pick-to: 5.15 5.12 Fixes: QTBUG-85725 Change-Id: Ia42d93aeb6e1b5c0528564a6c960a35f6710c8eb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QOperatingSystemVersion support for macOS Big SurTor Arne Vestbø2020-07-291-85/+0
| | | | | | | | | Pick-to: 5.15 Pick-to: 5.12 Change-Id: Ide57f675b20b08210f301da5177df45d008423c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Exclude 32-bit builds by checking pointer sizeTor Arne Vestbø2020-07-081-4/+0
| | | | | | | | Task-number: QTBUG-85279 Pick-to: 5.15 Pick-to: 5.12 Change-Id: I984ec21b9c5ed5e2bd02b3a8b52bbeb72953e454 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Clean up headersTor Arne Vestbø2020-06-051-0/+2
| | | | | | | | | | | | | | The headers are now C++ clean and can be used outside of Objective-C code. All includes of Objective-C frameworks have been moved to the implementation files. Header guards have been added in the few places they were missing. All includes are now done via #include, instead of sometimes using the #import variant. Change-Id: Ibb0a9c0bcfefbda4347737212e40e300a3184982 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Remove QtWidget dependency from platform pluginTor Arne Vestbø2020-06-041-4/+0
| | | | | | | | | The dialog helpers don't depend on widgets themselves, and should be built regardless of whether the widget dialogs are enabled, as these helpers can (and should) be used by other layers, such as Qt Quick. Change-Id: I1c66b474ab2f29748f1256aea90229c51c12a16f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Fix or ignore deprecated API in 10.14Tor Arne Vestbø2020-03-271-2/+2
| | | | | | | Fixes: QTBUG-82128 Change-Id: I11abfcf7f245a7a25733625b50e207b07abba289 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-06-071-3/+2
|\ | | | | | | | | | | | | | | | | | | Conflicts: qmake/generators/makefile.cpp src/plugins/platforms/cocoa/qcocoaintegration.h src/plugins/platforms/cocoa/qcocoaintegration.mm Done-With: Jörg Bornemann <joerg.bornemann@qt.io> Change-Id: I5a61e161784cc6f947abe370aab8f2971a9cbe78
| * 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: Track screens via Quartz Display Services instead of NSScreenTor Arne Vestbø2019-05-131-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Improve mouse loggingTor Arne Vestbø2019-03-051-1/+1
| | | | | Change-Id: Icc81f73e728d9b3669afc37b0c1ef73588f24749 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Account for LC_BUILD_VERSION when checking SDK version and deployment ↵Tor Arne Vestbø2018-12-031-9/+16
| | | | | | | | | | | | target The more modern LC_BUILD_VERSION load command was introduced in the 10.13 SDK to unify the various versions of the LC_*_VERSION_MIN command. When building with a deployment target of 10.14, the linker will use this load command instead. Change-Id: Ic3571fdbfdf4dfb9346128c6f6e75d1e06f86cd2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Log Qt and macOS version information at startupTor Arne Vestbø2018-10-251-0/+82
| | | | | | | | | The SDK and deployment target versions are helpful to know when diagnosing issues. Change-Id: I85026bd9c1d706a923e8953837bd59bf9ed0266f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Update all deprecated enums to their 10.12+ equivalentsTor Arne Vestbø2018-08-311-15/+15
| | | | | Change-Id: I3034258da95c9c70eb6758db92967f438617f6e9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Make screen property changes more verbose and granularTor Arne Vestbø2018-08-031-0/+1
| | | | | | | | 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: minor refactoring in mouse handlers for nsview/systemtrayiconMikhail Svetkin2018-05-311-1/+14
| | | | | | | Use new helper functions for mouse events Change-Id: I01e83a228deb16cbdb1d7c8c628a92d48055ee2b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Transition to new QPA dag-and-drop APIMikhail Svetkin2018-05-081-0/+71
| | | | | | | | | | The new API allows us to pass the mouse buttons and keyboard modifiers along with the QWSI event. Task-number: QTBUG-57168 Change-Id: Ic54c012d1593d922e7dcd31facab2f2c630c7996 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-031-0/+10
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/elasticnodes/graphwidget.cpp examples/widgets/graphicsview/elasticnodes/node.cpp examples/widgets/graphicsview/elasticnodes/node.h src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/cocoa/qnsview_drawing.mm src/widgets/kernel/qmacgesturerecognizer_p.h Change-Id: I13cf06bac75d48d779d8ee7b5c91bfc976f2a32c
| * macOS: ensure mouse events from the global monitor has the correct button setRichard Moe Gustavsen2018-05-031-0/+10
| | | | | | | | | | | | | | | | | | | | | | The global monitor will be used when popup windows are visible to catch all mouse events. But only certain kind of NSEvents has a buttonNumber set to something useful. So we need to check for this case before we create a QPA event. Task-number: QTBUG-60887 Change-Id: I5631c76ae82b8bfd232642036a08b5a8a29491c7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Cocoa Helpers: Add qt_objc_cast() functionGabriel de Dietrich2018-04-201-4/+1
| | | | | | | | | | | | | | | | | | | | This generalizes what qnsview_cast() does to any Objective-C class. Notice that this is a loose cast, using isKindOfClass: instead of isMemberOfClass:. Change-Id: I745f548e474f2f9eef89f370d7d45496f0c51434 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | macOS: Remove 'cocoa' infix in QPA logging categoriesTor Arne Vestbø2018-03-141-3/+3
| | | | | | | | | | | | | | | | Makes the naming of QPA logging categories the same across different platforms, which makes it easier to debug an unfamiliar platform. Change-Id: I60ed34892d154e86723c8e4bcff3c28fcab1f7a1 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* | Clean up our Objective-C usageJake Petroules2018-02-201-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.11' into devQt Forward Merge Bot2018-02-131-0/+2
|\| | | | | | | Change-Id: Iaec2e57d6bf33355ddfa61d25133580a8740335f
| * macOS: Add more granular logging categories for window eventsTor Arne Vestbø2018-02-131-0/+2
| | | | | | | | | | Change-Id: I202e2cecfb5438ba9edc82efaf80b6ecebafb835 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Cocoa: Support DnD to the TrashMorten Johan Sørvig2018-02-071-0/+1
|/ | | | | | | | | | | | | Map Qt:MoveAction to NSDragOperationDelete, in addition to the existing NSDragOperationMove mapping. From the point of view of the source there is no difference between Move and Delete; the source copy should be deleted. Task-number: QTBUG-63794 Change-Id: Iea5abe31efe0320dad150d243544f25167b3d18c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2018-01-201-1/+1
|\ | | | | | | | | | | | | Conflicts: tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: If089d5010d15c33b3c1f13912d4386207456c1a9
| * Merge remote-tracking branch 'origin/5.9' into 5.10Tor Arne Vestbø2018-01-161-1/+1
| |\ | | | | | | | | | Change-Id: I896b0cf54f317c4336cc3d3db319a0b89e421728
| | * macOS: Simplify mangling of QNSPanelDelegate protocolTor Arne Vestbø2018-01-101-1/+1
| | | | | | | | | | | | | | | Change-Id: If29bc36ecab2feb4ce3372153d0d1566cdffc719 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | | macOS: Simplify helpers for flipping between quadrant I and IVTor Arne Vestbø2017-11-081-33/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+15
|/ / | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.9' into devOswald Buddenhagen2017-08-021-0/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp src/plugins/styles/mac/qmacstyle_mac.mm src/widgets/widgets/qdockarealayout.cpp src/widgets/widgets/qmainwindow.cpp src/widgets/widgets/qmainwindowlayout.cpp src/widgets/widgets/qmainwindowlayout_p.h tests/auto/corelib/tools/qlocale/tst_qlocale.cpp tests/auto/other/macnativeevents/BLACKLIST tests/auto/widgets/widgets/qmenu/BLACKLIST Change-Id: Ic8e724b80a65e7b1af25511b0e674d209265e567
| * Fix 32-bit build on macOSJake Petroules2017-07-201-0/+5
| | | | | | | | | | | | | | | | | | | | Some customers still need this for interoperability with legacy code. Let's continue to keep it working in 5.9.x, and then move to 64-bit exclusive features (thus dropping 32-bit entirely) in 5.10. Task-number: QTBUG-58401 Change-Id: Ibb7200c1885e9caba70439df5f7c86c81b1312b5 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* | QNSPanelContentsWrapper - call [super layout]Timur Pocheptsov2017-05-181-0/+1
| | | | | | | | | | | | | | | | | | | | Docs say that we have to explicitly call [super layout] from the overriding -layout. On macOS < 10.12 missing -layout call results in a noisy debug message. Task-number: QTBUG-58699 Change-Id: I58ce442f1e3640a6b1ec32774078e2385d73f085 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Remove unused Carbon includeJake Petroules2017-03-031-2/+0
|/ | | | | Change-Id: I62d7fa00da98e2925049fc381f0a592e27f2a245 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
* Add QPlatformWindow::isForeignWindow()Tor Arne Vestbø2017-02-091-1/+2
| | | | | | | | Simplifies code at call sites and allows for refactoring how to decide if a window is foreign or not at a later point. Change-Id: Icc51a83bac187f4975535366b53b4990832b6c82 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2017-01-301-10/+2
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/network-chat/peermanager.cpp src/widgets/util/qsystemtrayicon.cpp src/widgets/util/qsystemtrayicon_qpa.cpp src/widgets/util/qsystemtrayicon_win.cpp src/widgets/util/qsystemtrayicon_x11.cpp Change-Id: I1c026df83818c0ccaf956980370e7522960627db
| * Fix mouse extra button mapping on macOSAlexandru Croitor2017-01-241-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously extra mouse buttons apart from left, right and middle buttons, were mapped incorrectly with an offset of -1. This resulted in the first extra button being recognized as the middle button, the second extra button as the first extra button, etc. Fix consists in using a binary shift with proper offset to create the corresponding Qt::MouseButton value. [ChangeLog][macOS] Fixed extra mouse buttons to be mapped to correct Qt::MouseButton values. Change-Id: I9e6084586cd4737a172b7706a805211f0edff749 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>