@neauoire I don't think core Xlib has any information about previously focused windows maintained in the display server, you'd likely have to have a client watching for focus change events a priori which could then know what was formerly focused.