xcompcap-main.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. #include <glad/glad.h>
  2. #include <glad/glad_glx.h>
  3. #include <X11/Xlib.h>
  4. #include <X11/extensions/Xcomposite.h>
  5. #include <pthread.h>
  6. #include <vector>
  7. #include <obs-module.h>
  8. #include <graphics/vec4.h>
  9. #include <util/platform.h>
  10. #include "xcompcap-main.hpp"
  11. #include "xcompcap-helper.hpp"
  12. #include "xcursor.h"
  13. #define xdisp (XCompcap::disp())
  14. #define WIN_STRING_DIV "\r\n"
  15. bool XCompcapMain::init()
  16. {
  17. if (!xdisp) {
  18. blog(LOG_ERROR, "failed opening display");
  19. return false;
  20. }
  21. int eventBase, errorBase;
  22. if (!XCompositeQueryExtension(xdisp, &eventBase, &errorBase)) {
  23. blog(LOG_ERROR, "Xcomposite extension not supported");
  24. return false;
  25. }
  26. int major = 0, minor = 2;
  27. XCompositeQueryVersion(xdisp, &major, &minor);
  28. if (major == 0 && minor < 2) {
  29. blog(LOG_ERROR, "Xcomposite extension is too old: %d.%d < 0.2",
  30. major, minor);
  31. return false;
  32. }
  33. return true;
  34. }
  35. void XCompcapMain::deinit()
  36. {
  37. XCompcap::cleanupDisplay();
  38. }
  39. obs_properties_t *XCompcapMain::properties()
  40. {
  41. obs_properties_t *props = obs_properties_create();
  42. obs_property_t *wins = obs_properties_add_list(
  43. props, "capture_window", obs_module_text("Window"),
  44. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
  45. for (Window win : XCompcap::getTopLevelWindows()) {
  46. std::string wname = XCompcap::getWindowName(win);
  47. std::string cls = XCompcap::getWindowClass(win);
  48. std::string winid = std::to_string((long long)win);
  49. std::string desc =
  50. (winid + WIN_STRING_DIV + wname + WIN_STRING_DIV + cls);
  51. obs_property_list_add_string(wins, wname.c_str(), desc.c_str());
  52. }
  53. obs_properties_add_int(props, "cut_top", obs_module_text("CropTop"), 0,
  54. 4096, 1);
  55. obs_properties_add_int(props, "cut_left", obs_module_text("CropLeft"),
  56. 0, 4096, 1);
  57. obs_properties_add_int(props, "cut_right", obs_module_text("CropRight"),
  58. 0, 4096, 1);
  59. obs_properties_add_int(props, "cut_bot", obs_module_text("CropBottom"),
  60. 0, 4096, 1);
  61. obs_properties_add_bool(props, "swap_redblue",
  62. obs_module_text("SwapRedBlue"));
  63. obs_properties_add_bool(props, "lock_x", obs_module_text("LockX"));
  64. obs_properties_add_bool(props, "show_cursor",
  65. obs_module_text("CaptureCursor"));
  66. obs_properties_add_bool(props, "include_border",
  67. obs_module_text("IncludeXBorder"));
  68. obs_properties_add_bool(props, "exclude_alpha",
  69. obs_module_text("ExcludeAlpha"));
  70. return props;
  71. }
  72. void XCompcapMain::defaults(obs_data_t *settings)
  73. {
  74. obs_data_set_default_string(settings, "capture_window", "");
  75. obs_data_set_default_int(settings, "cut_top", 0);
  76. obs_data_set_default_int(settings, "cut_left", 0);
  77. obs_data_set_default_int(settings, "cut_right", 0);
  78. obs_data_set_default_int(settings, "cut_bot", 0);
  79. obs_data_set_default_bool(settings, "swap_redblue", false);
  80. obs_data_set_default_bool(settings, "lock_x", false);
  81. obs_data_set_default_bool(settings, "show_cursor", true);
  82. obs_data_set_default_bool(settings, "include_border", false);
  83. obs_data_set_default_bool(settings, "exclude_alpha", false);
  84. }
  85. #define FIND_WINDOW_INTERVAL 2.0
  86. struct XCompcapMain_private {
  87. XCompcapMain_private()
  88. : win(0),
  89. cut_top(0),
  90. cur_cut_top(0),
  91. cut_left(0),
  92. cur_cut_left(0),
  93. cut_right(0),
  94. cur_cut_right(0),
  95. cut_bot(0),
  96. cur_cut_bot(0),
  97. inverted(false),
  98. width(0),
  99. height(0),
  100. pixmap(0),
  101. glxpixmap(0),
  102. tex(0),
  103. gltex(0)
  104. {
  105. pthread_mutexattr_init(&lockattr);
  106. pthread_mutexattr_settype(&lockattr, PTHREAD_MUTEX_RECURSIVE);
  107. pthread_mutex_init(&lock, &lockattr);
  108. }
  109. ~XCompcapMain_private()
  110. {
  111. pthread_mutex_destroy(&lock);
  112. pthread_mutexattr_destroy(&lockattr);
  113. }
  114. obs_source_t *source;
  115. std::string windowName;
  116. Window win = 0;
  117. int cut_top, cur_cut_top;
  118. int cut_left, cur_cut_left;
  119. int cut_right, cur_cut_right;
  120. int cut_bot, cur_cut_bot;
  121. bool inverted;
  122. bool swapRedBlue;
  123. bool lockX;
  124. bool include_border;
  125. bool exclude_alpha;
  126. bool draw_opaque;
  127. double window_check_time = 0.0;
  128. uint32_t width;
  129. uint32_t height;
  130. uint32_t border;
  131. Pixmap pixmap;
  132. GLXPixmap glxpixmap;
  133. gs_texture_t *tex;
  134. gs_texture_t *gltex;
  135. pthread_mutex_t lock;
  136. pthread_mutexattr_t lockattr;
  137. bool show_cursor = true;
  138. bool cursor_outside = false;
  139. xcursor_t *cursor = nullptr;
  140. };
  141. XCompcapMain::XCompcapMain(obs_data_t *settings, obs_source_t *source)
  142. {
  143. p = new XCompcapMain_private;
  144. p->source = source;
  145. obs_enter_graphics();
  146. p->cursor = xcursor_init(xdisp);
  147. obs_leave_graphics();
  148. updateSettings(settings);
  149. }
  150. static void xcc_cleanup(XCompcapMain_private *p);
  151. XCompcapMain::~XCompcapMain()
  152. {
  153. ObsGsContextHolder obsctx;
  154. if (p->tex) {
  155. gs_texture_destroy(p->tex);
  156. p->tex = 0;
  157. }
  158. xcc_cleanup(p);
  159. if (p->cursor) {
  160. xcursor_destroy(p->cursor);
  161. p->cursor = nullptr;
  162. }
  163. delete p;
  164. }
  165. static Window getWindowFromString(std::string wstr)
  166. {
  167. XErrorLock xlock;
  168. if (wstr == "") {
  169. return XCompcap::getTopLevelWindows().front();
  170. }
  171. if (wstr.substr(0, 4) == "root") {
  172. int i = std::stoi("0" + wstr.substr(4));
  173. return RootWindow(xdisp, i);
  174. }
  175. size_t firstMark = wstr.find(WIN_STRING_DIV);
  176. size_t markSize = strlen(WIN_STRING_DIV);
  177. if (firstMark == std::string::npos)
  178. return (Window)std::stol(wstr);
  179. Window wid = 0;
  180. wstr = wstr.substr(firstMark + markSize);
  181. size_t lastMark = wstr.rfind(WIN_STRING_DIV);
  182. std::string wname = wstr.substr(0, lastMark);
  183. std::string wcls = wstr.substr(lastMark + markSize);
  184. Window matchedNameWin = wid;
  185. for (Window cwin : XCompcap::getTopLevelWindows()) {
  186. std::string cwinname = XCompcap::getWindowName(cwin);
  187. std::string ccls = XCompcap::getWindowClass(cwin);
  188. if (cwin == wid && wname == cwinname && wcls == ccls)
  189. return wid;
  190. if (wname == cwinname ||
  191. (!matchedNameWin && !wcls.empty() && wcls == ccls))
  192. matchedNameWin = cwin;
  193. }
  194. return matchedNameWin;
  195. }
  196. static void xcc_cleanup(XCompcapMain_private *p)
  197. {
  198. PLock lock(&p->lock);
  199. XErrorLock xlock;
  200. if (p->gltex) {
  201. GLuint gltex = *(GLuint *)gs_texture_get_obj(p->gltex);
  202. glBindTexture(GL_TEXTURE_2D, gltex);
  203. if (p->glxpixmap) {
  204. glXReleaseTexImageEXT(xdisp, p->glxpixmap,
  205. GLX_FRONT_LEFT_EXT);
  206. if (xlock.gotError()) {
  207. blog(LOG_ERROR,
  208. "cleanup glXReleaseTexImageEXT failed: %s",
  209. xlock.getErrorText().c_str());
  210. xlock.resetError();
  211. }
  212. glXDestroyPixmap(xdisp, p->glxpixmap);
  213. if (xlock.gotError()) {
  214. blog(LOG_ERROR,
  215. "cleanup glXDestroyPixmap failed: %s",
  216. xlock.getErrorText().c_str());
  217. xlock.resetError();
  218. }
  219. p->glxpixmap = 0;
  220. }
  221. gs_texture_destroy(p->gltex);
  222. p->gltex = 0;
  223. }
  224. if (p->pixmap) {
  225. XFreePixmap(xdisp, p->pixmap);
  226. if (xlock.gotError()) {
  227. blog(LOG_ERROR, "cleanup glXDestroyPixmap failed: %s",
  228. xlock.getErrorText().c_str());
  229. xlock.resetError();
  230. }
  231. p->pixmap = 0;
  232. }
  233. if (p->win) {
  234. XCompositeUnredirectWindow(xdisp, p->win,
  235. CompositeRedirectAutomatic);
  236. XSelectInput(xdisp, p->win, 0);
  237. p->win = 0;
  238. }
  239. if (p->tex) {
  240. gs_texture_destroy(p->tex);
  241. p->tex = 0;
  242. }
  243. }
  244. static gs_color_format gs_format_from_tex()
  245. {
  246. GLint iformat = 0;
  247. // we can probably fix the intel swapped texture by querying via
  248. // GL_ARB_internalformat_query
  249. glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT,
  250. &iformat);
  251. switch (iformat) {
  252. case GL_RGB:
  253. return GS_RGBX;
  254. case GL_RGBA:
  255. return GS_RGBA;
  256. default:
  257. return GS_RGBA;
  258. }
  259. }
  260. // from libobs-opengl/gl-subsystem.h because we need to handle GLX modifying textures outside libobs.
  261. struct fb_info;
  262. struct gs_texture {
  263. gs_device_t *device;
  264. enum gs_texture_type type;
  265. enum gs_color_format format;
  266. GLenum gl_format;
  267. GLenum gl_target;
  268. GLenum gl_internal_format;
  269. GLenum gl_type;
  270. GLuint texture;
  271. uint32_t levels;
  272. bool is_dynamic;
  273. bool is_render_target;
  274. bool is_dummy;
  275. bool gen_mipmaps;
  276. gs_samplerstate_t *cur_sampler;
  277. struct fbo_info *fbo;
  278. };
  279. // End shitty hack.
  280. void XCompcapMain::updateSettings(obs_data_t *settings)
  281. {
  282. PLock lock(&p->lock);
  283. ObsGsContextHolder obsctx;
  284. blog(LOG_DEBUG, "Settings updating");
  285. Window prevWin = p->win;
  286. xcc_cleanup(p);
  287. if (settings) {
  288. const char *windowName =
  289. obs_data_get_string(settings, "capture_window");
  290. p->windowName = windowName;
  291. p->win = getWindowFromString(windowName);
  292. p->cut_top = obs_data_get_int(settings, "cut_top");
  293. p->cut_left = obs_data_get_int(settings, "cut_left");
  294. p->cut_right = obs_data_get_int(settings, "cut_right");
  295. p->cut_bot = obs_data_get_int(settings, "cut_bot");
  296. p->lockX = obs_data_get_bool(settings, "lock_x");
  297. p->swapRedBlue = obs_data_get_bool(settings, "swap_redblue");
  298. p->show_cursor = obs_data_get_bool(settings, "show_cursor");
  299. p->include_border =
  300. obs_data_get_bool(settings, "include_border");
  301. p->exclude_alpha = obs_data_get_bool(settings, "exclude_alpha");
  302. p->draw_opaque = false;
  303. } else {
  304. p->win = prevWin;
  305. }
  306. XErrorLock xlock;
  307. if (p->win)
  308. XCompositeRedirectWindow(xdisp, p->win,
  309. CompositeRedirectAutomatic);
  310. if (xlock.gotError()) {
  311. blog(LOG_ERROR, "XCompositeRedirectWindow failed: %s",
  312. xlock.getErrorText().c_str());
  313. return;
  314. }
  315. if (p->win)
  316. XSelectInput(xdisp, p->win,
  317. StructureNotifyMask | ExposureMask |
  318. VisibilityChangeMask);
  319. XSync(xdisp, 0);
  320. XWindowAttributes attr;
  321. if (!p->win || !XGetWindowAttributes(xdisp, p->win, &attr)) {
  322. p->win = 0;
  323. p->width = 0;
  324. p->height = 0;
  325. return;
  326. }
  327. if (p->win && p->cursor && p->show_cursor) {
  328. Window child;
  329. int x, y;
  330. XTranslateCoordinates(xdisp, p->win, attr.root, 0, 0, &x, &y,
  331. &child);
  332. xcursor_offset(p->cursor, x, y);
  333. }
  334. const int config_attrs[] = {GLX_BIND_TO_TEXTURE_RGBA_EXT,
  335. GL_TRUE,
  336. GLX_DRAWABLE_TYPE,
  337. GLX_PIXMAP_BIT,
  338. GLX_BIND_TO_TEXTURE_TARGETS_EXT,
  339. GLX_TEXTURE_2D_BIT_EXT,
  340. GLX_DOUBLEBUFFER,
  341. GL_FALSE,
  342. None};
  343. int nelem = 0;
  344. GLXFBConfig *configs = glXChooseFBConfig(
  345. xdisp, XCompcap::getRootWindowScreen(attr.root), config_attrs,
  346. &nelem);
  347. bool found = false;
  348. GLXFBConfig config;
  349. for (int i = 0; i < nelem; i++) {
  350. config = configs[i];
  351. XVisualInfo *visual = glXGetVisualFromFBConfig(xdisp, config);
  352. if (!visual)
  353. continue;
  354. if (attr.depth != visual->depth) {
  355. XFree(visual);
  356. continue;
  357. }
  358. XFree(visual);
  359. found = true;
  360. break;
  361. }
  362. if (!found) {
  363. blog(LOG_ERROR, "no matching fb config found");
  364. p->win = 0;
  365. p->height = 0;
  366. p->width = 0;
  367. XFree(configs);
  368. return;
  369. }
  370. if (p->exclude_alpha || attr.depth != 32) {
  371. p->draw_opaque = true;
  372. }
  373. int inverted;
  374. glXGetFBConfigAttrib(xdisp, config, GLX_Y_INVERTED_EXT, &inverted);
  375. p->inverted = inverted != 0;
  376. p->border = attr.border_width;
  377. if (p->include_border) {
  378. p->width = attr.width + p->border * 2;
  379. p->height = attr.height + p->border * 2;
  380. } else {
  381. p->width = attr.width;
  382. p->height = attr.height;
  383. }
  384. if (p->cut_top + p->cut_bot < (int)p->height) {
  385. p->cur_cut_top = p->cut_top;
  386. p->cur_cut_bot = p->cut_bot;
  387. } else {
  388. p->cur_cut_top = 0;
  389. p->cur_cut_bot = 0;
  390. }
  391. if (p->cut_left + p->cut_right < (int)p->width) {
  392. p->cur_cut_left = p->cut_left;
  393. p->cur_cut_right = p->cut_right;
  394. } else {
  395. p->cur_cut_left = 0;
  396. p->cur_cut_right = 0;
  397. }
  398. // Precautionary since we dont error check every GLX call above.
  399. xlock.resetError();
  400. p->pixmap = XCompositeNameWindowPixmap(xdisp, p->win);
  401. if (xlock.gotError()) {
  402. blog(LOG_ERROR, "XCompositeNameWindowPixmap failed: %s",
  403. xlock.getErrorText().c_str());
  404. p->pixmap = 0;
  405. XFree(configs);
  406. return;
  407. }
  408. // Should be consistent format with config we are using. Since we searched on RGBA lets use RGBA here.
  409. const int pixmap_attrs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
  410. GLX_TEXTURE_FORMAT_EXT,
  411. GLX_TEXTURE_FORMAT_RGBA_EXT, None};
  412. p->glxpixmap = glXCreatePixmap(xdisp, config, p->pixmap, pixmap_attrs);
  413. if (xlock.gotError()) {
  414. blog(LOG_ERROR, "glXCreatePixmap failed: %s",
  415. xlock.getErrorText().c_str());
  416. XFreePixmap(xdisp, p->pixmap);
  417. XFree(configs);
  418. p->pixmap = 0;
  419. p->glxpixmap = 0;
  420. return;
  421. }
  422. XFree(configs);
  423. // Build an OBS texture to bind the pixmap to.
  424. p->gltex = gs_texture_create(p->width, p->height, GS_RGBA, 1, 0,
  425. GS_GL_DUMMYTEX);
  426. GLuint gltex = *(GLuint *)gs_texture_get_obj(p->gltex);
  427. glBindTexture(GL_TEXTURE_2D, gltex);
  428. glXBindTexImageEXT(xdisp, p->glxpixmap, GLX_FRONT_LEFT_EXT, NULL);
  429. if (xlock.gotError()) {
  430. blog(LOG_ERROR, "glXBindTexImageEXT failed: %s",
  431. xlock.getErrorText().c_str());
  432. XFreePixmap(xdisp, p->pixmap);
  433. XFree(configs);
  434. p->pixmap = 0;
  435. p->glxpixmap = 0;
  436. return;
  437. }
  438. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  439. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  440. // glxBindTexImageEXT might modify the textures format.
  441. gs_color_format format = gs_format_from_tex();
  442. glBindTexture(GL_TEXTURE_2D, 0);
  443. // sync OBS texture format based on any glxBindTexImageEXT changes
  444. p->gltex->format = format;
  445. // Create a pure OBS texture to use for rendering. Using the same
  446. // format so we can copy instead of drawing from the source gltex.
  447. if (p->tex)
  448. gs_texture_destroy(p->tex);
  449. p->tex = gs_texture_create(width(), height(), format, 1, 0,
  450. GS_GL_DUMMYTEX);
  451. if (p->swapRedBlue) {
  452. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
  453. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
  454. }
  455. if (!p->windowName.empty()) {
  456. blog(LOG_INFO,
  457. "[window-capture: '%s'] update settings:\n"
  458. "\ttitle: %s\n"
  459. "\tclass: %s\n"
  460. "\tBit depth: %i\n"
  461. "\tFound proper GLXFBConfig (in %i): %s\n",
  462. obs_source_get_name(p->source),
  463. XCompcap::getWindowName(p->win).c_str(),
  464. XCompcap::getWindowClass(p->win).c_str(), attr.depth,
  465. nelem, found ? "yes" : "no");
  466. }
  467. }
  468. void XCompcapMain::tick(float seconds)
  469. {
  470. if (!obs_source_showing(p->source))
  471. return;
  472. PLock lock(&p->lock, true);
  473. if (!lock.isLocked())
  474. return;
  475. XCompcap::processEvents();
  476. if (p->win && XCompcap::windowWasReconfigured(p->win)) {
  477. p->window_check_time = FIND_WINDOW_INTERVAL;
  478. p->win = 0;
  479. }
  480. XDisplayLock xlock;
  481. XWindowAttributes attr;
  482. if (!p->win || !XGetWindowAttributes(xdisp, p->win, &attr)) {
  483. p->window_check_time += (double)seconds;
  484. if (p->window_check_time < FIND_WINDOW_INTERVAL)
  485. return;
  486. Window newWin = getWindowFromString(p->windowName);
  487. p->window_check_time = 0.0;
  488. if (newWin && XGetWindowAttributes(xdisp, newWin, &attr)) {
  489. p->win = newWin;
  490. updateSettings(0);
  491. } else {
  492. return;
  493. }
  494. }
  495. if (!p->tex || !p->gltex)
  496. return;
  497. obs_enter_graphics();
  498. if (p->lockX) {
  499. // XDisplayLock is still live so we should already be locked.
  500. XLockDisplay(xdisp);
  501. XSync(xdisp, 0);
  502. }
  503. if (p->include_border) {
  504. gs_copy_texture_region(p->tex, 0, 0, p->gltex, p->cur_cut_left,
  505. p->cur_cut_top, width(), height());
  506. } else {
  507. gs_copy_texture_region(p->tex, 0, 0, p->gltex,
  508. p->cur_cut_left + p->border,
  509. p->cur_cut_top + p->border, width(),
  510. height());
  511. }
  512. if (p->cursor && p->show_cursor) {
  513. xcursor_tick(p->cursor);
  514. p->cursor_outside =
  515. p->cursor->x < p->cur_cut_left ||
  516. p->cursor->y < p->cur_cut_top ||
  517. p->cursor->x > int(p->width - p->cur_cut_right) ||
  518. p->cursor->y > int(p->height - p->cur_cut_bot);
  519. }
  520. if (p->lockX)
  521. XUnlockDisplay(xdisp);
  522. obs_leave_graphics();
  523. }
  524. void XCompcapMain::render(gs_effect_t *effect)
  525. {
  526. if (!p->win)
  527. return;
  528. PLock lock(&p->lock, true);
  529. if (p->draw_opaque)
  530. effect = obs_get_base_effect(OBS_EFFECT_OPAQUE);
  531. else
  532. effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
  533. if (!lock.isLocked() || !p->tex)
  534. return;
  535. gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
  536. gs_effect_set_texture(image, p->tex);
  537. while (gs_effect_loop(effect, "Draw")) {
  538. gs_draw_sprite(p->tex, 0, 0, 0);
  539. }
  540. if (p->cursor && p->gltex && p->show_cursor && !p->cursor_outside) {
  541. effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
  542. while (gs_effect_loop(effect, "Draw")) {
  543. xcursor_render(p->cursor);
  544. }
  545. }
  546. }
  547. uint32_t XCompcapMain::width()
  548. {
  549. if (!p->win)
  550. return 0;
  551. return p->width - p->cur_cut_left - p->cur_cut_right;
  552. }
  553. uint32_t XCompcapMain::height()
  554. {
  555. if (!p->win)
  556. return 0;
  557. return p->height - p->cur_cut_bot - p->cur_cut_top;
  558. }