summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogelnew1@free.fr <fvogel>2016-04-21 16:33:03 (GMT)
committerfvogelnew1@free.fr <fvogel>2016-04-21 16:33:03 (GMT)
commit209c06ac40dd5a2edea3cfc2481e0408614f29ae (patch)
tree03919778bfee3f9ea146c905f6add344c234b949
parent085a25a12e666f951889000a333e5a958dce3e9c (diff)
downloadtk-bug_c95d4691ff.zip
tk-bug_c95d4691ff.tar.gz
tk-bug_c95d4691ff.tar.bz2
Fixed [c95d4691ff] - winfo screenheight w/dual monitors returns the screen height of the primary displaybug_c95d4691ff
-rw-r--r--generic/tkCmds.c8
-rw-r--r--generic/tkInt.h2
-rw-r--r--macosx/tkMacOSXWm.c46
-rw-r--r--unix/tkUnixWm.c46
-rw-r--r--win/tkWinWm.c94
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