瀏覽代碼

attempts at auto-focus

David Rose 19 年之前
父節點
當前提交
c1f598e117
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      panda/src/glxdisplay/glxGraphicsWindow.cxx

+ 12 - 0
panda/src/glxdisplay/glxGraphicsWindow.cxx

@@ -361,6 +361,9 @@ process_events() {
     case MapNotify:
       properties.set_minimized(false);
       system_changed_properties(properties);
+
+      // Auto-focus the window when it is mapped.
+      XSetInputFocus(_display, _xwindow, RevertToPointerRoot, CurrentTime);
       break;
 
     case ClientMessage:
@@ -514,6 +517,15 @@ set_properties_now(WindowProperties &properties) {
     properties.clear_cursor_hidden();
   }
 
+  if (properties.has_foreground()) {
+    if (properties.get_foreground()) {
+      XSetInputFocus(_display, _xwindow, RevertToPointerRoot, CurrentTime);
+    } else {
+      XSetInputFocus(_display, PointerRoot, RevertToPointerRoot, CurrentTime);
+    }
+    properties.clear_foreground();
+  }
+
   set_wm_properties(wm_properties, true);
 }