mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 09:50:52 +00:00
dinput: Acquire device only if specified window has focus in foreground coop level.
This commit is contained in:
parent
6a8bf96d73
commit
f83b53c160
2 changed files with 23 additions and 0 deletions
|
@ -556,6 +556,8 @@ HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
|
|||
HRESULT res;
|
||||
|
||||
if (!This->data_format.user_df) return DIERR_INVALIDPARAM;
|
||||
if (This->dwCoopLevel & DISCL_FOREGROUND && This->win != GetForegroundWindow())
|
||||
return DIERR_OTHERAPPHASPRIO;
|
||||
|
||||
EnterCriticalSection(&This->crit);
|
||||
res = This->acquired ? S_FALSE : DI_OK;
|
||||
|
|
|
@ -72,11 +72,15 @@ static void test_acquire(LPDIRECTINPUT pDI, HWND hwnd)
|
|||
{
|
||||
HRESULT hr;
|
||||
LPDIRECTINPUTDEVICE pMouse = NULL;
|
||||
DIMOUSESTATE2 m_state;
|
||||
|
||||
hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
|
||||
ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %s\n", DXGetErrorString8(hr));
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
|
||||
ok(hr == S_OK, "SetCooperativeLevel: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
hr = IDirectInputDevice_SetDataFormat(pMouse, &c_dfDIMouse);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %s\n", DXGetErrorString8(hr));
|
||||
hr = IDirectInputDevice_Unacquire(pMouse);
|
||||
|
@ -86,6 +90,23 @@ static void test_acquire(LPDIRECTINPUT pDI, HWND hwnd)
|
|||
hr = IDirectInputDevice_Acquire(pMouse);
|
||||
ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have failed: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
/* Foreground coop level requires window to have focus */
|
||||
/* This should make dinput loose mouse input */
|
||||
SetActiveWindow( 0 );
|
||||
|
||||
hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state);
|
||||
todo_wine
|
||||
ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %s\n", DXGetErrorString8(hr));
|
||||
/* Workaround so we can test other things. Remove when Wine is fixed */
|
||||
IDirectInputDevice_Unacquire(pMouse);
|
||||
|
||||
hr = IDirectInputDevice_Acquire(pMouse);
|
||||
ok(hr == DIERR_OTHERAPPHASPRIO, "Acquire() should have failed: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
SetActiveWindow( hwnd );
|
||||
hr = IDirectInputDevice_Acquire(pMouse);
|
||||
ok(hr == S_OK, "Acquire() failed: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
if (pMouse) IUnknown_Release(pMouse);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue