stacked windows with ncurses

stacked windows with ncurses

Post by Roger Leig » Wed, 18 Jun 2003 06:57:58



I'm starting to learn ncurses, but I'm a little confused by this
behaviour: When I run the following program, a WINDOW is created and
displayed over the top of some text on stdscr, but if I redisplay
stdscr, nothing changes (which I expected).  If I use
touchwin(stdscr), not all of the window is redrawn (the first and last
line of the WINDOW win are left).  I have to use redrawwin()
instead.

I thought that touchwin() would force a redraw of the entire window
when I call wrefresh()?  How does redrawwin() differ from touchwin()?

Also, the cur_window manpage (ncurses 5.2) says that subwin()
et. al. are buggy and should not be used.  However, the ncurses-intro
document says to use them for some purposes.  Which is correct?

Thanks,
Roger

#include <curses.h>
#include <unistd.h>

int
main(void)
{
  int x, y; /* Screen size */
  WINDOW *win;
  initscr();
  cbreak();
  noecho();
  nonl();
  intrflush(stdscr, FALSE);
  keypad(stdscr, TRUE);
  getmaxyx(stdscr, y, x);
  box(stdscr, 0, 0);
  mvwprintw(stdscr, 1, 1, "Simple NCURSES window test program");
  mvwhline(stdscr, 2, 1, 0, x-2);
  mvwaddch(stdscr, 2, 0, ACS_LTEE);
  mvwaddch(stdscr, 2, x-1, ACS_RTEE);
  mvwprintw(stdscr, 11, 11, "Testing...");
  wrefresh(stdscr);
  sleep(1);
  win = newwin(15, 20, 8, 8);
  box(win, 0, 0);
  mvwprintw(win, 1, 1, "Window");
  wrefresh(win);
  sleep (1);
  /*redrawwin(stdscr);*/
  /*touchwin(stdscr);*/
  wrefresh(stdscr);
  sleep (1);
  endwin();
  return 0;

Quote:}

--
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848 available on public keyservers

 
 
 

stacked windows with ncurses

Post by Thomas Dicke » Wed, 18 Jun 2003 10:14:53



> I'm starting to learn ncurses, but I'm a little confused by this
> behaviour: When I run the following program, a WINDOW is created and
> displayed over the top of some text on stdscr, but if I redisplay
> stdscr, nothing changes (which I expected).  If I use
> touchwin(stdscr), not all of the window is redrawn (the first and last
> line of the WINDOW win are left).  I have to use redrawwin()
> instead.
> I thought that touchwin() would force a redraw of the entire window
> when I call wrefresh()?  How does redrawwin() differ from touchwin()?

touchwin() marks every location on the window as changed,
redrawwin() does that, plus discarding the scrolling optimization.

That's from reading the code - sometimes it's simpler to do that than
fuss over terminology in the manpage.

I don't use the latter much.  One thing that I'd change in the example
is to use napms() rather than sleep().  The latter blocks I/O, so you
can get odd effects from it.

Quote:> Also, the cur_window manpage (ncurses 5.2) says that subwin()
> et. al. are buggy and should not be used.  However, the ncurses-intro
> document says to use them for some purposes.  Which is correct?

not exactly - the comment relates to the stacking order (the person who
wrote that comment is the type of person who finds it simpler to write
comments than test code ;-).  Sometime I'll remove the comment...

Quote:> Thanks,
> Roger
> #include <curses.h>
> #include <unistd.h>
> int
> main(void)
> {
>   int x, y; /* Screen size */
>   WINDOW *win;
>   initscr();
>   cbreak();
>   noecho();
>   nonl();
>   intrflush(stdscr, FALSE);
>   keypad(stdscr, TRUE);
>   getmaxyx(stdscr, y, x);
>   box(stdscr, 0, 0);
>   mvwprintw(stdscr, 1, 1, "Simple NCURSES window test program");
>   mvwhline(stdscr, 2, 1, 0, x-2);
>   mvwaddch(stdscr, 2, 0, ACS_LTEE);
>   mvwaddch(stdscr, 2, x-1, ACS_RTEE);
>   mvwprintw(stdscr, 11, 11, "Testing...");
>   wrefresh(stdscr);
>   sleep(1);
>   win = newwin(15, 20, 8, 8);
>   box(win, 0, 0);
>   mvwprintw(win, 1, 1, "Window");
>   wrefresh(win);
>   sleep (1);
>   /*redrawwin(stdscr);*/
>   /*touchwin(stdscr);*/
>   wrefresh(stdscr);
>   sleep (1);
>   endwin();
>   return 0;
> }
> --
> Roger Leigh
>                 Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
>                 GPG Public Key: 0x25BFB848 available on public keyservers

--

http://dickey.his.com
ftp://dickey.his.com

 
 
 

1. window manager focus and window stack

I really, really need some help on this so even if you can't help would
you please point me to someone might or another more appropriate list to
post to.  TIA

I'm writing a non-kde application that I would like it to stay on the
bottom of the window stack.  I also need to have KWM set up as "click to
focus" as well as have the application NOT act sticky(should display
ONLY on it's desigated desktop).  I need to program my app so that when
you click on it, it will not overlap the other windows on the desktop.
Presently, if you right-click on it, it acts as desired but I need to
have it act the same on left click.

So far I've tried the following:
1) set the override-redirect -- this causes to the app to stick on every
desktop  :-(
2) capture focus_in event and call XLowerWindow() -- the app will
momentarily be on top of the stack after the click and THEN the focus-in
event gets called and the app is moved to the bottom of the window
stack.  The other apps flicker momentarily :-(
3) set the noFocusTitles and noFocusClasses in the [Focus] section of
the kwmrc. -- this prevents the app from getting the focus but does NOT
prevent it from moving to the top of the window stack and overlapping
the other windows.  :-(

I've traced the sequence of events (using xev) during both right-click
and left-click and they're identical.  There are no exposure events
being generated during these types of clicks so something else is
painting (backingstore?) the app.

Thanks
Ed Centanni

Sent via Deja.com http://www.deja.com/
Before you buy.

2. perms & mounts for file transfer between linux partitions?

3. HELP: How to Circulate Window Stacking Order in X Windows/KDE

4. TIP available for linux/posix?

5. Ncurses.4 s ncurse.5

6. iptunnel

7. ncurses window clear

8. per file based authentication

9. Problems with windows in ncurses

10. 4KB stack + irq stack for x86

11. Packets from bottom of TCP/IP stack direct to application bypassing stack

12. 4KB stack + irq stack for x86

13. graphics.h in Linux? ncurses on DOS/WINDOWS?