bug-ncurses
[Top][All Lists]
Advanced

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

Re: windows move and subwindows coordinates


From: Pavel Stehule
Subject: Re: windows move and subwindows coordinates
Date: Wed, 26 Feb 2020 06:04:30 +0100



st 26. 2. 2020 v 3:16 odesílatel Thomas Dickey <address@hidden> napsal:
On Tue, Feb 25, 2020 at 01:50:04PM +0100, Pavel Stehule wrote:
> 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.

maybe - I don't know, will have to investigate.

It would help if the program built/ran with Solaris curses,
to use for comparison :-)

 https://github.com/okbob/pspg is possible to build on Solaris.



>  * 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?
>
> Original code
> https://github.com/okbob/ncurses-st-menu/blob/master/src/st_menu.c
>
> Regards
>
> Pavel

--
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]