From 957e7c415e6db8eabbf31f5b2a7ca5b62b436c24 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sun, 8 Aug 2010 00:13:05 +0000 Subject: [PATCH] Several little things: Clean up of the input selected for the opengl x window in linux. Fix a potential segfault when taking a screenshot (happens consistently when using "Save Targets" from the video debugger window). Fix a memory corruption error that results from the wrong image size being passed when dumping textures. Make the screenshot hotkey configurable. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6067 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/ConfigManager.cpp | 1 + Source/Core/Core/Src/CoreParameter.h | 1 + Source/Core/DolphinWX/Src/Frame.cpp | 8 ++++---- Source/Core/DolphinWX/Src/FrameTools.cpp | 6 +++++- Source/Core/DolphinWX/Src/HotkeyDlg.cpp | 1 + Source/Core/DolphinWX/Src/MainNoGUI.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 6 +++--- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h | 1 - Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 5 +++++ Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp | 11 ++++------- 10 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 00b0d08112..7bffdbc2f5 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -34,6 +34,7 @@ static const struct { { "ToggleFullscreen", 13 /* WXK_RETURN */, 0x0001 /* wxMOD_ALT */ }, { "PlayPause", 349 /* WXK_F10 */, 0x0000 /* wxMOD_NONE */ }, { "Stop", 27 /* WXK_ESCAPE */, 0x0000 /* wxMOD_NONE */ }, + { "Screenshot", 348 /* WXK_F9 */, 0x0000 /* wxMOD_NONE */ }, { "Wiimote1Connect", 344 /* WXK_F5 */, 0x0001 /* wxMOD_ALT */ }, { "Wiimote2Connect", 345 /* WXK_F6 */, 0x0001 /* wxMOD_ALT */ }, { "Wiimote3Connect", 346 /* WXK_F7 */, 0x0001 /* wxMOD_ALT */ }, diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 20132c5105..b1b3c0c2cc 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -25,6 +25,7 @@ enum Hotkey { HK_FULLSCREEN, HK_PLAY_PAUSE, HK_STOP, + HK_SCREENSHOT, HK_WIIMOTE1_CONNECT, HK_WIIMOTE2_CONNECT, HK_WIIMOTE3_CONNECT, diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 0069bd6508..7dbaff5670 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -744,6 +744,9 @@ void CFrame::OnKeyDown(wxKeyEvent& event) // Stop else if (IsHotkey(event, HK_STOP)) DoStop(); + // Screenshot hotkey + else if (IsHotkey(event, HK_SCREENSHOT)) + Core::ScreenShot(); // Wiimote connect and disconnect hotkeys else if (IsHotkey(event, HK_WIIMOTE1_CONNECT)) WiimoteId = 0; @@ -753,7 +756,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) WiimoteId = 2; else if (IsHotkey(event, HK_WIIMOTE4_CONNECT)) WiimoteId = 3; - // state save and state load hotkeys + // State save and state load hotkeys else if (event.GetKeyCode() >= WXK_F1 && event.GetKeyCode() <= WXK_F8) { int slot_number = event.GetKeyCode() - WXK_F1 + 1; @@ -775,9 +778,6 @@ void CFrame::OnKeyDown(wxKeyEvent& event) else event.Skip(); } - // screenshot hotkeys - else if (event.GetKeyCode() == WXK_F9 && event.GetModifiers() == wxMOD_NONE) - Core::ScreenShot(); else event.Skip(); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 4de5bf120d..70bbef1b30 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -144,7 +144,7 @@ void CFrame::CreateMenu() skippingMenu->Append(IDM_FRAMESKIP0 + i, wxString::Format(_T("%i"), i), wxEmptyString, wxITEM_RADIO); emulationMenu->AppendSeparator(); - emulationMenu->Append(IDM_SCREENSHOT, _T("Take S&creenshot\tF9")); + emulationMenu->Append(IDM_SCREENSHOT, GetMenuLabel(HK_SCREENSHOT)); emulationMenu->AppendSeparator(); wxMenu *saveMenu = new wxMenu; @@ -311,6 +311,9 @@ wxString CFrame::GetMenuLabel(int Id) case HK_STOP: Label = _T("&Stop\t"); break; + case HK_SCREENSHOT: + Label = _T("Take Screenshot\t"); + break; case HK_WIIMOTE1_CONNECT: case HK_WIIMOTE2_CONNECT: case HK_WIIMOTE3_CONNECT: @@ -1280,6 +1283,7 @@ void CFrame::UpdateGUI() GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->SetItemLabel(GetMenuLabel(HK_FULLSCREEN)); GetMenuBar()->FindItem(IDM_PLAY)->SetItemLabel(GetMenuLabel(HK_PLAY_PAUSE)); GetMenuBar()->FindItem(IDM_STOP)->SetItemLabel(GetMenuLabel(HK_STOP)); + GetMenuBar()->FindItem(IDM_SCREENSHOT)->SetItemLabel(GetMenuLabel(HK_SCREENSHOT)); GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->SetItemLabel(GetMenuLabel(HK_WIIMOTE1_CONNECT)); GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->SetItemLabel(GetMenuLabel(HK_WIIMOTE2_CONNECT)); GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->SetItemLabel(GetMenuLabel(HK_WIIMOTE3_CONNECT)); diff --git a/Source/Core/DolphinWX/Src/HotkeyDlg.cpp b/Source/Core/DolphinWX/Src/HotkeyDlg.cpp index 67e9c2b7d9..625a31b069 100644 --- a/Source/Core/DolphinWX/Src/HotkeyDlg.cpp +++ b/Source/Core/DolphinWX/Src/HotkeyDlg.cpp @@ -191,6 +191,7 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls(void) wxT("Toggle Fullscreen"), wxT("Play/Pause"), wxT("Stop"), + wxT("Take Screenshot"), wxT("Connect Wiimote 1"), wxT("Connect Wiimote 2"), wxT("Connect Wiimote 3"), diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 81ce6852fd..8043b30b16 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -138,7 +138,7 @@ void X11_MainLoop() Display *dpy = XOpenDisplay(0); Window win = (Window)Core::GetWindowHandle(); - XSelectInput(dpy, win, KeyPressMask | KeyReleaseMask | FocusChangeMask); + XSelectInput(dpy, win, KeyPressMask | FocusChangeMask); #if defined(HAVE_XRANDR) && HAVE_XRANDR X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 0656aa5a10..8e571651c4 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -115,8 +115,7 @@ void CreateXWindow (void) // Setup window attributes GLWin.attr.colormap = XCreateColormap(GLWin.dpy, GLWin.parent, GLWin.vi->visual, AllocNone); - GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | - StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask; + GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask; GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen); GLWin.attr.border_pixel = 0; @@ -348,7 +347,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLWin.screen = DefaultScreen(GLWin.dpy); if (GLWin.parent == 0) GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen); - XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL); glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion); @@ -404,8 +402,10 @@ bool OpenGL_MakeCurrent() #elif defined(_WIN32) return wglMakeCurrent(hDC,hRC) ? true : false; #elif defined(HAVE_X11) && HAVE_X11 +#if defined(HAVE_WX) && (HAVE_WX) g_VideoInitialize.pRequestWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); +#endif return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); #endif return true; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index 91077ad6de..6ca927bc5c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -40,7 +40,6 @@ #elif defined(HAVE_X11) && HAVE_X11 #include -#include #include #include #include "Thread.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 631158a14b..6a38108461 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -496,6 +496,11 @@ void Renderer::Shutdown(void) } #endif +#if defined(HAVE_WX) && HAVE_WX + if (scrshotThread) + delete scrshotThread; +#endif + g_framebufferManager.Shutdown(); #ifdef _WIN32 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index c558d1f9a9..7224adaf0a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -583,13 +583,12 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width entry.SetTextureParameters(tm0,tm1); if (g_ActiveConfig.bDumpTextures) // dump texture to file { - char szTemp[MAX_PATH]; char szDir[MAX_PATH]; const char* uniqueId = globals->unique_id; - bool bCheckedDumpDir = false; + static bool bCheckedDumpDir = false; - sprintf(szDir,"%s%s",File::GetUserPath(D_DUMPTEXTURES_IDX), uniqueId); + sprintf(szDir,"%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), uniqueId); if(!bCheckedDumpDir) { @@ -599,11 +598,9 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width bCheckedDumpDir = true; } - sprintf(szTemp, "%s/%s_%08x_%i.tga",szDir, uniqueId, (unsigned int) texHash, tex_format); + sprintf(szTemp, "%s/%s_%08x_%i.tga", szDir, uniqueId, (unsigned int) texHash, tex_format); if (!File::Exists(szTemp)) - { - SaveTexture(szTemp, target, entry.texture, expandedWidth, expandedHeight); - } + SaveTexture(szTemp, target, entry.texture, entry.w, entry.h); } INCSTAT(stats.numTexturesCreated);