Permalink
Browse files

Only update menu state on actual state change.

Problem: Menu updates caused noticable delays because every menu item got
updated on state changes.
Solution: Remember old state and only pass update event on to MacVim if the new
state differs from the old one.

Also add .*.swp to .gitignore to ignore Vim swapfiles.
  • Loading branch information...
b4winckler committed Oct 19, 2007
1 parent 9aefa53 commit d7906883906e015d349a7ac21b33f0fa521944c3
Showing with 15 additions and 12 deletions.
  1. +1 −0 .gitignore
  2. +1 −6 src/MacVim/MMVimController.m
  3. +10 −4 src/MacVim/gui_macvim.m
  4. +3 −2 src/structs.h
View
@@ -16,3 +16,4 @@ src/xxd/xxd
src/auto/config.h
src/auto/config.mk
src/TAGS
+.*.swp
@@ -413,12 +413,7 @@ - (oneway void)processCommandQueue:(in bycopy NSArray *)queue
NSData *data = [queue objectAtIndex:i+1];
int msgid = *((int*)[value bytes]);
-#if 0
- if (msgid != EnableMenuItemMsgID && msgid != AddMenuItemMsgID
- && msgid != AddMenuMsgID) {
- NSLog(@"%s%s", _cmd, MessageStrings[msgid]);
- }
-#endif
+ //NSLog(@"%s%s", _cmd, MessageStrings[msgid]);
[self handleMessage:msgid data:data];
}
View
@@ -681,8 +681,15 @@
void
gui_mch_menu_grey(vimmenu_T *menu, int grey)
{
- [[MMBackend sharedInstance]
- enableMenuItemWithTag:(int)menu state:!grey];
+ /* Only update menu if the 'grey' state has changed to avoid having to pass
+ * lots of unnecessary data to MacVim. (Skipping this test makes MacVim
+ * pause noticably on mode changes. */
+ if (menu->was_grey != grey)
+ {
+ menu->was_grey = grey;
+ [[MMBackend sharedInstance]
+ enableMenuItemWithTag:(int)menu state:!grey];
+ }
}
@@ -694,8 +701,7 @@
{
// HACK! There is no (obvious) way to hide a menu item, so simply
// enable/disable it instead.
- [[MMBackend sharedInstance]
- enableMenuItemWithTag:(int)menu state:!hidden];
+ gui_mch_menu_grey(menu, hidden);
}
View
@@ -2246,8 +2246,9 @@ struct VimMenu
PtWidget_t *submenu_id;
#endif
#ifdef FEAT_GUI_MACVIM
- int mac_key;
- int mac_mods;
+ int mac_key; /* Key equivalent */
+ int mac_mods; /* Modifier flags for the above */
+ int was_grey; /* Remember last 'grey' state */
#endif
};
#else

0 comments on commit d790688

Please sign in to comment.