summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Resend event if the first input method event changes focusVolker Hilsheimer2021-06-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QAbstractItemView opens the editor and changes focus in response to the first QEvent::InputMethod event. Changing focus however cancels the current composition, so the key press is lost and needs to be repeated by the user. What QAbstractItemView does is probably not that unique, so fixing this there - if possible at all - is not a general solution. In the platform specific input method handling code, we can generally discover that the focus object changed in response to the InputMethod event that gets sent to the focus object. On macOS, we can then pass the key event to the input method once more, which works fine. On Windows and X11, the situation is more complicated. That the focus changed is easily discovered, but re-sending the key press in such a way that the input method responds doesn't seem possible. On Windows, using SendInput simply delivers the exact key to the focus object, without starting the expected composition. On X11 with IBus, it should be possible to call ProcessKeyEvent again on the IBus input context when we discover in filterEventFinished that the focus object changed while delivering the event. However, any attempt to do so has no effect. So, for now only fixing this for macOS. Task-number: QTBUG-54848 Change-Id: I0f7b786cfa57430e6a1e7d605415265cf53eb675 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Allow programatically minimizing frameless windowsMorten Johan Sørvig2021-06-091-1/+4
| | | | | | | | | | NSWindowStyleMaskMiniaturizable also controls programatic minimize, in addition to the window decoration button. Fixes: QTBUG-65637 Pick-to: 6.2 6.1 5.15 5.12 Change-Id: Iac5fb483433441173d770f4fcfb9e93440b9fe6a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Keep NSWindow alive after handling windowShouldClose callbackTor Arne Vestbø2021-06-091-0/+9
| | | | | | | | | | | | | | | | | | | | | Option-clicking the close-button on a window in macOS is a request to batch-close all the windows. When this happens we get an event in through the window that was clicked, which in turn results in AppKit calling windowShouldClose: for each window. We respond to that by explicitly closing each window (instead of just responding YES or NO), which results in the window being released and deallocated. This causes a crash when AppKit then follows up by closing each window after we responded YES to windowShouldClose. We work around this by keeping the window alive in the closest auto release pool, which is typically at the level of the runloop. This ensures that the window is alive for the duration of the logic that AppKit has for batch-closing windows. Fixes: QTBUG-92232 Pick-to: 6.2 6.1 5.15 Change-Id: I68b6138eb8325af0576b438ffa011137fec27926 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* macOS: don't show invisible separator itemsVolker Hilsheimer2021-05-272-3/+8
| | | | | | | | | | | | Give QCocoaMenu access to the item's visibility property by adding a public getter, and respect that state when syncing the separator to the corresponding QCocoaNSMenuItems. Pick-to: 6.1 5.15 Fixes: QTBUG-88651 Change-Id: I7e238e5d3be141ec8f4e8f6f3ab22d761094d2d2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Restore logic to set wantsBestResolutionOpenGLSurfaceTor Arne Vestbø2021-05-201-0/+8
| | | | | | | | | | | | | | | | The logic was removed in 1fc7ca091b3fdda52381a383318a3a752ec21132 when we removed support for surface-backed views, based on the documentation for wantsBestResolutionOpenGLSurface noting that layer-backed views ignore the property. But in some cases, when plugin views are embedded into host views, and the host was built with a pre-10.14 SDK, AppKit seems to get confused, and we still need to set this property. Fixes: QTBUG-93770 Pick-to: 6.1 Change-Id: Id67f2fcb8c090c0e01c05d00792eaef311146df1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* macOS: Fix warning about comparing different types in QCocoaScreen::isOnlineTor Arne Vestbø2021-05-201-2/+2
| | | | | | Pick-to: 6.1 Change-Id: Ieb70108d22bf254c69665e5b3e3a2988703e26a2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* cocoa: be more careful about rejecting frame strut eventsRichard Moe Gustavsen2021-05-121-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The m_buttons property is meant to hold the currently pressed mouse buttons done on the contents part of a QNSView. But m_buttons can sometimes get out of sync with AppKit (NSEvent.pressedMouseButtons). One way this is shown to happen is if you do a mouse press on a native child widget (that is backed by it's own QNSView), and then convert the widget to a top-level window before the release. In that case, the underlying QNSView will be reparented from one NSWindow to another, which will result in the old NSWindow getting the mouseUp call instead of the new window. The result is that we don't update m_buttons for the reparented QNSView, which will instead be left as "pressed". As a result of m_buttons being stuck in a faulty state, we also refuse to send out QEvent::NonClientAreaMouseMove events to the top-level widget. This because QNSView thinks that it's already in a dragging state that started on the content part of the view (and not on the strut). As a result, it can sometimes be impossible to dock a QDockWidget back into a QMainWindow, since we basically don't send out any frame-drag events to Qt for the new dock window. We can reason that if you start a mouse press on the frame strut, you cannot at the same time have an active mouse press on the view contents. This patch will therefore remove the buttons that we know was pressed on the frame strut from m_buttons. This will at least (be one way to) clear the faulty pressed state, and will let us send mouse press/drag/release (and after that, move) frame strut events to Qt. Pick-to: 6.1 5.15 Task-number: QTBUG-70137 Change-Id: If51e1fe57d2531b659d39de85658893dae6391e3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove MIME plumbing from QCocoaNativeInterfaceTor Arne Vestbø2021-05-112-19/+0
| | | | | | | | | | The functions are available as private API though qt_mac_addToGlobalMimeList and qt_mac_removeFromGlobalMimeList for those that need it. Task-number: QTBUG-83252 Change-Id: Ibc17aedd9aaced236a082d3d8de4b28313406a02 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: in password lineedits, pass dead keys to the input methodVolker Hilsheimer2021-05-062-1/+7
| | | | | | | | | | | | | | | Otherwise the IM cannot correctly compose the input, making it impossible to enter e.g. ü or ~ on certain keyboard layouts. Note that the native macOS NSSecureTextField does not allow that either, which is however a very bad user experience. With this change, the modifier characters like ¨ diacritics will be visible when entering them in either NoEcho or Password line edits. The follow-up commit will remove those as well. Fixes: QTBUG-84664 Change-Id: Ib4c5ab85634c17c407623f82b46c4849c72d9e69 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* cocoa: move DEBUG_PASTEBOARD into logging categoryLiang Qi2021-05-053-62/+21
| | | | | | Pick-to: 5.15 6.1 Change-Id: I8f49c030588122adff3c0eab4189bfa7e6aeff09 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Don't override action set during drop handlingAndy Shaw2021-04-291-1/+3
| | | | | | | | | | | | | | | | When the drop has been handled, the target might have accepted a specific action by calling QDropEvent::setDropAction. Don't override that with the operation received by the OS if the drag'n'drop operation takes place within the same application. If the operation comes from outside, we have no choice but to trust the OS. This way the drag-site will get the action accepted by the drop-site when QDrag::drag returns. Fixes: QTBUG-77427 Pick-to: 6.1 6.0 5.15 Change-Id: I0e4c86adeeea66b345966a03a3251fa62263b3e8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add storage for (pixel) deltas and fingerCount to QNativeGestureEventShawn Rutledge2021-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | It's not clear now whether trackpad gestures on Windows will need to be so different than on macOS; however, any reasonable int value can be stored in a qreal, and in Qt Quick we like to use floating-point numbers for all "real" values and measurements. So since we need to add more storage, and quint64 m_intValue has never been used, we now replace it with a QVector2D, which should have the same size. The intended use is that PanNativeGesture will include a displacement, probably in pixels, by which the viewport or some target item should be panned or moved. The naming of deltas() is flexible enough to support any gesture with some incremental 2D valuators, though, just as value() has gesture-dependent semantics. fingerCount() will be useful for Qt Quick pointer handlers to filter out events that have the wrong number of fingers, e.g. to require that either a 3-finger pan gesture or 3 individual touchpoints are required to activate DragHandler { minimumPointCount: 3 } (assuming we implement pan gesture support in DragHandler). Fixes: QTBUG-92179 Task-number: QTBUG-92098 Change-Id: I5462aea9047beed6e99075294a62011edd8a59f5 Reviewed-by: Povilas Kanapickas <povilas@radix.lt> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* cocoa: Use the system-provided color for QPalette::PlaceholderTextShawn Rutledge2021-04-201-0/+5
| | | | | | | Task-number: QTBUG-92947 Task-number: QTBUG-86195 Change-Id: I2aa61ad23aae526c3fff9982f4df9847a279712c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Don't disable menu items that belong to the active modal windowVolker Hilsheimer2021-04-123-5/+18
| | | | | | | | | | | | | | | | | | A popup/context menu created via QQuickPlatformMenu doesn't belong to any menubar, so by disabling items in a menu that doesn't belong to the currently active menubar (5b9f6862b1), we disabled all menu items in a QQuickPlatformMenu when a modal window was active. For such unrooted menus, use the QCocoaMenuObject data structure to record which window it is shown for, and only disable items if that window is not also the current modal window. Amends 5b9f6862b1aa474a392203c69f6db678d633cecf. Fixes: QTBUG-92040 Pick-to: 6.1 6.0 5.15 Change-Id: I56b6d579e5e94689b43ca84d4637e35dc2cbeb4c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Account for multiple screens when computing QSizeGrip available geometryZhang Hao2021-03-241-0/+2
| | | | | | | | | | | | | In a multi-screen setup, when the window was resized on one of the screens, the resize was limited to the available geometry of the screen the window was on. Fix this by using the whole virtual geometry of all the screens as basis for the resize. Fixes: QTBUG-91714 Change-Id: I28dd241d73f6a68550af88e368f0dbdcb9ebf42b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* cmake: Don't give plugins PUBLIC usage requirementsCraig Scott2021-02-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The pro2cmake.py conversion script faithfully reproduced the .pro files for the plugins, which specified the libraries as public. But in CMake, the implications of this are that public usage requirements should then be propagated to consumers. We don't expect any consumers, since a plugin is created as a MODULE library in CMake, so for Windows we don't even have an import library to link with. The only exception to this is for static builds where plugins are created as STATIC libraries instead, but only in certain controlled situations do we then link to plugins. Even then, usage requirements are not expected to propagate to the consumers, so these relationships should always be specified as private. This change warns on any PUBLIC usage requirements specified for a plugin. This check is disabled by default to avoid spamming CI builds for repos that haven't been fixed yet. The check can be enabled by a CMake cache option, which is intended for developers to use locally when fixing this issue in other repos (all plugins in qtbase should not trigger this warning as a result of changes in this commit). Task-number: QTBUG-90819 Pick-to: 6.1 Change-Id: I09f2c8da77db1193ad3370f85d367dfc6ab7b9a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* macOS: don't let windows that are transparent for input become key windowVolker Hilsheimer2021-02-191-1/+1
| | | | | | | | | | | | Such windows are typically used as mostly transparent overlays on top of other windows underneath. Letting such an overlay become the key window breaks cursor updates and focus handling. Pick-to: 6.0 6.1 5.15 Fixes: QTBUG-83632 Change-Id: I192d419a5bdb8dfa0e9223e9fbbd7876c62fe743 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* a11y: Report mixed state if QCheckBox is PartiallyCheckedJan Arve Sæther2021-02-041-0/+2
| | | | | | | | | | Previously it only returned checked or unchecked for a tri-state checkbox. Fixes: QTBUG-84616 Pick-to: 5.15 6.0 6.1 Change-Id: Ife72098e35f8295fd389bda232de5478ffa7e87f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Reduce duplicated code for showing file dialogsTor Arne Vestbø2021-02-022-75/+37
| | | | | | | | | | The initialization was duplicated across the different modes. We now do the setup once, in a shared showPanel:withParent function. This also simplifies and removes the need to store the return code. Change-Id: I3c4da48cfef92bcc59c76cffa15b40150de1a9e1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Reduce duplicated updates of file dialog propertiesTor Arne Vestbø2021-02-021-13/+6
| | | | | Change-Id: I2017bfdfa6d5598405d700680ecaaf04fd6023fd Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Refactor computing of accepted extensions in file dialogsTor Arne Vestbø2021-02-021-21/+20
| | | | | Change-Id: Ie71db5a0ab66dd9d157b53297cbb9aba248fa8af Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Use single variable to track file dialog in QCocoaFileDialogHelperTor Arne Vestbø2021-02-021-64/+74
| | | | | | | | | | | | | | Relying on Objective-C's no-op behavior when sending messages to nil was nifty, but a bit confusing when trying to track the ownership model of the class. It's now explicit at the call sites what's going on (a cast). The canSelectHiddenExtension property is valid both save and open panels, but AppKit will only show it for save panels. Change-Id: I8e12d629639e2179d155b2ecda1bb2dab2a5757d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Cocoa: When validating menus, account for modal window only if activeAndy Shaw2021-01-291-4/+3
| | | | | | | | | | | | When a modal window is WindowModal then it is possible for another top level window to be active and therefore the menus shown may be valid for the window. So we can still allow the menu items to be validated in the context of that window. Fixes: QTBUG-74088 Pick-to: 6.0 5.15 Change-Id: Ifb9c3fe12654b2972e0e3c368dc093fae1ed4cc8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Clean up QCocoaFileDialogHelperTor Arne Vestbø2021-01-262-338/+262
| | | | | | | | | | | | | | | | | | | - Remove indirections via helper functions that did nothing but redirect. - Remove unneeded checks of !m_helper in delegate. The helper is always valid for a delegate. - Use m_ prefix for member variables, as in the rest of Qt. - Implement init: as per modern Objective-C recommendations. - Remove respondsToSelector checks that were not needed. - Use modern Objective-C property syntax. - Fix code style issues/formatting. - Remove unused functions. - Reorder and remove unused includes. - Class-initialize member variables. Change-Id: Iedc084b67bb496b2ef13001a0e6aa46d4574eb57 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Don't restrict non-modal file dialogs to open-dialogs onlyTor Arne Vestbø2021-01-261-16/+14
| | | | | | | | None of the APIs used for non-modal operation require NSOpenPanel. Pick-to: 6.0 5.15 Change-Id: I7ea49a8dad6e724a8a0d4321ea443d4cdcc5a6b1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Show system tray icon on mouse button press, not releaseTor Arne Vestbø2021-01-261-1/+1
| | | | | | | | | | | | | | | This was a regression from 395e2d9bc48941d6. The system behavior is to show the menu on press, so we follow that. This is also documented at: https://doc.qt.io/qt-5/qsystemtrayicon.html#ActivationReason-enum Fixes: QTBUG-86518 Pick-to: 6.0 5.15 Change-Id: Ia4dc5356bf0377a9d55f238caf5bf1becd95648d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Don't exec file dialogs via runModal unless they are app modalTor Arne Vestbø2021-01-252-20/+40
| | | | | | | | | | | | | | | | | | | | | | Non-modal or window modal dialogs are shown at show(), via AppKit APIs that are non-blocking. If we want to block execution at this point, we need to spin our own event loop. The runModal API of NSSavePanel is not meant to be used for blocking execution for already shown dialogs, but is reserved for application modal dialogs. This means we no longer trip over AppKit's understanding of what state the dialog is in, which would result in the dialog not reporting back any files. It also allows us to remove the guard for closing dialogs twice. We now also correctly close and end the application modal session if the dialog is closed programmatically using Qt APIs. Task-number: QTBUG-89959 Fixes: QTBUG-85547 Pick-to: 6.0 5.15 Change-Id: Ida3dc404417789d4823822ecfbf0935591c23878 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Add QPlatformScreen::colorSpace()Allan Sandfeld Jensen2021-01-252-0/+7
| | | | | | | | Added for macOS and X11 screens Task-number: QTBUG-90535 Change-Id: Ifafe7a07ee2abc3c42cd12785db2d7329878375b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* iOS: Handle keyboard events when using an external keyboardAndy Shaw2021-01-2012-662/+21
| | | | | | | | | | | | | | | | | | This enables the two possible approaches for handling external keyboard events. While support still exists for before 13.4 then both approaches are needed. This ensures that all external keyboard events are handled as key events and passed on accordingly. Additionally, this accounts for possible shortcuts too, therefore a new function is added to QShortcutMap to aid that. As a result, code has now moved from QCocoaKeyMapper to be part of the gui/platforms/darwin part to make it easier to reuse this code elsewhere. Fixes: QTBUG-85727 Change-Id: I349af43468b03fd8dcb16adba02669974affe154 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove DontConfirmOverwrite workaroundMorten Johan Sørvig2021-01-191-9/+2
| | | | | | | | | | | | Does not work any more on recent macOS versions. As a bonus, Qt now handles file names which contain “___qt_very_unlikely_prefix_” correctly. Pick-to: 5.15 6.0 Task-number: QTBUG-39791 Change-Id: I944a68efa18edc72939d953ab32ecb53d8f8e1c4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove .prev_CMakeLists.txt filesJoerg Bornemann2021-01-121-106/+0
| | | | | | | | | | Those serve no purpose anymore, now that the .pro files are gone. Task-number: QTBUG-88742 Change-Id: I39943327b8c9871785b58e9973e4e7602371793e Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* macOS: Don't try to close already-closed/closing file dialogTor Arne Vestbø2021-01-121-1/+7
| | | | | | | | | | | | | | | | | Doing so results in a warning about "modalSession has been exited prematurely - check for a reentrant call to endModalSession:", and on Big Sur will also result in the file failing to save because the return code from runModal will no longer be NSModalResponseOK. This would happen when the completion handler for beginSheetModalForWindow would call QNSOpenSavePanelDelegate_panelClosed, resulting in calls to QDialog::done(), which in turn tries to hide the dialog, via QCocoaFileDialogHelper::hideCocoaFilePanel(). Pick-to: 6.0 5.15 Fixes: QTBUG-89959 Change-Id: I048afe3dcc7fe62e0d0273f12b4b2c0237abb052 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-111/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* macOS: Fix crash when showing parent-less platform menusTor Arne Vestbø2020-12-091-2/+2
| | | | | | | Pick-to: 6.0 Pick-to: 5.15 Change-Id: I80f02da1621e4088eb040bb16a4db3867b6ad4d7 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* macOS: Remove warning about KVO observers on QNSWindow/QNSPanelTor Arne Vestbø2020-12-091-5/+0
| | | | | | | | | | | | | | | | | | NSTitleBarView in Big Sur will observe the window it is in, but makes sure to remove these observers in viewWillMoveToWindow, as it should. To avoid spamming user logs with this warning we remove it. It was dubious what cases it would have caught anyways, as anyone trying to KVO observe properties Z of a child object Y of X.Y would need to track whether X changes its Y between adding and removing the observer. There are no guarantees that Y is stable, and this applies to an NSView's window property as well. Pick-to: 6.0 Pick-to: 5.15 Pick-to: 5.12 Change-Id: I27a0d04625f96c4c5d382c39ac068721ce1e8f9d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* macOS: Always allow interacting with popup windows during modal sessionTor Arne Vestbø2020-12-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | f4889e63c7b changed the worksWhenModal logic for QNSWindow to be based on the transient parent relationship of the child window to the modal session window, to fix many issues where windows that should be blocked were not. Unfortunately, some window types do not maintain a transient parent relationship (e.g. QCompleter, which is itself just a QObject), or are not common for users to create with a QWidget parent (such as a context QMenu). This change restores part of the special-casing that was removed in f4889e, so that all popup windows are always allowed to be interacted with during modal sessions. This includes popup windows that were opened as part of a parent modal session, which would normally be fully blocked, but we assume that popup windows are intermittent enough that this will not be a problem. For now we leave out the other two special casings from f4889e, namely tool windows and dialogs. The former should in most cases be created with a parent window, while the latter definitely should. Fixes: QTBUG-88188 Fixes: QTBUG-88985 Fixes: QTBUG-87849 Fixes: QTBUG-86845 Pick-to: 6.0 Pick-to: 5.15 Change-Id: I005a402b21e8dc16c3b18bcd7e67d12b94a66f44 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Propagate device-pixel-ratio of system tray iconTor Arne Vestbø2020-11-201-0/+1
| | | | | | | | | | | | | | | | | When preparing a system tray icon on a system with a retina screen, we end up creating a full-height icon of height 44. If there's also a 1x screen available, macOS will scale down this image for us when presenting the icon on the 1 screen, but the downscale will fail to preserve the aspect ratio of the original image on Big Sur. Telling macOS which device-pixel-ratio the image has seems to fix this, and is the right thing to do in any case. Pick-to: 5.15 Pick-to: 5.12 Fixes: QTBUG-88600 Change-Id: Ic31def94d073da1b256bbfcaf5905f92c169f43d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QFont: Prefer setFamilies() over setFamily()Andy Shaw2020-11-201-1/+1
| | | | | | | | | | | | | | | | By depending on setFamilies() then we can be sure that font names with spaces, commas, quotes and so on are correctly handled without being misinterpreted. For now it will split on the comma when a string containing one is passed to setFamily. But from Qt 6.2 this will be removed to preserve the family string as a convenience function. [ChangeLog][QtGui][QFont] Indicated that setFamilies/families is preferred over setFamily/family to ensure that font family names are preserved when spaces, commas and so on are used in the name. Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QChar: make construction from integral explicitGiuseppe D'Angelo2020-11-152-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QChar should not be convertible from any integral type except from char16_t, short and possibly char (since it's a direct superset). David provided the perfect example: if (str == 123) { ~~~ } compiles, with 123 implicitly converted to QChar (str == "123" was meant instead). But similarly one can construct other scenarios where QString(123) gets accidentally used (instead of QString::number(123)), like QString s; s += 123;. Add a macro to revert to the implicit constructors, for backwards compatibility. The breaks are mostly in tests that "abuse" of integers (arithmetic, etc.). Maybe it's time for user-defined literals for QChar/QString, but that is left for another commit. [ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar constructors from integral types are now by default explicit. It is recommended to use explicit conversions, QLatin1Char, QChar::fromUcs4 instead of implicit conversions. The old behavior can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION macro. Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Cocoa: Allow CMD+H to hide the application when a tooltip is visibleAndy Shaw2020-11-101-1/+2
| | | | | | | | | | | Since native applications allow CMD+H to hide an application when the tooltip is visible then we should do too. Other popup windows will still block the call. Pick-to: 5.15 Fixes: QTBUG-82626 Change-Id: Ieac86d6b3cb2152a3ba82d8bd850f13bfeedb7c8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix compile warningVolker Hilsheimer2020-11-061-2/+2
| | | | | | | | QInputDevice data types changed from 16 bit to int in 742de50c5ec01f93cf0e193a8a131cbd913cb787 Change-Id: Id2760b5b685e5efc14ee6f9e36e2b30a5b188cdd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove alpha from default surface formatMorten Johan Sørvig2020-10-231-8/+1
| | | | | | | | | | | | | | | (This reverts commit 2ca1253b13e77643b3d2dd993a038ae2df882311). This allowed use to avoid backing store RGB -> RGBA conversions on the CPU back before macOS was layer backed. The conversion should be GPU accelerated now, and we can return to the cross-platform default. In addition, RGBA backingstores requires filling with transparent pixels on each paint event, which causes increased CPU usage - often for no reason if transparency effects are not used. Change-Id: Ic795128b7e474b63f44f9f4f3526d0b205652e62 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Make QPointer comparisons hidden friendsAllan Sandfeld Jensen2020-10-231-1/+1
| | | | | | | Reduces ADL noise. Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Rename the new platform APIs from QPlatformInterface to QNativeInterfaceTor Arne Vestbø2020-10-075-5/+5
| | | | | | | | | | | | We were already using the 'native' nomenclature when referring to these kinds of APIs, e.g. when talking about native handles, or the existing QPlatformNativeInterface on a QPA level. Using 'native' for the user facing APIs also distinguishes them from the 'platform' backend layer in QPA and elsewhere. Change-Id: I0f3273265904f0f19c0b6d62471f8820d3c3232e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Un-special-case macOS in handling of QKeyEvent::nativeScanCode()Tor Arne Vestbø2020-10-062-11/+17
| | | | | | | | | | | | | | | | | | | | | | | In the porting from Qt 4 to Qt 5 an assumption was made in QKeyMapper that the underlying platform implementation needed the native scan code to be able to resolve the possible keymaps for an event. As a result, the macOS platform plugin started sending key events with a fake native scan code of 1, so that it would still be allowed to map key events. Which in turn led to the documentation of QKeyEvent::nativeScanCode() getting an exception for macOS. Let's clean up this by removing the original assumption, and leave it up to the platforms to decide what information from the key event is needed. QKeyMapperPrivate::possibleKeys() will still call extractKeyFromEvent as a fallback if the platform layer doesn't return any possible keys. Change-Id: I122a45bcec658c45ccc0b2c0671eb264d85d7be6 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Prevent mapping non-keydown events to charactersTor Arne Vestbø2020-10-061-13/+21
| | | | | | | | | | The [NSEvent charactersByApplyingModifiers:] API only supports key down events, but we might get into QCocoaKeyMapper::keyMapForKey for modifier key presses as well (even if QShortcutMap::nextState tries to filter out modifier keys). Change-Id: I02f163edac2baa9052f34b4d5d31b6a627d3d85c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QCocoaDrag - set image only on the first drag itemTimur Pocheptsov2020-09-281-2/+7
| | | | | | | | This image is already a combined image of all urls that we drag. Pick-to: 5.15 Change-Id: I8fe45f64a6022881320d100f8a6f4a25fcac73b9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QCocoaDrag::drag - make sure clipboard is ours and populatedTimur Pocheptsov2020-09-231-4/+4
| | | | | | | | | | | | This fix is not final yet, it's just to plumb the serious bug/regression of accessing NSPasteBoard in some strange state and the one we have not populated yet/do not even own (?). Drag image(s) is broken atm and will be fixed in the follow-up patch. Pick-to: 5.15 Task-number: QTBUG-71939 Change-Id: I5c3ac3ec138d7407c2e0c206485478aa5244ae15 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-232-10/+10
| | | | | | | | | | | Modify special case locations to use the new API as well. Clean up some stale .prev files that are not needed anymore. Clean up some project files that are not used anymore. Task-number: QTBUG-86815 Change-Id: I9947da921f98686023c6bb053dfcc101851276b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QCocoaDrag::maybeDragMultipleItems - fix erroneous size checkTimur Pocheptsov2020-09-211-1/+1
| | | | | | | | | | | | | Due to somewhat inverted logic introduced by the 8481a9fc974a1f1dd44a, testing number of items in a pasteboard happens _before_ we fill it, which is wrong and useless. As a result, maybeDragMultipleItems will prevent the single item drag. Pick-to: 5.15 Task-number: QTCREATORBUG-24665 Task-number: QTBUG-86786 Change-Id: Ia4be9fc56677575bb363cbb8b1adbea59e6c3b0b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>