unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* system "key" events in NS port
@ 2009-03-11  3:18 David Reitter
  2009-03-11 14:27 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: David Reitter @ 2009-03-11  3:18 UTC (permalink / raw)
  To: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 3478 bytes --]

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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2193 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: system "key" events in NS port
  2009-03-11  3:18 system "key" events in NS port David Reitter
@ 2009-03-11 14:27 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2009-03-11 14:27 UTC (permalink / raw)
  To: David Reitter; +Cc: Emacs-Devel devel

> 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.

I think the right way to do it is to add a new event_kind rather than
abuse `arg'.


        Stefan





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-11 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-11  3:18 system "key" events in NS port David Reitter
2009-03-11 14:27 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).