2 * MACDRV Cocoa application class declaration
4 * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #import <AppKit/AppKit.h>
23 #include "macdrv_cocoa.h"
26 #define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
30 WineApplicationEventWakeQuery
,
34 @
class WineEventQueue
;
38 @interface WineApplicationController
: NSObject
<NSApplicationDelegate
>
40 CFRunLoopSourceRef requestSource
;
41 NSMutableArray
* requests
;
42 dispatch_queue_t requestsManipQueue
;
44 NSMutableArray
* eventQueues
;
45 NSLock
* eventQueuesLock
;
47 NSTimeInterval eventTimeAdjustment
;
49 NSMutableArray
* keyWindows
;
50 NSMutableSet
* triedWindows
;
51 unsigned long windowFocusSerial
;
53 CGEventSourceKeyboardType keyboardType
;
54 NSEvent
* lastFlagsChanged
;
55 BOOL inputSourceIsInputMethod
;
56 BOOL inputSourceIsInputMethodValid
;
57 uint32_t pressedKeyCodes
[128 / 32];
59 CGFloat primaryScreenHeight
;
60 BOOL primaryScreenHeightValid
;
61 NSMutableData
* screenFrameCGRects
;
63 WineWindow
* lastTargetWindow
;
64 WineWindow
* mouseCaptureWindow
;
65 BOOL forceNextMouseMoveAbsolute
;
66 double mouseMoveDeltaX
, mouseMoveDeltaY
;
67 NSUInteger unmatchedMouseDowns
;
69 NSTimeInterval lastScrollTime
;
70 double accumScrollX
, accumScrollY
;
72 NSMutableDictionary
* originalDisplayModes
;
73 NSMutableDictionary
* latentDisplayModes
;
74 BOOL displaysCapturedForFullscreen
;
76 NSArray
* cursorFrames
;
82 BOOL clientWantsCursorHidden
;
85 CGRect cursorClipRect
;
86 CFMachPortRef cursorClippingEventTap
;
87 NSMutableArray
* warpRecords
;
88 CGPoint synthesizedLocation
;
89 NSTimeInterval lastSetCursorPositionTime
;
90 NSTimeInterval lastEventTapEventTime
;
92 NSImage
* applicationIcon
;
96 NSMutableSet
* windowsBeingDragged
;
99 @
property (nonatomic
) CGEventSourceKeyboardType keyboardType
;
100 @
property (readonly
, copy
, nonatomic
) NSEvent
* lastFlagsChanged
;
101 @
property (readonly
, nonatomic
) BOOL areDisplaysCaptured
;
103 @
property (readonly
) BOOL clippingCursor
;
105 + (WineApplicationController
*) sharedController
;
107 - (void) transformProcessToForeground
;
109 - (BOOL
) registerEventQueue
:(WineEventQueue
*)queue
;
110 - (void) unregisterEventQueue
:(WineEventQueue
*)queue
;
112 - (void) computeEventTimeAdjustmentFromTicks
:(unsigned long long)tickcount uptime
:(uint64_t)uptime_ns
;
113 - (double) ticksForEventTime
:(NSTimeInterval
)eventTime
;
115 - (void) windowGotFocus
:(WineWindow
*)window
;
117 - (BOOL
) waitUntilQueryDone
:(int*)done timeout
:(NSDate
*)timeout processEvents
:(BOOL
)processEvents
;
119 - (void) keyboardSelectionDidChange
;
120 - (void) noteKey
:(uint16_t)keyCode pressed
:(BOOL
)pressed
;
122 - (void) window
:(WineWindow
*)window isBeingDragged
:(BOOL
)dragged
;
124 - (void) flipRect
:(NSRect
*)rect
;
126 - (WineWindow
*) frontWineWindow
;
127 - (void) adjustWindowLevels
;
128 - (void) updateFullscreenWindows
;
130 - (BOOL
) handleEvent
:(NSEvent
*)anEvent
;
131 - (void) didSendEvent
:(NSEvent
*)anEvent
;
136 @interface WineApplication
: NSApplication
138 WineApplicationController
* wineController
;
141 @
property (readwrite
, assign
, nonatomic
) WineApplicationController
* wineController
;
146 void OnMainThreadAsync(dispatch_block_t block
);
148 void LogError(const char* func
, NSString
* format
, ...);
149 void LogErrorv(const char* func
, NSString
* format
, va_list args
);