Create NSWindow subclass.

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>
bb10
Morten Sorvig 2011-08-15 13:09:18 +02:00 committed by Richard Moe Gustavsen
parent 6fce65f871
commit c9d1adb7fa
2 changed files with 27 additions and 4 deletions

View File

@ -52,6 +52,12 @@
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;

View File

@ -53,8 +53,24 @@
#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: