forked from AuroraMiddleware/gtk
surface: Add coordinate translation
We maintain offsets for popups, so we can translate coordinates between surfaces that are attached directly or indirectly to the same toplevel. Add an api for that.
This commit is contained in:
parent
5675d585f4
commit
902a49af9d
@ -4076,3 +4076,41 @@ gdk_surface_handle_event (GdkEvent *event)
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_surface_translate_coordinates (GdkSurface *from,
|
||||
GdkSurface *to,
|
||||
double *x,
|
||||
double *y)
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
GdkSurface *f, *t;
|
||||
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
f = from;
|
||||
while (f->parent)
|
||||
{
|
||||
x1 += f->x;
|
||||
y1 += f->y;
|
||||
f = f->parent;
|
||||
}
|
||||
|
||||
x2 = 0;
|
||||
y2 = 0;
|
||||
t = to;
|
||||
while (t->parent)
|
||||
{
|
||||
x2 += t->x;
|
||||
y2 += t->y;
|
||||
t = t->parent;
|
||||
}
|
||||
|
||||
if (f != t)
|
||||
return FALSE;
|
||||
|
||||
*x += x1 - x2;
|
||||
*y += y1 - y2;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -557,6 +557,12 @@ gint gdk_surface_get_origin (GdkSurface *surface,
|
||||
gint *x,
|
||||
gint *y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_surface_translate_coordinates (GdkSurface *from,
|
||||
GdkSurface *to,
|
||||
double *x,
|
||||
double *y);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_get_frame_extents (GdkSurface *surface,
|
||||
GdkRectangle *rect);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user