src/video/win32/SDL_win32modes.c
changeset 2149 eba4fd03b4f6
parent 2119 9341a884a4d9
child 2859 99210400e8b9
equal deleted inserted replaced
2148:b93d0b4625f6 2149:eba4fd03b4f6
   108         }
   108         }
   109     }
   109     }
   110     return SDL_TRUE;
   110     return SDL_TRUE;
   111 }
   111 }
   112 
   112 
   113 static void
   113 static SDL_bool
   114 WIN_AddDisplay(LPTSTR DeviceName)
   114 WIN_AddDisplay(LPTSTR DeviceName)
   115 {
   115 {
   116     SDL_VideoDisplay display;
   116     SDL_VideoDisplay display;
   117     SDL_DisplayData *displaydata;
   117     SDL_DisplayData *displaydata;
   118     SDL_DisplayMode mode;
   118     SDL_DisplayMode mode;
   119 
   119 
   120 #ifdef DEBUG_MODES
   120 #ifdef DEBUG_MODES
   121     printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
   121     printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
   122 #endif
   122 #endif
   123     if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
   123     if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
   124         return;
   124         return SDL_FALSE;
   125     }
   125     }
   126 
   126 
   127     displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
   127     displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
   128     if (!displaydata) {
   128     if (!displaydata) {
   129         return;
   129         return SDL_FALSE;
   130     }
   130     }
   131     SDL_memcpy(displaydata->DeviceName, DeviceName,
   131     SDL_memcpy(displaydata->DeviceName, DeviceName,
   132                sizeof(displaydata->DeviceName));
   132                sizeof(displaydata->DeviceName));
   133 
   133 
   134     SDL_zero(display);
   134     SDL_zero(display);
   135     display.desktop_mode = mode;
   135     display.desktop_mode = mode;
   136     display.current_mode = mode;
   136     display.current_mode = mode;
   137     display.driverdata = displaydata;
   137     display.driverdata = displaydata;
   138     SDL_AddVideoDisplay(&display);
   138     SDL_AddVideoDisplay(&display);
       
   139     return SDL_TRUE;
   139 }
   140 }
   140 
   141 
   141 void
   142 void
   142 WIN_InitModes(_THIS)
   143 WIN_InitModes(_THIS)
   143 {
   144 {
   144     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   145     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   145     DWORD i, j;
   146     DWORD i, j, count;
   146     DISPLAY_DEVICE device;
   147     DISPLAY_DEVICE device;
   147 
   148 
   148     device.cb = sizeof(device);
   149     device.cb = sizeof(device);
   149     for (i = 0;; ++i) {
   150     for (i = 0;; ++i) {
   150         TCHAR DeviceName[32];
   151         TCHAR DeviceName[32];
   157         }
   158         }
   158         SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName));
   159         SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName));
   159 #ifdef DEBUG_MODES
   160 #ifdef DEBUG_MODES
   160         printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
   161         printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
   161 #endif
   162 #endif
       
   163         count = 0;
   162         for (j = 0;; ++j) {
   164         for (j = 0;; ++j) {
   163             if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
   165             if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
   164                 break;
   166                 break;
   165             }
   167             }
   166             if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
   168             if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
   167                 continue;
   169                 continue;
   168             }
   170             }
   169             WIN_AddDisplay(device.DeviceName);
   171             count += WIN_AddDisplay(device.DeviceName);
   170         }
   172         }
   171         if (j == 0) {
   173         if (count == 0) {
   172             WIN_AddDisplay(DeviceName);
   174             WIN_AddDisplay(DeviceName);
   173         }
   175         }
   174     }
   176     }
   175 }
   177 }
   176 
   178