Commit a1ddfb1
committed
cocoa: hand-rolled borderless fullscreen on non-Metal path
After 23a9456 unified Cocoa + Metal on -[RAWindow sendEvent:] as
the event pump, fullscreen on the HAVE_COCOA path stopped responding
to keyboard or mouse input.
ROOT CAUSE: -[NSView enterFullScreenMode:withOptions:] internally
calls CGCaptureAllDisplays and creates a new AppKit-manufactured
NSWindow to host the view during fullscreen. That replacement
window is a plain NSWindow, not RAWindow, so -[RAWindow sendEvent:]
stops firing; keystrokes and mouse events get delivered to the
fullscreen wrapper and die in CocoaView's default responder chain
(CocoaView's -keyDown: is an empty beep-squelch stub).
The Metal path is unaffected: it takes a completely different route
via -[apple_platform setVideoMode:] -> native -[NSWindow toggle-
FullScreen:] on 10.7+, which keeps the RAWindow as host throughout.
FIX: replace enterFullScreenMode: on the non-Metal path with a hand-
rolled borderless RAWindow. On fullscreen enter:
- save the current windowed window + view frame
- alloc a borderless RAWindow covering the chosen screen
- hide the menu bar via +[NSMenu setMenuBarVisible:NO] (pure Cocoa,
10.0+, no Carbon framework dependency); only when fullscreening
onto screen 0, since hiding the menu bar on a secondary screen
would mangle the primary
- move the CocoaView from windowed window to fullscreen window
- makeKeyAndOrderFront + makeFirstResponder so keystrokes route
On exit, reverse everything: move the view back, show menu bar, tear
down the fullscreen window. Both the fullscreen RAWindow and the
retained windowed-window reference are released at exit - net retain
count balanced.
ui_cocoa.m:
- Add -[RAWindow canBecomeKeyWindow] { return YES; }. A border-
less NSWindow (no NSWindowStyleMaskTitled) can't become the key
window by default, so without this the new fullscreen RAWindow
would be unable to receive keystrokes regardless of everything
else. No-op for the titled windowed-mode RAWindow, which is
key-eligible by default.
cocoa_gl_ctx.m:
- Replace the enterFullScreenMode: / exitFullScreenModeWithOptions:
pair with alloc/move/show of a borderless RAWindow. RAWindow is
looked up via NSClassFromString(@"RAWindow") rather than exposing
its @interface from ui_cocoa.m into a shared header.
Additional constraint worth calling out: on 10.5 Leopard, -[NSWindow
setStyleMask:] doesn't exist, so we can't toggle the existing window
between titled and borderless - the new-window approach is the only
one that works on every macOS version we target.
SDL, GLFW, and other cross-platform frontends use this same pattern
for pre-Lion fullscreen on macOS. Windowed mode is untouched so
there's no regression risk there; fullscreen on modern macOS via the
Metal path is also untouched.1 parent f0b5fd9 commit a1ddfb1
2 files changed
Lines changed: 104 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
466 | 493 | | |
467 | 494 | | |
468 | 495 | | |
469 | 496 | | |
470 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
471 | 544 | | |
472 | 545 | | |
473 | 546 | | |
474 | 547 | | |
475 | 548 | | |
476 | | - | |
| 549 | + | |
477 | 550 | | |
478 | | - | |
479 | | - | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
480 | 571 | | |
481 | 572 | | |
482 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
386 | 394 | | |
387 | 395 | | |
388 | 396 | | |
| |||
0 commit comments