Rework the way that windows mouse cursor hiding is done to use the built

in wxWidgets methods.
This commit is contained in:
Glenn Rice 2012-12-16 21:32:14 -06:00
parent 8838944cd3
commit d1a812231e
4 changed files with 14 additions and 61 deletions

View File

@ -201,6 +201,9 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
</Command> </Command>
<Message>Copying Data\* to $(TargetDir)</Message> <Message>Copying Data\* to $(TargetDir)</Message>
</PostBuildEvent> </PostBuildEvent>
<ResourceCompile>
<AdditionalIncludeDirectories>C:\Archives\Dolphin-emu\dolphin-emu-git\Externals\wxWidgets3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'">
<ClCompile> <ClCompile>

View File

@ -1,4 +1,5 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h" #include "resource.h"
#include <wx/msw/wx.rc>
IDI_ICON1 ICON "..\\..\\..\\Installer\\Dolphin.ico" IDI_ICON1 ICON "..\\..\\..\\Installer\\Dolphin.ico"

View File

@ -71,30 +71,7 @@ extern "C" {
}; };
// Windows functions. Setting the cursor with wxSetCursor() did not work in
// this instance. Probably because it's somehow reset from the WndProc() in
// the child window
#ifdef _WIN32 #ifdef _WIN32
// Declare a blank icon and one that will be the normal cursor
HCURSOR hCursor = NULL, hCursorBlank = NULL;
// Create the default cursor
void CreateCursor()
{
hCursor = LoadCursor( NULL, IDC_ARROW );
}
void MSWSetCursor(bool Show)
{
if(Show)
SetCursor(hCursor);
else
{
SetCursor(hCursorBlank);
//wxSetCursor(wxCursor(wxNullCursor));
}
}
// I could not use FindItemByHWND() instead of this, it crashed on that occation I used it */ // I could not use FindItemByHWND() instead of this, it crashed on that occation I used it */
HWND MSWGetParent_(HWND Parent) HWND MSWGetParent_(HWND Parent)
{ {
@ -133,10 +110,11 @@ CPanel::CPanel(
case WM_USER_SETCURSOR: case WM_USER_SETCURSOR:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN) main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN &&
MSWSetCursor(!SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor); SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
SetCursor(wxCURSOR_BLANK);
else else
MSWSetCursor(true); SetCursor(wxCURSOR_ARROW);
break; break;
case WIIMOTE_DISCONNECT: case WIIMOTE_DISCONNECT:
@ -435,9 +413,7 @@ CFrame::CFrame(wxFrame* parent,
// Commit // Commit
m_Mgr->Update(); m_Mgr->Update();
// Create cursors
#ifdef _WIN32 #ifdef _WIN32
CreateCursor();
SetToolTip(wxT("")); SetToolTip(wxT(""));
GetToolTip()->SetAutoPop(25000); GetToolTip()->SetAutoPop(25000);
#endif #endif
@ -494,20 +470,6 @@ void CFrame::OnActive(wxActivateEvent& event)
{ {
if (event.GetActive() && event.GetEventObject() == m_RenderFrame) if (event.GetActive() && event.GetEventObject() == m_RenderFrame)
{ {
// 32x32, 8bpp b/w image
// We want all transparent, so we can just use the same buffer for
// the "image" as for the transparency mask
static const char cursor_data[32 * 32] = { 0 };
#ifdef __WXGTK__
wxCursor cursor_transparent = wxCursor(cursor_data, 32, 32, 6, 14,
cursor_data, wxWHITE, wxBLACK);
#else
wxBitmap cursor_bitmap(cursor_data, 32, 32);
cursor_bitmap.SetMask(new wxMask(cursor_bitmap));
wxCursor cursor_transparent = wxCursor(cursor_bitmap.ConvertToImage());
#endif
#ifdef __WXMSW__ #ifdef __WXMSW__
::SetFocus((HWND)m_RenderParent->GetHandle()); ::SetFocus((HWND)m_RenderParent->GetHandle());
#else #else
@ -516,12 +478,12 @@ void CFrame::OnActive(wxActivateEvent& event)
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
Core::GetState() == Core::CORE_RUN) Core::GetState() == Core::CORE_RUN)
m_RenderParent->SetCursor(cursor_transparent); m_RenderParent->SetCursor(wxCURSOR_BLANK);
} }
else else
{ {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxNullCursor); m_RenderParent->SetCursor(wxCURSOR_ARROW);
} }
} }
event.Skip(); event.Skip();
@ -646,12 +608,12 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
} }
break; break;
#ifdef __WXGTK__
case WM_USER_CREATE: case WM_USER_CREATE:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_BLANK); m_RenderParent->SetCursor(wxCURSOR_BLANK);
break; break;
#ifdef __WXGTK__
case IDM_PANIC: case IDM_PANIC:
{ {
wxString caption = event.GetString().BeforeFirst(':'); wxString caption = event.GetString().BeforeFirst(':');

View File

@ -1059,23 +1059,10 @@ void CFrame::DoPause()
} }
else else
{ {
// 32x32, 8bpp b/w image
// We want all transparent, so we can just use the same buffer for
// the "image" as for the transparency mask
static const char cursor_data[32 * 32] = { 0 };
#ifdef __WXGTK__
wxCursor cursor_transparent = wxCursor(cursor_data, 32, 32, 6, 14,
cursor_data, wxWHITE, wxBLACK);
#else
wxBitmap cursor_bitmap(cursor_data, 32, 32);
cursor_bitmap.SetMask(new wxMask(cursor_bitmap));
wxCursor cursor_transparent = wxCursor(cursor_bitmap.ConvertToImage());
#endif
Core::SetState(Core::CORE_RUN); Core::SetState(Core::CORE_RUN);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
RendererHasFocus()) RendererHasFocus())
m_RenderParent->SetCursor(cursor_transparent); m_RenderParent->SetCursor(wxCURSOR_BLANK);
} }
UpdateGUI(); UpdateGUI();
} }