| 1 | /* |
| 2 | |
| 3 | Copyright 1993, 1998 The Open Group |
| 4 | Copyright (C) Colin Harrison 2005-2008 |
| 5 | |
| 6 | Permission to use, copy, modify, distribute, and sell this software and its |
| 7 | documentation for any purpose is hereby granted without fee, provided that |
| 8 | the above copyright notice appear in all copies and that both that |
| 9 | copyright notice and this permission notice appear in supporting |
| 10 | documentation. |
| 11 | |
| 12 | The above copyright notice and this permission notice shall be included |
| 13 | in all copies or substantial portions of the Software. |
| 14 | |
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 | IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 20 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 21 | OTHER DEALINGS IN THE SOFTWARE. |
| 22 | |
| 23 | Except as contained in this notice, the name of The Open Group shall |
| 24 | not be used in advertising or otherwise to promote the sale, use or |
| 25 | other dealings in this Software without prior written authorization |
| 26 | from The Open Group. |
| 27 | |
| 28 | */ |
| 29 | |
| 30 | #ifdef HAVE_XWIN_CONFIG_H |
| 31 | #include <xwin-config.h> |
| 32 | #endif |
| 33 | |
| 34 | #include "win.h" |
| 35 | #include "winmonitors.h" |
| 36 | |
| 37 | /* |
| 38 | * getMonitorInfo - callback function used to return information from the enumeration of monitors attached |
| 39 | */ |
| 40 | |
| 41 | static |
| 42 | wBOOL CALLBACK |
| 43 | getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data) |
| 44 | { |
| 45 | struct GetMonitorInfoData *data = (struct GetMonitorInfoData *) _data; |
| 46 | |
| 47 | // only get data for monitor number specified in <data> |
| 48 | data->monitorNum++; |
| 49 | if (data->monitorNum == data->requestedMonitor) { |
| 50 | data->bMonitorSpecifiedExists = TRUE; |
| 51 | data->monitorOffsetX = rect->left; |
| 52 | data->monitorOffsetY = rect->top; |
| 53 | data->monitorHeight = rect->bottom - rect->top; |
| 54 | data->monitorWidth = rect->right - rect->left; |
| 55 | data->monitorHandle = hMonitor; |
| 56 | return FALSE; |
| 57 | } |
| 58 | return TRUE; |
| 59 | } |
| 60 | |
| 61 | Bool |
| 62 | QueryMonitor(int i, struct GetMonitorInfoData *data) |
| 63 | { |
| 64 | /* prepare data */ |
| 65 | if (data == NULL) |
| 66 | return FALSE; |
| 67 | memset(data, 0, sizeof(*data)); |
| 68 | data->requestedMonitor = i; |
| 69 | |
| 70 | /* query information */ |
| 71 | EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data); |
| 72 | |
| 73 | return TRUE; |
| 74 | } |