summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.h
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-02-12 11:51:13 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-12 17:13:37 +0100
commit4beafcd944651cccfd711e12fb18caa9068813a2 (patch)
treebd0def1113ee872975a12342477126972dac9cbe /src/plugins/platforms/cocoa/qcocoawindow.h
parentff23fb6cf723bcc52a5f037ef92500c480ce5a5c (diff)
Cocoa: Bring back two-class native window system
While inheriting from NSPanel proved to be robust enough, it is not really future proof as we're at the mercy of Apple changing NSPanel's behavior. On the other hand, we can't inherit exclu- sively from NSWindow as the tool window case, where the QWindow should look like an NSPanel, can't be emulated perfectly without using private APIs. This reverts commits 79fb39a87ce5ffbda and df86721bb4028ae. Change-Id: I9021193e3614633a943578df9e2794b00094a1f7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 256f5ee6fb..748280af6a 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -52,32 +52,42 @@
QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
-@class QNSWindowDelegate;
+@interface QNSWindow : NSWindow
+{
+ @public QCocoaWindow *m_cocoaPlatformWindow;
+}
+- (id)initWithContentRect:(NSRect)contentRect
+ styleMask:(NSUInteger)windowStyle
+ qPlatformWindow:(QCocoaWindow *)qpw;
-@interface QNSWindow : NSPanel {
-@public
- QCocoaWindow *m_cocoaPlatformWindow;
+- (void)clearPlatformWindow;
+@end
+
+@interface QNSPanel : NSPanel
+{
+ @public QCocoaWindow *m_cocoaPlatformWindow;
}
+- (id)initWithContentRect:(NSRect)contentRect
+ styleMask:(NSUInteger)windowStyle
+ qPlatformWindow:(QCocoaWindow *)qpw;
+
- (void)clearPlatformWindow;
@end
-QT_BEGIN_NAMESPACE
+@class QNSWindowDelegate;
+QT_BEGIN_NAMESPACE
// QCocoaWindow
//
-// A QCocoaWindow is backed by a NSView and optionally a NSWindow.
+// QCocoaWindow is an NSView (not an NSWindow!) in the sense
+// that it relies on a NSView for all event handling and
+// graphics output and does not require a NSWindow, except for
+// for the window-related functions like setWindowTitle.
//
-// The NSView is used for most event handling and graphics output.
-//
-// Top-level QWindows are always backed by a NSWindow in addition to
-// the NSView. Child QWindows can also be backed by NSWindows, which
-// enables proper stacking of GL Widgets and threaded GL rendering
-// to multiple contexts.
-//
-// It is possible to embed the QCocoaWindow in an NSView hierarchy
-// by getting a pointer to the backing NSView and not calling
-// QCocoaWindow::show():
+// As a consequence of this it is possible to embed the QCocoaWindow
+// in an NSView hierarchy by getting a pointer to the "backing"
+// NSView and not calling QCocoaWindow::show():
//
// QWindow *qtWindow = new MyWindow();
// qtWindow->create();
@@ -139,7 +149,6 @@ public:
void windowDidResize();
bool windowShouldClose();
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
- bool windowShouldBehaveAsPanel() const;
void setSynchedWindowStateFromWindow();
@@ -174,9 +183,11 @@ public:
QWindow *childWindowAt(QPoint windowPoint);
protected:
void recreateWindow(const QPlatformWindow *parentWindow);
- QNSWindow *createNSWindow();
- void setNSWindow(QNSWindow *window);
- void clearNSWindow(QNSWindow *window);
+ NSWindow *createNSWindow();
+ void setNSWindow(NSWindow *window);
+ void clearNSWindow(NSWindow *window);
+
+ bool shouldUseNSPanel();
QRect windowGeometry() const;
QCocoaWindow *parentCocoaWindow() const;
@@ -191,7 +202,7 @@ public: // for QNSView
NSView *m_contentView;
QNSView *m_qtView;
- QNSWindow *m_nsWindow;
+ NSWindow *m_nsWindow;
QCocoaWindow *m_forwardWindow;
// TODO merge to one variable if possible