mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
noux: respond to terminal-size changes
This commit is contained in:
parent
8aa1e349fc
commit
a22b0c3ac6
@ -39,8 +39,9 @@ struct Noux::Sysio
|
||||
{
|
||||
/* signal numbers must match with libc signal numbers */
|
||||
enum Signal {
|
||||
SIG_INT = 2,
|
||||
SIG_CHLD = 20,
|
||||
SIG_INT = 2,
|
||||
SIG_CHLD = 20,
|
||||
SIG_WINCH = 28
|
||||
};
|
||||
|
||||
enum { SIGNAL_QUEUE_SIZE = 32 };
|
||||
|
@ -210,6 +210,7 @@ static bool noux_syscall(Noux::Session::Syscall opcode)
|
||||
if (signal_action[signal].sa_handler == SIG_DFL) {
|
||||
switch (signal) {
|
||||
case SIGCHLD:
|
||||
case SIGWINCH:
|
||||
/* ignore */
|
||||
break;
|
||||
default:
|
||||
|
@ -568,13 +568,14 @@ class Noux::Child : public Rpc_object<Session>,
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
/*********************************
|
||||
** Interrupt_handler interface **
|
||||
*********************************/
|
||||
|
||||
void handle_interrupt()
|
||||
void handle_interrupt(Sysio::Signal signal)
|
||||
{
|
||||
submit_signal(Sysio::SIG_INT);
|
||||
submit_signal(signal);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -14,11 +14,13 @@
|
||||
#ifndef _NOUX__INTERRUPT_HANDLER__H_
|
||||
#define _NOUX__INTERRUPT_HANDLER__H_
|
||||
|
||||
#include <noux_session/sysio.h>
|
||||
|
||||
namespace Noux {
|
||||
|
||||
struct Interrupt_handler
|
||||
{
|
||||
virtual void handle_interrupt() = 0;
|
||||
virtual void handle_interrupt(Sysio::Signal) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -177,14 +177,14 @@ class Noux::Io_channel : public Reference_counter
|
||||
/**
|
||||
* Tell all registered handlers about an interrupt event
|
||||
*/
|
||||
void invoke_all_interrupt_handlers()
|
||||
void invoke_all_interrupt_handlers(Sysio::Signal signal)
|
||||
{
|
||||
Lock::Guard signal_lock_guard(signal_lock());
|
||||
Lock::Guard guard(_interrupt_handlers_lock);
|
||||
|
||||
for (Io_channel_listener *l = _interrupt_handlers.first();
|
||||
l; l = l->next())
|
||||
l->object()->handle_interrupt();
|
||||
l->object()->handle_interrupt(signal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,8 @@ struct Noux::Terminal_io_channel : Io_channel
|
||||
|
||||
Signal_handler<Terminal_io_channel> _read_avail_handler;
|
||||
|
||||
Signal_handler<Terminal_io_channel> _resize_handler;
|
||||
|
||||
bool eof = false;
|
||||
|
||||
enum Type { STDIN, STDOUT, STDERR } type;
|
||||
@ -44,6 +46,7 @@ struct Noux::Terminal_io_channel : Io_channel
|
||||
:
|
||||
_terminal(terminal),
|
||||
_read_avail_handler(ep, *this, &Terminal_io_channel::_handle_read_avail),
|
||||
_resize_handler (ep, *this, &Terminal_io_channel::_handle_resize),
|
||||
type(type)
|
||||
{
|
||||
/*
|
||||
@ -59,6 +62,7 @@ struct Noux::Terminal_io_channel : Io_channel
|
||||
*/
|
||||
if (type == STDIN) {
|
||||
terminal.read_avail_sigh(_read_avail_handler);
|
||||
terminal.size_changed_sigh(_resize_handler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +215,7 @@ struct Noux::Terminal_io_channel : Io_channel
|
||||
enum { INTERRUPT = 3 };
|
||||
|
||||
if (c == INTERRUPT) {
|
||||
Io_channel::invoke_all_interrupt_handlers();
|
||||
Io_channel::invoke_all_interrupt_handlers(Sysio::SIG_INT);
|
||||
} else {
|
||||
read_buffer.add(c);
|
||||
}
|
||||
@ -219,6 +223,11 @@ struct Noux::Terminal_io_channel : Io_channel
|
||||
|
||||
Io_channel::invoke_all_notifiers();
|
||||
}
|
||||
|
||||
void _handle_resize()
|
||||
{
|
||||
Io_channel::invoke_all_interrupt_handlers(Sysio::SIG_WINCH);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _NOUX__TERMINAL_IO_CHANNEL_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user