Skip to content

Commit

Permalink
Update fullscreen background color immediately
Browse files Browse the repository at this point in the history
It is no longer necessary to exit and re-enter fullscreen to see changes
to the "background" setting in 'fopt'.
  • Loading branch information
b4winckler committed Sep 16, 2008
1 parent bdb7f8e commit def2d1a
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/MacVim/MMBackend.h
Expand Up @@ -111,6 +111,7 @@

- (void)enterFullscreen:(int)fuoptions background:(int)bg;
- (void)leaveFullscreen;
- (void)setFullscreenBackgroundColor:(int)color;

- (void)setAntialias:(BOOL)antialias;

Expand Down
9 changes: 9 additions & 0 deletions src/MacVim/MMBackend.m
Expand Up @@ -1019,6 +1019,15 @@ - (void)leaveFullscreen
[self queueMessage:LeaveFullscreenMsgID data:nil];
}

- (void)setFullscreenBackgroundColor:(int)color
{
NSMutableData *data = [NSMutableData data];
color = MM_COLOR(color);
[data appendBytes:&color length:sizeof(int)];

[self queueMessage:SetFullscreenColorMsgID data:data];
}

- (void)setAntialias:(BOOL)antialias
{
int msgid = antialias ? EnableAntialiasMsgID : DisableAntialiasMsgID;
Expand Down
5 changes: 5 additions & 0 deletions src/MacVim/MMVimController.m
Expand Up @@ -923,6 +923,11 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
}
} else if (CloseWindowMsgID == msgid) {
[self scheduleClose];
} else if (SetFullscreenColorMsgID == msgid) {
const int *bg = (const int*)[data bytes];
NSColor *color = [NSColor colorWithRgbInt:bg];

[windowController setFullscreenBackgroundColor:color];
// IMPORTANT: When adding a new message, make sure to update
// isUnsafeMessage() if necessary!
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/MacVim/MMWindowController.h
Expand Up @@ -62,6 +62,8 @@

- (void)enterFullscreen:(int)fuoptions backgroundColor:(NSColor *)back;
- (void)leaveFullscreen;
- (void)setFullscreenBackgroundColor:(NSColor *)back;

- (void)setBuffersModified:(BOOL)mod;

- (IBAction)addNewTab:(id)sender;
Expand Down
6 changes: 6 additions & 0 deletions src/MacVim/MMWindowController.m
Expand Up @@ -571,6 +571,12 @@ - (void)leaveFullscreen
shouldResizeVimView = YES;
}

- (void)setFullscreenBackgroundColor:(NSColor *)back
{
if (fullscreenEnabled)
[fullscreenWindow setBackgroundColor:back];
}

- (void)setBuffersModified:(BOOL)mod
{
// NOTE: We only set the document edited flag on the decorated window since
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/MacVim.h
Expand Up @@ -174,6 +174,7 @@ enum {
OpenWithArgumentsMsgID,
CloseWindowMsgID,
InterruptMsgID,
SetFullscreenColorMsgID,
};


Expand Down
1 change: 1 addition & 0 deletions src/MacVim/MacVim.m
Expand Up @@ -81,6 +81,7 @@
"OpenWithArgumentsMsgID",
"CloseWindowMsgID",
"InterruptMsgID",
"SetFullscreenColorMsgID",
};


Expand Down
14 changes: 14 additions & 0 deletions src/MacVim/gui_macvim.m
Expand Up @@ -1599,6 +1599,20 @@
}


void
gui_mch_fuopt_update()
{
guicolor_T fg, bg;
if (fuoptions_flags & FUOPT_BGCOLOR_HLGROUP) {
syn_id2colors(fuoptions_bgcolor, &fg, &bg);
} else {
bg = fuoptions_bgcolor;
}

[[MMBackend sharedInstance] setFullscreenBackgroundColor:bg];
}


void
gui_macvim_update_modified_flag()
{
Expand Down
4 changes: 4 additions & 0 deletions src/option.c
Expand Up @@ -10875,6 +10875,10 @@ check_fuoptions(p_fuoptions, flags, bgcolor)

*flags = new_fuoptions_flags;
*bgcolor = new_fuoptions_bgcolor;

/* Let the GUI know, in case the background color has changed. */
gui_mch_fuopt_update();

return OK;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/proto/gui_macvim.pro
Expand Up @@ -192,6 +192,7 @@ int serverSendReply(char_u *serverid, char_u *str);

void gui_mch_enter_fullscreen(int fuoptions_flags, guicolor_T bg);
void gui_mch_leave_fullscreen(void);
void gui_mch_fuopt_update(void);

void gui_macvim_update_modified_flag();
void gui_macvim_add_to_find_pboard(char_u *pat);
Expand Down

0 comments on commit def2d1a

Please sign in to comment.