jscript: Rename jsheap_t to heap_pool_t.
[wine] / dlls / winemac.drv / macdrv.h
1 /*
2  * MACDRV windowing driver
3  *
4  * Copyright 1996 Alexandre Julliard
5  * Copyright 1999 Patrik Stridvall
6  * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef __WINE_MACDRV_H
24 #define __WINE_MACDRV_H
25
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
28 #endif
29
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"
36
37
38 static inline CGRect cgrect_from_rect(RECT rect)
39 {
40     if (rect.left >= rect.right || rect.top >= rect.bottom)
41         return CGRectNull;
42     return CGRectMake(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
43 }
44
45 static inline RECT rect_from_cgrect(CGRect cgrect)
46 {
47     static const RECT empty;
48
49     if (!CGRectIsNull(cgrect))
50     {
51         RECT rect = { CGRectGetMinX(cgrect), CGRectGetMinY(cgrect),
52                       CGRectGetMaxX(cgrect), CGRectGetMaxY(cgrect) };
53         return rect;
54     }
55
56     return empty;
57 }
58
59 static inline const char *wine_dbgstr_cgrect(CGRect cgrect)
60 {
61     return wine_dbg_sprintf("(%g,%g)-(%g,%g)", CGRectGetMinX(cgrect), CGRectGetMinY(cgrect),
62                             CGRectGetMaxX(cgrect), CGRectGetMaxY(cgrect));
63 }
64
65
66 /**************************************************************************
67  * Mac GDI driver
68  */
69
70 extern CGRect macdrv_get_desktop_rect(void) DECLSPEC_HIDDEN;
71
72
73 /**************************************************************************
74  * Mac USER driver
75  */
76
77 /* Mac driver private messages, must be in the range 0x80001000..0x80001fff */
78 enum macdrv_window_messages
79 {
80     WM_MACDRV_SET_WIN_REGION = 0x80001000,
81 };
82
83 struct macdrv_thread_data
84 {
85     macdrv_event_queue          queue;
86     const macdrv_event         *current_event;
87     CFDataRef                   keyboard_layout_uchr;
88     CGEventSourceKeyboardType   keyboard_type;
89     int                         iso_keyboard;
90     CGEventFlags                last_modifiers;
91     UInt32                      dead_key_state;
92     HKL                         active_keyboard_layout;
93     WORD                        keyc2vkey[128];
94     WORD                        keyc2scan[128];
95 };
96
97 extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
98
99 extern struct macdrv_thread_data *macdrv_init_thread_data(void) DECLSPEC_HIDDEN;
100
101 static inline struct macdrv_thread_data *macdrv_thread_data(void)
102 {
103     return TlsGetValue(thread_data_tls_index);
104 }
105
106
107 /* macdrv private window data */
108 struct macdrv_win_data
109 {
110     HWND                hwnd;                   /* hwnd that this private data belongs to */
111     macdrv_window       cocoa_window;
112     RECT                window_rect;            /* USER window rectangle relative to parent */
113     RECT                whole_rect;             /* Mac window rectangle for the whole window relative to parent */
114     RECT                client_rect;            /* client area relative to parent */
115     COLORREF            color_key;              /* color key for layered window; CLR_INVALID is not color keyed */
116     BOOL                on_screen : 1;          /* is window ordered in? (minimized or not) */
117     BOOL                shaped : 1;             /* is window using a custom region shape? */
118     BOOL                layered : 1;            /* is window layered and with valid attributes? */
119     BOOL                per_pixel_alpha : 1;    /* is window using per-pixel alpha? */
120     BOOL                minimized : 1;          /* is window minimized? */
121     struct window_surface *surface;
122 };
123
124 extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp) DECLSPEC_HIDDEN;
125 extern struct window_surface *create_surface(macdrv_window window, const RECT *rect, BOOL use_alpha) DECLSPEC_HIDDEN;
126 extern void set_window_surface(macdrv_window window, struct window_surface *window_surface) DECLSPEC_HIDDEN;
127 extern void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha) DECLSPEC_HIDDEN;
128
129 extern void macdrv_window_close_requested(HWND hwnd) DECLSPEC_HIDDEN;
130 extern void macdrv_window_frame_changed(HWND hwnd, CGRect frame) DECLSPEC_HIDDEN;
131 extern void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
132 extern void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
133 extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN;
134 extern void macdrv_window_did_minimize(HWND hwnd) DECLSPEC_HIDDEN;
135 extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN;
136
137 extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
138 extern void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
139 extern void macdrv_mouse_scroll(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
140
141 extern void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) DECLSPEC_HIDDEN;
142 extern void macdrv_keyboard_changed(const macdrv_event *event) DECLSPEC_HIDDEN;
143 extern void macdrv_key_event(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
144
145 #endif  /* __WINE_MACDRV_H */