Revision: 21991
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21991
Author:   bdiego
Date:     2009-07-28 21:14:25 +0200 (Tue, 28 Jul 2009)

Log Message:
-----------
Fix crash on Linux with some WM.

This is fixed on trunk but was remove in some merge (give conflict).

Modified Paths:
--------------
    branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp

Modified: branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp 
2009-07-28 18:59:36 UTC (rev 21990)
+++ branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp 
2009-07-28 19:14:25 UTC (rev 21991)
@@ -534,11 +534,28 @@
                                                                      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 */
                        }


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to