2013-01-21 06:08:08 +00: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
|
|
|
|
*/
|
|
|
|
|
2022-06-02 22:25:16 +00:00
|
|
|
#if 0
|
|
|
|
#pragma makedep unix
|
|
|
|
#endif
|
|
|
|
|
2013-01-21 06:08:08 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2023-05-12 06:54:55 +00:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2013-01-21 06:08:08 +00:00
|
|
|
#include "macdrv.h"
|
2022-05-31 23:21:53 +00:00
|
|
|
#include "oleidl.h"
|
2013-01-21 06:08:08 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(event);
|
2022-05-31 18:09:45 +00:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(imm);
|
2013-01-21 06:08:08 +00:00
|
|
|
|
2023-05-12 05:42:38 +00:00
|
|
|
/* IME works synchronously, key input is passed from ImeProcessKey, to the
|
|
|
|
* host IME. We wait for it to be handled, or not, which is notified using
|
|
|
|
* the sent_text_input event. Meanwhile, while processing the key, the host
|
|
|
|
* IME may send one or more im_set_text events to update the input text.
|
|
|
|
*
|
|
|
|
* If ImeProcessKey returns TRUE, ImeToAsciiEx is then be called to retrieve
|
|
|
|
* the composition string updates. We use ime_update.comp_str != NULL as flag that
|
|
|
|
* composition is started, even if the preedit text is empty.
|
|
|
|
*
|
|
|
|
* If ImeProcessKey returns FALSE, ImeToAsciiEx will not be called.
|
|
|
|
*/
|
2023-05-02 09:55:46 +00:00
|
|
|
struct ime_update
|
|
|
|
{
|
2023-05-11 06:47:06 +00:00
|
|
|
DWORD cursor_pos;
|
2023-05-12 06:54:55 +00:00
|
|
|
WCHAR *comp_str;
|
|
|
|
WCHAR *result_str;
|
2023-05-02 09:55:46 +00:00
|
|
|
};
|
|
|
|
static struct ime_update ime_update;
|
2013-01-21 06:08:08 +00:00
|
|
|
|
|
|
|
/* return the name of an Mac event */
|
|
|
|
static const char *dbgstr_event(int type)
|
|
|
|
{
|
2013-01-21 06:08:12 +00:00
|
|
|
static const char * const event_names[] = {
|
2016-12-09 22:25:08 +00:00
|
|
|
"APP_ACTIVATED",
|
2013-01-27 22:19:56 +00:00
|
|
|
"APP_DEACTIVATED",
|
2013-04-03 23:56:55 +00:00
|
|
|
"APP_QUIT_REQUESTED",
|
2013-02-18 01:28:34 +00:00
|
|
|
"DISPLAYS_CHANGED",
|
2013-09-25 22:10:37 +00:00
|
|
|
"HOTKEY_PRESS",
|
2013-04-22 02:32:26 +00:00
|
|
|
"IM_SET_TEXT",
|
2013-02-03 23:20:18 +00:00
|
|
|
"KEY_PRESS",
|
|
|
|
"KEY_RELEASE",
|
2013-02-03 23:20:15 +00:00
|
|
|
"KEYBOARD_CHANGED",
|
2016-10-23 18:03:34 +00:00
|
|
|
"LOST_PASTEBOARD_OWNERSHIP",
|
2013-01-27 22:19:37 +00:00
|
|
|
"MOUSE_BUTTON",
|
2022-06-03 00:00:15 +00:00
|
|
|
"MOUSE_MOVED_RELATIVE",
|
2013-02-07 01:32:26 +00:00
|
|
|
"MOUSE_MOVED_ABSOLUTE",
|
2013-02-11 01:09:12 +00:00
|
|
|
"MOUSE_SCROLL",
|
2013-03-11 03:58:26 +00:00
|
|
|
"QUERY_EVENT",
|
2016-02-04 23:18:27 +00:00
|
|
|
"QUERY_EVENT_NO_PREEMPT_WAIT",
|
2015-10-05 20:44:28 +00:00
|
|
|
"REASSERT_WINDOW_POSITION",
|
2013-06-20 00:09:33 +00:00
|
|
|
"RELEASE_CAPTURE",
|
2016-02-04 23:18:25 +00:00
|
|
|
"SENT_TEXT_INPUT",
|
2013-09-06 03:23:52 +00:00
|
|
|
"STATUS_ITEM_MOUSE_BUTTON",
|
|
|
|
"STATUS_ITEM_MOUSE_MOVE",
|
2013-10-08 07:21:34 +00:00
|
|
|
"WINDOW_BROUGHT_FORWARD",
|
2013-01-21 06:08:12 +00:00
|
|
|
"WINDOW_CLOSE_REQUESTED",
|
2023-05-18 19:18:13 +00:00
|
|
|
"WINDOW_DID_MINIMIZE",
|
2013-02-03 23:20:07 +00:00
|
|
|
"WINDOW_DID_UNMINIMIZE",
|
2013-12-11 18:50:55 +00:00
|
|
|
"WINDOW_DRAG_BEGIN",
|
|
|
|
"WINDOW_DRAG_END",
|
2013-01-27 22:19:29 +00:00
|
|
|
"WINDOW_FRAME_CHANGED",
|
2013-01-27 22:19:48 +00:00
|
|
|
"WINDOW_GOT_FOCUS",
|
2013-01-27 22:19:53 +00:00
|
|
|
"WINDOW_LOST_FOCUS",
|
2013-12-30 03:34:48 +00:00
|
|
|
"WINDOW_MAXIMIZE_REQUESTED",
|
2013-09-30 15:29:23 +00:00
|
|
|
"WINDOW_MINIMIZE_REQUESTED",
|
2013-11-01 00:16:42 +00:00
|
|
|
"WINDOW_RESIZE_ENDED",
|
2013-12-30 03:34:48 +00:00
|
|
|
"WINDOW_RESTORE_REQUESTED",
|
2013-01-21 06:08:12 +00:00
|
|
|
};
|
2023-05-18 19:18:13 +00:00
|
|
|
C_ASSERT(ARRAYSIZE(event_names) == NUM_EVENT_TYPES);
|
2013-01-21 06:08:12 +00:00
|
|
|
|
|
|
|
if (0 <= type && type < NUM_EVENT_TYPES) return event_names[type];
|
2013-01-21 06:08:08 +00:00
|
|
|
return wine_dbg_sprintf("Unknown event %d", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* get_event_mask
|
|
|
|
*/
|
|
|
|
static macdrv_event_mask get_event_mask(DWORD mask)
|
|
|
|
{
|
2013-01-21 06:08:12 +00:00
|
|
|
macdrv_event_mask event_mask = 0;
|
|
|
|
|
2013-01-21 06:08:08 +00:00
|
|
|
if ((mask & QS_ALLINPUT) == QS_ALLINPUT) return -1;
|
2013-01-21 06:08:12 +00:00
|
|
|
|
2013-09-25 22:10:37 +00:00
|
|
|
if (mask & QS_HOTKEY)
|
|
|
|
event_mask |= event_mask_for_type(HOTKEY_PRESS);
|
|
|
|
|
2013-02-03 23:20:15 +00:00
|
|
|
if (mask & QS_KEY)
|
2013-02-03 23:20:18 +00:00
|
|
|
{
|
|
|
|
event_mask |= event_mask_for_type(KEY_PRESS);
|
|
|
|
event_mask |= event_mask_for_type(KEY_RELEASE);
|
2013-02-03 23:20:15 +00:00
|
|
|
event_mask |= event_mask_for_type(KEYBOARD_CHANGED);
|
2013-02-03 23:20:18 +00:00
|
|
|
}
|
2013-02-03 23:20:15 +00:00
|
|
|
|
2013-01-27 22:19:37 +00:00
|
|
|
if (mask & QS_MOUSEBUTTON)
|
2013-02-11 01:09:12 +00:00
|
|
|
{
|
2013-01-27 22:19:37 +00:00
|
|
|
event_mask |= event_mask_for_type(MOUSE_BUTTON);
|
2013-02-11 01:09:12 +00:00
|
|
|
event_mask |= event_mask_for_type(MOUSE_SCROLL);
|
|
|
|
}
|
2013-01-27 22:19:37 +00:00
|
|
|
|
2013-02-07 01:32:26 +00:00
|
|
|
if (mask & QS_MOUSEMOVE)
|
|
|
|
{
|
2022-06-03 00:00:15 +00:00
|
|
|
event_mask |= event_mask_for_type(MOUSE_MOVED_RELATIVE);
|
2013-02-07 01:32:26 +00:00
|
|
|
event_mask |= event_mask_for_type(MOUSE_MOVED_ABSOLUTE);
|
|
|
|
}
|
|
|
|
|
2013-01-21 06:08:12 +00:00
|
|
|
if (mask & QS_POSTMESSAGE)
|
2013-01-27 22:19:29 +00:00
|
|
|
{
|
2016-12-09 22:25:08 +00:00
|
|
|
event_mask |= event_mask_for_type(APP_ACTIVATED);
|
2013-01-27 22:19:56 +00:00
|
|
|
event_mask |= event_mask_for_type(APP_DEACTIVATED);
|
2013-04-03 23:56:55 +00:00
|
|
|
event_mask |= event_mask_for_type(APP_QUIT_REQUESTED);
|
2013-02-18 01:28:34 +00:00
|
|
|
event_mask |= event_mask_for_type(DISPLAYS_CHANGED);
|
2013-04-22 02:32:26 +00:00
|
|
|
event_mask |= event_mask_for_type(IM_SET_TEXT);
|
2016-10-23 18:03:34 +00:00
|
|
|
event_mask |= event_mask_for_type(LOST_PASTEBOARD_OWNERSHIP);
|
2013-09-06 03:23:52 +00:00
|
|
|
event_mask |= event_mask_for_type(STATUS_ITEM_MOUSE_BUTTON);
|
|
|
|
event_mask |= event_mask_for_type(STATUS_ITEM_MOUSE_MOVE);
|
2013-02-03 23:20:07 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_DID_UNMINIMIZE);
|
2013-01-27 22:19:29 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_FRAME_CHANGED);
|
2013-01-27 22:19:48 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_GOT_FOCUS);
|
2013-01-27 22:19:53 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_LOST_FOCUS);
|
2013-01-27 22:19:29 +00:00
|
|
|
}
|
2013-01-21 06:08:12 +00:00
|
|
|
|
2013-03-11 03:58:26 +00:00
|
|
|
if (mask & QS_SENDMESSAGE)
|
|
|
|
{
|
|
|
|
event_mask |= event_mask_for_type(QUERY_EVENT);
|
2016-02-04 23:18:27 +00:00
|
|
|
event_mask |= event_mask_for_type(QUERY_EVENT_NO_PREEMPT_WAIT);
|
2015-10-05 20:44:28 +00:00
|
|
|
event_mask |= event_mask_for_type(REASSERT_WINDOW_POSITION);
|
2013-06-20 00:09:33 +00:00
|
|
|
event_mask |= event_mask_for_type(RELEASE_CAPTURE);
|
2016-02-04 23:18:25 +00:00
|
|
|
event_mask |= event_mask_for_type(SENT_TEXT_INPUT);
|
2013-10-08 07:21:34 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_BROUGHT_FORWARD);
|
2013-12-30 03:33:14 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
|
2013-12-11 18:50:55 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_DRAG_BEGIN);
|
|
|
|
event_mask |= event_mask_for_type(WINDOW_DRAG_END);
|
2013-12-30 03:34:48 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_MAXIMIZE_REQUESTED);
|
2013-09-30 15:29:23 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_MINIMIZE_REQUESTED);
|
2013-11-01 00:16:42 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_RESIZE_ENDED);
|
2013-12-30 03:34:48 +00:00
|
|
|
event_mask |= event_mask_for_type(WINDOW_RESTORE_REQUESTED);
|
2013-03-11 03:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 06:08:12 +00:00
|
|
|
return event_mask;
|
2013-01-21 06:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-31 19:06:20 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_im_set_text
|
|
|
|
*/
|
|
|
|
static void macdrv_im_set_text(const macdrv_event *event)
|
|
|
|
{
|
|
|
|
HWND hwnd = macdrv_get_window_hwnd(event->window);
|
2023-05-12 05:42:38 +00:00
|
|
|
CFIndex length = 0;
|
|
|
|
WCHAR *text = NULL;
|
2022-05-31 19:06:20 +00:00
|
|
|
|
2023-03-30 13:33:10 +00:00
|
|
|
TRACE_(imm)("win %p/%p himc %p text %s complete %u\n", hwnd, event->window, event->im_set_text.himc,
|
2022-05-31 19:06:20 +00:00
|
|
|
debugstr_cf(event->im_set_text.text), event->im_set_text.complete);
|
|
|
|
|
|
|
|
if (event->im_set_text.text)
|
2023-05-12 05:42:38 +00:00
|
|
|
{
|
2022-05-31 19:06:20 +00:00
|
|
|
length = CFStringGetLength(event->im_set_text.text);
|
2023-05-12 05:42:38 +00:00
|
|
|
if (!(text = malloc((length + 1) * sizeof(WCHAR)))) return;
|
|
|
|
if (length) CFStringGetCharacters(event->im_set_text.text, CFRangeMake(0, length), text);
|
|
|
|
text[length] = 0;
|
|
|
|
}
|
2022-05-31 19:06:20 +00:00
|
|
|
|
2023-05-12 05:42:38 +00:00
|
|
|
/* discard any pending comp text */
|
|
|
|
free(ime_update.comp_str);
|
2023-05-12 06:54:55 +00:00
|
|
|
ime_update.comp_str = NULL;
|
2023-05-12 05:42:38 +00:00
|
|
|
ime_update.cursor_pos = -1;
|
2023-05-02 09:55:46 +00:00
|
|
|
|
2023-05-12 05:42:38 +00:00
|
|
|
if (event->im_set_text.complete)
|
2023-05-02 09:55:46 +00:00
|
|
|
{
|
2023-05-12 05:42:38 +00:00
|
|
|
free(ime_update.result_str);
|
|
|
|
ime_update.result_str = text;
|
2023-05-02 09:55:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-12 05:42:38 +00:00
|
|
|
ime_update.comp_str = text;
|
2023-05-11 06:47:06 +00:00
|
|
|
ime_update.cursor_pos = event->im_set_text.cursor_pos;
|
2023-05-02 09:55:46 +00:00
|
|
|
}
|
2022-05-31 19:06:20 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 18:09:45 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_sent_text_input
|
|
|
|
*/
|
|
|
|
static void macdrv_sent_text_input(const macdrv_event *event)
|
|
|
|
{
|
|
|
|
TRACE_(imm)("handled: %s\n", event->sent_text_input.handled ? "TRUE" : "FALSE");
|
2023-05-12 06:54:55 +00:00
|
|
|
*event->sent_text_input.done = event->sent_text_input.handled || ime_update.result_str ? 1 : -1;
|
2023-05-02 09:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2023-05-11 06:39:30 +00:00
|
|
|
* ImeToAsciiEx (MACDRV.@)
|
2023-05-02 09:55:46 +00:00
|
|
|
*/
|
2023-05-11 06:39:30 +00:00
|
|
|
UINT macdrv_ImeToAsciiEx(UINT vkey, UINT vsc, const BYTE *state, COMPOSITIONSTRING *compstr, HIMC himc)
|
2023-05-02 09:55:46 +00:00
|
|
|
{
|
2023-05-12 06:54:55 +00:00
|
|
|
UINT needed = sizeof(COMPOSITIONSTRING), comp_len, result_len;
|
|
|
|
struct ime_update *update = &ime_update;
|
2023-05-11 06:47:06 +00:00
|
|
|
void *dst;
|
2023-05-12 06:54:55 +00:00
|
|
|
|
2023-05-11 06:39:30 +00:00
|
|
|
TRACE_(imm)("vkey %#x, vsc %#x, state %p, compstr %p, himc %p\n", vkey, vsc, state, compstr, himc);
|
|
|
|
|
2023-05-12 06:54:55 +00:00
|
|
|
if (!update->comp_str) comp_len = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
comp_len = wcslen(update->comp_str);
|
|
|
|
needed += comp_len * sizeof(WCHAR); /* GCS_COMPSTR */
|
|
|
|
needed += comp_len; /* GCS_COMPATTR */
|
|
|
|
needed += 2 * sizeof(DWORD); /* GCS_COMPCLAUSE */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!update->result_str) result_len = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result_len = wcslen(update->result_str);
|
|
|
|
needed += result_len * sizeof(WCHAR); /* GCS_RESULTSTR */
|
|
|
|
needed += 2 * sizeof(DWORD); /* GCS_RESULTCLAUSE */
|
|
|
|
}
|
|
|
|
|
2023-05-11 06:47:06 +00:00
|
|
|
if (compstr->dwSize < needed)
|
|
|
|
{
|
|
|
|
compstr->dwSize = needed;
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset( compstr, 0, sizeof(*compstr) );
|
|
|
|
compstr->dwSize = sizeof(*compstr);
|
|
|
|
|
|
|
|
if (update->comp_str)
|
|
|
|
{
|
|
|
|
compstr->dwCursorPos = update->cursor_pos;
|
|
|
|
|
|
|
|
compstr->dwCompStrLen = comp_len;
|
|
|
|
compstr->dwCompStrOffset = compstr->dwSize;
|
|
|
|
dst = (BYTE *)compstr + compstr->dwCompStrOffset;
|
|
|
|
memcpy(dst, update->comp_str, compstr->dwCompStrLen * sizeof(WCHAR));
|
|
|
|
compstr->dwSize += compstr->dwCompStrLen * sizeof(WCHAR);
|
|
|
|
|
|
|
|
compstr->dwCompClauseLen = 2 * sizeof(DWORD);
|
|
|
|
compstr->dwCompClauseOffset = compstr->dwSize;
|
|
|
|
dst = (BYTE *)compstr + compstr->dwCompClauseOffset;
|
|
|
|
*((DWORD *)dst + 0) = 0;
|
|
|
|
*((DWORD *)dst + 1) = compstr->dwCompStrLen;
|
|
|
|
compstr->dwSize += compstr->dwCompClauseLen;
|
|
|
|
|
|
|
|
compstr->dwCompAttrLen = compstr->dwCompStrLen;
|
|
|
|
compstr->dwCompAttrOffset = compstr->dwSize;
|
|
|
|
dst = (BYTE *)compstr + compstr->dwCompAttrOffset;
|
|
|
|
memset(dst, ATTR_INPUT, compstr->dwCompAttrLen);
|
|
|
|
compstr->dwSize += compstr->dwCompAttrLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update->result_str)
|
|
|
|
{
|
|
|
|
compstr->dwResultStrLen = result_len;
|
|
|
|
compstr->dwResultStrOffset = compstr->dwSize;
|
|
|
|
dst = (BYTE *)compstr + compstr->dwResultStrOffset;
|
|
|
|
memcpy(dst, update->result_str, compstr->dwResultStrLen * sizeof(WCHAR));
|
|
|
|
compstr->dwSize += compstr->dwResultStrLen * sizeof(WCHAR);
|
|
|
|
|
|
|
|
compstr->dwResultClauseLen = 2 * sizeof(DWORD);
|
|
|
|
compstr->dwResultClauseOffset = compstr->dwSize;
|
|
|
|
dst = (BYTE *)compstr + compstr->dwResultClauseOffset;
|
|
|
|
*((DWORD *)dst + 0) = 0;
|
|
|
|
*((DWORD *)dst + 1) = compstr->dwResultStrLen;
|
|
|
|
compstr->dwSize += compstr->dwResultClauseLen;
|
|
|
|
}
|
|
|
|
|
2023-05-12 05:42:38 +00:00
|
|
|
free(update->result_str);
|
|
|
|
update->result_str = NULL;
|
2023-05-02 09:55:46 +00:00
|
|
|
return 0;
|
2022-05-31 18:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-31 23:21:53 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* drag_operations_to_dropeffects
|
|
|
|
*/
|
|
|
|
static DWORD drag_operations_to_dropeffects(uint32_t ops)
|
|
|
|
{
|
|
|
|
DWORD effects = 0;
|
|
|
|
if (ops & (DRAG_OP_COPY | DRAG_OP_GENERIC))
|
|
|
|
effects |= DROPEFFECT_COPY;
|
|
|
|
if (ops & DRAG_OP_MOVE)
|
|
|
|
effects |= DROPEFFECT_MOVE;
|
|
|
|
if (ops & (DRAG_OP_LINK | DRAG_OP_GENERIC))
|
|
|
|
effects |= DROPEFFECT_LINK;
|
|
|
|
return effects;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-01 00:41:22 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* dropeffect_to_drag_operation
|
|
|
|
*/
|
|
|
|
static uint32_t dropeffect_to_drag_operation(DWORD effect, uint32_t ops)
|
|
|
|
{
|
|
|
|
if (effect & DROPEFFECT_LINK && ops & DRAG_OP_LINK) return DRAG_OP_LINK;
|
|
|
|
if (effect & DROPEFFECT_COPY && ops & DRAG_OP_COPY) return DRAG_OP_COPY;
|
|
|
|
if (effect & DROPEFFECT_MOVE && ops & DRAG_OP_MOVE) return DRAG_OP_MOVE;
|
|
|
|
if (effect & DROPEFFECT_LINK && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC;
|
|
|
|
if (effect & DROPEFFECT_COPY && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC;
|
|
|
|
|
|
|
|
return DRAG_OP_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-31 23:21:53 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* query_drag_drop
|
|
|
|
*/
|
|
|
|
static BOOL query_drag_drop(macdrv_query *query)
|
|
|
|
{
|
|
|
|
HWND hwnd = macdrv_get_window_hwnd(query->window);
|
|
|
|
struct macdrv_win_data *data = get_win_data(hwnd);
|
|
|
|
struct dnd_query_drop_params params;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
WARN("no win_data for win %p/%p\n", hwnd, query->window);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-09-17 17:04:26 +00:00
|
|
|
params.hwnd = HandleToUlong(hwnd);
|
2022-05-31 23:21:53 +00:00
|
|
|
params.effect = drag_operations_to_dropeffects(query->drag_drop.op);
|
|
|
|
params.x = query->drag_drop.x + data->whole_rect.left;
|
|
|
|
params.y = query->drag_drop.y + data->whole_rect.top;
|
|
|
|
params.handle = (UINT_PTR)query->drag_drop.pasteboard;
|
|
|
|
release_win_data(data);
|
|
|
|
return macdrv_client_func(client_func_dnd_query_drop, ¶ms, sizeof(params));
|
|
|
|
}
|
|
|
|
|
2022-05-31 22:30:21 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* query_drag_exited
|
|
|
|
*/
|
|
|
|
static BOOL query_drag_exited(macdrv_query *query)
|
|
|
|
{
|
|
|
|
struct dnd_query_exited_params params;
|
2022-09-17 17:04:26 +00:00
|
|
|
params.hwnd = HandleToUlong(macdrv_get_window_hwnd(query->window));
|
2022-05-31 22:30:21 +00:00
|
|
|
return macdrv_client_func(client_func_dnd_query_exited, ¶ms, sizeof(params));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-01 00:41:22 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* query_drag_operation
|
|
|
|
*/
|
|
|
|
static BOOL query_drag_operation(macdrv_query *query)
|
|
|
|
{
|
|
|
|
struct dnd_query_drag_params params;
|
|
|
|
HWND hwnd = macdrv_get_window_hwnd(query->window);
|
|
|
|
struct macdrv_win_data *data = get_win_data(hwnd);
|
|
|
|
DWORD effect;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
WARN("no win_data for win %p/%p\n", hwnd, query->window);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-09-17 17:04:26 +00:00
|
|
|
params.hwnd = HandleToUlong(hwnd);
|
2022-06-01 00:41:22 +00:00
|
|
|
params.effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops);
|
|
|
|
params.x = query->drag_operation.x + data->whole_rect.left;
|
|
|
|
params.y = query->drag_operation.y + data->whole_rect.top;
|
|
|
|
params.handle = (UINT_PTR)query->drag_operation.pasteboard;
|
|
|
|
release_win_data(data);
|
|
|
|
|
|
|
|
effect = macdrv_client_func(client_func_dnd_query_drag, ¶ms, sizeof(params));
|
|
|
|
if (!effect) return FALSE;
|
|
|
|
|
|
|
|
query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect,
|
|
|
|
query->drag_operation.offered_ops);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-31 20:42:27 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* query_ime_char_rect
|
|
|
|
*/
|
|
|
|
BOOL query_ime_char_rect(macdrv_query* query)
|
|
|
|
{
|
|
|
|
HWND hwnd = macdrv_get_window_hwnd(query->window);
|
2023-03-30 13:33:10 +00:00
|
|
|
void *himc = query->ime_char_rect.himc;
|
2022-05-31 20:42:27 +00:00
|
|
|
CFRange *range = &query->ime_char_rect.range;
|
2023-05-09 19:43:58 +00:00
|
|
|
GUITHREADINFO info = {.cbSize = sizeof(info)};
|
|
|
|
BOOL ret = FALSE;
|
2022-05-31 20:42:27 +00:00
|
|
|
|
|
|
|
TRACE_(imm)("win %p/%p himc %p range %ld-%ld\n", hwnd, query->window, himc, range->location,
|
|
|
|
range->length);
|
|
|
|
|
2023-05-09 19:43:58 +00:00
|
|
|
if (NtUserGetGUIThreadInfo(0, &info))
|
|
|
|
{
|
|
|
|
NtUserMapWindowPoints(info.hwndCaret, 0, (POINT*)&info.rcCaret, 2);
|
|
|
|
if (range->length && info.rcCaret.left == info.rcCaret.right) info.rcCaret.right++;
|
|
|
|
query->ime_char_rect.rect = cgrect_from_rect(info.rcCaret);
|
|
|
|
}
|
2022-05-31 20:42:27 +00:00
|
|
|
|
|
|
|
TRACE_(imm)(" -> %s range %ld-%ld rect %s\n", ret ? "TRUE" : "FALSE", range->location,
|
2023-05-09 19:43:58 +00:00
|
|
|
range->length, wine_dbgstr_cgrect(query->ime_char_rect.rect));
|
2022-05-31 20:42:27 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-09 09:38:32 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* NotifyIMEStatus (X11DRV.@)
|
|
|
|
*/
|
|
|
|
void macdrv_NotifyIMEStatus( HWND hwnd, UINT status )
|
|
|
|
{
|
|
|
|
TRACE_(imm)( "hwnd %p, status %#x\n", hwnd, status );
|
|
|
|
if (!status) macdrv_clear_ime_text();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-11 03:58:26 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_query_event
|
|
|
|
*
|
2016-02-04 23:18:27 +00:00
|
|
|
* Handler for QUERY_EVENT and QUERY_EVENT_NO_PREEMPT_WAIT queries.
|
2013-03-11 03:58:26 +00:00
|
|
|
*/
|
2013-04-03 23:56:25 +00:00
|
|
|
static void macdrv_query_event(HWND hwnd, const macdrv_event *event)
|
2013-03-11 03:58:26 +00:00
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
macdrv_query *query = event->query_event.query;
|
|
|
|
|
|
|
|
switch (query->type)
|
|
|
|
{
|
2013-03-13 21:53:32 +00: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 21:48:39 +00:00
|
|
|
case QUERY_IME_CHAR_RECT:
|
|
|
|
TRACE("QUERY_IME_CHAR_RECT\n");
|
|
|
|
success = query_ime_char_rect(query);
|
|
|
|
break;
|
2013-03-11 03:58:51 +00:00
|
|
|
case QUERY_PASTEBOARD_DATA:
|
|
|
|
TRACE("QUERY_PASTEBOARD_DATA\n");
|
|
|
|
success = query_pasteboard_data(hwnd, query->pasteboard_data.type);
|
|
|
|
break;
|
2014-04-24 01:00:29 +00:00
|
|
|
case QUERY_RESIZE_SIZE:
|
|
|
|
TRACE("QUERY_RESIZE_SIZE\n");
|
|
|
|
success = query_resize_size(hwnd, query);
|
|
|
|
break;
|
2013-09-18 18:00:37 +00:00
|
|
|
case QUERY_RESIZE_START:
|
|
|
|
TRACE("QUERY_RESIZE_START\n");
|
|
|
|
success = query_resize_start(hwnd);
|
|
|
|
break;
|
2013-10-08 07:21:29 +00:00
|
|
|
case QUERY_MIN_MAX_INFO:
|
|
|
|
TRACE("QUERY_MIN_MAX_INFO\n");
|
|
|
|
success = query_min_max_info(hwnd);
|
|
|
|
break;
|
2013-03-11 03:58:26 +00: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 06:08:08 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_handle_event
|
|
|
|
*/
|
2013-04-03 23:56:25 +00:00
|
|
|
void macdrv_handle_event(const macdrv_event *event)
|
2013-01-21 06:08:08 +00: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)
|
|
|
|
{
|
2016-12-09 22:25:08 +00:00
|
|
|
case APP_ACTIVATED:
|
|
|
|
macdrv_app_activated();
|
|
|
|
break;
|
2013-01-27 22:19:56 +00:00
|
|
|
case APP_DEACTIVATED:
|
|
|
|
macdrv_app_deactivated();
|
|
|
|
break;
|
2013-04-03 23:56:55 +00:00
|
|
|
case APP_QUIT_REQUESTED:
|
|
|
|
macdrv_app_quit_requested(event);
|
|
|
|
break;
|
2013-02-18 01:28:34 +00:00
|
|
|
case DISPLAYS_CHANGED:
|
|
|
|
macdrv_displays_changed(event);
|
|
|
|
break;
|
2013-09-25 22:10:37 +00:00
|
|
|
case HOTKEY_PRESS:
|
|
|
|
macdrv_hotkey_press(event);
|
|
|
|
break;
|
2013-04-22 02:32:26 +00:00
|
|
|
case IM_SET_TEXT:
|
|
|
|
macdrv_im_set_text(event);
|
|
|
|
break;
|
2013-02-03 23:20:18 +00:00
|
|
|
case KEY_PRESS:
|
|
|
|
case KEY_RELEASE:
|
|
|
|
macdrv_key_event(hwnd, event);
|
|
|
|
break;
|
2013-02-03 23:20:15 +00:00
|
|
|
case KEYBOARD_CHANGED:
|
|
|
|
macdrv_keyboard_changed(event);
|
|
|
|
break;
|
2016-10-23 18:03:34 +00:00
|
|
|
case LOST_PASTEBOARD_OWNERSHIP:
|
|
|
|
macdrv_lost_pasteboard_ownership(hwnd);
|
|
|
|
break;
|
2013-01-27 22:19:37 +00:00
|
|
|
case MOUSE_BUTTON:
|
|
|
|
macdrv_mouse_button(hwnd, event);
|
|
|
|
break;
|
2022-06-03 00:00:15 +00:00
|
|
|
case MOUSE_MOVED_RELATIVE:
|
2013-02-07 01:32:26 +00:00
|
|
|
case MOUSE_MOVED_ABSOLUTE:
|
|
|
|
macdrv_mouse_moved(hwnd, event);
|
|
|
|
break;
|
2013-02-11 01:09:12 +00:00
|
|
|
case MOUSE_SCROLL:
|
|
|
|
macdrv_mouse_scroll(hwnd, event);
|
|
|
|
break;
|
2013-03-11 03:58:26 +00:00
|
|
|
case QUERY_EVENT:
|
2016-02-04 23:18:27 +00:00
|
|
|
case QUERY_EVENT_NO_PREEMPT_WAIT:
|
2013-03-11 03:58:26 +00:00
|
|
|
macdrv_query_event(hwnd, event);
|
|
|
|
break;
|
2015-10-05 20:44:28 +00:00
|
|
|
case REASSERT_WINDOW_POSITION:
|
|
|
|
macdrv_reassert_window_position(hwnd);
|
|
|
|
break;
|
2013-06-20 00:09:33 +00:00
|
|
|
case RELEASE_CAPTURE:
|
|
|
|
macdrv_release_capture(hwnd, event);
|
|
|
|
break;
|
2016-02-04 23:18:25 +00:00
|
|
|
case SENT_TEXT_INPUT:
|
|
|
|
macdrv_sent_text_input(event);
|
|
|
|
break;
|
2013-09-06 03:23:52 +00: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 03:40:54 +00:00
|
|
|
break;
|
2013-10-08 07:21:34 +00:00
|
|
|
case WINDOW_BROUGHT_FORWARD:
|
|
|
|
macdrv_window_brought_forward(hwnd);
|
|
|
|
break;
|
2013-01-21 06:08:12 +00:00
|
|
|
case WINDOW_CLOSE_REQUESTED:
|
|
|
|
macdrv_window_close_requested(hwnd);
|
|
|
|
break;
|
2021-10-19 21:21:12 +00:00
|
|
|
case WINDOW_DID_MINIMIZE:
|
|
|
|
macdrv_window_did_minimize(hwnd);
|
|
|
|
break;
|
2013-02-03 23:20:07 +00:00
|
|
|
case WINDOW_DID_UNMINIMIZE:
|
|
|
|
macdrv_window_did_unminimize(hwnd);
|
|
|
|
break;
|
2013-12-11 18:50:55 +00:00
|
|
|
case WINDOW_DRAG_BEGIN:
|
2017-04-24 18:07:10 +00:00
|
|
|
macdrv_window_drag_begin(hwnd, event);
|
2013-12-11 18:50:55 +00:00
|
|
|
break;
|
|
|
|
case WINDOW_DRAG_END:
|
|
|
|
macdrv_window_drag_end(hwnd);
|
|
|
|
break;
|
2013-01-27 22:19:29 +00:00
|
|
|
case WINDOW_FRAME_CHANGED:
|
2013-10-10 19:22:08 +00:00
|
|
|
macdrv_window_frame_changed(hwnd, event);
|
2013-01-27 22:19:29 +00:00
|
|
|
break;
|
2013-01-27 22:19:48 +00:00
|
|
|
case WINDOW_GOT_FOCUS:
|
|
|
|
macdrv_window_got_focus(hwnd, event);
|
|
|
|
break;
|
2013-01-27 22:19:53 +00:00
|
|
|
case WINDOW_LOST_FOCUS:
|
|
|
|
macdrv_window_lost_focus(hwnd, event);
|
|
|
|
break;
|
2013-12-30 03:34:48 +00:00
|
|
|
case WINDOW_MAXIMIZE_REQUESTED:
|
|
|
|
macdrv_window_maximize_requested(hwnd);
|
|
|
|
break;
|
2013-09-30 15:29:23 +00:00
|
|
|
case WINDOW_MINIMIZE_REQUESTED:
|
|
|
|
macdrv_window_minimize_requested(hwnd);
|
|
|
|
break;
|
2013-11-01 00:16:42 +00:00
|
|
|
case WINDOW_RESIZE_ENDED:
|
|
|
|
macdrv_window_resize_ended(hwnd);
|
|
|
|
break;
|
2013-12-30 03:34:48 +00:00
|
|
|
case WINDOW_RESTORE_REQUESTED:
|
2015-03-23 23:58:06 +00:00
|
|
|
macdrv_window_restore_requested(hwnd, event);
|
2013-12-30 03:34:48 +00:00
|
|
|
break;
|
2013-01-21 06:08:08 +00: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-03 23:56:35 +00:00
|
|
|
macdrv_event *event;
|
2013-01-21 06:08:08 +00:00
|
|
|
int count = 0;
|
|
|
|
|
2013-04-03 23:56:35 +00:00
|
|
|
while (macdrv_copy_event_from_queue(queue, mask, &event))
|
2013-01-21 06:08:08 +00:00
|
|
|
{
|
|
|
|
count++;
|
2013-04-03 23:56:35 +00:00
|
|
|
macdrv_handle_event(event);
|
|
|
|
macdrv_release_event(event);
|
2013-01-21 06:08:08 +00:00
|
|
|
}
|
|
|
|
if (count) TRACE("processed %d events\n", count);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2023-02-21 20:43:39 +00:00
|
|
|
* ProcessEvents (MACDRV.@)
|
2013-01-21 06:08:08 +00:00
|
|
|
*/
|
2023-02-24 09:30:28 +00:00
|
|
|
BOOL macdrv_ProcessEvents(DWORD mask)
|
2013-01-21 06:08:08 +00:00
|
|
|
{
|
|
|
|
struct macdrv_thread_data *data = macdrv_thread_data();
|
|
|
|
macdrv_event_mask event_mask = get_event_mask(mask);
|
|
|
|
|
2023-02-21 20:43:39 +00:00
|
|
|
TRACE("mask %x\n", (unsigned int)mask);
|
2013-01-21 06:08:08 +00:00
|
|
|
|
2023-02-21 20:43:39 +00:00
|
|
|
if (!data) return FALSE;
|
2013-01-21 06:08:08 +00:00
|
|
|
|
2013-04-03 23:56:55 +00:00
|
|
|
if (data->current_event && data->current_event->type != QUERY_EVENT &&
|
2016-02-04 23:18:27 +00:00
|
|
|
data->current_event->type != QUERY_EVENT_NO_PREEMPT_WAIT &&
|
2013-12-11 18:50:55 +00:00
|
|
|
data->current_event->type != APP_QUIT_REQUESTED &&
|
|
|
|
data->current_event->type != WINDOW_DRAG_BEGIN)
|
2013-03-13 21:52:57 +00:00
|
|
|
event_mask = 0; /* don't process nested events */
|
2013-01-21 06:08:08 +00:00
|
|
|
|
2023-02-21 20:43:39 +00:00
|
|
|
return process_events(data->queue, event_mask);
|
2013-01-21 06:08:08 +00:00
|
|
|
}
|