Dennis Schridde schreef:
> Am Sonntag, 26. November 2006 18:43 schrieb Giel van Schijndel:
>   
>> Dennis Schridde schreef:
>>     
>>>> The changes to trunk/lib/widget/scrap.c cause a compiler error
>>>> (comparison of int with pointer). This error will only be raised while
>>>> compiling a Windows build. I don't have the patches but according to the
>>>> description above I'm guessing number 003.
>>>>
>>>> Also the previous style of comparing those two values would result in
>>>> comparing pointer-addresses rather than a value comparison.
>>>> (See the typedef of HWND in windef.h).
>>>>         
>>> Seems like this more complicated...
>>>
>>> scrap.c sets SDL_Window (I don't think the name is choosen very wise,
>>> btw) to info.window, which is of type HWND...
>>> Can we revert SDL_Window back to HWND and then compare whatever type that
>>> is with GetClipboardOwner? Would that be the clean way of doing this? Or
>>> does MS recommend to use that HWND.i thing instead?
>>>       
>> The currently unmodified comparison which causes the compiler to abort
>> is this one:
>> ( GetClipboardOwner() != SDL_Window )
>>
>> Assuming GetClipboardOwner returns HWND this is the comparison being made:
>> ( (HWND) != (int) )
>> which equals:
>> ( (struct HWND__{int i;}*HWND) != (int) )
>>
>> If SDL_Window is declared as HWND however you get this:
>> ( (struct HWND__{int i;}*HWND) != (struct HWND__{int i;}*HWND) )
>>
>> So the current comparison as it is being made is wrong in all cases,
>> because all that the current comparison does is comparing pointer
>> addresses. This will when SDL_Window is declared as HWND always return
>> true (!=),
>>     
> Why will it return true?
> I thought HWND is a pointer to some blob, handled and allocated by Windows, 
> associated with the window? So this blob is allways at the same position for 
> the same window, so you can compare the pointer to it, can't you?
> And actually SDL_Window is set from a SDL_WMinfo.window thingy, which 
> actually 
> is a HWND, very probably handed over by Windows to SDL, being a reference for 
> the window. So I don't see why we can't compare it to some other HWND we get 
> from Windows. (Or why that should allways be true...)
>   
Well the problem is that the hWnd isn't a true pointer to a memory
address (see: http://en.wikipedia.org/wiki/Smart_pointer#Handles), but
more of an index number windows uses to manage memory chunks. Like an
index number to an array that contains the real pointers, whereas only
the windows API has access to that "array" to use the values within it.
So, if you compare the a pointer to a variable containing the hWnd value
with the hWnd value itself you probably will never get a match. Even
more so if you compare a pointer to variable A containing hWnd A with a
pointer to variable B containing hWnd A.

Hope that wasn't too fuzzy.
>>> (I guess Christian changed this in an accident, believing that, because
>>> HWND is defined to int on Linux (by frame.h) it would be of the same type
>>> on Windows.)
>>>       
>> Believing windows to follow similar standards is never a good thing in
>> my opinion ;-) .
>>     
> (The Linux definition of HWND only existed, as a workaround for some 
> functions 
> using it, because they still had some Windows only (non crossplatform stuff) 
> in them.)
>   
Didn't knew that. I do think however that removing hWnd dependencies for
functions would be nice, but that's another subject.

--
Giel

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to