fixed gwinDestroy() and added gwinGetAbsoluteCoordinates()
This commit is contained in:
parent
463a703183
commit
9f5d14cf5d
@ -336,6 +336,17 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
bool_t gwinGetEnabled(GHandle gh);
|
bool_t gwinGetEnabled(GHandle gh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get absolute coordinates of a window
|
||||||
|
*
|
||||||
|
* @param[in] gh The window
|
||||||
|
* @param[out] x The absolut x coordinate
|
||||||
|
* @param[out] y The absolut y coordinate
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
void gwinGetAbsoluteCoordinates(GHandle gh, coord_t *x, coord_t *y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Move a window
|
* @brief Move a window
|
||||||
*
|
*
|
||||||
|
@ -181,11 +181,16 @@ GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pI
|
|||||||
|
|
||||||
void gwinDestroy(GHandle gh) {
|
void gwinDestroy(GHandle gh) {
|
||||||
#if GWIN_NEED_HIERARCHY
|
#if GWIN_NEED_HIERARCHY
|
||||||
// kill your children as long as you have any
|
// fix hierarchy structure
|
||||||
while (gh->child) {
|
if (gh->parent->child == gh) {
|
||||||
GHandle tmp = gh->child;
|
// we are the first child
|
||||||
gh->child = gh->child->sibling;
|
gh->parent->child = gh->sibling;
|
||||||
gwinDestroy(tmp);
|
} else {
|
||||||
|
// find our predecessor
|
||||||
|
GHandle tmp = gh->parent->child;
|
||||||
|
while (tmp->sibling != gh)
|
||||||
|
tmp = tmp->sibling;
|
||||||
|
tmp->sibling = gh->sibling;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -269,6 +274,22 @@ bool_t gwinGetEnabled(GHandle gh) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gwinGetAbsoluteCoordinates(GHandle gh, coord_t *x, coord_t *y) {
|
||||||
|
#if GWIN_NEED_HIERARCHY
|
||||||
|
GHandle tmp;
|
||||||
|
|
||||||
|
// sum up all relative coordinates up to the root parent
|
||||||
|
for (*x = 0, *y = 0, tmp = gh; tmp; tmp = tmp->parent) {
|
||||||
|
*x += tmp->x;
|
||||||
|
*y += tmp->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
*x = gh->x;
|
||||||
|
*y = gh->y;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void gwinMove(GHandle gh, coord_t x, coord_t y) {
|
void gwinMove(GHandle gh, coord_t x, coord_t y) {
|
||||||
_gwm_redim(gh, x, y, gh->width, gh->height);
|
_gwm_redim(gh, x, y, gh->width, gh->height);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user