2 * MACDRV display settings
4 * Copyright 2003 Alexander James Pasadyn
5 * Copyright 2011, 2012 Ken Thomases for CodeWeavers Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 WINE_DEFAULT_DEBUG_CHANNEL(display
);
30 static inline HMONITOR
display_id_to_monitor(CGDirectDisplayID display_id
)
32 return (HMONITOR
)(UINT_PTR
)display_id
;
35 static inline CGDirectDisplayID
monitor_to_display_id(HMONITOR handle
)
37 return (CGDirectDisplayID
)(UINT_PTR
)handle
;
41 /***********************************************************************
42 * EnumDisplayMonitors (MACDRV.@)
44 BOOL CDECL
macdrv_EnumDisplayMonitors(HDC hdc
, LPRECT rect
, MONITORENUMPROC proc
, LPARAM lparam
)
46 struct macdrv_display
*displays
;
51 TRACE("%p, %s, %p, %#lx\n", hdc
, wine_dbgstr_rect(rect
), proc
, lparam
);
58 if (!GetDCOrgEx(hdc
, &origin
)) return FALSE
;
59 if (GetClipBox(hdc
, &limit
) == ERROR
) return FALSE
;
61 if (rect
&& !IntersectRect(&limit
, &limit
, rect
)) return TRUE
;
63 if (macdrv_get_displays(&displays
, &num_displays
))
66 for (i
= 0; i
< num_displays
; i
++)
68 RECT monrect
= rect_from_cgrect(displays
[i
].frame
);
69 OffsetRect(&monrect
, -origin
.x
, -origin
.y
);
70 if (IntersectRect(&monrect
, &monrect
, &limit
))
72 HMONITOR monitor
= display_id_to_monitor(displays
[i
].displayID
);
73 TRACE("monitor %d handle %p @ %s\n", i
, monitor
, wine_dbgstr_rect(&monrect
));
74 if (!proc(monitor
, hdc
, &monrect
, lparam
))
84 if (macdrv_get_displays(&displays
, &num_displays
))
87 for (i
= 0; i
< num_displays
; i
++)
89 RECT monrect
= rect_from_cgrect(displays
[i
].frame
);
91 if (!rect
|| IntersectRect(&unused
, &monrect
, rect
))
93 HMONITOR monitor
= display_id_to_monitor(displays
[i
].displayID
);
94 TRACE("monitor %d handle %p @ %s\n", i
, monitor
, wine_dbgstr_rect(&monrect
));
95 if (!proc(monitor
, 0, &monrect
, lparam
))
104 macdrv_free_displays(displays
);
110 /***********************************************************************
111 * GetMonitorInfo (MACDRV.@)
113 BOOL CDECL
macdrv_GetMonitorInfo(HMONITOR monitor
, LPMONITORINFO info
)
115 static const WCHAR adapter_name
[] = { '\\','\\','.','\\','D','I','S','P','L','A','Y','1',0 };
116 struct macdrv_display
*displays
;
118 CGDirectDisplayID display_id
;
121 TRACE("%p, %p\n", monitor
, info
);
123 if (macdrv_get_displays(&displays
, &num_displays
))
125 ERR("couldn't get display list\n");
126 SetLastError(ERROR_GEN_FAILURE
);
130 display_id
= monitor_to_display_id(monitor
);
131 for (i
= 0; i
< num_displays
; i
++)
133 if (displays
[i
].displayID
== display_id
)
137 if (i
< num_displays
)
139 info
->rcMonitor
= rect_from_cgrect(displays
[i
].frame
);
140 info
->rcWork
= rect_from_cgrect(displays
[i
].work_frame
);
142 info
->dwFlags
= (i
== 0) ? MONITORINFOF_PRIMARY
: 0;
144 if (info
->cbSize
>= sizeof(MONITORINFOEXW
))
145 lstrcpyW(((MONITORINFOEXW
*)info
)->szDevice
, adapter_name
);
147 TRACE(" -> rcMonitor %s rcWork %s dwFlags %08x\n", wine_dbgstr_rect(&info
->rcMonitor
),
148 wine_dbgstr_rect(&info
->rcWork
), info
->dwFlags
);
152 ERR("invalid monitor handle\n");
153 SetLastError(ERROR_INVALID_HANDLE
);
156 macdrv_free_displays(displays
);
157 return (i
< num_displays
);