]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix working text related issues on NS (Bug#38851)
authorMasahiro Nakamura <tsuucat@icloud.com>
Thu, 13 Feb 2020 18:21:15 +0000 (03:21 +0900)
committerAlan Third <alan@idiocy.org>
Wed, 19 Feb 2020 11:07:58 +0000 (11:07 +0000)
* 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.

src/keyboard.c
src/nsterm.m

index bf1f5da22d31846d8a6a8bfb283d4995d6ee58f4..9dd7e00709e19653a4f2bfa0f9a367470b5454a8 100644 (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
index f31ba5de89639644885125bd4e92d9d2c6136459..c0535825eeeddee3c86cbc9e23d58938952147d5 100644 (file)
@@ -6457,6 +6457,10 @@ not_in_argv (NSString *arg)
   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 @@ not_in_argv (NSString *arg)
       emacs_event->code = code;
       EV_TRAILER ((id)nil);
     }
-
-  /* Last, clear any working text.  */
-  if (workingText != nil)
-    [self deleteWorkingText];
 }
 
 
@@ -6584,13 +6584,18 @@ not_in_argv (NSString *arg)
 {
   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 @@ not_in_argv (NSString *arg)
 
   NSTRACE ("[EmacsView mouseDown:]");
 
-  [self deleteWorkingText];
-
   if (!emacs_event)
     return;
 
@@ -7325,7 +7328,6 @@ not_in_argv (NSString *arg)
 
   if (emacs_event && is_focus_frame)
     {
-      [self deleteWorkingText];
       emacs_event->kind = FOCUS_OUT_EVENT;
       EV_TRAILER ((id)nil);
     }