How can I check in xlib if window exists?

Viewed 1632

I am writing c++ library in Linux using gcc. Program opens web pages in new browser windows with

system("firefox https://www.webpage.com");

After that I use xlib to determine identifiers of each opened browser window. Then program raises firefox windows one by one using

XRaiseWindow(display, window)

in order to make a screenshot of each window and OCR.

But if I close browser window manually and try to use XRaiseWindow with the corresponding identifier it generates BadWindow error and terminates the program.

So how can I check in xlib if window with given window identifier exists?

1 Answers
Related