New upstream version 0.15.4+dfsg1
This commit is contained in:
parent
55d5047af0
commit
67704ac59c
359 changed files with 8423 additions and 1050 deletions
|
|
@ -1,6 +1,6 @@
|
|||
X11SharedMemoryScreenInput="التقاط الشاشة (XSHM)"
|
||||
Screen="الشاشة"
|
||||
CaptureCursor="مؤشر الالتقاط"
|
||||
CaptureCursor="التقاط المؤشر"
|
||||
AdvancedSettings="إعدادات متقدمة"
|
||||
XServer="X Server"
|
||||
XCCapture="التقاط النافذة (Xcomposite)"
|
||||
|
|
@ -11,4 +11,5 @@ CropRight="الاقتطاع من اليمين (بكسل)"
|
|||
CropBottom="الاقتطاع من الأسفل (بكسل)"
|
||||
SwapRedBlue="مبادلة بين الأحمر و الأزرق"
|
||||
LockX="قفل السيرفر X عند الالتقاط"
|
||||
IncludeXBorder="تضمين حواف X"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Screen="Kuvaruutu"
|
|||
CaptureCursor="Kaappaa kursori"
|
||||
AdvancedSettings="Lisäasetukset"
|
||||
XServer="X Server"
|
||||
XCCapture="Ikkunakaappaus (Xcomposite)"
|
||||
XCCapture="Ikkuna (Xcomposite)"
|
||||
Window="Ikkuna"
|
||||
CropTop="Rajaa ylhäältä (pikselit)"
|
||||
CropLeft="Rajaa vasemmalta (pikselit)"
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ CropBottom="חיתוך תחתון (פיקסלים)"
|
|||
SwapRedBlue="החלף אדום וכחול"
|
||||
LockX="נעל שרת X בעת לכידה"
|
||||
IncludeXBorder="כלול קצה שרת X"
|
||||
ExcludeAlpha="השתמש בתבנית מרקם ללא אלפא (עקיפת בעיית Mesa)"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ CropBottom="Crop Inferiore (pixels)"
|
|||
SwapRedBlue="Inverti rosso e blu"
|
||||
LockX="Blocca l' X Server durante l'acquisizione"
|
||||
IncludeXBorder="Includi X bordi"
|
||||
ExcludeAlpha="Usa formato texture alfa-less (soluzione di Mesa)"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ CropLeft="Beskjær venstre (piksler)"
|
|||
CropRight="Beskjær høyre (piksler)"
|
||||
CropBottom="Beskjær bunnen (piksler)"
|
||||
SwapRedBlue="Bytt rød og blå"
|
||||
LockX="Lås X-server under opptak"
|
||||
LockX="Lås X-tjener under opptak"
|
||||
IncludeXBorder="Inkludér X11-rammen"
|
||||
ExcludeAlpha="Bruk teksturformat uten alfakanal (Mesa løsning)"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ CropBottom="Cortar em baixo (píxeis)"
|
|||
SwapRedBlue="Trocar vermelho e azul"
|
||||
LockX="Bloquear X Server durante a captura"
|
||||
IncludeXBorder="Incluir X Border"
|
||||
ExcludeAlpha="Uso da textura Formato de alfa-menos (solução de Mesa)"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ CropBottom="剪裁底部(px)"
|
|||
SwapRedBlue="交換紅藍顏色"
|
||||
LockX="截取時鎖定 X server"
|
||||
IncludeXBorder="包含X邊框"
|
||||
ExcludeAlpha="使用不帶有alpha值的材質格式 (Mesa暫時解決方案)"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include <obs-module.h>
|
||||
#include <util/platform.h>
|
||||
|
||||
#include "xcompcap-helper.hpp"
|
||||
|
||||
|
|
@ -171,9 +172,9 @@ namespace XCompcap
|
|||
return XScreenNumberOfScreen(attr.screen);
|
||||
}
|
||||
|
||||
std::string getWindowName(Window win)
|
||||
std::string getWindowAtom(Window win, const char *atom)
|
||||
{
|
||||
Atom netWmName = XInternAtom(disp(), "_NET_WM_NAME", false);
|
||||
Atom netWmName = XInternAtom(disp(), atom, false);
|
||||
int n;
|
||||
char **list = 0;
|
||||
XTextProperty tp;
|
||||
|
|
@ -199,6 +200,11 @@ namespace XCompcap
|
|||
}
|
||||
}
|
||||
|
||||
char *conv = nullptr;
|
||||
if (os_mbs_to_utf8_ptr(res.c_str(), 0, &conv))
|
||||
res = conv;
|
||||
bfree(conv);
|
||||
|
||||
XFree(tp.value);
|
||||
|
||||
return res;
|
||||
|
|
@ -409,6 +415,39 @@ void XErrorLock::resetError()
|
|||
curErrorText[0] = 0;
|
||||
}
|
||||
|
||||
XDisplayLock::XDisplayLock()
|
||||
{
|
||||
islock = false;
|
||||
lock();
|
||||
}
|
||||
|
||||
XDisplayLock::~XDisplayLock()
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
|
||||
bool XDisplayLock::isLocked()
|
||||
{
|
||||
return islock;
|
||||
}
|
||||
|
||||
void XDisplayLock::lock()
|
||||
{
|
||||
if (!islock) {
|
||||
XLockDisplay(XCompcap::disp());
|
||||
islock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void XDisplayLock::unlock()
|
||||
{
|
||||
if (islock) {
|
||||
XSync(XCompcap::disp(), 0);
|
||||
XUnlockDisplay(XCompcap::disp());
|
||||
islock = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ObsGsContextHolder::ObsGsContextHolder()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,6 +48,23 @@ class XErrorLock
|
|||
void resetError();
|
||||
};
|
||||
|
||||
class XDisplayLock
|
||||
{
|
||||
bool islock;
|
||||
|
||||
public:
|
||||
XDisplayLock(const XDisplayLock&) = delete;
|
||||
XDisplayLock& operator=(const XDisplayLock&) = delete;
|
||||
|
||||
XDisplayLock();
|
||||
~XDisplayLock();
|
||||
|
||||
bool isLocked();
|
||||
|
||||
void unlock();
|
||||
void lock();
|
||||
};
|
||||
|
||||
class ObsGsContextHolder
|
||||
{
|
||||
public:
|
||||
|
|
@ -65,12 +82,22 @@ namespace XCompcap
|
|||
|
||||
std::string getWindowCommand(Window win);
|
||||
int getRootWindowScreen(Window root);
|
||||
std::string getWindowName(Window win);
|
||||
std::string getWindowAtom(Window win, const char *atom);
|
||||
int getWindowPid(Window win);
|
||||
bool ewmhIsSupported();
|
||||
std::list<Window> getTopLevelWindows();
|
||||
std::list<Window> getAllWindows();
|
||||
|
||||
inline std::string getWindowName(Window win)
|
||||
{
|
||||
return getWindowAtom(win, "_NET_WM_NAME");
|
||||
}
|
||||
|
||||
inline std::string getWindowClass(Window win)
|
||||
{
|
||||
return getWindowAtom(win, "WM_CLASS");
|
||||
}
|
||||
|
||||
void processEvents();
|
||||
bool windowWasReconfigured(Window win);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ obs_properties_t *XCompcapMain::properties()
|
|||
|
||||
for (Window win: XCompcap::getTopLevelWindows()) {
|
||||
std::string wname = XCompcap::getWindowName(win);
|
||||
std::string progpath = XCompcap::getWindowCommand(win);
|
||||
std::string cls = XCompcap::getWindowClass(win);
|
||||
std::string winid = std::to_string((long long)win);
|
||||
std::string desc =
|
||||
(winid + WIN_STRING_DIV + wname +
|
||||
WIN_STRING_DIV + progpath);
|
||||
WIN_STRING_DIV + cls);
|
||||
|
||||
obs_property_list_add_string(wins, wname.c_str(),
|
||||
desc.c_str());
|
||||
|
|
@ -106,6 +106,7 @@ void XCompcapMain::defaults(obs_data_t *settings)
|
|||
obs_data_set_default_bool(settings, "exclude_alpha", false);
|
||||
}
|
||||
|
||||
#define FIND_WINDOW_INTERVAL 2.0
|
||||
|
||||
struct XCompcapMain_private
|
||||
{
|
||||
|
|
@ -137,7 +138,7 @@ struct XCompcapMain_private
|
|||
obs_source_t *source;
|
||||
|
||||
std::string windowName;
|
||||
Window win;
|
||||
Window win = 0;
|
||||
int cut_top, cur_cut_top;
|
||||
int cut_left, cur_cut_left;
|
||||
int cut_right, cur_cut_right;
|
||||
|
|
@ -148,6 +149,8 @@ struct XCompcapMain_private
|
|||
bool include_border;
|
||||
bool exclude_alpha;
|
||||
|
||||
double window_check_time = 0.0;
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t border;
|
||||
|
|
@ -201,6 +204,8 @@ XCompcapMain::~XCompcapMain()
|
|||
|
||||
static Window getWindowFromString(std::string wstr)
|
||||
{
|
||||
XErrorLock xlock;
|
||||
|
||||
if (wstr == "") {
|
||||
return XCompcap::getTopLevelWindows().front();
|
||||
}
|
||||
|
|
@ -211,26 +216,29 @@ static Window getWindowFromString(std::string wstr)
|
|||
}
|
||||
|
||||
size_t firstMark = wstr.find(WIN_STRING_DIV);
|
||||
size_t markSize = strlen(WIN_STRING_DIV);
|
||||
|
||||
if (firstMark == std::string::npos)
|
||||
return (Window)std::stol(wstr);
|
||||
|
||||
std::string widstr = wstr.substr(0, firstMark);
|
||||
Window wid = (Window)std::stol(widstr);
|
||||
Window wid = 0;
|
||||
|
||||
wstr = wstr.substr(firstMark + strlen(WIN_STRING_DIV));
|
||||
wstr = wstr.substr(firstMark + markSize);
|
||||
|
||||
size_t lastMark = wstr.rfind(WIN_STRING_DIV);
|
||||
std::string wname = wstr.substr(0, lastMark);
|
||||
std::string wcls = wstr.substr(lastMark + markSize);
|
||||
|
||||
Window matchedNameWin = wid;
|
||||
for (Window cwin: XCompcap::getTopLevelWindows()) {
|
||||
std::string cwinname = XCompcap::getWindowName(cwin);
|
||||
std::string ccls = XCompcap::getWindowClass(cwin);
|
||||
|
||||
if (cwin == wid && wname == cwinname)
|
||||
if (cwin == wid && wname == cwinname && wcls == ccls)
|
||||
return wid;
|
||||
|
||||
if (wname == cwinname)
|
||||
if (wname == cwinname ||
|
||||
(!matchedNameWin && !wcls.empty() && wcls == ccls))
|
||||
matchedNameWin = cwin;
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +248,7 @@ static Window getWindowFromString(std::string wstr)
|
|||
static void xcc_cleanup(XCompcapMain_private *p)
|
||||
{
|
||||
PLock lock(&p->lock);
|
||||
XErrorLock xlock;
|
||||
XDisplayLock xlock;
|
||||
|
||||
if (p->gltex) {
|
||||
gs_texture_destroy(p->gltex);
|
||||
|
|
@ -299,7 +307,9 @@ void XCompcapMain::updateSettings(obs_data_t *settings)
|
|||
|
||||
xlock.resetError();
|
||||
|
||||
XCompositeRedirectWindow(xdisp, p->win, CompositeRedirectAutomatic);
|
||||
if (p->win)
|
||||
XCompositeRedirectWindow(xdisp, p->win,
|
||||
CompositeRedirectAutomatic);
|
||||
|
||||
if (xlock.gotError()) {
|
||||
blog(LOG_ERROR, "XCompositeRedirectWindow failed: %s",
|
||||
|
|
@ -307,18 +317,19 @@ void XCompcapMain::updateSettings(obs_data_t *settings)
|
|||
return;
|
||||
}
|
||||
|
||||
XSelectInput(xdisp, p->win, StructureNotifyMask | ExposureMask);
|
||||
if (p->win)
|
||||
XSelectInput(xdisp, p->win, StructureNotifyMask | ExposureMask);
|
||||
XSync(xdisp, 0);
|
||||
|
||||
XWindowAttributes attr;
|
||||
if (!XGetWindowAttributes(xdisp, p->win, &attr)) {
|
||||
if (!p->win || !XGetWindowAttributes(xdisp, p->win, &attr)) {
|
||||
p->win = 0;
|
||||
p->width = 0;
|
||||
p->height = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (p->cursor && p->show_cursor) {
|
||||
if (p->win && p->cursor && p->show_cursor) {
|
||||
Window child;
|
||||
int x, y;
|
||||
|
||||
|
|
@ -451,8 +462,6 @@ void XCompcapMain::updateSettings(obs_data_t *settings)
|
|||
|
||||
void XCompcapMain::tick(float seconds)
|
||||
{
|
||||
UNUSED_PARAMETER(seconds);
|
||||
|
||||
if (!obs_source_showing(p->source))
|
||||
return;
|
||||
|
||||
|
|
@ -463,21 +472,30 @@ void XCompcapMain::tick(float seconds)
|
|||
|
||||
XCompcap::processEvents();
|
||||
|
||||
if (XCompcap::windowWasReconfigured(p->win))
|
||||
updateSettings(0);
|
||||
if (p->win && XCompcap::windowWasReconfigured(p->win)) {
|
||||
p->window_check_time = FIND_WINDOW_INTERVAL;
|
||||
p->win = 0;
|
||||
}
|
||||
|
||||
XErrorLock xlock;
|
||||
xlock.resetError();
|
||||
XDisplayLock xlock;
|
||||
XWindowAttributes attr;
|
||||
|
||||
if (!XGetWindowAttributes(xdisp, p->win, &attr)) {
|
||||
if (!p->win || !XGetWindowAttributes(xdisp, p->win, &attr)) {
|
||||
p->window_check_time += (double)seconds;
|
||||
|
||||
if (p->window_check_time < FIND_WINDOW_INTERVAL)
|
||||
return;
|
||||
|
||||
Window newWin = getWindowFromString(p->windowName);
|
||||
|
||||
if (XGetWindowAttributes(xdisp, newWin, &attr)) {
|
||||
p->window_check_time = 0.0;
|
||||
|
||||
if (newWin && XGetWindowAttributes(xdisp, newWin, &attr)) {
|
||||
p->win = newWin;
|
||||
updateSettings(0);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!p->tex || !p->gltex)
|
||||
|
|
@ -524,11 +542,11 @@ void XCompcapMain::tick(float seconds)
|
|||
|
||||
void XCompcapMain::render(gs_effect_t *effect)
|
||||
{
|
||||
PLock lock(&p->lock, true);
|
||||
|
||||
if (!p->win)
|
||||
return;
|
||||
|
||||
PLock lock(&p->lock, true);
|
||||
|
||||
effect = obs_get_base_effect(OBS_EFFECT_OPAQUE);
|
||||
|
||||
if (!lock.isLocked() || !p->tex)
|
||||
|
|
@ -552,10 +570,16 @@ void XCompcapMain::render(gs_effect_t *effect)
|
|||
|
||||
uint32_t XCompcapMain::width()
|
||||
{
|
||||
if (!p->win)
|
||||
return 0;
|
||||
|
||||
return p->width - p->cur_cut_left - p->cur_cut_right;
|
||||
}
|
||||
|
||||
uint32_t XCompcapMain::height()
|
||||
{
|
||||
if (!p->win)
|
||||
return 0;
|
||||
|
||||
return p->height - p->cur_cut_bot - p->cur_cut_top;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ extern "C" void xcomposite_load(void)
|
|||
|
||||
sinfo.id = "xcomposite_input";
|
||||
sinfo.output_flags = OBS_SOURCE_VIDEO |
|
||||
OBS_SOURCE_CUSTOM_DRAW;
|
||||
OBS_SOURCE_CUSTOM_DRAW |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE;
|
||||
|
||||
sinfo.get_name = xcompcap_getname;
|
||||
sinfo.create = xcompcap_create;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue