summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2012-06-06 07:38:06 +0000
committerphintuka <phintuka>2012-06-06 07:38:06 +0000
commit0a20ab1cb679071ceaa42c20f6f046e510098152 (patch)
tree97168d6a8293b592bbfd4c1da4744d8d7501f468
parent1992faa3d3a1d5677381344a6eda8d924f3c86d1 (diff)
downloadxineliboutput-0a20ab1cb679071ceaa42c20f6f046e510098152.tar.gz
xineliboutput-0a20ab1cb679071ceaa42c20f6f046e510098152.tar.bz2
Change terminal state only when running on terminal
-rw-r--r--xine_frontend_kbd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/xine_frontend_kbd.c b/xine_frontend_kbd.c
index a20af17d..b107c5e8 100644
--- a/xine_frontend_kbd.c
+++ b/xine_frontend_kbd.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: xine_frontend_kbd.c,v 1.2 2011-11-13 09:51:44 phintuka Exp $
+ * $Id: xine_frontend_kbd.c,v 1.3 2012-06-06 07:38:06 phintuka Exp $
*
*/
@@ -154,11 +154,15 @@ static uint64_t read_key_seq(void)
static void kbd_receiver_thread_cleanup(void *arg)
{
- int status;
+ if (isatty(STDIN_FILENO)) {
tcsetattr(STDIN_FILENO, TCSANOW, &saved_tm);
+ }
+ if (isatty(STDOUT_FILENO)) {
+ int status;
status = system("setterm -cursor on");
if (status < 0)
LOGMSG("system(\"setterm -cursor on\") failed\n");
+ }
LOGMSG("Keyboard thread terminated");
}
@@ -167,15 +171,18 @@ static void *kbd_receiver_thread(void *fe_gen)
frontend_t *fe = (frontend_t*)fe_gen;
uint64_t code = 0;
char str[64];
- int status;
+ if (isatty(STDOUT_FILENO)) {
+ int status;
status = system("setterm -cursor off");
if (status < 0)
LOGMSG("system(\"setterm -cursor off\") failed\n");
status = system("setterm -blank off");
if (status < 0)
LOGMSG("system(\"setterm -blank off\") failed\n");
+ }
+ if (isatty(STDIN_FILENO)) {
/* Set stdin to deliver keypresses without buffering whole lines */
tcgetattr(STDIN_FILENO, &saved_tm);
if (tcgetattr(STDIN_FILENO, &tm) == 0) {
@@ -185,6 +192,7 @@ static void *kbd_receiver_thread(void *fe_gen)
tm.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &tm);
}
+ }
pthread_cleanup_push(kbd_receiver_thread_cleanup, NULL);