win32u: Move NtUserGetMessage implementation from user32.
[wine.git] / dlls / winemac.drv / cocoa_app.h
blob52c91c0621f19f02a8857c3e80039edf1cb999c4
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 BOOL inputSourceIsInputMethodValid;
96 uint32_t pressedKeyCodes[128 / 32];
98 CGFloat primaryScreenHeight;
99 BOOL primaryScreenHeightValid;
100 NSMutableData* screenFrameCGRects;
102 WineWindow* lastTargetWindow;
103 WineWindow* mouseCaptureWindow;
104 BOOL forceNextMouseMoveAbsolute;
105 double mouseMoveDeltaX, mouseMoveDeltaY;
106 NSUInteger unmatchedMouseDowns;
108 NSTimeInterval lastScrollTime;
109 double accumScrollX, accumScrollY;
111 NSMutableDictionary* originalDisplayModes;
112 NSMutableDictionary* latentDisplayModes;
113 BOOL displaysCapturedForFullscreen;
115 NSArray* cursorFrames;
116 int cursorFrame;
117 NSTimer* cursorTimer;
118 NSCursor* cursor;
119 BOOL cursorIsCurrent;
120 BOOL cursorHidden;
121 BOOL clientWantsCursorHidden;
123 NSTimeInterval lastSetCursorPositionTime;
125 id<WineClipCursorHandler> clipCursorHandler;
127 NSImage* applicationIcon;
129 BOOL beenActive;
131 NSMutableSet* windowsBeingDragged;
132 BOOL useDragNotifications;
135 @property (nonatomic) CGEventSourceKeyboardType keyboardType;
136 @property (readonly, copy, nonatomic) NSEvent* lastFlagsChanged;
137 @property (readonly, nonatomic) BOOL areDisplaysCaptured;
139 @property (readonly) BOOL clippingCursor;
140 @property (nonatomic) NSTimeInterval lastSetCursorPositionTime;
142 + (WineApplicationController*) sharedController;
144 - (void) transformProcessToForeground:(BOOL)activateIfTransformed;
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);