src/video/win32_v.cpp
branchgamebalance
changeset 9911 0b8b245a2391
parent 9910 0b2aebc8283e
child 9913 e79cd19772dd
--- a/src/video/win32_v.cpp	Wed Jun 13 11:17:30 2007 +0000
+++ b/src/video/win32_v.cpp	Wed Jun 13 11:45:14 2007 +0000
@@ -212,6 +212,7 @@
 static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	static uint32 keycode = 0;
+	static bool console = false;
 
 	switch (msg) {
 		case WM_CREATE:
@@ -363,12 +364,23 @@
 		}
 #endif /* UNICODE */
 
+		case WM_DEADCHAR:
+			console = GB(lParam, 16, 8) == 41;
+			return 0;
+
 		case WM_CHAR: {
 			/* Silently drop all non-text messages as those were handled by WM_KEYDOWN */
 			if (wParam < VK_SPACE) return 0;
 			uint scancode = GB(lParam, 16, 8);
 			uint charcode = wParam;
 
+			/* If the console key is a dead-key, we need to press it twice to get a WM_CHAR message.
+			 * But we then get two WM_CHAR messages, so ignore the first one */
+			if (console && scancode == 41) {
+				console = false;
+				return 0;
+			}
+
 #if !defined(UNICODE)
 			wchar_t w;
 			int len = MultiByteToWideChar(_codepage, 0, (char*)&charcode, 1, &w, 1);
@@ -659,7 +671,7 @@
 
 	if (_wnd.double_size) {
 		w = ALIGN(w, 4);
-		_wnd.alloced_bits = _wnd.buffer_bits = (Pixel*)malloc(w * h);
+		_wnd.alloced_bits = _wnd.buffer_bits = (Pixel *)malloc(w * h * sizeof(Pixel));
 		w *= 2;
 		h *= 2;
 	}