src/video/SDL_video.c
changeset 9363 c9a4d606f6db
parent 9278 8900afb78a19
child 9412 8b1436ce1028
equal deleted inserted replaced
9362:dfd8202eb9a7 9363:c9a4d606f6db
  1605 SDL_SetWindowPosition(SDL_Window * window, int x, int y)
  1605 SDL_SetWindowPosition(SDL_Window * window, int x, int y)
  1606 {
  1606 {
  1607     CHECK_WINDOW_MAGIC(window,);
  1607     CHECK_WINDOW_MAGIC(window,);
  1608 
  1608 
  1609     if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
  1609     if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
  1610         SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
  1610         int displayIndex = (x & 0xFFFF);
  1611         int displayIndex;
       
  1612         SDL_Rect bounds;
  1611         SDL_Rect bounds;
       
  1612         if (displayIndex > _this->num_displays) {
       
  1613             displayIndex = 0;
       
  1614         }
  1613 
  1615 
  1614         SDL_zero(bounds);
  1616         SDL_zero(bounds);
  1615 
  1617 
  1616         displayIndex = SDL_GetIndexOfDisplay(display);
       
  1617         SDL_GetDisplayBounds(displayIndex, &bounds);
  1618         SDL_GetDisplayBounds(displayIndex, &bounds);
  1618         if (SDL_WINDOWPOS_ISCENTERED(x)) {
  1619         if (SDL_WINDOWPOS_ISCENTERED(x)) {
  1619             x = bounds.x + (bounds.w - window->w) / 2;
  1620             x = bounds.x + (bounds.w - window->w) / 2;
  1620         }
  1621         }
  1621         if (SDL_WINDOWPOS_ISCENTERED(y)) {
  1622         if (SDL_WINDOWPOS_ISCENTERED(y)) {