FLTK logo

Re: [fltk/fltk] FLTK 1.3.6 doesn't handle fullscreen on macOS (Issue #287)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] FLTK 1.3.6 doesn't handle fullscreen on macOS (Issue #287) "Pierre Ossman (Work account)" Nov 03, 2021  
 

The following patch fixes this bug:

diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index be07b09fb..ae2958861 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -674,6 +674,9 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data)
 + (void)concatEtext:(NSString*)aString;
 - (BOOL)process_keydown:(NSEvent*)theEvent;
 - (id)initWithFrame:(NSRect)frameRect;
+- (void)viewDidMoveToWindow;
+- (void)setFrameSize:(NSSize)newSize;
+- (void)updateWindowSize;
 - (void)drawRect:(NSRect)rect;
 - (BOOL)acceptsFirstResponder;
 - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent;
@@ -1260,7 +1263,6 @@ static FLTextView *fltextview_instance = nil;
 + (void)initialize;
 + (FLWindowDelegate*)singleInstance;
 - (void)windowDidMove:(NSNotification *)notif;
-- (void)view_did_resize:(NSNotification *)notif;
 - (void)windowDidResignKey:(NSNotification *)notif;
 - (void)windowDidBecomeKey:(NSNotification *)notif;
 - (void)windowDidBecomeMain:(NSNotification *)notif;
@@ -1448,29 +1450,6 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
   }
   fl_unlock_function();
 }
-- (void)view_did_resize:(NSNotification *)notif
-{
-  if (![[notif object] isKindOfClass:[FLView class]]) return;
-  FLView *view = (FLView*)[notif object];
-  FLWindow *nsw = (FLWindow*)[view window];
-  if (!nsw || ![nsw getFl_Window]) return;
-  fl_lock_function();
-  Fl_Window *window = [nsw getFl_Window];
-  int X, Y;
-  CocoatoFLTK(window, X, Y);
-  NSRect r = [view frame];
-  Fl_X::i(window)->in_windowDidResize(1);
-  window->resize(X, Y, r.size.width, r.size.height);
-  Fl_X::i(window)->in_windowDidResize(0);
-  update_e_xy_and_e_xy_root(nsw);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
-  if (views_use_CA && !window->as_gl_window()) {
-    [view reset_aux_bitmap];
-    window->redraw();
-  }
-#endif
-  fl_unlock_function();
-}
 - (void)windowDidResignKey:(NSNotification *)notif
 {
   fl_lock_function();
@@ -1917,10 +1896,6 @@ void fl_open_display() {
 					     selector:@selector(anyWindowWillClose:) 
 						 name:NSWindowWillCloseNotification 
 					       object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:[FLWindowDelegate singleInstance]
-                                             selector:@selector(view_did_resize:)
-                                                 name:NSViewFrameDidChangeNotification
-                                               object:nil];
     if (![NSThread isMultiThreaded]) {
       // With old OS X versions, it is necessary to create one thread for secondary pthreads to be
       // allowed to use cocoa, especially to create an NSAutoreleasePool.
@@ -2414,6 +2389,39 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
   return self;
 }
 
+- (void)viewDidMoveToWindow
+{
+  [self updateWindowSize];
+}
+
+- (void)setFrameSize:(NSSize)newSize
+{
+  [super setFrameSize:newSize];
+  [self updateWindowSize];
+}
+
+- (void)updateWindowSize
+{
+  FLWindow *nsw = (FLWindow*)[self window];
+  if (!nsw || ![nsw getFl_Window]) return;
+  fl_lock_function();
+  Fl_Window *window = [nsw getFl_Window];
+  int X, Y;
+  CocoatoFLTK(window, X, Y);
+  NSRect r = [self frame];
+  Fl_X::i(window)->in_windowDidResize(1);
+  window->resize(X, Y, r.size.width, r.size.height);
+  Fl_X::i(window)->in_windowDidResize(0);
+  update_e_xy_and_e_xy_root(nsw);
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
+  if (views_use_CA && !window->as_gl_window()) {
+    [self reset_aux_bitmap];
+    window->redraw();
+  }
+#endif
+  fl_unlock_function();
+}
+
 /* Used by all GL or non-GL windows.
  * Gets called when a window is created, resized, or moved between retina and non-retina displays.
  * For non-GL windows, also called by Fl_X::flush() because of the display message sent to the view.

This is for the 1.3 branch, but I think it should be about the same on master.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.