Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorDiego Borghetti <bdiego@gmail.com>2009-05-04 19:31:28 +0400
committerDiego Borghetti <bdiego@gmail.com>2009-05-04 19:31:28 +0400
commit0999cf406abc3989b8a5216d86c468e251c1bdb6 (patch)
tree5397f3d7223c6be4e64a228cdfe6f9d31218518a /intern
parent42d571bf19381e8322b5848db57f97a1c2d7d102 (diff)
Fix crash because XSetInputFocus fail.
Some WM send a WM_TAKE_FOCUS event before the window is really mapped (for example, change from virtual desktop), because of this, the call to XSetInputFocus fail and close Blender.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 02dfdc2e25c..bfa5f35d312 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -515,11 +515,28 @@ GHOST_SystemX11::processEvent(XEvent *xe)
window, data);
}
} else if (((Atom)xcme.data.l[0]) == m_wm_take_focus) {
+ XWindowAttributes attr;
+ Window fwin;
+ int revert_to;
+
/* as ICCCM say, we need reply this event
* with a SetInputFocus, the data[1] have
* the valid timestamp (send by the wm).
+ *
+ * Some WM send this event before the
+ * window is really mapped (for example
+ * change from virtual desktop), so we need
+ * to be sure that our windows is mapped
+ * or this call fail and close blender.
*/
- XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]);
+ if (XGetWindowAttributes(m_display, xcme.window, &attr) == True) {
+ if (XGetInputFocus(m_display, &fwin, &revert_to) == True) {
+ if (attr.map_state == IsViewable) {
+ if (fwin != xcme.window)
+ XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]);
+ }
+ }
+ }
} else {
/* Unknown client message, ignore */
}