mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-29 03:32:42 +00:00
Added SIGHUP handling in non-win32 platforms that will shut down musikbox if the controlling terminal is closed.
This commit is contained in:
parent
9c9666da9d
commit
8c82089c59
@ -62,6 +62,10 @@
|
|||||||
#include <boost/chrono.hpp>
|
#include <boost/chrono.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <csignal>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#undef MOUSE_MOVED
|
#undef MOUSE_MOVED
|
||||||
#endif
|
#endif
|
||||||
@ -80,6 +84,8 @@ using namespace musik::box;
|
|||||||
using namespace cursespp;
|
using namespace cursespp;
|
||||||
using namespace boost::chrono;
|
using namespace boost::chrono;
|
||||||
|
|
||||||
|
static bool disconnected = false;
|
||||||
|
|
||||||
struct WindowState {
|
struct WindowState {
|
||||||
ILayoutPtr layout;
|
ILayoutPtr layout;
|
||||||
IWindowPtr focused;
|
IWindowPtr focused;
|
||||||
@ -202,6 +208,12 @@ static inline int64 now() {
|
|||||||
system_clock::now().time_since_epoch()).count();
|
system_clock::now().time_since_epoch()).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
static void hangupHandler(int signal) {
|
||||||
|
disconnected = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int _main(int argc, _TCHAR* argv[]);
|
int _main(int argc, _TCHAR* argv[]);
|
||||||
|
|
||||||
@ -246,6 +258,10 @@ int main(int argc, char* argv[])
|
|||||||
refresh();
|
refresh();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
std::signal(SIGHUP, hangupHandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
Colors::Init();
|
Colors::Init();
|
||||||
|
|
||||||
@ -271,7 +287,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
changeLayout(state, libraryLayout);
|
changeLayout(state, libraryLayout);
|
||||||
|
|
||||||
while (!quit) {
|
while (!quit && !disconnected) {
|
||||||
/* if the focused item is an IInput, then get characters from it,
|
/* if the focused item is an IInput, then get characters from it,
|
||||||
so it can draw a pretty cursor if it wants */
|
so it can draw a pretty cursor if it wants */
|
||||||
if (state.input) {
|
if (state.input) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user