Ecore_X (RandR): Fix long outstanding randr bug which caused

ecore_x_randr to not work for pretty much everyone. Short version,
don't memcpy something potentially Larger into something Certainly
smaller. (read on for the details).

NB: This 'should' fix all the randr problems in ecore_x (tho I have
not tested Everything).

NB: Ok, here goes:
    XRRGetScreenResources returns a struct. Inside that struct is a
    list of RROutputs.

    RROutput is defined as (from randrproto.h):
      #define RROutput CARD32

    CARD32 is defined as (from X11/Xmd.h): 
      # ifdef LONG64
        typedef unsigned long CARD64;
        typedef unsigned int CARD32;
      # else
        typedef unsigned long CARD32;
      # endif
    so CARD32 can change based on the system (32/64 bit).

    Ecore_X_Randr_Output is defined as (Ecore_X.h):
       typedef Ecore_X_ID Ecore_X_Randr_Output;
       (for reference: typedef unsigned int Ecore_X_ID)

    Double bonus points if you have already spotted the problem !! ;)



SVN revision: 76306
This commit is contained in:
Christopher Michael 2012-09-07 13:12:30 +00:00
parent e26ae30eb8
commit aa88c5697d
1 changed files with 6 additions and 4 deletions

View File

@ -642,10 +642,12 @@ ecore_x_randr_outputs_get(Ecore_X_Window root,
{
if ((ret = malloc(sizeof(Ecore_X_Randr_Output) * res->noutput)))
{
memcpy(ret, res->outputs,
(sizeof(Ecore_X_Randr_Output) * res->noutput));
if (num)
*num = res->noutput;
int i = 0;
if (num) *num = res->noutput;
for (i = 0; i < res->noutput; i++)
ret[i] = res->outputs[i];
}
if (res)