Beispiel #1
0
/**
 * Check the DPMS power level.
 * @return @c 0 if DPMS is :In Use
 * @return @c 1 if DPMS is :Blanked, low power
 * @return @c 2 if DPMS is :Blanked, lower power
 * @return @c 3 if DPMS is :Shut off, awaiting activity
 * @return @c -1 otherwise.
*/
EAPI Ecore_X_Dpms_Mode 
ecore_x_dpms_power_level_get(void)
{
   Ecore_X_Dpms_Mode ret = -1;
#ifdef ECORE_XCB_DPMS
   xcb_dpms_info_cookie_t cookie;
   xcb_dpms_info_reply_t *reply;
#endif

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   if (!_dpms_avail) return ret;

#ifdef ECORE_XCB_DPMS
   cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
   reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return -1;

   ret = reply->power_level;
   free(reply);
#endif

   return ret;
}
/*
 * Calls draw_image on a new pixmap and swaps that with the current pixmap
 *
 */
void redraw_screen(void) {

    /* avoid drawing if monitor state is not on */
    if (dpms_capable) {
        xcb_dpms_info_reply_t *dpms_info =
            xcb_dpms_info_reply(conn,xcb_dpms_info(conn), NULL);
        if (dpms_info) {
            /* monitor is off when DPMS state is enabled and power level is not
             * DPMS_MODE_ON */
            uint8_t monitor_off = dpms_info->state
                && dpms_info->power_level != XCB_DPMS_DPMS_MODE_ON;
            free(dpms_info);
            if (monitor_off)
                return;
        }
    }

    xcb_pixmap_t bg_pixmap = draw_image(last_resolution);
    xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[1]){ bg_pixmap });
    /* XXX: Possible optimization: Only update the area in the middle of the
     * screen instead of the whole screen. */
    xcb_clear_area(conn, 0, win, 0, 0, last_resolution[0], last_resolution[1]);
    xcb_free_pixmap(conn, bg_pixmap);
    xcb_flush(conn);
}
Beispiel #3
0
/**
 * Checks the DPMS state of the display.
 * @return @c EINA_TRUE if DPMS is enabled, @c EINA_FALSE otherwise.
 * @ingroup Ecore_X_DPMS_Group
 */
EAPI Eina_Bool
ecore_x_dpms_enabled_get(void)
{
   Eina_Bool ret = EINA_FALSE;
#ifdef ECORE_XCB_DPMS
   xcb_dpms_info_cookie_t cookie;
   xcb_dpms_info_reply_t *reply;
#endif

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   if (!_dpms_avail) return EINA_FALSE;

#ifdef ECORE_XCB_DPMS
   cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
   reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return EINA_FALSE;
   if (reply->state) ret = EINA_TRUE;
   free(reply);
#endif

   return ret;
}