2013-01-21 07:08:08 +01:00
|
|
|
/*
|
|
|
|
* MACDRV event driver
|
|
|
|
*
|
|
|
|
* Copyright 1993 Alexandre Julliard
|
|
|
|
* 1999 Noel Borthwick
|
|
|
|
* Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "macdrv.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(event);
|
|
|
|
|
|
|
|
|
|
|
|
/* return the name of an Mac event */
|
|
|
|
static const char *dbgstr_event(int type)
|
|
|
|
{
|
2013-01-21 07:08:12 +01:00
|
|
|
static const char * const event_names[] = {
|
2013-01-27 23:19:56 +01:00
|
|
|
"APP_DEACTIVATED",
|
2013-04-04 01:56:55 +02:00
|
|
|
"APP_QUIT_REQUESTED",
|
2013-02-18 02:28:34 +01:00
|
|
|
"DISPLAYS_CHANGED",
|
2013-09-26 00:10:37 +02:00
|
|
|
"HOTKEY_PRESS",
|
2013-04-22 04:32:26 +02:00
|
|
|
"IM_SET_TEXT",
|
2013-02-04 00:20:18 +01:00
|
|
|
"KEY_PRESS",
|
|
|
|
"KEY_RELEASE",
|
2013-02-04 00:20:15 +01:00
|
|
|
"KEYBOARD_CHANGED",
|
2013-01-27 23:19:37 +01:00
|
|
|
"MOUSE_BUTTON",
|
2013-02-07 02:32:26 +01:00
|
|
|
"MOUSE_MOVED",
|
|
|
|
"MOUSE_MOVED_ABSOLUTE",
|
2013-02-11 02:09:12 +01:00
|
|
|
"MOUSE_SCROLL",
|
2013-03-11 04:58:26 +01:00
|
|
|
"QUERY_EVENT",
|
2013-06-20 02:09:33 +02:00
|
|
|
"RELEASE_CAPTURE",
|
2013-09-06 05:23:52 +02:00
|
|
|
"STATUS_ITEM_MOUSE_BUTTON",
|
|
|
|
"STATUS_ITEM_MOUSE_MOVE",
|
2013-10-08 09:21:34 +02:00
|
|
|
"WINDOW_BROUGHT_FORWARD",
|
2013-01-21 07:08:12 +01:00
|
|
|
"WINDOW_CLOSE_REQUESTED",
|
2013-02-04 00:20:07 +01:00
|
|
|
"WINDOW_DID_UNMINIMIZE",
|
2013-12-11 19:50:55 +01:00
|
|
|
"WINDOW_DRAG_BEGIN",
|
|
|
|
"WINDOW_DRAG_END",
|
2013-01-27 23:19:29 +01:00
|
|
|
"WINDOW_FRAME_CHANGED",
|
2013-01-27 23:19:48 +01:00
|
|
|
"WINDOW_GOT_FOCUS",
|
2013-01-27 23:19:53 +01:00
|
|
|
"WINDOW_LOST_FOCUS",
|
2013-12-30 04:34:48 +01:00
|
|
|
"WINDOW_MAXIMIZE_REQUESTED",
|
2013-09-30 17:29:23 +02:00
|
|
|
"WINDOW_MINIMIZE_REQUESTED",
|
2013-11-01 01:16:42 +01:00
|
|
|
"WINDOW_RESIZE_ENDED",
|
2013-12-30 04:34:48 +01:00
|
|
|
"WINDOW_RESTORE_REQUESTED",
|
2013-01-21 07:08:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if (0 <= type && type < NUM_EVENT_TYPES) return event_names[type];
|
2013-01-21 07:08:08 +01:00
|
|
|
return wine_dbg_sprintf("Unknown event %d", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* get_event_mask
|
|
|
|
*/
|
|
|
|
static macdrv_event_mask get_event_mask(DWORD mask)
|
|
|
|
{
|
2013-01-21 07:08:12 +01:00
|
|
|
macdrv_event_mask event_mask = 0;
|
|
|
|
|
2013-01-21 07:08:08 +01:00
|
|
|
if ((mask & QS_ALLINPUT) == QS_ALLINPUT) return -1;
|
2013-01-21 07:08:12 +01:00
|
|
|
|
2013-09-26 00:10:37 +02:00
|
|
|
if (mask & QS_HOTKEY)
|
|
|
|
event_mask |= event_mask_for_type(HOTKEY_PRESS);
|
|
|
|
|
2013-02-04 00:20:15 +01:00
|
|
|
if (mask & QS_KEY)
|
2013-02-04 00:20:18 +01:00
|
|
|
{
|
|
|
|
event_mask |= event_mask_for_type(KEY_PRESS);
|
|
|
|
event_mask |= event_mask_for_type(KEY_RELEASE);
|
2013-02-04 00:20:15 +01:00
|
|
|
event_mask |= event_mask_for_type(KEYBOARD_CHANGED);
|
2013-02-04 00:20:18 +01:00
|
|
|
}
|
2013-02-04 00:20:15 +01:00
|
|
|
|
2013-01-27 23:19:37 +01:00
|
|
|
if (mask & QS_MOUSEBUTTON)
|
2013-02-11 02:09:12 +01:00
|
|
|
{
|
2013-01-27 23:19:37 +01:00
|
|
|
event_mask |= event_mask_for_type(MOUSE_BUTTON);
|
2013-02-11 02:09:12 +01:00
|
|
|
event_mask |= event_mask_for_type(MOUSE_SCROLL);
|
|
|
|
}
|
2013-01-27 23:19:37 +01:00
|
|
|
|
2013-02-07 02:32:26 +01:00
|
|
|
if (mask & QS_MOUSEMOVE)
|
|
|
|
{
|
|
|
|
event_mask |= event_mask_for_type(MOUSE_MOVED);
|
|
|
|
event_mask |= event_mask_for_type(MOUSE_MOVED_ABSOLUTE);
|
|
|
|
}
|
|
|
|
|
2013-01-21 07:08:12 +01:00
|
|
|
if (mask & QS_POSTMESSAGE)
|
2013-01-27 23:19:29 +01:00
|
|
|
{
|
2013-01-27 23:19:56 +01:00
|
|
|
event_mask |= event_mask_for_type(APP_DEACTIVATED);
|
2013-04-04 01:56:55 +02:00
|
|
|
event_mask |= event_mask_for_type(APP_QUIT_REQUESTED);
|
2013-02-18 02:28:34 +01:00
|
|
|
event_mask |= event_mask_for_type(DISPLAYS_CHANGED);
|
2013-04-22 04:32:26 +02:00
|
|
|
event_mask |= event_mask_for_type(IM_SET_TEXT);
|
2013-09-06 05:23:52 +02:00
|
|
|
event_mask |= event_mask_for_type(STATUS_ITEM_MOUSE_BUTTON);
|
|
|
|
event_mask |= event_mask_for_type(STATUS_ITEM_MOUSE_MOVE);
|
2013-02-04 00:20:07 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_DID_UNMINIMIZE);
|
2013-01-27 23:19:29 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_FRAME_CHANGED);
|
2013-01-27 23:19:48 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_GOT_FOCUS);
|
2013-01-27 23:19:53 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_LOST_FOCUS);
|
2013-01-27 23:19:29 +01:00
|
|
|
}
|
2013-01-21 07:08:12 +01:00
|
|
|
|
2013-03-11 04:58:26 +01:00
|
|
|
if (mask & QS_SENDMESSAGE)
|
|
|
|
{
|
|
|
|
event_mask |= event_mask_for_type(QUERY_EVENT);
|
2013-06-20 02:09:33 +02:00
|
|
|
event_mask |= event_mask_for_type(RELEASE_CAPTURE);
|
2013-10-08 09:21:34 +02:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_BROUGHT_FORWARD);
|
2013-12-30 04:33:14 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
|
2013-12-11 19:50:55 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_DRAG_BEGIN);
|
|
|
|
event_mask |= event_mask_for_type(WINDOW_DRAG_END);
|
2013-12-30 04:34:48 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_MAXIMIZE_REQUESTED);
|
2013-09-30 17:29:23 +02:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_MINIMIZE_REQUESTED);
|
2013-11-01 01:16:42 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_RESIZE_ENDED);
|
2013-12-30 04:34:48 +01:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_RESTORE_REQUESTED);
|
2013-03-11 04:58:26 +01:00
|
|
|
}
|
|
|
|
|
2013-01-21 07:08:12 +01:00
|
|
|
return event_mask;
|
2013-01-21 07:08:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-11 04:58:26 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_query_event
|
|
|
|
*
|
|
|
|
* Handler for QUERY_EVENT queries.
|
|
|
|
*/
|
2013-04-04 01:56:25 +02:00
|
|
|
static void macdrv_query_event(HWND hwnd, const macdrv_event *event)
|
2013-03-11 04:58:26 +01:00
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
macdrv_query *query = event->query_event.query;
|
|
|
|
|
|
|
|
switch (query->type)
|
|
|
|
{
|
2013-03-13 22:53:32 +01:00
|
|
|
case QUERY_DRAG_DROP:
|
|
|
|
TRACE("QUERY_DRAG_DROP\n");
|
|
|
|
success = query_drag_drop(query);
|
|
|
|
break;
|
|
|
|
case QUERY_DRAG_EXITED:
|
|
|
|
TRACE("QUERY_DRAG_EXITED\n");
|
|
|
|
success = query_drag_exited(query);
|
|
|
|
break;
|
|
|
|
case QUERY_DRAG_OPERATION:
|
|
|
|
TRACE("QUERY_DRAG_OPERATION\n");
|
|
|
|
success = query_drag_operation(query);
|
|
|
|
break;
|
2013-05-16 23:48:39 +02:00
|
|
|
case QUERY_IME_CHAR_RECT:
|
|
|
|
TRACE("QUERY_IME_CHAR_RECT\n");
|
|
|
|
success = query_ime_char_rect(query);
|
|
|
|
break;
|
2013-03-11 04:58:51 +01:00
|
|
|
case QUERY_PASTEBOARD_DATA:
|
|
|
|
TRACE("QUERY_PASTEBOARD_DATA\n");
|
|
|
|
success = query_pasteboard_data(hwnd, query->pasteboard_data.type);
|
|
|
|
break;
|
2013-09-18 20:00:37 +02:00
|
|
|
case QUERY_RESIZE_START:
|
|
|
|
TRACE("QUERY_RESIZE_START\n");
|
|
|
|
success = query_resize_start(hwnd);
|
|
|
|
break;
|
2013-10-08 09:21:29 +02:00
|
|
|
case QUERY_MIN_MAX_INFO:
|
|
|
|
TRACE("QUERY_MIN_MAX_INFO\n");
|
|
|
|
success = query_min_max_info(hwnd);
|
|
|
|
break;
|
2013-03-11 04:58:26 +01:00
|
|
|
default:
|
|
|
|
FIXME("unrecognized query type %d\n", query->type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("success %d\n", success);
|
|
|
|
query->status = success;
|
|
|
|
macdrv_set_query_done(query);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-21 07:08:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_handle_event
|
|
|
|
*/
|
2013-04-04 01:56:25 +02:00
|
|
|
void macdrv_handle_event(const macdrv_event *event)
|
2013-01-21 07:08:08 +01:00
|
|
|
{
|
|
|
|
HWND hwnd = macdrv_get_window_hwnd(event->window);
|
|
|
|
const macdrv_event *prev;
|
|
|
|
struct macdrv_thread_data *thread_data = macdrv_thread_data();
|
|
|
|
|
|
|
|
TRACE("%s for hwnd/window %p/%p\n", dbgstr_event(event->type), hwnd,
|
|
|
|
event->window);
|
|
|
|
|
|
|
|
prev = thread_data->current_event;
|
|
|
|
thread_data->current_event = event;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
2013-01-27 23:19:56 +01:00
|
|
|
case APP_DEACTIVATED:
|
|
|
|
macdrv_app_deactivated();
|
|
|
|
break;
|
2013-04-04 01:56:55 +02:00
|
|
|
case APP_QUIT_REQUESTED:
|
|
|
|
macdrv_app_quit_requested(event);
|
|
|
|
break;
|
2013-02-18 02:28:34 +01:00
|
|
|
case DISPLAYS_CHANGED:
|
|
|
|
macdrv_displays_changed(event);
|
|
|
|
break;
|
2013-09-26 00:10:37 +02:00
|
|
|
case HOTKEY_PRESS:
|
|
|
|
macdrv_hotkey_press(event);
|
|
|
|
break;
|
2013-04-22 04:32:26 +02:00
|
|
|
case IM_SET_TEXT:
|
|
|
|
macdrv_im_set_text(event);
|
|
|
|
break;
|
2013-02-04 00:20:18 +01:00
|
|
|
case KEY_PRESS:
|
|
|
|
case KEY_RELEASE:
|
|
|
|
macdrv_key_event(hwnd, event);
|
|
|
|
break;
|
2013-02-04 00:20:15 +01:00
|
|
|
case KEYBOARD_CHANGED:
|
|
|
|
macdrv_keyboard_changed(event);
|
|
|
|
break;
|
2013-01-27 23:19:37 +01:00
|
|
|
case MOUSE_BUTTON:
|
|
|
|
macdrv_mouse_button(hwnd, event);
|
|
|
|
break;
|
2013-02-07 02:32:26 +01:00
|
|
|
case MOUSE_MOVED:
|
|
|
|
case MOUSE_MOVED_ABSOLUTE:
|
|
|
|
macdrv_mouse_moved(hwnd, event);
|
|
|
|
break;
|
2013-02-11 02:09:12 +01:00
|
|
|
case MOUSE_SCROLL:
|
|
|
|
macdrv_mouse_scroll(hwnd, event);
|
|
|
|
break;
|
2013-03-11 04:58:26 +01:00
|
|
|
case QUERY_EVENT:
|
|
|
|
macdrv_query_event(hwnd, event);
|
|
|
|
break;
|
2013-06-20 02:09:33 +02:00
|
|
|
case RELEASE_CAPTURE:
|
|
|
|
macdrv_release_capture(hwnd, event);
|
|
|
|
break;
|
2013-09-06 05:23:52 +02:00
|
|
|
case STATUS_ITEM_MOUSE_BUTTON:
|
|
|
|
macdrv_status_item_mouse_button(event);
|
|
|
|
break;
|
|
|
|
case STATUS_ITEM_MOUSE_MOVE:
|
|
|
|
macdrv_status_item_mouse_move(event);
|
2013-03-18 04:40:54 +01:00
|
|
|
break;
|
2013-10-08 09:21:34 +02:00
|
|
|
case WINDOW_BROUGHT_FORWARD:
|
|
|
|
macdrv_window_brought_forward(hwnd);
|
|
|
|
break;
|
2013-01-21 07:08:12 +01:00
|
|
|
case WINDOW_CLOSE_REQUESTED:
|
|
|
|
macdrv_window_close_requested(hwnd);
|
|
|
|
break;
|
2013-02-04 00:20:07 +01:00
|
|
|
case WINDOW_DID_UNMINIMIZE:
|
|
|
|
macdrv_window_did_unminimize(hwnd);
|
|
|
|
break;
|
2013-12-11 19:50:55 +01:00
|
|
|
case WINDOW_DRAG_BEGIN:
|
|
|
|
macdrv_window_drag_begin(hwnd);
|
|
|
|
break;
|
|
|
|
case WINDOW_DRAG_END:
|
|
|
|
macdrv_window_drag_end(hwnd);
|
|
|
|
break;
|
2013-01-27 23:19:29 +01:00
|
|
|
case WINDOW_FRAME_CHANGED:
|
2013-10-10 21:22:08 +02:00
|
|
|
macdrv_window_frame_changed(hwnd, event);
|
2013-01-27 23:19:29 +01:00
|
|
|
break;
|
2013-01-27 23:19:48 +01:00
|
|
|
case WINDOW_GOT_FOCUS:
|
|
|
|
macdrv_window_got_focus(hwnd, event);
|
|
|
|
break;
|
2013-01-27 23:19:53 +01:00
|
|
|
case WINDOW_LOST_FOCUS:
|
|
|
|
macdrv_window_lost_focus(hwnd, event);
|
|
|
|
break;
|
2013-12-30 04:34:48 +01:00
|
|
|
case WINDOW_MAXIMIZE_REQUESTED:
|
|
|
|
macdrv_window_maximize_requested(hwnd);
|
|
|
|
break;
|
2013-09-30 17:29:23 +02:00
|
|
|
case WINDOW_MINIMIZE_REQUESTED:
|
|
|
|
macdrv_window_minimize_requested(hwnd);
|
|
|
|
break;
|
2013-11-01 01:16:42 +01:00
|
|
|
case WINDOW_RESIZE_ENDED:
|
|
|
|
macdrv_window_resize_ended(hwnd);
|
|
|
|
break;
|
2013-12-30 04:34:48 +01:00
|
|
|
case WINDOW_RESTORE_REQUESTED:
|
|
|
|
macdrv_window_restore_requested(hwnd);
|
|
|
|
break;
|
2013-01-21 07:08:08 +01:00
|
|
|
default:
|
|
|
|
TRACE(" ignoring\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_data->current_event = prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* process_events
|
|
|
|
*/
|
|
|
|
static int process_events(macdrv_event_queue queue, macdrv_event_mask mask)
|
|
|
|
{
|
2013-04-04 01:56:35 +02:00
|
|
|
macdrv_event *event;
|
2013-01-21 07:08:08 +01:00
|
|
|
int count = 0;
|
|
|
|
|
2013-04-04 01:56:35 +02:00
|
|
|
while (macdrv_copy_event_from_queue(queue, mask, &event))
|
2013-01-21 07:08:08 +01:00
|
|
|
{
|
|
|
|
count++;
|
2013-04-04 01:56:35 +02:00
|
|
|
macdrv_handle_event(event);
|
|
|
|
macdrv_release_event(event);
|
2013-01-21 07:08:08 +01:00
|
|
|
}
|
|
|
|
if (count) TRACE("processed %d events\n", count);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsgWaitForMultipleObjectsEx (MACDRV.@)
|
|
|
|
*/
|
|
|
|
DWORD CDECL macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
|
|
|
|
DWORD timeout, DWORD mask, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
struct macdrv_thread_data *data = macdrv_thread_data();
|
|
|
|
macdrv_event_mask event_mask = get_event_mask(mask);
|
|
|
|
|
|
|
|
TRACE("count %d, handles %p, timeout %u, mask %x, flags %x\n", count,
|
|
|
|
handles, timeout, mask, flags);
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
if (!count && !timeout) return WAIT_TIMEOUT;
|
|
|
|
return WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE);
|
|
|
|
}
|
|
|
|
|
2013-04-04 01:56:55 +02:00
|
|
|
if (data->current_event && data->current_event->type != QUERY_EVENT &&
|
2013-12-11 19:50:55 +01:00
|
|
|
data->current_event->type != APP_QUIT_REQUESTED &&
|
|
|
|
data->current_event->type != WINDOW_DRAG_BEGIN)
|
2013-03-13 22:52:57 +01:00
|
|
|
event_mask = 0; /* don't process nested events */
|
2013-01-21 07:08:08 +01:00
|
|
|
|
|
|
|
if (process_events(data->queue, event_mask)) ret = count - 1;
|
|
|
|
else if (count || timeout)
|
|
|
|
{
|
|
|
|
ret = WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE);
|
|
|
|
if (ret == count - 1) process_events(data->queue, event_mask);
|
|
|
|
}
|
|
|
|
else ret = WAIT_TIMEOUT;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|