ecere/gui/drivers/XInterface: Setting global app focus
[sdk] / ecere / src / gui / drivers / XInterface.ec
index edffdd9..7dda68d 100644 (file)
@@ -1617,7 +1617,7 @@ class XInterface : Interface
                      // Force a raise on click here to deal with confused active state preventing to bring the window up
                      if(!atomsSupported[_net_active_window] && !window.isRemote)
                         XRaiseWindow(xGlobalDisplay, (X11Window)window.windowHandle);
-                     XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToPointerRoot, CurrentTime);
+                     XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToParent, CurrentTime);
                      button = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown;
                      buttonDouble = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick;
                      whichButton = 0;
@@ -1808,6 +1808,8 @@ class XInterface : Interface
                }
                case FocusIn:
                {
+                  guiApp.SetAppFocus(true);
+
                   if(activeWindow != (X11Window)window.windowHandle)
                   {
                      XFocusChangeEvent *event = (XFocusChangeEvent *) thisEvent;
@@ -1840,6 +1842,9 @@ class XInterface : Interface
                }
                case FocusOut:
                {
+                  if((X11Window)window.windowHandle == activeWindow)
+                     guiApp.SetAppFocus(false);
+
 #ifdef _DEBUG
                   //printf("Processing a FocusOut Event for %s (%x)\n", window._class.name, window);
 #endif
@@ -2153,7 +2158,8 @@ class XInterface : Interface
 #endif
 
                                  XSendEvent(xGlobalDisplay, DefaultRootWindow(xGlobalDisplay), bool::false, SubstructureRedirectMask | SubstructureNotifyMask, (union _XEvent *)&event);
-                                 XSetInputFocus(xGlobalDisplay, (X11Window)modalRoot.windowHandle, RevertToPointerRoot, timeStamp);
+                                 XSetInputFocus(xGlobalDisplay, (X11Window)modalRoot.windowHandle, RevertToParent, timeStamp);
+                                 guiApp.SetAppFocus(true);
                                  activeWindow = (X11Window)window.windowHandle;
 
                                  //XFlush(xGlobalDisplay);
@@ -2162,7 +2168,8 @@ class XInterface : Interface
                            }
                            else
                            {
-                              XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToPointerRoot, timeStamp);
+                              XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToParent, timeStamp);
+                              guiApp.SetAppFocus(true);
                               activeWindow = (X11Window)window.windowHandle;
                               window.ExternalActivate(true, true, window, null); // lastActive);
                               if(windowData && windowData.ic)
@@ -2924,11 +2931,11 @@ class XInterface : Interface
 
                XSendEvent(xGlobalDisplay, DefaultRootWindow(xGlobalDisplay), bool::false, SubstructureRedirectMask | SubstructureNotifyMask, (union _XEvent *)&event);
 //#if defined(__APPLE__)
-               XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToPointerRoot, CurrentTime);
+               XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToParent, CurrentTime);
 //#endif
             }
             else
-               XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToPointerRoot, CurrentTime);
+               XSetInputFocus(xGlobalDisplay, (X11Window)window.windowHandle, RevertToParent, CurrentTime);
          }
       }
    }
@@ -3040,7 +3047,7 @@ class XInterface : Interface
    {
       if(window.rootWindow.windowHandle)
          XDefineCursor(xGlobalDisplay, (X11Window) window.rootWindow.windowHandle,
-            cursor == -1 ? (X11Cursor)0 : systemCursors[(SystemCursor)cursor]);
+            cursor == -1 ? nullCursor : systemCursors[(SystemCursor)cursor]);
    }
 
    // --- Caret ---