Why gnome window_id is different from xdotool window_id?

The following command giving output like:

% xdotool search --onlyvisible --desktop $i --name ".*" 2> /dev/null
6291459
73400382
56691633
56623114
56652097
56695632
60817412

But command using gnome extension giving:

% dbus-send --print-reply=literal --session --dest=org.gnome.Shell /org/gnome/Shell/Extensions/GnomeUtilsWindows org.gnome.Shell.Extensions.GnomeUtilsWindows.GetWindowsNormal | jq .
[
  {
    "wm_class": "Nemo",
    "wm_class_instance": "nemo",
    "pid": 7354,
    "id": 3622595801
  },
  {
    "wm_class": "Nemo",
    "wm_class_instance": "nemo",
    "pid": 7354,
    "id": 3622595803
  },
  {
    "wm_class": "VSCodium",
    "wm_class_instance": "vscodium",
    "pid": 2300,
    "id": 3622595795
  },
  {
    "wm_class": "Firefox-esr",
    "wm_class_instance": "Navigator",
    "pid": 3955,
    "id": 3622595796
  },
  {
    "wm_class": "Nemo",
    "wm_class_instance": "nemo",
    "pid": 7354,
    "id": 3622595799
  },
  {
    "wm_class": "Nemo",
    "wm_class_instance": "nemo",
    "pid": 7354,
    "id": 3622595800
  },
  {
    "wm_class": "Nemo",
    "wm_class_instance": "nemo",
    "pid": 7354,
    "id": 3622595802
  },
  {
    "wm_class": "Alacritty",
    "wm_class_instance": "Alacritty",
    "pid": 3251,
    "id": 3622595798
  }
]

The function I am using for the dbus command is:

GetWindowsNormal() {
    let win = global.get_window_actors().filter(w => w.meta_window.get_window_type() == 0);

    var winJsonArr = [];
    win.forEach(function (w) {
        winJsonArr.push({
            wm_class: w.meta_window.get_wm_class(),
            wm_class_instance: w.meta_window.get_wm_class_instance(),
            pid: w.meta_window.get_pid(),
            id: w.meta_window.get_id()
        });
    })
    return JSON.stringify(winJsonArr);
}

Here, meta_window.get_id() gives the window id.

My question is, why are they different. I am asking this for interoperability. I mean, I need to pass value found in xdotool to gnome extension and vice versa.

Mutter cannot use the XID as window ID, because it does not only support X11 windows. The MetaWindow id is a unique identifier inside mutter. It is meaningless for any other tools.

1 Like

Thank you very much.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.