linux-capture: Try to reacquire lost windows

When a window being captured is closed, it never tries to reacquire.
This just searches for the window in video_tick and reacquires if the
currently set window is found again.

Closes jp9000/obs-studio#465
This commit is contained in:
Gökberk Yaltıraklı 2015-08-16 16:37:50 +03:00 committed by jp9000
parent 23e60561cb
commit 8efbcc599a

View File

@ -132,6 +132,7 @@ struct XCompcapMain_private
obs_source_t *source;
std::string windowName;
Window win;
int cut_top, cur_cut_top;
int cut_left, cur_cut_left;
@ -272,6 +273,7 @@ void XCompcapMain::updateSettings(obs_data_t *settings)
const char *windowName = obs_data_get_string(settings,
"capture_window");
p->windowName = windowName;
p->win = getWindowFromString(windowName);
p->cut_top = obs_data_get_int(settings, "cut_top");
@ -456,6 +458,20 @@ void XCompcapMain::tick(float seconds)
if (XCompcap::windowWasReconfigured(p->win))
updateSettings(0);
XErrorLock xlock;
xlock.resetError();
XWindowAttributes attr;
if (!XGetWindowAttributes(xdisp, p->win, &attr)) {
Window newWin = getWindowFromString(p->windowName);
if (XGetWindowAttributes(xdisp, newWin, &attr)) {
p->win = newWin;
updateSettings(0);
}
return;
}
if (!p->tex || !p->gltex)
return;