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