emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

system "key" events in NS port


From: David Reitter
Subject: system "key" events in NS port
Date: Tue, 10 Mar 2009 23:18:03 -0400

The events sent in the NS port to signal menu actions such as "Quit Emacs" (application menu) are sent as NON_ASCII_KEYSTROKE_EVENTs, which lead to last_nonmenu_event being set. This is unfortunate, because functions like y-or-n-p depend on the variable to decide whether to show a graphical dialog when the mouse was used.

The patch below has an #ifdef HAVE_NS, which can be removed should other platforms exhibit the same problem.

Note that the EVENT_INIT macro will zero the input_event structure so that ->arg should be NULL unless explicitly set.
Does this look safe?


*** termhooks.h 25 Jan 2009 14:43:35 -0500      1.101
--- termhooks.h 10 Mar 2009 23:04:55 -0400      
***************
*** 246,253 ****
       does not overlap with it.  */
    Lisp_Object frame_or_window;

!   /* Additional event argument.  This is used for TOOL_BAR_EVENTs and
!      HELP_EVENTs and avoids calling Fcons during signal handling.  */
    Lisp_Object arg;
  };

--- 246,254 ----
       does not overlap with it.  */
    Lisp_Object frame_or_window;

!   /* Additional event argument.  This is used for TOOL_BAR_EVENTs,
!      HELP_EVENTs, and some rare NON_ASCII_KEYSTROKE_EVENTs
!      and avoids calling Fcons during signal handling.  */
    Lisp_Object arg;
  };

*** keyboard.c  12 Feb 2009 13:20:56 -0500      1.996
--- keyboard.c  10 Mar 2009 23:02:44 -0400      
***************
*** 4158,4163 ****
--- 4158,4164 ----
            else
              obj = Fcons (intern ("ns-unput-working-text"), Qnil);
          kbd_fetch_ptr = event + 1;
+         *used_mouse_menu = 1;
          }
  #endif

***************
*** 4312,4317 ****
--- 4313,4325 ----
                      || event->kind == TOOL_BAR_EVENT))
                *used_mouse_menu = 1;
  #endif
+ #ifdef HAVE_NS
+             /* for certain system events, event->arg is used to indicate
+                a non-key event. */
+             if (event->kind == NON_ASCII_KEYSTROKE_EVENT
+                 && event->arg && !NILP (event->arg))
+               *used_mouse_menu = 1;
+ #endif

              /* Wipe out this event, to catch bugs.  */
              clear_event (event);

*** nsterm.m    6 Mar 2009 19:07:00 -0000       1.65
--- nsterm.m    11 Mar 2009 02:52:23 -0000
***************
*** 4120,4125 ****
--- 4147,4153 ----
    emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
    emacs_event->code = KEY_NS_NEW_FRAME;
    emacs_event->modifiers = 0;
+   emacs_event->arg = Qt; /* mark as non-key event */
    EV_TRAILER (theEvent);
  }

***************
*** 4135,4140 ****
--- 4163,4169 ----

    emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
    emacs_event->code = KEY_NS_OPEN_FILE_LINE;
+   emacs_event->arg = Qt; /* mark as non-key event */
ns_input_file = append2 (ns_input_file, build_string ([fileName UTF8String]));
    ns_input_line = Qnil; /* can be start or cons start,end */
    emacs_event->modifiers =0;
***************
*** 4363,4368 ****
--- 4387,4393 ----
    ns_input_spi_name = build_string ([name UTF8String]);
    ns_input_spi_arg = build_string ([arg UTF8String]);
    emacs_event->modifiers = EV_MODIFIERS (theEvent);
+   emacs_event->arg = Qt; /* mark as non-key event */
    EV_TRAILER (theEvent);

    return YES;
***************
*** 4417,4422 ****
--- 4442,4448 ----
        emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
        emacs_event->modifiers = 0;
        emacs_event->code = KEY_NS_CHANGE_FONT;
+       emacs_event->arg = Qt; /* mark as non-key event */

        size = [newFont pointSize];
        ns_input_fontsize = make_number (lrint (size));

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]