src/video/windows/SDL_windowswindow.c
changeset 12153 de4288fa5b0b
parent 12070 1d65571b57dd
child 12231 e653f009e6c0
child 12349 a67dedb293c8
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Fri Aug 24 10:41:57 2018 -0700
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Sun Aug 26 10:34:23 2018 -0700
     1.3 @@ -98,9 +98,10 @@
     1.4              style |= STYLE_RESIZABLE;
     1.5          }
     1.6  
     1.7 -		/* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
     1.8 -		if ( window->flags & SDL_WINDOW_MINIMIZED )
     1.9 -			style |= WS_MINIMIZE;
    1.10 +        /* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
    1.11 +        if (window->flags & SDL_WINDOW_MINIMIZED) {
    1.12 +            style |= WS_MINIMIZE;
    1.13 +        }
    1.14      }
    1.15      return style;
    1.16  }
    1.17 @@ -334,8 +335,9 @@
    1.18      /* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
    1.19      SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
    1.20  
    1.21 -	if ( window->flags & SDL_WINDOW_MINIMIZED )
    1.22 -		ShowWindow( hwnd, SW_SHOWMINNOACTIVE );
    1.23 +    if (window->flags & SDL_WINDOW_MINIMIZED) {
    1.24 +        ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
    1.25 +    }
    1.26  
    1.27      if (!(window->flags & SDL_WINDOW_OPENGL)) {
    1.28          return 0;
    1.29 @@ -409,13 +411,11 @@
    1.30              SDL_sscanf(hint, "%p", (void**)&otherWindow);
    1.31  
    1.32              /* Do some error checking on the pointer */
    1.33 -            if (otherWindow != NULL && otherWindow->magic == &_this->window_magic)
    1.34 -            {
    1.35 +            if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) {
    1.36                  /* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */
    1.37 -                if (otherWindow->flags & SDL_WINDOW_OPENGL)
    1.38 -                {
    1.39 +                if (otherWindow->flags & SDL_WINDOW_OPENGL) {
    1.40                      window->flags |= SDL_WINDOW_OPENGL;
    1.41 -                    if(!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
    1.42 +                    if (!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
    1.43                          return -1;
    1.44                      }
    1.45                  }
    1.46 @@ -548,17 +548,17 @@
    1.47  void
    1.48  WIN_ShowWindow(_THIS, SDL_Window * window)
    1.49  {
    1.50 -	DWORD style;
    1.51 -	HWND hwnd;
    1.52 -	int nCmdShow;
    1.53 -	
    1.54 -	hwnd = ( (SDL_WindowData *)window->driverdata )->hwnd;
    1.55 -	nCmdShow = SW_SHOW;
    1.56 -	style = GetWindowLong(hwnd, GWL_EXSTYLE);
    1.57 -	if ( style & WS_EX_NOACTIVATE )
    1.58 -		nCmdShow = SW_SHOWNOACTIVATE;
    1.59 -	
    1.60 -    ShowWindow(hwnd, nCmdShow );
    1.61 +    DWORD style;
    1.62 +    HWND hwnd;
    1.63 +    int nCmdShow;
    1.64 +    
    1.65 +    hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
    1.66 +    nCmdShow = SW_SHOW;
    1.67 +    style = GetWindowLong(hwnd, GWL_EXSTYLE);
    1.68 +    if (style & WS_EX_NOACTIVATE) {
    1.69 +        nCmdShow = SW_SHOWNOACTIVATE;
    1.70 +    }
    1.71 +    ShowWindow(hwnd, nCmdShow);
    1.72  }
    1.73  
    1.74  void
    1.75 @@ -902,6 +902,7 @@
    1.76  {
    1.77      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.78      SDL_Mouse *mouse = SDL_GetMouse();
    1.79 +    RECT rect;
    1.80  
    1.81      if (data->focus_click_pending) {
    1.82          return;
    1.83 @@ -911,7 +912,6 @@
    1.84          (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
    1.85          if (mouse->relative_mode && !mouse->relative_mode_warp) {
    1.86              LONG cx, cy;
    1.87 -            RECT rect;
    1.88              GetWindowRect(data->hwnd, &rect);
    1.89  
    1.90              cx = (rect.left + rect.right) / 2;
    1.91 @@ -923,17 +923,21 @@
    1.92              rect.top = cy - 1;
    1.93              rect.bottom = cy + 1;
    1.94  
    1.95 -            ClipCursor(&rect);
    1.96 +            if (ClipCursor(&rect)) {
    1.97 +                data->cursor_clipped_rect = rect;
    1.98 +            }
    1.99          } else {
   1.100 -            RECT rect;
   1.101              if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
   1.102                  ClientToScreen(data->hwnd, (LPPOINT) & rect);
   1.103                  ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
   1.104 -                ClipCursor(&rect);
   1.105 +                if (ClipCursor(&rect)) {
   1.106 +                    data->cursor_clipped_rect = rect;
   1.107 +                }
   1.108              }
   1.109          }
   1.110 -    } else {
   1.111 +    } else if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
   1.112          ClipCursor(NULL);
   1.113 +        SDL_zero(data->cursor_clipped_rect);
   1.114      }
   1.115  }
   1.116