public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
* problem evaluating window resize hints under 64 bit
@ 2014-06-19 12:22 Oliver Schmidt
  2014-06-19 21:44 ` Jon TURNEY
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Schmidt @ 2014-06-19 12:22 UTC (permalink / raw)
  To: cygwin-xfree

The current cygwin x server 1.15.1-2 under 64-bit cygwin seems to have a problem correctly evaluating the window resize 
hints.

In hw/xwin/winmultiwindowwndproc.c the function ValidateSizing calls winMultiWindowGetWMNormalHints and gets wrong 
values in sizeHints.width_inc and sizeHints.height_inc.

In function winMultiWindowGetWMNormalHints in file hw/xwin/winmultiwindowclass.c you can see that a memcpy occurs from 
prop->data with sizeof(WinXSizeHints).

As it turns out, everything is correct if you modify the typedef of WinXSizeHints in hw/xwin/winmultiwindowclass.h so 
that long type becomes int:

--- a/cygwin/hw/xwin/winmultiwindowclass.h
+++ b/cygwin/hw/xwin/winmultiwindowclass.h
@@ -63,7 +63,7 @@ typedef struct {
   * used with WM_NORMAL_HINTS.
   */
  typedef struct {
-    long flags;                 /* marks which fields in this structure are defined */
+    int flags;                 /* marks which fields in this structure are defined */
      int x, y;                   /* obsolete for new window mgrs, but clients */
      int width, height;          /* should set so old wm's don't mess up */

I can only guess why this works: in the X11 message protocol all int and long types are mapped to 32 bit integers. It 
seems that the memcpy in winMultiWindowGetWMNormalHints has source data that has memory layout as in the X11 message 
protocol.

Best regards,
Oliver

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: problem evaluating window resize hints under 64 bit
  2014-06-19 12:22 problem evaluating window resize hints under 64 bit Oliver Schmidt
@ 2014-06-19 21:44 ` Jon TURNEY
  0 siblings, 0 replies; 2+ messages in thread
From: Jon TURNEY @ 2014-06-19 21:44 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: oschmidt-mailinglists

On 19/06/2014 13:22, Oliver Schmidt wrote:
> The current cygwin x server 1.15.1-2 under 64-bit cygwin seems to have a
> problem correctly evaluating the window resize hints.
>
> In hw/xwin/winmultiwindowwndproc.c the function ValidateSizing calls
> winMultiWindowGetWMNormalHints and gets wrong values in
> sizeHints.width_inc and sizeHints.height_inc.
>
> In function winMultiWindowGetWMNormalHints in file
> hw/xwin/winmultiwindowclass.c you can see that a memcpy occurs from
> prop->data with sizeof(WinXSizeHints).
>
> As it turns out, everything is correct if you modify the typedef of
> WinXSizeHints in hw/xwin/winmultiwindowclass.h so that long type becomes
> int:
>
> --- a/cygwin/hw/xwin/winmultiwindowclass.h
> +++ b/cygwin/hw/xwin/winmultiwindowclass.h
> @@ -63,7 +63,7 @@ typedef struct {
>    * used with WM_NORMAL_HINTS.
>    */
>   typedef struct {
> -    long flags;                 /* marks which fields in this structure
> are defined */
> +    int flags;                 /* marks which fields in this structure
> are defined */
>       int x, y;                   /* obsolete for new window mgrs, but
> clients */
>       int width, height;          /* should set so old wm's don't mess
> up */

Thanks for pointing this out and the patch.

The same problem also occurs with WM_HINTS a few lines above.

> I can only guess why this works: in the X11 message protocol all int and
> long types are mapped to 32 bit integers. It seems that the memcpy in
> winMultiWindowGetWMNormalHints has source data that has memory layout as
> in the X11 message protocol.

Yes.  For historical reasons, 'long' is used for the CARD32 type in the 
libX11 API (which this structure has been copied from), but because that 
has a different size on x86 and x86_64, so libX11 marshalls that into a 
32-bit quantity before storing it into the window property.

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-19 21:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-19 12:22 problem evaluating window resize hints under 64 bit Oliver Schmidt
2014-06-19 21:44 ` Jon TURNEY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).