本文整理汇总了C++中xcb_connect函数的典型用法代码示例。如果您正苦于以下问题:C++ xcb_connect函数的具体用法?C++ xcb_connect怎么用?C++ xcb_connect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xcb_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmOpen
/**
* Wrap an existing X11 window to embed the video.
*/
static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
xcb_window_t window = var_InheritInteger (wnd, "drawable-xid");
if (window == 0)
return VLC_EGENERIC;
if (AcquireDrawable (VLC_OBJECT(wnd), window))
return VLC_EGENERIC;
vout_window_sys_t *p_sys = malloc (sizeof (*p_sys));
xcb_connection_t *conn = xcb_connect (NULL, NULL);
if (p_sys == NULL || xcb_connection_has_error (conn))
goto error;
p_sys->embedded = true;
p_sys->keys = NULL;
wnd->handle.xid = window;
wnd->control = Control;
wnd->sys = p_sys;
p_sys->conn = conn;
xcb_get_geometry_reply_t *geo =
xcb_get_geometry_reply (conn, xcb_get_geometry (conn, window), NULL);
if (geo == NULL)
{
msg_Err (wnd, "bad X11 window 0x%08"PRIx8, window);
goto error;
}
p_sys->root = geo->root;
free (geo);
if (var_InheritBool (wnd, "keyboard-events"))
{
p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
if (p_sys->keys != NULL)
{
const uint32_t mask = XCB_CW_EVENT_MASK;
const uint32_t values[1] = {
XCB_EVENT_MASK_KEY_PRESS,
};
xcb_change_window_attributes (conn, window, mask, values);
}
}
CacheAtoms (p_sys);
if ((p_sys->keys != NULL)
&& vlc_clone (&p_sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW))
DestroyKeyHandler (p_sys->keys);
xcb_flush (conn);
(void) cfg;
return VLC_SUCCESS;
error:
xcb_disconnect (conn);
free (p_sys);
ReleaseDrawable (VLC_OBJECT(wnd), window);
return VLC_EGENERIC;
}
示例2: deploy
static int
deploy(void)
{
/* init xcb and grab events */
uint32_t values[2];
int mask;
if (xcb_connection_has_error(conn = xcb_connect(NULL, NULL)))
return -1;
scr = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
focuswin = scr->root;
#ifdef ENABLE_MOUSE
xcb_grab_button(conn, 0, scr->root, XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE, XCB_GRAB_MODE_ASYNC,
XCB_GRAB_MODE_ASYNC, scr->root, XCB_NONE, 1, MOD);
xcb_grab_button(conn, 0, scr->root, XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE, XCB_GRAB_MODE_ASYNC,
XCB_GRAB_MODE_ASYNC, scr->root, XCB_NONE, 3, MOD);
#endif
mask = XCB_CW_EVENT_MASK;
values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
xcb_change_window_attributes_checked(conn, scr->root, mask, values);
xcb_flush(conn);
return 0;
}
示例3: xcb_connect
void SimplicityApplication::initialize_x_connection(void)
{
int nScreenNum = 0;
m_pXConnection = xcb_connect(m_sDisplayName.c_str(), &nScreenNum);
if (check_xcb_connection(m_pXConnection))
{
xcb_disconnect(m_pXConnection);
m_bRunning = false;
return;
}
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(m_pXConnection));
for (int i = 0; i != nScreenNum; i++)
xcb_screen_next(&iter);
m_pRootScreen = iter.data;
if (m_pRootScreen == nullptr)
{
global_log_error << "Could not get the current screen. Exiting";
xcb_disconnect(m_pXConnection);
m_bRunning = false;
}
global_log_debug << "Root screen dimensions: "
<< m_pRootScreen->width_in_pixels
<< "x"
<< m_pRootScreen->height_in_pixels;
global_log_debug << "Root window: "
<< m_pRootScreen->root;
}
示例4: main
int main(int argc, char **argv) {
(void)argc;
(void)argv;
/* open connection with the server */
nil_.con = xcb_connect(0, 0);
if (xcb_connection_has_error(nil_.con)) {
NIL_ERR("xcb_connect %p", (void *)nil_.con);
exit(1);
}
/* 1st stage */
if ((init_screen() != 0) || (init_key() != 0) || (init_mouse() != 0)) {
xcb_disconnect(nil_.con);
exit(1);
}
/* 2nd stage */
if ((init_cursor() != 0) || (init_color() != 0) != (init_font() != 0)
|| (init_bar() != 0) || (init_wm() != 0)) {
cleanup();
exit(1);
}
xcb_flush(nil_.con);
recv_events();
cleanup();
return 0;
}
示例5: NGBInit
void NGBInit()
{
event = NULL;
mask = 0;
con = xcb_connect(":0.0", NULL); //打开连接
if(xcb_connection_has_error(con))
{
printf("Cannot open display\n");
exit(1);
}
screen = xcb_setup_roots_iterator(xcb_get_setup(con)).data;
win = screen->root;
foreground = xcb_generate_id(con);
mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
values[0] = screen->black_pixel;
values[1] = 0;
xcb_create_gc(con, foreground, win, mask, values);
win = xcb_generate_id(con);
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
values[0] = screen->white_pixel;
values[1] = XCB_EVENT_MASK_EXPOSURE;
}
示例6: main
int main(void)
{
xcb_connection_t *conn;
xcb_screen_t *screen;
xcb_window_t win;
xcb_gcontext_t gcontext;
xcb_generic_event_t *event;
uint32_t mask;
uint32_t values[2];
/* open connection with the server */
conn = xcb_connect(NULL,NULL);
if (xcb_connection_has_error(conn)) {
printf("Cannot open display\n");
exit(1);
}
/* get the first screen */
screen = xcb_setup_roots_iterator( xcb_get_setup(conn) ).data;
/* create black graphics gcontext */
gcontext = xcb_generate_id(conn);
win = screen->root;
mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
values[0] = screen->black_pixel;
values[1] = 0;
xcb_create_gc(conn, gcontext, win, mask, values);
/* create window */
win = xcb_generate_id(conn);
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
values[0] = screen->white_pixel;
values[1] = XCB_EVENT_MASK_EXPOSURE
| XCB_EVENT_MASK_KEY_PRESS
| XCB_EVENT_MASK_KEY_RELEASE;
xcb_create_window(conn, screen->root_depth, win, screen->root,
10, 10, 100, 100, 1,
XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual,
mask, values);
/* map (show) the window */
xcb_map_window(conn, win);
xcb_flush(conn);
cterm_add_event_listener(XCB_KEY_PRESS, output_string);
cterm_add_event_listener(XCB_KEY_PRESS, close_window);
/* event loop */
while (!done) {
event = xcb_poll_for_event(conn);
if(event == NULL) continue;
cterm_handle_event(event);
free(event);
}
/* close connection to server */
xcb_disconnect(conn);
cterm_free_event_handlers();
return 0;
}
示例7: init
void init(void)
{
int scrno;
xcb_screen_iterator_t iter;
conn = xcb_connect(NULL, &scrno);
if (!conn)
{
fprintf(stderr, "can't connect to an X server\n");
exit(1);
}
iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
for (int i = 0; i < scrno; ++i)
{
xcb_screen_next(&iter);
}
screen = iter.data;
if (!screen)
{
fprintf(stderr, "can't get the current screen\n");
xcb_disconnect(conn);
exit(1);
}
}
示例8: main
int main() {
/* Open the connection to the server. Use de DISPLAY enviroment variable */
int i, screenNum;
xcb_connection_t *connection = xcb_connect(NULL, &screenNum);
// Get the screen whose number is screenNum
const xcb_setup_t *setup = xcb_get_setup(connection);
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup);
// We want the screen at index screenNum of the iterator
for (i = 0; i < screenNum; i++) {
xcb_screen_next(&iter);
}
xcb_screen_t *screen = iter.data;
// report
printf("\n");
printf("Informations of screen %" PRIu32 "\n", screen->root);
printf(" width.........: %" PRIu16 "\n", screen->width_in_pixels);
printf(" height........: %" PRIu16 "\n", screen->height_in_pixels);
printf(" white_pixel...: %" PRIu32 "\n", screen->white_pixel);
printf(" black pixel...: %" PRIu32 "\n", screen->black_pixel);
printf("\n");
return 0;
}
示例9: xcb_connect
xcb_window_t LinuxWindowCapture::FindWindow( const QString& instanceName, const QString& windowClass ) {
xcb_window_t window = static_cast< xcb_window_t > ( 0 );
xcb_connection_t* dpy = xcb_connect( NULL, NULL );
if ( xcb_connection_has_error( dpy ) ) { qDebug() << "Can't open display"; }
xcb_screen_t* screen = xcb_setup_roots_iterator( xcb_get_setup( dpy ) ).data;
if( !screen ) { qDebug() << "Can't acquire screen"; }
xcb_window_t root = screen->root;
QList< xcb_window_t > windows = listWindowsRecursive( dpy, root );
foreach( const xcb_window_t& win, windows ) {
xcb_icccm_get_wm_class_reply_t wmNameR;
xcb_get_property_cookie_t wmClassC = xcb_icccm_get_wm_class( dpy, win );
if ( xcb_icccm_get_wm_class_reply( dpy, wmClassC, &wmNameR, NULL ) ) {
if( !qstrcmp( wmNameR.class_name, windowClass.toStdString().c_str() ) ||
!qstrcmp( wmNameR.instance_name, instanceName.toStdString().c_str() ) ) {
qDebug() << wmNameR.instance_name;
qDebug() << wmNameR.class_name;
window = win;
break;
}
}
}
示例10: init_vk
int vkDisplay::init(const unsigned int gpu_idx)
{
//m_gpuIdx = gpu_idx;
#if 0
VkResult result = init_vk(gpu_idx);
if (result != VK_SUCCESS) {
vktrace_LogError("could not init vulkan library");
return -1;
} else {
m_initedVK = true;
}
#endif
#if defined(PLATFORM_LINUX)
const xcb_setup_t *setup;
xcb_screen_iterator_t iter;
int scr;
m_pXcbConnection = xcb_connect(NULL, &scr);
setup = xcb_get_setup(m_pXcbConnection);
iter = xcb_setup_roots_iterator(setup);
while (scr-- > 0)
xcb_screen_next(&iter);
m_pXcbScreen = iter.data;
#endif
return 0;
}
示例11: main
int main(int argc, char **argv){
xcb_connection_t *c = xcb_connect(0, 0);
xcb_screen_t *s = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
int w, h, n,
depth = s->root_depth,
win_class = XCB_WINDOW_CLASS_INPUT_OUTPUT,
format = XCB_IMAGE_FORMAT_Z_PIXMAP;
xcb_colormap_t colormap = s->default_colormap;
xcb_drawable_t win = xcb_generate_id(c);
xcb_gcontext_t gc = xcb_generate_id(c);
xcb_pixmap_t pixmap = xcb_generate_id(c);
xcb_generic_event_t *ev;
xcb_image_t *image;
char *data = NULL;
uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
value_mask = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS,
values[] = { s->black_pixel, value_mask };
if (argc<2) return -1;
data = stbi_load(argv[1], &w, &h, &n, 4);
if (data) {
unsigned *dp = (unsigned *)data;
size_t i, len = w*h;
for(i=0;i<len;i++) //rgba to bgra
dp[i]=dp[i]&0xff00ff00|((dp[i]>>16)&0xFF)|((dp[i]<<16)&0xFF0000);
}else return -1;
示例12: main
int main()
{
/* Open the connection to the X server */
xcb_connection_t *connection = xcb_connect(NULL, NULL);
/* Get the first screen */
const xcb_setup_t *setup = xcb_get_setup(connection);
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup);
xcb_screen_t *screen = iter.data;
/* Create the window */
xcb_window_t window = xcb_generate_id(connection);
xcb_create_window(connection, /* Connection */
XCB_COPY_FROM_PARENT, /* depth (same as root) */
window, /* window Id */
screen->root, /* parent window */
0, 0, /* x, y */
150, 150, /* width, height */
10, /* border_width */
XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
screen->root_visual, /* visual */
0, NULL); /* masks, not used yet */
/* Map the window on the screen */
xcb_map_window(connection, window);
/* Make sure commands are sent before we pause so that the window gets shown */
xcb_flush(connection);
pause(); /* hold client until Ctrl-C */
xcb_disconnect(connection);
return 0;
}
示例13: xcb_connect
bool X11IdleDetector::idleCheckPossible()
{
m_connection = xcb_connect(NULL, NULL); //krazy:exclude=null
m_screen = xcb_setup_roots_iterator(xcb_get_setup(m_connection)).data;
if (m_screen)
return true;
return false;
}
示例14: xcb_connect
xcb_connection_t *X11Info::xcbConnection()
{
if (!_xcb) {
_xcb = xcb_connect(NULL, &_xcbPreferredScreen);
Q_ASSERT(_xcb);
}
return _xcb;
}
示例15: main
int main(int argc, char **argv) {
uint32_t width = test_width - 2 * INSET_X;
uint32_t height = test_height - 2 * INSET_Y;
int snum;
xcb_void_cookie_t check_cookie;
xcb_window_t w;
xcb_gcontext_t gc;
xcb_pixmap_t pix;
xcb_connection_t *c = xcb_connect(0, &snum);
xcb_screen_t *s = xcb_aux_get_screen(c, snum);
xcb_alloc_named_color_cookie_t bg_cookie =
xcb_alloc_named_color(c, s->default_colormap,
strlen("white"), "white");
xcb_alloc_named_color_cookie_t fg_cookie =
xcb_alloc_named_color(c, s->default_colormap,
strlen("black"), "black");
xcb_alloc_named_color_reply_t *bg_reply =
xcb_alloc_named_color_reply(c, bg_cookie, 0);
xcb_alloc_named_color_reply_t *fg_reply =
xcb_alloc_named_color_reply(c, fg_cookie, 0);
uint32_t fg, bg;
xcb_image_t *image, *native_image, *subimage;
uint32_t mask = 0;
xcb_params_gc_t gcv;
assert(bg_reply && fg_reply);
bg = bg_reply->pixel;
fg = fg_reply->pixel;
free(bg_reply);
free(fg_reply);
w = make_window(c, s, bg, fg, width, height);
gc = xcb_generate_id(c);
check_cookie = xcb_create_gc_checked(c, gc, w, 0, 0);
assert(!xcb_request_check(c, check_cookie));
image = xcb_image_create_from_bitmap_data((uint8_t *)test_bits,
test_width, test_height);
native_image = xcb_image_native(c, image, 1);
assert(native_image);
if (native_image != image)
xcb_image_destroy(image);
subimage = xcb_image_subimage(native_image, INSET_X, INSET_Y,
width, height,
0, 0, 0);
assert(subimage);
xcb_image_destroy(native_image);
subimage->format = XCB_IMAGE_FORMAT_XY_BITMAP;
pix = xcb_generate_id(c);
xcb_create_pixmap(c, s->root_depth, pix, w,
subimage->width, subimage->height);
gc = xcb_generate_id(c);
XCB_AUX_ADD_PARAM(&mask, &gcv, foreground, fg);
XCB_AUX_ADD_PARAM(&mask, &gcv, background, bg);
xcb_aux_create_gc(c, gc, pix, mask, &gcv);
xcb_image_put(c, pix, gc, subimage, 0, 0, 0);
process_events(c, gc, w, pix, width, height);
xcb_disconnect(c);
return 1;
}