summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-05-27 09:33:15 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-05-27 09:33:15 (GMT)
commit1044345b47c8f1e672e2d3c1a45c5ea2cbb5a716 (patch)
treef4dd93d227991cc9714def29f65fc765a6914f7e
parent0529352ef03d575aa2df3317cd1e3145209c5292 (diff)
downloadtk-1044345b47c8f1e672e2d3c1a45c5ea2cbb5a716.zip
tk-1044345b47c8f1e672e2d3c1a45c5ea2cbb5a716.tar.gz
tk-1044345b47c8f1e672e2d3c1a45c5ea2cbb5a716.tar.bz2
Make windows aware of screen assignation changes when they are moved from one monitor to another one
-rw-r--r--win/tkWinWm.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 4200251..9811d82 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -546,6 +546,12 @@ static int WmWithdrawCmd(Tk_Window tkwin,
static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr);
/*
+ * Declarations of static variables used in this file.
+ */
+
+static int screenId = -1; /* Used to enumerate monitors */
+
+/*
* Used in BytesPerLine
*/
@@ -7830,6 +7836,44 @@ TopLevelProc(
/*
*----------------------------------------------------------------------
*
+ * MonitorEnumProcScreenChanged
+ *
+ * Monitors enumeration callback. This updates the screen number for
+ * the given window. This callback is called once for each monitor.
+ *
+ * Results:
+ * Screen number of the given window is updated.
+ *
+ * Side effects:
+ * The window becomes "linked" to the new screen.
+ * All [winfo screenxxx ...] will return information based on the new
+ * screen.
+ *
+ *----------------------------------------------------------------------
+ */
+
+BOOL CALLBACK
+MonitorEnumProcScreenChanged(
+ HMONITOR hMonitor,
+ HDC hdcMonitor,
+ LPRECT lprcMonitor,
+ LPARAM dwData)
+{
+ HMONITOR hMonitorWin;
+
+ screenId++;
+ hMonitorWin = MonitorFromWindow(Tk_GetHWND(((TkWindow *) dwData)->window),
+ MONITOR_DEFAULTTOPRIMARY);
+ if (hMonitor == hMonitorWin) {
+ ((TkWindow *) dwData)->screenNum = screenId;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* WmProc --
*
* Callback from Windows whenever an event occurs on the decorative
@@ -7981,6 +8025,18 @@ WmProc(
break;
case WM_WINDOWPOSCHANGED:
+ /*
+ * If the window got moved we potentially need to link the window to a
+ * different screen so that [winfo screen...] will output the correct
+ * results. This is also needed for other reasons such as having
+ * -fullscreen show the window on the monitor on which that window was
+ * displayed when -fullscreen got applied.
+ */
+
+ winPtr = GetTopLevel(((WINDOWPOS *) lParam)->hwnd);
+ screenId = -1;
+ EnumDisplayMonitors(NULL, NULL, MonitorEnumProcScreenChanged, (LPARAM) winPtr);
+
ConfigureTopLevel((WINDOWPOS *) lParam);
result = 0;
goto done;