diff options
| author | Matthias Melcher <git@matthiasm.com> | 2020-01-14 19:22:03 +0100 |
|---|---|---|
| committer | Matthias Melcher <git@matthiasm.com> | 2020-01-14 19:22:03 +0100 |
| commit | afcc79c3f7d5ffd9f9bd2185494688a5d5927aab (patch) | |
| tree | 667156480c4b8c5eef936b47ed5103e3c137565f /src/Fl_cocoa.mm | |
| parent | ed80d9cef0c321012c65c31104be66dc64bf2fad (diff) | |
| parent | d598f9ea06f610053cd16b51cbe1aa477c8501ef (diff) | |
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'src/Fl_cocoa.mm')
| -rw-r--r-- | src/Fl_cocoa.mm | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index cb634a43c..8b392cdba 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -582,6 +582,7 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop() #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 if (views_use_CA) [(FLView*)[self contentView] reset_aux_bitmap]; #endif + [[self standardWindowButton:NSWindowDocumentIconButton] setImage:nil]; [super close]; // when a fullscreen window is closed, windowDidResize may be sent after the close message was sent // and before the FLWindow receives the final dealloc message @@ -1133,6 +1134,7 @@ static FLTextView *fltextview_instance = nil; - (BOOL)windowShouldClose:(id)fl; - (void)anyWindowWillClose:(NSNotification *)notif; - (void)doNothing:(id)unused; +- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu; @end @@ -1304,6 +1306,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; FLWindow *nsw = (FLWindow*)[notif object]; Fl_Window *window = [nsw getFl_Window]; Fl::first_window(window); + if (!window->parent()) [nsw orderFront:nil]; update_e_xy_and_e_xy_root(nsw); if (fl_sys_menu_bar && Fl_MacOS_Sys_Menu_Bar_Driver::window_menu_style()) { // select the corresponding Window menu item @@ -1390,6 +1393,9 @@ static FLWindowDelegate *flwindowdelegate_instance = nil; { return; } +- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu { + return NO; +} @end @interface FLAppDelegate : NSObject @@ -3075,6 +3081,16 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow() [cw setLevel:winlevel]; q_set_window_title(cw, w->label(), w->iconlabel()); + NSImage *icon = icon_image; // is a window or default icon present? + if (!icon) icon = ((Fl_Cocoa_Screen_Driver*)Fl::screen_driver())->default_icon; + if (icon && (winstyle & NSTitledWindowMask) && w->label() && strlen(w->label())>0) { + [cw setRepresentedFilename:[NSString stringWithFormat:@"/%@", [cw title]]]; + NSButton *icon_button = [cw standardWindowButton:NSWindowDocumentIconButton]; + if (icon_button) { + [icon setSize:[icon_button frame].size]; + [icon_button setImage:icon]; + } + } if (!force_position()) { if (w->modal()) { [cw center]; @@ -4428,13 +4444,59 @@ char *Fl_Darwin_System_Driver::preference_rootnode(Fl_Preferences *prefs, Fl_Pre // Our C path names for preferences will be: // SYSTEM: "/Library/Preferences/$vendor/$application.prefs" - // SYSTEM: "/Users/$user/Preferences/$vendor/$application.prefs" + // USER: "/Users/$user/Library/Preferences/$vendor/$application.prefs" snprintf(filename + strlen(filename), FL_PATH_MAX - strlen(filename), "/%s/%s.prefs", vendor, application); return filename; } +Fl_Cocoa_Window_Driver::~Fl_Cocoa_Window_Driver() +{ + if (shape_data_) { + if (shape_data_->mask) { + CGImageRelease(shape_data_->mask); + } + delete shape_data_; + } + [icon_image release]; +} + +static NSImage* rgb_to_nsimage(const Fl_RGB_Image *rgb) { + if (!rgb) return nil; + int ld = rgb->ld(); + if (!ld) ld = rgb->w() * rgb->d(); + NSImage *win_icon = nil; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (fl_mac_os_version >= 101000) { + NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:rgb->w() pixelsHigh:rgb->h() + bitsPerSample:8 samplesPerPixel:rgb->d() hasAlpha:!(rgb->d() & 1) isPlanar:NO + colorSpaceName:(rgb->d()<=2) ? NSDeviceWhiteColorSpace : NSDeviceRGBColorSpace + bitmapFormat:NSAlphaNonpremultipliedBitmapFormat bytesPerRow:ld bitsPerPixel:rgb->d()*8]; // 10.4 + memcpy([bitmap bitmapData], rgb->array, rgb->h() * ld); + win_icon = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)]; + [win_icon addRepresentation:bitmap]; + [bitmap release]; + } +#endif + return win_icon; +} + +void Fl_Cocoa_Window_Driver::icons(const Fl_RGB_Image *icons[], int count) { + [icon_image release]; + icon_image = nil; + if (count >= 1 && pWindow->border() && pWindow->label() && strlen(pWindow->label())) { + icon_image = rgb_to_nsimage(icons[0]); + } +} + +void Fl_Cocoa_Screen_Driver::default_icons(const Fl_RGB_Image *icons[], int count) { + [default_icon release]; + default_icon = nil; + if (count >= 1) { + default_icon = rgb_to_nsimage(icons[0]); + } +} // // End of "$Id$". |
