how to define window stacking order?

后端 未结 2 1149
遥遥无期
遥遥无期 2021-01-22 09:12

I\'m trying to write my own window manager. One issue I faced is that I don\'t understand how to define in which order windows should be displayed. The only means I found is to

相关标签:
2条回答
  • 2021-01-22 09:58

    It is the responsibility of the window manager to order the windows. A window gives hints about which type it is (popup dialog, menu window, splashscreen, toolbox, etc), the window manager then decides how to display this on the screen. This includes keeping track of the order and deciding which gets priority.

    There is a X11 call to change the order (XRestackWindows), but I don't know the Xcb equivalent.

    0 讨论(0)
  • 2021-01-22 10:04

    X11 only gives you the absolute minimum. There are no layers or always-over or always-under windows. You implement all the fancy stuff yourself, typically in the window manager, which is what you are writing.

    There is no raw protocol request to change the stacking order of windows at once. Xlib has a function XRestackWindows which does that, but it uses one configure request per window. The pseudocode is just

     for each window in the list except the first
          change the stacking order to be under the previous window
    

    That's it. Nothing more fancy than that.

    You do need to track the stacking order in your WM in order to implement layers, so that when a program tries to restack a top level window, you intercept the request and only restack it within its layer.

    Another possible way to implement layers is to have several transparent full-screen windows and reparent users' top-level windows to those, instead of to the root window. I'm not totally sure it will always work though, and you need to deal with transparency in one way or another, which requires transparency supporting hardware or the composite extension or possibly both.

    0 讨论(0)
提交回复
热议问题