After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 85229 - rewrite_events_translate caculates (x,y) in a wrong way
rewrite_events_translate caculates (x,y) in a wrong way
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.0.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2002-06-14 04:18 UTC by Robin Lu
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (591 bytes, patch)
2002-06-14 04:19 UTC, Robin Lu
none Details | Review

Description Robin Lu 2002-06-14 04:18:34 UTC
This is the rewrite_event_translate in gtkmain.c:
rewrite_events_translate (GdkWindow *old_window,
			  GdkWindow *new_window,
			  gdouble   *x,
			  gdouble   *y)
{
  gint old_origin_x, old_origin_y;
  gint new_origin_x, new_origin_y;

  gdk_window_get_origin	(old_window, &old_origin_x, &old_origin_y);
  gdk_window_get_origin	(new_window, &new_origin_x, &new_origin_y);

 
  *x += new_origin_x - old_origin_x;
  *y += new_origin_y - old_origin_y;
}

As I understand, this will translate the (x,y) relative to old window to
(x,y) relative to new window.
Firstly, we can caculate the (x,y) relative to the origin point by:
*x += old_origin_x;
*y += old_origin_y;
Then, we can caculate the (x,y) relative to the new window by:
*x -= new_origin_x;
*y -= new_origin_y;
So, we should have:
  *x -= new_origin_x - old_origin_x;
  *y -= new_origin_y - old_origin_y;

You can reproduce the error by:
1. create two GtkWindow (window A and B)in the same application and add
them to diffrent GtkWindowGroups.
2. gdk_pointer_grab one of the GtkWindow (window A), with owner_even=TRUE
and mask=GDK_POINTER_MOTION_MASK.
3. print out the event->x and event->y or log them to a file when the
motion_notify_event is triggered.
4. run the application. move mouse pointer to window B (which is not grabed
and is not in the same group as A).

result we expect: the value of event->x and event->y which are relative to
window A is right.
in fact we got: wrong (x,y).
Comment 1 Robin Lu 2002-06-14 04:19:54 UTC
Created attachment 9217 [details] [review]
patch
Comment 2 Jay Yan 2002-06-14 06:50:58 UTC
Erwann,
when are porting mozilla to gtk2, we found a mozilla bug 
http://bugzilla.mozilla.org/show_bug.cgi?id=140867 is probably casued
by this bug.
or perhaps this bug is invalid? can you help to take a look at this
bug? thanks. and I will add you to the cclist of that mozilla bug.
Jay
Comment 3 Owen Taylor 2002-06-14 14:17:48 UTC
Fixed in CVS, will be in 2.0.4.

Fri Jun 14 10:00:29 2002  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkmain.c (rewrite_events_translate): Fix sign
	problem with coordinate translation. (Fix from
	Robin Lu, #85229)