Cocoa: Improve window activation handling.
Make Qt window activation follow the Cocoa key window, with one exception: Popup windows become the key window but not the Qt active window. Change-Id: Ic4d8685737fa3ec5c15a68b81844929370c9cd8e Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
parent
68d291c12a
commit
7445d41e32
@ -111,6 +111,7 @@ public:
|
||||
void windowDidMove();
|
||||
void windowDidResize();
|
||||
void windowWillClose();
|
||||
bool windowIsPopupType() const;
|
||||
|
||||
void setCurrentContext(QCocoaGLContext *context);
|
||||
QCocoaGLContext *currentContext() const;
|
||||
|
@ -303,6 +303,15 @@ void QCocoaWindow::windowWillClose()
|
||||
QWindowSystemInterface::handleSynchronousCloseEvent(window());
|
||||
}
|
||||
|
||||
bool QCocoaWindow::windowIsPopupType() const
|
||||
{
|
||||
Qt::WindowType type = window()->windowType();
|
||||
if (type == Qt::Tool)
|
||||
return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac.
|
||||
|
||||
return ((type & Qt::Popup) == Qt::Popup);
|
||||
}
|
||||
|
||||
void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
|
||||
{
|
||||
m_glContext = context;
|
||||
@ -348,7 +357,7 @@ NSWindow * QCocoaWindow::createNSWindow()
|
||||
|
||||
// Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
|
||||
if ((type & Qt::Popup) == Qt::Popup) {
|
||||
if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::SplashScreen) {
|
||||
if (windowIsPopupType()) {
|
||||
styleMask = NSBorderlessWindowMask;
|
||||
} else {
|
||||
styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
|
||||
|
@ -146,24 +146,24 @@ static QTouchDevice *touchDevice = 0;
|
||||
|
||||
- (void)windowDidBecomeKey
|
||||
{
|
||||
// QWindowSystemInterface::handleWindowActivated(m_window);
|
||||
if (!m_platformWindow->windowIsPopupType())
|
||||
QWindowSystemInterface::handleWindowActivated(m_window);
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey
|
||||
{
|
||||
// QWindowSystemInterface::handleWindowActivated(0);
|
||||
if (!m_platformWindow->windowIsPopupType())
|
||||
QWindowSystemInterface::handleWindowActivated(0);
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain
|
||||
{
|
||||
// qDebug() << "window did become main" << m_window;
|
||||
QWindowSystemInterface::handleWindowActivated(m_window);
|
||||
}
|
||||
|
||||
- (void)windowDidResignMain
|
||||
{
|
||||
// qDebug() << "window did resign main" << m_window;
|
||||
QWindowSystemInterface::handleWindowActivated(0);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user