summaryrefslogtreecommitdiff
path: root/src/w32term.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-05-22 17:15:10 +0800
committerPo Lu <luangruo@yahoo.com>2022-05-22 17:15:10 +0800
commitae8b1b8fd476b8c6240c1337c0c51763d4879ac9 (patch)
treef52f05cf00b960a840f3593da41243017f84ebdc /src/w32term.c
parent73df958411e2b1c55f3e91b1ed747de0b2bcd59d (diff)
downloademacs-ae8b1b8fd476b8c6240c1337c0c51763d4879ac9.tar.gz
Implement `display-monitors-changed-functions' on MS Windows
* src/w32term.c (w32_read_socket): Handle WM_DISPLAYCHANGE by sending monitor change events.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/w32term.c b/src/w32term.c
index da7ac379723..373c5b5f786 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -5912,6 +5912,29 @@ w32_read_socket (struct terminal *terminal,
(short) HIWORD (msg.msg.lParam)));
}
+ /* According to the MS documentation, this message is sent
+ to each window whenever a monitor is added, removed, or
+ has its resolution change. Detect duplicate events when
+ there are multiple frames by ensuring only one event is
+ put in the keyboard buffer at any given time. */
+ {
+ union buffered_input_event *ev;
+
+ ev = (kbd_store_ptr == kbd_buffer
+ ? kbd_buffer + KBD_BUFFER_SIZE - 1
+ : kbd_store_ptr - 1);
+
+ if (kbd_store_ptr != kbd_fetch_ptr
+ && ev->ie.kind == MONITORS_CHANGED_EVENT
+ && XTERMINAL (ev->ie.arg) == dpyinfo->terminal)
+ /* Don't store a MONITORS_CHANGED_EVENT if there is
+ already an undelivered event on the queue. */
+ break;
+
+ inev.kind = MONITORS_CHANGED_EVENT;
+ XSETTERMINAL (inev.arg, dpyinfo->terminal);
+ }
+
check_visibility = 1;
break;