To: vim-dev@vim.org Subject: patch 7.1.007 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.1.007 (extra) Problem: Mac: Context menu doesn't work on Intel Macs. Scrollbars are not dimmed when Vim is not the active application. Solution: Remove the test whether context menus are supported. They are always there in OS/X. Handle the dimming. (Nicolas Weber) Files: src/gui_mac.c, src/gui.h *** ../vim-7.1.006/src/gui_mac.c Thu May 10 20:07:25 2007 --- src/gui_mac.c Sat Jun 9 14:19:25 2007 *************** *** 1676,1688 **** /* TODO: NEEDED? */ clickIsPopup = FALSE; ! if ((gui.MacOSHaveCntxMenu) && (mouse_model_popup())) ! if (IsShowContextualMenuClick(theEvent)) ! { ! vimMouseButton = MOUSE_RIGHT; ! vimModifiers &= ~MOUSE_CTRL; ! clickIsPopup = TRUE; ! } /* Is it a double click ? */ dblClick = ((theEvent->when - lastMouseTick) < GetDblTime()); --- 1676,1687 ---- /* TODO: NEEDED? */ clickIsPopup = FALSE; ! if (mouse_model_popup() && IsShowContextualMenuClick(theEvent)) ! { ! vimMouseButton = MOUSE_RIGHT; ! vimModifiers &= ~MOUSE_CTRL; ! clickIsPopup = TRUE; ! } /* Is it a double click ? */ dblClick = ((theEvent->when - lastMouseTick) < GetDblTime()); *************** *** 1920,1943 **** WindowPtr whichWindow; whichWindow = (WindowPtr) event->message; ! if ((event->modifiers) & activeFlag) ! /* Activate */ ! gui_focus_change(TRUE); ! else { ! /* Deactivate */ ! gui_focus_change(FALSE); ! /* DON'T KNOW what the code below was doing ! found in the deactivate clause, but the ! clause writing TRUE into in_focus (BUG) ! */ ! ! #if 0 /* Removed by Dany as per above June 2001 */ ! a_bool = false; ! SetPreserveGlyph(a_bool); ! SetOutlinePreferred(a_bool); ! #endif } } --- 1919,1937 ---- WindowPtr whichWindow; whichWindow = (WindowPtr) event->message; ! /* Dim scrollbars */ ! if (whichWindow == gui.VimWindow) { ! ControlRef rootControl; ! GetRootControl(gui.VimWindow, &rootControl); ! if ((event->modifiers) & activeFlag) ! ActivateControl(rootControl); ! else ! DeactivateControl(rootControl); } + + /* Activate */ + gui_focus_change((event->modifiers) & activeFlag); } *************** *** 2559,2574 **** OSErr error; /* Handle contextual menu right now (if needed) */ ! if (gui.MacOSHaveCntxMenu) ! if (IsShowContextualMenuClick(event)) ! { # if 0 ! gui_mac_handle_contextual_menu(event); # else ! gui_mac_doMouseDownEvent(event); # endif ! return; ! } /* Handle normal event */ switch (event->what) --- 2553,2567 ---- OSErr error; /* Handle contextual menu right now (if needed) */ ! if (IsShowContextualMenuClick(event)) ! { # if 0 ! gui_mac_handle_contextual_menu(event); # else ! gui_mac_doMouseDownEvent(event); # endif ! return; ! } /* Handle normal event */ switch (event->what) *************** *** 2782,2795 **** (void) InstallAEHandlers(); #endif - if (Gestalt(gestaltContextualMenuAttr, &gestalt_rc) == noErr) - gui.MacOSHaveCntxMenu = BitTst(&gestalt_rc, 31-gestaltContextualMenuTrapAvailable); - else - gui.MacOSHaveCntxMenu = false; - - if (gui.MacOSHaveCntxMenu) - gui.MacOSHaveCntxMenu = (InitContextualMenus()==noErr); - pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */ AppendMenu(pomme, "\pAbout VIM"); --- 2775,2780 ---- *************** *** 2941,2946 **** --- 2926,2932 ---- #ifdef USE_CARBONKEYHANDLER EventHandlerRef keyEventHandlerRef; #endif + ControlRef rootControl; if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr) gMacSystemVersion = 0x1000; /* TODO: Default to minimum sensible value */ *************** *** 2954,2968 **** (void) InstallAEHandlers(); #endif - /* Ctrl click */ - if (Gestalt(gestaltContextualMenuAttr, &gestalt_rc) == noErr) - gui.MacOSHaveCntxMenu = BitTst(&gestalt_rc, 31-gestaltContextualMenuTrapAvailable); - else - gui.MacOSHaveCntxMenu = false; - - if (gui.MacOSHaveCntxMenu) - gui.MacOSHaveCntxMenu = (InitContextualMenus()==noErr); - pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */ AppendMenu(pomme, "\pAbout VIM"); --- 2940,2945 ---- *************** *** 2981,2986 **** --- 2958,2964 ---- gui.VimWindow = NewCWindow(nil, &windRect, "\pgVim on Macintosh", true, zoomDocProc, (WindowPtr)-1L, true, 0); + CreateRootControl(gui.VimWindow, &rootControl); InstallReceiveHandler((DragReceiveHandlerUPP)receiveHandler, gui.VimWindow, NULL); SetPortWindowPort(gui.VimWindow); *** ../vim-7.1.006/src/gui.h Thu May 10 19:18:46 2007 --- src/gui.h Sat Jun 9 14:10:34 2007 *************** *** 460,466 **** WindowPtr VimWindow; MenuHandle MacOSHelpMenu; /* Help menu provided by the MacOS */ int MacOSHelpItems; /* Nr of help-items supplied by MacOS */ - int MacOSHaveCntxMenu; /* Contextual menu available */ WindowPtr wid; /* Window id of text area */ int visibility; /* Is window partially/fully obscured? */ #endif --- 460,465 ---- *** ../vim-7.1.006/src/version.c Tue Jun 19 15:40:51 2007 --- src/version.c Tue Jun 19 15:44:15 2007 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 7, /**/ -- When danger reared its ugly head, He bravely turned his tail and fled Yes, Brave Sir Robin turned about And gallantly he chickened out Bravely taking to his feet He beat a very brave retreat Bravest of the brave Sir Robin Petrified of being dead Soiled his pants then brave Sir Robin Turned away and fled. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///