Skip to content

Cannot raise window on top using configure() or raise_window() #280

@invader-zimm

Description

@invader-zimm

I'm trying to bring a specific window on top of all else and set focus to it. This is what I have so far:

def focus_window(window_id):
    d = display.Display()
    window = d.create_resource_object('window', window_id)
    window.map()
    window.configure(x=10, y=30, width=800, height=600, stack_mode=X.Above)
    window.set_input_focus(X.RevertToParent, X.CurrentTime)
    d.sync()

if __name__ == "__main__":
    focus_window(0x034000fc)

With the code above, everything works except the window being drawn on top. The focus is put into the window of interest, said window is moved and resized as expected but it doesn't raise on top. If I use window.raise_window() nothing happens. Using either methods, I don't get any error messages, it just doesn't work.

Am I missing something, or doing something wrong? I'm using MATE Desktop (on X, of course), Python 3.12.7 on Fedora.

Also, is there a way to get the window ID from the process PID using python-xlib? At the moment I'm using wmctrl but I'm wondering if there's a better way.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions