st/wgl: Release stw_framebuffer::mutex after pbuffer creation.
[mesa.git] / src / gallium / state_trackers / wgl / stw_ext_pbuffer.c
index fb5d5e8b9296f1a848f9a014f1ea9cadf914c973..252d07a90cc216f85e8f93384b207a1c094e5765 100644 (file)
 #include "stw_framebuffer.h"
 
 
+#define LARGE_WINDOW_SIZE 60000
+
+
+static LRESULT CALLBACK
+WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    MINMAXINFO *pMMI;
+    switch (uMsg) {
+    case WM_GETMINMAXINFO:
+        // Allow to create a window bigger than the desktop
+        pMMI = (MINMAXINFO *)lParam;
+        pMMI->ptMaxSize.x = LARGE_WINDOW_SIZE;
+        pMMI->ptMaxSize.y = LARGE_WINDOW_SIZE;
+        pMMI->ptMaxTrackSize.x = LARGE_WINDOW_SIZE;
+        pMMI->ptMaxTrackSize.y = LARGE_WINDOW_SIZE;
+        break;
+    default:
+        break;
+    }
+
+    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+
 HPBUFFERARB WINAPI
 wglCreatePbufferARB(HDC _hDC,
                     int iPixelFormat,
@@ -109,7 +133,7 @@ wglCreatePbufferARB(HDC _hDC,
       wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
       wc.hCursor = LoadCursor(NULL, IDC_ARROW);
       wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
-      wc.lpfnWndProc = DefWindowProc;
+      wc.lpfnWndProc = WndProc;
       wc.lpszClassName = "wglpbuffer";
       wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
       RegisterClass(&wc);
@@ -185,6 +209,8 @@ wglCreatePbufferARB(HDC _hDC,
    fb = stw_framebuffer_create(hDC, iPixelFormat);
    if (!fb) {
       SetLastError(ERROR_NO_SYSTEM_RESOURCES);
+   } else {
+      stw_framebuffer_release(fb);
    }
 
    return (HPBUFFERARB)fb;
@@ -244,7 +270,7 @@ wglQueryPbufferARB(HPBUFFERARB hPbuffer,
       *piValue = fb->width;
       return TRUE;
    case WGL_PBUFFER_HEIGHT_ARB:
-      *piValue = fb->width;
+      *piValue = fb->height;
       return TRUE;
    case WGL_PBUFFER_LOST_ARB:
       /* We assume that no content is ever lost due to display mode change */