Skip to content

Commit 58064dc

Browse files
authored
Merge pull request #1064 from ichizok/fix/balloon-gui
Fix balloon API on GUI
2 parents 900bd68 + 7d9cb9b commit 58064dc

File tree

6 files changed

+14
-39
lines changed

6 files changed

+14
-39
lines changed

src/MacVim/MMBackend.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
#import "vim.h"
1414

1515

16-
#ifdef FEAT_BEVAL
17-
// Seconds to delay balloon evaluation after mouse event (subtracted from
18-
// p_bdlay).
19-
extern NSTimeInterval MMBalloonEvalInternalDelay;
20-
#endif
21-
22-
2316
@interface MMBackend : NSObject <MMBackendProtocol, MMVimServerProtocol,
2417
MMVimClientProtocol> {
2518
NSMutableArray *outputQueue;

src/MacVim/MMBackend.m

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@
4646

4747
static unsigned MMServerMax = 1000;
4848

49-
#ifdef FEAT_BEVAL
50-
// Seconds to delay balloon evaluation after mouse event (subtracted from
51-
// p_bdlay so that this effectively becomes the smallest possible delay).
52-
NSTimeInterval MMBalloonEvalInternalDelay = 0.1;
53-
#endif
54-
5549
// TODO: Move to separate file.
5650
static int eventModifierFlagsToVimModMask(int modifierFlags);
5751
static int eventModifierFlagsToVimMouseModMask(int modifierFlags);
@@ -1919,7 +1913,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
19191913
object:nil];
19201914
[self performSelector:@selector(bevalCallback:)
19211915
withObject:nil
1922-
afterDelay:MMBalloonEvalInternalDelay];
1916+
afterDelay:p_bdlay/1000.0];
19231917
}
19241918
#endif
19251919
} else if (MouseDownMsgID == msgid) {
@@ -1978,7 +1972,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
19781972
object:nil];
19791973
[self performSelector:@selector(bevalCallback:)
19801974
withObject:nil
1981-
afterDelay:MMBalloonEvalInternalDelay];
1975+
afterDelay:p_bdlay/1000.0];
19821976
}
19831977
#endif
19841978
} else if (AddInputMsgID == msgid) {
@@ -3359,14 +3353,14 @@ - (void)bevalCallback:(id UNUSED)sender
33593353
// variable. (The reason we need to know is due to how the Cocoa tool
33603354
// tips work: if there is no tool tip we must set it to nil explicitly
33613355
// or it might never go away.)
3362-
[self setLastToolTip:nil];
3363-
33643356
(*balloonEval->msgCB)(balloonEval, 0);
33653357

33663358
[self queueMessage:SetTooltipMsgID properties:
33673359
[NSDictionary dictionaryWithObject:(lastToolTip ? lastToolTip : @"")
33683360
forKey:@"toolTip"]];
33693361
[self flushQueue:YES];
3362+
3363+
[self setLastToolTip:nil];
33703364
}
33713365
}
33723366
#endif

src/MacVim/MMVimController.m

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ - (void)scheduleClose;
161161
- (void)handleBrowseForFile:(NSDictionary *)attr;
162162
- (void)handleShowDialog:(NSDictionary *)attr;
163163
- (void)handleDeleteSign:(NSDictionary *)attr;
164-
- (void)setToolTipDelay:(NSTimeInterval)seconds;
164+
- (void)setToolTipDelay;
165165
@end
166166

167167

@@ -219,6 +219,8 @@ - (id)initWithBackend:(id)backend pid:(int)processIdentifier
219219

220220
[mainMenu addItem:appMenuItem];
221221

222+
[self setToolTipDelay];
223+
222224
isInitialized = YES;
223225

224226
// After MMVimController's initialization is completed,
@@ -1006,11 +1008,6 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
10061008
[textView setToolTipAtMousePoint:toolTip];
10071009
else
10081010
[textView setToolTipAtMousePoint:nil];
1009-
} else if (SetTooltipDelayMsgID == msgid) {
1010-
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
1011-
NSNumber *delay = dict ? [dict objectForKey:@"delay"] : nil;
1012-
if (delay)
1013-
[self setToolTipDelay:[delay floatValue]];
10141011
} else if (AddToMRUMsgID == msgid) {
10151012
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
10161013
NSArray *filenames = dict ? [dict objectForKey:@"filenames"] : nil;
@@ -1906,18 +1903,15 @@ - (void)handleDeleteSign:(NSDictionary *)attr
19061903
[view deleteSign:[attr objectForKey:@"imgName"]];
19071904
}
19081905

1909-
- (void)setToolTipDelay:(NSTimeInterval)seconds
1906+
- (void)setToolTipDelay
19101907
{
19111908
// HACK! NSToolTipManager is an AppKit private class.
19121909
static Class TTM = nil;
19131910
if (!TTM)
19141911
TTM = NSClassFromString(@"NSToolTipManager");
19151912

1916-
if (seconds < 0)
1917-
seconds = 0;
1918-
19191913
if (TTM) {
1920-
[[TTM sharedToolTipManager] setInitialToolTipDelay:seconds];
1914+
[[TTM sharedToolTipManager] setInitialToolTipDelay:1e-6];
19211915
} else {
19221916
ASLogNotice(@"Failed to get NSToolTipManager");
19231917
}

src/MacVim/MacVim.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ extern const char * const MMVimMsgIDStrings[];
261261
MSG(SetWindowPositionMsgID) \
262262
MSG(DeleteSignMsgID) \
263263
MSG(SetTooltipMsgID) \
264-
MSG(SetTooltipDelayMsgID) \
265264
MSG(GestureMsgID) \
266265
MSG(AddToMRUMsgID) \
267266
MSG(BackingPropertiesChangedMsgID) \

src/MacVim/gui_macvim.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,12 +2494,7 @@
24942494
void
24952495
gui_mch_enable_beval_area(BalloonEval *beval UNUSED)
24962496
{
2497-
// Set the balloon delay when enabling balloon eval.
2498-
float delay = p_bdlay/1000.0f - MMBalloonEvalInternalDelay;
2499-
if (delay < 0) delay = 0;
2500-
[[MMBackend sharedInstance] queueMessage:SetTooltipDelayMsgID properties:
2501-
[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:delay]
2502-
forKey:@"delay"]];
2497+
// NOP
25032498
}
25042499

25052500
void
@@ -2514,8 +2509,11 @@
25142509
* Show a balloon with "mesg".
25152510
*/
25162511
void
2517-
gui_mch_post_balloon(BalloonEval *beval UNUSED, char_u *mesg)
2512+
gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
25182513
{
2514+
vim_free(beval->msg);
2515+
beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
2516+
25192517
NSString *toolTip = [NSString stringWithVimString:mesg];
25202518
[[MMBackend sharedInstance] setLastToolTip:toolTip];
25212519
}

src/testdir/test_balloon_gui.vim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ source check.vim
44
CheckGui
55
CheckFeature balloon_eval
66

7-
if !has('gui_macvim') " See https://github.com/macvim-dev/macvim/issues/902
8-
97
func Test_balloon_show_gui()
108
let msg = 'this this this this'
119
call balloon_show(msg)
@@ -20,5 +18,4 @@ func Test_balloon_show_gui()
2018
call balloon_show('')
2119
endfunc
2220

23-
endif " !has('gui_macvim')
2421
" vim: shiftwidth=2 sts=2 expandtab

0 commit comments

Comments
 (0)