summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2012-01-12 12:32:59 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-13 07:47:47 +0100
commit7407045388cc7a7d5f955ed9cbf938db8031baa0 (patch)
tree5aaa5b8cb4a6c4345ce94ea7ca4a46c88b2294b7 /src
parent56b2a229a392befd23c6ff48d0c1af8605075d31 (diff)
Cocoa: Send window activation events.
Change-Id: I599b4316f1535bf4855b205bfb2117bbcee63bf0 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm10
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm10
3 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index b65d371c63..b4b4bc6857 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -100,6 +100,16 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
m_contentView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
+ [[NSNotificationCenter defaultCenter] addObserver:m_contentView
+ selector:@selector(windowDidBecomeKey)
+ name:NSWindowDidBecomeKeyNotification
+ object:m_nsWindow];
+
+ [[NSNotificationCenter defaultCenter] addObserver:m_contentView
+ selector:@selector(windowDidResignKey)
+ name:NSWindowDidResignKeyNotification
+ object:m_nsWindow];
+
// ### Accept touch events by default.
// Beware that enabling touch events has a negative impact on the overall performance.
// We probably need a QWindowSystemInterface API to enable/disable touch events.
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index b778c7c87b..73c8030e1d 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -62,6 +62,8 @@ class QCocoaWindow;
- (void)setImage:(QImage *)image;
- (void)drawRect:(NSRect)dirtyRect;
- (void)updateGeometry;
+- (void)windowDidBecomeKey;
+- (void)windowDidResignKey;
- (BOOL)isFlipped;
- (BOOL)acceptsFirstResponder;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index c853e721a4..26ddd44aa6 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -138,6 +138,16 @@ static QTouchDevice *touchDevice = 0;
QWindowSystemInterface::handleSynchronousGeometryChange(m_window, geo);
}
+- (void)windowDidBecomeKey
+{
+ QWindowSystemInterface::handleWindowActivated(m_window);
+}
+
+- (void)windowDidResignKey
+{
+ QWindowSystemInterface::handleWindowActivated(0);
+}
+
- (void) setImage:(QImage *)image
{
CGImageRelease(m_cgImage);