Hi
in ncurses_st_menu I have to use one ugly hack. I would to know if it is known bug or not.
I use a windows (panels) and subwindow. Sometimes I had to detect if mouse was pressed inside subwindow. I use a function wenclose(subwindow, y, x). But for this function I have to do correction of y, x when parent windows (of subwindow) was moved.
my code:
add_correction(menu->draw_area, &y, &x);
if (wenclose(menu->draw_area, y, x)) { ... }
/*
* The coordinates of subwin are not "correctly" refreshed, when
* parent panel is moved. Maybe it is bug in ncurses, maybe not.
* The new coordinates are calculated from parent and offset to parent
* and difference between new and old coordinates is applyed on
* x, y points.
*/
static void
add_correction(WINDOW *s, int *y, int *x)
{
WINDOW *p = wgetparent(s);
/*
* Note: function is_subwin is unknown on some
* older ncurses implementations. Don't use it.
*/
if (p)
{
int py, px, sy, sx, oy, ox;
int fix_y, fix_x;
getbegyx(p, py, px);
getbegyx(s, sy, sx);
getparyx(s, oy, ox);
fix_y = sy - (py + oy);
fix_x = sx - (px + ox);
*y += fix_y;
*x += fix_x;
}
}
This code looks very strange, but it is working, across all used ncurses libraries.
Is it known behave?
Regards
Pavel