Have each game declare a name which is used for window titles etc.
[sgt/puzzles] / windows.c
index 3d9820d..4db17f4 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -234,7 +234,7 @@ static frontend *new_window(HINSTANCE inst)
                       (WS_THICKFRAME | WS_MAXIMIZEBOX | WS_OVERLAPPED),
                       TRUE, 0);
 
-    fe->hwnd = CreateWindowEx(0, "puzzle", "puzzle",
+    fe->hwnd = CreateWindowEx(0, game_name, game_name,
                              WS_OVERLAPPEDWINDOW &~
                              (WS_THICKFRAME | WS_MAXIMIZEBOX),
                              CW_USEDEFAULT, CW_USEDEFAULT,
@@ -438,12 +438,25 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
       case WM_LBUTTONDOWN:
       case WM_RBUTTONDOWN:
       case WM_MBUTTONDOWN:
-       if (!midend_process_key(fe->me, LOWORD(lParam), HIWORD(lParam),
-                               (message == WM_LBUTTONDOWN ? LEFT_BUTTON :
-                                message == WM_RBUTTONDOWN ? RIGHT_BUTTON :
-                                MIDDLE_BUTTON)))
-           PostQuitMessage(0);
-       
+       {
+           int button;
+
+           /*
+            * Shift-clicks count as middle-clicks, since otherwise
+            * two-button Windows users won't have any kind of
+            * middle click to use.
+            */
+           if (message == WM_MBUTTONDOWN || (wParam & MK_SHIFT))
+               button = MIDDLE_BUTTON;
+           else if (message == WM_LBUTTONDOWN)
+               button = LEFT_BUTTON;
+           else
+               button = RIGHT_BUTTON;
+               
+           if (!midend_process_key(fe->me, LOWORD(lParam),
+                                   HIWORD(lParam), button))
+               PostQuitMessage(0);
+       }
        break;
       case WM_CHAR:
        if (!midend_process_key(fe->me, 0, 0, (unsigned char)wParam))
@@ -476,7 +489,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndclass.hbrBackground = NULL;
        wndclass.lpszMenuName = NULL;
-       wndclass.lpszClassName = "puzzle";
+       wndclass.lpszClassName = game_name;
 
        RegisterClass(&wndclass);
     }