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); config::OptionID::kUIAllowKeyboardBackgroundInput);
disableKeyboardBackgroundInput(); disableKeyboardBackgroundInput();
if (OPTION(kUIAllowKeyboardBackgroundInput)) { if (OPTION(kUIAllowKeyboardBackgroundInput) ||
(OPTION(kSDLRenderer) == wxString("direct3d"))) {
if (panel && panel->panel) { if (panel && panel->panel) {
enableKeyboardBackgroundInput(panel->panel->GetWindow()->GetEventHandler()); enableKeyboardBackgroundInput(panel->panel->GetWindow()->GetEventHandler());
} }

View File

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

View File

@ -1260,7 +1260,8 @@ void GameArea::OnIdle(wxIdleEvent& event)
w->SetSize(wxSize(basic_width, basic_height)); w->SetSize(wxSize(basic_width, basic_height));
// Allow input while on background // Allow input while on background
if (OPTION(kUIAllowKeyboardBackgroundInput)) { if (OPTION(kUIAllowKeyboardBackgroundInput) ||
(OPTION(kSDLRenderer) == wxString("direct3d"))) {
enableKeyboardBackgroundInput(w->GetEventHandler()); enableKeyboardBackgroundInput(w->GetEventHandler());
} }
@ -2264,6 +2265,11 @@ DrawingPanelBase::~DrawingPanelBase()
disableKeyboardBackgroundInput(); disableKeyboardBackgroundInput();
} }
BEGIN_EVENT_TABLE(SDLDrawingPanel, wxPanel)
EVT_PAINT(SDLDrawingPanel::PaintEv)
END_EVENT_TABLE()
SDLDrawingPanel::SDLDrawingPanel(wxWindow* parent, int _width, int _height) SDLDrawingPanel::SDLDrawingPanel(wxWindow* parent, int _width, int _height)
: DrawingPanel(parent, _width, _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) if (SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER, xid) == false)
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
if (SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER, wxGetApp().frame->GetPanel()->GetHandle()) == false) 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 #else
if (SDL_SetPointerProperty(props, "sdl2-compat.external_window", GetWindow()->GetHandle()) == false) if (SDL_SetPointerProperty(props, "sdl2-compat.external_window", GetWindow()->GetHandle()) == false)
#endif #endif
@ -2418,7 +2432,7 @@ void SDLDrawingPanel::DrawingPanelInit()
} }
sdlwindow = SDL_CreateWindowWithProperties(props); sdlwindow = SDL_CreateWindowWithProperties(props);
if (sdlwindow == NULL) { if (sdlwindow == NULL) {
systemScreenMessage(_("Failed to create SDL window")); systemScreenMessage(_("Failed to create SDL window"));
return; return;
@ -2426,7 +2440,7 @@ void SDLDrawingPanel::DrawingPanelInit()
if (props != NULL) if (props != NULL)
SDL_DestroyProperties(props); SDL_DestroyProperties(props);
if (OPTION(kSDLRenderer) == wxString("default")) { if (OPTION(kSDLRenderer) == wxString("default")) {
renderer = SDL_CreateRenderer(sdlwindow, NULL); renderer = SDL_CreateRenderer(sdlwindow, NULL);
} else { } else {

View File

@ -881,7 +881,8 @@ wxEvtHandler* wxvbamApp::event_handler() {
return nullptr; 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. // Use the game panel, if the background polling option is enabled.
return panel->panel->GetWindow()->GetEventHandler(); return panel->panel->GetWindow()->GetEventHandler();
} }