1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/*
SCREENGlobalRect.c
AUTHORS:
Allen.Ingling@nyu.edu awi
mario.kleiner@tuebingen.mpg.de mk
PLATFORMS:
All.
HISTORY:
10/16/04 awi Created.
11/14/08 mk Extended: Now 'GloblRect' really returns the proper absolute window location, even if the window
isn't a fullscreen window, but a real window system window.
*/
#include "Screen.h"
// If you change the useString then also change the corresponding synopsis string in ScreenSynopsis.c
static char useString[] = "rect=Screen('GlobalRect', windowPointerOrScreenNumber);";
// 1
static char synopsisString[] =
"Get global rect of window, texture or screen. This is the real position / rectangular area occupied "
"by a screen or onscreen window, with respect to the origin (0,0) of the desktop coordinate "
"system. A secondary display screen will have its top-left corner not at (0,0), but at a "
"proper offset, depending if mirror mode is on or off, and how your displays are arranged in "
"the display settings dialog. An onscreen window which is not displayed in fullscreen mode "
"will have its top-left and bottom-right corners properly set. ";
static char seeAlsoString[] = "";
PsychError SCREENGlobalRect(void)
{
int screenNumber;
PsychWindowRecordType *windowRecord;
PsychRectType rect;
//all sub functions should have these two lines
PsychPushHelp(useString, synopsisString,seeAlsoString);
if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};
//check for superfluous arguments
PsychErrorExit(PsychCapNumInputArgs(1));
PsychErrorExit(PsychRequireNumInputArgs(1));
PsychErrorExit(PsychCapNumOutputArgs(1));
if (PsychIsScreenNumberArg(1)) {
// Real screen id: Get screens global rect and return it:
PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
PsychGetGlobalScreenRect(screenNumber, rect);
PsychCopyOutRectArg(1, FALSE, rect);
}
else if (PsychIsWindowIndexArg(1)) {
// Window:
PsychAllocInWindowRecordArg(1, TRUE, &windowRecord);
// Onscreen?
if (PsychIsOnscreenWindow(windowRecord)) {
PsychOSProcessEvents(windowRecord, 0);
PsychCopyOutRectArg(1, FALSE, windowRecord->globalrect);
}
else {
PsychCopyOutRectArg(1, FALSE, windowRecord->rect);
}
}
else PsychErrorExitMsg(PsychError_user, "Argument was recognized as neither a window index nor a screen pointer");
return(PsychError_none);
}
|