mirror of
https://github.com/encounter/SDL.git
synced 2025-12-21 18:59:15 +00:00
Add SDL_GetWindowICCProfile(). (#4314)
* Add SDL_GetWindowICCProfile * Add new SDL display events * Implement ICC profile change event for macOS * Implement ICC profile notification for Windows * Fix SDL_GetWindowICCProfile() for X11 * Fix compile errors
This commit is contained in:
@@ -590,6 +590,30 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void WIN_CheckICMProfileChanged(SDL_Window* window)
|
||||
{
|
||||
SDL_VideoDisplay* display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData* data = (SDL_DisplayData*)display->driverdata;
|
||||
static WCHAR currentIcmFileName[MAX_PATH] = { '\0' };
|
||||
WCHAR icmFileName[MAX_PATH];
|
||||
HDC hdc;
|
||||
SDL_bool succeeded;
|
||||
DWORD fileNameSize = MAX_PATH;
|
||||
|
||||
hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
|
||||
if (hdc) {
|
||||
succeeded = GetICMProfileW(hdc, &fileNameSize, icmFileName);
|
||||
DeleteDC(hdc);
|
||||
if (succeeded) {
|
||||
|
||||
if (SDL_wcsncmp(currentIcmFileName, icmFileName, fileNameSize)) {
|
||||
SDL_wcslcpy(currentIcmFileName, icmFileName, fileNameSize);
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_ICCPROF_CHANGED, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@@ -655,6 +679,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
actually being the foreground window, but this appears to get called in all cases where
|
||||
the global foreground window changes to and from this window. */
|
||||
WIN_UpdateFocus(data->window);
|
||||
WIN_CheckICMProfileChanged(data->window);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1108,6 +1133,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
/* Forces a WM_PAINT event */
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
|
||||
WIN_CheckICMProfileChanged(data->window);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user