/** * Sends the GetScreenInfo request. * @param window Window whose properties are requested. * @ingroup Ecore_X_RandR_Group */ EAPI void ecore_x_randr_get_screen_info_prefetch(Ecore_X_Window window) { #ifdef ECORE_XCB_RANDR xcb_randr_get_screen_info_cookie_t cookie; cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, _xcb_randr_root_to_screen(window)); _ecore_xcb_cookie_cache(cookie.sequence); #endif /* ECORE_XCB_RANDR */ }
void QXcbScreen::updateRefreshRate() { if (!connection()->hasXRandr()) return; int rate = m_refreshRate; xcb_randr_get_screen_info_reply_t *screenInfoReply = xcb_randr_get_screen_info_reply(xcb_connection(), xcb_randr_get_screen_info_unchecked(xcb_connection(), m_screen->root), 0); if (screenInfoReply) { rate = screenInfoReply->rate; free(screenInfoReply); } if (rate == m_refreshRate) return; m_refreshRate = rate; QWindowSystemInterface::handleScreenRefreshRateChange(QPlatformScreen::screen(), rate); }
static void init_xcb() { const xcb_query_extension_reply_t *qer; const xcb_setup_t *setup; xcb_screen_t *screen; xcb_screen_iterator_t screen_iter; xcb_drawable_t win; guint num_screens; guint i; xcb_generic_error_t *err = NULL; /* Open xcb connection */ conn = xcb_connect(gdk_get_display_arg_name(), NULL); if (xcb_connection_has_error(conn)) { g_error("Failed to connect to display\n"); exit(EXIT_FAILURE); } /* query the version to prevent error 16 when setting config */ xcb_randr_query_version_unchecked(conn, 1, 5); qer = xcb_get_extension_data(conn, &xcb_randr_id); if (!qer || !qer->present) { g_error("RandR extension missing\n"); exit(EXIT_FAILURE); } randr_base = qer->first_event; xcb_source = g_xcb_source_new_for_connection(NULL, conn); g_xcb_source_set_event_callback(xcb_source, on_xcb_event, NULL); /* get the screens */ setup = xcb_get_setup(conn); screen_iter = xcb_setup_roots_iterator(setup); num_screens = setup->roots_len; /* Set up space for cookies */ xcb_randr_get_screen_info_cookie_t get_screen_info_cookies[num_screens]; for (i = 0; i < num_screens; i++) { /* Get root window */ screen = screen_iter.data; win = screen->root; /* Register for screen change events */ xcb_randr_select_input(conn, win, XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE); /* Get screen info */ get_screen_info_cookies[i] = xcb_randr_get_screen_info_unchecked(conn, win); xcb_screen_next(&screen_iter); } /* TODO: detect adding and removal of screens */ xcb_flush(conn); /* Get screen info replies */ for (i = 0; i < num_screens; i++) { xcb_randr_get_screen_info_reply_t *reply = xcb_randr_get_screen_info_reply(conn, get_screen_info_cookies[i], &err); if (err) { g_warning("Error getting info for screen %u\n", i); err = NULL; continue; } add_screen(reply); free(reply); } xcb_flush(conn); }