winemac: Actually set the system's keyboard layout.

This commit is contained in:
Huw Davies 2013-11-20 15:30:38 +00:00 committed by Alexandre Julliard
parent f6e2af6843
commit c4761d8002
3 changed files with 29 additions and 63 deletions

View File

@ -2503,3 +2503,14 @@ CFArrayRef macdrv_create_input_source_list(void)
return ret;
}
int macdrv_select_input_source(TISInputSourceRef input_source)
{
__block int ret = FALSE;
OnMainThread(^{
ret = (TISSelectInputSource(input_source) == noErr);
});
return ret;
}

View File

@ -1114,48 +1114,6 @@ void macdrv_hotkey_press(const macdrv_event *event)
}
/***********************************************************************
* get_locale_keyboard_layout
*/
static HKL get_locale_keyboard_layout(void)
{
ULONG_PTR layout;
LANGID langid;
layout = GetUserDefaultLCID();
/*
* Microsoft Office expects this value to be something specific
* for Japanese and Korean Windows with an IME the value is 0xe001
* We should probably check to see if an IME exists and if so then
* set this word properly.
*/
langid = PRIMARYLANGID(LANGIDFROMLCID(layout));
if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
layout |= 0xe001 << 16; /* IME */
else
layout |= layout << 16;
return (HKL)layout;
}
/***********************************************************************
* match_keyboard_layout
*/
static BOOL match_keyboard_layout(HKL hkl)
{
const DWORD isIME = 0xE0000000;
HKL current_hkl = get_locale_keyboard_layout();
/* if the layout is an IME, only match the low word (LCID) */
if (((ULONG_PTR)hkl & isIME) == isIME)
return (LOWORD(hkl) == LOWORD(current_hkl));
else
return (hkl == current_hkl);
}
/***********************************************************************
* macdrv_process_text_input
*/
@ -1210,20 +1168,11 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags)
{
HKL oldHkl = 0;
struct macdrv_thread_data *thread_data = macdrv_init_thread_data();
struct layout *layout;
/* FIXME: Use Text Input Services or NSTextInputContext to actually
change the Mac keyboard input source. */
TRACE("hkl %p flags %04x\n", hkl, flags);
FIXME("hkl %p flags %04x: semi-stub!\n", hkl, flags);
if (flags & KLF_SETFORPROCESS)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
FIXME("KLF_SETFORPROCESS not supported\n");
return 0;
}
if (flags)
FIXME("flags %x not supported\n",flags);
if (flags) FIXME("flags %x not supported\n",flags);
if (hkl == (HKL)HKL_NEXT || hkl == (HKL)HKL_PREV)
{
@ -1232,17 +1181,22 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags)
return 0;
}
if (!match_keyboard_layout(hkl))
EnterCriticalSection(&layout_list_section);
update_layout_list();
LIST_FOR_EACH_ENTRY(layout, &layout_list, struct layout, entry)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
FIXME("setting keyboard of different locales not supported\n");
return 0;
if (layout->hkl == hkl)
{
if (macdrv_select_input_source(layout->input_source))
{
oldHkl = thread_data->active_keyboard_layout;
thread_data->active_keyboard_layout = hkl;
}
break;
}
}
oldHkl = thread_data->active_keyboard_layout;
if (!oldHkl) oldHkl = macdrv_GetKeyboardLayout(0);
thread_data->active_keyboard_layout = hkl;
LeaveCriticalSection(&layout_list_section);
return oldHkl;
}

View File

@ -415,6 +415,7 @@ extern int macdrv_send_text_input_event(int pressed, unsigned int flags, int rep
extern void macdrv_get_input_source_info(CFDataRef* uchr,CGEventSourceKeyboardType* keyboard_type, int* is_iso,
TISInputSourceRef* input_source) DECLSPEC_HIDDEN;
extern CFArrayRef macdrv_create_input_source_list(void) DECLSPEC_HIDDEN;
extern int macdrv_select_input_source(TISInputSourceRef input_source) DECLSPEC_HIDDEN;
extern const CFStringRef macdrv_input_source_input_key DECLSPEC_HIDDEN;
extern const CFStringRef macdrv_input_source_type_key DECLSPEC_HIDDEN;
extern const CFStringRef macdrv_input_source_lang_key DECLSPEC_HIDDEN;