Commit c4761d80 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winemac: Actually set the system's keyboard layout.

parent f6e2af68
...@@ -2503,3 +2503,14 @@ CFArrayRef macdrv_create_input_source_list(void) ...@@ -2503,3 +2503,14 @@ CFArrayRef macdrv_create_input_source_list(void)
return ret; return ret;
} }
int macdrv_select_input_source(TISInputSourceRef input_source)
{
__block int ret = FALSE;
OnMainThread(^{
ret = (TISSelectInputSource(input_source) == noErr);
});
return ret;
}
...@@ -1115,48 +1115,6 @@ void macdrv_hotkey_press(const macdrv_event *event) ...@@ -1115,48 +1115,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 * macdrv_process_text_input
*/ */
BOOL macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *key_state, void *himc) BOOL macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *key_state, void *himc)
...@@ -1210,20 +1168,11 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) ...@@ -1210,20 +1168,11 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags)
{ {
HKL oldHkl = 0; HKL oldHkl = 0;
struct macdrv_thread_data *thread_data = macdrv_init_thread_data(); struct macdrv_thread_data *thread_data = macdrv_init_thread_data();
struct layout *layout;
/* FIXME: Use Text Input Services or NSTextInputContext to actually TRACE("hkl %p flags %04x\n", hkl, flags);
change the Mac keyboard input source. */
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) if (flags) FIXME("flags %x not supported\n",flags);
FIXME("flags %x not supported\n",flags);
if (hkl == (HKL)HKL_NEXT || hkl == (HKL)HKL_PREV) if (hkl == (HKL)HKL_NEXT || hkl == (HKL)HKL_PREV)
{ {
...@@ -1232,17 +1181,22 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) ...@@ -1232,17 +1181,22 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags)
return 0; 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); if (layout->hkl == hkl)
FIXME("setting keyboard of different locales not supported\n"); {
return 0; if (macdrv_select_input_source(layout->input_source))
{
oldHkl = thread_data->active_keyboard_layout;
thread_data->active_keyboard_layout = hkl;
}
break;
}
} }
LeaveCriticalSection(&layout_list_section);
oldHkl = thread_data->active_keyboard_layout;
if (!oldHkl) oldHkl = macdrv_GetKeyboardLayout(0);
thread_data->active_keyboard_layout = hkl;
return oldHkl; return oldHkl;
} }
......
...@@ -415,6 +415,7 @@ extern int macdrv_send_text_input_event(int pressed, unsigned int flags, int rep ...@@ -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, extern void macdrv_get_input_source_info(CFDataRef* uchr,CGEventSourceKeyboardType* keyboard_type, int* is_iso,
TISInputSourceRef* input_source) DECLSPEC_HIDDEN; TISInputSourceRef* input_source) DECLSPEC_HIDDEN;
extern CFArrayRef macdrv_create_input_source_list(void) 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_input_key DECLSPEC_HIDDEN;
extern const CFStringRef macdrv_input_source_type_key DECLSPEC_HIDDEN; extern const CFStringRef macdrv_input_source_type_key DECLSPEC_HIDDEN;
extern const CFStringRef macdrv_input_source_lang_key DECLSPEC_HIDDEN; extern const CFStringRef macdrv_input_source_lang_key DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment