macOS: Implement NSTextInputClient.windowLevel

Without this optional NSTextInputClient method the input methods
will assume it's safe to place the input panel somewhere above
NSFloatingWindowLevel.

But our NSWindow level can potentially be higher than that, if
set via QWindow::setFlags(), or directly on the NSWindow.

In practice this can be observed by setting a level higher
than kCGDockWindowLevel on the NSWindow.

Account for this by returning the true window level.

Pick-to: 6.2
Change-Id: I77d9ac3c59e2f6de9b768c7519b2bc0f1e5fda1d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 709d2848e1d33be70c2b9a9ff0219a3bba1a5114)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e5b46f3ea75ea5f0980695b0655a8347f6f1965e)
This commit is contained in:
Ws ShawnWoo 2023-11-07 14:16:32 +08:00 committed by Qt Cherry-pick Bot
parent cd8f7a7619
commit eef97bb44e

View File

@ -505,6 +505,23 @@
return NSNotFound;
}
/*
Returns the window level of the text input.
This allows the input method to place its input panel
above the text input.
*/
- (NSInteger)windowLevel
{
// The default level assumed by input methods is NSFloatingWindowLevel,
// but our NSWindow level could be higher than that for many reasons,
// including being set via QWindow::setFlags() or directly on the
// NSWindow, or because we're embedded into a native view hierarchy.
// Return the actual window level to account for this.
return m_platformWindow ? m_platformWindow->nativeWindow().level
: NSNormalWindowLevel;
}
// ------------- Helper functions -------------
/*