widl: Add support for structures.
[wine.git] / dlls / winemac.drv / cocoa_app.h
blobb2b8187e0b464deca89316857f9b98c21ff779b6
1 /*
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"
25 #if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
26 /* For older SDKs, #define the new names of constants deprecated/renamed in macOS 10.12. */
27 #define NSCompositingOperationSourceOver NSCompositeSourceOver
28 #define NSEventMaskAny NSAnyEventMask
29 #define NSEventMaskLeftMouseDown NSLeftMouseDownMask
30 #define NSEventMaskOtherMouseDown NSOtherMouseDownMask
31 #define NSEventMaskRightMouseDown NSRightMouseDownMask
32 #define NSEventModifierFlagCommand NSCommandKeyMask
33 #define NSEventModifierFlagControl NSControlKeyMask
34 #define NSEventModifierFlagOption NSAlternateKeyMask
35 #define NSEventModifierFlagShift NSShiftKeyMask
36 #define NSEventTypeAppKitDefined NSAppKitDefined
37 #define NSEventTypeApplicationDefined NSApplicationDefined
38 #define NSEventTypeFlagsChanged NSFlagsChanged
39 #define NSEventTypeKeyDown NSKeyDown
40 #define NSEventTypeKeyUp NSKeyUp
41 #define NSEventTypeLeftMouseDown NSLeftMouseDown
42 #define NSEventTypeLeftMouseDragged NSLeftMouseDragged
43 #define NSEventTypeLeftMouseUp NSLeftMouseUp
44 #define NSEventTypeMouseMoved NSMouseMoved
45 #define NSEventTypeOtherMouseDown NSOtherMouseDown
46 #define NSEventTypeOtherMouseDragged NSOtherMouseDragged
47 #define NSEventTypeOtherMouseUp NSOtherMouseUp
48 #define NSEventTypeRightMouseDown NSRightMouseDown
49 #define NSEventTypeRightMouseUp NSRightMouseUp
50 #define NSEventTypeRightMouseDragged NSRightMouseDragged
51 #define NSEventTypeScrollWheel NSScrollWheel
52 #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
53 #define NSWindowStyleMaskClosable NSClosableWindowMask
54 #define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
55 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
56 #define NSWindowStyleMaskResizable NSResizableWindowMask
57 #define NSWindowStyleMaskTitled NSTitledWindowMask
58 #define NSWindowStyleMaskUtilityWindow NSUtilityWindowMask
59 #define NSWindowStyleMaskNonactivatingPanel NSNonactivatingPanelMask
60 #endif
62 #define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
65 enum {
66 WineApplicationEventWakeQuery,
70 @class WineEventQueue;
71 @class WineWindow;
72 @protocol WineClipCursorHandler;
75 @interface WineApplicationController : NSObject <NSApplicationDelegate>
77 CFRunLoopSourceRef requestSource;
78 NSMutableArray* requests;
79 dispatch_queue_t requestsManipQueue;
81 NSMutableArray* eventQueues;
82 NSLock* eventQueuesLock;
84 NSTimeInterval eventTimeAdjustment;
86 NSMutableArray* keyWindows;
87 NSMutableSet* triedWindows;
88 unsigned long windowFocusSerial;
90 TISInputSourceRef lastKeyboardInputSource;
91 TISInputSourceRef lastKeyboardLayoutInputSource;
92 CGEventSourceKeyboardType keyboardType;
93 NSEvent* lastFlagsChanged;
94 BOOL inputSourceIsInputMethod;
95 uint32_t pressedKeyCodes[128 / 32];
97 CGFloat primaryScreenHeight;
98 BOOL primaryScreenHeightValid;
99 NSMutableData* screenFrameCGRects;
101 WineWindow* lastTargetWindow;
102 WineWindow* mouseCaptureWindow;
103 BOOL forceNextMouseMoveAbsolute;
104 double mouseMoveDeltaX, mouseMoveDeltaY;
105 NSUInteger unmatchedMouseDowns;
107 NSTimeInterval lastScrollTime;
108 double accumScrollX, accumScrollY;
110 NSMutableDictionary* originalDisplayModes;
111 NSMutableDictionary* latentDisplayModes;
112 BOOL displaysCapturedForFullscreen;
114 NSArray* cursorFrames;
115 int cursorFrame;
116 NSTimer* cursorTimer;
117 NSCursor* cursor;
118 BOOL cursorIsCurrent;
119 BOOL cursorHidden;
120 BOOL clientWantsCursorHidden;
122 NSTimeInterval lastSetCursorPositionTime;
124 id<WineClipCursorHandler> clipCursorHandler;
126 NSImage* applicationIcon;
128 BOOL beenActive;
130 NSMutableSet* windowsBeingDragged;
131 BOOL useDragNotifications;
134 @property (nonatomic) CGEventSourceKeyboardType keyboardType;
135 @property (readonly, copy, nonatomic) NSEvent* lastFlagsChanged;
136 @property (readonly, nonatomic) BOOL areDisplaysCaptured;
138 @property (readonly) BOOL clippingCursor;
139 @property (nonatomic) NSTimeInterval lastSetCursorPositionTime;
141 + (WineApplicationController*) sharedController;
143 - (void) transformProcessToForeground:(BOOL)activateIfTransformed;
144 - (void) tryToActivateIgnoringOtherApps:(BOOL)ignore;
146 - (BOOL) registerEventQueue:(WineEventQueue*)queue;
147 - (void) unregisterEventQueue:(WineEventQueue*)queue;
149 - (void) computeEventTimeAdjustmentFromTicks:(unsigned long long)tickcount uptime:(uint64_t)uptime_ns;
150 - (double) ticksForEventTime:(NSTimeInterval)eventTime;
152 - (void) windowGotFocus:(WineWindow*)window;
154 - (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents;
156 - (void) noteKey:(uint16_t)keyCode pressed:(BOOL)pressed;
158 - (void) window:(WineWindow*)window isBeingDragged:(BOOL)dragged;
159 - (void) windowWillOrderOut:(WineWindow*)window;
161 - (void) flipRect:(NSRect*)rect;
162 - (NSPoint) flippedMouseLocation:(NSPoint)point;
164 - (WineWindow*) frontWineWindow;
165 - (void) adjustWindowLevels;
166 - (void) updateFullscreenWindows;
168 - (BOOL) handleEvent:(NSEvent*)anEvent;
169 - (void) didSendEvent:(NSEvent*)anEvent;
171 @end
174 @interface WineApplication : NSApplication
176 WineApplicationController* wineController;
179 @property (readwrite, assign, nonatomic) WineApplicationController* wineController;
181 @end
184 void OnMainThreadAsync(dispatch_block_t block);
186 void LogError(const char* func, NSString* format, ...);
187 void LogErrorv(const char* func, NSString* format, va_list args);