MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / eventFilter

Method eventFilter

pcsx2-qt/DisplayWidget.cpp:446–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446bool DisplaySurface::eventFilter(QObject* object, QEvent* event)
447{
448 switch (event->type())
449 {
450 case QEvent::KeyPress:
451 case QEvent::KeyRelease:
452#ifdef _WIN32
453 // Nvidia overlay causes the child window to lose focus, but not its parent.
454 // Refocus the child window.
455 requestActivate();
456#endif
457 handleKeyInputEvent(event);
458 return true;
459
460 // These events only work on the top level control.
461 // Which is this container when render to seperate or fullscreen is active (Non-Windows).
462 case QEvent::Close:
463 handleCloseEvent(static_cast<QCloseEvent*>(event));
464 return true;
465 case QEvent::WindowStateChange:
466 if (static_cast<QWindowStateChangeEvent*>(event)->oldState() & Qt::WindowMinimized)
467 emit windowRestoredEvent();
468 return false;
469
470 case QEvent::ChildWindowRemoved:
471 if (static_cast<QChildWindowEvent*>(event)->child() == this)
472 {
473 object->removeEventFilter(this);
474 m_container = nullptr;
475 }
476 return false;
477
478 case QEvent::FocusIn:
479 // macOS: When we (the display window) get focus from another window with a toolbar we update to the MainWindow toolbar.
480 // This is because we are a different native window from our MainWindow. So, whenever we get focus, focus our MainWindow.
481 // That way macOS will show the MainWindow toolbar when you click from the debugger / log window to the game.
482
483 // Don't try to steal focus when we're showing a modal dialog
484 // We end up ping ponging focus in a feedback loop
485 if (QApplication::activeModalWidget() != nullptr)
486 return false;
487
488 if (const auto* w = qobject_cast<QWidget*>(object))
489 w->window()->activateWindow();
490
491 return false;
492 default:
493 return false;
494 }
495}
496
497#include "moc_DisplayWidget.cpp"

Callers

nothing calls this directly

Calls 2

windowMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected