yolobs-studio/plugins/linux-capture/xcompcap-helper.hpp

98 lines
1.7 KiB
C++
Raw Normal View History

2016-02-23 23:16:51 +00:00
#pragma once
#include <string>
#include <list>
#define blog(level, msg, ...) blog(level, "xcompcap: " msg, ##__VA_ARGS__)
2019-09-22 21:19:10 +00:00
class PLock {
2016-02-23 23:16:51 +00:00
pthread_mutex_t *m;
bool islock;
2019-09-22 21:19:10 +00:00
public:
PLock(const PLock &) = delete;
PLock &operator=(const PLock &) = delete;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
PLock(pthread_mutex_t *mtx, bool trylock = false);
2016-02-23 23:16:51 +00:00
~PLock();
bool isLocked();
void unlock();
void lock();
};
2019-09-22 21:19:10 +00:00
class XErrorLock {
2016-02-23 23:16:51 +00:00
bool islock;
bool goterr;
XErrorHandler prevhandler;
2019-09-22 21:19:10 +00:00
public:
XErrorLock(const XErrorLock &) = delete;
XErrorLock &operator=(const XErrorLock &) = delete;
2016-02-23 23:16:51 +00:00
XErrorLock();
~XErrorLock();
bool isLocked();
void unlock();
void lock();
bool gotError();
std::string getErrorText();
void resetError();
};
2019-09-22 21:19:10 +00:00
class XDisplayLock {
2016-08-28 12:07:43 +00:00
bool islock;
2019-09-22 21:19:10 +00:00
public:
XDisplayLock(const XDisplayLock &) = delete;
XDisplayLock &operator=(const XDisplayLock &) = delete;
2016-08-28 12:07:43 +00:00
XDisplayLock();
~XDisplayLock();
bool isLocked();
void unlock();
void lock();
};
2019-09-22 21:19:10 +00:00
class ObsGsContextHolder {
public:
ObsGsContextHolder(const ObsGsContextHolder &) = delete;
ObsGsContextHolder &operator=(const ObsGsContextHolder &) = delete;
2016-02-23 23:16:51 +00:00
ObsGsContextHolder();
~ObsGsContextHolder();
};
2019-09-22 21:19:10 +00:00
namespace XCompcap {
Display *disp();
void cleanupDisplay();
std::string getWindowCommand(Window win);
int getRootWindowScreen(Window root);
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)
2016-02-23 23:16:51 +00:00
{
2019-09-22 21:19:10 +00:00
return getWindowAtom(win, "WM_CLASS");
}
void processEvents();
bool windowWasReconfigured(Window win);
2016-02-23 23:16:51 +00:00
}