summaryrefslogtreecommitdiffstats
path: root/src/plugins
Commit message (Collapse)AuthorAgeFilesLines
* QNetworkInfo(Win): cleanupsMårten Nordheim2021-09-201-4/+3
| | | | | | | | | One signal emission was not labelled emit. Removed some unnecessary braces Change-Id: I1c0adde869e559056e60671619bfca33b1966d1e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Compile autotests for IntegrityTatiana Borisova2021-09-201-3/+4
| | | | | | | | | - process environment/DNS are OFF for INTEGRITY Task-number: QTBUG-96176 Pick-to: 6.2 Change-Id: I189a97f88c96a428586c31a66b8d250e04482900 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* macOS: Remove remnant of popup closing logic from Cocoa pluginVolker Hilsheimer2021-09-182-30/+0
| | | | | | | | This monitor call back is never called when a popup is open and there's mouse action. Change-Id: I6c45b600ebea16e5fd6c5b3af66fd1242973d747 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* xcb: convert last screen to fake when no screenLiang Qi2021-09-183-17/+57
| | | | | | | | | | | | | | | | | available for xrandr 1.5 like we did before for xrandr 1.4 (since a094af001795c9651b299d700a992150d1aba33a). Tested with following combination: * qtbase -DECM_ENABLE_SANITIZERS=address cmake build * examples/widgets/widgets/wiggly with ASAN_OPTIONS=verify_asan_link_order=0 env * xrandr --output LastScreen --off and --auto. Fixes: QTBUG-96247 Task-number: QTBUG-42985 Change-Id: Idd95d1a3aa057d23e3adb6635dd1acbb2c853497 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove conditioning on Android embeddedEdward Welbourne2021-09-174-6/+6
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* android: Implement nativeResourceForContextLaszlo Agocs2021-09-172-0/+14
| | | | | | | | | | | | | | | | | | To bring the plugin on par with xcb and eglfs in this regard. New code has a better way to query these via QOpenGLContext::nativeInterface() (or, more correctly, will have a better way once the ability to query the config and display is added in a follow up patch), but having some symmetry between the EGL-based plugins won't hurt. This is relevant in particular with OpenXR: not knowing the EGLConfig makes it impossible to use the API on Android: https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrGraphicsBindingOpenGLESAndroidKHR Pick-to: 6.2 Change-Id: I163aed070096a4b58d3f650906c2f70ea31b3231 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix loading of OpenSSL on macOS versions that ship its own OpenSSLTor Arne Vestbø2021-09-171-0/+5
| | | | | | | | | | | The unversioned libcrypto.dylib that's shipped with macOS 10.15 will result in a crash if loaded, with a message saying that the unversioned library should not be loaded, as it doesn't provide a stable ABI. Task-number: QTBUG-95249 Pick-to: 6.2 5.15 Change-Id: I49325e5d675155e90840cc93623549f725bc77b4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Revert "Qt xcb: remove false detects of Qt::GroupSwitchModifier"Liang Qi2021-09-171-3/+3
| | | | | | | | | | | | | | | | | This reverts commit 25a7034d78aeb12726a1052d64c0aa3314a1f69d. The change makes the 5th modifier key broken, which is more serious than Backspace key doesn't work in CapsLock on. And we don't have a better solution for both of them now, perhaps it's better to keep the old behavior in 6.2 LTS. Task-number: QTBUG-49771 Fixes: QTBUG-95108 Fixes: QTBUG-95289 Pick-to: 6.2 6.2.0 5.15 Change-Id: Ie5d0aafa562b5097e089cafc83ae227c75c6d752 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Use new QPlatformTheme::appearance() functionMitch Curtis2021-09-171-20/+21
| | | | | | | | Instead of qt_mac_applicationIsInDarkMode(). Task-number: QTBUG-94859 Change-Id: Ib64c081adfafb2843a7593d0e35668cce70cffd0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add QPlatformTheme::Appearance for detecting light/dark modesMitch Curtis2021-09-174-0/+14
| | | | | | | | | And implement it on Windows and macOS. Fixes: QTBUG-83908 Fixes: QTBUG-94859 Change-Id: I7b0c062adf5d4dbaefa64c862ab8ab1348809d71 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: convert mask region to native geometryMorten Johan Sørvig2021-09-152-2/+3
| | | | | | | | | | | QWindow::mask() returns a region in device independent geometry which can’t be used directly by the platform plugin. Pick-to: 6.2 5.15 Task-number: QTBUG-94770 Change-Id: I76279bc74cfabe315178327938f485f4447568be Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: don't block CMD+H while a popup is openVolker Hilsheimer2021-09-151-7/+2
| | | | | | | | | | | | | | | | | The shortcut hides the application, which works in native apps such as Xcode or Safari also while a popup menu (or combobox drop down) is open. This essentially reverts 29104c85db53e7c0c0aaf3fe78f84b737fce4886, which introduced the blocking of CMD+H to prevent the popup stack in the Cocoa plugin from going out of sync. With that stack gone after the previous commits, this is no longer a problem. Task-number: QTBUG-82626 Task-number: QTBUG-96450 Task-number: QTBUG-58727 Pick-to: 6.2 Change-Id: I35603d971741f03b793b7839b183b7ab37200647 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: remove the popup stack from QCocoaIntegrationVolker Hilsheimer2021-09-155-77/+2
| | | | | | | | | Since popup handling is now done exclusively by Q(Gui)Application, we don't need to keep track of the popup stack in the Cocoa plugin anymore. Fixes: QTBUG-96450 Change-Id: I869f36f52bc2210b6c92efd9425502de4122c553 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: remove mouse and key grabbing logic from Cocoa pluginVolker Hilsheimer2021-09-152-15/+0
| | | | | | | | | | For QGuiApplication with QWindow, no other QPA plugins do so, and for QApplication with QWidgets, QApplication implements popup functionality consistently. Task-number: QTBUG-96450 Change-Id: I47489296e0e470d8948ca7858d0a2608c58b2975 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Remove duplicate code closing popups on window interactionVolker Hilsheimer2021-09-154-36/+0
| | | | | | | | | | | | | | | | | | | After 70b94eea10d7af83cced09296755a8af28e167b5, all popups are closed on mouseDown within the window frame. As with native applications, the popup is closed on press, and before the press is delivered to the frame (ie before the jewel is shown as depressed). The previous notification handlers for window moving, minimizing, and closing can now be removed, together with the alternative implementation of closePopups that relies on the Cocoa plugin maintaining its own popup stack. This reverts 048e66a11d87845eaba9e8cf23de3fb4acac924d. Task-number: QTBUG-96450 Task-number: QTBUG-77833 Change-Id: I165f3caa64bf9a7b4c4d5455ca33e87029d75f73 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Use QGuiApplication popup APIs in Cocoa pluginVolker Hilsheimer2021-09-151-4/+3
| | | | | | | | | This removes more dependencies to the Cocoa plugin managing its own popup stack. Task-number: QTBUG-96450 Change-Id: Id01577739af525a34728f27b790b9aaac29705f2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Compute NSWindow background color without checking styleMaskTor Arne Vestbø2021-09-152-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | The check for styleMask == NSWindowStyleMaskBorderless to decide whether to clear the NSWindow background was broken, as NSWindowStyleMaskBorderless has the value 0, but is only supposed to be compared to its companion NSWindowStyleMaskTitled (with value 1). A window can perfectly well be NSWindowStyleMaskBorderless and NSWindowStyleMaskMiniaturizable e.g., so by comparing directly to NSWindowStyleMaskBorderless instead of masking to the first bit first we ended up making miniaturizable windows non-translucent. We now check the Qt::FramelessWindowHint directly, and also whether the window is opaque. Ideally we'd have QWindow flags that could plumb WA_NoSystemBackground from Qt Widgets, as well as a background color property on QWindow to control the system background, but in the meantime we'll have to use the FramelessWindowHint heuristic. The QWidget docs have been updated to reflect this. Task-number: QTBUG-95042 Pick-to: 6.2 Change-Id: I0d40eecace60883c205ebb8c76cef1092cdf1144 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QAndroidSystemLocale: add missing day and month format handlingIvan Solovev2021-09-151-0/+12
| | | | | | | | | | | This patch adds support for previously missing Narrow format, as well as standalone day name handling for QAndroidSystemLocale Task-number: QTBUG-84877 Pick-to: 6.2 Change-Id: Ib74fb8f0e12f03ab96022abaf26ac9039ffaa60b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* macOS: Move handleMouseEvent: to MouseAPI categoryTor Arne Vestbø2021-09-141-53/+53
| | | | | | | Fixes warning of method definition not found. Change-Id: I87866785d1564e29fc356c033ae8cf972548ea7f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Don't close popups in Cocoa plugin for most mouse eventsVolker Hilsheimer2021-09-133-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QWidget and QApplication handle popup closing for most events at the right time for the Qt-internal state logic. On other platforms popup QWindows are never closed automatically when clicking outside. So don't close any popups in the Cocoa plugin either, and let the Qt logic take care of it. This ensures that window activation is done at the right time, that Qt's modal popup stack is consistent, and that mouse replay for events closing a popup works. There are however two exceptions: mouse events in the window frame don't produce a QMouseEvent for Qt; and mouse events in a modally blocked (by Cocoa) window don't reach Qt at all. For those case, the logic in QWidget and QApplication is not enough. For the former, leave the change introduced in 70b94eea10d7af83cced092967 to explicitly close popups for LMB down in the frame. This still needs to happen before the event is delivered. For the latter case, deliver the event explicitly to Qt when we discover that the target window is modally blocked while a popup is active. The handleMouseEvent implementation then takes care of the redirect to the active popup, and Qt will further respect the modal stack in the QApplication::isWindowBlocked implementation. Change-Id: I578eb5e6aebc897a0ff1f69bc5c53bcaa05d138d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: don't replay mouse presses that closed a popupVolker Hilsheimer2021-09-131-0/+2
| | | | | | | | | | | | | | On macOS, we only follow the native behavior to not replay mouse presses outside of a popup because we close popups in the QPA plugin before any popup-specific logic in QApplication kicks in, so a press that closed a popup is never seen by Qt at all. Before we can remove the popup closing code from the QPA plugin, implement the existing platform style hint for Cocoa to prevent mouse press replays. Change-Id: I2328f706ba148ece2d0e3fb4e71fe9123ab5e205 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use qmath.h's conversions between degrees and radiansEdward Welbourne2021-09-101-3/+4
| | | | | | | | The make the semantics overt and avoid the joys of yet another approximation to pi/180 hard-coded in our source-code. Change-Id: I9dcbaada2e7de119e385fc7056bc601ecd59311a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Adapt the implementation of QDesktopService on iOS to AndroidLars Schmertmann2021-09-101-6/+4
| | | | | Change-Id: I8c2048155c5c065b5cdf7ad4cef9d8a446a0561d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Android: Enable QDesktopServiceLars Schmertmann2021-09-102-2/+49
| | | | | | | | | | | | QDesktopServices::openUrl(const QUrl &url) is already implemented on Android. But even if it is possible to set an URL handler, the mechanism to invoke it is missing. With this commit the URL handler will work on Android like it is already working on iOS. Task-number: QTBUG-84382 Pick-to: 6.2 Change-Id: Ic560bd380f1cc59586861aa1a6a3ea064276a39e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* macOS: process all activation events synchronouslyMorten Johan Sørvig2021-09-101-1/+2
| | | | | | | | | | | | Commit ed483346 changed the main code path to deliver activation events synchronously, however it looks like an additional code path was missed. Use SynchronousDelivery also in becomeFirstResponder. Pick-to: 6.2 Change-Id: I9061868b0dd0db0252f281e3a974cffe795af38f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Move pointingDeviceFor helper to top of fileVolker Hilsheimer2021-09-081-30/+30
| | | | | | | | | It's confusing to have it in the middle of the code implementing the various interfaces. Make review of follow up patches easier by moving it out of the way. Change-Id: I10f6e8f7642ec0cb14ae31b14a023c6a9ef455d9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* OpenSSL: Let people opt-in to use TLS 1.3 PSK callbackMårten Nordheim2021-09-081-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's a workaround for the workaround... If TLS 1.3 was explicitly chosen and the PSK callback is set then without this patch the callback is never called since, with TLS 1.3, PSK would only be queried once at the start of a connection. It can now be re-enabled with an environment variable. A new API should be added to address the new requirements of PSK with TLS 1.3: For session resumption the connection MUST use the same hash algorithm as in the original session. For new sessions the hash algorithm must be decided ahead of time, or a default will be used (as defined by the standard). A user can also pass along multiple identity+key pairs and the server will pick one it recognizes. This is not something we can currently do with the preSharedKeyAuthenticationRequired callback. [ChangeLog][Network][QSslSocket][OpenSSL] When using TLS 1.3 we suppress the first callback from OpenSSL about pre-shared keys, as it doesn't conform to the past behavior which preSharedKeyAuthenticationRequired provided. With this update you can opt-out of that workaround by setting the QT_USE_TLS_1_3_PSK environment variable Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-95670 Change-Id: Ia7454bbbf394cbcb859de333b371d0890b42a1c3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* High-dpi configuration change testingMorten Johan Sørvig2021-09-083-1/+42
| | | | | | | | | | | | Export configuration() and setConfiguration() from the offscreen platform plugin using QPlatformNativeInterface. tst_qighdpi can then resolve and make use of them since it always uses the offscreen platform plugin. Add screenDpiChange() auto test. Change-Id: I459b4df5d94ec4991234a346e3a94618cb3485e9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Offscreen: add configuration update APIMorten Johan Sørvig2021-09-085-42/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for updating the platform configuration at runtime, which enables use cases such as changing the screen configuration from an auto test. Provide functions for getting and setting the complete configuration as a QJsonObject: QJsonObject configuration() void setConfiguration(QJsonObject) User code can then either set a completely new configuration, or make a smaller update by using a get-modify-set sequence: // Set the logical DPI for screen 0 to 192: auto config = configuration(); config[“screens”][0][“logicalDpi] = 192 setConfiguration(config); This approach means we can expose a minimal but complete API, at the cost of doing more work in the offscreen plugin in order to figure out what changed. Note that this change does not export thew API from the platform plugin. Change-Id: If776c36d5ae6d72dca715cc8e89e42768ed32c60 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Cocoa: Make sure we can display multiple sheets for the same NSWindowDoris Verria2021-09-071-1/+5
| | | | | | | | | | | | | | | On macOS, to display a modal with Qt::WindowModality set, or of type Qt::Sheet, we call beginSheet:completinHandler:. However, this method won't display the specified sheet unless the current active one is dismissed, which is a different behavior than what we expect for this case. Use beginCriticalSheet:completionHandler: whenever we already have an active sheet attached to the NSWindow, which allows us to display multiple sheets for the same window. Fixes: QTBUG-91059 Pick-to: 5.15 6.1 6.2 Change-Id: I86bdbcbd63758edbbc48a8aade0178917dcb0e5b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* xcb: update connection time when possibleLiang Qi2021-09-062-3/+19
| | | | | | | | | At least we try to do it with all events triggered by user. Pick-to: 5.15 6.1 6.2 Change-Id: I28b399a2517600f7da2c91a50fecdf58b9d81fb6 Reviewed-by: JiDe Zhang <zhangjide@uniontech.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* macOS: Report preedit cursor position and cursor visibility correctlyTor Arne Vestbø2021-09-061-2/+9
| | | | | | | | | | | | | | | | Unfortunately QInputMethodEvent::Cursor defines length == 0 as the cursor being hidden, and length > 0 as being visible. This is the opposite of what native macOS application do. A future improvement here would be to base the QInputMethodEvent logic on QStyle::SH_BlinkCursorWhenTextSelected, which we already respect for normal selections. That would also allow us to use QInputMethodEvent::Cursor to set the preedit selection, which we currently have to fake via QInputMethodEvent::TextFormat. Pick-to: 6.2 Change-Id: I75b5d8c5403283a0988355e440a98b4df35ec995 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QSslCertificate(OpenSSL plugin): fix memory leaks in extension 'parser'Timur Pocheptsov2021-09-043-12/+63
| | | | | | | | | | They went unnoticed previously because of lazy evaluation, which is not the case anymore. Fixes: QTBUG-96155 Pick-to: 6.2 5.15 Change-Id: I46026a24b354c1db7c10d84fceae06c4ab7cc0fc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* macOS: Don't rely on invalidateCursorRectsForView when mouse is over viewTor Arne Vestbø2021-09-031-0/+14
| | | | | | | | | | | | | | | | | | | | | | Calling invalidateCursorRectsForView will normally result in a updateCursor callback, where we then set the current cursor using [NSCursor set]. But if an override cursor is set by AppKit, which happens for example when hovering over a resizable window's theme frame, then AppKit ignores the call to invalidateCursorRectsForView. And it will not consult the view when the override cursor is unset again, which results in the cursor being reset back to the default arrow cursor instead of the cursor that was set when we initiated the invalidateCursorRectsForView call. We need to hit-test to confirm that the mouse is over the view, as there might be child views in the mix that also have custom cursors, and we don't want to activate the parent view's cursor unless we're actually over that view. Fixes: QTBUG-81552 Fixes: QTBUG-96003 Pick-to: 6.2 5.15 Change-Id: I52573ab7be82f28c6a1cf686bd4b133551cfe98b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* cocoa: use TouchPad deviceType for trackpadShawn Rutledge2021-09-031-0/+1
| | | | | | | | | | | WheelHandler { acceptedDevices: PointerDevice.TouchPad } doesn't react unless we use the right type. Amends 69c833dae91d004b48f815e0156d6caeb4cdb491 Pick-to: 6.2 Change-Id: I813de096b87f3af4dfcf5510abc0d0bd9c15b689 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* xcb: support xrandr(1.5) monitor setupLiang Qi2021-09-017-119/+429
| | | | | | | | | | | | | | | | | | | | | | | | More information about monitor in xrandr 1.5, see https://keithp.com/blogs/MST-monitors/ Since this change, screen is logical instead of physical. If xrandr 1.5 and later is installed, Qt screen info will get from xrandr monitor object instead of xrandr output if only have 1.2 to 1.4. Users can manipulate monitor as they want, for example, a combination for two physical screens, half of one screen and etc. Didn't have chance to access MST monitors, but it should work if xrandr monitor object was created automatically. [ChangeLog][xcb] Qt screen info will get from xrandr monitor object if 1.5 is installed. Fixes: QTBUG-65457 Change-Id: Iad339cc0d4293b2403b4ef6bf6eb770feb3e685f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-013-19/+15
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* TLS plugins: Prefix with 'q'Mårten Nordheim2021-08-308-8/+8
| | | | | | | | For consistency with other plugins. Pick-to: 6.2 Change-Id: I45507389a42e645c94f1ca3f32262a2181f282f7 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* macOS: Hide mouse cursor when initiating IM enabled text inputTor Arne Vestbø2021-08-271-0/+13
| | | | | | | Fixes: QTBUG-72744 Pick-to: 6.2 Change-Id: I952710e88a11fd00498562c9011461a010f02f7b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Correctly implement attributedSubstringForProposedRangeTor Arne Vestbø2021-08-271-6/+36
| | | | | | | | | | | | | | | | The substring range refers to the entire text of the focus object, not just the selection. As there is no way to pull out the entire text via input method queries we do the best we can via ImTextBeforeCursor and ImTextAfterCursor. Returning the correct substring enables input method features such as backtracking into already committed text with the Hiragana IM, as well as the Keyboard Viewer's 'Current Text' toolbar. Pick-to: 6.2 Change-Id: I53286ef1e8e7c5fba37858dda7317ae74d95b528 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Assume input method handles key eventTor Arne Vestbø2021-08-272-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When input methods are enabled for the focus object we send key events through interpretKeyEvents, which will involve the input method in the key event processing. The input method will get back to us with callbacks such as insertText, setMarkedText, or doCommandBySelector. In the case of insertText, when the inserted text matches the originating key event's text, we opt to not send the text as an QInputMethodEvent, and instead fall back to sending it as a normal QKeyEvent. The reason for this is that Qt's IM protocol was designed to handle composited text, so sending non-composited (but IM-initiated) text input as IM events is unexpected (see 2d05d3bd2815c220474b3c07bf3f2ef7417d3070). However, we cannot assume that the input method will always call us back with one of the above mentioned methods. The input method can very well eat the event as part of its own operation. This happens for example when pressing and holding 'a' in a US English keyboard layout, which will pop up an input panel for the various accents available. Or it may happen when using the AquaSKK third party IM, which uses the 'l' key to switch the input mode to latin without producing any characters. To allow these input methods the freedom to control the processing of key events we need to reverse the logic for when we send key events as QKeyEvent. We now assume that the IM will handle the event, and only trigger QKeyEvent in two cases where we explicitly were called back by the IM, but decided that a QKeyEvent is needed: - If the IM calls insertText and we consider the text simple text - If the IM calls doCommandBySelector and we can't find a matching selector for the command. We only implement insertNewline and cancel, so in all other cases we want to pass on the key event to let the focus object handle it, for example for 'Select All' and similar key combinations. Fixes: QTBUG-46300 Fixes: QTBUG-71394 Pick-to: 6.2 Inspired-by: Vladimir Belyavsky Change-Id: I9a73a8e1baa2ebe0c5df1166a9ec3d9843632bb1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Handle replacement range during marking of textTor Arne Vestbø2021-08-271-0/+16
| | | | | | | | | | | | The input method may include already committed text when marking text, in which case the replacement range reflects the position and length of the existing text. We handle this the same way we do replacement ranges in insertText. Pick-to: 6.2 Change-Id: I148e4701318a59c7e0d9441d157199d7c8606f43 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Handle IM insertNewline by sending synthetic Qt::Key_ReturnTor Arne Vestbø2021-08-273-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Depending on the input method, pressing enter may result in simply dismissing the input method editor, without confirming the composition. For example with Hiragana, pressing 'a', then 'Tab', and then 'Enter'. In other cases it may confirm the composition as well, for example with Hiragana, pressing 'a' and then 'Enter'. And in some cases the IME will produce an explicit new line, for example with US English, pressing '~' and then 'Enter', or with 2-Set Korean, pressing 'a', then 'j', and then 'Enter'. Semantically, the input method has then asked us to insert a newline, and we should probably do so via an QInputMethodEvent, either directly or via [self insertText:@"\r"]. This is also how NSTextView handles the command. But, if we did, we would bypass all the code in Qt (and clients) that assume that pressing the return key results in a key event, for example the QLineEdit::returnPressed logic. To ensure that clients will still see the Qt::Key_Return key event, we send it as a normal key event. But, we can not fall back to handleKeyEvent for this, as the original key event may have text that reflects the combination of the inserted text and the newline, e.g. "~\r". We have already inserted the composition, so we need to follow up with a single newline event. Task-number: QTBUG-39125 Pick-to: 6.2 Change-Id: If1e95687e6d5b06011692175a325f457b0b8a72f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Factor out key event handling into helper structTor Arne Vestbø2021-08-272-72/+140
| | | | | | | | | | | This allows us to share code between handleKeyEvent: and flagsChanged: for parsing the incoming NSEvent, and allows for sending key events from other call sites in the future without duplicating the parsing and sending logic. Pick-to: 6.2 Change-Id: Ic63f740523496a9432e439663a20f78b5bc234c5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Return early from key handler if shortcut was handledTor Arne Vestbø2021-08-271-7/+3
| | | | | | | | The code paths after accepting a shortcut event can never be hit. Pick-to: 6.2 Change-Id: Ida77417adb8fcfd25a4b20c4eb86056b3769f014 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* wasm: add Emscripten module accessor to qtloader.jsMorten Johan Sørvig2021-08-271-0/+10
| | | | | | | | | | | | | | After enabling -s MODULARIZE=1 there is no longer a global MODULE object. Add module() accessor which can be used to retrieve the Emscripten module. This does not really fit with the current state tracking since the app transitions from “loading” to “running” before the module object is ready. We’ll have to revisit this at some point. Change-Id: Ib7191cf4ce436e1de99f84b63ed4c10936fa62b1 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* macOS: Check NSEvent.characters to determine dead key stateTor Arne Vestbø2021-08-271-2/+3
| | | | | | | | | | | | | | We map NSEvent.characters to text that we pass on in our QKeyEvent, but for Qt 4 compatibility we explicitly skip function keys and arrow keys, as the text these events produce are control characters. See 4dbce2a469608194527188a136baa3e812caf361. However, these keys are not dead keys, so we can't use the resolved text we're planning to pass on to Qt to determine if they are. Pick-to: 6.2 Change-Id: Ib59f0489ae014379c699600f14634c55161ccc8a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Use current NSEvent to determine if IM text matches key eventTor Arne Vestbø2021-08-273-13/+17
| | | | | | | | | Gives us one less state member to worry about in the IM machinery. Task-number: QTBUG-35700 Pick-to: 6.2 Change-Id: Iaa06b29015f9b9594b8107b74a8931f076a26e12 Reviewed-by: Liang Qi <liang.qi@qt.io>
* macOS: Modernize and clean up key event handlingTor Arne Vestbø2021-08-261-54/+56
| | | | | | | | | | | | | - Pass key event type as QEvent::Type - Use proper type for NSEventModifierFlags - Use modern Objective-C property access in key handler - Modernize flagsChanged implementation using ranged-for - Use explicit Qt::Key type in key handling - Add FIXME comments for dubious code Pick-to: 6.2 Change-Id: I533e0a5685108dc3cdccd2b276b4eb7a729d172e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Move replacement range calculations into helper methodsTor Arne Vestbø2021-08-261-35/+70
| | | | | | | | We're going to need this logic for marked text as well. Pick-to: 6.2 Change-Id: I461024c3df0c4956c794f16d1cb31fc6b0efe4c5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>