3 #endif /* ifdef HAVE_CONFIG_H */
7 #include "ecore_x_private.h"
10 int _ecore_x_present_major = 0;
11 static Eina_Bool _ecore_x_present_exists = EINA_FALSE;
14 _ecore_x_present_init(void)
16 ECORE_X_EVENT_PRESENT_CONFIGURE = ecore_event_type_new();
17 ECORE_X_EVENT_PRESENT_COMPLETE = ecore_event_type_new();
18 ECORE_X_EVENT_PRESENT_IDLE = ecore_event_type_new();
20 LOGFN(__FILE__, __LINE__, __FUNCTION__);
21 _ecore_x_present_exists = XPresentQueryExtension(_ecore_x_disp, &_ecore_x_present_major, NULL, NULL);
26 #define SET(X) e->X = ev->X
29 _present_configure(XPresentConfigureNotifyEvent *ev)
31 Ecore_X_Event_Present_Configure *e;
33 e = calloc(1, sizeof(Ecore_X_Event_Present_Configure));
38 SET(width), SET(height);
39 SET(off_x), SET(off_y);
40 SET(pixmap_width), SET(pixmap_height);
43 ecore_event_add(ECORE_X_EVENT_PRESENT_CONFIGURE, e, NULL, NULL);
47 _present_complete(XPresentCompleteNotifyEvent *ev)
51 [PresentCompleteModeCopy] = ECORE_X_PRESENT_COMPLETE_MODE_COPY,
52 [PresentCompleteModeFlip] = ECORE_X_PRESENT_COMPLETE_MODE_FLIP,
53 [PresentCompleteModeSkip] = ECORE_X_PRESENT_COMPLETE_MODE_SKIP,
55 Ecore_X_Event_Present_Complete *e;
57 e = calloc(1, sizeof(Ecore_X_Event_Present_Complete));
61 e->serial = ev->serial_number;
63 e->kind = (ev->kind == 1); //libXpresent doesn't expose this...
64 e->mode = mode[ev->mode];
65 ecore_event_add(ECORE_X_EVENT_PRESENT_COMPLETE, e, NULL, NULL);
69 _present_idle(XPresentIdleNotifyEvent *ev)
71 Ecore_X_Event_Present_Idle *e;
73 e = calloc(1, sizeof(Ecore_X_Event_Present_Idle));
77 e->serial = ev->serial_number;
80 ecore_event_add(ECORE_X_EVENT_PRESENT_IDLE, e, NULL, NULL);
85 _ecore_x_present_handler(XGenericEvent *ge)
87 XGenericEventCookie *gec = (XGenericEventCookie*)ge;
89 if (XGetEventData(_ecore_x_disp, gec))
93 case PresentConfigureNotify:
94 _present_configure(gec->data);
96 case PresentCompleteNotify:
97 _present_complete(gec->data);
99 case PresentIdleNotify:
100 _present_idle(gec->data);
105 XFreeEventData(_ecore_x_disp, gec);
110 ecore_x_present_select_events(Ecore_X_Window win, unsigned int events)
112 #ifdef ECORE_XPRESENT
113 XPresentSelectInput(_ecore_x_disp, win, events);
114 if (_ecore_xlib_sync) ecore_x_sync();
122 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)
124 #ifdef ECORE_XPRESENT
125 XPresentNotifyMSC(_ecore_x_disp, win, serial, target_msc, divisor, remainder);
126 if (_ecore_xlib_sync) ecore_x_sync();
137 ecore_x_present_pixmap(Ecore_X_Window win, Ecore_X_Pixmap pixmap, unsigned int serial, Ecore_X_Region valid,
138 Ecore_X_Region update, int x_off, int y_off, Ecore_X_Randr_Crtc target_crtc,
139 Ecore_X_Sync_Fence wait_fence, Ecore_X_Sync_Fence idle_fence, unsigned int options,
140 unsigned long long target_msc, unsigned long long divisor, unsigned long long remainder,
141 Ecore_X_Present *notifies, int num_notifies)
143 #ifdef ECORE_XPRESENT
144 XPresentPixmap(_ecore_x_disp, win, pixmap, serial, valid, update,
145 x_off, y_off, target_crtc, wait_fence, idle_fence, options, target_msc,
146 divisor, remainder, (XPresentNotify*)notifies, num_notifies);
147 if (_ecore_xlib_sync) ecore_x_sync();
169 ecore_x_present_exists(void)
171 return _ecore_x_present_exists;