diff --git a/src/MacVim/MMBackend.h b/src/MacVim/MMBackend.h index 4abd9c73b9..021955f3f8 100644 --- a/src/MacVim/MMBackend.h +++ b/src/MacVim/MMBackend.h @@ -13,13 +13,6 @@ #import "vim.h" -#ifdef FEAT_BEVAL -// Seconds to delay balloon evaluation after mouse event (subtracted from -// p_bdlay). -extern NSTimeInterval MMBalloonEvalInternalDelay; -#endif - - @interface MMBackend : NSObject { NSMutableArray *outputQueue; diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 32f3c717cb..14c4a9872d 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -46,12 +46,6 @@ static unsigned MMServerMax = 1000; -#ifdef FEAT_BEVAL -// Seconds to delay balloon evaluation after mouse event (subtracted from -// p_bdlay so that this effectively becomes the smallest possible delay). -NSTimeInterval MMBalloonEvalInternalDelay = 0.1; -#endif - // TODO: Move to separate file. static int eventModifierFlagsToVimModMask(int modifierFlags); static int eventModifierFlagsToVimMouseModMask(int modifierFlags); @@ -1919,7 +1913,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data object:nil]; [self performSelector:@selector(bevalCallback:) withObject:nil - afterDelay:MMBalloonEvalInternalDelay]; + afterDelay:p_bdlay/1000.0]; } #endif } else if (MouseDownMsgID == msgid) { @@ -1978,7 +1972,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data object:nil]; [self performSelector:@selector(bevalCallback:) withObject:nil - afterDelay:MMBalloonEvalInternalDelay]; + afterDelay:p_bdlay/1000.0]; } #endif } else if (AddInputMsgID == msgid) { @@ -3359,14 +3353,14 @@ - (void)bevalCallback:(id UNUSED)sender // variable. (The reason we need to know is due to how the Cocoa tool // tips work: if there is no tool tip we must set it to nil explicitly // or it might never go away.) - [self setLastToolTip:nil]; - (*balloonEval->msgCB)(balloonEval, 0); [self queueMessage:SetTooltipMsgID properties: [NSDictionary dictionaryWithObject:(lastToolTip ? lastToolTip : @"") forKey:@"toolTip"]]; [self flushQueue:YES]; + + [self setLastToolTip:nil]; } } #endif diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 6ae432acac..06c7348d23 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -163,7 +163,7 @@ - (void)scheduleClose; - (void)handleBrowseForFile:(NSDictionary *)attr; - (void)handleShowDialog:(NSDictionary *)attr; - (void)handleDeleteSign:(NSDictionary *)attr; -- (void)setToolTipDelay:(NSTimeInterval)seconds; +- (void)setToolTipDelay; @end @@ -221,6 +221,8 @@ - (id)initWithBackend:(id)backend pid:(int)processIdentifier [mainMenu addItem:appMenuItem]; + [self setToolTipDelay]; + isInitialized = YES; // After MMVimController's initialization is completed, @@ -1007,11 +1009,6 @@ - (void)handleMessage:(int)msgid data:(NSData *)data [textView setToolTipAtMousePoint:toolTip]; else [textView setToolTipAtMousePoint:nil]; - } else if (SetTooltipDelayMsgID == msgid) { - NSDictionary *dict = [NSDictionary dictionaryWithData:data]; - NSNumber *delay = dict ? [dict objectForKey:@"delay"] : nil; - if (delay) - [self setToolTipDelay:[delay floatValue]]; } else if (AddToMRUMsgID == msgid) { NSDictionary *dict = [NSDictionary dictionaryWithData:data]; NSArray *filenames = dict ? [dict objectForKey:@"filenames"] : nil; @@ -1907,18 +1904,15 @@ - (void)handleDeleteSign:(NSDictionary *)attr [view deleteSign:[attr objectForKey:@"imgName"]]; } -- (void)setToolTipDelay:(NSTimeInterval)seconds +- (void)setToolTipDelay { // HACK! NSToolTipManager is an AppKit private class. static Class TTM = nil; if (!TTM) TTM = NSClassFromString(@"NSToolTipManager"); - if (seconds < 0) - seconds = 0; - if (TTM) { - [[TTM sharedToolTipManager] setInitialToolTipDelay:seconds]; + [[TTM sharedToolTipManager] setInitialToolTipDelay:1e-6]; } else { ASLogNotice(@"Failed to get NSToolTipManager"); } diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index f3beb56656..2f0aba2c3b 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -261,7 +261,6 @@ extern const char * const MMVimMsgIDStrings[]; MSG(SetWindowPositionMsgID) \ MSG(DeleteSignMsgID) \ MSG(SetTooltipMsgID) \ - MSG(SetTooltipDelayMsgID) \ MSG(GestureMsgID) \ MSG(AddToMRUMsgID) \ MSG(BackingPropertiesChangedMsgID) \ diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 6b77258247..f630f7b935 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -2494,12 +2494,7 @@ void gui_mch_enable_beval_area(BalloonEval *beval UNUSED) { - // Set the balloon delay when enabling balloon eval. - float delay = p_bdlay/1000.0f - MMBalloonEvalInternalDelay; - if (delay < 0) delay = 0; - [[MMBackend sharedInstance] queueMessage:SetTooltipDelayMsgID properties: - [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:delay] - forKey:@"delay"]]; + // NOP } void @@ -2514,8 +2509,11 @@ * Show a balloon with "mesg". */ void -gui_mch_post_balloon(BalloonEval *beval UNUSED, char_u *mesg) +gui_mch_post_balloon(BalloonEval *beval, char_u *mesg) { + vim_free(beval->msg); + beval->msg = mesg == NULL ? NULL : vim_strsave(mesg); + NSString *toolTip = [NSString stringWithVimString:mesg]; [[MMBackend sharedInstance] setLastToolTip:toolTip]; } diff --git a/src/testdir/test_balloon_gui.vim b/src/testdir/test_balloon_gui.vim index bbff4a9448..d01114c1c6 100644 --- a/src/testdir/test_balloon_gui.vim +++ b/src/testdir/test_balloon_gui.vim @@ -4,8 +4,6 @@ source check.vim CheckGui CheckFeature balloon_eval -if !has('gui_macvim') " See https://github.com/macvim-dev/macvim/issues/902 - func Test_balloon_show_gui() let msg = 'this this this this' call balloon_show(msg) @@ -20,5 +18,4 @@ func Test_balloon_show_gui() call balloon_show('') endfunc -endif " !has('gui_macvim') " vim: shiftwidth=2 sts=2 expandtab