Create NSWindow subclass.
authorMorten Sorvig <morten.sorvig@nokia.com>
Mon, 15 Aug 2011 11:09:18 +0000 (13:09 +0200)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>
Thu, 18 Aug 2011 07:46:57 +0000 (09:46 +0200)
Allows us to override canBecomeKeyWindow etc.

Change-Id: Ia74006ac85acb98e8a0fe0a8cdc8e5e0b9aee5c4
Reviewed-on: http://codereview.qt.nokia.com/2955
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
src/plugins/platforms/cocoa/qcocoawindow.h
src/plugins/platforms/cocoa/qcocoawindow.mm

index e301c48..92fc026 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
+@interface QNSWindow : NSWindow {
+
+}
+
+@end
+
 class QCocoaWindow : public QPlatformWindow
 {
 public:
@@ -76,13 +82,14 @@ public:
 
 protected:
     void determineWindowClass();
-    NSWindow *createWindow();
+    QNSWindow *createWindow();
     NSRect globalGeometry(const QRect localWindowGeometry) const;
     QRect windowGeometry() const;
     QCocoaWindow *parentCocoaWindow() const;
+
 private:
     friend class QCocoaBackingStore;
-    NSWindow *m_nsWindow;
+    QNSWindow *m_nsWindow;
     QNSView *m_contentView;
     NSView *m_windowSurfaceView;
     quint32 m_windowAttributes;
index fefdbc8..7e88cdb 100644 (file)
 
 #include <QDebug>
 
+@implementation QNSWindow
+
+- (BOOL)canBecomeKeyWindow
+{
+    return YES;
+}
+
+- (BOOL)canBecomeMainWindow
+{
+    return YES;
+}
+
+@end
+
 QCocoaWindow::QCocoaWindow(QWindow *tlw)
     : QPlatformWindow(tlw)
+    , m_windowAttributes(0)
+    , m_windowClass(0)
     , m_glContext(0)
 {
     QCocoaAutoReleasePool pool;
@@ -251,7 +267,7 @@ void QCocoaWindow::determineWindowClass()
 /*
 
 */
-NSWindow * QCocoaWindow::createWindow()
+QNSWindow * QCocoaWindow::createWindow()
 {
     // Determine if we need to add in our "custom window" attribute. Cocoa is rather clever
     // in deciding if we need the maximize button or not (i.e., it's resizeable, so you
@@ -272,7 +288,7 @@ NSWindow * QCocoaWindow::createWindow()
 */
     NSRect frame = globalGeometry(window()->geometry());
     QCocoaAutoReleasePool pool;
-    NSWindow *window;
+    QNSWindow *window;
 
     switch (m_windowClass) {
     case kMovableModalWindowClass: