summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-06-10 17:22:29 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-06-10 17:22:59 +0200
commite43dee9d8a74fda6325054fc95e99992b8ba5a16 (patch)
treeb1d9fd82e5924662e53ca4dbe0170bcf223c75a0 /src
parent95165884b67f30d794e963be81d0a6a2adba2d4a (diff)
Fix for "Fullscreen_off removing the icon from the titlebar on MacOS" in fltk.coredev
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index d7d7ec151..31f5bd08e 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -3188,6 +3188,19 @@ static NSUInteger calc_win_style(Fl_Window *win) {
} else winstyle = NSBorderlessWindowMask;
return winstyle;
}
+
+static void restore_window_title_and_icon(Fl_Window *pWindow, NSImage *icon) {
+ FLWindow *nswin = fl_xid(pWindow);
+ q_set_window_title(nswin, pWindow->label(), pWindow->iconlabel());
+ if (!icon) icon = ((Fl_Cocoa_Screen_Driver*)Fl::screen_driver())->default_icon;
+ if (icon && ([nswin styleMask] & NSTitledWindowMask) && pWindow->label() && strlen(pWindow->label())>0) {
+ NSButton *icon_button = [nswin standardWindowButton:NSWindowDocumentIconButton];
+ if (icon_button) {
+ [icon setSize:[icon_button frame].size];
+ [icon_button setImage:icon];
+ }
+ }
+}
#endif
void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
@@ -3200,6 +3213,7 @@ void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
else if (pWindow->non_modal()) level = non_modal_window_level();
[nswin setLevel:level];
[nswin setStyleMask:calc_win_style(pWindow)]; //10.6
+ restore_window_title_and_icon(pWindow, icon_image);
pWindow->resize(X, Y, W, H);
} else
#endif
@@ -3216,6 +3230,7 @@ void Fl_Cocoa_Window_Driver::use_border() {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (fl_mac_os_version >= 100600) {
[fl_xid(pWindow) setStyleMask:calc_win_style(pWindow)]; // 10.6
+ if (border()) restore_window_title_and_icon(pWindow, icon_image);
pWindow->redraw();
}
else