include: Added missing FindExInfoBasic enum.
[wine/multimedia.git] / dlls / winemac.drv / macdrv_cocoa.h
blob564910c2c75fb31fd2f08c29273eee9e330189ee
1 /*
2 * MACDRV Cocoa interface declarations
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 /* This header serves as a C interface between the Wine parts of MACDRV
22 * and the Objective-C parts. It should restrict itself to C and the C-based
23 * Mac APIs, avoiding both Wine and Objective-C/Cocoa features, so that it can
24 * be included by both sides without contaminating either.
27 #ifndef __WINE_MACDRV_COCOA_H
28 #define __WINE_MACDRV_COCOA_H
31 #define GetCurrentProcess MacGetCurrentProcess
32 #define GetCurrentThread MacGetCurrentThread
33 #define LoadResource MacLoadResource
34 #define AnimatePalette MacAnimatePalette
35 #define EqualRgn MacEqualRgn
36 #define FillRgn MacFillRgn
37 #define FrameRgn MacFrameRgn
38 #define GetPixel MacGetPixel
39 #define InvertRgn MacInvertRgn
40 #define LineTo MacLineTo
41 #define OffsetRgn MacOffsetRgn
42 #define PaintRgn MacPaintRgn
43 #define Polygon MacPolygon
44 #define ResizePalette MacResizePalette
45 #define SetRectRgn MacSetRectRgn
46 #define EqualRect MacEqualRect
47 #define FillRect MacFillRect
48 #define FrameRect MacFrameRect
49 #define GetCursor MacGetCursor
50 #define InvertRect MacInvertRect
51 #define OffsetRect MacOffsetRect
52 #define PtInRect MacPtInRect
53 #define SetCursor MacSetCursor
54 #define SetRect MacSetRect
55 #define ShowCursor MacShowCursor
56 #define UnionRect MacUnionRect
58 #include <ApplicationServices/ApplicationServices.h>
60 #undef GetCurrentProcess
61 #undef GetCurrentThread
62 #undef LoadResource
63 #undef AnimatePalette
64 #undef EqualRgn
65 #undef FillRgn
66 #undef FrameRgn
67 #undef GetPixel
68 #undef InvertRgn
69 #undef LineTo
70 #undef OffsetRgn
71 #undef PaintRgn
72 #undef Polygon
73 #undef ResizePalette
74 #undef SetRectRgn
75 #undef EqualRect
76 #undef FillRect
77 #undef FrameRect
78 #undef GetCursor
79 #undef InvertRect
80 #undef OffsetRect
81 #undef PtInRect
82 #undef SetCursor
83 #undef SetRect
84 #undef ShowCursor
85 #undef UnionRect
86 #undef DPRINTF
88 #include <pthread.h>
91 #ifndef DECLSPEC_HIDDEN
92 # if defined(__MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
93 # define DECLSPEC_HIDDEN
94 # elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
95 # define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
96 # else
97 # define DECLSPEC_HIDDEN
98 # endif
99 #endif
102 /* Must match the values of Cocoa's NSDragOperation enum. */
103 enum {
104 DRAG_OP_NONE = 0,
105 DRAG_OP_COPY = 1,
106 DRAG_OP_LINK = 2,
107 DRAG_OP_GENERIC = 4,
108 DRAG_OP_PRIVATE = 8,
109 DRAG_OP_MOVE = 16,
110 DRAG_OP_DELETE = 32,
111 DRAG_OP_EVERY = UINT32_MAX
114 enum {
115 TOPMOST_FLOAT_INACTIVE_NONE,
116 TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN,
117 TOPMOST_FLOAT_INACTIVE_ALL,
120 enum {
121 MACDRV_HOTKEY_SUCCESS,
122 MACDRV_HOTKEY_ALREADY_REGISTERED,
123 MACDRV_HOTKEY_FAILURE,
126 typedef struct __TISInputSource *TISInputSourceRef;
128 typedef struct macdrv_opaque_window* macdrv_window;
129 typedef struct macdrv_opaque_event_queue* macdrv_event_queue;
130 typedef struct macdrv_opaque_view* macdrv_view;
131 typedef struct macdrv_opaque_opengl_context* macdrv_opengl_context;
132 typedef struct macdrv_opaque_status_item* macdrv_status_item;
133 struct macdrv_event;
134 struct macdrv_query;
136 struct macdrv_display {
137 CGDirectDisplayID displayID;
138 CGRect frame;
139 CGRect work_frame;
143 /* main */
144 extern int macdrv_err_on;
145 extern int topmost_float_inactive DECLSPEC_HIDDEN;
146 extern int capture_displays_for_fullscreen DECLSPEC_HIDDEN;
147 extern int left_option_is_alt DECLSPEC_HIDDEN;
148 extern int right_option_is_alt DECLSPEC_HIDDEN;
149 extern int allow_immovable_windows DECLSPEC_HIDDEN;
151 extern int macdrv_start_cocoa_app(unsigned long long tickcount) DECLSPEC_HIDDEN;
152 extern void macdrv_window_rejected_focus(const struct macdrv_event *event) DECLSPEC_HIDDEN;
153 extern void macdrv_beep(void) DECLSPEC_HIDDEN;
154 extern void macdrv_set_application_icon(CFArrayRef images) DECLSPEC_HIDDEN;
155 extern void macdrv_quit_reply(int reply) DECLSPEC_HIDDEN;
156 extern int macdrv_using_input_method(void) DECLSPEC_HIDDEN;
157 extern void macdrv_set_mouse_capture_window(macdrv_window window) DECLSPEC_HIDDEN;
160 /* cursor */
161 extern void macdrv_set_cursor(CFStringRef name, CFArrayRef frames) DECLSPEC_HIDDEN;
162 extern int macdrv_get_cursor_position(CGPoint *pos) DECLSPEC_HIDDEN;
163 extern int macdrv_set_cursor_position(CGPoint pos) DECLSPEC_HIDDEN;
164 extern int macdrv_clip_cursor(CGRect rect) DECLSPEC_HIDDEN;
167 /* display */
168 extern int macdrv_get_displays(struct macdrv_display** displays, int* count) DECLSPEC_HIDDEN;
169 extern void macdrv_free_displays(struct macdrv_display* displays) DECLSPEC_HIDDEN;
170 extern int macdrv_set_display_mode(const struct macdrv_display* display,
171 CGDisplayModeRef display_mode) DECLSPEC_HIDDEN;
174 /* event */
175 enum {
176 APP_DEACTIVATED,
177 APP_QUIT_REQUESTED,
178 DISPLAYS_CHANGED,
179 HOTKEY_PRESS,
180 IM_SET_TEXT,
181 KEY_PRESS,
182 KEY_RELEASE,
183 KEYBOARD_CHANGED,
184 MOUSE_BUTTON,
185 MOUSE_MOVED,
186 MOUSE_MOVED_ABSOLUTE,
187 MOUSE_SCROLL,
188 QUERY_EVENT,
189 RELEASE_CAPTURE,
190 STATUS_ITEM_MOUSE_BUTTON,
191 STATUS_ITEM_MOUSE_MOVE,
192 WINDOW_BROUGHT_FORWARD,
193 WINDOW_CLOSE_REQUESTED,
194 WINDOW_DID_UNMINIMIZE,
195 WINDOW_DRAG_BEGIN,
196 WINDOW_DRAG_END,
197 WINDOW_FRAME_CHANGED,
198 WINDOW_GOT_FOCUS,
199 WINDOW_LOST_FOCUS,
200 WINDOW_MAXIMIZE_REQUESTED,
201 WINDOW_MINIMIZE_REQUESTED,
202 WINDOW_RESIZE_ENDED,
203 WINDOW_RESTORE_REQUESTED,
204 NUM_EVENT_TYPES
207 enum {
208 QUIT_REASON_NONE,
209 QUIT_REASON_LOGOUT,
210 QUIT_REASON_RESTART,
211 QUIT_REASON_SHUTDOWN,
214 typedef uint32_t macdrv_event_mask;
216 typedef struct macdrv_event {
217 int refs;
218 int deliver;
219 int type;
220 macdrv_window window;
221 union {
222 struct {
223 int reason;
224 } app_quit_requested;
225 struct {
226 int activating;
227 } displays_changed;
228 struct {
229 unsigned int vkey;
230 unsigned int mod_flags;
231 unsigned int keycode;
232 unsigned long time_ms;
233 } hotkey_press;
234 struct {
235 void *data;
236 CFStringRef text; /* new text or NULL if just completing existing text */
237 unsigned int cursor_pos;
238 unsigned int complete; /* is completing text? */
239 } im_set_text;
240 struct {
241 CGKeyCode keycode;
242 CGEventFlags modifiers;
243 unsigned long time_ms;
244 } key;
245 struct {
246 CFDataRef uchr;
247 CGEventSourceKeyboardType keyboard_type;
248 int iso_keyboard;
249 TISInputSourceRef input_source;
250 } keyboard_changed;
251 struct {
252 int button;
253 int pressed;
254 int x;
255 int y;
256 unsigned long time_ms;
257 } mouse_button;
258 struct {
259 int x;
260 int y;
261 int drag;
262 unsigned long time_ms;
263 } mouse_moved;
264 struct {
265 int x_scroll;
266 int y_scroll;
267 int x;
268 int y;
269 unsigned long time_ms;
270 } mouse_scroll;
271 struct {
272 struct macdrv_query *query;
273 } query_event;
274 struct {
275 macdrv_status_item item;
276 int button;
277 int down;
278 int count;
279 } status_item_mouse_button;
280 struct {
281 macdrv_status_item item;
282 } status_item_mouse_move;
283 struct {
284 CGRect frame;
285 int fullscreen;
286 int in_resize;
287 } window_frame_changed;
288 struct {
289 unsigned long serial;
290 void *tried_windows;
291 } window_got_focus;
293 } macdrv_event;
295 enum {
296 QUERY_DRAG_DROP,
297 QUERY_DRAG_EXITED,
298 QUERY_DRAG_OPERATION,
299 QUERY_IME_CHAR_RECT,
300 QUERY_PASTEBOARD_DATA,
301 QUERY_RESIZE_START,
302 QUERY_MIN_MAX_INFO,
303 NUM_QUERY_TYPES
306 typedef struct macdrv_query {
307 int refs;
308 int type;
309 macdrv_window window;
310 int status;
311 int done;
312 union {
313 struct {
314 int x;
315 int y;
316 uint32_t op;
317 CFTypeRef pasteboard;
318 } drag_drop;
319 struct {
320 int x;
321 int y;
322 uint32_t offered_ops;
323 uint32_t accepted_op;
324 CFTypeRef pasteboard;
325 } drag_operation;
326 struct {
327 void *data;
328 CFRange range;
329 CGRect rect;
330 } ime_char_rect;
331 struct {
332 CFStringRef type;
333 } pasteboard_data;
335 } macdrv_query;
337 static inline macdrv_event_mask event_mask_for_type(int type)
339 return ((macdrv_event_mask)1 << type);
342 typedef void (*macdrv_event_handler)(const macdrv_event *event);
344 extern macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler) DECLSPEC_HIDDEN;
345 extern void macdrv_destroy_event_queue(macdrv_event_queue queue) DECLSPEC_HIDDEN;
346 extern int macdrv_get_event_queue_fd(macdrv_event_queue queue) DECLSPEC_HIDDEN;
348 extern int macdrv_copy_event_from_queue(macdrv_event_queue queue,
349 macdrv_event_mask mask, macdrv_event **event) DECLSPEC_HIDDEN;
350 extern void macdrv_release_event(macdrv_event *event) DECLSPEC_HIDDEN;
352 extern macdrv_query* macdrv_create_query(void) DECLSPEC_HIDDEN;
353 extern macdrv_query* macdrv_retain_query(macdrv_query *query) DECLSPEC_HIDDEN;
354 extern void macdrv_release_query(macdrv_query *query) DECLSPEC_HIDDEN;
355 extern void macdrv_set_query_done(macdrv_query *query) DECLSPEC_HIDDEN;
356 extern int macdrv_register_hot_key(macdrv_event_queue q, unsigned int vkey, unsigned int mod_flags,
357 unsigned int keycode, unsigned int modifiers) DECLSPEC_HIDDEN;
358 extern void macdrv_unregister_hot_key(macdrv_event_queue q, unsigned int vkey, unsigned int mod_flags) DECLSPEC_HIDDEN;
361 /* window */
362 struct macdrv_window_features {
363 unsigned int title_bar:1;
364 unsigned int close_button:1;
365 unsigned int minimize_button:1;
366 unsigned int resizable:1;
367 unsigned int maximize_button:1;
368 unsigned int utility:1;
369 unsigned int shadow:1;
372 struct macdrv_window_state {
373 unsigned int disabled:1;
374 unsigned int no_activate:1;
375 unsigned int floating:1;
376 unsigned int excluded_by_expose:1;
377 unsigned int excluded_by_cycle:1;
378 unsigned int minimized:1;
379 unsigned int minimized_valid:1;
380 unsigned int maximized:1;
383 extern macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf,
384 CGRect frame, void* hwnd, macdrv_event_queue queue) DECLSPEC_HIDDEN;
385 extern void macdrv_destroy_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
386 extern void* macdrv_get_window_hwnd(macdrv_window w) DECLSPEC_HIDDEN;
387 extern void macdrv_set_cocoa_window_features(macdrv_window w,
388 const struct macdrv_window_features* wf) DECLSPEC_HIDDEN;
389 extern void macdrv_set_cocoa_window_state(macdrv_window w,
390 const struct macdrv_window_state* state) DECLSPEC_HIDDEN;
391 extern void macdrv_set_cocoa_window_title(macdrv_window w, const UniChar* title,
392 size_t length) DECLSPEC_HIDDEN;
393 extern void macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
394 macdrv_window next, int activate) DECLSPEC_HIDDEN;
395 extern void macdrv_hide_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
396 extern void macdrv_set_cocoa_window_frame(macdrv_window w, const CGRect* new_frame) DECLSPEC_HIDDEN;
397 extern void macdrv_get_cocoa_window_frame(macdrv_window w, CGRect* out_frame) DECLSPEC_HIDDEN;
398 extern void macdrv_set_cocoa_parent_window(macdrv_window w, macdrv_window parent) DECLSPEC_HIDDEN;
399 extern void macdrv_set_window_surface(macdrv_window w, void *surface, pthread_mutex_t *mutex) DECLSPEC_HIDDEN;
400 extern CGImageRef create_surface_image(void *window_surface, CGRect *rect, int copy_data) DECLSPEC_HIDDEN;
401 extern int get_surface_blit_rects(void *window_surface, const CGRect **rects, int *count) DECLSPEC_HIDDEN;
402 extern void macdrv_window_needs_display(macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
403 extern void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count) DECLSPEC_HIDDEN;
404 extern void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha) DECLSPEC_HIDDEN;
405 extern void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGreen,
406 CGFloat keyBlue) DECLSPEC_HIDDEN;
407 extern void macdrv_clear_window_color_key(macdrv_window w) DECLSPEC_HIDDEN;
408 extern void macdrv_window_use_per_pixel_alpha(macdrv_window w, int use_per_pixel_alpha) DECLSPEC_HIDDEN;
409 extern void macdrv_give_cocoa_window_focus(macdrv_window w, int activate) DECLSPEC_HIDDEN;
410 extern void macdrv_set_window_min_max_sizes(macdrv_window w, CGSize min_size, CGSize max_size) DECLSPEC_HIDDEN;
411 extern macdrv_view macdrv_create_view(macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
412 extern void macdrv_dispose_view(macdrv_view v) DECLSPEC_HIDDEN;
413 extern void macdrv_set_view_window_and_frame(macdrv_view v, macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
414 extern void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
415 extern void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
416 extern uint32_t macdrv_window_background_color(void) DECLSPEC_HIDDEN;
417 extern int macdrv_send_text_input_event(int pressed, unsigned int flags, int repeat, int keyc,
418 void* data) DECLSPEC_HIDDEN;
421 /* keyboard */
422 extern void macdrv_get_input_source_info(CFDataRef* uchr,CGEventSourceKeyboardType* keyboard_type, int* is_iso,
423 TISInputSourceRef* input_source) DECLSPEC_HIDDEN;
424 extern CFArrayRef macdrv_create_input_source_list(void) DECLSPEC_HIDDEN;
425 extern int macdrv_select_input_source(TISInputSourceRef input_source) DECLSPEC_HIDDEN;
426 extern const CFStringRef macdrv_input_source_input_key DECLSPEC_HIDDEN;
427 extern const CFStringRef macdrv_input_source_type_key DECLSPEC_HIDDEN;
428 extern const CFStringRef macdrv_input_source_lang_key DECLSPEC_HIDDEN;
429 extern int macdrv_layout_list_needs_update DECLSPEC_HIDDEN;
432 /* clipboard */
433 extern CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) DECLSPEC_HIDDEN;
434 extern CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) DECLSPEC_HIDDEN;
435 extern int macdrv_is_pasteboard_owner(void) DECLSPEC_HIDDEN;
436 extern void macdrv_clear_pasteboard(void) DECLSPEC_HIDDEN;
437 extern int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w) DECLSPEC_HIDDEN;
440 /* opengl */
441 extern macdrv_opengl_context macdrv_create_opengl_context(void* cglctx) DECLSPEC_HIDDEN;
442 extern void macdrv_dispose_opengl_context(macdrv_opengl_context c) DECLSPEC_HIDDEN;
443 extern void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v) DECLSPEC_HIDDEN;
444 extern void macdrv_update_opengl_context(macdrv_opengl_context c) DECLSPEC_HIDDEN;
445 extern void macdrv_flush_opengl_context(macdrv_opengl_context c) DECLSPEC_HIDDEN;
448 /* systray / status item */
449 extern macdrv_status_item macdrv_create_status_item(macdrv_event_queue q) DECLSPEC_HIDDEN;
450 extern void macdrv_destroy_status_item(macdrv_status_item s) DECLSPEC_HIDDEN;
451 extern void macdrv_set_status_item_image(macdrv_status_item s, CGImageRef cgimage) DECLSPEC_HIDDEN;
452 extern void macdrv_set_status_item_tooltip(macdrv_status_item s, CFStringRef cftip) DECLSPEC_HIDDEN;
454 #endif /* __WINE_MACDRV_COCOA_H */