QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
cocoaWindow->setCurrentContext(this);
- NSView *view = cocoaWindow->contentView();
- [m_context setView:view];
+ [(QNSView *) cocoaWindow->contentView() setQCocoaGLContext:this];
}
void QCocoaGLContext::doneCurrent()
QT_BEGIN_NAMESPACE
class QCocoaWindow;
class QCocoaBackingStore;
+class QCocoaGLContext;
QT_END_NAMESPACE
@interface QNSView : NSView <NSTextInputClient> {
bool m_sendKeyEvent;
QStringList *currentCustomDragTypes;
Qt::KeyboardModifiers currentWheelModifiers;
+ bool m_subscribesForGlobalFrameNotifications;
}
- (id)init;
- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow;
-
+- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
- (void)flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset;
- (void)setMaskRegion:(const QRegion *)region;
- (void)drawRect:(NSRect)dirtyRect;
#include <QtCore/QDebug>
#include <private/qguiapplication_p.h>
#include "qcocoabackingstore.h"
+#include "qcocoaglcontext.h"
#ifdef QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR
#include <accessibilityinspector.h>
m_window = 0;
m_buttons = Qt::NoButton;
m_sendKeyEvent = false;
+ m_subscribesForGlobalFrameNotifications = false;
currentCustomDragTypes = 0;
+
if (!touchDevice) {
touchDevice = new QTouchDevice;
touchDevice->setType(QTouchDevice::TouchPad);
delete[] m_maskData;
m_maskData = 0;
m_window = 0;
+ if (m_subscribesForGlobalFrameNotifications) {
+ m_subscribesForGlobalFrameNotifications = false;
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:NSViewGlobalFrameDidChangeNotification
+ object:self];
+}
[super dealloc];
}
return self;
}
+- (void) setQCocoaGLContext:(QCocoaGLContext *)context
+{
+ [context->nsOpenGLContext() setView:self];
+ if (!m_subscribesForGlobalFrameNotifications) {
+ // NSOpenGLContext expects us to repaint (or update) the view when
+ // it changes position on screen. Since this happens unnoticed for
+ // the view when the parent view moves, we need to register a special
+ // notification that lets us handle this case:
+ m_subscribesForGlobalFrameNotifications = true;
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(globalFrameChanged:)
+ name:NSViewGlobalFrameDidChangeNotification
+ object:self];
+ }
+}
+
+- (void) globalFrameChanged:(NSNotification*)notification
+{
+ Q_UNUSED(notification);
+ QWindowSystemInterface::handleExposeEvent(m_window, m_window->geometry());
+}
+
- (void)updateGeometry
{
QRect geometry;