ecore-evas: feature++ : support netm sync protocol for clients

SVN revision: 58198
This commit is contained in:
Carsten Haitzler 2011-03-30 10:10:04 +00:00
parent 9c336235b2
commit 1588a92819
5 changed files with 76 additions and 1 deletions

View File

@ -103,3 +103,8 @@
* Add ecore_con_url_ssl_ca_set to manually set a certificate authority.
2011-03-30 Carsten Haitzler (The Rasterman)
* Ecore_X gains some more x sync counter controls and Ecore_Evas
now uses the netwm sync protocol to get wm's to only configure
as fast as it can keep drawing.

View File

@ -202,6 +202,9 @@ struct _Ecore_Evas_Engine
Ecore_X_XRegion *damages;
Ecore_X_Sync_Counter sync_counter;
Ecore_X_Window leader;
Ecore_X_Sync_Counter netwm_sync_counter;
int netwm_sync_val_hi;
unsigned int netwm_sync_val_lo;
int sync_val; // bigger! this will screw up at 2 billion frames (414 days of continual rendering @ 60fps)
int screen_num;
int px, py, pw, ph;
@ -210,6 +213,7 @@ struct _Ecore_Evas_Engine
unsigned char managed : 1;
unsigned char sync_began : 1;
unsigned char sync_cancel : 1;
unsigned char netwm_sync_set : 1;
struct {
unsigned char modal : 1;
unsigned char sticky : 1;

View File

@ -81,7 +81,18 @@ _ecore_evas_x_protocols_set(Ecore_Evas *ee)
if (ee->func.fn_delete_request)
protos[num++] = ECORE_X_ATOM_WM_DELETE_WINDOW;
protos[num++] = ECORE_X_ATOM_NET_WM_PING;
protos[num++] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
ecore_x_icccm_protocol_atoms_set(ee->prop.window, protos, num);
if (!ee->engine.x.netwm_sync_counter)
ee->engine.x.netwm_sync_counter = ecore_x_sync_counter_new(0);
////////
{
unsigned int tmp = ee->engine.x.netwm_sync_counter;
ecore_x_window_prop_card32_set(ee->prop.window,
ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER,
&tmp, 1);
}
}
static void
@ -739,6 +750,15 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v
ee->engine.x.sync_began = 0;
ee->engine.x.sync_cancel = 1;
}
else if ((e->message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
(e->data.l[0] == (int)ECORE_X_ATOM_NET_WM_SYNC_REQUEST))
{
ee = ecore_event_window_match(e->win);
if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
ee->engine.x.netwm_sync_val_lo = (unsigned int)e->data.l[2];
ee->engine.x.netwm_sync_val_hi = (int)e->data.l[3];
ee->engine.x.netwm_sync_set = 1;
}
return ECORE_CALLBACK_PASS_ON;
}
@ -2996,6 +3016,13 @@ _ecore_evas_x_flush_post(void *data, Evas *e __UNUSED__, void *event_info __UNUS
{
Ecore_Evas *ee = data;
if (ee->engine.x.netwm_sync_set)
{
ecore_x_sync_counter_2_set(ee->engine.x.netwm_sync_counter,
ee->engine.x.netwm_sync_val_hi,
ee->engine.x.netwm_sync_val_lo);
ee->engine.x.netwm_sync_set = 0;
}
if (ee->no_comp_sync) return;
if (!_ecore_evas_app_comp_sync) return;
if (ee->engine.x.sync_counter)

View File

@ -2257,7 +2257,11 @@ EAPI void ecore_x_sync_counter_inc(
EAPI void ecore_x_sync_counter_val_wait(
Ecore_X_Sync_Counter counter,
int val);
EAPI void ecore_x_sync_counter_set(Ecore_X_Sync_Counter counter, int val);
EAPI void ecore_x_sync_counter_2_set(Ecore_X_Sync_Counter counter, int val_hi, unsigned int val_lo);
EAPI Eina_Bool ecore_x_sync_counter_2_query(Ecore_X_Sync_Counter counter, int *val_hi, unsigned int *val_lo);
EAPI void ecore_x_xinerama_query_screens_prefetch(
void);
EAPI void ecore_x_xinerama_query_screens_fetch(void);

View File

@ -114,3 +114,38 @@ ecore_x_sync_counter_val_wait(Ecore_X_Sync_Counter counter, int val)
// XSync(_ecore_x_disp, False); // dont need this
} /* ecore_x_sync_counter_val_wait */
EAPI void
ecore_x_sync_counter_set(Ecore_X_Sync_Counter counter, int val)
{
XSyncValue v;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XSyncIntToValue(&v, val);
XSyncSetCounter(_ecore_x_disp, counter, v);
}
EAPI void
ecore_x_sync_counter_2_set(Ecore_X_Sync_Counter counter, int val_hi, unsigned int val_lo)
{
XSyncValue v;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XSyncIntsToValue(&v, val_lo, val_hi);
XSyncSetCounter(_ecore_x_disp, counter, v);
}
EAPI Eina_Bool
ecore_x_sync_counter_2_query(Ecore_X_Sync_Counter counter, int *val_hi, unsigned int *val_lo)
{
XSyncValue value;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (XSyncQueryCounter(_ecore_x_disp, counter, &value))
{
*val_lo = (unsigned int)XSyncValueLow32(value);
*val_hi = (int)XSyncValueHigh32(value);
return EINA_TRUE;
}
return EINA_FALSE;
}