wined3d: Pass the pixel shader input signature to shader_arb_generate_vshader.
[wine.git] / dlls / winemac.drv / event.c
blobcb305d64a163468d56d2e0b5f563172f446d824a
1 /*
2 * MACDRV event driver
4 * Copyright 1993 Alexandre Julliard
5 * 1999 Noel Borthwick
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 #include "config.h"
25 #include "macdrv.h"
26 #include "winuser.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(event);
31 /* return the name of an Mac event */
32 static const char *dbgstr_event(int type)
34 static const char * const event_names[] = {
35 "APP_DEACTIVATED",
36 "APP_QUIT_REQUESTED",
37 "DISPLAYS_CHANGED",
38 "IM_SET_CURSOR_POS",
39 "IM_SET_TEXT",
40 "KEY_PRESS",
41 "KEY_RELEASE",
42 "KEYBOARD_CHANGED",
43 "MOUSE_BUTTON",
44 "MOUSE_MOVED",
45 "MOUSE_MOVED_ABSOLUTE",
46 "MOUSE_SCROLL",
47 "QUERY_EVENT",
48 "STATUS_ITEM_CLICKED",
49 "WINDOW_CLOSE_REQUESTED",
50 "WINDOW_DID_MINIMIZE",
51 "WINDOW_DID_UNMINIMIZE",
52 "WINDOW_FRAME_CHANGED",
53 "WINDOW_GOT_FOCUS",
54 "WINDOW_LOST_FOCUS",
57 if (0 <= type && type < NUM_EVENT_TYPES) return event_names[type];
58 return wine_dbg_sprintf("Unknown event %d", type);
62 /***********************************************************************
63 * get_event_mask
65 static macdrv_event_mask get_event_mask(DWORD mask)
67 macdrv_event_mask event_mask = 0;
69 if ((mask & QS_ALLINPUT) == QS_ALLINPUT) return -1;
71 if (mask & QS_KEY)
73 event_mask |= event_mask_for_type(KEY_PRESS);
74 event_mask |= event_mask_for_type(KEY_RELEASE);
75 event_mask |= event_mask_for_type(KEYBOARD_CHANGED);
78 if (mask & QS_MOUSEBUTTON)
80 event_mask |= event_mask_for_type(MOUSE_BUTTON);
81 event_mask |= event_mask_for_type(MOUSE_SCROLL);
84 if (mask & QS_MOUSEMOVE)
86 event_mask |= event_mask_for_type(MOUSE_MOVED);
87 event_mask |= event_mask_for_type(MOUSE_MOVED_ABSOLUTE);
90 if (mask & QS_POSTMESSAGE)
92 event_mask |= event_mask_for_type(APP_DEACTIVATED);
93 event_mask |= event_mask_for_type(APP_QUIT_REQUESTED);
94 event_mask |= event_mask_for_type(DISPLAYS_CHANGED);
95 event_mask |= event_mask_for_type(IM_SET_CURSOR_POS);
96 event_mask |= event_mask_for_type(IM_SET_TEXT);
97 event_mask |= event_mask_for_type(STATUS_ITEM_CLICKED);
98 event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
99 event_mask |= event_mask_for_type(WINDOW_DID_MINIMIZE);
100 event_mask |= event_mask_for_type(WINDOW_DID_UNMINIMIZE);
101 event_mask |= event_mask_for_type(WINDOW_FRAME_CHANGED);
102 event_mask |= event_mask_for_type(WINDOW_GOT_FOCUS);
103 event_mask |= event_mask_for_type(WINDOW_LOST_FOCUS);
106 if (mask & QS_SENDMESSAGE)
108 event_mask |= event_mask_for_type(QUERY_EVENT);
111 return event_mask;
115 /***********************************************************************
116 * macdrv_query_event
118 * Handler for QUERY_EVENT queries.
120 static void macdrv_query_event(HWND hwnd, const macdrv_event *event)
122 BOOL success = FALSE;
123 macdrv_query *query = event->query_event.query;
125 switch (query->type)
127 case QUERY_DRAG_DROP:
128 TRACE("QUERY_DRAG_DROP\n");
129 success = query_drag_drop(query);
130 break;
131 case QUERY_DRAG_EXITED:
132 TRACE("QUERY_DRAG_EXITED\n");
133 success = query_drag_exited(query);
134 break;
135 case QUERY_DRAG_OPERATION:
136 TRACE("QUERY_DRAG_OPERATION\n");
137 success = query_drag_operation(query);
138 break;
139 case QUERY_PASTEBOARD_DATA:
140 TRACE("QUERY_PASTEBOARD_DATA\n");
141 success = query_pasteboard_data(hwnd, query->pasteboard_data.type);
142 break;
143 default:
144 FIXME("unrecognized query type %d\n", query->type);
145 break;
148 TRACE("success %d\n", success);
149 query->status = success;
150 macdrv_set_query_done(query);
154 /***********************************************************************
155 * macdrv_handle_event
157 void macdrv_handle_event(const macdrv_event *event)
159 HWND hwnd = macdrv_get_window_hwnd(event->window);
160 const macdrv_event *prev;
161 struct macdrv_thread_data *thread_data = macdrv_thread_data();
163 TRACE("%s for hwnd/window %p/%p\n", dbgstr_event(event->type), hwnd,
164 event->window);
166 prev = thread_data->current_event;
167 thread_data->current_event = event;
169 switch (event->type)
171 case APP_DEACTIVATED:
172 macdrv_app_deactivated();
173 break;
174 case APP_QUIT_REQUESTED:
175 macdrv_app_quit_requested(event);
176 break;
177 case DISPLAYS_CHANGED:
178 macdrv_displays_changed(event);
179 break;
180 case IM_SET_CURSOR_POS:
181 macdrv_im_set_cursor_pos(event);
182 break;
183 case IM_SET_TEXT:
184 macdrv_im_set_text(event);
185 break;
186 case KEY_PRESS:
187 case KEY_RELEASE:
188 macdrv_key_event(hwnd, event);
189 break;
190 case KEYBOARD_CHANGED:
191 macdrv_keyboard_changed(event);
192 break;
193 case MOUSE_BUTTON:
194 macdrv_mouse_button(hwnd, event);
195 break;
196 case MOUSE_MOVED:
197 case MOUSE_MOVED_ABSOLUTE:
198 macdrv_mouse_moved(hwnd, event);
199 break;
200 case MOUSE_SCROLL:
201 macdrv_mouse_scroll(hwnd, event);
202 break;
203 case QUERY_EVENT:
204 macdrv_query_event(hwnd, event);
205 break;
206 case STATUS_ITEM_CLICKED:
207 macdrv_status_item_clicked(event);
208 break;
209 case WINDOW_CLOSE_REQUESTED:
210 macdrv_window_close_requested(hwnd);
211 break;
212 case WINDOW_DID_MINIMIZE:
213 macdrv_window_did_minimize(hwnd);
214 break;
215 case WINDOW_DID_UNMINIMIZE:
216 macdrv_window_did_unminimize(hwnd);
217 break;
218 case WINDOW_FRAME_CHANGED:
219 macdrv_window_frame_changed(hwnd, event->window_frame_changed.frame);
220 break;
221 case WINDOW_GOT_FOCUS:
222 macdrv_window_got_focus(hwnd, event);
223 break;
224 case WINDOW_LOST_FOCUS:
225 macdrv_window_lost_focus(hwnd, event);
226 break;
227 default:
228 TRACE(" ignoring\n");
229 break;
232 thread_data->current_event = prev;
236 /***********************************************************************
237 * process_events
239 static int process_events(macdrv_event_queue queue, macdrv_event_mask mask)
241 macdrv_event *event;
242 int count = 0;
244 while (macdrv_copy_event_from_queue(queue, mask, &event))
246 count++;
247 macdrv_handle_event(event);
248 macdrv_release_event(event);
250 if (count) TRACE("processed %d events\n", count);
251 return count;
255 /***********************************************************************
256 * MsgWaitForMultipleObjectsEx (MACDRV.@)
258 DWORD CDECL macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
259 DWORD timeout, DWORD mask, DWORD flags)
261 DWORD ret;
262 struct macdrv_thread_data *data = macdrv_thread_data();
263 macdrv_event_mask event_mask = get_event_mask(mask);
265 TRACE("count %d, handles %p, timeout %u, mask %x, flags %x\n", count,
266 handles, timeout, mask, flags);
268 if (!data)
270 if (!count && !timeout) return WAIT_TIMEOUT;
271 return WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
272 timeout, flags & MWMO_ALERTABLE);
275 if (data->current_event && data->current_event->type != QUERY_EVENT &&
276 data->current_event->type != APP_QUIT_REQUESTED)
277 event_mask = 0; /* don't process nested events */
279 if (process_events(data->queue, event_mask)) ret = count - 1;
280 else if (count || timeout)
282 ret = WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
283 timeout, flags & MWMO_ALERTABLE);
284 if (ret == count - 1) process_events(data->queue, event_mask);
286 else ret = WAIT_TIMEOUT;
288 return ret;