fix screen resize
ncmpcpp was sometimes segfaulting while resizing screen, this commit fixes that.
This commit is contained in:
@@ -92,17 +92,12 @@ namespace
|
|||||||
std::streambuf *cerr_buffer;
|
std::streambuf *cerr_buffer;
|
||||||
|
|
||||||
bool design_changed = 0;
|
bool design_changed = 0;
|
||||||
|
bool order_resize = 0;
|
||||||
size_t header_height, footer_start_y, footer_height;
|
size_t header_height, footer_start_y, footer_height;
|
||||||
|
|
||||||
void sighandler(GNUC_UNUSED int signal)
|
void resize_screen()
|
||||||
{
|
{
|
||||||
# if !defined(WIN32)
|
order_resize = 0;
|
||||||
if (signal == SIGPIPE)
|
|
||||||
{
|
|
||||||
ShowMessage("Broken pipe signal caught!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
# endif // !WIN32
|
|
||||||
|
|
||||||
# if defined(USE_PDCURSES)
|
# if defined(USE_PDCURSES)
|
||||||
resize_term(0, 0);
|
resize_term(0, 0);
|
||||||
@@ -114,7 +109,11 @@ namespace
|
|||||||
refresh();
|
refresh();
|
||||||
// get rid of KEY_RESIZE as it sometimes
|
// get rid of KEY_RESIZE as it sometimes
|
||||||
// corrupts our new cool ReadKey() function
|
// corrupts our new cool ReadKey() function
|
||||||
|
// because KEY_RESIZE doesn't come from stdin
|
||||||
|
// and thus select cannot detect it
|
||||||
|
timeout(10);
|
||||||
getch();
|
getch();
|
||||||
|
timeout(-1);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -193,6 +192,20 @@ namespace
|
|||||||
wFooter->Refresh();
|
wFooter->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if !defined(WIN32)
|
||||||
|
void sighandler(int signal)
|
||||||
|
{
|
||||||
|
if (signal == SIGPIPE)
|
||||||
|
{
|
||||||
|
ShowMessage("Broken pipe signal caught!");
|
||||||
|
}
|
||||||
|
else if (signal == SIGWINCH)
|
||||||
|
{
|
||||||
|
order_resize = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif // !WIN32
|
||||||
|
|
||||||
void do_at_exit()
|
void do_at_exit()
|
||||||
{
|
{
|
||||||
// restore old cerr buffer
|
// restore old cerr buffer
|
||||||
@@ -323,6 +336,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
MessagesAllowed = 1;
|
MessagesAllowed = 1;
|
||||||
|
|
||||||
|
if (order_resize)
|
||||||
|
resize_screen();
|
||||||
|
|
||||||
// header stuff
|
// header stuff
|
||||||
if (((Timer.tv_sec == past.tv_sec && Timer.tv_usec >= past.tv_usec+500000) || Timer.tv_sec > past.tv_sec)
|
if (((Timer.tv_sec == past.tv_sec && Timer.tv_usec >= past.tv_usec+500000) || Timer.tv_sec > past.tv_sec)
|
||||||
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
|
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
|
||||||
@@ -511,11 +527,7 @@ int main(int argc, char *argv[])
|
|||||||
UnlockProgressbar();
|
UnlockProgressbar();
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
design_changed = 1;
|
design_changed = 1;
|
||||||
# if !defined(WIN32)
|
resize_screen();
|
||||||
sighandler(SIGWINCH);
|
|
||||||
# else
|
|
||||||
sighandler(0);
|
|
||||||
# endif // !WIN23
|
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.GoToParentDir))
|
else if (Keypressed(input, Key.GoToParentDir))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user