[Xcb] Problem with dock windows and libxcb-icccm
David Coppa
dcoppa at gmail.com
Wed Mar 10 12:06:31 PST 2010
On Wed, 10 Mar 2010, Peter Harris wrote:
> On 2010-03-10 08:18, David Coppa wrote:
> >
> > What about this patch?
>
> Looks sensible. Could you please include a Signed-off-by in the next
> version? Thanks.
>
> > if (!(reply->type == XCB_ATOM_WM_SIZE_HINTS &&
> > (reply->format == 8 || reply->format == 16 ||
> > - reply->format == 32) &&
> > - /* OldNumPropSizeElements = 15 (pre-ICCCM) */
> > - length >= 15))
> > + reply->format == 32)))
>
> You could even remove the line "(reply->format == 8 || reply->format ==
> 16 ||" too, since the size hints must be 32 bit to make sense.
>
> Other formats might appear to work if you're not in a mixed-endian
> environment, but it's safer to just ignore hints with the wrong
> ->format. Also, the (length >= 15) test is wrong if ->format isn't 32.
Hi Peter,
I've merged your patch at
http://archive.netbsd.se/view_attachment.php?id=12115870.183264
with mine.
Is it ok now?
Cheers,
David
Signed-off-by: David Coppa <dcoppa at gmail.com>
---
icccm/icccm.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/icccm/icccm.c b/icccm/icccm.c
index 0206e4b..b07c2ea 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -440,21 +440,22 @@ uint8_t
xcb_get_wm_size_hints_from_reply(xcb_size_hints_t *hints, xcb_get_property_reply_t *reply)
{
uint32_t flags;
+ int length;
if(!reply)
return 0;
- int length = xcb_get_property_value_length(reply) / (reply->format / 8);
-
if (!(reply->type == XCB_ATOM_WM_SIZE_HINTS &&
- (reply->format == 8 || reply->format == 16 ||
- reply->format == 32) &&
- /* OldNumPropSizeElements = 15 (pre-ICCCM) */
- length >= 15))
+ reply->format == 32))
return 0;
+ length = xcb_get_property_value_length(reply) / (reply->format / 8);
+
+ if (length > 18)
+ length = 18;
+
memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value (reply),
- length * reply->format >> 3);
+ length * (reply->format / 8));
flags = (XCB_SIZE_HINT_US_POSITION | XCB_SIZE_HINT_US_SIZE |
XCB_SIZE_HINT_P_POSITION | XCB_SIZE_HINT_P_SIZE |
@@ -462,7 +463,7 @@ xcb_get_wm_size_hints_from_reply(xcb_size_hints_t *hints, xcb_get_property_reply
XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_P_ASPECT);
/* NumPropSizeElements = 18 (ICCCM version 1) */
- if(length >= 18)
+ if(length == 18)
flags |= (XCB_SIZE_HINT_BASE_SIZE | XCB_SIZE_HINT_P_WIN_GRAVITY);
else
{
@@ -644,6 +645,9 @@ xcb_get_wm_hints_from_reply(xcb_wm_hints_t *hints,
if(num_elem < XCB_NUM_WM_HINTS_ELEMENTS - 1)
return 0;
+ if (length > sizeof(xcb_size_hints_t))
+ length = sizeof(xcb_size_hints_t);
+
memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value(reply), length);
if(num_elem < XCB_NUM_WM_HINTS_ELEMENTS)
---
More information about the Xcb
mailing list