obs-studio/plugins/linux-capture/xcursor-xcb.h
Kurt Kartaltepe 1604400e48 linux-capture: Rewrite xcomposite
Generally moves all the plugin code into xcomposite-input.cpp and
removes all C++ dependencies.

Migrate as much as possible to xcb from Xlib to enable us to handle
errors and attribute them to the correct callers. This caused many other
knock on issues such as wrongly attributed errors and cleanup code
working incorrectly.

That allows us to use the xcursor-xcb implementation and delete the pure
Xlib implementation. We also add the missing functionality from the Xlib
implementation to the xcb implementation.

Capture glXCreatePixmap errors which occur most commonly on
nvidia+gnome due to nvidia's driver being unable to allocate more than 1
pixmap per window and gnome being the only compositor to read window
data via glx pixmaps.

Fix cleanup after failed glXCreatePixmap that might have leaked pixmaps
and prevented later captures on nvidia drivers for the same reason.
2022-05-14 17:01:08 -03:00

85 lines
1.9 KiB
C

/*
Copyright (C) 2014 by Leonhard Oelke <leonhard@in-verted.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <obs.h>
#include <xcb/xfixes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
unsigned int last_serial;
unsigned int last_width;
unsigned int last_height;
gs_texture_t *tex;
int x;
int y;
int x_org;
int y_org;
float x_render;
float y_render;
} xcb_xcursor_t;
/**
* Initializes the xcursor object
*
* @return NULL on error
*/
xcb_xcursor_t *xcb_xcursor_init(xcb_connection_t *xcb);
/**
* Destroys the xcursor object
* @param data xcursor object
*/
void xcb_xcursor_destroy(xcb_xcursor_t *data);
/**
* Update the cursor data
* @param xcb xcb connection
* @param data xcursor object
*
* @note This needs to be executed within a valid render context
*
*/
void xcb_xcursor_update(xcb_connection_t *xcb, xcb_xcursor_t *data);
/**
* Draw the cursor
*
* This needs to be executed within a valid render context
*/
void xcb_xcursor_render(xcb_xcursor_t *data);
/**
* Specify a manual offset for the cursor.
*/
void xcb_xcursor_offset(xcb_xcursor_t *data, const int x_org, const int y_org);
/**
* Update the offset to match the window's origin.
*/
void xcb_xcursor_offset_win(xcb_connection_t *xcb, xcb_xcursor_t *data,
xcb_window_t win);
#ifdef __cplusplus
}
#endif