1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00

Change freeglut to only look for ctrl/alt/shift down events when window

has focus.

Previously this functionality was in libqb.
This commit is contained in:
Luke Ceddia 2017-10-10 13:47:10 +11:00
parent 6e0fd03256
commit 86a6646bdb
2 changed files with 50 additions and 59 deletions

View file

@ -29745,23 +29745,12 @@ void sub__maptriangle(int32 cull_options,float sx1,float sy1,float sx2,float sy2
if (key==GLUT_KEY_INSERT){vk=0x5200;} if (key==GLUT_KEY_INSERT){vk=0x5200;}
#ifdef CORE_FREEGLUT #ifdef CORE_FREEGLUT
#ifdef QB64_WINDOWS if (key==112){vk=VK+QBVK_LSHIFT;}
if (window_handle==GetForegroundWindow()) { if (key==113){vk=VK+QBVK_RSHIFT;}
if (key==112){vk=VK+QBVK_LSHIFT;} if (key==114){vk=VK+QBVK_LCTRL;}
if (key==113){vk=VK+QBVK_RSHIFT;} if (key==115){vk=VK+QBVK_RCTRL;}
if (key==114){vk=VK+QBVK_LCTRL;} if (key==116){vk=VK+QBVK_LALT;}
if (key==115){vk=VK+QBVK_RCTRL;} if (key==117){vk=VK+QBVK_RALT;}
if (key==116){vk=VK+QBVK_LALT;}
if (key==117){vk=VK+QBVK_RALT;}
}
#else
if (key==112){vk=VK+QBVK_LSHIFT;}
if (key==113){vk=VK+QBVK_RSHIFT;}
if (key==114){vk=VK+QBVK_LCTRL;}
if (key==115){vk=VK+QBVK_RCTRL;}
if (key==116){vk=VK+QBVK_LALT;}
if (key==117){vk=VK+QBVK_RALT;}
#endif
#endif #endif
if (vk!=-1){ if (vk!=-1){

View file

@ -1948,59 +1948,61 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
if ( window ) if ( window )
{ {
/* Checking for CTRL, ALT, and SHIFT key positions: Key Down! */ /* Checking for CTRL, ALT, and SHIFT key positions: Key Down! */
if ( !lControl && GetAsyncKeyState ( VK_LCONTROL ) ) if (hWnd == GetForegroundWindow()) {
{ if ( !lControl && GetAsyncKeyState ( VK_LCONTROL ) )
INVOKE_WCB ( *window, Special, {
( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY ) INVOKE_WCB ( *window, Special,
); ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
);
lControl = 1; lControl = 1;
} }
if ( !rControl && GetAsyncKeyState ( VK_RCONTROL ) ) if ( !rControl && GetAsyncKeyState ( VK_RCONTROL ) )
{ {
INVOKE_WCB ( *window, Special, INVOKE_WCB ( *window, Special,
( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY ) ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
); );
rControl = 1; rControl = 1;
} }
if ( !lShift && GetAsyncKeyState ( VK_LSHIFT ) ) if ( !lShift && GetAsyncKeyState ( VK_LSHIFT ) )
{ {
INVOKE_WCB ( *window, Special, INVOKE_WCB ( *window, Special,
( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY ) ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
); );
lShift = 1; lShift = 1;
} }
if ( !rShift && GetAsyncKeyState ( VK_RSHIFT ) ) if ( !rShift && GetAsyncKeyState ( VK_RSHIFT ) )
{ {
INVOKE_WCB ( *window, Special, INVOKE_WCB ( *window, Special,
( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY ) ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
); );
rShift = 1; rShift = 1;
} }
if ( !lAlt && GetAsyncKeyState ( VK_LMENU ) ) if ( !lAlt && GetAsyncKeyState ( VK_LMENU ) )
{ {
INVOKE_WCB ( *window, Special, INVOKE_WCB ( *window, Special,
( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY ) ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
); );
lAlt = 1; lAlt = 1;
} }
if ( !rAlt && GetAsyncKeyState ( VK_RMENU ) ) if ( !rAlt && GetAsyncKeyState ( VK_RMENU ) )
{ {
INVOKE_WCB ( *window, Special, INVOKE_WCB ( *window, Special,
( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY ) ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
); );
rAlt = 1; rAlt = 1;
} }
}
/* Checking for CTRL, ALT, and SHIFT key positions: Key Up! */ /* Checking for CTRL, ALT, and SHIFT key positions: Key Up! */
if ( lControl && !GetAsyncKeyState ( VK_LCONTROL ) ) if ( lControl && !GetAsyncKeyState ( VK_LCONTROL ) )