Skip to content

Commit

Permalink
Disable macOS' native full screen
Browse files Browse the repository at this point in the history
It clashes with the method used by FLTK and gives very unreliable
behaviour.
  • Loading branch information
CendioOssman committed Jan 22, 2025
1 parent e3e4848 commit f5b42e4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion vncviewer/DesktopWindow.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright 2011-2025 Pierre Ossman <ossman@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -199,6 +199,11 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name,

show();

#ifdef __APPLE__
// FLTK does its own full screen, so disable the system one
cocoa_prevent_native_fullscreen(this);
#endif

// Full screen events are not sent out for a hidden window,
// so send a fake one here to set up things properly.
if (fullscreen_active())
Expand Down
4 changes: 3 additions & 1 deletion vncviewer/cocoa.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
/* Copyright 2011-2025 Pierre Ossman <ossman@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -21,6 +21,8 @@

class Fl_Window;

void cocoa_prevent_native_fullscreen(Fl_Window *win);

int cocoa_get_level(Fl_Window *win);
void cocoa_set_level(Fl_Window *win, int level);

Expand Down
12 changes: 11 additions & 1 deletion vncviewer/cocoa.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
/* Copyright 2011-2025 Pierre Ossman <ossman@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -30,6 +30,16 @@

static bool captured = false;

void cocoa_prevent_native_fullscreen(Fl_Window *win)
{
NSWindow *nsw;
nsw = (NSWindow*)fl_xid(win);
assert(nsw);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 100700
nsw.collectionBehavior |= NSWindowCollectionBehaviorFullScreenNone;
#endif
}

int cocoa_get_level(Fl_Window *win)
{
NSWindow *nsw;
Expand Down

0 comments on commit f5b42e4

Please sign in to comment.