Aric Stewart : macdrv: Rework the way we handle cursor position and composition text.
Alexandre Julliard
julliard at winehq.org
Thu May 30 14:51:33 CDT 2013
Module: wine
Branch: master
Commit: c6d307533b87d780937c4118f9c3f158dd314b8b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c6d307533b87d780937c4118f9c3f158dd314b8b
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed May 29 13:11:57 2013 -0500
macdrv: Rework the way we handle cursor position and composition text.
---
dlls/winemac.drv/cocoa_window.m | 9 +----
dlls/winemac.drv/event.c | 5 --
dlls/winemac.drv/ime.c | 85 ++++++++++++--------------------------
dlls/winemac.drv/macdrv.h | 1 -
dlls/winemac.drv/macdrv_cocoa.h | 6 +--
5 files changed, 29 insertions(+), 77 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index a47715a..5ee1aac 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -356,14 +356,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
event->im_set_text.data = [window imeData];
event->im_set_text.text = (CFStringRef)[[markedText string] copy];
event->im_set_text.complete = FALSE;
-
- [[window queue] postEvent:event];
-
- macdrv_release_event(event);
-
- event = macdrv_create_event(IM_SET_CURSOR_POS, window);
- event->im_set_cursor_pos.data = [window imeData];
- event->im_set_cursor_pos.pos = markedTextSelection.location;
+ event->im_set_text.cursor_pos = markedTextSelection.location;
[[window queue] postEvent:event];
diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c
index 51f6723..deac187 100644
--- a/dlls/winemac.drv/event.c
+++ b/dlls/winemac.drv/event.c
@@ -35,7 +35,6 @@ static const char *dbgstr_event(int type)
"APP_DEACTIVATED",
"APP_QUIT_REQUESTED",
"DISPLAYS_CHANGED",
- "IM_SET_CURSOR_POS",
"IM_SET_TEXT",
"KEY_PRESS",
"KEY_RELEASE",
@@ -92,7 +91,6 @@ static macdrv_event_mask get_event_mask(DWORD mask)
event_mask |= event_mask_for_type(APP_DEACTIVATED);
event_mask |= event_mask_for_type(APP_QUIT_REQUESTED);
event_mask |= event_mask_for_type(DISPLAYS_CHANGED);
- event_mask |= event_mask_for_type(IM_SET_CURSOR_POS);
event_mask |= event_mask_for_type(IM_SET_TEXT);
event_mask |= event_mask_for_type(STATUS_ITEM_CLICKED);
event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
@@ -181,9 +179,6 @@ void macdrv_handle_event(const macdrv_event *event)
case DISPLAYS_CHANGED:
macdrv_displays_changed(event);
break;
- case IM_SET_CURSOR_POS:
- macdrv_im_set_cursor_pos(event);
- break;
case IM_SET_TEXT:
macdrv_im_set_text(event);
break;
diff --git a/dlls/winemac.drv/ime.c b/dlls/winemac.drv/ime.c
index 44d5d8b..bed094d 100644
--- a/dlls/winemac.drv/ime.c
+++ b/dlls/winemac.drv/ime.c
@@ -940,15 +940,14 @@ UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROCW lpfnEnumProc, LPCWSTR lpsz
return 0;
}
-BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
- LPCVOID lpRead, DWORD dwReadLen)
+static BOOL IME_SetCompositionString(void* hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, DWORD cursor_pos, BOOL cursor_valid)
{
LPINPUTCONTEXT lpIMC;
DWORD flags = 0;
WCHAR wParam = 0;
LPIMEPRIVATE myPrivate;
- TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
+ TRACE("(%p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen);
/*
* Explanation:
@@ -957,9 +956,6 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
* TODO: set the Cocoa window's marked text string and tell text input context
*/
- if (lpRead && dwReadLen)
- FIXME("Reading string unimplemented\n");
-
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
@@ -985,8 +981,8 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr;
- wParam = ((const WCHAR*)lpComp)[0];
- flags |= GCS_COMPCLAUSE | GCS_COMPATTR | GCS_DELTASTART;
+ wParam = ((const WCHAR*)lpComp)[0];
+ flags |= GCS_COMPCLAUSE | GCS_COMPATTR | GCS_DELTASTART;
}
else
{
@@ -994,6 +990,16 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr;
}
+
+ if (cursor_valid)
+ {
+ LPCOMPOSITIONSTRING compstr;
+ compstr = ImmLockIMCC(lpIMC->hCompStr);
+ compstr->dwCursorPos = cursor_pos;
+ ImmUnlockIMCC(lpIMC->hCompStr);
+ flags |= GCS_CURSORPOS;
+ }
+
}
GenerateIMEMessage(hIMC, WM_IME_COMPOSITION, wParam, flags);
@@ -1003,44 +1009,23 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
return TRUE;
}
-DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu,
- LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize)
-{
- FIXME("(%p, %x %x %p %p %x): stub\n", hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-static void IME_SetCursorPos(void* hIMC, DWORD pos)
+BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
+ LPCVOID lpRead, DWORD dwReadLen)
{
- LPINPUTCONTEXT lpIMC;
- LPCOMPOSITIONSTRING compstr;
-
- if (!hSelectedFrom)
- return;
-
- lpIMC = LockRealIMC(hIMC);
- if (!lpIMC)
- return;
+ TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
- compstr = ImmLockIMCC(lpIMC->hCompStr);
- if (!compstr)
- {
- UnlockRealIMC(hIMC);
- return;
- }
+ if (lpRead && dwReadLen)
+ FIXME("Reading string unimplemented\n");
- compstr->dwCursorPos = pos;
- ImmUnlockIMCC(lpIMC->hCompStr);
- UnlockRealIMC(hIMC);
- GenerateIMEMessage(FROM_MACDRV, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
- return;
+ return IME_SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, 0, FALSE);
}
-
-static void IME_SetCompositionString(void* hIMC, LPCVOID lpComp, DWORD dwCompLen)
+DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu,
+ LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize)
{
- ImeSetCompositionString(hIMC, SCS_SETSTR, lpComp, dwCompLen, NULL, 0);
+ FIXME("(%p, %x %x %p %p %x): stub\n", hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return 0;
}
static void IME_NotifyComplete(void* hIMC)
@@ -1437,23 +1422,6 @@ void IME_RegisterClasses(HINSTANCE hImeInst)
WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
}
-
-/***********************************************************************
- * macdrv_im_set_cursor_pos
- */
-void macdrv_im_set_cursor_pos(const macdrv_event *event)
-{
- HWND hwnd = macdrv_get_window_hwnd(event->window);
- void *himc = event->im_set_cursor_pos.data;
-
- TRACE("win %p/%p himc %p pos %u\n", hwnd, event->window, himc, event->im_set_cursor_pos.pos);
-
- if (!himc) himc = RealIMC(FROM_MACDRV);
-
- IME_SetCursorPos(himc, event->im_set_cursor_pos.pos);
-}
-
-
/***********************************************************************
* macdrv_im_set_text
*/
@@ -1481,7 +1449,8 @@ void macdrv_im_set_text(const macdrv_event *event)
}
if (himc)
- IME_SetCompositionString(himc, chars, length * sizeof(*chars));
+ IME_SetCompositionString(himc, SCS_SETSTR, chars, length * sizeof(*chars),
+ event->im_set_text.cursor_pos, !event->im_set_text.complete);
else
{
INPUT input;
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h
index 1010ded..8e0b0f8 100644
--- a/dlls/winemac.drv/macdrv.h
+++ b/dlls/winemac.drv/macdrv.h
@@ -202,7 +202,6 @@ extern void IME_RegisterClasses(HINSTANCE hImeInst) DECLSPEC_HIDDEN;
extern BOOL macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *key_state,
void *himc) DECLSPEC_HIDDEN;
-extern void macdrv_im_set_cursor_pos(const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_im_set_text(const macdrv_event *event) DECLSPEC_HIDDEN;
extern BOOL query_ime_char_rect(macdrv_query* query) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index e7e2c4c..96a9592 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -165,7 +165,6 @@ enum {
APP_DEACTIVATED,
APP_QUIT_REQUESTED,
DISPLAYS_CHANGED,
- IM_SET_CURSOR_POS,
IM_SET_TEXT,
KEY_PRESS,
KEY_RELEASE,
@@ -208,11 +207,8 @@ typedef struct macdrv_event {
} displays_changed;
struct {
void *data;
- unsigned int pos;
- } im_set_cursor_pos;
- struct {
- void *data;
CFStringRef text; /* new text or NULL if just completing existing text */
+ unsigned int cursor_pos;
unsigned int complete; /* is completing text? */
} im_set_text;
struct {
More information about the wine-cvs
mailing list