Commit 23a9456
committed
ui_cocoa: unify Cocoa + Metal event pump on RAWindow
On 10.5 Leopard (and any macOS make-build that runs the bare binary
from a terminal rather than a .app bundle), the window appeared but
didn't respond to keyboard or mouse. The menu was unreachable.
ROOT CAUSE: input delivery used two different architectures:
HAVE_COCOA_METAL: RAWindow : NSWindow with a -sendEvent: override.
AppKit calls -[NSWindow sendEvent:] unconditionally on every event
destined for the key window, so the override fires with no setup.
HAVE_COCOA: RApplication : NSApplication with a -sendEvent: override.
Only fires if NSApp is actually an RApplication instance, which
requires either NSApplicationMain() + NSPrincipalClass=RApplication
in Info.plist, or an explicit [RApplication sharedApplication] call
before any [NSApplication sharedApplication].
The qb/make build bootstraps via plain [NSApplication sharedApplication]
in main() with no NSApplicationMain / Info.plist lookup, so RApplication
was declared but never instantiated. -sendEvent: was dead code. Events
flowed through plain NSApplication, got forwarded to the key window's
responder chain, and died in CocoaView's empty -keyDown: stub (which
exists only to squelch the system beep). Result: window visible,
utterly unresponsive.
FIX: unify on the Metal architecture. Make HAVE_COCOA also use
RAWindow : NSWindow with the same -sendEvent: override. AppKit calls
it automatically - no NSPrincipalClass, no class-registration dance.
The two code paths converge on the same event-dispatch structure.
ui_cocoa.m:
- Merge the conditional RAWindow-or-RApplication declaration into
a single unconditional @interface RAWindow : NSWindow.
- Bracket all 11 NSEvent dot-syntax sites (event.type -> [event type],
etc.) - now that sendEvent: compiles on the Cocoa path instead
of being dead code, every dot-access is a compile error on the
10.5 SDK / GCC 4.0 (pre-Obj-C-2.0, NSEvent's getters aren't
declared @Property there). Same class of fix as c49a525,
d38dcb5, f4d1390.
- Collapse three #if HAVE_COCOA_METAL / #elif HAVE_COCOA case-label
splits (NSEventTypeFlagsChanged vs NSFlagsChanged, etc.) into
single modern-name labels. cocoa_defines.h already provides the
modern names as aliases on pre-10.12 SDKs.
- cocoa_create_main_window(): drop the #ifdef HAVE_COCOA_METAL -
both paths now allocate RAWindow.
Behavioral impact:
* HAVE_COCOA_METAL (modern macOS, Xcode/make-bundle builds):
unchanged. Same RAWindow, same sendEvent:, same event flow.
* HAVE_COCOA on modern macOS make-bundle: still works - now via
RAWindow instead of going through the NSPrincipalClass dance.
* HAVE_COCOA bare-binary from terminal (Leopard PPC, and any make
build run without .app bundling): NOW WORKS. Previously unable
to receive input at all.
* HAVE_COCOA Xcode builds (RetroArch.xcodeproj, RetroArch_OSX107.
xcodeproj, RetroArch_PPC.xcodeproj): still work. Those set
NSPrincipalClass=RApplication in pkg/apple/OSX/Info.plist, which
becomes a dangling reference now - but a dangling NSPrincipalClass
falls back to NSApplication, which is what we want. The plists
can be cleaned up in a separate commit.
No per-event overhead change. NSWindow's sendEvent: dispatch has
the same Obj-C message-send cost as NSApplication's did. Binary
size grows by a few hundred bytes (the sendEvent: body now compiles
into the non-Metal binary instead of being dead code).1 parent 53c32a2 commit 23a9456
1 file changed
Lines changed: 27 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
369 | 374 | | |
370 | 375 | | |
371 | 376 | | |
372 | 377 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | 378 | | |
380 | 379 | | |
381 | 380 | | |
| |||
395 | 394 | | |
396 | 395 | | |
397 | 396 | | |
398 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
399 | 402 | | |
400 | 403 | | |
401 | 404 | | |
| |||
405 | 408 | | |
406 | 409 | | |
407 | 410 | | |
408 | | - | |
| 411 | + | |
409 | 412 | | |
410 | | - | |
| 413 | + | |
411 | 414 | | |
412 | | - | |
413 | | - | |
| 415 | + | |
| 416 | + | |
414 | 417 | | |
415 | 418 | | |
416 | 419 | | |
| |||
425 | 428 | | |
426 | 429 | | |
427 | 430 | | |
428 | | - | |
| 431 | + | |
429 | 432 | | |
430 | 433 | | |
431 | 434 | | |
| |||
436 | 439 | | |
437 | 440 | | |
438 | 441 | | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 442 | + | |
444 | 443 | | |
445 | 444 | | |
446 | | - | |
| 445 | + | |
447 | 446 | | |
448 | | - | |
| 447 | + | |
449 | 448 | | |
450 | 449 | | |
451 | 450 | | |
| |||
468 | 467 | | |
469 | 468 | | |
470 | 469 | | |
471 | | - | |
472 | | - | |
| 470 | + | |
| 471 | + | |
473 | 472 | | |
474 | 473 | | |
475 | 474 | | |
| |||
496 | 495 | | |
497 | 496 | | |
498 | 497 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
| 498 | + | |
504 | 499 | | |
505 | 500 | | |
506 | 501 | | |
507 | 502 | | |
508 | 503 | | |
509 | 504 | | |
510 | | - | |
| 505 | + | |
511 | 506 | | |
512 | 507 | | |
513 | 508 | | |
| |||
522 | 517 | | |
523 | 518 | | |
524 | 519 | | |
525 | | - | |
| 520 | + | |
526 | 521 | | |
527 | 522 | | |
528 | 523 | | |
| |||
1410 | 1405 | | |
1411 | 1406 | | |
1412 | 1407 | | |
1413 | | - | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1414 | 1411 | | |
1415 | 1412 | | |
1416 | 1413 | | |
1417 | 1414 | | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | 1415 | | |
1425 | 1416 | | |
1426 | 1417 | | |
| |||
0 commit comments