diff src/video/win32/SDL_win32window.c @ 4661:03dcb795c583

Merged changes from the main SDL codebase
author Sam Lantinga <slouken@libsdl.org>
date Mon, 12 Jul 2010 21:09:23 -0700
parents 7ad7a473b086 eff4e88cc1e8
children c24ba2cc9583
line wrap: on
line diff
--- a/src/video/win32/SDL_win32window.c	Mon Jul 12 22:03:25 2010 -0400
+++ b/src/video/win32/SDL_win32window.c	Mon Jul 12 21:09:23 2010 -0700
@@ -73,9 +73,6 @@
 
 #endif
 
-extern HCTX *g_hCtx;            /* the table of tablet event contexts, each windows has to have it's own tablet context */
-static Uint32 highestId = 0;    /* the highest id of the tablet context */
-
 /* Fake window to help with DirectInput events. */
 HWND SDL_HelperWindow = NULL;
 static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
@@ -165,9 +162,8 @@
         }
     }
     if (GetFocus() == hwnd) {
-        int index = data->videodata->keyboard;
         window->flags |= SDL_WINDOW_INPUT_FOCUS;
-        SDL_SetKeyboardFocus(index, data->window);
+        SDL_SetKeyboardFocus(data->window);
 
         if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
             RECT rect;
@@ -186,13 +182,8 @@
 int
 WIN_CreateWindow(_THIS, SDL_Window * window)
 {
-    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     SDL_VideoDisplay *display = window->display;
-    RAWINPUTDEVICE Rid;
-    AXIS TabX, TabY;
-    LOGCONTEXTA lc;
     HWND hwnd;
-    HWND top;
     RECT rect;
     SDL_Rect bounds;
     DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
@@ -210,11 +201,6 @@
     }
 
     /* Figure out what the window area will be */
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        top = HWND_TOPMOST;
-    } else {
-        top = HWND_NOTOPMOST;
-    }
     rect.left = 0;
     rect.top = 0;
     rect.right = window->w;
@@ -224,9 +210,17 @@
     h = (rect.bottom - rect.top);
 
     WIN_GetDisplayBounds(_this, display, &bounds);
+    if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        /* The bounds when this window is visible is the fullscreen mode */
+        SDL_DisplayMode fullscreen_mode;
+        if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
+            bounds.w = fullscreen_mode.w;
+            bounds.h = fullscreen_mode.h;
+        }
+    }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->x == SDL_WINDOWPOS_CENTERED) {
-        x = bounds.x + (bounds.w - window->w) / 2;
+        x = bounds.x + (bounds.w - w) / 2;
     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
         if (bounds.x == 0) {
             x = CW_USEDEFAULT;
@@ -238,7 +232,7 @@
     }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->y == SDL_WINDOWPOS_CENTERED) {
-        y = bounds.y + (bounds.h - window->h) / 2;
+        y = bounds.y + (bounds.h - h) / 2;
     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
         if (bounds.x == 0) {
             y = CW_USEDEFAULT;
@@ -256,52 +250,7 @@
         WIN_SetError("Couldn't create window");
         return -1;
     }
-	/*Disable Tablet support, replace with multi-touch.*/
-#if 0 
-    /* we're configuring the tablet data. See Wintab reference for more info */
-    if (videodata->wintabDLL
-        && videodata->WTInfoA(WTI_DEFSYSCTX, 0, &lc) != 0) {
-        lc.lcPktData = PACKETDATA;
-        lc.lcPktMode = PACKETMODE;
-        lc.lcOptions |= CXO_MESSAGES;
-        lc.lcOptions |= CXO_SYSTEM;
-        lc.lcMoveMask = PACKETDATA;
-        lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA;
-        videodata->WTInfoA(WTI_DEVICES, DVC_X, &TabX);
-        videodata->WTInfoA(WTI_DEVICES, DVC_Y, &TabY);
-        lc.lcInOrgX = 0;
-        lc.lcInOrgY = 0;
-        lc.lcInExtX = TabX.axMax;
-        lc.lcInExtY = TabY.axMax;
-        lc.lcOutOrgX = 0;
-        lc.lcOutOrgY = 0;
-        lc.lcOutExtX = GetSystemMetrics(SM_CXSCREEN);
-        lc.lcOutExtY = -GetSystemMetrics(SM_CYSCREEN);
-        if (window->id > highestId) {
-            HCTX *tmp_hctx;
-            highestId = window->id;
-            tmp_hctx =
-                (HCTX *) SDL_realloc(g_hCtx, (highestId + 1) * sizeof(HCTX));
-            if (!tmp_hctx) {
-                SDL_OutOfMemory();
-                DestroyWindow(hwnd);
-                return -1;
-            }
-            g_hCtx = tmp_hctx;
-        }
-        g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE);
-    }
-#else 
 	//RegisterTouchWindow(hwnd, 0);
-#endif 
-#ifndef _WIN32_WCE              /* has no RawInput */
-    /* we're telling the window, we want it to report raw input events from mice */
-    Rid.usUsagePage = 0x01;
-    Rid.usUsage = 0x02;
-    Rid.dwFlags = RIDEV_INPUTSINK;
-    Rid.hwndTarget = hwnd;
-    RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
-#endif
 
     WIN_PumpEvents(_this);
 
@@ -441,6 +390,7 @@
     HWND top;
     BOOL menu;
     int x, y;
+    int w, h;
 
     /* Figure out what the window area will be */
     if (window->flags & SDL_WINDOW_FULLSCREEN) {
@@ -459,17 +409,27 @@
     menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
 #endif
     AdjustWindowRectEx(&rect, style, menu, 0);
+    w = (rect.right - rect.left);
+    h = (rect.bottom - rect.top);
 
     WIN_GetDisplayBounds(_this, display, &bounds);
+    if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        /* The bounds when this window is visible is the fullscreen mode */
+        SDL_DisplayMode fullscreen_mode;
+        if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
+            bounds.w = fullscreen_mode.w;
+            bounds.h = fullscreen_mode.h;
+        }
+    }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->x == SDL_WINDOWPOS_CENTERED) {
-        x = bounds.x + (bounds.w - window->w) / 2;
+        x = bounds.x + (bounds.w - w) / 2;
     } else {
         x = bounds.x + window->x + rect.left;
     }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->y == SDL_WINDOWPOS_CENTERED) {
-        y = bounds.y + (bounds.h - window->h) / 2;
+        y = bounds.y + (bounds.h - h) / 2;
     } else {
         y = bounds.y + window->y + rect.top;
     }
@@ -624,15 +584,11 @@
 void
 WIN_DestroyWindow(_THIS, SDL_Window * window)
 {
-    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
 
     if (data) {
         ReleaseDC(data->hwnd, data->hdc);
         if (data->created) {
-            if (videodata->wintabDLL) {
-                videodata->WTClose(g_hCtx[window->id]);
-            }
             DestroyWindow(data->hwnd);
         }
         SDL_free(data);
@@ -678,8 +634,7 @@
     /* Register the class. */
     SDL_HelperWindowClass = RegisterClass(&wce);
     if (SDL_HelperWindowClass == 0) {
-        SDL_SetError("Unable to create Helper Window Class: error %d.",
-                     GetLastError());
+        WIN_SetError("Unable to create Helper Window Class");
         return -1;
     }
 
@@ -697,8 +652,7 @@
                                       hInstance, NULL);
     if (SDL_HelperWindow == NULL) {
         UnregisterClass(SDL_HelperWindowClassName, hInstance);
-        SDL_SetError("Unable to create Helper Window: error %d.",
-                     GetLastError());
+        WIN_SetError("Unable to create Helper Window");
         return -1;
     }
 
@@ -717,8 +671,7 @@
     /* Destroy the window. */
     if (SDL_HelperWindow != NULL) {
         if (DestroyWindow(SDL_HelperWindow) == 0) {
-            SDL_SetError("Unable to destroy Helper Window: error %d.",
-                         GetLastError());
+            WIN_SetError("Unable to destroy Helper Window");
             return;
         }
         SDL_HelperWindow = NULL;
@@ -727,8 +680,7 @@
     /* Unregister the class. */
     if (SDL_HelperWindowClass != 0) {
         if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
-            SDL_SetError("Unable to destroy Helper Window Class: error %d.",
-                         GetLastError());
+            WIN_SetError("Unable to destroy Helper Window Class");
             return;
         }
         SDL_HelperWindowClass = 0;