1 #include "ecore_xcb_private.h"
2 # ifdef ECORE_XCB_XPRESENT
3 # include <xcb/present.h>
7 static Eina_Bool _xpresent_avail = EINA_FALSE;
9 /* external variables */
10 int _ecore_xcb_event_xpresent = -1;
13 _ecore_xcb_xpresent_init(void)
15 LOGFN(__FILE__, __LINE__, __FUNCTION__);
17 #ifdef ECORE_XCB_XPRESENT
18 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_present_id);
23 _ecore_xcb_xpresent_finalize(void)
25 #ifdef ECORE_XCB_XPRESENT
26 const xcb_query_extension_reply_t *ext_reply;
29 LOGFN(__FILE__, __LINE__, __FUNCTION__);
31 #ifdef ECORE_XCB_XPRESENT
32 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_present_id);
33 if ((ext_reply) && (ext_reply->present))
35 xcb_present_query_version_cookie_t cookie;
36 xcb_present_query_version_reply_t *reply;
39 xcb_present_query_version_unchecked(_ecore_xcb_conn,
40 XCB_PRESENT_MAJOR_VERSION,
41 XCB_PRESENT_MINOR_VERSION);
42 reply = xcb_present_query_version_reply(_ecore_xcb_conn, cookie, NULL);
45 _xpresent_avail = EINA_TRUE;
50 _ecore_xcb_event_xpresent = ext_reply->first_event;
55 #ifdef ECORE_XCB_XPRESENT
56 #define SET(X) e->X = ev->X
59 _present_configure(xcb_present_configure_notify_event_t *ev)
61 Ecore_X_Event_Present_Configure *e;
63 e = calloc(1, sizeof(Ecore_X_Event_Present_Configure));
68 SET(width), SET(height);
69 SET(off_x), SET(off_y);
70 SET(pixmap_width), SET(pixmap_height);
73 ecore_event_add(ECORE_X_EVENT_PRESENT_CONFIGURE, e, NULL, NULL);
77 _present_complete(xcb_present_complete_notify_event_t *ev)
81 [XCB_PRESENT_COMPLETE_MODE_COPY] = ECORE_X_PRESENT_COMPLETE_MODE_COPY,
82 [XCB_PRESENT_COMPLETE_MODE_FLIP] = ECORE_X_PRESENT_COMPLETE_MODE_FLIP,
83 [XCB_PRESENT_COMPLETE_MODE_SKIP] = ECORE_X_PRESENT_COMPLETE_MODE_SKIP,
85 Ecore_X_Event_Present_Complete *e;
87 e = calloc(1, sizeof(Ecore_X_Event_Present_Complete));
93 e->kind = (ev->kind == XCB_PRESENT_COMPLETE_KIND_NOTIFY_MSC);
94 e->mode = mode[ev->mode];
95 ecore_event_add(ECORE_X_EVENT_PRESENT_COMPLETE, e, NULL, NULL);
99 _present_idle(xcb_present_idle_notify_event_t *ev)
101 Ecore_X_Event_Present_Idle *e;
103 e = calloc(1, sizeof(Ecore_X_Event_Present_Idle));
110 ecore_event_add(ECORE_X_EVENT_PRESENT_IDLE, e, NULL, NULL);
115 _ecore_xcb_event_handle_present_event(xcb_ge_event_t *ev)
117 switch (ev->event_type)
119 case XCB_PRESENT_EVENT_CONFIGURE_NOTIFY:
120 _present_configure((xcb_present_configure_notify_event_t*)(long)ev->pad1);
122 case XCB_PRESENT_EVENT_COMPLETE_NOTIFY:
123 _present_complete((xcb_present_complete_notify_event_t*)(long)ev->pad1);
125 case XCB_PRESENT_EVENT_IDLE_NOTIFY:
126 _present_idle((xcb_present_idle_notify_event_t*)(long)ev->pad1);
135 ecore_x_present_select_events(Ecore_X_Window win, unsigned int events)
137 LOGFN(__FILE__, __LINE__, __FUNCTION__);
138 #ifdef ECORE_XCB_XPRESENT
140 xcb_present_select_input(_ecore_xcb_conn, _ecore_xcb_event_xpresent, win, events);
148 ecore_x_present_notify_msc(Ecore_X_Window win, unsigned int serial, unsigned long long target_msc, unsigned long long divisor, unsigned long long remainder)
150 LOGFN(__FILE__, __LINE__, __FUNCTION__);
151 #ifdef ECORE_XCB_XPRESENT
153 xcb_present_notify_msc(_ecore_xcb_conn, win, serial, target_msc, divisor, remainder);
164 ecore_x_present_pixmap(Ecore_X_Window win, Ecore_X_Pixmap pixmap, unsigned int serial, Ecore_X_Region valid,
165 Ecore_X_Region update, int x_off, int y_off, Ecore_X_Randr_Crtc target_crtc,
166 Ecore_X_Sync_Fence wait_fence, Ecore_X_Sync_Fence idle_fence, unsigned int options,
167 unsigned long long target_msc, unsigned long long divisor, unsigned long long remainder,
168 Ecore_X_Present *notifies, int num_notifies)
170 LOGFN(__FILE__, __LINE__, __FUNCTION__);
171 #ifdef ECORE_XCB_XPRESENT
173 xcb_present_pixmap(_ecore_xcb_conn, win, pixmap, serial, valid, update,
174 x_off, y_off, target_crtc, wait_fence, idle_fence, options, target_msc,
175 divisor, remainder, num_notifies, (xcb_present_notify_t*)notifies);
197 ecore_x_present_exists(void)
199 return _xpresent_avail;