启动并检查虚拟X显示器上窗口的名称

2024-09-28 21:18:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在写一个关于ubuntu18.04的测试。我想创建一个虚拟显示,在上面启动一个窗口,然后检查窗口名。在我运行的三个独立的shell中:

Xvfb :4 -screen 0 1920x1080x24+32 -fbdir /var/tmp 

那么

DISPLAY=:4 xterm

那么

DISPLAY=:4 xdotool getwindowfocus getwindowname

最后一个命令返回

XGetInputFocus returned the focused window of 1. This is likely a bug in the X server.
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x1
  Serial number of failed request:  20
  Current serial number in output stream:  20

这个错误似乎来自xdotool

int xdo_get_focused_window(const xdo_t *xdo, Window *window_ret) {
  int ret = 0;
  int unused_revert_ret;

  ret = XGetInputFocus(xdo->xdpy, window_ret, &unused_revert_ret);

  /* Xvfb with no window manager and given otherwise no input, with 
   * a single client, will return the current focused window as '1'
   * I think this is a bug, so let's alert the user. */
  if (*window_ret == 1) {
    fprintf(stderr, 
            "XGetInputFocus returned the focused window of %ld. "
            "This is likely a bug in the X server.\n", *window_ret);
  }
  return _is_success("XGetInputFocus", ret == 0, xdo);
}

我只想做最简单的事情来获得一个虚拟显示,在上面启动一个窗口,并检查窗口名。你知道吗

我该怎么办?你知道吗


Tags: oftheinisrequestdisplaywindowbug