summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5fa6d11)
raw | patch | inline | side by side (parent: 5fa6d11)
author | Max Kellermann <max@duempel.org> | |
Fri, 19 Sep 2008 06:02:40 +0000 (08:02 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 19 Sep 2008 06:02:40 +0000 (08:02 +0200) |
When I replaced ncmpc's old main loop with g_main_loop from libglib,
SIGWINCH (i.e. window resizing) stopped working. This regression was
caused by the fact that ncurses' wgetch() function was only called
when there was actually data on STDIN. wgetch() has several side
effects besides reading data from STDIN, for example it checks whether
there has been a window resize.
Fix this with a custom SIGWINCH handler.
SIGWINCH (i.e. window resizing) stopped working. This regression was
caused by the fact that ncurses' wgetch() function was only called
when there was actually data on STDIN. wgetch() has several side
effects besides reading data from STDIN, for example it checks whether
there has been a window resize.
Fix this with a custom SIGWINCH handler.
src/main.c | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index c8b22df5fd6754422b14d999ccaccc537178ad08..6f662f53c76da970779a0908b504975623c9edca 100644 (file)
--- a/src/main.c
+++ b/src/main.c
kill(0, SIGSTOP); /* issue SIGSTOP */
}
+static guint timer_sigwinch_id;
+
+static gboolean
+timer_sigwinch(mpd_unused gpointer data)
+{
+ /* the following causes the screen to flicker. There might be
+ better solutions, but I believe it isn't all that
+ important. */
+
+ endwin();
+ refresh();
+ screen_resize();
+
+ return FALSE;
+}
+
+static void
+catch_sigwinch(mpd_unused int sig)
+{
+ if (timer_sigwinch_id != 0)
+ g_source_remove(timer_sigwinch_id);
+
+ timer_sigwinch_id = g_timeout_add(100, timer_sigwinch, NULL);
+}
+
#ifndef NDEBUG
void
D(const char *format, ...)
exit(EXIT_FAILURE);
}
+ /* setup SIGWINCH */
+
+ act.sa_handler = catch_sigwinch;
+ if (sigaction(SIGWINCH, &act, NULL) < 0) {
+ perror("sigaction(SIGWINCH)");
+ exit(EXIT_FAILURE);
+ }
+
ncurses_init();
lyrics_init();