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: Bryan Christ
Subject: Re: windows move and subwindows coordinates
Date: Tue, 25 Feb 2020 21:35:07 -0600

Pavel,

I believe I encountered this problem years ago and you have to adjust the coords yourself.  It's not just an issue with panels, but if you move a window, the subwin coords are not updated.  In one of my libraries I do something like this:

retval = mvwin(vwnd->window_frame, y, x);
                                                                               
/* this is a hack until mvwin is fixed */
if((vwnd->ctx->managed == TRUE) && retval != ERR)
{
    getbegyx(vwnd->window_frame, y, x);
    vwnd->user_window->_begy = y + vwnd->user_window->_pary;
    vwnd->user_window->_begx = x + vwnd->user_window->_parx;
}
/* end of hack */


Thomas,

I'm pretty sure you have an exchange with me years ago about this in your mail archives.  Pretty much just decided to live with this behavior.



On Tue, Feb 25, 2020 at 8:17 PM Thomas Dickey <address@hidden> wrote:
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 :-)

>  * 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


--
Bryan
<><

reply via email to

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