Fix working text related issues on NS (Bug#38851)

* src/keyboard.c (read_char): Prevent redsiplay right after
ns-unput-working-text event.
* src/nsterm.m ([EmacsView insertText:]): Partially revert commit
ba04217.
([EmacsView firstRectForCharacterRange:]): Fix candidate window
position when cursor is on echoarea.
([EmacsView mouseDown:])
([EmacsView windowDidResignKey:]): Don't delete working text.
This commit is contained in:
Masahiro Nakamura 2020-02-14 03:21:15 +09:00 committed by Alan Third
parent 1a75e8b7e0
commit b3de1302ca
2 changed files with 16 additions and 8 deletions

View file

@ -2901,6 +2901,12 @@ read_char (int commandflag, Lisp_Object map,
example banishing the mouse under mouse-avoidance-mode. */
timer_resume_idle ();
#ifdef HAVE_NS
if (CONSP (c)
&& (EQ (XCAR (c), intern ("ns-unput-working-text"))))
input_was_pending = input_pending;
#endif
if (current_buffer != prev_buffer)
{
/* The command may have changed the keymaps. Pretend there

View file

@ -6457,6 +6457,10 @@ - (void)insertText: (id)aString
if (!emacs_event)
return;
/* First, clear any working text. */
if (workingText != nil)
[self deleteWorkingText];
/* It might be preferable to use getCharacters:range: below,
cf. https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CocoaPerformance/Articles/StringDrawing.html#//apple_ref/doc/uid/TP40001445-112378.
However, we probably can't use SAFE_NALLOCA here because it might
@ -6485,10 +6489,6 @@ - (void)insertText: (id)aString
emacs_event->code = code;
EV_TRAILER ((id)nil);
}
/* Last, clear any working text. */
if (workingText != nil)
[self deleteWorkingText];
}
@ -6584,13 +6584,18 @@ - (NSRect)firstRectForCharacterRange: (NSRange)theRange
{
NSRect rect;
NSPoint pt;
struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
struct window *win;
NSTRACE ("[EmacsView firstRectForCharacterRange:]");
if (NS_KEYLOG)
NSLog (@"firstRectForCharRange request");
if (WINDOWP (echo_area_window) && ! NILP (call0 (intern ("ns-in-echo-area"))))
win = XWINDOW (echo_area_window);
else
win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
@ -6697,8 +6702,6 @@ - (void)mouseDown: (NSEvent *)theEvent
NSTRACE ("[EmacsView mouseDown:]");
[self deleteWorkingText];
if (!emacs_event)
return;
@ -7325,7 +7328,6 @@ - (void)windowDidResignKey: (NSNotification *)notification
if (emacs_event && is_focus_frame)
{
[self deleteWorkingText];
emacs_event->kind = FOCUS_OUT_EVENT;
EV_TRAILER ((id)nil);
}