Commit 07b87a10 authored by Adrian Robert's avatar Adrian Robert
Browse files

fix popup menu selection return (menu.c); add use of popup_activated under NS...

fix popup menu selection return (menu.c); add use of popup_activated under NS (nsmenu.m, xdisp.c); improve comments (lisp.h, s/darwin.h); use FORWARD_SIGNAL_TO_MAIN_THREAD (syssignal.h)
parent 14145fa3
......@@ -4,6 +4,18 @@
* keyboard.h: Comment an #endif.
* lisp.h (have_menus_p): Adjust comment.
* menu.c (find_and_return_menu_selection): Fix comparison with
client_data.
* nsmenu.m (popup_activated_flag): New variable.
(popup_activated): New function.
(menu-or-popup-active-p): New exported lisp definition.
(ns_popup_menu): Set popup_activated_flag. Call discard_menu_items()
when popup done.
(ns_popup_dialog): Set popup_activated_flag.
* nsterm.m (EmacsView -converstationIdentifier): Use NSInteger
version for GNUstep (handled by conditional typedef in nsterm.m).
(ns_get_color): Remove special-casing for "darkblue", "dark blue" (now
......@@ -13,11 +25,17 @@
* sysselect.h: Conditionalize init_process undef on DARWIN_OS.
* syssignal.h (FORWARD_SIGNAL_TO_MAIN_THREAD): Do it also under NS.
* xdisp.c (redisplay_internal, note_mouse_highlight): Under NS,
shortcircuit if popup_activated like GTK and X toolkit.
* m/inter386.h: Change DARWIN to DARWIN_OS.
* s/darwin.h: Add #define DARWIN_OS. Get rid of C_SWITCH_SYSTEM def.
Change LIBS_MACGUI to LIBS_NSGUI. Move temacs-conditionalized defs
closer to C_SWITCH_SYSTEM_TEMACS so usage is understood.
closer to C_SWITCH_SYSTEM_TEMACS so usage is understood. Expand
comment on NO_SOCK_SIGIO.
2008-08-03 Chong Yidong <cyd@stupidchicken.com>
......
......@@ -3332,7 +3332,7 @@ EXFUN (Fmsdos_downcase_filename, 1);
#endif
#ifdef HAVE_MENUS
/* Defined in (x|w32)fns.c... */
/* Defined in (x|w32)fns.c, nsfns.m... */
extern int have_menus_p P_ ((void));
#endif
......
......@@ -1005,7 +1005,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
{
entry
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
if ((int) (EMACS_INT)client_data == i)
if ((int) (EMACS_INT)client_data == &XVECTOR (menu_items)->contents[i]/*i*/)
{
if (keymaps != 0)
{
......
......@@ -65,6 +65,9 @@
extern long context_menu_value;
EmacsMenu *mainMenu, *svcsMenu;
/* Nonzero means a menu is currently active. */
static int popup_activated_flag;
/* NOTE: toolbar implementation is at end,
following complete menu implementation. */
......@@ -94,6 +97,13 @@
}
int
popup_activated ()
{
return popup_activated_flag;
}
/* --------------------------------------------------------------------------
Update menubar. Three cases:
1) deep_p = 0, submenu = nil: Fresh switch onto a frame -- either set up
......@@ -592,6 +602,7 @@ -(NSString *)parseKeyEquiv: (char *)key
return [NSString stringWithFormat: @"%c", tpos[2]];
}
- (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr
{
NSMenuItem *item;
......@@ -1117,10 +1128,13 @@ key equivalents (see below) because the keydefs in ns-win.el have
free_menubar_widget_value_tree (first_wv);
unbind_to (specpdl_count2, Qnil);
popup_activated_flag = 1;
tem = [pmenu runMenuAt: p forFrame: f keymaps: keymaps];
popup_activated_flag = 0;
[[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
UNBLOCK_INPUT;
discard_menu_items ();
unbind_to (specpdl_count, Qnil);
UNGCPRO;
......@@ -1511,8 +1525,9 @@ - (NSRect) frame
p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2;
dialog = [[EmacsDialogPanel alloc] initFromContents: contents
isQuestion: isQ];
popup_activated_flag = 1;
tem = [dialog runDialogAt: p];
popup_activated_flag = 0;
[dialog close];
......@@ -1934,6 +1949,12 @@ Each ITEM is a cons cell (STRING . VALUE).
return ns_popup_dialog (position, contents, header);
}
DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
doc: /* Return t if a menu or popup dialog is active. */)
()
{
return popup_activated () ? Qt : Qnil;
}
/* ==========================================================================
......@@ -1947,6 +1968,7 @@ Each ITEM is a cons cell (STRING . VALUE).
defsubr (&Sx_popup_menu);
defsubr (&Sx_popup_dialog);
defsubr (&Sns_reset_menu);
defsubr (&Smenu_or_popup_active_p);
staticpro (&menu_items);
menu_items = Qnil;
......
......@@ -134,7 +134,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define HAVE_SOCKETS
/* This seems to help in Ctrl-G detection under Cocoa, however at the cost
of some quirks that may or may not bother a given user. */
of some quirks that may or may not bother a given user.
It was earlier commented that "In Carbon, asynchronous I/O (using SIGIO)
can't be used for window events because they don't come from sockets,
even though it works fine on tty's. Uncertain about situation in Cocoa. */
#ifdef COCOA_EXPERIMENTAL_CTRL_G
#define NO_SOCK_SIGIO
#endif
......
......@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
extern void init_signals P_ ((void));
#if defined (HAVE_GTK_AND_PTHREAD)
#if defined (HAVE_GTK_AND_PTHREAD) || defined (HAVE_NS)
#include <pthread.h>
/* If defined, asynchronous signals delivered to a non-main thread are
forwarded to the main thread. */
......
......@@ -11349,7 +11349,7 @@ redisplay_internal (preserve_echo_area)
return;
}
#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
if (popup_activated ())
return;
#endif
......@@ -23521,7 +23521,7 @@ note_mouse_highlight (f, x, y)
struct buffer *b;
/* When a menu is active, don't highlight because this looks odd. */
#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
if (popup_activated ())
return;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment