diff options
author | Po Lu <luangruo@yahoo.com> | 2022-05-22 17:15:10 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-05-22 17:15:10 +0800 |
commit | ae8b1b8fd476b8c6240c1337c0c51763d4879ac9 (patch) | |
tree | f52f05cf00b960a840f3593da41243017f84ebdc | |
parent | 73df958411e2b1c55f3e91b1ed747de0b2bcd59d (diff) | |
download | emacs-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.
-rw-r--r-- | src/w32term.c | 23 |
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; |