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
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")))
97 # define DECLSPEC_HIDDEN
102 /* Must match the values of Cocoa's NSDragOperation enum. */
111 DRAG_OP_EVERY
= UINT32_MAX
115 TOPMOST_FLOAT_INACTIVE_NONE
,
116 TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN
,
117 TOPMOST_FLOAT_INACTIVE_ALL
,
121 GL_SURFACE_IN_FRONT_OPAQUE
,
122 GL_SURFACE_IN_FRONT_TRANSPARENT
,
127 MACDRV_HOTKEY_SUCCESS
,
128 MACDRV_HOTKEY_ALREADY_REGISTERED
,
129 MACDRV_HOTKEY_FAILURE
,
132 typedef struct __TISInputSource
*TISInputSourceRef
;
134 typedef struct macdrv_opaque_window
* macdrv_window
;
135 typedef struct macdrv_opaque_event_queue
* macdrv_event_queue
;
136 typedef struct macdrv_opaque_view
* macdrv_view
;
137 typedef struct macdrv_opaque_opengl_context
* macdrv_opengl_context
;
138 typedef struct macdrv_opaque_status_item
* macdrv_status_item
;
142 struct macdrv_display
{
143 CGDirectDisplayID displayID
;
150 extern int macdrv_err_on
;
151 extern int topmost_float_inactive DECLSPEC_HIDDEN
;
152 extern int capture_displays_for_fullscreen DECLSPEC_HIDDEN
;
153 extern int left_option_is_alt DECLSPEC_HIDDEN
;
154 extern int right_option_is_alt DECLSPEC_HIDDEN
;
155 extern int allow_immovable_windows DECLSPEC_HIDDEN
;
156 extern int cursor_clipping_locks_windows DECLSPEC_HIDDEN
;
157 extern int use_precise_scrolling DECLSPEC_HIDDEN
;
158 extern int gl_surface_mode DECLSPEC_HIDDEN
;
160 extern int macdrv_start_cocoa_app(unsigned long long tickcount
) DECLSPEC_HIDDEN
;
161 extern void macdrv_window_rejected_focus(const struct macdrv_event
*event
) DECLSPEC_HIDDEN
;
162 extern void macdrv_beep(void) DECLSPEC_HIDDEN
;
163 extern void macdrv_set_application_icon(CFArrayRef images
) DECLSPEC_HIDDEN
;
164 extern void macdrv_quit_reply(int reply
) DECLSPEC_HIDDEN
;
165 extern int macdrv_using_input_method(void) DECLSPEC_HIDDEN
;
166 extern void macdrv_set_mouse_capture_window(macdrv_window window
) DECLSPEC_HIDDEN
;
170 extern void macdrv_set_cursor(CFStringRef name
, CFArrayRef frames
) DECLSPEC_HIDDEN
;
171 extern int macdrv_get_cursor_position(CGPoint
*pos
) DECLSPEC_HIDDEN
;
172 extern int macdrv_set_cursor_position(CGPoint pos
) DECLSPEC_HIDDEN
;
173 extern int macdrv_clip_cursor(CGRect rect
) DECLSPEC_HIDDEN
;
177 extern int macdrv_get_displays(struct macdrv_display
** displays
, int* count
) DECLSPEC_HIDDEN
;
178 extern void macdrv_free_displays(struct macdrv_display
* displays
) DECLSPEC_HIDDEN
;
179 extern int macdrv_set_display_mode(const struct macdrv_display
* display
,
180 CGDisplayModeRef display_mode
) DECLSPEC_HIDDEN
;
195 MOUSE_MOVED_ABSOLUTE
,
199 STATUS_ITEM_MOUSE_BUTTON
,
200 STATUS_ITEM_MOUSE_MOVE
,
201 WINDOW_BROUGHT_FORWARD
,
202 WINDOW_CLOSE_REQUESTED
,
203 WINDOW_DID_UNMINIMIZE
,
206 WINDOW_FRAME_CHANGED
,
209 WINDOW_MAXIMIZE_REQUESTED
,
210 WINDOW_MINIMIZE_REQUESTED
,
212 WINDOW_RESTORE_REQUESTED
,
220 QUIT_REASON_SHUTDOWN
,
223 typedef uint32_t macdrv_event_mask
;
225 typedef struct macdrv_event
{
229 macdrv_window window
;
233 } app_quit_requested
;
239 unsigned int mod_flags
;
240 unsigned int keycode
;
241 unsigned long time_ms
;
245 CFStringRef text
; /* new text or NULL if just completing existing text */
246 unsigned int cursor_pos
;
247 unsigned int complete
; /* is completing text? */
251 CGEventFlags modifiers
;
252 unsigned long time_ms
;
256 CGEventSourceKeyboardType keyboard_type
;
258 TISInputSourceRef input_source
;
265 unsigned long time_ms
;
271 unsigned long time_ms
;
278 unsigned long time_ms
;
281 struct macdrv_query
*query
;
284 macdrv_status_item item
;
288 } status_item_mouse_button
;
290 macdrv_status_item item
;
291 } status_item_mouse_move
;
296 } window_frame_changed
;
298 unsigned long serial
;
304 } window_restore_requested
;
311 QUERY_DRAG_OPERATION
,
313 QUERY_PASTEBOARD_DATA
,
320 typedef struct macdrv_query
{
323 macdrv_window window
;
331 CFTypeRef pasteboard
;
336 uint32_t offered_ops
;
337 uint32_t accepted_op
;
338 CFTypeRef pasteboard
;
350 unsigned int from_left
: 1;
351 unsigned int from_top
: 1;
356 static inline macdrv_event_mask
event_mask_for_type(int type
)
358 return ((macdrv_event_mask
)1 << type
);
361 typedef void (*macdrv_event_handler
)(const macdrv_event
*event
);
363 extern macdrv_event_queue
macdrv_create_event_queue(macdrv_event_handler handler
) DECLSPEC_HIDDEN
;
364 extern void macdrv_destroy_event_queue(macdrv_event_queue queue
) DECLSPEC_HIDDEN
;
365 extern int macdrv_get_event_queue_fd(macdrv_event_queue queue
) DECLSPEC_HIDDEN
;
367 extern int macdrv_copy_event_from_queue(macdrv_event_queue queue
,
368 macdrv_event_mask mask
, macdrv_event
**event
) DECLSPEC_HIDDEN
;
369 extern void macdrv_release_event(macdrv_event
*event
) DECLSPEC_HIDDEN
;
371 extern macdrv_query
* macdrv_create_query(void) DECLSPEC_HIDDEN
;
372 extern macdrv_query
* macdrv_retain_query(macdrv_query
*query
) DECLSPEC_HIDDEN
;
373 extern void macdrv_release_query(macdrv_query
*query
) DECLSPEC_HIDDEN
;
374 extern void macdrv_set_query_done(macdrv_query
*query
) DECLSPEC_HIDDEN
;
375 extern int macdrv_register_hot_key(macdrv_event_queue q
, unsigned int vkey
, unsigned int mod_flags
,
376 unsigned int keycode
, unsigned int modifiers
) DECLSPEC_HIDDEN
;
377 extern void macdrv_unregister_hot_key(macdrv_event_queue q
, unsigned int vkey
, unsigned int mod_flags
) DECLSPEC_HIDDEN
;
381 struct macdrv_window_features
{
382 unsigned int title_bar
:1;
383 unsigned int close_button
:1;
384 unsigned int minimize_button
:1;
385 unsigned int resizable
:1;
386 unsigned int maximize_button
:1;
387 unsigned int utility
:1;
388 unsigned int shadow
:1;
391 struct macdrv_window_state
{
392 unsigned int disabled
:1;
393 unsigned int no_activate
:1;
394 unsigned int floating
:1;
395 unsigned int excluded_by_expose
:1;
396 unsigned int excluded_by_cycle
:1;
397 unsigned int minimized
:1;
398 unsigned int minimized_valid
:1;
399 unsigned int maximized
:1;
402 extern macdrv_window
macdrv_create_cocoa_window(const struct macdrv_window_features
* wf
,
403 CGRect frame
, void* hwnd
, macdrv_event_queue queue
) DECLSPEC_HIDDEN
;
404 extern void macdrv_destroy_cocoa_window(macdrv_window w
) DECLSPEC_HIDDEN
;
405 extern void* macdrv_get_window_hwnd(macdrv_window w
) DECLSPEC_HIDDEN
;
406 extern void macdrv_set_cocoa_window_features(macdrv_window w
,
407 const struct macdrv_window_features
* wf
) DECLSPEC_HIDDEN
;
408 extern void macdrv_set_cocoa_window_state(macdrv_window w
,
409 const struct macdrv_window_state
* state
) DECLSPEC_HIDDEN
;
410 extern void macdrv_set_cocoa_window_title(macdrv_window w
, const UniChar
* title
,
411 size_t length
) DECLSPEC_HIDDEN
;
412 extern void macdrv_order_cocoa_window(macdrv_window w
, macdrv_window prev
,
413 macdrv_window next
, int activate
) DECLSPEC_HIDDEN
;
414 extern void macdrv_hide_cocoa_window(macdrv_window w
) DECLSPEC_HIDDEN
;
415 extern void macdrv_set_cocoa_window_frame(macdrv_window w
, const CGRect
* new_frame
) DECLSPEC_HIDDEN
;
416 extern void macdrv_get_cocoa_window_frame(macdrv_window w
, CGRect
* out_frame
) DECLSPEC_HIDDEN
;
417 extern void macdrv_set_cocoa_parent_window(macdrv_window w
, macdrv_window parent
) DECLSPEC_HIDDEN
;
418 extern void macdrv_set_window_surface(macdrv_window w
, void *surface
, pthread_mutex_t
*mutex
) DECLSPEC_HIDDEN
;
419 extern CGImageRef
create_surface_image(void *window_surface
, CGRect
*rect
, int copy_data
) DECLSPEC_HIDDEN
;
420 extern int get_surface_blit_rects(void *window_surface
, const CGRect
**rects
, int *count
) DECLSPEC_HIDDEN
;
421 extern void macdrv_window_needs_display(macdrv_window w
, CGRect rect
) DECLSPEC_HIDDEN
;
422 extern void macdrv_set_window_shape(macdrv_window w
, const CGRect
*rects
, int count
) DECLSPEC_HIDDEN
;
423 extern void macdrv_set_window_alpha(macdrv_window w
, CGFloat alpha
) DECLSPEC_HIDDEN
;
424 extern void macdrv_set_window_color_key(macdrv_window w
, CGFloat keyRed
, CGFloat keyGreen
,
425 CGFloat keyBlue
) DECLSPEC_HIDDEN
;
426 extern void macdrv_clear_window_color_key(macdrv_window w
) DECLSPEC_HIDDEN
;
427 extern void macdrv_window_use_per_pixel_alpha(macdrv_window w
, int use_per_pixel_alpha
) DECLSPEC_HIDDEN
;
428 extern void macdrv_give_cocoa_window_focus(macdrv_window w
, int activate
) DECLSPEC_HIDDEN
;
429 extern void macdrv_set_window_min_max_sizes(macdrv_window w
, CGSize min_size
, CGSize max_size
) DECLSPEC_HIDDEN
;
430 extern macdrv_view
macdrv_create_view(macdrv_window w
, CGRect rect
) DECLSPEC_HIDDEN
;
431 extern void macdrv_dispose_view(macdrv_view v
) DECLSPEC_HIDDEN
;
432 extern void macdrv_set_view_window_and_frame(macdrv_view v
, macdrv_window w
, CGRect rect
) DECLSPEC_HIDDEN
;
433 extern void macdrv_add_view_opengl_context(macdrv_view v
, macdrv_opengl_context c
) DECLSPEC_HIDDEN
;
434 extern void macdrv_remove_view_opengl_context(macdrv_view v
, macdrv_opengl_context c
) DECLSPEC_HIDDEN
;
435 extern uint32_t macdrv_window_background_color(void) DECLSPEC_HIDDEN
;
436 extern int macdrv_send_text_input_event(int pressed
, unsigned int flags
, int repeat
, int keyc
,
437 void* data
) DECLSPEC_HIDDEN
;
441 extern void macdrv_get_input_source_info(CFDataRef
* uchr
,CGEventSourceKeyboardType
* keyboard_type
, int* is_iso
,
442 TISInputSourceRef
* input_source
) DECLSPEC_HIDDEN
;
443 extern CFArrayRef
macdrv_create_input_source_list(void) DECLSPEC_HIDDEN
;
444 extern int macdrv_select_input_source(TISInputSourceRef input_source
) DECLSPEC_HIDDEN
;
445 extern const CFStringRef macdrv_input_source_input_key DECLSPEC_HIDDEN
;
446 extern const CFStringRef macdrv_input_source_type_key DECLSPEC_HIDDEN
;
447 extern const CFStringRef macdrv_input_source_lang_key DECLSPEC_HIDDEN
;
448 extern int macdrv_layout_list_needs_update DECLSPEC_HIDDEN
;
452 extern CFArrayRef
macdrv_copy_pasteboard_types(CFTypeRef pasteboard
) DECLSPEC_HIDDEN
;
453 extern CFDataRef
macdrv_copy_pasteboard_data(CFTypeRef pasteboard
, CFStringRef type
) DECLSPEC_HIDDEN
;
454 extern int macdrv_is_pasteboard_owner(void) DECLSPEC_HIDDEN
;
455 extern void macdrv_clear_pasteboard(void) DECLSPEC_HIDDEN
;
456 extern int macdrv_set_pasteboard_data(CFStringRef type
, CFDataRef data
, macdrv_window w
) DECLSPEC_HIDDEN
;
460 extern macdrv_opengl_context
macdrv_create_opengl_context(void* cglctx
) DECLSPEC_HIDDEN
;
461 extern void macdrv_dispose_opengl_context(macdrv_opengl_context c
) DECLSPEC_HIDDEN
;
462 extern void macdrv_make_context_current(macdrv_opengl_context c
, macdrv_view v
) DECLSPEC_HIDDEN
;
463 extern void macdrv_update_opengl_context(macdrv_opengl_context c
) DECLSPEC_HIDDEN
;
464 extern void macdrv_flush_opengl_context(macdrv_opengl_context c
) DECLSPEC_HIDDEN
;
467 /* systray / status item */
468 extern macdrv_status_item
macdrv_create_status_item(macdrv_event_queue q
) DECLSPEC_HIDDEN
;
469 extern void macdrv_destroy_status_item(macdrv_status_item s
) DECLSPEC_HIDDEN
;
470 extern void macdrv_set_status_item_image(macdrv_status_item s
, CGImageRef cgimage
) DECLSPEC_HIDDEN
;
471 extern void macdrv_set_status_item_tooltip(macdrv_status_item s
, CFStringRef cftip
) DECLSPEC_HIDDEN
;
473 #endif /* __WINE_MACDRV_COCOA_H */