本文整理汇总了C++中xcb_setup_roots_iterator函数的典型用法代码示例。如果您正苦于以下问题:C++ xcb_setup_roots_iterator函数的具体用法?C++ xcb_setup_roots_iterator怎么用?C++ xcb_setup_roots_iterator使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xcb_setup_roots_iterator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initScreen
void initScreen() {
/* Open Xlib Display */
display = XOpenDisplay(0);
if (!display) printf("Can't open display");
default_screen = ((_XPrivDisplay)display)->default_screen;
/* Get the XCB connection from the display */
connection = XGetXCBConnection(display);
if (!connection) printf("Can't get xcb connection from display");
/* Acquire event queue ownership */
XSetEventQueueOwner(display, XCBOwnsEventQueue);
/* Find XCB screen */
screen = 0;
xcb_screen_iterator_t screen_iter =
xcb_setup_roots_iterator(xcb_get_setup(connection));
for (int screen_num = default_screen;
screen_iter.rem && screen_num > 0;
--screen_num, xcb_screen_next(&screen_iter));
screen = screen_iter.data;
/*
width = screen->width_in_pixels;
height = screen->height_in_pixels;
*/
width = 250;
height = 260;
}
示例2: systray_process_client_message
/** Handle systray message.
* \param ev The event.
* \return 0 on no error.
*/
int
systray_process_client_message(xcb_client_message_event_t *ev)
{
int screen_nbr = 0, ret = 0;
xcb_get_geometry_cookie_t geom_c;
xcb_get_geometry_reply_t *geom_r;
xcb_screen_iterator_t iter;
switch(ev->data.data32[1])
{
case SYSTEM_TRAY_REQUEST_DOCK:
geom_c = xcb_get_geometry_unchecked(globalconf.connection, ev->window);
if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL)))
return -1;
for(iter = xcb_setup_roots_iterator(xcb_get_setup(globalconf.connection)), screen_nbr = 0;
iter.rem && iter.data->root != geom_r->root; xcb_screen_next (&iter), ++screen_nbr);
p_delete(&geom_r);
ret = systray_request_handle(ev->data.data32[2], screen_nbr, NULL);
break;
}
return ret;
}
示例3: _best_depth_get
static int
_best_depth_get(int backend, void *connection, int screen)
{
if (!connection) return 0;
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
{
return DefaultDepth((Display *)connection, screen);
}
#endif
#ifdef BUILD_ENGINE_SOFTWARE_XCB
if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
{
xcb_screen_iterator_t iter_screen;
xcb_screen_t *s;
iter_screen = xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
for (; iter_screen.rem; --screen, xcb_screen_next (&iter_screen))
if (screen == 0)
{
s = iter_screen.data;
break;
}
return s->root_depth;
}
#endif
return 0;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
示例7: xcb_setup_roots_iterator
void QXcbCursor::queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask)
{
if (pos)
*pos = QPoint();
xcb_screen_iterator_t it = xcb_setup_roots_iterator(c->setup());
while (it.rem) {
xcb_window_t root = it.data->root;
xcb_query_pointer_cookie_t cookie = xcb_query_pointer(c->xcb_connection(), root);
xcb_generic_error_t *err = 0;
xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(c->xcb_connection(), cookie, &err);
if (!err && reply) {
if (pos)
*pos = QPoint(reply->root_x, reply->root_y);
if (rootWin)
*rootWin = root;
if (keybMask)
*keybMask = reply->mask;
free(reply);
return;
}
free(err);
free(reply);
xcb_screen_next(&it);
}
}
示例8: 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;
}
示例9: 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;
}
示例10: has_required_depths
static int
has_required_depths (xcb_connection_t *c)
{
xcb_screen_iterator_t screens;
xcb_pixmap_t pixmap = { -1 };
for (screens = xcb_setup_roots_iterator(xcb_get_setup(c)); screens.rem; xcb_screen_next(&screens))
{
xcb_depth_iterator_t depths;
uint32_t missing = REQUIRED_DEPTHS;
xcb_drawable_t root;
for (depths = xcb_screen_allowed_depths_iterator(screens.data); depths.rem; xcb_depth_next(&depths))
missing &= ~DEPTH_MASK(depths.data->depth);
if (!missing)
continue;
/*
* Ok, this is ugly. It should be sufficient at this
* point to just return false, but Xinerama is broken at
* this point and only advertises depths which have an
* associated visual. Of course, the other depths still
* work, but the only way to find out is to try them.
*/
if (pixmap == -1)
pixmap = xcb_generate_id(c);
root = screens.data->root;
if (!pixmap_depths_usable (c, missing, pixmap, root))
return 0;
}
return 1;
}
示例11: _cairo_xcb_screen_from_visual
static xcb_screen_t *
_cairo_xcb_screen_from_visual (xcb_connection_t *connection,
xcb_visualtype_t *visual,
int *depth)
{
xcb_depth_iterator_t d;
xcb_screen_iterator_t s;
s = xcb_setup_roots_iterator (xcb_get_setup (connection));
for (; s.rem; xcb_screen_next (&s)) {
if (s.data->root_visual == visual->visual_id) {
*depth = s.data->root_depth;
return s.data;
}
d = xcb_screen_allowed_depths_iterator(s.data);
for (; d.rem; xcb_depth_next (&d)) {
xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator (d.data);
for (; v.rem; xcb_visualtype_next (&v)) {
if (v.data->visual_id == visual->visual_id) {
*depth = d.data->depth;
return s.data;
}
}
}
}
return NULL;
}
示例12: 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);
}
}
示例13: xcb_setup_roots_iterator
xcb_screen_t* IdlenessWatcher::screenOfDisplay(xcb_connection_t* conn, int screen)
{
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
for (; iter.rem; --screen, xcb_screen_next(&iter))
if (screen == 0)
return iter.data;
return NULL;
}
示例14: xconn_get_root
static xcb_window_t xconn_get_root(xconn_t c)
{
const xcb_setup_t *setup;
setup=xcb_get_setup(c->c);
xcb_screen_iterator_t iter = xcb_setup_roots_iterator (setup);
xcb_screen_t *screen = iter.data;
return screen->root;
}
示例15: 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;
}