Fix Fullscreen issues in DirectX plugin. Fixes issue 1470, issue 1886 and issue 1673 too.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4779 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e80078dc3c
commit
ede1c935f4
|
@ -1,10 +1,26 @@
|
||||||
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "../../Core/Src/Core.h"
|
|
||||||
#include "VideoConfig.h"
|
#include "VideoConfig.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "EmuWindow.h"
|
#include "EmuWindow.h"
|
||||||
|
#include "D3DBase.h"
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
|
|
||||||
namespace EmuWindow
|
namespace EmuWindow
|
||||||
|
@ -61,11 +77,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case VK_ESCAPE:
|
case VK_ESCAPE:
|
||||||
// Toggle full screen doesn't work yet
|
if (g_Config.bFullscreen)
|
||||||
/*
|
|
||||||
if (g_ActiveConfig.bFullscreen)
|
|
||||||
{
|
{
|
||||||
// Pressing Esc switch to Windowed in Fullscreen mode
|
// Pressing Esc switches to Windowed in Fullscreen mode
|
||||||
ToggleFullscreen(hWnd);
|
ToggleFullscreen(hWnd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,34 +89,20 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||||
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
|
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if (g_ActiveConfig.bFullscreen)
|
|
||||||
{
|
|
||||||
DestroyWindow(hWnd);
|
|
||||||
PostQuitMessage(0);
|
|
||||||
ExitProcess(0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Tell the hotkey function that this key was pressed
|
// Tell the hotkey function that this key was pressed
|
||||||
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
switch( LOWORD( wParam ))
|
switch( LOWORD( wParam ))
|
||||||
{
|
{
|
||||||
case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed
|
case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed
|
||||||
if (g_ActiveConfig.bFullscreen)
|
ToggleFullscreen(hWnd);
|
||||||
{
|
|
||||||
DestroyWindow(hWnd);
|
|
||||||
PostQuitMessage(0);
|
|
||||||
ExitProcess(0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
|
|
||||||
/* Post thes mouse events to the main window, it's nessesary because in difference to the
|
/* Post thes mouse events to the main window, it's nessesary because in difference to the
|
||||||
keyboard inputs these events only appear here, not in the parent window or any other WndProc()*/
|
keyboard inputs these events only appear here, not in the parent window or any other WndProc()*/
|
||||||
|
@ -123,9 +123,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_USER:
|
case WM_USER:
|
||||||
// if (wParam == TOGGLE_FULLSCREEN)
|
if (wParam == TOGGLE_FULLSCREEN)
|
||||||
// TODO : Insert some toggle fullscreen code here, kthx :d
|
ToggleFullscreen(hWnd);
|
||||||
// see TODO ^ upper
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
|
@ -240,11 +239,20 @@ void ToggleFullscreen(HWND hParent)
|
||||||
{
|
{
|
||||||
if (m_hParent == NULL)
|
if (m_hParent == NULL)
|
||||||
{
|
{
|
||||||
|
if (D3D::IsFullscreen()) {
|
||||||
|
PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RECT rcdesktop;
|
||||||
int w_fs = 640, h_fs = 480;
|
int w_fs = 640, h_fs = 480;
|
||||||
if (g_Config.bFullscreen)
|
if (g_Config.bFullscreen)
|
||||||
{
|
{
|
||||||
|
if (strlen(g_Config.cInternalRes) > 1)
|
||||||
|
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
|
||||||
|
|
||||||
//Get out of fullscreen
|
//Get out of fullscreen
|
||||||
g_ActiveConfig.bFullscreen = false;
|
g_Config.bFullscreen = false;
|
||||||
|
|
||||||
// FullScreen - > Desktop
|
// FullScreen - > Desktop
|
||||||
ChangeDisplaySettings(NULL, 0);
|
ChangeDisplaySettings(NULL, 0);
|
||||||
|
@ -252,14 +260,13 @@ void ToggleFullscreen(HWND hParent)
|
||||||
// Re-Enable the cursor
|
// Re-Enable the cursor
|
||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
|
|
||||||
RECT rcdesktop;
|
RECT rc = {0, 0, w_fs, h_fs};
|
||||||
RECT rc = {0, 0, 640, 480};
|
|
||||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||||
|
|
||||||
|
// SetWindowPos to the center of the screen
|
||||||
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
|
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
|
||||||
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
||||||
// SetWindowPos to the center of the screen
|
SetWindowPos(hParent, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||||
SetWindowPos(hParent, NULL, X, Y, 640, 480, SWP_NOREPOSITION | SWP_NOZORDER);
|
|
||||||
|
|
||||||
// Set new window style FS -> Windowed
|
// Set new window style FS -> Windowed
|
||||||
SetWindowLong(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
SetWindowLong(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||||
|
@ -269,26 +276,26 @@ void ToggleFullscreen(HWND hParent)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (strlen(g_Config.cFSResolution) > 1)
|
||||||
|
sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs);
|
||||||
|
|
||||||
// Get into fullscreen
|
// Get into fullscreen
|
||||||
g_ActiveConfig.bFullscreen = true;
|
g_Config.bFullscreen = true;
|
||||||
DEVMODE dmScreenSettings;
|
DEVMODE dmScreenSettings;
|
||||||
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
||||||
RECT rcdesktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
|
||||||
|
|
||||||
// Desktop -> FullScreen
|
// Desktop -> FullScreen
|
||||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||||
dmScreenSettings.dmPelsWidth = rcdesktop.right;
|
dmScreenSettings.dmPelsWidth = w_fs;
|
||||||
dmScreenSettings.dmPelsHeight = rcdesktop.bottom;
|
dmScreenSettings.dmPelsHeight = h_fs;
|
||||||
dmScreenSettings.dmBitsPerPel = 32;
|
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT;
|
||||||
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
|
if (ChangeDisplaySettings(&dmScreenSettings, 0) != DISP_CHANGE_SUCCESSFUL)
|
||||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
return;
|
||||||
return ;
|
|
||||||
// Disable the cursor
|
// Disable the cursor
|
||||||
ShowCursor(FALSE);
|
ShowCursor(FALSE);
|
||||||
|
|
||||||
// SetWindowPos to the upper-left corner of the screen
|
// SetWindowPos to the upper-left corner of the screen
|
||||||
SetWindowPos(hParent, NULL, 0, 0, rcdesktop.right, rcdesktop.bottom, SWP_NOREPOSITION | SWP_NOZORDER);
|
SetWindowPos(hParent, NULL, 0, 0, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||||
|
|
||||||
// Set new window style -> PopUp
|
// Set new window style -> PopUp
|
||||||
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
|
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
|
||||||
|
|
|
@ -68,7 +68,7 @@ PLUGIN_GLOBALS* globals = NULL;
|
||||||
bool s_initialized;
|
bool s_initialized;
|
||||||
|
|
||||||
static u32 s_efbAccessRequested = FALSE;
|
static u32 s_efbAccessRequested = FALSE;
|
||||||
static u32 s_FifoShuttingDown = FALSE;
|
static volatile u32 s_FifoShuttingDown = FALSE;
|
||||||
static bool s_swapRequested = false;
|
static bool s_swapRequested = false;
|
||||||
|
|
||||||
static volatile struct
|
static volatile struct
|
||||||
|
|
|
@ -453,16 +453,18 @@ void ToggleFullscreen(HWND hParent)
|
||||||
int w_fs = 640, h_fs = 480;
|
int w_fs = 640, h_fs = 480;
|
||||||
if (g_Config.bFullscreen)
|
if (g_Config.bFullscreen)
|
||||||
{
|
{
|
||||||
// Get out of fullscreen
|
|
||||||
g_Config.bFullscreen = false;
|
|
||||||
RECT rc = {0, 0, w_fs, h_fs};
|
|
||||||
|
|
||||||
if (strlen(g_Config.cInternalRes) > 1)
|
if (strlen(g_Config.cInternalRes) > 1)
|
||||||
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
|
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
|
||||||
|
|
||||||
|
// Get out of fullscreen
|
||||||
|
g_Config.bFullscreen = false;
|
||||||
|
|
||||||
// FullScreen -> Desktop
|
// FullScreen -> Desktop
|
||||||
ChangeDisplaySettings(NULL, 0);
|
ChangeDisplaySettings(NULL, 0);
|
||||||
|
|
||||||
RECT rcdesktop; // Get desktop resolution
|
// Get desktop resolution
|
||||||
|
RECT rcdesktop;
|
||||||
|
RECT rc = {0, 0, w_fs, h_fs};
|
||||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||||
|
|
||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
|
@ -470,13 +472,7 @@ void ToggleFullscreen(HWND hParent)
|
||||||
// SetWindowPos to the center of the screen
|
// SetWindowPos to the center of the screen
|
||||||
int X = (rcdesktop.right - rcdesktop.left)/2 - (rc.right - rc.left)/2;
|
int X = (rcdesktop.right - rcdesktop.left)/2 - (rc.right - rc.left)/2;
|
||||||
int Y = (rcdesktop.bottom - rcdesktop.top)/2 - (rc.bottom - rc.top)/2;
|
int Y = (rcdesktop.bottom - rcdesktop.top)/2 - (rc.bottom - rc.top)/2;
|
||||||
|
SetWindowPos(hParent, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||||
// Note: we now use the same res for fullscreen and windowed, so we need to check if the window
|
|
||||||
// is not too big here
|
|
||||||
if (w_fs == rcdesktop.right-rcdesktop.left)
|
|
||||||
SetWindowPos(hParent, NULL, X*0.75, Y*0.75, w_fs*0.75, h_fs*0.75, SWP_NOREPOSITION | SWP_NOZORDER);
|
|
||||||
else
|
|
||||||
SetWindowPos(hParent, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
|
|
||||||
|
|
||||||
// Set new window style FS -> Windowed
|
// Set new window style FS -> Windowed
|
||||||
SetWindowLongPtr(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
SetWindowLongPtr(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||||
|
|
|
@ -107,7 +107,7 @@ static bool s_PluginInitialized = false;
|
||||||
|
|
||||||
static u32 s_swapRequested = FALSE;
|
static u32 s_swapRequested = FALSE;
|
||||||
static u32 s_efbAccessRequested = FALSE;
|
static u32 s_efbAccessRequested = FALSE;
|
||||||
static u32 s_FifoShuttingDown = FALSE;
|
static volatile u32 s_FifoShuttingDown = FALSE;
|
||||||
static bool ForceSwap = true;
|
static bool ForceSwap = true;
|
||||||
|
|
||||||
bool IsD3D()
|
bool IsD3D()
|
||||||
|
|
Loading…
Reference in New Issue