X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f0177f86f745ef86357214b110f9d98e4ed63b7a..2fdec80c2cebf486bc708c5a59b0cd52def5285b:/src/nsmenu.m diff --git a/src/nsmenu.m b/src/nsmenu.m index 697329df67..27ba6928ee 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1,5 +1,5 @@ /* NeXT/Open/GNUstep and MacOSX Cocoa menu and toolbar module. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -1054,8 +1054,10 @@ free_frame_tool_bar (struct frame *f) Under NS we just hide the toolbar until it might be needed again. -------------------------------------------------------------------------- */ { + EmacsView *view = FRAME_NS_VIEW (f); block_input (); - [[FRAME_NS_VIEW (f) toolbar] setVisible: NO]; + view->wait_for_tool_bar = NO; + [[view toolbar] setVisible: NO]; FRAME_TOOLBAR_HEIGHT (f) = 0; unblock_input (); } @@ -1070,9 +1072,13 @@ update_frame_tool_bar (struct frame *f) EmacsView *view = FRAME_NS_VIEW (f); NSWindow *window = [view window]; EmacsToolbar *toolbar = [view toolbar]; + int oldh; + if (view == nil || toolbar == nil) return; block_input (); + oldh = FRAME_TOOLBAR_HEIGHT (f); + #ifdef NS_IMPL_COCOA [toolbar clearActive]; #else @@ -1096,7 +1102,7 @@ update_frame_tool_bar (struct frame *f) /* Check if this is a separator. */ if (EQ (TOOLPROP (TOOL_BAR_ITEM_TYPE), Qt)) { - /* Skip separators. Newer OSX don't show them, and on GNUStep they + /* Skip separators. Newer OSX don't show them, and on GNUstep they are wide as a button, thus overflowing the toolbar most of the time. */ continue; @@ -1176,9 +1182,15 @@ update_frame_tool_bar (struct frame *f) FRAME_TOOLBAR_HEIGHT (f) = NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) - FRAME_NS_TITLEBAR_HEIGHT (f); - if (FRAME_TOOLBAR_HEIGHT (f) < 0) // happens if frame is fullscreen. - FRAME_TOOLBAR_HEIGHT (f) = 0; - unblock_input (); + if (FRAME_TOOLBAR_HEIGHT (f) < 0) // happens if frame is fullscreen. + FRAME_TOOLBAR_HEIGHT (f) = 0; + + if (oldh != FRAME_TOOLBAR_HEIGHT (f)) + [view updateFrameSize:YES]; + if (view->wait_for_tool_bar && FRAME_TOOLBAR_HEIGHT (f) > 0) + [view setNeedsDisplay: YES]; + + unblock_input (); } @@ -1242,7 +1254,7 @@ update_frame_tool_bar (struct frame *f) { /* 1) come up w/identifier */ NSString *identifier - = [NSString stringWithFormat: @"%u", [img hash]]; + = [NSString stringWithFormat: @"%lu", (unsigned long)[img hash]]; [activeIdentifiers addObject: identifier]; /* 2) create / reuse item */ @@ -1452,7 +1464,7 @@ pop_down_menu (void *arg) Lisp_Object -ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) +ns_popup_dialog (Lisp_Object position, Lisp_Object header, Lisp_Object contents) { id dialog; Lisp_Object window, tem, title; @@ -1919,34 +1931,6 @@ DEFUN ("ns-reset-menu", Fns_reset_menu, Sns_reset_menu, 0, 0, 0, } -DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0, - doc: /* Pop up a dialog box and return user's selection. -POSITION specifies which frame to use. -This is normally a mouse button event or a window or frame. -If POSITION is t, it means to use the frame the mouse is on. -The dialog box appears in the middle of the specified frame. - -CONTENTS specifies the alternatives to display in the dialog box. -It is a list of the form (DIALOG ITEM1 ITEM2...). -Each ITEM is a cons cell (STRING . VALUE). -The return value is VALUE from the chosen item. - -An ITEM may also be just a string--that makes a nonselectable item. -An ITEM may also be nil--that means to put all preceding items -on the left of the dialog box and all following items on the right. -\(By default, approximately half appear on each side.) - -If HEADER is non-nil, the frame title for the box is "Information", -otherwise it is "Question". - -If the user gets rid of the dialog box without making a valid choice, -for instance using the window manager, then this produces a quit and -`x-popup-dialog' does not return. */) - (Lisp_Object position, Lisp_Object contents, Lisp_Object header) -{ - 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. */) (void) @@ -1964,11 +1948,10 @@ void syms_of_nsmenu (void) { #ifndef NS_IMPL_COCOA - /* Don't know how to keep track of this in Next/Open/Gnustep. Always + /* Don't know how to keep track of this in Next/Open/GNUstep. Always update menus there. */ trackingMenu = 1; #endif - defsubr (&Sx_popup_dialog); defsubr (&Sns_reset_menu); defsubr (&Smenu_or_popup_active_p);