Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

linux

xlib

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.

like image 859
peeeg Avatar asked Oct 24 '09 00:10

peeeg


2 Answers

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.

like image 195
unutbu Avatar answered Dec 06 '22 06:12

unutbu


Try this:

window=Display().screen().root.query_pointer().child
window.set_input_focus(X.RevertToParent, X.CurrentTime)
window.configure(stack_mode=X.Above)
like image 36
diyism Avatar answered Dec 06 '22 06:12

diyism