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

时间:2019-04-22 02:54:55

标签: python xlib xorg xdotool

我正在Ubuntu 18.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);
}

我只想做最少的事情来获得虚拟显示,在其上启动一个窗口,并检查窗口名称。

我该怎么办?

0 个答案:

没有答案