X11 virtual desktops: which are visible? - xlib

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?

Related

Windows Containers - Is it possible to interact with desktop apps running in a container using the Desktop Sharing API?

I understand that desktop/GUI apps are not supported in Windows containers. They do run but there's no built-in way to interact with them. I had the following idea - maybe I could use the Desktop Sharing API (https://learn.microsoft.com/en-us/windows/win32/api/_rdp/) for this purpose, the idea is to run a desktop app, then run a sharing program that uses the Desktop Sharing API, and connect to it using a Desktop Sharing API viewing program from the host.
I had to do some recap about window stations and desktops, and I noticed that when starting the container with cmd in interactive mode, I'm logged with ContainerAdministrator as a service (logon type 5). I tried running some WinAPI functions that deal with desktops and winstation and got some access denied results, so I switched to running cmd as system.
The window station of the cmd process (and other child processes) is not the interactive WinSta0, but instead some other service window station, which makes sense since I'm logged on as a service, and I figured that I can't use this window station, so I used a little program I wrote to run notepad in Winsta0 in the Default desktop. Afterwards I ran another program that enumerates the windows on WinSta0\Default, and the notepad window does get enumerated and I also get it's title, so it's running somewhere.
So now I tried running the desktop sharing API program (also on WinSta0\Default). It runs and I can connect from the host, but I only get a black screen without anything on it. I also tried running a program that takes a screenshot of the windows but I get an empty bitmap.
So I thought maybe the Default desktop is not the active desktop, and by using the OpenInputDesktop function I could confirm it - the current desktop was the Winlogon desktop, so I used the SwitchDesktop function to switch to the Default desktop (I used OpenInputDesktop again to verify that it actually worked).
Unfortunately, this didn't change anything, I still get an empty screen and empty bitmaps.
I know that containers are built for micro services and are not supposed to run GUI apps and so, but still - is there a way to make this work? Or any ideas of what else I can check? Alternatively, if you know that it can't work - I would also be happy to hear a good technical explanation of why it doesn't work.

Prevent disconnected display from merging windows into the active one

I've got a personal laptop (running Windows 10) which I use at work where I connect it to an external display using extended display mode. I keep all my personal icons and windows on my laptop display and store all the work-related windows on the external display. Whenever I unplug it, all the windows and icons from that display are merged into my laptop screen. I want to programmatically prevent changing anything on my primary screen when the secondary is disconnected. I'm currently writing a utility app for a variety of small productivity improving features and would like to add such feature in it. I can think of two ways to achieve this:
by tricking the system to think that the external display hasn't been
disconnected;
or take all the opened windows and icons on disconnected screen and put them on separate virtual desktop.
I was looking into Windows GDI Device Context Functions but haven't found anything about display connection/disconnection events. How can I detect display disconnection (and get that display's opened windows and icons)? Anything that can be done using C#, C++ or PowerShell scripts would be much appreciated!

Javafx Virtual Desktop Windows10/OSX

I have a Javafx desktop application with multiple stages and i want to move each window in particular positions. I also have to manage multiple virtual desktops available in Windows10 and OSX.
How can I put a stage in a particular virtual desktop in Win10 or OSX (and create a new one if it doesn't exist)?

How to detect if Windows 8 is showing desktop

In a Windows desktop application written in C# and running on Windows 8 how can I detect if Windows 8 is in desktop mode (i.e. showing the Desktop rather than the modern UI)?
Although it's in C++, the Start Screen Visibility Sample should be a good starting point for you. It uses COM objects to get the state of all monitors on the system that are either displaying Windows Store Apps or the Start Screen, and illustrates how to receive notifications when the state of a monitor changes or when the visibility of the Start screen changes.

What is the keyword for Mac OS X Service-like applications?

I need to build an application on Mac OS X that runs on the background, windowless and provides a status icon in the top-right corner of the menu bar. It should launch on a specific action initiated by the user (not at system start up) and interact solely through the status bar icon.
On Windows this is very close to Services, on Unix - to daemons. What should i search for in Mac documentation? I just need a few keywords.
Nothing so strictly defined. Mac OS X considers the parts of your question to be separate concepts:
The icon on the right side of the menu bar (i.e., in the status bar) is a status item. Any application can create any number of them, using the NSStatusItem class.
An application with no Dock tile is usually an agent. An application with no UI at all is a daemon. A status item counts as UI, so an application with only a status item is an agent. The typical way to make an agent (with or without a status item) is to set LSUIElement to the string "1" in its Info.plist.
Having never programmed DOS or Windows, I have no idea what “resident” means to you. On Mac OS X, it simply means “in RAM”, which any running application at least partially is.
Services on Windows are not at all connected to this concept. A status item-only utility is the simile for something running solely from the system tray (like one of those delightfully useless nuggets that you get for seemingly every trackpad, audio card or GPU that you have the bad luck to be outfitted with). Services are just background programs a) without UI and b) that support or provide system or application functions. Dozens flare in and out of existence as you use Windows, mostly at startup, and most of them provide completely abstract functionality, such as providing network APIs for other services to use.
That said, Peter's answer is likely what you meant to find out, but I think it should be spelled out that it's not necessarily connected to the equivalent of Windows Services. (If you're looking to build such a thing on OS X, look up daemons and launchd.)
"launchd"
See http://en.wikipedia.org/wiki/Launchd

Resources