Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/common/colorspaces.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2010-2025 darktable developers.
Copyright (C) 2010-2026 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,6 +37,11 @@
#include "colord-gtk.h"
#endif

#ifdef _WIN32
#include <dwmapi.h>
#include <gdk/gdkwin32.h>
#endif

#if 0
#include <ApplicationServices/ApplicationServices.h>
#include <Carbon/Carbon.h>
Expand Down Expand Up @@ -2009,7 +2014,18 @@ void dt_colorspaces_set_display_profile
profile_source = g_strdup("osx color profile api");
#endif
#elif defined G_OS_WIN32
HDC hdc = GetDC(NULL);
GtkWidget *widget = (profile_type == DT_COLORSPACE_DISPLAY2)
? darktable.develop->second_wnd
: dt_ui_center(darktable.gui->ui);
GdkWindow *window = gtk_widget_get_window(widget);
HWND hwnd = (HWND)gdk_win32_window_get_handle(window); // get window handle
HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); // get monitor handle
if(!hMonitor){ dt_print(DT_DEBUG_ALWAYS, "[win32 dt_colorspaces_set_display_profile] error getting monitor handle"); return;}
MONITORINFOEX monitorInfo;
monitorInfo.cbSize = sizeof(MONITORINFOEX);
if(!GetMonitorInfoW(hMonitor, (LPMONITORINFO) &monitorInfo)) //get monitor info
{ dt_print(DT_DEBUG_ALWAYS, "[win32 dt_colorspaces_set_display_profile] error getting monitor info"); return;}
HDC hdc = CreateIC(L"MONITOR", monitorInfo.szDevice, NULL, NULL); // get device-info context of the monitor
if(hdc != NULL)
{
DWORD len = 0;
Expand All @@ -2028,7 +2044,7 @@ void dt_colorspaces_set_display_profile
}
}
g_free(wpath);
ReleaseDC(NULL, hdc);
DeleteDC(hdc);
}
profile_source = g_strdup("windows color profile api");
#endif
Expand Down