aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdrian Robert2008-08-04 16:57:44 +0000
committerAdrian Robert2008-08-04 16:57:44 +0000
commit07b87a106a72dc6647dbe5910c78506c576f5399 (patch)
tree957ced55f63c30149b269ae1d4f8b8429eea23cb /src
parent14145fa3d03d61fec15d5939b5c4417c9d6472d9 (diff)
downloademacs-07b87a106a72dc6647dbe5910c78506c576f5399.tar.gz
emacs-07b87a106a72dc6647dbe5910c78506c576f5399.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog20
-rw-r--r--src/lisp.h2
-rw-r--r--src/menu.c2
-rw-r--r--src/nsmenu.m24
-rw-r--r--src/s/darwin.h5
-rw-r--r--src/syssignal.h2
-rw-r--r--src/xdisp.c4
7 files changed, 51 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b6ef8670e75..f4ad592bb33 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -4,6 +4,18 @@
4 4
5 * keyboard.h: Comment an #endif. 5 * keyboard.h: Comment an #endif.
6 6
7 * lisp.h (have_menus_p): Adjust comment.
8
9 * menu.c (find_and_return_menu_selection): Fix comparison with
10 client_data.
11
12 * nsmenu.m (popup_activated_flag): New variable.
13 (popup_activated): New function.
14 (menu-or-popup-active-p): New exported lisp definition.
15 (ns_popup_menu): Set popup_activated_flag. Call discard_menu_items()
16 when popup done.
17 (ns_popup_dialog): Set popup_activated_flag.
18
7 * nsterm.m (EmacsView -converstationIdentifier): Use NSInteger 19 * nsterm.m (EmacsView -converstationIdentifier): Use NSInteger
8 version for GNUstep (handled by conditional typedef in nsterm.m). 20 version for GNUstep (handled by conditional typedef in nsterm.m).
9 (ns_get_color): Remove special-casing for "darkblue", "dark blue" (now 21 (ns_get_color): Remove special-casing for "darkblue", "dark blue" (now
@@ -13,11 +25,17 @@
13 25
14 * sysselect.h: Conditionalize init_process undef on DARWIN_OS. 26 * sysselect.h: Conditionalize init_process undef on DARWIN_OS.
15 27
28 * syssignal.h (FORWARD_SIGNAL_TO_MAIN_THREAD): Do it also under NS.
29
30 * xdisp.c (redisplay_internal, note_mouse_highlight): Under NS,
31 shortcircuit if popup_activated like GTK and X toolkit.
32
16 * m/inter386.h: Change DARWIN to DARWIN_OS. 33 * m/inter386.h: Change DARWIN to DARWIN_OS.
17 34
18 * s/darwin.h: Add #define DARWIN_OS. Get rid of C_SWITCH_SYSTEM def. 35 * s/darwin.h: Add #define DARWIN_OS. Get rid of C_SWITCH_SYSTEM def.
19 Change LIBS_MACGUI to LIBS_NSGUI. Move temacs-conditionalized defs 36 Change LIBS_MACGUI to LIBS_NSGUI. Move temacs-conditionalized defs
20 closer to C_SWITCH_SYSTEM_TEMACS so usage is understood. 37 closer to C_SWITCH_SYSTEM_TEMACS so usage is understood. Expand
38 comment on NO_SOCK_SIGIO.
21 39
222008-08-03 Chong Yidong <cyd@stupidchicken.com> 402008-08-03 Chong Yidong <cyd@stupidchicken.com>
23 41
diff --git a/src/lisp.h b/src/lisp.h
index cd9d0f5585a..0e9c8b7c799 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3332,7 +3332,7 @@ EXFUN (Fmsdos_downcase_filename, 1);
3332#endif 3332#endif
3333 3333
3334#ifdef HAVE_MENUS 3334#ifdef HAVE_MENUS
3335/* Defined in (x|w32)fns.c... */ 3335/* Defined in (x|w32)fns.c, nsfns.m... */
3336extern int have_menus_p P_ ((void)); 3336extern int have_menus_p P_ ((void));
3337#endif 3337#endif
3338 3338
diff --git a/src/menu.c b/src/menu.c
index e3882dbd965..13deec59450 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1005,7 +1005,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
1005 { 1005 {
1006 entry 1006 entry
1007 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; 1007 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
1008 if ((int) (EMACS_INT)client_data == i) 1008 if ((int) (EMACS_INT)client_data == &XVECTOR (menu_items)->contents[i]/*i*/)
1009 { 1009 {
1010 if (keymaps != 0) 1010 if (keymaps != 0)
1011 { 1011 {
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 822aa94efa9..b4e8dbc9143 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -65,6 +65,9 @@ extern Lisp_Object Voverriding_local_map, Voverriding_local_map_menu_flag,
65extern long context_menu_value; 65extern long context_menu_value;
66EmacsMenu *mainMenu, *svcsMenu; 66EmacsMenu *mainMenu, *svcsMenu;
67 67
68/* Nonzero means a menu is currently active. */
69static int popup_activated_flag;
70
68/* NOTE: toolbar implementation is at end, 71/* NOTE: toolbar implementation is at end,
69 following complete menu implementation. */ 72 following complete menu implementation. */
70 73
@@ -94,6 +97,13 @@ free_frame_menubar (struct frame *f)
94} 97}
95 98
96 99
100int
101popup_activated ()
102{
103 return popup_activated_flag;
104}
105
106
97/* -------------------------------------------------------------------------- 107/* --------------------------------------------------------------------------
98 Update menubar. Three cases: 108 Update menubar. Three cases:
99 1) deep_p = 0, submenu = nil: Fresh switch onto a frame -- either set up 109 1) deep_p = 0, submenu = nil: Fresh switch onto a frame -- either set up
@@ -592,6 +602,7 @@ name_is_separator (name)
592 return [NSString stringWithFormat: @"%c", tpos[2]]; 602 return [NSString stringWithFormat: @"%c", tpos[2]];
593} 603}
594 604
605
595- (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr 606- (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr
596{ 607{
597 NSMenuItem *item; 608 NSMenuItem *item;
@@ -1117,10 +1128,13 @@ ns_popup_menu (Lisp_Object position, Lisp_Object menu)
1117 free_menubar_widget_value_tree (first_wv); 1128 free_menubar_widget_value_tree (first_wv);
1118 unbind_to (specpdl_count2, Qnil); 1129 unbind_to (specpdl_count2, Qnil);
1119 1130
1131 popup_activated_flag = 1;
1120 tem = [pmenu runMenuAt: p forFrame: f keymaps: keymaps]; 1132 tem = [pmenu runMenuAt: p forFrame: f keymaps: keymaps];
1133 popup_activated_flag = 0;
1121 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; 1134 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
1122 1135
1123 UNBLOCK_INPUT; 1136 UNBLOCK_INPUT;
1137 discard_menu_items ();
1124 unbind_to (specpdl_count, Qnil); 1138 unbind_to (specpdl_count, Qnil);
1125 UNGCPRO; 1139 UNGCPRO;
1126 1140
@@ -1511,8 +1525,9 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1511 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; 1525 p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2;
1512 dialog = [[EmacsDialogPanel alloc] initFromContents: contents 1526 dialog = [[EmacsDialogPanel alloc] initFromContents: contents
1513 isQuestion: isQ]; 1527 isQuestion: isQ];
1514 1528 popup_activated_flag = 1;
1515 tem = [dialog runDialogAt: p]; 1529 tem = [dialog runDialogAt: p];
1530 popup_activated_flag = 0;
1516 1531
1517 [dialog close]; 1532 [dialog close];
1518 1533
@@ -1934,6 +1949,12 @@ for instance using the window manager, then this produces a quit and
1934 return ns_popup_dialog (position, contents, header); 1949 return ns_popup_dialog (position, contents, header);
1935} 1950}
1936 1951
1952DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
1953 doc: /* Return t if a menu or popup dialog is active. */)
1954 ()
1955{
1956 return popup_activated () ? Qt : Qnil;
1957}
1937 1958
1938/* ========================================================================== 1959/* ==========================================================================
1939 1960
@@ -1947,6 +1968,7 @@ syms_of_nsmenu ()
1947 defsubr (&Sx_popup_menu); 1968 defsubr (&Sx_popup_menu);
1948 defsubr (&Sx_popup_dialog); 1969 defsubr (&Sx_popup_dialog);
1949 defsubr (&Sns_reset_menu); 1970 defsubr (&Sns_reset_menu);
1971 defsubr (&Smenu_or_popup_active_p);
1950 staticpro (&menu_items); 1972 staticpro (&menu_items);
1951 menu_items = Qnil; 1973 menu_items = Qnil;
1952 1974
diff --git a/src/s/darwin.h b/src/s/darwin.h
index e71eb15ff03..4dcf8bb5fdd 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -134,7 +134,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
134#define HAVE_SOCKETS 134#define HAVE_SOCKETS
135 135
136/* This seems to help in Ctrl-G detection under Cocoa, however at the cost 136/* This seems to help in Ctrl-G detection under Cocoa, however at the cost
137 of some quirks that may or may not bother a given user. */ 137 of some quirks that may or may not bother a given user.
138 It was earlier commented that "In Carbon, asynchronous I/O (using SIGIO)
139 can't be used for window events because they don't come from sockets,
140 even though it works fine on tty's. Uncertain about situation in Cocoa. */
138#ifdef COCOA_EXPERIMENTAL_CTRL_G 141#ifdef COCOA_EXPERIMENTAL_CTRL_G
139#define NO_SOCK_SIGIO 142#define NO_SOCK_SIGIO
140#endif 143#endif
diff --git a/src/syssignal.h b/src/syssignal.h
index 21df63959f5..56988be6b78 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20extern void init_signals P_ ((void)); 20extern void init_signals P_ ((void));
21 21
22#if defined (HAVE_GTK_AND_PTHREAD) 22#if defined (HAVE_GTK_AND_PTHREAD) || defined (HAVE_NS)
23#include <pthread.h> 23#include <pthread.h>
24/* If defined, asynchronous signals delivered to a non-main thread are 24/* If defined, asynchronous signals delivered to a non-main thread are
25 forwarded to the main thread. */ 25 forwarded to the main thread. */
diff --git a/src/xdisp.c b/src/xdisp.c
index 431541c608d..bc6545b5fd8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11349,7 +11349,7 @@ redisplay_internal (preserve_echo_area)
11349 return; 11349 return;
11350 } 11350 }
11351 11351
11352#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 11352#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
11353 if (popup_activated ()) 11353 if (popup_activated ())
11354 return; 11354 return;
11355#endif 11355#endif
@@ -23521,7 +23521,7 @@ note_mouse_highlight (f, x, y)
23521 struct buffer *b; 23521 struct buffer *b;
23522 23522
23523 /* When a menu is active, don't highlight because this looks odd. */ 23523 /* When a menu is active, don't highlight because this looks odd. */
23524#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 23524#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
23525 if (popup_activated ()) 23525 if (popup_activated ())
23526 return; 23526 return;
23527#endif 23527#endif