From 4e6790c8dc21c5287bff6799fb0984a72e2f2766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 18 Oct 2010 14:40:16 +0200 Subject: Lighthouse: initial COCOA plugin --- demos/demos.pro | 2 +- src/plugins/platforms/cocoa/cocoa.pro | 29 +++ src/plugins/platforms/cocoa/main.mm | 74 ++++++++ .../platforms/cocoa/qcocoaautoreleasepool.h | 57 ++++++ .../platforms/cocoa/qcocoaautoreleasepool.mm | 52 +++++ .../platforms/cocoa/qcocoaeventloopintegration.h | 74 ++++++++ .../platforms/cocoa/qcocoaeventloopintegration.mm | 128 +++++++++++++ src/plugins/platforms/cocoa/qcocoaintegration.h | 98 ++++++++++ src/plugins/platforms/cocoa/qcocoaintegration.mm | 122 ++++++++++++ src/plugins/platforms/cocoa/qcocoawindow.h | 75 ++++++++ src/plugins/platforms/cocoa/qcocoawindow.mm | 116 +++++++++++ src/plugins/platforms/cocoa/qcocoawindowsurface.h | 73 +++++++ src/plugins/platforms/cocoa/qcocoawindowsurface.mm | 103 ++++++++++ src/plugins/platforms/cocoa/qnsview.h | 79 ++++++++ src/plugins/platforms/cocoa/qnsview.mm | 211 +++++++++++++++++++++ src/plugins/platforms/cocoa/qnswindowdelegate.h | 61 ++++++ src/plugins/platforms/cocoa/qnswindowdelegate.mm | 73 +++++++ 17 files changed, 1426 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/cocoa/cocoa.pro create mode 100644 src/plugins/platforms/cocoa/main.mm create mode 100644 src/plugins/platforms/cocoa/qcocoaautoreleasepool.h create mode 100644 src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm create mode 100644 src/plugins/platforms/cocoa/qcocoaeventloopintegration.h create mode 100644 src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm create mode 100644 src/plugins/platforms/cocoa/qcocoaintegration.h create mode 100644 src/plugins/platforms/cocoa/qcocoaintegration.mm create mode 100644 src/plugins/platforms/cocoa/qcocoawindow.h create mode 100644 src/plugins/platforms/cocoa/qcocoawindow.mm create mode 100644 src/plugins/platforms/cocoa/qcocoawindowsurface.h create mode 100644 src/plugins/platforms/cocoa/qcocoawindowsurface.mm create mode 100644 src/plugins/platforms/cocoa/qnsview.h create mode 100644 src/plugins/platforms/cocoa/qnsview.mm create mode 100644 src/plugins/platforms/cocoa/qnswindowdelegate.h create mode 100644 src/plugins/platforms/cocoa/qnswindowdelegate.mm diff --git a/demos/demos.pro b/demos/demos.pro index fdc1e4c..362a3bc 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -44,7 +44,7 @@ contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, SUBDIRS += demos_boxes } -mac*: SUBDIRS += demos_macmainwindow +mac* && !qpa: SUBDIRS += demos_macmainwindow wince*|symbian|embedded|x11: SUBDIRS += demos_embedded !contains(QT_EDITION, Console):!cross_compile:!embedded:!wince*:SUBDIRS += demos_arthurplugin diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro new file mode 100644 index 0000000..7701b9c --- /dev/null +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -0,0 +1,29 @@ +TARGET = qcocoa +include(../../qpluginbase.pri) +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms + +OBJECTIVE_SOURCES = main.mm \ + qcocoaintegration.mm \ + qcocoawindowsurface.mm \ + qcocoawindow.mm \ + qnsview.mm \ + qcocoaeventloopintegration.mm \ + qcocoaautoreleasepool.mm \ + qnswindowdelegate.mm + +OBJECTIVE_HEADERS = qcocoaintegration.h \ + qcocoawindowsurface.h \ + qcocoawindow.h \ + qnsview.h \ + qcocoaeventloopintegration.h \ + qcocoaautoreleasepool.h \ + qnswindowdelegate.h + +#add libz for freetype. +LIBS += -lz +LIBS += -framework cocoa + +include(../fontdatabases/genericunix/genericunix.pri) +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target + diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm new file mode 100644 index 0000000..8be8883 --- /dev/null +++ b/src/plugins/platforms/cocoa/main.mm @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include "qcocoaintegration.h" + +QT_BEGIN_NAMESPACE + +class QCocoaIntegrationPlugin : public QPlatformIntegrationPlugin +{ +public: + QStringList keys() const; + QPlatformIntegration *create(const QString&, const QStringList&); +}; + +QStringList QCocoaIntegrationPlugin::keys() const +{ + QStringList list; + list << "Cocoa"; + return list; +} + +QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + if (system.toLower() == "cocoa") + return new QCocoaIntegration; + + return 0; +} + +Q_EXPORT_PLUGIN2(Cocoa, QCocoaIntegrationPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h new file mode 100644 index 0000000..47b94d1 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOAAUTORELEASEPOOL_H +#define QCOCOAAUTORELEASEPOOL_H + +#include + +class QCocoaAutoReleasePool +{ +public: + QCocoaAutoReleasePool(); + ~QCocoaAutoReleasePool(); + +private: + NSAutoreleasePool *pool; +}; + +#endif // QCOCOAAUTORELEASEPOOL_H diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm new file mode 100644 index 0000000..9a18fe2 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoaautoreleasepool.h" + +QCocoaAutoReleasePool::QCocoaAutoReleasePool() +{ + pool = [[NSAutoreleasePool alloc] init]; +} + +QCocoaAutoReleasePool::~QCocoaAutoReleasePool() +{ + [pool release]; +} diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h new file mode 100644 index 0000000..8c21944 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCAEVENTLOOPINTEGRATION_H +#define QCOCAEVENTLOOPINTEGRATION_H + +#include + +#include + +@interface OurApplication: NSApplication +{ + bool shouldKeepRunning; +} + +- (void) run; +- (void) processEvents: (int) msec; + +@end + +class QCocoaEventLoopIntegration : public QPlatformEventLoopIntegration +{ +public: + QCocoaEventLoopIntegration(); + void processEvents( qint64 msec ); + void wakeup(); + + static int wakeupEventId; +private: + OurApplication *app; +}; + + + +#endif // QCOCAEVENTLOOPINTEGRATION_H + diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm new file mode 100644 index 0000000..b184f90 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoaeventloopintegration.h" + +#import + +#include "qcocoaautoreleasepool.h" + +#include + +#include + +@implementation OurApplication + +- (void) run +{ + QCocoaAutoReleasePool pool; + [self finishLaunching]; + + shouldKeepRunning = YES; +} + +- (void) processEvents : (int) msec +{ + QCocoaAutoReleasePool pool; + Q_UNUSED(pool); + + QElapsedTimer timer; + timer.start(); + + NSTimeInterval seconds = NSTimeInterval(msec)/1000; + id untilDate = [NSDate dateWithTimeIntervalSinceNow:seconds]; + bool continueLooping = true; + while ((timer.elapsed() < (msec-1)) && continueLooping) { + NSEvent *event = + [self nextEventMatchingMask:NSAnyEventMask + untilDate:untilDate + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if ([event type] == NSApplicationDefined + && [event subtype] == QCocoaEventLoopIntegration::wakeupEventId) { + continueLooping = false; + } else { + [self sendEvent:event]; + } + + } + [self updateWindows]; +} + +@end + +int QCocoaEventLoopIntegration::wakeupEventId = SHRT_MAX; + +QCocoaEventLoopIntegration::QCocoaEventLoopIntegration() : + QPlatformEventLoopIntegration() +{ + app = (OurApplication *)[OurApplication sharedApplication]; + [app run]; +} + +void QCocoaEventLoopIntegration::processEvents(qint64 msec) +{ + [app processEvents:msec]; +} + +void QCocoaEventLoopIntegration::wakeup() +{ + QCocoaAutoReleasePool pool; + Q_UNUSED(pool); + + NSPoint p = NSMakePoint(0,0); + NSWindow *nswin = [app keyWindow]; + double timestamp = (double)(AbsoluteToDuration(UpTime())) / 1000.0; + NSEvent *event = [NSEvent + otherEventWithType:NSApplicationDefined + location:NSZeroPoint + modifierFlags:0 + timestamp: timestamp + windowNumber:[nswin windowNumber] + context:0 + subtype:QCocoaEventLoopIntegration::wakeupEventId + data1:0 + data2:0 + ]; + [app postEvent:event atStart:NO]; + +} + diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h new file mode 100644 index 0000000..e7ecf2a --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_COCOA_H +#define QPLATFORMINTEGRATION_COCOA_H + +#include + +#include "qcocoaautoreleasepool.h" + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaScreen : public QPlatformScreen +{ +public: + QCocoaScreen(int screenIndex); + ~QCocoaScreen(); + + QRect geometry() const { return m_geometry; } + int depth() const { return m_depth; } + QImage::Format format() const { return m_format; } + QSize physicalSize() const { return m_physicalSize; } + +public: + NSScreen *m_screen; + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QSize m_physicalSize; +}; + +class QCocoaIntegration : public QPlatformIntegration +{ +public: + QCocoaIntegration(); + ~QCocoaIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + + QPlatformFontDatabase *fontDatabase() const; + + QPlatformEventLoopIntegration *createEventLoopIntegration() const; + +private: + QList mScreens; + QPlatformFontDatabase *mFontDb; + + QCocoaAutoReleasePool *mPool; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm new file mode 100644 index 0000000..baf5a73 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoaintegration.h" + +#include "qcocoawindow.h" +#include "qcocoawindowsurface.h" +#include "qcocoaeventloopintegration.h" + +#include "qgenericunixfontdatabase.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +QCocoaScreen::QCocoaScreen(int screenIndex) + :QPlatformScreen() +{ + m_screen = [[NSScreen screens] objectAtIndex:screenIndex]; + NSRect rect = [m_screen frame]; + m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); + + m_format = QImage::Format_ARGB32; + + m_depth = NSBitsPerPixelFromDepth([m_screen depth]); + + const int dpi = 72; + const qreal inch = 25.4; + m_physicalSize = QSize(qRound(m_geometry.width() * inch / dpi), qRound(m_geometry.height() *inch / dpi)); +} + +QCocoaScreen::~QCocoaScreen() +{ +} + +QCocoaIntegration::QCocoaIntegration() + : mFontDb(new QGenericUnixFontDatabase()) +{ + mPool = new QCocoaAutoReleasePool; + + //Make sure we have a nsapplication :) + [OurApplication sharedApplication]; +// [[OurApplication alloc] init]; + + NSArray *screens = [NSScreen screens]; + for (uint i = 0; i < [screens count]; i++) { + QCocoaScreen *screen = new QCocoaScreen(i); + mScreens.append(screen); + } +} + +QCocoaIntegration::~QCocoaIntegration() +{ + delete mPool; +} + +QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + return new QCocoaWindow(widget); +} + +QWindowSurface *QCocoaIntegration::createWindowSurface(QWidget *widget, WId winId) const +{ + return new QCocoaWindowSurface(widget,winId); +} + +QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const +{ + return mFontDb; +} + +QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() const +{ + return new QCocoaEventLoopIntegration(); +} +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h new file mode 100644 index 0000000..660e9f8 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOAWINDOW_H +#define QCOCOAWINDOW_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaWindow : public QPlatformWindow +{ +public: + QCocoaWindow(QWidget *tlw); + ~QCocoaWindow(); + + void setGeometry(const QRect &rect); + + void setVisible(bool visible); + + WId winId() const; + + NSView *contentView() const; + void setContentView(NSView *contentView); + + void windowDidResize(); + +private: + NSWindow *m_nsWindow; +}; + +QT_END_NAMESPACE + +#endif // QCOCOAWINDOW_H + diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm new file mode 100644 index 0000000..f004cb8 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qcocoawindow.h" +#include "qnswindowdelegate.h" +#include "qcocoaautoreleasepool.h" + +#include + +#include + +#include + +#include + +QCocoaWindow::QCocoaWindow(QWidget *tlw) + : QPlatformWindow(tlw) +{ + QCocoaAutoReleasePool pool; + const QRect geo = tlw->geometry(); + NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); + + m_nsWindow = [[NSWindow alloc] initWithContentRect:frame + styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask + backing:NSBackingStoreBuffered + defer:YES]; + + QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this]; + [m_nsWindow setDelegate:delegate]; + + [m_nsWindow makeKeyAndOrderFront:nil]; + [m_nsWindow setAcceptsMouseMovedEvents:YES]; +} + +QCocoaWindow::~QCocoaWindow() +{ +} + +void QCocoaWindow::setGeometry(const QRect &rect) +{ + QPlatformWindow::setGeometry(rect); + + NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); + [[m_nsWindow contentView]setFrameSize:bounds.size]; +} + +void QCocoaWindow::setVisible(bool visible) +{ + Q_UNUSED(visible); +} + +WId QCocoaWindow::winId() const +{ + return WId([m_nsWindow windowNumber]); +} + +NSView *QCocoaWindow::contentView() const +{ + return [m_nsWindow contentView]; +} + +void QCocoaWindow::setContentView(NSView *contentView) +{ + [m_nsWindow setContentView:contentView]; +} + +void QCocoaWindow::windowDidResize() +{ + //jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing... + NSRect rect = [[m_nsWindow contentView]frame]; + QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); + if (geometry() != geo) { + widget()->setGeometry(geo); + QResizeEvent e(geo.size(), geometry().size()); + setGeometry(geo); + QApplication::sendEvent(widget(), &e); + widget()->repaint(); + } +} diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoawindowsurface.h new file mode 100644 index 0000000..35f4064 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_COCOA_H +#define QWINDOWSURFACE_COCOA_H + +#include + +#include "qcocoawindow.h" +#include "qnsview.h" + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaWindowSurface : public QWindowSurface +{ +public: + QCocoaWindowSurface(QWidget *window, WId wid); + ~QCocoaWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize (const QSize &size); + +private: + + QCocoaWindow *m_cocoaWindow; + QImage *m_image; + QNSView *m_contentView; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm new file mode 100644 index 0000000..443a486 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoawindowsurface.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +QRect flipedRect(const QRect &sourceRect,int height) +{ + if (!sourceRect.isValid()) + return QRect(); + QRect flippedRect = sourceRect; + flippedRect.moveTop(height - sourceRect.y()); + return flippedRect; +} + +QCocoaWindowSurface::QCocoaWindowSurface(QWidget *window, WId wId) + : QWindowSurface(window) +{ + m_cocoaWindow = static_cast(window->platformWindow()); + + const QRect geo = window->geometry(); + NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height()); + m_contentView = [[QNSView alloc] initWithWidget:window]; + m_cocoaWindow->setContentView(m_contentView); + + m_image = new QImage(window->size(),QImage::Format_ARGB32); +} + +QCocoaWindowSurface::~QCocoaWindowSurface() +{ + delete m_image; +} + +QPaintDevice *QCocoaWindowSurface::paintDevice() +{ + return m_image; +} + +void QCocoaWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect geo = region.boundingRect(); + + NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); + [m_contentView displayRect:rect]; +} + +void QCocoaWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + delete m_image; + m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); + NSSize newSize = NSMakeSize(size.width(),size.height()); + [m_contentView setImage:m_image]; + +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h new file mode 100644 index 0000000..0523725 --- /dev/null +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNSVIEW_H +#define QNSVIEW_H + +#include + +#include + +@interface QNSView : NSView { + CGImageRef m_cgImage; + QWidget *m_widget; + Qt::MouseButtons m_buttons; +} + +- (id)init; +- (id)initWithWidget:(QWidget *)widget; + +- (void)setImage:(QImage *)image; +- (void)drawRect:(NSRect)dirtyRect; + +- (BOOL)isFlipped; + +- (void)handleMouseEvent:(NSEvent *)theEvent; +- (void)mouseDown:(NSEvent *)theEvent; +- (void)mouseDragged:(NSEvent *)theEvent; +- (void)mouseUp:(NSEvent *)theEvent; +- (void)mouseMoved:(NSEvent *)theEvent; +- (void)mouseEntered:(NSEvent *)theEvent; +- (void)mouseExited:(NSEvent *)theEvent; +- (void)rightMouseDown:(NSEvent *)theEvent; +- (void)rightMouseDragged:(NSEvent *)theEvent; +- (void)rightMouseUp:(NSEvent *)theEvent; +- (void)otherMouseDown:(NSEvent *)theEvent; +- (void)otherMouseDragged:(NSEvent *)theEvent; +- (void)otherMouseUp:(NSEvent *)theEvent; + +@end + +#endif //QNSVIEW_H diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm new file mode 100644 index 0000000..60de6ba --- /dev/null +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnsview.h" + +#include + +#include + +@implementation QNSView + +- (id) init +{ + self = [super init]; + if (self) { + m_cgImage = 0; + m_widget = 0; + m_buttons = Qt::NoButton; + } + return self; +} + +- (id)initWithWidget:(QWidget *)widget { + self = [self init]; + if (self) { + m_widget = widget; + } + return self; +} + +- (void) setImage:(QImage *)image +{ + CGImageRelease(m_cgImage); + + const uchar *imageData = image->bits(); + int bitDepth = image->depth(); + int colorBufferSize = 8; + int bytesPrLine = image->bytesPerLine(); + int width = image->width(); + int height = image->height(); + + CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB(); + + CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData( + NULL, + imageData, + image->byteCount(), + NULL); + + m_cgImage = CGImageCreate(width, + height, + colorBufferSize, + bitDepth, + bytesPrLine, + cgColourSpaceRef, + kCGImageAlphaNone, + cgDataProviderRef, + NULL, + false, + kCGRenderingIntentDefault); + + CGColorSpaceRelease(cgColourSpaceRef); + +} + +- (void) drawRect:(NSRect)dirtyRect +{ + if (!m_cgImage) + return; + + CGRect dirtyCGRect = NSRectToCGRect(dirtyRect); + + NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext]; + CGContextRef cgContext = (CGContextRef) [nsGraphicsContext graphicsPort]; + + CGContextSaveGState( cgContext ); + int dy = dirtyCGRect.origin.y + CGRectGetMaxY(dirtyCGRect); + CGContextTranslateCTM(cgContext, 0, dy); + CGContextScaleCTM(cgContext, 1, -1); + + CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, dirtyCGRect); + CGContextDrawImage(cgContext,dirtyCGRect,subImage); + + CGContextRestoreGState(cgContext); + + CGImageRelease(subImage); + +} + +- (BOOL) isFlipped +{ + return YES; +} + +- (void)handleMouseEvent:(NSEvent *)theEvent; +{ + NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil]; + QPoint qt_localPoint(point.x,point.y); + + NSTimeInterval timestamp = [theEvent timestamp]; + ulong qt_timestamp = timestamp * 1000; + + QWindowSystemInterface::handleMouseEvent(m_widget,qt_timestamp,qt_localPoint,QPoint(),m_buttons); + +} + - (void)mouseDown:(NSEvent *)theEvent + { + m_buttons |= Qt::LeftButton; + [self handleMouseEvent:theEvent]; + } + - (void)mouseDragged:(NSEvent *)theEvent + { + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; + } + - (void)mouseUp:(NSEvent *)theEvent + { + m_buttons &= QFlag(~int(Qt::LeftButton)); + [self handleMouseEvent:theEvent]; + } + +- (void)mouseMoved:(NSEvent *)theEvent +{ + qDebug() << "mouseMove"; + [self handleMouseEvent:theEvent]; +} +- (void)mouseEntered:(NSEvent *)theEvent +{ + Q_UNUSED(theEvent); + QWindowSystemInterface::handleEnterEvent(m_widget); +} +- (void)mouseExited:(NSEvent *)theEvent +{ + Q_UNUSED(theEvent); + QWindowSystemInterface::handleLeaveEvent(m_widget); +} +- (void)rightMouseDown:(NSEvent *)theEvent +{ + m_buttons |= Qt::RightButton; + [self handleMouseEvent:theEvent]; +} +- (void)rightMouseDragged:(NSEvent *)theEvent +{ + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; +} +- (void)rightMouseUp:(NSEvent *)theEvent +{ + m_buttons &= QFlag(~int(Qt::RightButton)); + [self handleMouseEvent:theEvent]; +} +- (void)otherMouseDown:(NSEvent *)theEvent +{ + m_buttons |= Qt::RightButton; + [self handleMouseEvent:theEvent]; +} +- (void)otherMouseDragged:(NSEvent *)theEvent +{ + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; +} +- (void)otherMouseUp:(NSEvent *)theEvent +{ + m_buttons &= QFlag(~int(Qt::MiddleButton)); + [self handleMouseEvent:theEvent]; +} + + + +@end diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h new file mode 100644 index 0000000..9fc1d63 --- /dev/null +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNSWINDOWDELEGATE_H +#define QNSWINDOWDELEGATE_H + +#include + +#include "qcocoawindow.h" + +@interface QNSWindowDelegate : NSObject +{ + QCocoaWindow *m_cocoaWindow; +} + +- (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow; + +- (void)windowDidResize:(NSNotification *)notification; +- (void)windowWillClose:(NSNotification *)notification; + +@end + +#endif // QNSWINDOWDELEGATE_H diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm new file mode 100644 index 0000000..c04602b --- /dev/null +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnswindowdelegate.h" + +#include +#include + +@implementation QNSWindowDelegate + +- (id) initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow +{ + self = [super init]; + + if (self) { + m_cocoaWindow = cocoaWindow; + } + return self; +} + +- (void)windowDidResize:(NSNotification *)notification +{ + Q_UNUSED(notification); + if (m_cocoaWindow) { + m_cocoaWindow->windowDidResize(); + } +} + +- (void)windowWillClose:(NSNotification *)notification +{ + Q_UNUSED(notification); + QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->widget()); +} + +@end -- cgit v0.12