mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 23:06:54 +08:00
macOS: let fullscreen windows have access to the system menubar
This commit is contained in:
@@ -20,6 +20,7 @@ Details:
|
|||||||
|
|
||||||
ManoloFLTK:
|
ManoloFLTK:
|
||||||
Fix "FLTK on NetBSD very slow on X11 with Unicode locale" (#935)
|
Fix "FLTK on NetBSD very slow on X11 with Unicode locale" (#935)
|
||||||
|
macOS: let fullscreen windows have access to the system menubar
|
||||||
|
|
||||||
Matthias Melcher:
|
Matthias Melcher:
|
||||||
Fix Fl_Shared_Image refcount (#877)
|
Fix Fl_Shared_Image refcount (#877)
|
||||||
|
|||||||
+35
-11
@@ -1272,6 +1272,8 @@ static FLTextView *fltextview_instance = nil;
|
|||||||
- (void)windowDidDeminiaturize:(NSNotification *)notif;
|
- (void)windowDidDeminiaturize:(NSNotification *)notif;
|
||||||
- (void)fl_windowMiniaturize:(NSNotification *)notif;
|
- (void)fl_windowMiniaturize:(NSNotification *)notif;
|
||||||
- (void)windowDidMiniaturize:(NSNotification *)notif;
|
- (void)windowDidMiniaturize:(NSNotification *)notif;
|
||||||
|
- (void)windowWillEnterFullScreen:(NSNotification *)notif;
|
||||||
|
- (void)windowWillExitFullScreen:(NSNotification *)notif;
|
||||||
- (BOOL)windowShouldClose:(id)fl;
|
- (BOOL)windowShouldClose:(id)fl;
|
||||||
- (void)anyWindowWillClose:(NSNotification *)notif;
|
- (void)anyWindowWillClose:(NSNotification *)notif;
|
||||||
- (void)doNothing:(id)unused;
|
- (void)doNothing:(id)unused;
|
||||||
@@ -1496,7 +1498,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
FLWindow *nsw = (FLWindow*)[notif object];
|
FLWindow *nsw = (FLWindow*)[notif object];
|
||||||
Fl_Window *w = [nsw getFl_Window];
|
Fl_Window *w = [nsw getFl_Window];
|
||||||
/* Restore previous fullscreen level */
|
/* Restore previous fullscreen level */
|
||||||
if (w->fullscreen_active()) {
|
if (w->fullscreen_active() && fl_mac_os_version < 100700) {
|
||||||
[nsw setLevel:NSStatusWindowLevel];
|
[nsw setLevel:NSStatusWindowLevel];
|
||||||
fixup_window_levels();
|
fixup_window_levels();
|
||||||
}
|
}
|
||||||
@@ -1554,6 +1556,18 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
|||||||
Fl::handle(FL_HIDE, window);
|
Fl::handle(FL_HIDE, window);
|
||||||
fl_unlock_function();
|
fl_unlock_function();
|
||||||
}
|
}
|
||||||
|
- (void)windowWillEnterFullScreen:(NSNotification *)notif;
|
||||||
|
{
|
||||||
|
FLWindow *nsw = (FLWindow*)[notif object];
|
||||||
|
Fl_Window *window = [nsw getFl_Window];
|
||||||
|
window->_set_fullscreen();
|
||||||
|
}
|
||||||
|
- (void)windowWillExitFullScreen:(NSNotification *)notif;
|
||||||
|
{
|
||||||
|
FLWindow *nsw = (FLWindow*)[notif object];
|
||||||
|
Fl_Window *window = [nsw getFl_Window];
|
||||||
|
window->_clear_fullscreen();
|
||||||
|
}
|
||||||
- (BOOL)windowShouldClose:(id)fl
|
- (BOOL)windowShouldClose:(id)fl
|
||||||
{
|
{
|
||||||
fl_lock_function();
|
fl_lock_function();
|
||||||
@@ -3101,15 +3115,13 @@ NSOpenGLContext* Fl_X::GLcontext_getcurrent()
|
|||||||
|
|
||||||
void Fl_Window::fullscreen_x() {
|
void Fl_Window::fullscreen_x() {
|
||||||
_set_fullscreen();
|
_set_fullscreen();
|
||||||
if (fl_mac_os_version < 101000) {
|
|
||||||
// On OS X < 10.6, it is necessary to recreate the window. This is done with hide+show.
|
|
||||||
// The alternative procedure isn't stable until MacOS 10.10
|
|
||||||
hide();
|
|
||||||
show();
|
|
||||||
} else {
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||||
[i->xid setStyleMask:NSBorderlessWindowMask]; //10.6
|
if (fl_mac_os_version >= 100700 && border()) {
|
||||||
#endif
|
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||||
|
[i->xid toggleFullScreen:nil];
|
||||||
|
# endif
|
||||||
|
} else if (fl_mac_os_version >= 100600) {
|
||||||
|
[i->xid setStyleMask:NSBorderlessWindowMask]; // 10.6
|
||||||
if ([i->xid isKeyWindow]) {
|
if ([i->xid isKeyWindow]) {
|
||||||
if ([i->xid level] != NSStatusWindowLevel) {
|
if ([i->xid level] != NSStatusWindowLevel) {
|
||||||
[i->xid setLevel:NSStatusWindowLevel];
|
[i->xid setLevel:NSStatusWindowLevel];
|
||||||
@@ -3139,6 +3151,11 @@ void Fl_Window::fullscreen_x() {
|
|||||||
Fl::screen_xywh(sx, sy, sw, sh, right);
|
Fl::screen_xywh(sx, sy, sw, sh, right);
|
||||||
W = sx + sw - X;
|
W = sx + sw - X;
|
||||||
resize(X, Y, W, H);
|
resize(X, Y, W, H);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{ // On OS X < 10.6, it is necessary to recreate the window. This is done with hide+show.
|
||||||
|
hide();
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
Fl::handle(FL_FULLSCREEN, this);
|
Fl::handle(FL_FULLSCREEN, this);
|
||||||
}
|
}
|
||||||
@@ -3146,7 +3163,11 @@ void Fl_Window::fullscreen_x() {
|
|||||||
void Fl_Window::fullscreen_off_x(int X, int Y, int W, int H) {
|
void Fl_Window::fullscreen_off_x(int X, int Y, int W, int H) {
|
||||||
_clear_fullscreen();
|
_clear_fullscreen();
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||||
if (fl_mac_os_version >= 100600) {
|
if (fl_mac_os_version >= 100700) {
|
||||||
|
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||||
|
[i->xid toggleFullScreen:nil];
|
||||||
|
# endif
|
||||||
|
} else if (fl_mac_os_version >= 100600) {
|
||||||
NSInteger level = NSNormalWindowLevel;
|
NSInteger level = NSNormalWindowLevel;
|
||||||
if (modal()) level = modal_window_level();
|
if (modal()) level = modal_window_level();
|
||||||
else if (non_modal()) level = non_modal_window_level();
|
else if (non_modal()) level = non_modal_window_level();
|
||||||
@@ -3264,7 +3285,7 @@ void Fl_X::make(Fl_Window* w)
|
|||||||
x->in_windowDidResize(false);
|
x->in_windowDidResize(false);
|
||||||
|
|
||||||
NSRect crect;
|
NSRect crect;
|
||||||
if (w->fullscreen_active()) {
|
if (w->fullscreen_active() && fl_mac_os_version < 100700) {
|
||||||
int top, bottom, left, right;
|
int top, bottom, left, right;
|
||||||
int sx, sy, sw, sh, X, Y, W, H;
|
int sx, sy, sw, sh, X, Y, W, H;
|
||||||
|
|
||||||
@@ -3382,6 +3403,9 @@ void Fl_X::make(Fl_Window* w)
|
|||||||
} else { // a top-level window
|
} else { // a top-level window
|
||||||
if ([cw canBecomeKeyWindow]) [cw makeKeyAndOrderFront:nil];
|
if ([cw canBecomeKeyWindow]) [cw makeKeyAndOrderFront:nil];
|
||||||
else [cw orderFront:nil];
|
else [cw orderFront:nil];
|
||||||
|
if (w->fullscreen_active() && fl_mac_os_version >= 100700) {
|
||||||
|
[cw toggleFullScreen:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int old_event = Fl::e_number;
|
int old_event = Fl::e_number;
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class fullscreen_window : public Fl_Single_Window {
|
|||||||
public:
|
public:
|
||||||
fullscreen_window(int W, int H, const char *t=0);
|
fullscreen_window(int W, int H, const char *t=0);
|
||||||
int handle (int e);
|
int handle (int e);
|
||||||
|
void resize(int x, int y, int w, int h);
|
||||||
Fl_Toggle_Light_Button *b3;
|
Fl_Toggle_Light_Button *b3;
|
||||||
Fl_Toggle_Light_Button *b4;
|
Fl_Toggle_Light_Button *b4;
|
||||||
};
|
};
|
||||||
@@ -134,6 +135,20 @@ fullscreen_window::fullscreen_window(int W, int H, const char *t) : Fl_Single_Wi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void after_resize(void *data) {
|
||||||
|
Fl::remove_check(after_resize, data);
|
||||||
|
fullscreen_window *win = (fullscreen_window*)data;
|
||||||
|
if (win->fullscreen_active()) win->b3->set();
|
||||||
|
else win->b3->clear();
|
||||||
|
win->b3->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fullscreen_window::resize(int x, int y, int w, int h) {
|
||||||
|
Fl_Single_Window::resize(x,y,w,h);
|
||||||
|
Fl::add_check(after_resize, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int fullscreen_window::handle(int e) {
|
int fullscreen_window::handle(int e) {
|
||||||
if (e == FL_FULLSCREEN) {
|
if (e == FL_FULLSCREEN) {
|
||||||
printf("Received FL_FULLSCREEN event\n");
|
printf("Received FL_FULLSCREEN event\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user