[PATCH 06/21] [terminal] only support vt-like operations on VTs
Scott James Remnant
scott at ubuntu.com
Wed Mar 17 21:10:48 PDT 2010
Now we can simply test whether a terminal is virtual or not, add
a guard in the mode and vt change functions that ensure they only
operate on virtual terminals.
---
src/libply-splash-core/ply-terminal.c | 23 ++++++++++++++++++++++-
src/libply-splash-core/ply-text-display.c | 2 +-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c
index a4a9e76..b9d5a57 100644
--- a/src/libply-splash-core/ply-terminal.c
+++ b/src/libply-splash-core/ply-terminal.c
@@ -388,6 +388,9 @@ ply_terminal_watch_for_vt_changes (ply_terminal_t *terminal)
if (terminal->fd < 0)
return;
+ if (!ply_terminal_is_vt (terminal))
+ return;
+
if (terminal->is_watching_for_vt_changes)
return;
@@ -416,6 +419,9 @@ ply_terminal_stop_watching_for_vt_changes (ply_terminal_t *terminal)
{
struct vt_mode mode = { 0 };
+ if (!ply_terminal_is_vt (terminal))
+ return;
+
if (!terminal->is_watching_for_vt_changes)
return;
@@ -495,7 +501,10 @@ ply_terminal_open (ply_terminal_t *terminal)
ply_terminal_look_up_geometry,
terminal);
- ply_terminal_watch_for_vt_changes (terminal);
+ if (ply_terminal_is_vt (terminal))
+ {
+ ply_terminal_watch_for_vt_changes (terminal);
+ }
terminal->is_open = true;
@@ -616,6 +625,9 @@ ply_terminal_set_mode (ply_terminal_t *terminal,
assert (terminal != NULL);
assert (mode == PLY_TERMINAL_MODE_TEXT || mode == PLY_TERMINAL_MODE_GRAPHICS);
+ if (!ply_terminal_is_vt (terminal))
+ return;
+
if (terminal->should_ignore_mode_changes)
return;
@@ -637,6 +649,9 @@ void
ply_terminal_ignore_mode_changes (ply_terminal_t *terminal,
bool should_ignore)
{
+ if (!ply_terminal_is_vt (terminal))
+ return;
+
terminal->should_ignore_mode_changes = should_ignore;
}
@@ -737,6 +752,9 @@ ply_terminal_watch_for_active_vt_change (ply_terminal_t *terminal,
{
ply_terminal_active_vt_changed_closure_t *closure;
+ if (!ply_terminal_is_vt (terminal))
+ return;
+
closure = calloc (1, sizeof (*closure));
closure->handler = active_vt_changed_handler;
closure->user_data = user_data;
@@ -751,6 +769,9 @@ ply_terminal_stop_watching_for_active_vt_change (ply_terminal_t *terminal,
{
ply_list_node_t *node;
+ if (!ply_terminal_is_vt (terminal))
+ return;
+
node = ply_list_get_first_node (terminal->vt_change_closures);
while (node != NULL)
{
diff --git a/src/libply-splash-core/ply-text-display.c b/src/libply-splash-core/ply-text-display.c
index cdf78dc..69d652b 100644
--- a/src/libply-splash-core/ply-text-display.c
+++ b/src/libply-splash-core/ply-text-display.c
@@ -249,7 +249,7 @@ ply_text_display_write (ply_text_display_t *display,
vasprintf (&string, format, args);
va_end (args);
- if (ply_terminal_get_vt_number (display->terminal) > 0)
+ if (ply_terminal_is_vt (display->terminal))
ply_terminal_set_mode (display->terminal, PLY_TERMINAL_MODE_TEXT);
write (fd, string, strlen (string));
free (string);
--
1.7.0
More information about the plymouth
mailing list