Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.05 KB | None | 0 0
  1. commit 4c1988604e40c057d149a8330964094b10f66524
  2. Author: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
  3. Date: Thu Aug 17 19:01:40 2017 +0200
  4.  
  5. macOS: Deduplicate QNSWindow/QNSPanel code
  6.  
  7. By sharing the implementations of the methods between QNSWindow and
  8. QNSPanel we don't need a helper, and can remove a lot of duplicated
  9. code.
  10.  
  11. The only snag is that calls to super are hard-coded to a specific
  12. superclass during complication, so we provide our wrapper for
  13. objc_msgSendSuper that resolves the superclass at runtime.
  14.  
  15. Change-Id: Iaf13f27675d90f884470f5005270ea0d9d0316f3
  16.  
  17. diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
  18. index 4478895538..97bd0c4b3f 100644
  19. --- a/src/plugins/platforms/cocoa/qcocoahelpers.h
  20. +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
  21. @@ -55,6 +55,9 @@
  22. #include <QtGui/qpalette.h>
  23. #include <QtGui/qscreen.h>
  24.  
  25. +#include <objc/runtime.h>
  26. +#include <objc/message.h>
  27. +
  28. Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSView));
  29.  
  30. QT_BEGIN_NAMESPACE
  31. @@ -188,5 +191,103 @@ QT_END_NAMESPACE
  32.  
  33. QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSPanelContentsWrapper);
  34.  
  35. +// -------------------------------------------------------------------------
  36. +
  37. +template<typename... Args>
  38. +class DynamicSendSuper {
  39. +public:
  40. + DynamicSendSuper(id receiver, SEL sel, Args... args)
  41. + : m_receiver(receiver), m_selector(sel), m_args(std::make_tuple(args...))
  42. + {
  43. + }
  44. +
  45. + ~DynamicSendSuper()
  46. + {
  47. + if (m_selector)
  48. + msgSendSuper<id>(m_args);
  49. + }
  50. +
  51. + template <typename ReturnType>
  52. + operator ReturnType()
  53. + {
  54. +#if defined(QT_DEBUG)
  55. + Method method = class_getInstanceMethod(object_getClass(m_receiver), m_selector);
  56. + char returnTypeEncoding[256];
  57. + method_getReturnType(method, returnTypeEncoding, sizeof(returnTypeEncoding));
  58. + NSUInteger alignedReturnTypeSize = 0;
  59. + NSGetSizeAndAlignment(returnTypeEncoding, nullptr, &alignedReturnTypeSize);
  60. + Q_ASSERT(alignedReturnTypeSize == sizeof(ReturnType));
  61. +#endif
  62. + ReturnType ret = msgSendSuper<ReturnType>(m_args);
  63. + m_selector = nullptr;
  64. + return ret;
  65. + }
  66. +
  67. +private:
  68. + template <std::size_t... Ts>
  69. + struct index {};
  70. +
  71. + template <std::size_t N, std::size_t... Ts>
  72. + struct gen_seq : gen_seq<N - 1, N - 1, Ts...> {};
  73. +
  74. + template <std::size_t... Ts>
  75. + struct gen_seq<0, Ts...> : index<Ts...> {};
  76. +
  77. + template <typename T, size_t S>
  78. + using equal_or_below = typename std::enable_if<(sizeof(T) <= S), bool>::type;
  79. +
  80. + template <typename T, size_t S>
  81. + using larger_than = typename std::enable_if<(sizeof(T) > S), bool>::type;
  82. +
  83. + // Depending on the ABI of the platform, we may need to use objc_msgSendSuper_stret
  84. + static Q_CONSTEXPR size_t stretCutoff =
  85. +#if defined(Q_PROCESSOR_X86)
  86. + sizeof(void*) * 2; // Any return value larger than two registers on i386/x86_64
  87. +#elif defined(Q_PROCESSOR_ARM_32)
  88. + sizeof(void*); // Any return value larger than a single registers on arm
  89. +#elif defined(Q_PROCESSOR_ARM_64)
  90. + std::numeric_limits<std::size_t>::max(); // Stret never used on arm64
  91. +#endif
  92. +
  93. + template <typename ReturnType, equal_or_below<ReturnType, stretCutoff> = true, std::size_t... Is>
  94. + ReturnType msgSendSuper(std::tuple<Args...>& args, index<Is...>)
  95. + {
  96. + typedef ReturnType (*SuperFn)(objc_super *, SEL, Args...);
  97. + SuperFn superFn = reinterpret_cast<SuperFn>(objc_msgSendSuper);
  98. + objc_super sup = { m_receiver, class_getSuperclass(object_getClass(m_receiver)) };
  99. + return superFn(&sup, m_selector, std::get<Is>(args)...);
  100. + }
  101. +
  102. + template <typename ReturnType, larger_than<ReturnType, stretCutoff> = true, std::size_t... Is>
  103. + ReturnType msgSendSuper(std::tuple<Args...>& args, index<Is...>)
  104. + {
  105. + typedef void (*SuperStretFn)(ReturnType *, objc_super *, SEL, Args...);
  106. + SuperStretFn superStretFn = reinterpret_cast<SuperStretFn>(objc_msgSendSuper_stret);
  107. + objc_super sup = { m_receiver, class_getSuperclass(object_getClass(m_receiver)) };
  108. + ReturnType ret;
  109. + superStretFn(&ret, &sup, m_selector, std::get<Is>(args)...);
  110. + return ret;
  111. + }
  112. +
  113. + template <typename ReturnType>
  114. + ReturnType msgSendSuper(std::tuple<Args...>& args)
  115. + {
  116. + return msgSendSuper<ReturnType>(args, gen_seq<sizeof...(Args)>{});
  117. + }
  118. +
  119. + id m_receiver;
  120. + SEL m_selector;
  121. + std::tuple<Args...> m_args;
  122. +};
  123. +
  124. +template<typename... Args>
  125. +DynamicSendSuper<Args...> callSuper(id receiver, SEL selector, Args... args)
  126. +{
  127. + return DynamicSendSuper<Args...>(receiver, selector, args...);
  128. +}
  129. +
  130. +// Same as calling super, but the super_class field resolved at runtime instead of compile time
  131. +#define dynamicSuper(...) callSuper(self, _cmd, ##__VA_ARGS__)
  132. +
  133. #endif //QCOCOAHELPERS_H
  134.  
  135. diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
  136. index 1df74c986a..7b1e689388 100644
  137. --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
  138. +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
  139. @@ -218,7 +218,7 @@ QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
  140. continue;
  141.  
  142. id<QNSWindowProtocol> proto = static_cast<id<QNSWindowProtocol> >(nsWindow);
  143. - QCocoaWindow *cocoaWindow = proto.helper.platformWindow;
  144. + QCocoaWindow *cocoaWindow = proto.platformWindow;
  145. if (!cocoaWindow)
  146. continue;
  147. window = cocoaWindow->window();
  148. diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
  149. index e8550887cb..caab104954 100644
  150. --- a/src/plugins/platforms/cocoa/qcocoawindow.mm
  151. +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
  152. @@ -210,7 +210,6 @@ QCocoaWindow::~QCocoaWindow()
  153. QMacAutoReleasePool pool;
  154. [m_nsWindow makeFirstResponder:nil];
  155. [m_nsWindow setContentView:nil];
  156. - [m_nsWindow.helper detachFromPlatformWindow];
  157. if ([m_view superview])
  158. [m_view removeFromSuperview];
  159.  
  160. @@ -1300,10 +1299,34 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
  161. // Create NSWindow
  162. Class windowClass = shouldBePanel ? [QNSPanel class] : [QNSWindow class];
  163. QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:frame
  164. - screen:cocoaScreen->nativeScreen() styleMask:windowStyleMask(flags) qPlatformWindow:this];
  165. + styleMask:windowStyleMask(flags)
  166. + // Deferring window creation breaks OpenGL (the GL context is
  167. + // set up before the window is shown and needs a proper window)
  168. + backing:NSBackingStoreBuffered defer:NO
  169. + screen:cocoaScreen->nativeScreen()];
  170. +
  171. Q_ASSERT_X(nsWindow.screen == cocoaScreen->nativeScreen(), "QCocoaWindow",
  172. "Resulting NSScreen should match the requested NSScreen");
  173.  
  174. + nsWindow.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
  175. +
  176. + // Prevent Cocoa from releasing the window on close. Qt
  177. + // handles the close event asynchronously and we want to
  178. + // make sure that NSWindow stays valid until the
  179. + // QCocoaWindow is deleted by Qt.
  180. + [nsWindow setReleasedWhenClosed:NO];
  181. +
  182. + if (alwaysShowToolWindow()) {
  183. + static dispatch_once_t onceToken;
  184. + dispatch_once(&onceToken, ^{
  185. + NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  186. + [center addObserver:[QNSWindow class] selector:@selector(applicationActivationChanged:)
  187. + name:NSApplicationWillResignActiveNotification object:nil];
  188. + [center addObserver:[QNSWindow class] selector:@selector(applicationActivationChanged:)
  189. + name:NSApplicationWillBecomeActiveNotification object:nil];
  190. + });
  191. + }
  192. +
  193. if (targetScreen != window()->screen())
  194. QWindowSystemInterface::handleWindowScreenChanged(window(), targetScreen);
  195.  
  196. diff --git a/src/plugins/platforms/cocoa/qnswindow.h b/src/plugins/platforms/cocoa/qnswindow.h
  197. index b13b6d42a9..ac9cbb978f 100644
  198. --- a/src/plugins/platforms/cocoa/qnswindow.h
  199. +++ b/src/plugins/platforms/cocoa/qnswindow.h
  200. @@ -47,62 +47,26 @@
  201. #include <AppKit/AppKit.h>
  202.  
  203. QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
  204. -Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSWindowHelper));
  205. -
  206. -// -------------------------------------------------------------------------
  207.  
  208. @interface NSWindow (FullScreenProperty)
  209. @property(readonly) BOOL qt_fullScreen;
  210. @end
  211.  
  212. -// -------------------------------------------------------------------------
  213. -
  214. @protocol QNSWindowProtocol
  215. -
  216. -@property (nonatomic, readonly) QT_MANGLE_NAMESPACE(QNSWindowHelper) *helper;
  217. -
  218. -- (id)initWithContentRect:(NSRect)contentRect screen:(NSScreen*)screen
  219. - styleMask:(NSUInteger)windowStyle qPlatformWindow:(QCocoaWindow *)qpw;
  220. -
  221. -- (void)superSendEvent:(NSEvent *)theEvent;
  222. +@optional
  223. +- (BOOL)canBecomeKeyWindow;
  224. +- (void)sendEvent:(NSEvent*)theEvent;
  225. - (void)closeAndRelease;
  226. -
  227. -@end
  228. -
  229. -typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
  230. -
  231. -// -------------------------------------------------------------------------
  232. -
  233. -@interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject
  234. -{
  235. - QPointer<QCocoaWindow> _platformWindow;
  236. -}
  237. -
  238. -@property (nonatomic, readonly) QCocoaNSWindow *window;
  239. +- (void)dealloc;
  240. @property (nonatomic, readonly) QCocoaWindow *platformWindow;
  241. -
  242. -- (id)initWithNSWindow:(QCocoaNSWindow *)window platformWindow:(QCocoaWindow *)platformWindow;
  243. -- (void)handleWindowEvent:(NSEvent *)theEvent;
  244. -- (void)detachFromPlatformWindow;
  245. -
  246. @end
  247.  
  248. -QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowHelper);
  249. -
  250. -// -------------------------------------------------------------------------
  251. -
  252. -@interface QT_MANGLE_NAMESPACE(QNSWindow) : NSWindow<QNSWindowProtocol>
  253. -@end
  254. +typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
  255.  
  256. +@interface QT_MANGLE_NAMESPACE(QNSWindow) : NSWindow<QNSWindowProtocol> @end
  257. QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindow);
  258.  
  259. -// -------------------------------------------------------------------------
  260. -
  261. -@interface QT_MANGLE_NAMESPACE(QNSPanel) : NSPanel<QNSWindowProtocol>
  262. -@end
  263. -
  264. +@interface QT_MANGLE_NAMESPACE(QNSPanel) : NSPanel<QNSWindowProtocol> @end
  265. QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSPanel);
  266.  
  267. -// -------------------------------------------------------------------------
  268. -
  269. #endif // QNSWINDOW_H
  270. diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
  271. index e44db3ff3b..e99155a5d7 100644
  272. --- a/src/plugins/platforms/cocoa/qnswindow.mm
  273. +++ b/src/plugins/platforms/cocoa/qnswindow.mm
  274. @@ -88,32 +88,70 @@ static bool isMouseEvent(NSEvent *ev)
  275. }
  276. @end
  277.  
  278. -@implementation QNSWindowHelper
  279. +#define super USE_dynamicSuper_INSTEAD
  280. +
  281. +@implementation QNSWindow
  282. +
  283. ++ (void)load
  284. +{
  285. + const Class windowClass = [self class];
  286. + const Class panelClass = [QNSPanel class];
  287. +
  288. + unsigned int methodDescriptionsCount;
  289. + objc_method_description *methods = protocol_copyMethodDescriptionList(
  290. + objc_getProtocol("QNSWindowProtocol"), NO, YES, &methodDescriptionsCount);
  291. +
  292. + for (unsigned int i = 0; i < methodDescriptionsCount; ++i) {
  293. + objc_method_description method = methods[i];
  294. + class_addMethod(panelClass, method.name,
  295. + class_getMethodImplementation(windowClass, method.name),
  296. + method.types);
  297. + }
  298. +}
  299.  
  300. - (QCocoaWindow *)platformWindow
  301. {
  302. - return _platformWindow.data();
  303. + return qnsview_cast(self.contentView).platformWindow;
  304. }
  305.  
  306. -- (id)initWithNSWindow:(QCocoaNSWindow *)window platformWindow:(QCocoaWindow *)platformWindow
  307. +- (BOOL)canBecomeKeyWindow
  308. {
  309. - if (self = [super init]) {
  310. - _window = window;
  311. - _platformWindow = platformWindow;
  312. + QCocoaWindow *pw = self.platformWindow;
  313. + if (!pw)
  314. + return NO;
  315.  
  316. - _window.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:_platformWindow];
  317. + if (pw->shouldRefuseKeyWindowAndFirstResponder())
  318. + return NO;
  319. +
  320. + if ([self isKindOfClass:[QNSPanel class]]) {
  321. + // Only tool or dialog windows should become key:
  322. + Qt::WindowType type = pw->window()->type();
  323. + if (type == Qt::Tool || type == Qt::Dialog)
  324. + return YES;
  325.  
  326. - // Prevent Cocoa from releasing the window on close. Qt
  327. - // handles the close event asynchronously and we want to
  328. - // make sure that NSWindow stays valid until the
  329. - // QCocoaWindow is deleted by Qt.
  330. - [_window setReleasedWhenClosed:NO];
  331. + return NO;
  332. + } else {
  333. + // The default implementation returns NO for title-bar less windows,
  334. + // override and return yes here to make sure popup windows such as
  335. + // the combobox popup can become the key window.
  336. + return YES;
  337. }
  338. +}
  339. +
  340. +- (BOOL)canBecomeMainWindow
  341. +{
  342. + BOOL canBecomeMain = YES; // By default, windows can become the main window
  343.  
  344. - return self;
  345. + // Windows with a transient parent (such as combobox popup windows)
  346. + // cannot become the main window:
  347. + QCocoaWindow *pw = self.platformWindow;
  348. + if (!pw || pw->window()->transientParent())
  349. + canBecomeMain = NO;
  350. +
  351. + return canBecomeMain;
  352. }
  353.  
  354. -- (void)handleWindowEvent:(NSEvent *)theEvent
  355. +- (void)sendEvent:(NSEvent*)theEvent
  356. {
  357. // We might get events for a NSWindow after the corresponding platform
  358. // window has been deleted, as the NSWindow can outlive the QCocoaWindow
  359. @@ -129,7 +167,7 @@ static bool isMouseEvent(NSEvent *ev)
  360. return;
  361. }
  362.  
  363. - [self.window superSendEvent:theEvent];
  364. + dynamicSuper(theEvent);
  365.  
  366. if (!self.platformWindow)
  367. return; // Platform window went away while processing event
  368. @@ -137,108 +175,31 @@ static bool isMouseEvent(NSEvent *ev)
  369. QCocoaWindow *pw = self.platformWindow;
  370. if (pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
  371. NSPoint loc = [theEvent locationInWindow];
  372. - NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
  373. - NSRect contentFrame = [[self.window contentView] frame];
  374. + NSRect windowFrame = [self convertRectFromScreen:self.frame];
  375. + NSRect contentFrame = self.contentView.frame;
  376. if (NSMouseInRect(loc, windowFrame, NO) && !NSMouseInRect(loc, contentFrame, NO))
  377. [qnsview_cast(pw->view()) handleFrameStrutMouseEvent:theEvent];
  378. }
  379. }
  380.  
  381. -- (void)detachFromPlatformWindow
  382. -{
  383. - _platformWindow.clear();
  384. - [self.window.delegate release];
  385. - self.window.delegate = nil;
  386. -}
  387. -
  388. -- (void)dealloc
  389. -{
  390. - _window = nil;
  391. - _platformWindow.clear();
  392. - [super dealloc];
  393. -}
  394. -
  395. -@end
  396. -
  397. -// Deferring window creation breaks OpenGL (the GL context is
  398. -// set up before the window is shown and needs a proper window)
  399. -static const bool kNoDefer = NO;
  400. -
  401. -@implementation QNSWindow
  402. -
  403. -@synthesize helper = _helper;
  404. -
  405. -- (id)initWithContentRect:(NSRect)contentRect
  406. - screen:(NSScreen*)screen
  407. - styleMask:(NSUInteger)windowStyle
  408. - qPlatformWindow:(QCocoaWindow *)qpw
  409. -{
  410. - if (self = [super initWithContentRect:contentRect styleMask:windowStyle
  411. - backing:NSBackingStoreBuffered defer:kNoDefer screen:screen]) {
  412. - _helper = [[QNSWindowHelper alloc] initWithNSWindow:self platformWindow:qpw];
  413. - }
  414. - return self;
  415. -}
  416. -
  417. -- (BOOL)canBecomeKeyWindow
  418. -{
  419. - QCocoaWindow *pw = self.helper.platformWindow;
  420. - if (!pw)
  421. - return NO;
  422. -
  423. - if (pw->shouldRefuseKeyWindowAndFirstResponder())
  424. - return NO;
  425. -
  426. - // The default implementation returns NO for title-bar less windows,
  427. - // override and return yes here to make sure popup windows such as
  428. - // the combobox popup can become the key window.
  429. - return YES;
  430. -}
  431. -
  432. -- (BOOL)canBecomeMainWindow
  433. -{
  434. - BOOL canBecomeMain = YES; // By default, windows can become the main window
  435. -
  436. - // Windows with a transient parent (such as combobox popup windows)
  437. - // cannot become the main window:
  438. - QCocoaWindow *pw = self.helper.platformWindow;
  439. - if (!pw || pw->window()->transientParent())
  440. - canBecomeMain = NO;
  441. -
  442. - return canBecomeMain;
  443. -}
  444. -
  445. -- (void)sendEvent:(NSEvent*)theEvent
  446. -{
  447. - [self.helper handleWindowEvent:theEvent];
  448. -}
  449. -
  450. -- (void)superSendEvent:(NSEvent *)theEvent
  451. -{
  452. - [super sendEvent:theEvent];
  453. -}
  454. -
  455. - (void)closeAndRelease
  456. {
  457. qCDebug(lcQpaCocoaWindow) << "closeAndRelease" << self;
  458.  
  459. - [self.helper detachFromPlatformWindow];
  460. + [self.delegate release];
  461. + self.delegate = nil;
  462. +
  463. [self close];
  464. [self release];
  465. }
  466.  
  467. +#pragma clang diagnostic push
  468. +#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
  469. - (void)dealloc
  470. {
  471. - [_helper release];
  472. - _helper = nil;
  473. - [super dealloc];
  474. + dynamicSuper();
  475. }
  476. -
  477. -@end
  478. -
  479. -@implementation QNSPanel
  480. -
  481. -@synthesize helper = _helper;
  482. +#pragma clang diagnostic pop
  483.  
  484. + (void)applicationActivationChanged:(NSNotification*)notification
  485. {
  486. @@ -284,7 +245,7 @@ static const bool kNoDefer = NO;
  487. continue;
  488.  
  489. if ([window conformsToProtocol:@protocol(QNSWindowProtocol)]) {
  490. - QCocoaWindow *cocoaWindow = static_cast<id<QNSWindowProtocol>>(window).helper.platformWindow;
  491. + QCocoaWindow *cocoaWindow = static_cast<QCocoaNSWindow *>(window).platformWindow;
  492. window.level = notification.name == NSApplicationWillResignActiveNotification ?
  493. NSNormalWindowLevel : cocoaWindow->windowLevel(cocoaWindow->window()->flags());
  494. }
  495. @@ -305,70 +266,10 @@ static const bool kNoDefer = NO;
  496. }
  497. }
  498.  
  499. -- (id)initWithContentRect:(NSRect)contentRect
  500. - screen:(NSScreen*)screen
  501. - styleMask:(NSUInteger)windowStyle
  502. - qPlatformWindow:(QCocoaWindow *)qpw
  503. -{
  504. - if (self = [super initWithContentRect:contentRect styleMask:windowStyle
  505. - backing:NSBackingStoreBuffered defer:kNoDefer screen:screen]) {
  506. - _helper = [[QNSWindowHelper alloc] initWithNSWindow:self platformWindow:qpw];
  507. -
  508. - if (qpw->alwaysShowToolWindow()) {
  509. - static dispatch_once_t onceToken;
  510. - dispatch_once(&onceToken, ^{
  511. - NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  512. - [center addObserver:[self class] selector:@selector(applicationActivationChanged:)
  513. - name:NSApplicationWillResignActiveNotification object:nil];
  514. - [center addObserver:[self class] selector:@selector(applicationActivationChanged:)
  515. - name:NSApplicationWillBecomeActiveNotification object:nil];
  516. - });
  517. - }
  518. - }
  519. - return self;
  520. -}
  521. -
  522. -- (BOOL)canBecomeKeyWindow
  523. -{
  524. - QCocoaWindow *pw = self.helper.platformWindow;
  525. - if (!pw)
  526. - return NO;
  527. -
  528. - if (pw->shouldRefuseKeyWindowAndFirstResponder())
  529. - return NO;
  530. -
  531. - // Only tool or dialog windows should become key:
  532. - Qt::WindowType type = pw->window()->type();
  533. - if (type == Qt::Tool || type == Qt::Dialog)
  534. - return YES;
  535. -
  536. - return NO;
  537. -}
  538. -
  539. -- (void)sendEvent:(NSEvent*)theEvent
  540. -{
  541. - [self.helper handleWindowEvent:theEvent];
  542. -}
  543. -
  544. -- (void)superSendEvent:(NSEvent *)theEvent
  545. -{
  546. - [super sendEvent:theEvent];
  547. -}
  548. -
  549. -- (void)closeAndRelease
  550. -{
  551. - qCDebug(lcQpaCocoaWindow) << "closeAndRelease" << self;
  552. -
  553. - [self.helper detachFromPlatformWindow];
  554. - [self close];
  555. - [self release];
  556. -}
  557. -
  558. -- (void)dealloc
  559. -{
  560. - [_helper release];
  561. - _helper = nil;
  562. - [super dealloc];
  563. -}
  564. +@end
  565.  
  566. +@implementation QNSPanel
  567. +// Implementation shared with QNSWindow, see +[QNSWindow load] above
  568. @end
  569. +
  570. +#undef super
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement