[Bf-blender-cvs] [65381e220e5] blender-v2.83-release: Fix T76507: Reading clipboard blocks keyboard input on X11

Campbell Barton noreply at git.blender.org
Tue May 12 14:09:41 CEST 2020


Commit: 65381e220e5e04d60e2959d5ccf4c1ea02144c8c
Author: Campbell Barton
Date:   Tue May 12 22:09:11 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rB65381e220e5e04d60e2959d5ccf4c1ea02144c8c

Fix T76507: Reading clipboard blocks keyboard input on X11

===================================================================

M	intern/ghost/intern/GHOST_SystemX11.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 6c35e209167..9c7368355b4 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2172,14 +2172,24 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
   else if (owner == None)
     return (NULL);
 
+  /* Restore events so copy doesn't swallow other event types (keyboard/mouse). */
+  vector<XEvent> restore_events;
+
   while (1) {
     /* only get an event if xcout() is doing something */
-    if (context != XCLIB_XCOUT_NONE)
+    bool restore_this_event = false;
+    if (context != XCLIB_XCOUT_NONE) {
       XNextEvent(m_display, &evt);
+      restore_this_event = (evt.type != SelectionNotify);
+    }
 
     /* fetch the selection, or part of it */
     getClipboard_xcout(&evt, sseln, target, &sel_buf, &sel_len, &context);
 
+    if (restore_this_event) {
+      restore_events.push_back(evt);
+    }
+
     /* fallback is needed. set XA_STRING to target and restart the loop. */
     if (context == XCLIB_XCOUT_FALLBACK) {
       context = XCLIB_XCOUT_NONE;
@@ -2208,6 +2218,11 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
       break;
   }
 
+  while (!restore_events.empty()) {
+    XPutBackEvent(m_display, &restore_events.back());
+    restore_events.pop_back();
+  }
+
   if (sel_len) {
     /* only print the buffer out, and free it, if it's not
      * empty



More information about the Bf-blender-cvs mailing list