Python: Xlib — How can I raise(bring to top) windows?

南笙酒味 提交于 2019-12-01 04:38:41

问题


I've tried using:

   win.configure(stack_mode=X.TopIf)
   win.set_input_focus(X.RevertToParent, X.CurrentTime)

However even without any focus loss prevention on my window manager this does not work, does anyone know of another way to do this? Xlib or not.


回答1:


There is a command-line tool called wmctrl which allows you to interact with EWMH/NetWM-compatible X window managers.

For example,

wmctrl -l

lists all the windows managed by the window manager, and

wmctrl -a Mozilla 

makes active the first window in the list which has the string "Mozilla" in its title. There are other ways to select windows; the above is just an example.

wmctrl enables you to move and resize windows too.




回答2:


Try this:

window=Display().screen().root.query_pointer().child
window.set_input_focus(X.RevertToParent, X.CurrentTime)
window.configure(stack_mode=X.Above)



回答3:


Perhaps this is the solution:
[Xlib] Force Raise/Map/Focus a given Window

A solution given (follow the thread) involves using wnck, which in Python is a part of the Gtk+ bindings.



来源:https://stackoverflow.com/questions/1616628/python-xlib-how-can-i-raisebring-to-top-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!