Skip to content
Permalink
Browse files

Merge pull request #506 from Armada651/d3dfullscreen

D3D: Add exclusive fullscreen support.
  • Loading branch information...
delroth committed Jul 26, 2014
2 parents 906b05c + 06b13f1 commit 8e865f38489f204ea2fabf2cee3acad1a215deff
@@ -31,6 +31,7 @@ void Host_Message(int Id);
void Host_NotifyMapLoaded();
void Host_RefreshDSPDebuggerWindow();
void Host_RequestRenderWindowSize(int width, int height);
void Host_RequestFullscreen(bool enable_fullscreen);
void Host_SetStartupDebuggingParameters();
void Host_SetWiiMoteConnectionState(int _State);
void Host_ShowJitResults(unsigned int address);
@@ -78,57 +78,6 @@ extern "C" {
#include "DolphinWX/resources/Dolphin.c" // NOLINT: Dolphin icon
};

#ifdef _WIN32
// I could not use FindItemByHWND() instead of this, it crashed on that occasion I used it */
HWND MSWGetParent_(HWND Parent)
{
return GetParent(Parent);
}
#endif

// ---------------
// The CPanel class to receive MSWWindowProc messages from the video backend.

BEGIN_EVENT_TABLE(CPanel, wxPanel)
END_EVENT_TABLE()

CPanel::CPanel(
wxWindow *parent,
wxWindowID id
)
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, 0) // disables wxTAB_TRAVERSAL because it was breaking hotkeys
{
}

#ifdef _WIN32
WXLRESULT CPanel::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
switch (nMsg)
{
case WM_USER:
switch (wParam)
{
case WM_USER_STOP:
main_frame->DoStop();
break;

case WM_USER_SETCURSOR:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN)
SetCursor(wxCURSOR_BLANK);
else
SetCursor(wxNullCursor);
break;
}
break;

default:
// By default let wxWidgets do what it normally does with this event
return wxPanel::MSWWindowProc(nMsg, wParam, lParam);
}
return 0;
}
#endif

CRenderFrame::CRenderFrame(wxFrame* parent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style)
@@ -213,6 +162,23 @@ WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa
}
break;

case WM_USER:
switch (wParam)
{
case WM_USER_STOP:
main_frame->DoStop();
break;

case WM_USER_SETCURSOR:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN)
SetCursor(wxCURSOR_BLANK);
else
SetCursor(wxNullCursor);
break;
}
break;

case WM_CLOSE:
// Let Core finish initializing before accepting any WM_CLOSE messages
if (!Core::IsRunning()) break;
@@ -350,7 +316,7 @@ CFrame::CFrame(wxFrame* parent,
, m_LogWindow(nullptr), m_LogConfigWindow(nullptr)
, m_FifoPlayerDlg(nullptr), UseDebugger(_UseDebugger)
, m_bBatchMode(_BatchMode), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
, m_bGameLoading(false), m_bClosing(false)
, m_bGameLoading(false), m_bClosing(false), m_confirmStop(false)
{
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
bFloatWindow[i] = false;
@@ -384,7 +350,7 @@ CFrame::CFrame(wxFrame* parent,
// ---------------
// Main panel
// This panel is the parent for rendering and it holds the gamelistctrl
m_Panel = new CPanel(this, IDM_MPANEL);
m_Panel = new wxPanel(this, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0);

m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL,
wxDefaultPosition, wxDefaultSize,
@@ -484,7 +450,7 @@ bool CFrame::RendererIsFullscreen()

if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{
fullscreen = m_RenderFrame->IsFullScreen();
fullscreen = m_RenderFrame->IsFullScreen() && g_Config.bFullscreen;
}

#if defined(__APPLE__)
@@ -674,6 +640,21 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
}
break;

case IDM_FULLSCREENREQUEST:
{
bool enable_fullscreen = event.GetInt() == 0 ? false : true;
ToggleDisplayMode(enable_fullscreen);
if (m_RenderFrame != nullptr)
m_RenderFrame->ShowFullScreen(enable_fullscreen);

// If the stop dialog initiated this fullscreen switch then we need
// to pause the emulator after we've completed the switch.
// TODO: Allow the renderer to switch fullscreen modes while paused.
if (m_confirmStop)
Core::SetState(Core::CORE_PAUSE);
}
break;

case WM_USER_CREATE:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_BLANK);
@@ -756,7 +737,11 @@ bool CFrame::RendererHasFocus()
if (m_RenderParent == nullptr)
return false;
#ifdef _WIN32
if (m_RenderParent->GetParent()->GetHWND() == GetForegroundWindow())
HWND window = GetForegroundWindow();
if (window == nullptr)
return false;

if (m_RenderFrame->GetHWND() == window)
return true;
#else
wxWindow *window = wxWindow::FindFocus();
@@ -1202,25 +1187,47 @@ void CFrame::OnMouse(wxMouseEvent& event)
event.Skip();
}

void CFrame::DoFullscreen(bool bF)
void CFrame::DoFullscreen(bool enable_fullscreen)
{
ToggleDisplayMode(bF);
if (!g_Config.bBorderlessFullscreen &&
!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
Core::GetState() != Core::CORE_RUN)
{
// A responsive renderer is required for exclusive fullscreen, but the
// renderer can only respond in the running state. Therefore we ignore
// fullscreen switches if we support exclusive fullscreen, but the
// renderer is not running.
// TODO: Allow the renderer to switch fullscreen modes while paused.
return;
}

ToggleDisplayMode(enable_fullscreen);

#if defined(__APPLE__)
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];

if (bF != RendererIsFullscreen())
if (enable_fullscreen != RendererIsFullscreen())
{
[window toggleFullScreen:nil];
}
#else
m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL);
if (enable_fullscreen)
{
m_RenderFrame->ShowFullScreen(true, wxFULLSCREEN_ALL);
}
else if (g_Config.bBorderlessFullscreen ||
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
// Exiting exclusive fullscreen should be done from a Renderer callback.
// Therefore we don't exit fullscreen from here if we support exclusive mode.
m_RenderFrame->ShowFullScreen(false, wxFULLSCREEN_ALL);
}
#endif

if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
if (bF)
if (enable_fullscreen)
{
// Save the current mode before going to fullscreen
AuiCurrent = m_Mgr->SavePerspective();
@@ -1236,6 +1243,8 @@ void CFrame::DoFullscreen(bool bF)
{
m_RenderFrame->Raise();
}

g_Config.bFullscreen = enable_fullscreen;
}

const CGameListCtrl *CFrame::GetGameListCtrl() const
@@ -50,24 +50,6 @@ class wxListEvent;
class wxMenuItem;
class wxWindow;

// The CPanel class to receive MSWWindowProc messages from the video backend.
class CPanel : public wxPanel
{
public:
CPanel(
wxWindow* parent,
wxWindowID id = wxID_ANY
);

private:
DECLARE_EVENT_TABLE();

#ifdef _WIN32
// Receive WndProc messages
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
};

class CRenderFrame : public wxFrame
{
public:
@@ -177,7 +159,7 @@ class CFrame : public CRenderFrame
CGameListCtrl* m_GameListCtrl;
wxPanel* m_Panel;
CRenderFrame* m_RenderFrame;
wxPanel* m_RenderParent;
wxWindow* m_RenderParent;
CLogWindow* m_LogWindow;
LogConfigWindow* m_LogConfigWindow;
FifoPlayerDlg* m_FifoPlayerDlg;
@@ -188,6 +170,7 @@ class CFrame : public CRenderFrame
bool m_bNoDocking;
bool m_bGameLoading;
bool m_bClosing;
bool m_confirmStop;

std::vector<std::string> drives;

@@ -95,6 +95,7 @@ Core::GetWindowHandle().
#include "InputCommon/ControllerInterface/ControllerInterface.h"

#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"

#ifdef _WIN32
#ifndef SM_XVIRTUALSCREEN
@@ -119,8 +120,6 @@ extern "C" {
class InputPlugin;
class wxFrame;

static bool confirmStop = false;

// Create menu items
// ---------------------
void CFrame::CreateMenu()
@@ -976,7 +975,7 @@ void CFrame::StartGame(const std::string& filename)
m_RenderFrame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnRenderParentClose, this);
m_RenderFrame->Bind(wxEVT_ACTIVATE, &CFrame::OnActive, this);
m_RenderFrame->Bind(wxEVT_MOVE, &CFrame::OnRenderParentMove, this);
m_RenderParent = new CPanel(m_RenderFrame, wxID_ANY);
m_RenderParent = m_RenderFrame;
m_RenderFrame->Show();
}

@@ -1082,11 +1081,11 @@ void CFrame::DoStop()
{
if (!Core::IsRunningAndStarted())
return;
if (confirmStop)
if (m_confirmStop)
return;

// don't let this function run again until it finishes, or is aborted.
confirmStop = true;
m_confirmStop = true;

m_bGameLoading = false;
if (Core::GetState() != Core::CORE_UNINITIALIZED ||
@@ -1100,8 +1099,21 @@ void CFrame::DoStop()
// Ask for confirmation in case the user accidentally clicked Stop / Escape
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
{
// Pause the state during confirmation and restore it afterwards
Core::EState state = Core::GetState();
Core::SetState(Core::CORE_PAUSE);

// If exclusive fullscreen is not enabled then we can pause the emulation
// before we've exited fullscreen. If not then we need to exit fullscreen first.
if (!RendererIsFullscreen() || g_Config.bBorderlessFullscreen ||
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
Core::SetState(Core::CORE_PAUSE);
}
else
{
DoFullscreen(false);
}

wxMessageDialog m_StopDlg(
this,
_("Do you want to stop the current emulation?"),
@@ -1113,7 +1125,7 @@ void CFrame::DoStop()
if (Ret != wxID_YES)
{
Core::SetState(state);
confirmStop = false;
m_confirmStop = false;
return;
}
}
@@ -1135,7 +1147,7 @@ void CFrame::OnStopped()
{
wxEndBusyCursor();

confirmStop = false;
m_confirmStop = false;

#if defined(HAVE_X11) && HAVE_X11
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
@@ -256,6 +256,7 @@ enum
IDM_WINDOWSIZEREQUEST,
IDM_STOPPED,
IDM_HOST_MESSAGE,
IDM_FULLSCREENREQUEST,

IDM_MPANEL, ID_STATUSBAR,

@@ -627,6 +627,13 @@ void Host_RequestRenderWindowSize(int width, int height)
main_frame->GetEventHandler()->AddPendingEvent(event);
}

void Host_RequestFullscreen(bool enable_fullscreen)
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FULLSCREENREQUEST);
event.SetInt(enable_fullscreen ? 1 : 0);
main_frame->GetEventHandler()->AddPendingEvent(event);
}

void Host_SetStartupDebuggingParameters()
{
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
@@ -94,6 +94,9 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
}

void Host_RequestRenderWindowSize(int width, int height) {}

void Host_RequestFullscreen(bool enable_fullscreen) {}

void Host_SetStartupDebuggingParameters()
{
}
@@ -88,6 +88,9 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
}

void Host_RequestRenderWindowSize(int width, int height) {}

void Host_RequestFullscreen(bool enable_fullscreen) {}

void Host_SetStartupDebuggingParameters()
{
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
Oops, something went wrong.

0 comments on commit 8e865f3

Please sign in to comment.
You can’t perform that action at this time.