linux-capture: Add helper to get xcb screen

Add a helper function to get a xcb screen from a screen id.
master
fryshorts 2014-12-21 19:51:14 +01:00
parent e7cdb837aa
commit 069ee92ff4
2 changed files with 22 additions and 0 deletions

View File

@ -188,3 +188,15 @@ void xshm_xcb_detach(xcb_shm_t *shm)
bfree(shm);
}
xcb_screen_t *xcb_get_screen(xcb_connection_t *xcb, int screen)
{
xcb_screen_iterator_t iter;
iter = xcb_setup_roots_iterator(xcb_get_setup(xcb));
for (; iter.rem; --screen, xcb_screen_next(&iter)) {
if (screen == 0)
return iter.data;
}
return NULL;
}

View File

@ -24,6 +24,7 @@ extern "C" {
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <xcb/shm.h>
#include <xcb/xproto.h>
#include <obs.h>
typedef struct {
@ -120,6 +121,15 @@ xcb_shm_t *xshm_xcb_attach(xcb_connection_t *xcb, const int w, const int h);
*/
void xshm_xcb_detach(xcb_shm_t *shm);
/**
* Get screen by id for a xcb connection
*
* @param xcb xcb connection
* @param screen id of the screen
* @return screen info structure
*/
xcb_screen_t *xcb_get_screen(xcb_connection_t *xcb, int screen);
#ifdef __cplusplus
}
#endif