Bug in GtkEventBox / mouse-motion-event?



I think I have found a GTK+ bug, but wanted to tell you guys before
going to bugzilla, because perhaps it is just me doing something stupid.

I wrote the following code to demonstrate it: http://pastebin.ca/337410

What this code does, essentially, is 
  * Create a window, with 20 pixels of border width
  * Put an event box inside the window
  * Put a 300x200 px GtkImage inside the eventbox
  * Enable GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK for
the event box
  * attach event handlers to button_press_event, button-release-event
and motion-notify-event, all of them essentially showing the coordinates
of the GdkEvent. The handler for motion also shows the output of
gdk_window_get_pointer applied to the event box window (to keep getting
hinted motions).

I expected this code to show every coordinate relative to the
GtkEventBox (which is in position (20,20) relative to the toplevel). If
I made a mistake, I would expect to get some coordinate relative to the
toplevel. But somehow I am getting events relative to the point (40,40)
in the window. I can't image which window is at that position
(considering that the GtkImage does not have a window, and the 2 windows
of the eventbox should be at 20,20). So my guess is that at someplace
relative coordinates are being messed up, summed twice, or something
like that (note that if you change the set_border_width value, the
offsets move accordingly).

To see my point, run the app, and try the following experiments:

1) Starting in the top left corner, make clicks, progressively and
slowly moving the mouse towards the opposite corner between each click.
I would expect values going slowly from 0,0 to 300,200. Instead, I get
outputs like:

        release @ (0.0, 1.0)
        press @ (0.0, 1.0)
        release @ (3.0, 6.0)
        press @ (3.0, 6.0)
        release @ (7.0, 7.0)
        press @ (7.0, 7.0)
        release @ (10.0, 9.0)
        press @ (10.0, 9.0)
        release @ (12.0, 12.0)
        press @ (12.0, 12.0)
        release @ (15.0, 15.0)
        press @ (15.0, 15.0)
        release @ (18.0, 19.0)
        press @ (18.0, 19.0)
        release @ (1.0, 2.0)
        press @ (1.0, 2.0)
        release @ (7.0, 6.0)
        press @ (7.0, 6.0)
        
Note that near 20,20 values wrap around to 0,0. When I reach the bottom
right corner I get values about (280,180) instead of about (300,200).

2) Drag the mouse from the top left towards the bottom right. In that
case, values printed by the motion handler are the same for event->x,y
and gdk_window_get_pointer (the two pairs of coordinates printed). They
move from about 0,0 to about 300,200.

3) Now drag the mouse from the bottom right to the top left. Now, the
coordinates in the GdkEvent move from 280,180 to -20,-20 in the top left
of the event box. OTOH, the values printed by get_pointer change (as I
expect) from 300,200 to 0,0.

Is this a bug, or am I missing something?

Regards, and thanks for your time,

	Daniel





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]