Send plymouth mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.freedesktop.org/mailman/listinfo/plymouth
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of plymouth digest..."
Today's Topics:
1. [PATCH 17/21] [frame-buffer] default renderer to inactive
(Scott James Remnant)
2. [PATCH 04/21] [terminal] replace set_active_vt with
activate_vt (Scott James Remnant)
3. [PATCH 00/21] Improve VT Handling (Scott James Remnant)
4. [PATCH 21/21] [configure] allow boot and shutdown ttys to be
changed (Scott James Remnant)
5. [PATCH 20/21] [main] add --tty command-line option
(Scott James Remnant)
6. [PATCH 01/21] [terminal] merge console and terminal code
(Scott James Remnant)
----------------------------------------------------------------------
Message: 1
Date: Thu, 18 Mar 2010 05:03:53 +0000
From: Scott James Remnant <[email protected]>
Subject: [PATCH 17/21] [frame-buffer] default renderer to inactive
To: [email protected]
Message-ID:
<7939ad861638e122950b6f03264cff0881c1267e.1268889867.git.sc...@ubuntu.com>
Change the renderer so that it defaults to inactive, then when we
map to the device, activate the renderer by activating the VT;
unless the VT is already active in which case activate the
renderer directly.
---
src/plugins/renderers/drm/plugin.c | 4 ++--
src/plugins/renderers/frame-buffer/plugin.c | 13 ++++++++-----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/plugins/renderers/drm/plugin.c
b/src/plugins/renderers/drm/plugin.c
index 75c3927..7bd181a 100644
--- a/src/plugins/renderers/drm/plugin.c
+++ b/src/plugins/renderers/drm/plugin.c
@@ -820,9 +820,9 @@ map_to_device (ply_renderer_backend_t *backend)
}
if (ply_terminal_is_active (backend->terminal))
- activate (backend);
+ activate (backend);
else
- ply_terminal_activate_vt (backend->terminal);
+ ply_terminal_activate_vt (backend->terminal);
return head_mapped;
}
diff --git a/src/plugins/renderers/frame-buffer/plugin.c
b/src/plugins/renderers/frame-buffer/plugin.c
index 570b21a..d9f193b 100644
--- a/src/plugins/renderers/frame-buffer/plugin.c
+++ b/src/plugins/renderers/frame-buffer/plugin.c
@@ -108,7 +108,7 @@ struct _ply_renderer_backend
unsigned int bytes_per_pixel;
unsigned int row_stride;
- uint32_t is_inactive : 1;
+ uint32_t is_active : 1;
void (* flush_area) (ply_renderer_backend_t *backend,
ply_renderer_head_t *head,
@@ -305,7 +305,7 @@ destroy_backend (ply_renderer_backend_t *backend)
static void
activate (ply_renderer_backend_t *backend)
{
- backend->is_inactive = false;
+ backend->is_active = true;
if (backend->head.map_address != MAP_FAILED)
ply_renderer_head_redraw (backend, &backend->head);
@@ -314,7 +314,7 @@ activate (ply_renderer_backend_t *backend)
static void
deactivate (ply_renderer_backend_t *backend)
{
- backend->is_inactive = true;
+ backend->is_active = false;
}
static void
@@ -527,7 +527,10 @@ map_to_device (ply_renderer_backend_t *backend)
if (head->map_address == MAP_FAILED)
return false;
- ply_terminal_activate_vt (backend->terminal);
+ if (ply_terminal_is_active (backend->terminal))
+ activate (backend);
+ else
+ ply_terminal_activate_vt (backend->terminal);
return true;
}
@@ -558,7 +561,7 @@ flush_head (ply_renderer_backend_t *backend,
assert (backend != NULL);
assert (&backend->head == head);
- if (backend->is_inactive)
+ if (!backend->is_active)
return;
ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
--
1.7.0
------------------------------
Message: 2
Date: Thu, 18 Mar 2010 03:59:18 +0000
From: Scott James Remnant <[email protected]>
Subject: [PATCH 04/21] [terminal] replace set_active_vt with
activate_vt
To: [email protected]
Message-ID:
<9c4c3433b6f5a640baa93fc1fa7247c2d062744f.1268889867.git.sc...@ubuntu.com>
Since a terminal already knows which VT number it is, there's no
need to accept a VT number for switching to this VT.
---
src/libply-splash-core/ply-terminal.c | 23 ++++++++++++++++-------
src/libply-splash-core/ply-terminal.h | 3 +--
src/main.c | 3 +--
src/plugins/renderers/drm/plugin.c | 3 +--
src/plugins/renderers/frame-buffer/plugin.c | 3 +--
5 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/libply-splash-core/ply-terminal.c
b/src/libply-splash-core/ply-terminal.c
index ed08657..7725eb4 100644
--- a/src/libply-splash-core/ply-terminal.c
+++ b/src/libply-splash-core/ply-terminal.c
@@ -695,23 +695,32 @@ ply_terminal_get_active_vt (ply_terminal_t *terminal)
return terminal->active_vt;
}
+static bool
+set_active_vt (ply_terminal_t *terminal,
+ int vt_number)
+{
+ if (ioctl (terminal->fd, VT_ACTIVATE, vt_number) < 0)
+ return false;
+
+ terminal->next_active_vt = vt_number;
+
+ return true;
+}
+
bool
-ply_terminal_set_active_vt (ply_terminal_t *terminal,
- int vt_number)
+ply_terminal_activate_vt (ply_terminal_t *terminal)
{
assert (terminal != NULL);
- if (vt_number <= 0)
+ if (terminal->vt_number <= 0)
return false;
- if (vt_number == terminal->active_vt)
+ if (terminal->vt_number == terminal->active_vt)
return true;
- if (ioctl (terminal->fd, VT_ACTIVATE, vt_number) < 0)
+ if (!set_active_vt (terminal, terminal->vt_number))
return false;
- terminal->next_active_vt = vt_number;
-
return true;
}
diff --git a/src/libply-splash-core/ply-terminal.h
b/src/libply-splash-core/ply-terminal.h
index 4b9ef5a..2c9c4f8 100644
--- a/src/libply-splash-core/ply-terminal.h
+++ b/src/libply-splash-core/ply-terminal.h
@@ -90,8 +90,7 @@ void ply_terminal_ignore_mode_changes (ply_terminal_t
*terminal,
int ply_terminal_get_vt_number (ply_terminal_t *terminal);
int ply_terminal_get_active_vt (ply_terminal_t *terminal);
-bool ply_terminal_set_active_vt (ply_terminal_t *terminal,
- int vt_number);
+bool ply_terminal_activate_vt (ply_terminal_t *terminal);
void ply_terminal_watch_for_active_vt_change (ply_terminal_t *terminal,
ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
diff --git a/src/main.c b/src/main.c
index 76ba53a..35c287f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1021,8 +1021,7 @@ add_display_and_keyboard_for_terminal (state_t *state,
state->terminal = terminal;
- ply_terminal_set_active_vt (state->terminal,
- ply_terminal_get_vt_number (state->terminal));
+ ply_terminal_activate_vt (state->terminal);
keyboard = ply_keyboard_new_for_terminal (state->terminal);
display = ply_text_display_new (state->terminal);
diff --git a/src/plugins/renderers/drm/plugin.c
b/src/plugins/renderers/drm/plugin.c
index 48e9ab0..549955d 100644
--- a/src/plugins/renderers/drm/plugin.c
+++ b/src/plugins/renderers/drm/plugin.c
@@ -806,8 +806,7 @@ map_to_device (ply_renderer_backend_t *backend)
node = next_node;
}
- ply_terminal_set_active_vt (backend->terminal,
- ply_terminal_get_vt_number (backend->terminal));
+ ply_terminal_activate_vt (backend->terminal);
return head_mapped;
}
diff --git a/src/plugins/renderers/frame-buffer/plugin.c
b/src/plugins/renderers/frame-buffer/plugin.c
index ff2d1dc..1c0e34b 100644
--- a/src/plugins/renderers/frame-buffer/plugin.c
+++ b/src/plugins/renderers/frame-buffer/plugin.c
@@ -512,8 +512,7 @@ map_to_device (ply_renderer_backend_t *backend)
if (head->map_address == MAP_FAILED)
return false;
- ply_terminal_set_active_vt (backend->terminal,
- ply_terminal_get_vt_number (backend->terminal));
+ ply_terminal_activate_vt (backend->terminal);
return true;
}
--
1.7.0
------------------------------
Message: 3
Date: Thu, 18 Mar 2010 05:24:27 +0000
From: Scott James Remnant <[email protected]>
Subject: [PATCH 00/21] Improve VT Handling
To: [email protected]
Message-ID: <[email protected]>
One of the main differences between Ubuntu's use of Plymouth and
Fedora's is that on Ubuntu we've tried to keep the X server on VT7
so that the historical documentation of Ctrl-Alt-F1 giving you a
text console is preserved.
This obviously means that for a smooth transition, Plymouth must also
run on VT7.
We discovered that although Plymouth does have code to attempt to deal
with VTs, none of it is quite right and there are many paths that don't
work unless Plymouth is run on VT1.
This patch set fixes our known problems with the VT handling making it
possible to run Plymouth on any VT of your choosing, with VT1 remaining
the default.
Scott James Remnant (21):
[terminal] merge console and terminal code
[terminal] remove references to ply_console_t
[console] remove console files
[terminal] replace set_active_vt with activate_vt
[terminal] add ply_terminal_is_vt() function
[terminal] only support vt-like operations on VTs
[terminal] drop support for opening the foreground terminal
[terminal] don't keep track of active vt, just if vt is active
[terminal] drop next_active_vt
[terminal] don't treat ttySx as VT
[terminal] move terminal opening into renderers/plugins
[drm] don't run on non-virtual terminals
[frame-buffer] don't run on non-virtual terminals
[x11] ignore terminal completely
[terminal,text,details] move activate vt into plugins
[drm] default renderer to inactive
[frame-buffer] default renderer to inactive
[x11] default renderer to inactive
[terminal] guard open and close against repeated calls
[main] add --tty command-line option
[configure] allow boot and shutdown ttys to be changed
configure.ac | 7 +
src/libply-splash-core/Makefile.am | 2 -
src/libply-splash-core/ply-boot-splash.c | 37 +--
src/libply-splash-core/ply-boot-splash.h | 10 +-
src/libply-splash-core/ply-console.c | 410 --------------------------
src/libply-splash-core/ply-console.h | 70 -----
src/libply-splash-core/ply-renderer-plugin.h | 5 +-
src/libply-splash-core/ply-renderer.c | 12 +-
src/libply-splash-core/ply-renderer.h | 6 +-
src/libply-splash-core/ply-terminal.c | 341 ++++++++++++++++++---
src/libply-splash-core/ply-terminal.h | 24 ++
src/libply-splash-core/ply-text-display.c | 10 +-
src/libply-splash-core/ply-text-display.h | 4 +-
src/main.c | 61 ++---
src/plugins/renderers/drm/plugin.c | 67 +++--
src/plugins/renderers/frame-buffer/plugin.c | 62 +++--
src/plugins/renderers/x11/plugin.c | 24 +-
src/plugins/splash/details/plugin.c | 5 +
src/plugins/splash/text/plugin.c | 5 +
src/tests/ply-boot-splash-test.am | 2 -
20 files changed, 469 insertions(+), 695 deletions(-)
delete mode 100644 src/libply-splash-core/ply-console.c
delete mode 100644 src/libply-splash-core/ply-console.h
------------------------------
Message: 4
Date: Thu, 18 Mar 2010 05:16:17 +0000
From: Scott James Remnant <[email protected]>
Subject: [PATCH 21/21] [configure] allow boot and shutdown ttys to be
changed
To: [email protected]
Message-ID:
<b925e7ac474a46140d4b7c5aa40a153a54e52336.1268889867.git.sc...@ubuntu.com>
Allow distributions like Ubuntu to override the boot and shutdown
ttys from the configure script so they don't have to patch the
source.
---
configure.ac | 7 +++++++
src/main.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index fafef27..41a8921 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,12 @@ AC_ARG_WITH(release-file,
AC_HELP_STRING([--with-release-file=<path_to_release_f
AC_SUBST(RELEASE_FILE)
AC_DEFINE_UNQUOTED(RELEASE_FILE, "$RELEASE_FILE", [Release file path])
+AC_ARG_WITH(boot-tty, AC_HELP_STRING([--with-boot-tty=<tty>], [Default TTY to
use in boot mode (by default tty1)]),BOOT_TTY=${withval},BOOT_TTY=/dev/tty1)
+AC_DEFINE_UNQUOTED(BOOT_TTY, "$BOOT_TTY", [TTY to use in boot mode])
+
+AC_ARG_WITH(shutdown-tty, AC_HELP_STRING([--with-shutdown-tty=<tty>], [Default
TTY to use in shutdown mode (by default
tty63)]),SHUTDOWN_TTY=${withval},SHUTDOWN_TTY=/dev/tty63)
+AC_DEFINE_UNQUOTED(SHUTDOWN_TTY, "$SHUTDOWN_TTY", [TTY to use in shutdown
mode])
+
# Turn on the additional warnings last, so -Werror doesn't affect other tests.
AC_DEFUN([PLYMOUTH_CC_TRY_FLAG], [
@@ -223,6 +229,7 @@ AC_OUTPUT([Makefile
src/plugins/renderers/frame-buffer/Makefile
src/plugins/renderers/drm/Makefile
src/plugins/renderers/x11/Makefile
+ src/plugins/renderers/vga16fb/Makefile
src/plugins/splash/Makefile
src/plugins/splash/throbgress/Makefile
src/plugins/splash/fade-throbber/Makefile
diff --git a/src/main.c b/src/main.c
index edf7289..a865a1d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1424,10 +1424,10 @@ initialize_environment (state_t *state)
{
if (state->mode == PLY_MODE_SHUTDOWN)
{
- state->default_tty = "tty63";
+ state->default_tty = SHUTDOWN_TTY;
}
else
- state->default_tty = "tty1";
+ state->default_tty = BOOT_TTY;
}
check_for_consoles (state, state->default_tty, false);
--
1.7.0
------------------------------
Message: 5
Date: Thu, 18 Mar 2010 05:09:21 +0000
From: Scott James Remnant <[email protected]>
Subject: [PATCH 20/21] [main] add --tty command-line option
To: [email protected]
Message-ID:
<6c9447d2834c5615646761a3bc753badb9456e40.1268889867.git.sc...@ubuntu.com>
Add a command-line option to specify the TTY that plymouth should
use. This is mostly useful for debugging, for example you can put
plymouth onto a TTY not used by the X server; or if you're feeling
particularly sneaky, plymouth into an xterm.
---
src/main.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/main.c b/src/main.c
index 429d8c5..edf7289 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1420,12 +1420,15 @@ initialize_environment (state_t *state)
state->text_displays = ply_list_new ();
state->keyboard = NULL;
- if (state->mode == PLY_MODE_SHUTDOWN)
+ if (!state->default_tty)
{
- state->default_tty = "tty63";
+ if (state->mode == PLY_MODE_SHUTDOWN)
+ {
+ state->default_tty = "tty63";
+ }
+ else
+ state->default_tty = "tty1";
}
- else
- state->default_tty = "tty1";
check_for_consoles (state, state->default_tty, false);
@@ -1517,6 +1520,7 @@ main (int argc,
bool attach_to_session;
ply_daemon_handle_t *daemon_handle;
char *mode_string = NULL;
+ char *tty = NULL;
state.command_parser = ply_command_parser_new ("plymouthd", "Boot splash
control server");
@@ -1530,6 +1534,7 @@ main (int argc,
"debug-file", "File to output debugging
information to", PLY_COMMAND_OPTION_TYPE_STRING,
"mode", "Mode is one of: boot, shutdown",
PLY_COMMAND_OPTION_TYPE_STRING,
"pid-file", "Write the pid of the daemon to
a file", PLY_COMMAND_OPTION_TYPE_STRING,
+ "tty", "TTY to use instead of default",
PLY_COMMAND_OPTION_TYPE_STRING,
NULL);
if (!ply_command_parser_parse_arguments (state.command_parser, state.loop,
argv, argc))
@@ -1552,6 +1557,7 @@ main (int argc,
"debug", &debug,
"debug-file", &debug_buffer_path,
"pid-file", &pid_file,
+ "tty", &tty,
NULL);
if (should_help)
@@ -1582,6 +1588,11 @@ main (int argc,
free (mode_string);
}
+ if (tty != NULL)
+ {
+ state.default_tty = tty;
+ }
+
if (geteuid () != 0)
{
ply_error ("plymouthd must be run as root user");
--
1.7.0
------------------------------
Message: 6
Date: Thu, 18 Mar 2010 03:21:01 +0000
From: Scott James Remnant <[email protected]>
Subject: [PATCH 01/21] [terminal] merge console and terminal code
To: [email protected]
Message-ID:
<21278d3f76cf30aa3f9fd2cad943aa28cb1c509d.1268889867.git.sc...@ubuntu.com>
This removes the separation in code of "console" functions and
"terminal" functions; this never really made sense, and doesn't
particularly map to the behaviour of Linux virtual terminals.
The three principle operations that Plymouth was using "console"
for were:
* changing the active VT
* notification of changes to the active VT through VT_PROCESS
* switching between text and graphics mode
And it was using the "foreground terminal" alias /dev/tty0 to do
this. While this is fine for the first of those, since any console
device will do, it's always wrong for the latter two which should
always be on the actual VT we want Plymouth to run from.
If running on tty7, only tty7 should be in VT_PROCESS mode (since
we want to know when we enter this VT and leave this VT), and
certainly only tty7 should be in graphics mode.
Since you can use that same tty to obtain the current active VT,
and switch VT, you don't need another; so the need for a separate
"console" functionality goes away.
---
src/libply-splash-core/ply-terminal.c | 285 ++++++++++++++++++++++++++++++---
src/libply-splash-core/ply-terminal.h | 24 +++
2 files changed, 288 insertions(+), 21 deletions(-)
diff --git a/src/libply-splash-core/ply-terminal.c
b/src/libply-splash-core/ply-terminal.c
index ea9349c..ed08657 100644
--- a/src/libply-splash-core/ply-terminal.c
+++ b/src/libply-splash-core/ply-terminal.c
@@ -50,6 +50,12 @@
#define TEXT_PALETTE_SIZE 48
#endif
+typedef struct
+{
+ ply_terminal_active_vt_changed_handler_t handler;
+ void *user_data;
+} ply_terminal_active_vt_changed_closure_t;
+
struct _ply_terminal
{
ply_event_loop_t *loop;
@@ -59,7 +65,10 @@ struct _ply_terminal
char *name;
int fd;
int vt_number;
+ int active_vt;
+ int next_active_vt;
+ ply_list_t *vt_change_closures;
ply_fd_watch_t *fd_watch;
ply_terminal_color_t foreground_color;
ply_terminal_color_t background_color;
@@ -73,6 +82,8 @@ struct _ply_terminal
uint32_t original_term_attributes_saved : 1;
uint32_t supports_text_color : 1;
uint32_t is_open : 1;
+ uint32_t is_watching_for_vt_changes : 1;
+ uint32_t should_ignore_mode_changes : 1;
};
static bool ply_terminal_open_device (ply_terminal_t *terminal);
@@ -85,6 +96,7 @@ ply_terminal_new (const char *device_name)
terminal = calloc (1, sizeof (ply_terminal_t));
terminal->loop = ply_event_loop_get_default ();
+ terminal->vt_change_closures = ply_list_new ();
if (device_name != NULL)
{
if (strncmp (device_name, "/dev/", strlen ("/dev/")) == 0)
@@ -243,27 +255,6 @@ on_tty_disconnected (ply_terminal_t *terminal)
}
}
-static int
-get_active_vt (void)
-{
- int console_fd;
- struct vt_stat console_state = { 0 };
-
- console_fd = open ("/dev/tty0", O_RDONLY | O_NOCTTY);
-
- if (console_fd < 0)
- goto out;
-
- if (ioctl (console_fd, VT_GETSTATE, &console_state) < 0)
- goto out;
-
-out:
- if (console_fd >= 0)
- close (console_fd);
-
- return console_state.v_active;
-}
-
static bool
ply_terminal_look_up_geometry (ply_terminal_t *terminal)
{
@@ -310,6 +301,133 @@ ply_terminal_check_for_vt (ply_terminal_t *terminal)
terminal->vt_number = -1;
}
+static int
+get_active_vt (void)
+{
+ int console_fd;
+ struct vt_stat console_state = { 0 };
+
+ console_fd = open ("/dev/tty0", O_RDONLY | O_NOCTTY);
+
+ if (console_fd < 0)
+ goto out;
+
+ if (ioctl (console_fd, VT_GETSTATE, &console_state) < 0)
+ goto out;
+
+out:
+ if (console_fd >= 0)
+ close (console_fd);
+
+ return console_state.v_active;
+}
+
+static void
+ply_terminal_look_up_active_vt (ply_terminal_t *terminal)
+{
+ struct vt_stat terminal_state = { 0 };
+
+ if (ioctl (terminal->fd, VT_GETSTATE, &terminal_state) < 0)
+ return;
+
+ terminal->active_vt = terminal_state.v_active;
+}
+
+static void
+do_active_vt_changed (ply_terminal_t *terminal)
+{
+ ply_list_node_t *node;
+
+ node = ply_list_get_first_node (terminal->vt_change_closures);
+ while (node != NULL)
+ {
+ ply_terminal_active_vt_changed_closure_t *closure;
+ ply_list_node_t *next_node;
+
+ closure = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (terminal->vt_change_closures, node);
+
+ if (closure->handler != NULL)
+ closure->handler (closure->user_data, terminal);
+
+ node = next_node;
+ }
+}
+
+static void
+on_leave_vt (ply_terminal_t *terminal)
+{
+ ioctl (terminal->fd, VT_RELDISP, 1);
+
+ if (terminal->next_active_vt > 0)
+ {
+ ioctl (terminal->fd, VT_WAITACTIVE, terminal->next_active_vt);
+ terminal->next_active_vt = 0;
+ }
+
+ ply_terminal_look_up_active_vt (terminal);
+ do_active_vt_changed (terminal);
+}
+
+static void
+on_enter_vt (ply_terminal_t *terminal)
+{
+ ioctl (terminal->fd, VT_RELDISP, VT_ACKACQ);
+
+ ply_terminal_look_up_active_vt (terminal);
+ do_active_vt_changed (terminal);
+}
+
+static void
+ply_terminal_watch_for_vt_changes (ply_terminal_t *terminal)
+{
+ assert (terminal != NULL);
+
+ struct vt_mode mode = { 0 };
+
+ if (terminal->fd < 0)
+ return;
+
+ if (terminal->is_watching_for_vt_changes)
+ return;
+
+ mode.mode = VT_PROCESS;
+ mode.relsig = SIGUSR1;
+ mode.acqsig = SIGUSR2;
+
+ if (ioctl (terminal->fd, VT_SETMODE, &mode) < 0)
+ return;
+
+ ply_event_loop_watch_signal (terminal->loop,
+ SIGUSR1,
+ (ply_event_handler_t)
+ on_leave_vt, terminal);
+
+ ply_event_loop_watch_signal (terminal->loop,
+ SIGUSR2,
+ (ply_event_handler_t)
+ on_enter_vt, terminal);
+
+ terminal->is_watching_for_vt_changes = true;
+}
+
+static void
+ply_terminal_stop_watching_for_vt_changes (ply_terminal_t *terminal)
+{
+ struct vt_mode mode = { 0 };
+
+ if (!terminal->is_watching_for_vt_changes)
+ return;
+
+ terminal->is_watching_for_vt_changes = false;
+
+ ply_event_loop_stop_watching_signal (terminal->loop, SIGUSR1);
+ ply_event_loop_stop_watching_signal (terminal->loop, SIGUSR2);
+
+ mode.mode = VT_AUTO;
+ ioctl (terminal->fd, VT_SETMODE, &mode);
+}
+
static bool
ply_terminal_open_device (ply_terminal_t *terminal)
{
@@ -330,6 +448,7 @@ ply_terminal_open_device (ply_terminal_t *terminal)
terminal);
ply_terminal_check_for_vt (terminal);
+ ply_terminal_look_up_active_vt (terminal);
if (!ply_terminal_set_unbuffered_input (terminal))
ply_trace ("terminal '%s' will be line buffered", terminal->name);
@@ -376,6 +495,8 @@ ply_terminal_open (ply_terminal_t *terminal)
ply_terminal_look_up_geometry,
terminal);
+ ply_terminal_watch_for_vt_changes (terminal);
+
terminal->is_open = true;
return true;
@@ -398,6 +519,8 @@ ply_terminal_close (ply_terminal_t *terminal)
{
terminal->is_open = false;
+ ply_terminal_stop_watching_for_vt_changes (terminal);
+
ply_trace ("restoring color palette");
ply_terminal_restore_color_palette (terminal);
@@ -479,6 +602,38 @@ ply_terminal_supports_color (ply_terminal_t *terminal)
return terminal->supports_text_color;
}
+void
+ply_terminal_set_mode (ply_terminal_t *terminal,
+ ply_terminal_mode_t mode)
+{
+
+ assert (terminal != NULL);
+ assert (mode == PLY_TERMINAL_MODE_TEXT || mode ==
PLY_TERMINAL_MODE_GRAPHICS);
+
+ if (terminal->should_ignore_mode_changes)
+ return;
+
+ switch (mode)
+ {
+ case PLY_TERMINAL_MODE_TEXT:
+ if (ioctl (terminal->fd, KDSETMODE, KD_TEXT) < 0)
+ return;
+ break;
+
+ case PLY_TERMINAL_MODE_GRAPHICS:
+ if (ioctl (terminal->fd, KDSETMODE, KD_GRAPHICS) < 0)
+ return;
+ break;
+ }
+}
+
+void
+ply_terminal_ignore_mode_changes (ply_terminal_t *terminal,
+ bool should_ignore)
+{
+ terminal->should_ignore_mode_changes = should_ignore;
+}
+
static void
ply_terminal_detach_from_event_loop (ply_terminal_t *terminal)
{
@@ -487,6 +642,26 @@ ply_terminal_detach_from_event_loop (ply_terminal_t
*terminal)
terminal->fd_watch = NULL;
}
+static void
+free_vt_change_closures (ply_terminal_t *terminal)
+{
+ ply_list_node_t *node;
+
+ node = ply_list_get_first_node (terminal->vt_change_closures);
+ while (node != NULL)
+ {
+ ply_terminal_active_vt_changed_closure_t *closure;
+ ply_list_node_t *next_node;
+
+ closure = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (terminal->vt_change_closures, node);
+
+ free (closure);
+ node = next_node;
+ }
+ ply_list_free (terminal->vt_change_closures);
+}
+
void
ply_terminal_free (ply_terminal_t *terminal)
{
@@ -504,6 +679,7 @@ ply_terminal_free (ply_terminal_t *terminal)
if (terminal->is_open)
ply_terminal_close (terminal);
+ free_vt_change_closures (terminal);
free (terminal);
}
@@ -513,4 +689,71 @@ ply_terminal_get_vt_number (ply_terminal_t *terminal)
return terminal->vt_number;
}
+int
+ply_terminal_get_active_vt (ply_terminal_t *terminal)
+{
+ return terminal->active_vt;
+}
+
+bool
+ply_terminal_set_active_vt (ply_terminal_t *terminal,
+ int vt_number)
+{
+ assert (terminal != NULL);
+
+ if (vt_number <= 0)
+ return false;
+
+ if (vt_number == terminal->active_vt)
+ return true;
+
+ if (ioctl (terminal->fd, VT_ACTIVATE, vt_number) < 0)
+ return false;
+
+ terminal->next_active_vt = vt_number;
+
+ return true;
+}
+
+void
+ply_terminal_watch_for_active_vt_change (ply_terminal_t *terminal,
+
ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
+ void *user_data)
+{
+ ply_terminal_active_vt_changed_closure_t *closure;
+
+ closure = calloc (1, sizeof (*closure));
+ closure->handler = active_vt_changed_handler;
+ closure->user_data = user_data;
+
+ ply_list_append_data (terminal->vt_change_closures, closure);
+}
+
+void
+ply_terminal_stop_watching_for_active_vt_change (ply_terminal_t *terminal,
+
ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
+ void *user_data)
+{
+ ply_list_node_t *node;
+
+ node = ply_list_get_first_node (terminal->vt_change_closures);
+ while (node != NULL)
+ {
+ ply_terminal_active_vt_changed_closure_t *closure;
+ ply_list_node_t *next_node;
+
+ closure = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (terminal->vt_change_closures, node);
+
+ if (closure->handler == active_vt_changed_handler &&
+ closure->user_data == user_data)
+ {
+ free (closure);
+ ply_list_remove_node (terminal->vt_change_closures, node);
+ }
+
+ node = next_node;
+ }
+}
+
/* vim: set ts=4 sw=4 et ai ci
cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
diff --git a/src/libply-splash-core/ply-terminal.h
b/src/libply-splash-core/ply-terminal.h
index 21689d1..4b9ef5a 100644
--- a/src/libply-splash-core/ply-terminal.h
+++ b/src/libply-splash-core/ply-terminal.h
@@ -31,6 +31,8 @@
#include "ply-event-loop.h"
typedef struct _ply_terminal ply_terminal_t;
+typedef void (* ply_terminal_active_vt_changed_handler_t) (void
*user_data,
+ ply_terminal_t
*terminal);
typedef enum
{
@@ -45,6 +47,12 @@ typedef enum
PLY_TERMINAL_COLOR_DEFAULT = PLY_TERMINAL_COLOR_WHITE + 2
} ply_terminal_color_t;
+typedef enum
+{
+ PLY_TERMINAL_MODE_TEXT,
+ PLY_TERMINAL_MODE_GRAPHICS
+} ply_terminal_mode_t;
+
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_terminal_t *ply_terminal_new (const char *device_name);
@@ -74,7 +82,23 @@ void ply_terminal_set_color_hex_value (ply_terminal_t
*terminal,
ply_terminal_color_t color,
uint32_t hex_value);
+void ply_terminal_set_mode (ply_terminal_t *terminal,
+ ply_terminal_mode_t mode);
+
+void ply_terminal_ignore_mode_changes (ply_terminal_t *terminal,
+ bool should_ignore);
+
int ply_terminal_get_vt_number (ply_terminal_t *terminal);
+int ply_terminal_get_active_vt (ply_terminal_t *terminal);
+bool ply_terminal_set_active_vt (ply_terminal_t *terminal,
+ int vt_number);
+
+void ply_terminal_watch_for_active_vt_change (ply_terminal_t *terminal,
+
ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
+ void *user_data);
+void ply_terminal_stop_watching_for_active_vt_change (ply_terminal_t *terminal,
+
ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
+ void *user_data);
#endif
--
1.7.0
------------------------------
_______________________________________________
plymouth mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/plymouth
End of plymouth Digest, Vol 17, Issue 9
***************************************