macOS: prevent changing window border while window is fullscreen

This commit is contained in:
ManoloFLTK 2024-10-31 15:15:33 +01:00
parent 0cab095b3c
commit 0ac1379985
2 changed files with 17 additions and 4 deletions

View File

@ -3403,6 +3403,17 @@ void Fl_Cocoa_Window_Driver::use_border() {
if (!shown() || pWindow->parent()) return;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (fl_mac_os_version >= 100600) {
if (pWindow->fullscreen_active()) {
// prevent changing border while window is fullscreen
static bool active = false;
if (!active) {
active = true;
bool b = !border();
pWindow->border(b);
active = false;
}
return;
}
[fl_xid(pWindow) setStyleMask:calc_win_style(pWindow)]; // 10.6
if (border()) restore_window_title_and_icon(pWindow, icon_image);
pWindow->redraw();

View File

@ -174,10 +174,12 @@ void double_cb(Fl_Widget *o, void *p) {
void double_cb(Fl_Widget *, void *) {}
#endif
void border_cb(Fl_Widget *o, void *p) {
Fl_Window *w = (Fl_Window *)p;
int d = ((Fl_Button *)o)->value();
void border_cb(Fl_Button *b, Fl_Window *w) {
int d = b->value();
w->border(d);
// border change may have been refused (e.g. with fullscreen window)
if (w->border() != d) b->value(w->border());
}
@ -337,7 +339,7 @@ int main(int argc, char **argv) {
y+=30;
Fl_Toggle_Light_Button b2(50,y,window.w()-60,30,"Border");
b2.callback(border_cb,w);
b2.callback((Fl_Callback*)border_cb,w);
b2.set();
border_button = &b2;
y+=30;