ws2_32/tests: Initialize bytesReturned to 123456 before a failing test.
[wine.git] / dlls / winemac.drv / macdrv_cocoa.h
bloba22b4c2917b7f3eac4b56280b3671767251e4b5a
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 #include "macdrv_res.h"
105 /* Must match the values of Cocoa's NSDragOperation enum. */
106 enum {
107 DRAG_OP_NONE = 0,
108 DRAG_OP_COPY = 1,
109 DRAG_OP_LINK = 2,
110 DRAG_OP_GENERIC = 4,
111 DRAG_OP_PRIVATE = 8,
112 DRAG_OP_MOVE = 16,
113 DRAG_OP_DELETE = 32,
114 DRAG_OP_EVERY = UINT32_MAX
117 enum {
118 TOPMOST_FLOAT_INACTIVE_NONE,
119 TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN,
120 TOPMOST_FLOAT_INACTIVE_ALL,
123 enum {
124 GL_SURFACE_IN_FRONT_OPAQUE,
125 GL_SURFACE_IN_FRONT_TRANSPARENT,
126 GL_SURFACE_BEHIND,
129 enum {
130 MACDRV_HOTKEY_SUCCESS,
131 MACDRV_HOTKEY_ALREADY_REGISTERED,
132 MACDRV_HOTKEY_FAILURE,
135 typedef struct __TISInputSource *TISInputSourceRef;
137 typedef struct macdrv_opaque_window* macdrv_window;
138 typedef struct macdrv_opaque_event_queue* macdrv_event_queue;
139 typedef struct macdrv_opaque_view* macdrv_view;
140 typedef struct macdrv_opaque_opengl_context* macdrv_opengl_context;
141 typedef struct macdrv_opaque_status_item* macdrv_status_item;
142 struct macdrv_event;
143 struct macdrv_query;
145 struct macdrv_display {
146 CGDirectDisplayID displayID;
147 CGRect frame;
148 CGRect work_frame;
152 /* main */
153 extern int macdrv_err_on;
154 extern int topmost_float_inactive DECLSPEC_HIDDEN;
155 extern int capture_displays_for_fullscreen DECLSPEC_HIDDEN;
156 extern int left_option_is_alt DECLSPEC_HIDDEN;
157 extern int right_option_is_alt DECLSPEC_HIDDEN;
158 extern int allow_immovable_windows DECLSPEC_HIDDEN;
159 extern int cursor_clipping_locks_windows DECLSPEC_HIDDEN;
160 extern int use_precise_scrolling DECLSPEC_HIDDEN;
161 extern int gl_surface_mode DECLSPEC_HIDDEN;
162 extern CFDictionaryRef localized_strings DECLSPEC_HIDDEN;
163 extern int retina_enabled DECLSPEC_HIDDEN; /* Whether Retina mode is enabled via registry setting. */
164 extern int retina_on DECLSPEC_HIDDEN; /* Whether Retina mode is currently active (enabled and display is in default mode). */
166 static inline CGRect cgrect_mac_from_win(CGRect rect)
168 if (retina_on)
170 rect.origin.x /= 2;
171 rect.origin.y /= 2;
172 rect.size.width /= 2;
173 rect.size.height /= 2;
176 return rect;
179 static inline CGRect cgrect_win_from_mac(CGRect rect)
181 if (retina_on)
183 rect.origin.x *= 2;
184 rect.origin.y *= 2;
185 rect.size.width *= 2;
186 rect.size.height *= 2;
189 return rect;
192 static inline CGSize cgsize_mac_from_win(CGSize size)
194 if (retina_on)
196 size.width /= 2;
197 size.height /= 2;
200 return size;
203 static inline CGSize cgsize_win_from_mac(CGSize size)
205 if (retina_on)
207 size.width *= 2;
208 size.height *= 2;
211 return size;
214 static inline CGPoint cgpoint_mac_from_win(CGPoint point)
216 if (retina_on)
218 point.x /= 2;
219 point.y /= 2;
222 return point;
225 static inline CGPoint cgpoint_win_from_mac(CGPoint point)
227 if (retina_on)
229 point.x *= 2;
230 point.y *= 2;
233 return point;
236 extern int macdrv_start_cocoa_app(unsigned long long tickcount) DECLSPEC_HIDDEN;
237 extern void macdrv_window_rejected_focus(const struct macdrv_event *event) DECLSPEC_HIDDEN;
238 extern void macdrv_beep(void) DECLSPEC_HIDDEN;
239 extern void macdrv_set_application_icon(CFArrayRef images) DECLSPEC_HIDDEN;
240 extern void macdrv_quit_reply(int reply) DECLSPEC_HIDDEN;
241 extern int macdrv_using_input_method(void) DECLSPEC_HIDDEN;
242 extern void macdrv_set_mouse_capture_window(macdrv_window window) DECLSPEC_HIDDEN;
243 extern void macdrv_set_cocoa_retina_mode(int new_mode) DECLSPEC_HIDDEN;
246 /* cursor */
247 extern void macdrv_set_cursor(CFStringRef name, CFArrayRef frames) DECLSPEC_HIDDEN;
248 extern int macdrv_get_cursor_position(CGPoint *pos) DECLSPEC_HIDDEN;
249 extern int macdrv_set_cursor_position(CGPoint pos) DECLSPEC_HIDDEN;
250 extern int macdrv_clip_cursor(CGRect rect) DECLSPEC_HIDDEN;
253 /* display */
254 extern int macdrv_get_displays(struct macdrv_display** displays, int* count) DECLSPEC_HIDDEN;
255 extern void macdrv_free_displays(struct macdrv_display* displays) DECLSPEC_HIDDEN;
256 extern int macdrv_set_display_mode(const struct macdrv_display* display,
257 CGDisplayModeRef display_mode) DECLSPEC_HIDDEN;
260 /* event */
261 enum {
262 APP_ACTIVATED,
263 APP_DEACTIVATED,
264 APP_QUIT_REQUESTED,
265 DISPLAYS_CHANGED,
266 HOTKEY_PRESS,
267 IM_SET_TEXT,
268 KEY_PRESS,
269 KEY_RELEASE,
270 KEYBOARD_CHANGED,
271 LOST_PASTEBOARD_OWNERSHIP,
272 MOUSE_BUTTON,
273 MOUSE_MOVED,
274 MOUSE_MOVED_ABSOLUTE,
275 MOUSE_SCROLL,
276 QUERY_EVENT,
277 QUERY_EVENT_NO_PREEMPT_WAIT,
278 REASSERT_WINDOW_POSITION,
279 RELEASE_CAPTURE,
280 SENT_TEXT_INPUT,
281 STATUS_ITEM_MOUSE_BUTTON,
282 STATUS_ITEM_MOUSE_MOVE,
283 WINDOW_BROUGHT_FORWARD,
284 WINDOW_CLOSE_REQUESTED,
285 WINDOW_DID_UNMINIMIZE,
286 WINDOW_DRAG_BEGIN,
287 WINDOW_DRAG_END,
288 WINDOW_FRAME_CHANGED,
289 WINDOW_GOT_FOCUS,
290 WINDOW_LOST_FOCUS,
291 WINDOW_MAXIMIZE_REQUESTED,
292 WINDOW_MINIMIZE_REQUESTED,
293 WINDOW_RESIZE_ENDED,
294 WINDOW_RESTORE_REQUESTED,
295 NUM_EVENT_TYPES
298 enum {
299 QUIT_REASON_NONE,
300 QUIT_REASON_LOGOUT,
301 QUIT_REASON_RESTART,
302 QUIT_REASON_SHUTDOWN,
305 typedef uint64_t macdrv_event_mask;
307 typedef struct macdrv_event {
308 int refs;
309 int deliver;
310 int type;
311 macdrv_window window;
312 union {
313 struct {
314 int reason;
315 } app_quit_requested;
316 struct {
317 int activating;
318 } displays_changed;
319 struct {
320 unsigned int vkey;
321 unsigned int mod_flags;
322 unsigned int keycode;
323 unsigned long time_ms;
324 } hotkey_press;
325 struct {
326 void *data;
327 CFStringRef text; /* new text or NULL if just completing existing text */
328 unsigned int cursor_pos;
329 unsigned int complete; /* is completing text? */
330 } im_set_text;
331 struct {
332 CGKeyCode keycode;
333 CGEventFlags modifiers;
334 unsigned long time_ms;
335 } key;
336 struct {
337 CFDataRef uchr;
338 CGEventSourceKeyboardType keyboard_type;
339 int iso_keyboard;
340 TISInputSourceRef input_source;
341 } keyboard_changed;
342 struct {
343 int button;
344 int pressed;
345 int x;
346 int y;
347 unsigned long time_ms;
348 } mouse_button;
349 struct {
350 int x;
351 int y;
352 int drag;
353 unsigned long time_ms;
354 } mouse_moved;
355 struct {
356 int x_scroll;
357 int y_scroll;
358 int x;
359 int y;
360 unsigned long time_ms;
361 } mouse_scroll;
362 struct {
363 struct macdrv_query *query;
364 } query_event;
365 struct {
366 int handled;
367 int *done;
368 } sent_text_input;
369 struct {
370 macdrv_status_item item;
371 int button;
372 int down;
373 int count;
374 int x;
375 int y;
376 } status_item_mouse_button;
377 struct {
378 macdrv_status_item item;
379 int x;
380 int y;
381 } status_item_mouse_move;
382 struct {
383 int no_activate;
384 } window_drag_begin;
385 struct {
386 CGRect frame;
387 int fullscreen;
388 int in_resize;
389 } window_frame_changed;
390 struct {
391 unsigned long serial;
392 void *tried_windows;
393 } window_got_focus;
394 struct {
395 int keep_frame;
396 CGRect frame;
397 } window_restore_requested;
399 } macdrv_event;
401 enum {
402 QUERY_DRAG_DROP,
403 QUERY_DRAG_EXITED,
404 QUERY_DRAG_OPERATION,
405 QUERY_IME_CHAR_RECT,
406 QUERY_PASTEBOARD_DATA,
407 QUERY_RESIZE_SIZE,
408 QUERY_RESIZE_START,
409 QUERY_MIN_MAX_INFO,
410 NUM_QUERY_TYPES
413 typedef struct macdrv_query {
414 int refs;
415 int type;
416 macdrv_window window;
417 int status;
418 int done;
419 union {
420 struct {
421 int x;
422 int y;
423 uint32_t op;
424 CFTypeRef pasteboard;
425 } drag_drop;
426 struct {
427 int x;
428 int y;
429 uint32_t offered_ops;
430 uint32_t accepted_op;
431 CFTypeRef pasteboard;
432 } drag_operation;
433 struct {
434 void *data;
435 CFRange range;
436 CGRect rect;
437 } ime_char_rect;
438 struct {
439 CFStringRef type;
440 } pasteboard_data;
441 struct {
442 CGRect rect;
443 unsigned int from_left : 1;
444 unsigned int from_top : 1;
445 } resize_size;
447 } macdrv_query;
449 static inline macdrv_event_mask event_mask_for_type(int type)
451 return ((macdrv_event_mask)1 << type);
454 typedef void (*macdrv_event_handler)(const macdrv_event *event);
456 extern macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler) DECLSPEC_HIDDEN;
457 extern void macdrv_destroy_event_queue(macdrv_event_queue queue) DECLSPEC_HIDDEN;
458 extern int macdrv_get_event_queue_fd(macdrv_event_queue queue) DECLSPEC_HIDDEN;
460 extern int macdrv_copy_event_from_queue(macdrv_event_queue queue,
461 macdrv_event_mask mask, macdrv_event **event) DECLSPEC_HIDDEN;
462 extern void macdrv_release_event(macdrv_event *event) DECLSPEC_HIDDEN;
464 extern macdrv_query* macdrv_create_query(void) DECLSPEC_HIDDEN;
465 extern macdrv_query* macdrv_retain_query(macdrv_query *query) DECLSPEC_HIDDEN;
466 extern void macdrv_release_query(macdrv_query *query) DECLSPEC_HIDDEN;
467 extern void macdrv_set_query_done(macdrv_query *query) DECLSPEC_HIDDEN;
468 extern int macdrv_register_hot_key(macdrv_event_queue q, unsigned int vkey, unsigned int mod_flags,
469 unsigned int keycode, unsigned int modifiers) DECLSPEC_HIDDEN;
470 extern void macdrv_unregister_hot_key(macdrv_event_queue q, unsigned int vkey, unsigned int mod_flags) DECLSPEC_HIDDEN;
473 /* window */
474 struct macdrv_window_features {
475 unsigned int title_bar:1;
476 unsigned int close_button:1;
477 unsigned int minimize_button:1;
478 unsigned int resizable:1;
479 unsigned int maximize_button:1;
480 unsigned int utility:1;
481 unsigned int shadow:1;
484 struct macdrv_window_state {
485 unsigned int disabled:1;
486 unsigned int no_activate:1;
487 unsigned int floating:1;
488 unsigned int excluded_by_expose:1;
489 unsigned int excluded_by_cycle:1;
490 unsigned int minimized:1;
491 unsigned int minimized_valid:1;
492 unsigned int maximized:1;
495 extern macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf,
496 CGRect frame, void* hwnd, macdrv_event_queue queue) DECLSPEC_HIDDEN;
497 extern void macdrv_destroy_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
498 extern void* macdrv_get_window_hwnd(macdrv_window w) DECLSPEC_HIDDEN;
499 extern void macdrv_set_cocoa_window_features(macdrv_window w,
500 const struct macdrv_window_features* wf) DECLSPEC_HIDDEN;
501 extern void macdrv_set_cocoa_window_state(macdrv_window w,
502 const struct macdrv_window_state* state) DECLSPEC_HIDDEN;
503 extern void macdrv_set_cocoa_window_title(macdrv_window w, const UniChar* title,
504 size_t length) DECLSPEC_HIDDEN;
505 extern void macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
506 macdrv_window next, int activate) DECLSPEC_HIDDEN;
507 extern void macdrv_hide_cocoa_window(macdrv_window w) DECLSPEC_HIDDEN;
508 extern void macdrv_set_cocoa_window_frame(macdrv_window w, const CGRect* new_frame) DECLSPEC_HIDDEN;
509 extern void macdrv_get_cocoa_window_frame(macdrv_window w, CGRect* out_frame) DECLSPEC_HIDDEN;
510 extern void macdrv_set_cocoa_parent_window(macdrv_window w, macdrv_window parent) DECLSPEC_HIDDEN;
511 extern void macdrv_set_window_surface(macdrv_window w, void *surface, pthread_mutex_t *mutex) DECLSPEC_HIDDEN;
512 extern CGImageRef create_surface_image(void *window_surface, CGRect *rect, int copy_data) DECLSPEC_HIDDEN;
513 extern int get_surface_blit_rects(void *window_surface, const CGRect **rects, int *count) DECLSPEC_HIDDEN;
514 extern void macdrv_window_needs_display(macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
515 extern void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count) DECLSPEC_HIDDEN;
516 extern void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha) DECLSPEC_HIDDEN;
517 extern void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGreen,
518 CGFloat keyBlue) DECLSPEC_HIDDEN;
519 extern void macdrv_clear_window_color_key(macdrv_window w) DECLSPEC_HIDDEN;
520 extern void macdrv_window_use_per_pixel_alpha(macdrv_window w, int use_per_pixel_alpha) DECLSPEC_HIDDEN;
521 extern void macdrv_give_cocoa_window_focus(macdrv_window w, int activate) DECLSPEC_HIDDEN;
522 extern void macdrv_set_window_min_max_sizes(macdrv_window w, CGSize min_size, CGSize max_size) DECLSPEC_HIDDEN;
523 extern macdrv_view macdrv_create_view(CGRect rect) DECLSPEC_HIDDEN;
524 extern void macdrv_dispose_view(macdrv_view v) DECLSPEC_HIDDEN;
525 extern void macdrv_set_view_frame(macdrv_view v, CGRect rect) DECLSPEC_HIDDEN;
526 extern void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, macdrv_view p, macdrv_view n) DECLSPEC_HIDDEN;
527 extern void macdrv_set_view_hidden(macdrv_view v, int hidden) DECLSPEC_HIDDEN;
528 extern void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
529 extern void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
530 extern int macdrv_get_view_backing_size(macdrv_view v, int backing_size[2]) DECLSPEC_HIDDEN;
531 extern void macdrv_set_view_backing_size(macdrv_view v, const int backing_size[2]) DECLSPEC_HIDDEN;
532 extern uint32_t macdrv_window_background_color(void) DECLSPEC_HIDDEN;
533 extern void macdrv_send_text_input_event(int pressed, unsigned int flags, int repeat, int keyc,
534 void* data, int* done) DECLSPEC_HIDDEN;
537 /* keyboard */
538 extern void macdrv_get_input_source_info(CFDataRef* uchr,CGEventSourceKeyboardType* keyboard_type, int* is_iso,
539 TISInputSourceRef* input_source) DECLSPEC_HIDDEN;
540 extern CFArrayRef macdrv_create_input_source_list(void) DECLSPEC_HIDDEN;
541 extern int macdrv_select_input_source(TISInputSourceRef input_source) DECLSPEC_HIDDEN;
542 extern const CFStringRef macdrv_input_source_input_key DECLSPEC_HIDDEN;
543 extern const CFStringRef macdrv_input_source_type_key DECLSPEC_HIDDEN;
544 extern const CFStringRef macdrv_input_source_lang_key DECLSPEC_HIDDEN;
545 extern int macdrv_layout_list_needs_update DECLSPEC_HIDDEN;
548 /* clipboard */
549 extern CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) DECLSPEC_HIDDEN;
550 extern CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) DECLSPEC_HIDDEN;
551 extern int macdrv_is_pasteboard_owner(macdrv_window w) DECLSPEC_HIDDEN;
552 extern int macdrv_has_pasteboard_changed(void) DECLSPEC_HIDDEN;
553 extern void macdrv_clear_pasteboard(macdrv_window w) DECLSPEC_HIDDEN;
554 extern int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w) DECLSPEC_HIDDEN;
557 /* opengl */
558 extern macdrv_opengl_context macdrv_create_opengl_context(void* cglctx) DECLSPEC_HIDDEN;
559 extern void macdrv_dispose_opengl_context(macdrv_opengl_context c) DECLSPEC_HIDDEN;
560 extern void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect r) DECLSPEC_HIDDEN;
561 extern void macdrv_update_opengl_context(macdrv_opengl_context c) DECLSPEC_HIDDEN;
562 extern void macdrv_flush_opengl_context(macdrv_opengl_context c) DECLSPEC_HIDDEN;
565 /* systray / status item */
566 extern macdrv_status_item macdrv_create_status_item(macdrv_event_queue q) DECLSPEC_HIDDEN;
567 extern void macdrv_destroy_status_item(macdrv_status_item s) DECLSPEC_HIDDEN;
568 extern void macdrv_set_status_item_image(macdrv_status_item s, CGImageRef cgimage) DECLSPEC_HIDDEN;
569 extern void macdrv_set_status_item_tooltip(macdrv_status_item s, CFStringRef cftip) DECLSPEC_HIDDEN;
571 #endif /* __WINE_MACDRV_COCOA_H */