63#if defined GDK_WINDOWING_X11
65 GdkWindow *
window = gtk_widget_get_window(widget);
66 GdkScreen *screen = gtk_widget_get_screen(widget);
67 if(
IS_NULL_PTR(screen)) screen = gdk_screen_get_default();
69 GdkDisplay *display = gtk_widget_get_display(widget);
70 const int monitor = _monitor_index(gdk_display_get_monitor_at_window(display,
window));
74 atom_name = g_strdup_printf(
"_ICC_PROFILE_%d", monitor);
76 atom_name = g_strdup(
"_ICC_PROFILE");
78 *source = g_strdup_printf(
"xatom %s", atom_name);
80 GdkAtom
type = GDK_NONE;
82 gdk_property_get(gdk_screen_get_root_window(screen), gdk_atom_intern(atom_name,
FALSE), GDK_NONE, 0,
83 64 * 1024 * 1024,
FALSE, &
type, &format, buffer_size, buffer);
86#elif defined GDK_WINDOWING_QUARTZ
88 GdkScreen *screen = gtk_widget_get_screen(widget);
89 if(
IS_NULL_PTR(screen)) screen = gdk_screen_get_default();
90 const int monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget));
92 CGDirectDisplayID ids[monitor + 1];
94 CMProfileRef prof = NULL;
95 if(CGGetOnlineDisplayList(monitor + 1, &ids[0], &total_ids) == kCGErrorSuccess && total_ids == monitor + 1)
96 CMGetProfileByAVID(ids[monitor], &prof);
100 data = CMProfileCopyICCData(NULL, prof);
101 CMCloseProfile(prof);
103 UInt8 *tmp_buffer = (UInt8 *)g_malloc(CFDataGetLength(
data));
104 CFDataGetBytes(
data, CFRangeMake(0, CFDataGetLength(
data)), tmp_buffer);
106 *buffer = (guint8 *)tmp_buffer;
107 *buffer_size = CFDataGetLength(
data);
111 *source = g_strdup(
"osx color profile api");
114#elif defined G_OS_WIN32
116 GdkWindow *
window = gtk_widget_get_window(widget);
117 HWND hwnd = (HWND)gdk_win32_window_get_handle(
window);
118 HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
121 MONITORINFOEX monitorInfo;
122 monitorInfo.cbSize =
sizeof(MONITORINFOEX);
123 if(!GetMonitorInfoW(hMonitor, (LPMONITORINFO)&monitorInfo))
return;
125 HDC hdc = CreateIC(
L"MONITOR", monitorInfo.szDevice, NULL, NULL);
129 GetICMProfile(hdc, &len, NULL);
130 wchar_t *wpath = g_new(
wchar_t, len);
132 if(GetICMProfileW(hdc, &len, wpath))
134 gchar *path = g_utf16_to_utf8(wpath, -1, NULL, NULL, NULL);
138 g_file_get_contents(path, (gchar **)buffer, &
size, NULL);
146 *source = g_strdup(
"windows color profile api");