Cocoa: Move window logging to qt.qpa.cocoa.window

Remove QT_COCOCA_ENABLE_WINDOW_DEBUG. Replace/Add
logging for window state changes and drawing.

The window identifier is now the QWindow (not the
platform window) everywhere since this object provides
more debug output.

Change-Id: I4ae56626015241279ab1b44d2b81c9d462b532a0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
Morten Johan Sørvig 2015-04-23 15:00:05 +02:00 committed by Timur Pocheptsov
parent f9e746959b
commit 3ee01f7403
6 changed files with 48 additions and 34 deletions

View File

@ -105,8 +105,6 @@ OTHER_FILES += cocoa.json
# DEFINES += QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR # DEFINES += QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR
# include ($$PWD/../../../../util/accessibilityinspector/accessibilityinspector.pri) # include ($$PWD/../../../../util/accessibilityinspector/accessibilityinspector.pri)
# Window debug support
#DEFINES += QT_COCOA_ENABLE_WINDOW_DEBUG
PLUGIN_TYPE = platforms PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QCocoaIntegrationPlugin PLUGIN_CLASS_NAME = QCocoaIntegrationPlugin

View File

@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaCocoaWindow)
class QPixmap; class QPixmap;
class QString; class QString;

View File

@ -77,6 +77,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaCocoaWindow, "qt.qpa.cocoa.window");
// //
// Conversion Functions // Conversion Functions
// //

View File

@ -374,9 +374,8 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_bottomContentBorderThickness(0) , m_bottomContentBorderThickness(0)
, m_normalGeometry(QRect(0,0,-1,-1)) , m_normalGeometry(QRect(0,0,-1,-1))
{ {
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::QCocoaWindow" << window();
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
#endif
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (tlw->type() == Qt::ForeignWindow) { if (tlw->type() == Qt::ForeignWindow) {
@ -409,9 +408,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
QCocoaWindow::~QCocoaWindow() QCocoaWindow::~QCocoaWindow()
{ {
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::~QCocoaWindow" << window();
qDebug() << "QCocoaWindow::~QCocoaWindow" << this;
#endif
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
[m_nsWindow makeFirstResponder:nil]; [m_nsWindow makeFirstResponder:nil];
@ -469,6 +466,8 @@ QSurfaceFormat QCocoaWindow::format() const
void QCocoaWindow::setGeometry(const QRect &rectIn) void QCocoaWindow::setGeometry(const QRect &rectIn)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setGeometry" << window() << rectIn;
QBoolBlocker inSetGeometry(m_inSetGeometry, true); QBoolBlocker inSetGeometry(m_inSetGeometry, true);
QRect rect = rectIn; QRect rect = rectIn;
@ -481,9 +480,7 @@ void QCocoaWindow::setGeometry(const QRect &rectIn)
} }
if (geometry() == rect) if (geometry() == rect)
return; return;
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::setGeometry" << this << rect;
#endif
setCocoaGeometry(rect); setCocoaGeometry(rect);
} }
@ -506,6 +503,7 @@ QRect QCocoaWindow::geometry() const
void QCocoaWindow::setCocoaGeometry(const QRect &rect) void QCocoaWindow::setCocoaGeometry(const QRect &rect)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setCocoaGeometry" << window() << rect;
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (m_contentViewIsEmbedded) { if (m_contentViewIsEmbedded) {
@ -629,6 +627,8 @@ void QCocoaWindow::show(bool becauseOfAncestor)
void QCocoaWindow::setVisible(bool visible) void QCocoaWindow::setVisible(bool visible)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setVisible" << window() << visible;
if (m_isNSWindowChild && m_hiddenByClipping) if (m_isNSWindowChild && m_hiddenByClipping)
return; return;
@ -638,9 +638,7 @@ void QCocoaWindow::setVisible(bool visible)
QCocoaWindow *parentCocoaWindow = 0; QCocoaWindow *parentCocoaWindow = 0;
if (window()->transientParent()) if (window()->transientParent())
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle()); parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::setVisible" << window() << visible;
#endif
if (visible) { if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating // We need to recreate if the modality has changed as the style mask will need updating
if (m_windowModality != window()->modality()) if (m_windowModality != window()->modality())
@ -861,9 +859,6 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
if (m_drawContentBorderGradient) if (m_drawContentBorderGradient)
styleMask |= NSTexturedBackgroundWindowMask; styleMask |= NSTexturedBackgroundWindowMask;
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug("windowStyleMask of '%s': flags %X -> styleMask %lX", qPrintable(window()->title()), (int)flags, styleMask);
#endif
return styleMask; return styleMask;
} }
@ -985,7 +980,8 @@ bool QCocoaWindow::isAlertState() const
void QCocoaWindow::raise() void QCocoaWindow::raise()
{ {
//qDebug() << "raise" << this; qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::raise" << window();
// ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm) // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm)
if (!m_nsWindow) if (!m_nsWindow)
return; return;
@ -1026,6 +1022,7 @@ void QCocoaWindow::raise()
void QCocoaWindow::lower() void QCocoaWindow::lower()
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::lower" << window();
if (!m_nsWindow) if (!m_nsWindow)
return; return;
if (m_isNSWindowChild) { if (m_isNSWindowChild) {
@ -1078,13 +1075,11 @@ void QCocoaWindow::propagateSizeHints()
if (!m_nsWindow) if (!m_nsWindow)
return; return;
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::propagateSizeHints" << window() << "\n"
qDebug() << "QCocoaWindow::propagateSizeHints" << this; << " min/max" << windowMinimumSize() << windowMaximumSize()
qDebug() << " min/max" << windowMinimumSize() << windowMaximumSize(); << "size increment" << windowSizeIncrement()
qDebug() << "size increment" << windowSizeIncrement(); << " basesize" << windowBaseSize()
qDebug() << " basesize" << windowBaseSize(); << " geometry" << windowGeometry();
qDebug() << " geometry" << windowGeometry();
#endif
// Set the minimum content size. // Set the minimum content size.
const QSize minimumSize = windowMinimumSize(); const QSize minimumSize = windowMinimumSize();
@ -1116,6 +1111,7 @@ void QCocoaWindow::propagateSizeHints()
void QCocoaWindow::setOpacity(qreal level) void QCocoaWindow::setOpacity(qreal level)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setOpacity" << level;
if (m_nsWindow) { if (m_nsWindow) {
[m_nsWindow setAlphaValue:level]; [m_nsWindow setAlphaValue:level];
[m_nsWindow setOpaque: isOpaque()]; [m_nsWindow setOpaque: isOpaque()];
@ -1124,6 +1120,7 @@ void QCocoaWindow::setOpacity(qreal level)
void QCocoaWindow::setMask(const QRegion &region) void QCocoaWindow::setMask(const QRegion &region)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMask" << window() << region;
if (m_nsWindow) if (m_nsWindow)
[m_nsWindow setBackgroundColor:[NSColor clearColor]]; [m_nsWindow setBackgroundColor:[NSColor clearColor]];
@ -1133,6 +1130,7 @@ void QCocoaWindow::setMask(const QRegion &region)
bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setKeyboardGrabEnabled" << window() << grab;
if (!m_nsWindow) if (!m_nsWindow)
return false; return false;
@ -1145,6 +1143,7 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
bool QCocoaWindow::setMouseGrabEnabled(bool grab) bool QCocoaWindow::setMouseGrabEnabled(bool grab)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMouseGrabEnabled" << window() << grab;
if (!m_nsWindow) if (!m_nsWindow)
return false; return false;
@ -1162,6 +1161,8 @@ WId QCocoaWindow::winId() const
void QCocoaWindow::setParent(const QPlatformWindow *parentWindow) void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setParent" << window() << (parentWindow ? parentWindow->window() : 0);
// recreate the window for compatibility // recreate the window for compatibility
bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden]; bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden];
recreateWindow(parentWindow); recreateWindow(parentWindow);
@ -1245,6 +1246,7 @@ void QCocoaWindow::windowDidEndLiveResize()
bool QCocoaWindow::windowShouldClose() bool QCocoaWindow::windowShouldClose()
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::windowShouldClose" << window();
// This callback should technically only determine if the window // This callback should technically only determine if the window
// should (be allowed to) close, but since our QPA API to determine // should (be allowed to) close, but since our QPA API to determine
// that also involves actually closing the window we do both at the // that also involves actually closing the window we do both at the
@ -1285,6 +1287,9 @@ QCocoaGLContext *QCocoaWindow::currentContext() const
void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
{ {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::recreateWindow" << window()
<< "parent" << (parentWindow ? parentWindow->window() : 0);
bool wasNSWindowChild = m_isNSWindowChild; bool wasNSWindowChild = m_isNSWindowChild;
BOOL requestNSWindowChild = qt_mac_resolveOption(NO, window(), "_q_platform_MacUseNSWindow", BOOL requestNSWindowChild = qt_mac_resolveOption(NO, window(), "_q_platform_MacUseNSWindow",
"QT_MAC_USE_NSWINDOW"); "QT_MAC_USE_NSWINDOW");
@ -1621,10 +1626,6 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
} }
} }
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::syncWindowState" << newState << "actual" << predictedState << "was" << m_synchedWindowState << "effectively maximized" << m_effectivelyMaximized;
#endif
// New state is now the current synched state // New state is now the current synched state
m_synchedWindowState = predictedState; m_synchedWindowState = predictedState;
} }
@ -1817,7 +1818,9 @@ void QCocoaWindow::exposeWindow()
m_isExposed = true; m_isExposed = true;
m_exposedGeometry = geometry(); m_exposedGeometry = geometry();
m_exposedDevicePixelRatio = devicePixelRatio(); m_exposedDevicePixelRatio = devicePixelRatio();
QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), m_exposedGeometry.size())); QRect geometry(QPoint(0, 0), m_exposedGeometry.size());
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow: exposeWindow" << window() << geometry;
QWindowSystemInterface::handleExposeEvent(window(), geometry);
} }
} }
@ -1827,6 +1830,8 @@ void QCocoaWindow::obscureWindow()
if (m_isExposed) { if (m_isExposed) {
m_geometryUpdateExposeAllowed = false; m_geometryUpdateExposeAllowed = false;
m_isExposed = false; m_isExposed = false;
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::obscureWindow" << window();
QWindowSystemInterface::handleExposeEvent(window(), QRegion()); QWindowSystemInterface::handleExposeEvent(window(), QRegion());
} }
} }
@ -1853,7 +1858,10 @@ void QCocoaWindow::updateExposedGeometry()
m_isExposed = true; m_isExposed = true;
m_exposedGeometry = geometry(); m_exposedGeometry = geometry();
m_exposedDevicePixelRatio = devicePixelRatio(); m_exposedDevicePixelRatio = devicePixelRatio();
QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), m_exposedGeometry.size()));
QRect geometry(QPoint(0, 0), m_exposedGeometry.size());
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::updateExposedGeometry" << window() << geometry;
QWindowSystemInterface::handleExposeEvent(window(), geometry);
} }
QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint) QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint)

View File

@ -369,9 +369,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
if (m_platformWindow->m_inSetStyleMask && !self.window) if (m_platformWindow->m_inSetStyleMask && !self.window)
return; return;
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qCDebug(lcQpaCocoaWindow) << "[QNSView udpateGeometry:]" << m_window
qDebug() << "QNSView::udpateGeometry" << m_platformWindow << geometry; << "current" << m_platformWindow->geometry() << "new" << geometry;
#endif
// Call setGeometry on QPlatformWindow. (not on QCocoaWindow, // Call setGeometry on QPlatformWindow. (not on QCocoaWindow,
// doing that will initiate a geometry change it and possibly create // doing that will initiate a geometry change it and possibly create
@ -514,6 +513,8 @@ QT_WARNING_POP
- (void) flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset - (void) flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset
{ {
qCDebug(lcQpaCocoaWindow) << "[QNSView flushBackingStore:]" << m_window << region.rectCount() << region.boundingRect() << offset;
m_backingStore = backingStore; m_backingStore = backingStore;
m_backingStoreOffset = offset * m_backingStore->getBackingStoreDevicePixelRatio(); m_backingStoreOffset = offset * m_backingStore->getBackingStoreDevicePixelRatio();
foreach (QRect rect, region.rects()) foreach (QRect rect, region.rects())
@ -576,6 +577,8 @@ QT_WARNING_POP
- (void) drawRect:(NSRect)dirtyRect - (void) drawRect:(NSRect)dirtyRect
{ {
qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << qt_mac_toQRect(dirtyRect);
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
if (m_glContext && m_shouldSetGLContextinDrawRect) { if (m_glContext && m_shouldSetGLContextinDrawRect) {
[m_glContext->nsOpenGLContext() setView:self]; [m_glContext->nsOpenGLContext() setView:self];

View File

@ -64,6 +64,7 @@
#include "QtCore/qvariant.h" #include "QtCore/qvariant.h"
#include "QtCore/qmimedata.h" #include "QtCore/qmimedata.h"
#include "QtCore/qpointer.h" #include "QtCore/qpointer.h"
#include "QtCore/qloggingcategory.h"
#include "private/qcore_mac_p.h" #include "private/qcore_mac_p.h"