From 230731c69d9f0bbd552eb05878701623cce1162a Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Mon, 9 Aug 2004 20:58:32 +0000 Subject: [PATCH] Allow the standard Windows PrtSc action (i.e. copy to clipboard) if HOTKEY_SCREENSHOT has been redefined This was SVN commit r951. --- source/lib/sysdep/win/wsdl.cpp | 20 +++++++++++++------- source/ps/Hotkey.cpp | 12 ++++++++++++ source/ps/Hotkey.h | 2 ++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/source/lib/sysdep/win/wsdl.cpp b/source/lib/sysdep/win/wsdl.cpp index ca967dd5e0..a488ccf806 100755 --- a/source/lib/sysdep/win/wsdl.cpp +++ b/source/lib/sysdep/win/wsdl.cpp @@ -35,6 +35,7 @@ #include "win_internal.h" #include "SDL_vkeys.h" +#include "ps/Hotkey.h" #include #include @@ -446,14 +447,19 @@ LRESULT CALLBACK keyboard_ll_hook(int nCode, WPARAM wParam, LPARAM lParam) // replace Windows PrintScreen handler if(vk == VK_SNAPSHOT) { - // send to wndproc - UINT msg = (UINT)wParam; - PostMessage(hWnd, msg, vk, 0); - // specify hWnd to be safe. - // if window not yet created, it's INVALID_HANDLE_VALUE. + // check whether PrintScreen should be taking screenshots -- if + // not, allow the standard Windows clipboard to work + if(keyRespondsTo(HOTKEY_SCREENSHOT, SDLK_PRINT)) + { + // send to wndproc + UINT msg = (UINT)wParam; + PostMessage(hWnd, msg, vk, 0); + // specify hWnd to be safe. + // if window not yet created, it's INVALID_HANDLE_VALUE. - // don't pass it on to other handlers - return 1; + // don't pass it on to other handlers + return 1; + } } } diff --git a/source/ps/Hotkey.cpp b/source/ps/Hotkey.cpp index 13413f0006..0b8637008b 100755 --- a/source/ps/Hotkey.cpp +++ b/source/ps/Hotkey.cpp @@ -478,3 +478,15 @@ int hotkeyInputHandler( const SDL_Event* ev ) } return( EV_PASS ); } + + +// Returns true if the specified HOTKEY_* responds to the specified SDLK_* +// (mainly for the screenshot system to know whether it needs to override +// the printscreen screen). Ignores modifier keys. +bool keyRespondsTo( int hotkey, int sdlkey ) +{ + for (KeyMapping::iterator it = hotkeyMap[sdlkey].begin(); it != hotkeyMap[sdlkey].end(); ++it) + if (it->mapsTo == hotkey) + return true; + return false; +} diff --git a/source/ps/Hotkey.h b/source/ps/Hotkey.h index a199c587b0..8dcee61d0d 100755 --- a/source/ps/Hotkey.h +++ b/source/ps/Hotkey.h @@ -102,4 +102,6 @@ void initKeyNameMap(); CStr getKeyName( int keycode ); int getKeyCode( CStr keyname ); +bool keyRespondsTo( int hotkey, int sdlkey ); + extern bool hotkeys[HOTKEY_LAST];