Release 1.5.29.
[wine] / dlls / winemac.drv / cocoa_app.h
1 /*
2  * MACDRV Cocoa application class declaration
3  *
4  * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #import <AppKit/AppKit.h>
22
23 #include "macdrv_cocoa.h"
24
25
26 #define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
27
28
29 enum {
30     WineApplicationEventWakeQuery,
31 };
32
33
34 @class WineEventQueue;
35 @class WineWindow;
36
37
38 @interface WineApplicationController : NSObject <NSApplicationDelegate>
39 {
40     CFRunLoopSourceRef requestSource;
41     NSMutableArray* requests;
42     dispatch_queue_t requestsManipQueue;
43
44     NSMutableArray* eventQueues;
45     NSLock*         eventQueuesLock;
46
47     NSTimeInterval eventTimeAdjustment;
48
49     NSMutableArray* keyWindows;
50     NSMutableSet* triedWindows;
51     unsigned long windowFocusSerial;
52
53     CGEventSourceKeyboardType keyboardType;
54     NSEvent* lastFlagsChanged;
55     BOOL inputSourceIsInputMethod;
56     BOOL inputSourceIsInputMethodValid;
57
58     CGFloat primaryScreenHeight;
59     BOOL primaryScreenHeightValid;
60
61     WineWindow* lastTargetWindow;
62     BOOL forceNextMouseMoveAbsolute;
63
64     NSMutableArray* orderedWineWindows;
65
66     NSMutableDictionary* originalDisplayModes;
67
68     NSArray*    cursorFrames;
69     int         cursorFrame;
70     NSTimer*    cursorTimer;
71     BOOL        cursorHidden;
72
73     BOOL clippingCursor;
74     CGRect cursorClipRect;
75     CFMachPortRef cursorClippingEventTap;
76     NSMutableArray* warpRecords;
77     CGPoint synthesizedLocation;
78     NSTimeInterval lastSetCursorPositionTime;
79     NSTimeInterval lastEventTapEventTime;
80
81     NSImage* applicationIcon;
82 }
83
84 @property (nonatomic) CGEventSourceKeyboardType keyboardType;
85 @property (readonly, copy, nonatomic) NSEvent* lastFlagsChanged;
86 @property (readonly, nonatomic) NSArray* orderedWineWindows;
87 @property (readonly, nonatomic) BOOL areDisplaysCaptured;
88
89     + (WineApplicationController*) sharedController;
90
91     - (void) transformProcessToForeground;
92
93     - (BOOL) registerEventQueue:(WineEventQueue*)queue;
94     - (void) unregisterEventQueue:(WineEventQueue*)queue;
95
96     - (void) computeEventTimeAdjustmentFromTicks:(unsigned long long)tickcount uptime:(uint64_t)uptime_ns;
97     - (double) ticksForEventTime:(NSTimeInterval)eventTime;
98
99     - (void) windowGotFocus:(WineWindow*)window;
100
101     - (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents;
102
103     - (void) keyboardSelectionDidChange;
104
105     - (void) flipRect:(NSRect*)rect;
106
107     - (void) wineWindow:(WineWindow*)window
108                 ordered:(NSWindowOrderingMode)order
109              relativeTo:(WineWindow*)otherWindow;
110
111     - (BOOL) handleEvent:(NSEvent*)anEvent;
112     - (void) didSendEvent:(NSEvent*)anEvent;
113
114 @end
115
116
117 @interface WineApplication : NSApplication
118 {
119     WineApplicationController* wineController;
120 }
121
122 @property (readwrite, assign, nonatomic) WineApplicationController* wineController;
123
124 @end
125
126
127 void OnMainThreadAsync(dispatch_block_t block);
128
129 void LogError(const char* func, NSString* format, ...);
130 void LogErrorv(const char* func, NSString* format, va_list args);