winemac.drv: Allow mac IME to clear text in system input method.

Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Aric Stewart 2019-05-06 11:30:14 -05:00 committed by Alexandre Julliard
parent 3736c36736
commit db3864e5b3
3 changed files with 26 additions and 4 deletions

View File

@ -702,6 +702,13 @@ - (void) viewDidUnhide
[self invalidateHasGLDescendant];
}
- (void) clearMarkedText
{
[markedText deleteCharactersInRange:NSMakeRange(0, [markedText length])];
markedTextSelection = NSMakeRange(0, 0);
[[self inputContext] discardMarkedText];
}
- (void) completeText:(NSString*)text
{
macdrv_event* event;
@ -716,9 +723,7 @@ - (void) completeText:(NSString*)text
macdrv_release_event(event);
[markedText deleteCharactersInRange:NSMakeRange(0, [markedText length])];
markedTextSelection = NSMakeRange(0, 0);
[[self inputContext] discardMarkedText];
[self clearMarkedText];
}
- (void) didAddSubview:(NSView*)subview
@ -3907,3 +3912,18 @@ void macdrv_send_text_input_event(int pressed, unsigned int flags, int repeat, i
macdrv_release_event(event);
});
}
void macdrv_clear_ime_text(void)
{
OnMainThreadAsync(^{
WineWindow* window = (WineWindow*)[NSApp keyWindow];
if (![window isKindOfClass:[WineWindow class]])
{
window = (WineWindow*)[NSApp mainWindow];
if (![window isKindOfClass:[WineWindow class]])
window = [[WineApplicationController sharedController] frontWineWindow];
}
if (window)
[[window contentView] clearMarkedText];
});
}

View File

@ -76,7 +76,6 @@ static UINT WM_MSIME_RECONVERT;
static UINT WM_MSIME_QUERYPOSITION;
static UINT WM_MSIME_DOCUMENTFEED;
static HIMC RealIMC(HIMC hIMC)
{
if (hIMC == FROM_MACDRV)
@ -840,6 +839,7 @@ BOOL WINAPI NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
TRACE("NI_COMPOSITIONSTR: CPS_CANCEL\n");
macdrv_clear_ime_text();
if (lpIMC->hCompStr)
ImmDestroyIMCC(lpIMC->hCompStr);

View File

@ -580,4 +580,6 @@ extern void macdrv_get_input_source_info(CFDataRef* uchr,CGEventSourceKeyboardTy
extern void macdrv_set_status_item_image(macdrv_status_item s, CGImageRef cgimage) DECLSPEC_HIDDEN;
extern void macdrv_set_status_item_tooltip(macdrv_status_item s, CFStringRef cftip) DECLSPEC_HIDDEN;
extern void macdrv_clear_ime_text(void) DECLSPEC_HIDDEN;
#endif /* __WINE_MACDRV_COCOA_H */