0

My Python program uses Xlib and Gtk3 and runs in an X-session with the window manager i3. I have 3 (real) monitors in this setup. i3 provides virtual desktops (and many other window managers behave similar here), at least 3 of them, as each monitor represents a desktop (on this standard setup). A monitor can have more desktops, but only one of them will be visible at a time.

I managed to move windows to any desktop:

gtk_window.get_window().move_to_desktop(2)

I can also distinguish on which monitor a desktop/window is:

x11display = Gdk.get_default_root_window().get_display()
x11monitor = x11display.get_monitor_at_window(gtk_window)
xid = GdkX11.X11Monitor.get_output(x11monitor)
# different xid → different monitor

But I found no way to see which desktop is visible whenever multiple desktops are associated with a monitor.

Any solution?

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94
  • AFAICT workspaces of I3 are not really desktops. A desktop as defined by freede3sktop.org is not per monitor, so I3 probably uses some other conventions. I would recommend running some experiments. For each monitor, run `xprop` for a window on the current desktop/workspace, then for its parent, then for its parent... Then switch to a different desktop/workspace and do it again. Examine the output for helpful hints. – n. m. could be an AI Dec 16 '22 at 08:57
  • @n.m. I used “desktop” here in the sense of what you call “workspace”. In the Extended Window Manager Hints specification those are called “desktops”. – Robert Siemer Dec 19 '22 at 16:54
  • What is called "desktop" in EWMH is not per monitor, it is active or inactive on the entire display, you can easily query the active one (there is only one) by looking at _NET_CURRENT_DESKTOP. I don't see "desktops" being mentioned in the i3 docs. There are "workspaces", and there may be several active at any given time (one per monitor), so these things are clearly not what EWMH calls "desktops". – n. m. could be an AI Dec 19 '22 at 17:36
  • @n.m. EWMH is written without multiple monitors in mind unfortunately. We must distinguish two major multi-monitor setups: either multiple monitors form a larger “virtual monitor” and a full screen window spans all of those, or—the more common one—full screen windows enlarge to the dimensions of a single physical monitor.—In any case: whatever they enlarge to, this is what I called desktop and this is what EWMH calls desktop as well. So a desktop can be—and often is for office setups—_per monitor_. – Robert Siemer Dec 19 '22 at 18:40
  • @n.m. While there might be multiple desktops visible (e.g. on multiple monitors), only one will indeed be active: the one which contains the biggest part of the focused window.—I improved my wording in my question (title) based on your input. – Robert Siemer Dec 19 '22 at 18:49
  • I am not sure what you are talking about. There is a property of the root window called _NET_CURRENT_DESKTOP of type CARDINAL/32 which stores the EMWH current desktop. There is only one such property because there is only one root window. This is the de-facto standard, for multihead setups too. If you have many active desktops, or workspaces, or devils with horns, or whatever you want to call them, you cannot store all of them in a single property of type CARDINAL/32. So you must determine what i3 does with these entities in a way that does not involve looking in the EMWH documentation. – n. m. could be an AI Dec 19 '22 at 18:53
  • As far as EMWH spec is concerned, there is only one visible desktop, which is the current one. I quote, "The window manager may virtualize this resource and offer multiple so-called 'virtual desktops', of which only one can be shown on the screen at a time". – n. m. could be an AI Dec 19 '22 at 18:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/250536/discussion-between-robert-siemer-and-n-m). – Robert Siemer Dec 19 '22 at 18:55

0 Answers0