src/video/windows/SDL_windowswindow.c
changeset 12153 de4288fa5b0b
parent 12070 1d65571b57dd
child 12231 e653f009e6c0
child 12349 a67dedb293c8
equal deleted inserted replaced
12152:cb129c06aa86 12153:de4288fa5b0b
    96         /* You can have a borderless resizable window */
    96         /* You can have a borderless resizable window */
    97         if (window->flags & SDL_WINDOW_RESIZABLE) {
    97         if (window->flags & SDL_WINDOW_RESIZABLE) {
    98             style |= STYLE_RESIZABLE;
    98             style |= STYLE_RESIZABLE;
    99         }
    99         }
   100 
   100 
   101 		/* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
   101         /* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
   102 		if ( window->flags & SDL_WINDOW_MINIMIZED )
   102         if (window->flags & SDL_WINDOW_MINIMIZED) {
   103 			style |= WS_MINIMIZE;
   103             style |= WS_MINIMIZE;
       
   104         }
   104     }
   105     }
   105     return style;
   106     return style;
   106 }
   107 }
   107 
   108 
   108 static void
   109 static void
   332     }
   333     }
   333 
   334 
   334     /* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
   335     /* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
   335     SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
   336     SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
   336 
   337 
   337 	if ( window->flags & SDL_WINDOW_MINIMIZED )
   338     if (window->flags & SDL_WINDOW_MINIMIZED) {
   338 		ShowWindow( hwnd, SW_SHOWMINNOACTIVE );
   339         ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
       
   340     }
   339 
   341 
   340     if (!(window->flags & SDL_WINDOW_OPENGL)) {
   342     if (!(window->flags & SDL_WINDOW_OPENGL)) {
   341         return 0;
   343         return 0;
   342     }
   344     }
   343 
   345 
   407             */
   409             */
   408             SDL_Window *otherWindow = NULL;
   410             SDL_Window *otherWindow = NULL;
   409             SDL_sscanf(hint, "%p", (void**)&otherWindow);
   411             SDL_sscanf(hint, "%p", (void**)&otherWindow);
   410 
   412 
   411             /* Do some error checking on the pointer */
   413             /* Do some error checking on the pointer */
   412             if (otherWindow != NULL && otherWindow->magic == &_this->window_magic)
   414             if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) {
   413             {
       
   414                 /* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */
   415                 /* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */
   415                 if (otherWindow->flags & SDL_WINDOW_OPENGL)
   416                 if (otherWindow->flags & SDL_WINDOW_OPENGL) {
   416                 {
       
   417                     window->flags |= SDL_WINDOW_OPENGL;
   417                     window->flags |= SDL_WINDOW_OPENGL;
   418                     if(!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
   418                     if (!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
   419                         return -1;
   419                         return -1;
   420                     }
   420                     }
   421                 }
   421                 }
   422             }
   422             }
   423         }
   423         }
   546 }
   546 }
   547 
   547 
   548 void
   548 void
   549 WIN_ShowWindow(_THIS, SDL_Window * window)
   549 WIN_ShowWindow(_THIS, SDL_Window * window)
   550 {
   550 {
   551 	DWORD style;
   551     DWORD style;
   552 	HWND hwnd;
   552     HWND hwnd;
   553 	int nCmdShow;
   553     int nCmdShow;
   554 	
   554     
   555 	hwnd = ( (SDL_WindowData *)window->driverdata )->hwnd;
   555     hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
   556 	nCmdShow = SW_SHOW;
   556     nCmdShow = SW_SHOW;
   557 	style = GetWindowLong(hwnd, GWL_EXSTYLE);
   557     style = GetWindowLong(hwnd, GWL_EXSTYLE);
   558 	if ( style & WS_EX_NOACTIVATE )
   558     if (style & WS_EX_NOACTIVATE) {
   559 		nCmdShow = SW_SHOWNOACTIVATE;
   559         nCmdShow = SW_SHOWNOACTIVATE;
   560 	
   560     }
   561     ShowWindow(hwnd, nCmdShow );
   561     ShowWindow(hwnd, nCmdShow);
   562 }
   562 }
   563 
   563 
   564 void
   564 void
   565 WIN_HideWindow(_THIS, SDL_Window * window)
   565 WIN_HideWindow(_THIS, SDL_Window * window)
   566 {
   566 {
   900 void
   900 void
   901 WIN_UpdateClipCursor(SDL_Window *window)
   901 WIN_UpdateClipCursor(SDL_Window *window)
   902 {
   902 {
   903     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   903     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   904     SDL_Mouse *mouse = SDL_GetMouse();
   904     SDL_Mouse *mouse = SDL_GetMouse();
       
   905     RECT rect;
   905 
   906 
   906     if (data->focus_click_pending) {
   907     if (data->focus_click_pending) {
   907         return;
   908         return;
   908     }
   909     }
   909 
   910 
   910     if ((mouse->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
   911     if ((mouse->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
   911         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   912         (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   912         if (mouse->relative_mode && !mouse->relative_mode_warp) {
   913         if (mouse->relative_mode && !mouse->relative_mode_warp) {
   913             LONG cx, cy;
   914             LONG cx, cy;
   914             RECT rect;
       
   915             GetWindowRect(data->hwnd, &rect);
   915             GetWindowRect(data->hwnd, &rect);
   916 
   916 
   917             cx = (rect.left + rect.right) / 2;
   917             cx = (rect.left + rect.right) / 2;
   918             cy = (rect.top + rect.bottom) / 2;
   918             cy = (rect.top + rect.bottom) / 2;
   919 
   919 
   921             rect.left = cx - 1;
   921             rect.left = cx - 1;
   922             rect.right = cx + 1;
   922             rect.right = cx + 1;
   923             rect.top = cy - 1;
   923             rect.top = cy - 1;
   924             rect.bottom = cy + 1;
   924             rect.bottom = cy + 1;
   925 
   925 
   926             ClipCursor(&rect);
   926             if (ClipCursor(&rect)) {
       
   927                 data->cursor_clipped_rect = rect;
       
   928             }
   927         } else {
   929         } else {
   928             RECT rect;
       
   929             if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
   930             if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
   930                 ClientToScreen(data->hwnd, (LPPOINT) & rect);
   931                 ClientToScreen(data->hwnd, (LPPOINT) & rect);
   931                 ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
   932                 ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
   932                 ClipCursor(&rect);
   933                 if (ClipCursor(&rect)) {
       
   934                     data->cursor_clipped_rect = rect;
       
   935                 }
   933             }
   936             }
   934         }
   937         }
   935     } else {
   938     } else if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
   936         ClipCursor(NULL);
   939         ClipCursor(NULL);
       
   940         SDL_zero(data->cursor_clipped_rect);
   937     }
   941     }
   938 }
   942 }
   939 
   943 
   940 int
   944 int
   941 WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
   945 WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)