octalmage / mDesktop

mDesktop is a lightweight application that allows the user to utilize multiple virtual desktops.
Other
242 stars 46 forks source link

Z-Order is not preserved when switching desktops #2

Open octalmage opened 10 years ago

octalmage commented 10 years ago

What steps will reproduce the problem?

  1. Observe window A on top of window B
  2. Switch to another desktop and switch back
  3. Observe window B on top of window A

I expect to see the same window that was on top be on top. Instead what I see is as if I did an Alt+Tab to switch between the top two windows in the Z-Order

Source: https://code.google.com/p/mdesktop/issues/detail?id=11

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2710093-z-order-is-not-preserved-when-switching-desktops?utm_campaign=plugin&utm_content=tracker%2F1897034&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1897034&utm_medium=issues&utm_source=github).
octalmage commented 10 years ago

I've tried to resolve this issue before without much luck. When I grab the list of visible windows it's suppose to grab them in order, but for some reason this doesn't always happen. So as a "hack" I store the top most window then move that to the front when I switch back to the desktop. I'll see if I can find a more reliable way to get the windows in order.

MPagel commented 10 years ago

Z order problems extend to the taskbar window order, as well as the desktop display order.

It seems to me that your application is treating it as a FIFO system, rather than LIFO (or vice versa?:P) for a given application. I do not stack/collapse the windows of one application into a single entity, but rather I have a taskbar item for each open window. Windows 8/7 (and I think vista) clump all windows from the same application as a contiguous group on the taskbar.

In the following A, B, C and D are applications, 1-x are windows. * is the topmost active window. For simplicity all other windows are minimized. If I have A1 A2* A3 A4 A5 B1 B2 C1 D1 D2

This will sort (upon paging away and back to the desktop) A2* A5 A4 A3 A1 B2 B1 C1 D2 D1

If the order was A1 A2 A3 B1 B2* C1 D1

This reorders as B2 B1 A3 A2 A1 C1 D1

So...It looks like active windows are assumed to be on the "top" of the Z order of the taskbar. I also witness the behavior of this bug report: Z order is being reversed for desktop windows (at least within an application)

I think the solution is to put the most recently active windows into the queue first, followed by the other windows DESC by datetime (if possible: for taskbar by time created, rather than accessed; for desktop by non-minimized, then by access time). Then you pop them off the top of the stack, so the oldest windows/applications get seeded onto the desktop first upon reload and your recent and active windows get placed on the new desktop last.