winemac: Track drawn surface region to reduce black flicker for new or resized windows.
[wine/multimedia.git] / dlls / winemac.drv / macdrv.h
blobf8c45ab21a5982893f39f71ffa9e261a7d819306
1 /*
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
28 #endif
30 #include "macdrv_cocoa.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "wine/debug.h"
35 #include "wine/gdi_driver.h"
38 extern const char* debugstr_cf(CFTypeRef t) DECLSPEC_HIDDEN;
40 static inline CGRect cgrect_from_rect(RECT rect)
42 if (rect.left >= rect.right || rect.top >= rect.bottom)
43 return CGRectNull;
44 return CGRectMake(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
47 static inline RECT rect_from_cgrect(CGRect cgrect)
49 static const RECT empty;
51 if (!CGRectIsNull(cgrect))
53 RECT rect = { CGRectGetMinX(cgrect), CGRectGetMinY(cgrect),
54 CGRectGetMaxX(cgrect), CGRectGetMaxY(cgrect) };
55 return rect;
58 return empty;
61 static inline const char *wine_dbgstr_cgrect(CGRect cgrect)
63 return wine_dbg_sprintf("(%g,%g)-(%g,%g)", CGRectGetMinX(cgrect), CGRectGetMinY(cgrect),
64 CGRectGetMaxX(cgrect), CGRectGetMaxY(cgrect));
68 /**************************************************************************
69 * Mac GDI driver
72 extern CGRect macdrv_get_desktop_rect(void) DECLSPEC_HIDDEN;
73 extern void macdrv_reset_device_metrics(void) DECLSPEC_HIDDEN;
74 extern BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) DECLSPEC_HIDDEN;
75 extern BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) DECLSPEC_HIDDEN;
78 /**************************************************************************
79 * Mac USER driver
82 /* Mac driver private messages, must be in the range 0x80001000..0x80001fff */
83 enum macdrv_window_messages
85 WM_MACDRV_SET_WIN_REGION = 0x80001000,
86 WM_MACDRV_UPDATE_DESKTOP_RECT,
87 WM_MACDRV_RESET_DEVICE_METRICS,
88 WM_MACDRV_DISPLAYCHANGE,
91 struct macdrv_thread_data
93 macdrv_event_queue queue;
94 const macdrv_event *current_event;
95 CFDataRef keyboard_layout_uchr;
96 CGEventSourceKeyboardType keyboard_type;
97 int iso_keyboard;
98 CGEventFlags last_modifiers;
99 UInt32 dead_key_state;
100 HKL active_keyboard_layout;
101 WORD keyc2vkey[128];
102 WORD keyc2scan[128];
105 extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
107 extern struct macdrv_thread_data *macdrv_init_thread_data(void) DECLSPEC_HIDDEN;
109 static inline struct macdrv_thread_data *macdrv_thread_data(void)
111 return TlsGetValue(thread_data_tls_index);
115 /* macdrv private window data */
116 struct macdrv_win_data
118 HWND hwnd; /* hwnd that this private data belongs to */
119 macdrv_window cocoa_window;
120 RECT window_rect; /* USER window rectangle relative to parent */
121 RECT whole_rect; /* Mac window rectangle for the whole window relative to parent */
122 RECT client_rect; /* client area relative to parent */
123 int pixel_format; /* pixel format for GL */
124 macdrv_view gl_view; /* view for GL */
125 RECT gl_rect; /* GL view rectangle relative to whole_rect */
126 COLORREF color_key; /* color key for layered window; CLR_INVALID is not color keyed */
127 BOOL on_screen : 1; /* is window ordered in? (minimized or not) */
128 BOOL shaped : 1; /* is window using a custom region shape? */
129 BOOL layered : 1; /* is window layered and with valid attributes? */
130 BOOL ulw_layered : 1; /* has UpdateLayeredWindow() been called for window? */
131 BOOL per_pixel_alpha : 1; /* is window using per-pixel alpha? */
132 BOOL minimized : 1; /* is window minimized? */
133 struct window_surface *surface;
136 extern struct macdrv_win_data *get_win_data(HWND hwnd) DECLSPEC_HIDDEN;
137 extern void release_win_data(struct macdrv_win_data *data) DECLSPEC_HIDDEN;
138 extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen) DECLSPEC_HIDDEN;
139 extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp) DECLSPEC_HIDDEN;
140 extern struct window_surface *create_surface(macdrv_window window, const RECT *rect,
141 struct window_surface *old_surface, BOOL use_alpha) DECLSPEC_HIDDEN;
142 extern void set_window_surface(macdrv_window window, struct window_surface *window_surface) DECLSPEC_HIDDEN;
143 extern void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha) DECLSPEC_HIDDEN;
145 extern void macdrv_handle_event(macdrv_event *event) DECLSPEC_HIDDEN;
147 extern void macdrv_window_close_requested(HWND hwnd) DECLSPEC_HIDDEN;
148 extern void macdrv_window_frame_changed(HWND hwnd, CGRect frame) DECLSPEC_HIDDEN;
149 extern void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
150 extern void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
151 extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN;
152 extern void macdrv_window_did_minimize(HWND hwnd) DECLSPEC_HIDDEN;
153 extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN;
155 extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
156 extern void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
157 extern void macdrv_mouse_scroll(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
159 extern void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) DECLSPEC_HIDDEN;
160 extern void macdrv_keyboard_changed(const macdrv_event *event) DECLSPEC_HIDDEN;
161 extern void macdrv_key_event(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
163 extern void macdrv_displays_changed(const macdrv_event *event) DECLSPEC_HIDDEN;
165 extern void macdrv_clipboard_process_attach(void) DECLSPEC_HIDDEN;
166 extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) DECLSPEC_HIDDEN;
167 extern const char *debugstr_format(UINT id) DECLSPEC_HIDDEN;
168 extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN;
169 extern BOOL CDECL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN;
170 extern CFArrayRef macdrv_copy_pasteboard_formats(CFTypeRef pasteboard) DECLSPEC_HIDDEN;
172 extern BOOL query_drag_operation(macdrv_query* query) DECLSPEC_HIDDEN;
173 extern BOOL query_drag_exited(macdrv_query* query) DECLSPEC_HIDDEN;
174 extern BOOL query_drag_drop(macdrv_query* query) DECLSPEC_HIDDEN;
176 extern struct opengl_funcs *macdrv_wine_get_wgl_driver(PHYSDEV dev, UINT version) DECLSPEC_HIDDEN;
177 extern void sync_gl_view(struct macdrv_win_data *data) DECLSPEC_HIDDEN;
178 extern void set_gl_view_parent(HWND hwnd, HWND parent) DECLSPEC_HIDDEN;
180 extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP hbmColor,
181 unsigned char *color_bits, int color_size, HBITMAP hbmMask,
182 unsigned char *mask_bits, int mask_size, int width,
183 int height, int istep) DECLSPEC_HIDDEN;
184 extern CGImageRef create_cgimage_from_icon(HANDLE icon, int width, int height) DECLSPEC_HIDDEN;
185 extern CFArrayRef create_app_icon_images(void) DECLSPEC_HIDDEN;
187 extern void macdrv_status_item_clicked(const macdrv_event *event) DECLSPEC_HIDDEN;
189 #endif /* __WINE_MACDRV_H */