Xfixes xcb problem?

View: New views
5 Messages — Rating Filter:   Alert me  

Xfixes xcb problem?

by Michele Comignano-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm using some xfixes extension functions noticing a strange (and not correct)
behavior.  I was wondering about that so I docided to implement the same with
both xlib and xcb and compare. (the program creates a region with one
rectangle and prints the rectangles resulting after a fetchrectangles
request).

xcb version:
#include <xcb/xcb.h>
#include <xcb/xfixes.h>
#include <stdio.h>

int main(int argc, char **argv) {
    int i;
    xcb_rectangle_t *refresh_rects = NULL;
    xcb_xfixes_fetch_region_reply_t *reply;
    xcb_connection_t *c = xcb_connect(NULL, NULL);
    xcb_xfixes_query_version_reply(c, xcb_xfixes_query_version(c,
XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION), NULL);
    xcb_rectangle_t r = {10, 10, 500, 500};
    xcb_xfixes_region_t region = xcb_generate_id(c);
    xcb_xfixes_create_region(c, region, 1, &r);
    reply = xcb_xfixes_fetch_region_reply(c, xcb_xfixes_fetch_region(c,
region), NULL);
    refresh_rects = xcb_xfixes_fetch_region_rectangles(reply);
    for (i = 0; i < xcb_xfixes_fetch_region_rectangles_length(reply); i++) {
        printf("%d) x: %d, y: %d, width: %d, height: %d\n", i,
refresh_rects[i].x, refresh_rects[i].y, refresh_rects[i].width,
refresh_rects[i].height);
    }
}

output (unexpected second rectangle):
0) x: 10, y: 10, width: 500, height: 500
1) x: 0, y: 0, width: 48081, height: 1  // what is this??

xlib version:
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
int main(int argc, char **argv) {
    Display *dpy = XOpenDisplay(NULL);
    int xfixes_event, xfixes_error,nrects,i;
    XFixesQueryExtension(dpy, &xfixes_event, &xfixes_error);
    XRectangle rec = {10, 10, 500, 500};
    XserverRegion reg = XFixesCreateRegion(dpy, &rec, 1);
    XRectangle *rects = XFixesFetchRegion(dpy,reg,&nrects);
    for (i=0; i< nrects; i++){
         printf("%d) x: %d, y: %d, width: %d, height: %d\n", i,
                rects[i].x,
                rects[i].y,
                rects[i].width,
                rects[i].height);
    }
}

outputs (as expected):
0) x: 10, y: 10, width: 500, height: 500

Is my xcb code wrong or what else?

--
Michele Comignano (comick)
Jabber: comick@...
Web: http://comick.playlinux.net
_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb

Re: Xfixes xcb problem?

by Peter Harris-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michele Comignano wrote:
> I'm using some xfixes extension functions noticing a strange (and not correct)
> behavior.
...
> output (unexpected second rectangle):
> 0) x: 10, y: 10, width: 500, height: 500
> 1) x: 0, y: 0, width: 48081, height: 1  // what is this??

Looks like extra garbage. It appears as though the rectangle count
calculation is incorrect in xcb/proto/xfixes.xml

> Is my xcb code wrong or what else?

Could you please try the attached patch, and confirm that it fixes the
problem for you?

Thanks,
 Peter Harris
--
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris@...            Toll Free: 1 877 359 4866

From 7307e6c122b045bac08369273a0c1e922f18fd07 Mon Sep 17 00:00:00 2001
From: Peter Harris <pharris@...>
Date: Wed, 28 Oct 2009 16:05:26 -0400
Subject: [PATCH] Fix length calculation for xfixes/FetchRegion reply

Signed-off-by: Peter Harris <pharris@...>
---
 src/xfixes.xml |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/xfixes.xml b/src/xfixes.xml
index f6b0623..9bbeaab 100644
--- a/src/xfixes.xml
+++ b/src/xfixes.xml
@@ -229,7 +229,10 @@ authorization from the authors.
       <field type="RECTANGLE" name="extents" />
       <pad bytes="16" />
       <list  type="RECTANGLE" name="rectangles">
+ <op op='/'>
  <fieldref>length</fieldref>
+ <value>2</value>
+ </op>
       </list>
     </reply>
   </request>
--
1.6.5


_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb

Re: Xfixes xcb problem?

by Julien Cristau-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 28, 2009 at 16:13:18 -0400, Peter Harris wrote:

> From: Peter Harris <pharris@...>
> Date: Wed, 28 Oct 2009 16:05:26 -0400
> Subject: [PATCH] Fix length calculation for xfixes/FetchRegion reply
>
> Signed-off-by: Peter Harris <pharris@...>
> ---
>  src/xfixes.xml |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/src/xfixes.xml b/src/xfixes.xml
> index f6b0623..9bbeaab 100644
> --- a/src/xfixes.xml
> +++ b/src/xfixes.xml
> @@ -229,7 +229,10 @@ authorization from the authors.
>        <field type="RECTANGLE" name="extents" />
>        <pad bytes="16" />
>        <list  type="RECTANGLE" name="rectangles">
> + <op op='/'>
>   <fieldref>length</fieldref>
> + <value>2</value>
> + </op>
>        </list>
>      </reply>
>    </request>

Looks fine to me: a rectangle is 8 bytes, length is in 4 bytes units...

Also, that matches libXfixes, which does
    nrects = rep.length >> 1;

So FWIW,
Reviewed-by: Julien Cristau <jcristau@...>

Cheers,
Julien
_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb

Re: Xfixes xcb problem?

by Michele Comignano-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 28 October 2009 21:13:18 you wrote:
> Could you please try the attached patch, and confirm that it fixes the
> problem for you?

Done, it works for me.

>
> Thanks,
>  Peter Harris
>

Thanks.
Hope this helped.

--
Michele Comignano (comick)
Jabber: comick@...
Web: http://comick.playlinux.net
_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb

Re: Xfixes xcb problem?

by Peter Harris-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michele Comignano wrote:
> On Wednesday 28 October 2009 21:13:18 you wrote:
>> Could you please try the attached patch, and confirm that it fixes the
>> problem for you?
>
> Done, it works for me.

Thanks for testing, and thanks to Julien for the review.

Pushed.

Peter Harris
--
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris@...            Toll Free: 1 877 359 4866
_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb