2 * MACDRV windowing driver
4 * Copyright 1996 Alexandre Julliard
5 * Copyright 1999 Patrik Stridvall
6 * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifndef __WINE_MACDRV_H
24 #define __WINE_MACDRV_H
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
30 #include "macdrv_cocoa.h"
34 #include "wine/debug.h"
35 #include "wine/gdi_driver.h"
38 extern BOOL skip_single_buffer_flushes DECLSPEC_HIDDEN
;
39 extern BOOL allow_vsync DECLSPEC_HIDDEN
;
40 extern BOOL allow_set_gamma DECLSPEC_HIDDEN
;
41 extern BOOL allow_software_rendering DECLSPEC_HIDDEN
;
42 extern BOOL disable_window_decorations DECLSPEC_HIDDEN
;
43 extern HMODULE macdrv_module DECLSPEC_HIDDEN
;
46 extern const char* debugstr_cf(CFTypeRef t
) DECLSPEC_HIDDEN
;
48 static inline CGRect
cgrect_from_rect(RECT rect
)
50 if (rect
.left
>= rect
.right
|| rect
.top
>= rect
.bottom
)
51 return CGRectMake(rect
.left
, rect
.top
, 0, 0);
52 return CGRectMake(rect
.left
, rect
.top
, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
55 static inline RECT
rect_from_cgrect(CGRect cgrect
)
57 static const RECT empty
;
59 if (!CGRectIsNull(cgrect
))
61 RECT rect
= { CGRectGetMinX(cgrect
), CGRectGetMinY(cgrect
),
62 CGRectGetMaxX(cgrect
), CGRectGetMaxY(cgrect
) };
69 static inline const char *wine_dbgstr_cgrect(CGRect cgrect
)
71 return wine_dbg_sprintf("(%g,%g)-(%g,%g)", CGRectGetMinX(cgrect
), CGRectGetMinY(cgrect
),
72 CGRectGetMaxX(cgrect
), CGRectGetMaxY(cgrect
));
75 extern const char* debugstr_cf(CFTypeRef t
) DECLSPEC_HIDDEN
;
78 /**************************************************************************
82 extern CGRect
macdrv_get_desktop_rect(void) DECLSPEC_HIDDEN
;
83 extern void macdrv_reset_device_metrics(void) DECLSPEC_HIDDEN
;
84 extern BOOL
macdrv_GetDeviceGammaRamp(PHYSDEV dev
, LPVOID ramp
) DECLSPEC_HIDDEN
;
85 extern BOOL
macdrv_SetDeviceGammaRamp(PHYSDEV dev
, LPVOID ramp
) DECLSPEC_HIDDEN
;
88 /**************************************************************************
92 /* Mac driver private messages, must be in the range 0x80001000..0x80001fff */
93 enum macdrv_window_messages
95 WM_MACDRV_SET_WIN_REGION
= 0x80001000,
96 WM_MACDRV_UPDATE_DESKTOP_RECT
,
97 WM_MACDRV_RESET_DEVICE_METRICS
,
98 WM_MACDRV_DISPLAYCHANGE
,
99 WM_MACDRV_ACTIVATE_ON_FOLLOWING_FOCUS
,
102 struct macdrv_thread_data
104 macdrv_event_queue queue
;
105 const macdrv_event
*current_event
;
106 macdrv_window capture_window
;
107 CFDataRef keyboard_layout_uchr
;
108 CGEventSourceKeyboardType keyboard_type
;
110 CGEventFlags last_modifiers
;
111 UInt32 dead_key_state
;
112 HKL active_keyboard_layout
;
117 extern DWORD thread_data_tls_index DECLSPEC_HIDDEN
;
119 extern struct macdrv_thread_data
*macdrv_init_thread_data(void) DECLSPEC_HIDDEN
;
121 static inline struct macdrv_thread_data
*macdrv_thread_data(void)
123 return TlsGetValue(thread_data_tls_index
);
127 /* macdrv private window data */
128 struct macdrv_win_data
130 HWND hwnd
; /* hwnd that this private data belongs to */
131 macdrv_window cocoa_window
;
132 macdrv_view cocoa_view
;
133 macdrv_view client_cocoa_view
;
134 RECT window_rect
; /* USER window rectangle relative to parent */
135 RECT whole_rect
; /* Mac window rectangle for the whole window relative to parent */
136 RECT client_rect
; /* client area relative to parent */
137 int pixel_format
; /* pixel format for GL */
138 COLORREF color_key
; /* color key for layered window; CLR_INVALID is not color keyed */
139 unsigned int on_screen
: 1; /* is window ordered in? (minimized or not) */
140 unsigned int shaped
: 1; /* is window using a custom region shape? */
141 unsigned int layered
: 1; /* is window layered and with valid attributes? */
142 unsigned int ulw_layered
: 1; /* has UpdateLayeredWindow() been called for window? */
143 unsigned int per_pixel_alpha
: 1; /* is window using per-pixel alpha? */
144 unsigned int minimized
: 1; /* is window minimized? */
145 unsigned int being_dragged
: 1; /* is window being dragged under Cocoa's control? */
146 unsigned int swap_interval
: 1; /* GL swap interval for window */
147 struct window_surface
*surface
;
148 struct window_surface
*unminimized_surface
;
151 extern struct macdrv_win_data
*get_win_data(HWND hwnd
) DECLSPEC_HIDDEN
;
152 extern void release_win_data(struct macdrv_win_data
*data
) DECLSPEC_HIDDEN
;
153 extern macdrv_window
macdrv_get_cocoa_window(HWND hwnd
, BOOL require_on_screen
) DECLSPEC_HIDDEN
;
154 extern RGNDATA
*get_region_data(HRGN hrgn
, HDC hdc_lptodp
) DECLSPEC_HIDDEN
;
155 extern void activate_on_following_focus(void) DECLSPEC_HIDDEN
;
156 extern struct window_surface
*create_surface(macdrv_window window
, const RECT
*rect
,
157 struct window_surface
*old_surface
, BOOL use_alpha
) DECLSPEC_HIDDEN
;
158 extern void set_window_surface(macdrv_window window
, struct window_surface
*window_surface
) DECLSPEC_HIDDEN
;
159 extern void set_surface_use_alpha(struct window_surface
*window_surface
, BOOL use_alpha
) DECLSPEC_HIDDEN
;
160 extern void surface_clip_to_visible_rect(struct window_surface
*window_surface
, const RECT
*visible_rect
) DECLSPEC_HIDDEN
;
162 extern void macdrv_handle_event(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
164 extern void macdrv_window_close_requested(HWND hwnd
) DECLSPEC_HIDDEN
;
165 extern void macdrv_window_frame_changed(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
166 extern void macdrv_window_got_focus(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
167 extern void macdrv_window_lost_focus(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
168 extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN
;
169 extern void macdrv_app_quit_requested(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
170 extern void macdrv_window_maximize_requested(HWND hwnd
) DECLSPEC_HIDDEN
;
171 extern void macdrv_window_minimize_requested(HWND hwnd
) DECLSPEC_HIDDEN
;
172 extern void macdrv_window_did_unminimize(HWND hwnd
) DECLSPEC_HIDDEN
;
173 extern void macdrv_window_brought_forward(HWND hwnd
) DECLSPEC_HIDDEN
;
174 extern void macdrv_window_resize_ended(HWND hwnd
) DECLSPEC_HIDDEN
;
175 extern void macdrv_window_restore_requested(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
176 extern void macdrv_window_drag_begin(HWND hwnd
) DECLSPEC_HIDDEN
;
177 extern void macdrv_window_drag_end(HWND hwnd
) DECLSPEC_HIDDEN
;
178 extern void macdrv_reassert_window_position(HWND hwnd
) DECLSPEC_HIDDEN
;
179 extern BOOL
query_resize_size(HWND hwnd
, macdrv_query
*query
) DECLSPEC_HIDDEN
;
180 extern BOOL
query_resize_start(HWND hwnd
) DECLSPEC_HIDDEN
;
181 extern BOOL
query_min_max_info(HWND hwnd
) DECLSPEC_HIDDEN
;
183 extern void macdrv_mouse_button(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
184 extern void macdrv_mouse_moved(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
185 extern void macdrv_mouse_scroll(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
186 extern void macdrv_release_capture(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
187 extern void CDECL
macdrv_SetCapture(HWND hwnd
, UINT flags
) DECLSPEC_HIDDEN
;
189 extern void macdrv_compute_keyboard_layout(struct macdrv_thread_data
*thread_data
) DECLSPEC_HIDDEN
;
190 extern void macdrv_keyboard_changed(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
191 extern void macdrv_key_event(HWND hwnd
, const macdrv_event
*event
) DECLSPEC_HIDDEN
;
192 extern void macdrv_hotkey_press(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
193 extern HKL
macdrv_get_hkl_from_source(TISInputSourceRef input_source
) DECLSPEC_HIDDEN
;
195 extern void macdrv_displays_changed(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
197 extern void macdrv_clipboard_process_attach(void) DECLSPEC_HIDDEN
;
198 extern BOOL
query_pasteboard_data(HWND hwnd
, CFStringRef type
) DECLSPEC_HIDDEN
;
199 extern const char *debugstr_format(UINT id
) DECLSPEC_HIDDEN
;
200 extern HANDLE
macdrv_get_pasteboard_data(CFTypeRef pasteboard
, UINT desired_format
) DECLSPEC_HIDDEN
;
201 extern BOOL
macdrv_pasteboard_has_format(CFTypeRef pasteboard
, UINT desired_format
) DECLSPEC_HIDDEN
;
202 extern CFArrayRef
macdrv_copy_pasteboard_formats(CFTypeRef pasteboard
) DECLSPEC_HIDDEN
;
204 extern BOOL
query_drag_operation(macdrv_query
* query
) DECLSPEC_HIDDEN
;
205 extern BOOL
query_drag_exited(macdrv_query
* query
) DECLSPEC_HIDDEN
;
206 extern BOOL
query_drag_drop(macdrv_query
* query
) DECLSPEC_HIDDEN
;
208 extern struct opengl_funcs
*macdrv_wine_get_wgl_driver(PHYSDEV dev
, UINT version
) DECLSPEC_HIDDEN
;
209 extern void sync_gl_view(struct macdrv_win_data
* data
, const RECT
* old_whole_rect
, const RECT
* old_client_rect
) DECLSPEC_HIDDEN
;
211 extern CGImageRef
create_cgimage_from_icon_bitmaps(HDC hdc
, HANDLE icon
, HBITMAP hbmColor
,
212 unsigned char *color_bits
, int color_size
, HBITMAP hbmMask
,
213 unsigned char *mask_bits
, int mask_size
, int width
,
214 int height
, int istep
) DECLSPEC_HIDDEN
;
215 extern CGImageRef
create_cgimage_from_icon(HANDLE icon
, int width
, int height
) DECLSPEC_HIDDEN
;
216 extern CFArrayRef
create_app_icon_images(void) DECLSPEC_HIDDEN
;
218 extern void macdrv_status_item_mouse_button(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
219 extern void macdrv_status_item_mouse_move(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
221 extern void check_retina_status(void) DECLSPEC_HIDDEN
;
223 /**************************************************************************
227 extern void macdrv_process_text_input(UINT vkey
, UINT scan
, UINT repeat
, const BYTE
*key_state
,
228 void *himc
, int* done
) DECLSPEC_HIDDEN
;
230 extern void macdrv_im_set_text(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
231 extern void macdrv_sent_text_input(const macdrv_event
*event
) DECLSPEC_HIDDEN
;
232 extern BOOL
query_ime_char_rect(macdrv_query
* query
) DECLSPEC_HIDDEN
;
234 #endif /* __WINE_MACDRV_H */