|
1 | 1 | #include "WindowOverlayImpl.h"
|
2 | 2 | #include "WindowInterfaces.h"
|
3 | 3 |
|
| 4 | +WindowOverlayImpl::~WindowOverlayImpl() |
| 5 | +{ |
| 6 | + [View removeFromSuperview]; |
| 7 | + [[NSNotificationCenter defaultCenter] removeObserver: View]; |
| 8 | + |
| 9 | + for (id monitor in eventMonitors) |
| 10 | + { |
| 11 | + [NSEvent removeMonitor: monitor]; |
| 12 | + } |
| 13 | +} |
| 14 | + |
4 | 15 | WindowOverlayImpl::WindowOverlayImpl(void* parentWindow, char* parentView, IAvnWindowEvents *events) : WindowImpl(events), WindowBaseImpl(events, false, true) {
|
5 | 16 | this->parentWindow = (__bridge NSWindow*) parentWindow;
|
6 | 17 | this->parentView = FindNSView(this->parentWindow, [NSString stringWithUTF8String:parentView]);
|
|
23 | 34 | [[NSNotificationCenter defaultCenter] addObserver:View selector:@selector(overlayWindowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:this->parentWindow];
|
24 | 35 | [[NSNotificationCenter defaultCenter] addObserver:View selector:@selector(overlayWindowDidResignKey:) name:NSWindowDidResignKeyNotification object:this->parentWindow];
|
25 | 36 |
|
26 |
| - [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskMouseMoved handler:^NSEvent * (NSEvent * event) { |
| 37 | + id mouseMovedMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskMouseMoved handler:^NSEvent * (NSEvent * event) { |
27 | 38 | //NSLog(@"MONITOR mouseMoved START");
|
28 | 39 |
|
29 | 40 | if ([event window] != this->parentWindow)
|
|
73 | 84 | }
|
74 | 85 | }];
|
75 | 86 |
|
76 |
| - [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskLeftMouseDown handler:^NSEvent * (NSEvent * event) { |
| 87 | + id leftMouseDownMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskLeftMouseDown handler:^NSEvent * (NSEvent * event) { |
77 | 88 | NSLog(@"MONITOR mouseDown START");
|
78 | 89 |
|
79 | 90 | if ([event window] != this->parentWindow)
|
|
102 | 113 | return event;
|
103 | 114 | }];
|
104 | 115 |
|
105 |
| - [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged handler:^NSEvent * (NSEvent * event) { |
| 116 | + id keydownMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged handler:^NSEvent * (NSEvent * event) { |
106 | 117 | bool handled = false;
|
107 | 118 | NSUInteger flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
108 | 119 |
|
|
189 | 200 | return event;
|
190 | 201 | }
|
191 | 202 | }];
|
| 203 | + |
| 204 | + eventMonitors = [NSArray arrayWithObjects: mouseMovedMonitor, leftMouseDownMonitor, keydownMonitor, nil]; |
192 | 205 | }
|
193 | 206 |
|
194 | 207 |
|
|
239 | 252 | return S_OK;
|
240 | 253 | }
|
241 | 254 |
|
| 255 | +HRESULT WindowOverlayImpl::Close() |
| 256 | +{ |
| 257 | + START_COM_CALL; |
| 258 | + HRESULT result = WindowImpl::Close(); |
| 259 | + [View onClosed]; |
| 260 | + |
| 261 | + return result; |
| 262 | +} |
| 263 | + |
242 | 264 | HRESULT WindowOverlayImpl::PointToClient(AvnPoint point, AvnPoint *ret) {
|
243 | 265 | START_COM_CALL;
|
244 | 266 |
|
|
0 commit comments