Separate window for SDL direct3d9 with background input

Separate window for SDL direct3d9 with background input
This commit is contained in:
Andy Vandijck 2025-07-04 10:10:06 +02:00
parent 6505ca17df
commit 2c17201cdd
4 changed files with 24 additions and 6 deletions

View File

@ -1223,7 +1223,8 @@ EVT_HANDLER(AllowKeyboardBackgroundInput, "Allow keyboard background input (togg
config::OptionID::kUIAllowKeyboardBackgroundInput);
disableKeyboardBackgroundInput();
if (OPTION(kUIAllowKeyboardBackgroundInput)) {
if (OPTION(kUIAllowKeyboardBackgroundInput) ||
(OPTION(kSDLRenderer) == wxString("direct3d"))) {
if (panel && panel->panel) {
enableKeyboardBackgroundInput(panel->panel->GetWindow()->GetEventHandler());
}

View File

@ -69,7 +69,9 @@ private:
SDL_Window *sdlwindow = NULL;
SDL_Texture *texture = NULL;
SDL_Renderer *renderer = NULL;
wxString renderername = wxEmptyString;
wxString renderername = wxEmptyString;
DECLARE_EVENT_TABLE()
};
#if defined(__WXMSW__) && !defined(NO_D3D)

View File

@ -1260,7 +1260,8 @@ void GameArea::OnIdle(wxIdleEvent& event)
w->SetSize(wxSize(basic_width, basic_height));
// Allow input while on background
if (OPTION(kUIAllowKeyboardBackgroundInput)) {
if (OPTION(kUIAllowKeyboardBackgroundInput) ||
(OPTION(kSDLRenderer) == wxString("direct3d"))) {
enableKeyboardBackgroundInput(w->GetEventHandler());
}
@ -2264,6 +2265,11 @@ DrawingPanelBase::~DrawingPanelBase()
disableKeyboardBackgroundInput();
}
BEGIN_EVENT_TABLE(SDLDrawingPanel, wxPanel)
EVT_PAINT(SDLDrawingPanel::PaintEv)
END_EVENT_TABLE()
SDLDrawingPanel::SDLDrawingPanel(wxWindow* parent, int _width, int _height)
: DrawingPanel(parent, _width, _height)
{
@ -2401,6 +2407,14 @@ void SDLDrawingPanel::DrawingPanelInit()
if (SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER, xid) == false)
#elif defined(__WXMAC__)
if (SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER, wxGetApp().frame->GetPanel()->GetHandle()) == false)
#elif defined(__WXMSW__)
if (OPTION(kSDLRenderer) == wxString("direct3d")) {
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, height * scale);
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, width * scale);
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN, true);
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, true);
SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, "visualboyadvance-m SDL DX9");
} else if (SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER, GetHandle()) == false)
#else
if (SDL_SetPointerProperty(props, "sdl2-compat.external_window", GetWindow()->GetHandle()) == false)
#endif

View File

@ -881,7 +881,8 @@ wxEvtHandler* wxvbamApp::event_handler() {
return nullptr;
}
if (OPTION(kUIAllowJoystickBackgroundInput) || OPTION(kUIAllowKeyboardBackgroundInput)) {
if (OPTION(kUIAllowJoystickBackgroundInput) || OPTION(kUIAllowKeyboardBackgroundInput) ||
(OPTION(kSDLRenderer) == wxString("direct3d"))) {
// Use the game panel, if the background polling option is enabled.
return panel->panel->GetWindow()->GetEventHandler();
}