emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b7b14e9203: Implement monitor change hooks on NS


From: Po Lu
Subject: master b7b14e9203: Implement monitor change hooks on NS
Date: Fri, 20 May 2022 23:50:35 -0400 (EDT)

branch: master
commit b7b14e920336646428c357b370cbfaac544ce295
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Implement monitor change hooks on NS
    
    This hasn't been tested with anything more complicated than
    removing an emulated monitor.
    
    * nsterm.m (ns_displays_reconfigured): New function.
    (ns_term_init): Register display reconfiguration callbacks.
---
 src/nsterm.m | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/nsterm.m b/src/nsterm.m
index 7fbfcf8c6d..67b02c7a54 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5213,6 +5213,31 @@ static struct redisplay_interface ns_redisplay_interface 
=
   ns_default_font_parameter
 };
 
+#ifdef NS_IMPL_COCOA
+static void
+ns_displays_reconfigured (CGDirectDisplayID display,
+                         CGDisplayChangeSummaryFlags flags,
+                         void *user_info)
+{
+  struct input_event ie;
+  union buffered_input_event *ev;
+
+  EVENT_INIT (ie);
+
+  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)
+    return;
+
+  ie.kind = MONITORS_CHANGED_EVENT;
+  XSETTERMINAL (ie.arg, x_display_list->terminal);
+
+  kbd_buffer_store_event (&ie);
+}
+#endif
 
 static void
 ns_delete_display (struct ns_display_info *dpyinfo)
@@ -5568,6 +5593,15 @@ ns_term_init (Lisp_Object display_name)
   catch_child_signal ();
 #endif
 
+#ifdef NS_IMPL_COCOA
+  /* Begin listening for display reconfiguration, so we can run the
+     appropriate hooks.  FIXME: is this called when the resolution of
+     a monitor changes?  */
+
+  CGDisplayRegisterReconfigurationCallback (ns_displays_reconfigured,
+                                           NULL);
+#endif
+
   NSTRACE_MSG ("ns_term_init done");
 
   unblock_input ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]