mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 00:49:48 +00:00
Merge branch 'master' into multi-monitor
This commit is contained in:
+19
-53
@@ -304,37 +304,6 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Translates a Windows key to Unicode
|
||||
//========================================================================
|
||||
|
||||
static void translateChar(_GLFWwindow* window, DWORD wParam, DWORD lParam)
|
||||
{
|
||||
BYTE keyboard_state[256];
|
||||
WCHAR unicode_buf[10];
|
||||
UINT scan_code;
|
||||
int i, num_chars;
|
||||
|
||||
GetKeyboardState(keyboard_state);
|
||||
|
||||
// Derive scan code from lParam and action
|
||||
scan_code = (lParam & 0x01ff0000) >> 16;
|
||||
|
||||
num_chars = ToUnicode(
|
||||
wParam, // virtual-key code
|
||||
scan_code, // scan code
|
||||
keyboard_state, // key-state array
|
||||
unicode_buf, // buffer for translated key
|
||||
10, // size of translated key buffer
|
||||
0 // active-menu flag
|
||||
);
|
||||
|
||||
// Report characters
|
||||
for (i = 0; i < num_chars; i++)
|
||||
_glfwInputChar(window, (int) unicode_buf[i]);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Window callback function (handles window events)
|
||||
//========================================================================
|
||||
@@ -458,13 +427,15 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
case WM_SYSKEYDOWN:
|
||||
{
|
||||
_glfwInputKey(window, translateKey(wParam, lParam), GLFW_PRESS);
|
||||
|
||||
if (_glfwLibrary.charCallback)
|
||||
translateChar(window, (DWORD) wParam, (DWORD) lParam);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CHAR:
|
||||
{
|
||||
_glfwInputChar(window, wParam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
{
|
||||
@@ -1139,6 +1110,7 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
ShowWindow(window->Win32.handle, SW_HIDE);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Write back window parameters into GLFW window structure
|
||||
//========================================================================
|
||||
@@ -1185,28 +1157,22 @@ void _glfwPlatformPollEvents(void)
|
||||
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
switch (msg.message)
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
case WM_QUIT:
|
||||
// Treat WM_QUIT as a close on all windows
|
||||
|
||||
window = _glfwLibrary.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
// Treat WM_QUIT as a close on all windows
|
||||
|
||||
window = _glfwLibrary.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
DispatchMessage(&msg);
|
||||
break;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
|
||||
|
||||
+8
-7
@@ -336,8 +336,9 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
// Cache the actual (as opposed to requested) window parameters
|
||||
_glfwPlatformRefreshWindowParams(window);
|
||||
|
||||
// Cache the actual (as opposed to requested) context parameters
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
// Cache the actual (as opposed to requested) context parameters
|
||||
if (!_glfwRefreshContextParams())
|
||||
{
|
||||
glfwDestroyWindow(window);
|
||||
@@ -353,6 +354,11 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Clearing the front buffer to black to avoid garbage pixels left over
|
||||
// from previous uses of our bit of VRAM
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
_glfwPlatformSwapBuffers(window);
|
||||
|
||||
// Restore the previously current context (or NULL)
|
||||
glfwMakeContextCurrent(previous);
|
||||
|
||||
@@ -361,12 +367,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
if (mode == GLFW_FULLSCREEN)
|
||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
|
||||
|
||||
// Clearing the front buffer to black to avoid garbage pixels left over
|
||||
// from previous uses of our bit of VRAM
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
_glfwPlatformSwapBuffers(window);
|
||||
|
||||
if (wndconfig.visible || mode == GLFW_FULLSCREEN)
|
||||
if (mode == GLFW_FULLSCREEN || wndconfig.visible)
|
||||
glfwShowWindow(window);
|
||||
|
||||
return window;
|
||||
|
||||
Reference in New Issue
Block a user