Browse Source

win32 visible, focused, size fix

Henrique Santiago 10 years ago
parent
commit
8a13517714
1 changed files with 30 additions and 4 deletions
  1. 30
    4
      src/framework/win32platform.cpp

+ 30
- 4
src/framework/win32platform.cpp View File

@@ -40,7 +40,7 @@ struct Win32PlatformPrivate {
40 40
     int x, y;
41 41
     int width, height;
42 42
     int minWidth, minHeight;
43
-    bool maximized;
43
+    bool focused, visible, maximized;
44 44
 } win32;
45 45
 
46 46
 void Platform::init(const char *appName)
@@ -299,6 +299,16 @@ void Platform::swapBuffers()
299 299
     SwapBuffers(win32.hdc);
300 300
 }
301 301
 
302
+bool Platform::isWindowFocused()
303
+{
304
+    return win32.focused;
305
+}
306
+
307
+bool Platform::isWindowVisible()
308
+{
309
+    return win32.visible;
310
+}
311
+
302 312
 int Platform::getWindowX()
303 313
 {
304 314
     return win32.x;
@@ -345,8 +355,15 @@ const char *Platform::getAppUserDir()
345 355
 
346 356
 LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
347 357
 {
358
+    static int lastX, lastY;
359
+
348 360
     switch(uMsg)
349 361
     {
362
+    case WM_ACTIVATE:
363
+        {
364
+            win32.focused = !(wParam == WA_INACTIVE);
365
+            break;
366
+        }
350 367
     case WM_CLOSE:
351 368
         {
352 369
             g_engine.onClose();
@@ -361,6 +378,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
361 378
         }
362 379
     case WM_MOVE:
363 380
         {
381
+            lastX = win32.x;
382
+            lastY = win32.y;
364 383
             win32.x = LOWORD(lParam);
365 384
             win32.y = HIWORD(lParam);
366 385
             break;
@@ -370,6 +389,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
370 389
             switch(wParam)
371 390
             {
372 391
             case SIZE_MAXIMIZED:
392
+                win32.x = lastX;
393
+                win32.y = lastY;
373 394
                 win32.maximized = true;
374 395
                 break;
375 396
             case SIZE_RESTORED:
@@ -377,14 +398,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
377 398
                 break;
378 399
             }
379 400
 
380
-            win32.width = LOWORD(lParam);
381
-            win32.height = HIWORD(lParam);
401
+            win32.visible = !(wParam == SIZE_MINIMIZED);
402
+
403
+            if(!win32.maximized) {
404
+                win32.width = LOWORD(lParam);
405
+                win32.height = HIWORD(lParam);
406
+            }
407
+
382 408
             g_engine.onResize(LOWORD(lParam), HIWORD(lParam));
383 409
             break;
384 410
         }
385 411
     default:
386 412
         {
387
-            return DefWindowProc(hWnd,uMsg,wParam,lParam);
413
+            return DefWindowProc(hWnd, uMsg, wParam, lParam);
388 414
         }
389 415
     }
390 416
     return 0;

Loading…
Cancel
Save