diff options
-rw-r--r-- | generic/tkCmds.c | 8 | ||||
-rw-r--r-- | generic/tkInt.h | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 46 | ||||
-rw-r--r-- | unix/tkUnixWm.c | 46 | ||||
-rw-r--r-- | win/tkWinWm.c | 94 |
5 files changed, 192 insertions, 4 deletions
diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 6196b17..1b871eb 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -1477,12 +1477,12 @@ Tk_WinfoObjCmd( Tcl_NewIntObj(DefaultDepthOfScreen(Tk_Screen(tkwin)))); break; case WIN_SCREENHEIGHT: - Tcl_SetObjResult(interp, - Tcl_NewIntObj(HeightOfScreen(Tk_Screen(tkwin)))); + Tcl_SetObjResult(interp, + Tcl_NewIntObj(TkpHeightOfScreen(tkwin))); break; case WIN_SCREENWIDTH: - Tcl_SetObjResult(interp, - Tcl_NewIntObj(WidthOfScreen(Tk_Screen(tkwin)))); + Tcl_SetObjResult(interp, + Tcl_NewIntObj(TkpWidthOfScreen(tkwin))); break; case WIN_SCREENMMHEIGHT: Tcl_SetObjResult(interp, diff --git a/generic/tkInt.h b/generic/tkInt.h index b644c5b..b330601 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1217,6 +1217,8 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp, MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr); +MODULE_SCOPE int TkpHeightOfScreen(Tk_Window tkwin); +MODULE_SCOPE int TkpWidthOfScreen(Tk_Window tkwin); #ifdef _WIN32 #define TkParseColor XParseColor diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 39990e6..c9f4e9c 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6757,6 +6757,52 @@ RemapWindows( } /* + *---------------------------------------------------------------------- + * + * TkpHeightOfScreen + * + * Return the height (in pixels) of the screen. + * + * Results: + * The pixel height of the screen. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpHeightOfScreen( + Tk_Window tkwin) +{ + return HeightOfScreen(Tk_Screen(tkwin)); +} + +/* + *---------------------------------------------------------------------- + * + * TkpWidthOfScreen + * + * Return the width (in pixels) of the screen. + * + * Results: + * The pixel width of the screen. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpWidthOfScreen( + Tk_Window tkwin) +{ + return WidthOfScreen(Tk_Screen(tkwin)); +} + +/* * Local Variables: * mode: objc * c-basic-offset: 4 diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 19ac86c..6c0edc9 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -7413,6 +7413,52 @@ RemapWindows( } /* + *---------------------------------------------------------------------- + * + * TkpHeightOfScreen + * + * Return the height (in pixels) of the screen. + * + * Results: + * The pixel height of the screen. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpHeightOfScreen( + Tk_Window tkwin) +{ + return HeightOfScreen(Tk_Screen(tkwin)); +} + +/* + *---------------------------------------------------------------------- + * + * TkpWidthOfScreen + * + * Return the width (in pixels) of the screen. + * + * Results: + * The pixel width of the screen. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpWidthOfScreen( + Tk_Window tkwin) +{ + return WidthOfScreen(Tk_Screen(tkwin)); +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 4e7618d..4e8ff12 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -8680,6 +8680,100 @@ RemapWindows( } /* + *---------------------------------------------------------------------- + * + * GetMonitorRect + * + * Return the rectangle of the monitor on which the given window + * is displayed. + * + * Results: + * The display rectangle of the monitor, in virtual screen + * coordinates. + * + * Side effects: + * The passed window comes into existence if it was not already + * the case. + * + *---------------------------------------------------------------------- + */ + +RECT +GetMonitorRect( + Tk_Window tkwin) +{ + HWND hWnd; + HMONITOR hMonitor; + MONITORINFO mi; + + Tk_MakeWindowExist(tkwin); + + /* + * Get monitor information for the monitor showing the window. + */ + + hWnd = Tk_GetHWND(Tk_WindowId(tkwin)); + hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY); + + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor, &mi); + + return mi.rcMonitor; +} + +/* + *---------------------------------------------------------------------- + * + * TkpHeightOfScreen + * + * Return the height (in pixels) of the monitor on which the given + * window is displayed. + * + * Results: + * The pixel height of the monitor. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpHeightOfScreen( + Tk_Window tkwin) +{ + RECT rc = GetMonitorRect(tkwin); + + return (rc.bottom - rc.top); +} + +/* + *---------------------------------------------------------------------- + * + * TkpWidthOfScreen + * + * Return the width (in pixels) of the monitor on which the given + * window is displayed. + * + * Results: + * The pixel width of the monitor. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpWidthOfScreen( + Tk_Window tkwin) +{ + RECT rc = GetMonitorRect(tkwin); + + return (rc.right - rc.left); +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 |