From e05ea21e0167a37bb1bc1aebf20b5e903c5cf15e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 26 Mar 2020 09:39:36 +0100 Subject: [PATCH] Do maximize more properly on macOS --- vncviewer/DesktopWindow.cxx | 8 +------- vncviewer/cocoa.h | 1 + vncviewer/cocoa.mm | 7 +++++++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index 78893925..2ca13eea 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -1023,15 +1023,9 @@ void DesktopWindow::maximizeWindow() } else ShowWindow(fl_xid(this), SW_MAXIMIZE); #elif defined(__APPLE__) - // OS X is somewhat strange and does not really have a concept of a - // maximized window, so we can simply resize the window to the workarea. - // Note that we shouldn't do this whilst in full screen as that will - // incorrectly adjust things. if (fullscreen_active()) return; - int X, Y, W, H; - Fl::screen_work_area(X, Y, W, H, this->x(), this->y()); - size(W, H); + cocoa_win_zoom(this); #else // X11 fl_open_display(); diff --git a/vncviewer/cocoa.h b/vncviewer/cocoa.h index c65e19eb..98e5fafd 100644 --- a/vncviewer/cocoa.h +++ b/vncviewer/cocoa.h @@ -27,6 +27,7 @@ typedef struct CGColorSpace *CGColorSpaceRef; CGColorSpaceRef cocoa_win_color_space(Fl_Window *win); bool cocoa_win_is_zoomed(Fl_Window *win); +void cocoa_win_zoom(Fl_Window *win); int cocoa_is_keyboard_event(const void *event); diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm index bd0e0800..9fa5470f 100644 --- a/vncviewer/cocoa.mm +++ b/vncviewer/cocoa.mm @@ -145,6 +145,13 @@ bool cocoa_win_is_zoomed(Fl_Window *win) return [nsw isZoomed]; } +void cocoa_win_zoom(Fl_Window *win) +{ + NSWindow *nsw; + nsw = (NSWindow*)fl_xid(win); + [nsw zoom:nsw]; +} + int cocoa_is_keyboard_event(const void *event) { NSEvent *nsevent; -- 2.39.5