]> git.pld-linux.org Git - packages/plymouth.git/blame - plymouth-git.patch
- get rid of ShowDelay from defaults
[packages/plymouth.git] / plymouth-git.patch
CommitLineData
612b1f77
JR
1diff --git a/Makefile.am b/Makefile.am
2index b322463..395c91b 100644
3--- a/Makefile.am
4+++ b/Makefile.am
5@@ -1,4 +1,8 @@
6-SUBDIRS = src themes images scripts docs systemd-units
7+SUBDIRS = src themes images scripts systemd-units
8+
9+if BUILD_DOCUMENTATION
10+SUBDIRS += docs
11+endif
12
13 DISTCHECK_CONFIGURE_FLAGS = --disable-tests --without-system-root-install
14
15diff --git a/configure.ac b/configure.ac
16index 2ab0893..9c8f863 100644
17--- a/configure.ac
18+++ b/configure.ac
19@@ -6,7 +6,7 @@ AC_CONFIG_AUX_DIR(build-tools)
20 AC_USE_SYSTEM_EXTENSIONS
21 AC_SYS_LARGEFILE
22 AC_PROG_AWK
23-AC_PROG_CC
24+AC_PROG_CC_STDC
25 AM_PROG_CC_C_O
26 AC_HEADER_STDC
27 AC_C_CONST
28@@ -16,7 +16,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
29 AM_MAINTAINER_MODE([enable])
30
31 PKG_PROG_PKG_CONFIG
32-LT_INIT
33+LT_INIT([dlopen disable-static pic-only])
34
35 ## increment if the interface has additions, changes, removals.
36 LT_CURRENT=3
37@@ -38,12 +38,19 @@ PKG_CHECK_MODULES(IMAGE, [libpng >= 1.2.16 ])
38 AC_SUBST(IMAGE_CFLAGS)
39 AC_SUBST(IMAGE_LIBS)
40
41+PKG_CHECK_MODULES(UDEV, [libudev]);
42+AC_SUBST(UDEV_CFLAGS)
43+AC_SUBST(UDEV_LIBS)
44+
45 PLYMOUTH_CFLAGS=""
46 PLYMOUTH_LIBS="-lm -lrt -ldl"
47
48 AC_SUBST(PLYMOUTH_CFLAGS)
49 AC_SUBST(PLYMOUTH_LIBS)
50
51+AC_PATH_PROG([SYSTEMD_ASK_PASSWORD_AGENT], [systemd-tty-ask-password-agent])
52+AC_PATH_PROG([UDEVADM], [udevadm])
53+
54 AC_ARG_ENABLE(pango, AS_HELP_STRING([--enable-pango],[enable building with pango, disabled there is no encryption prompts]),enable_pango=$enableval,enable_pango=yes)
55 AM_CONDITIONAL(ENABLE_PANGO, [test "$enable_pango" = yes])
56
57@@ -62,148 +69,6 @@ if test x$enable_gtk = xyes; then
58 AC_SUBST(GTK_LIBS)
59 fi
60
61-AC_ARG_ENABLE(libdrm_intel, AS_HELP_STRING([--enable-libdrm_intel],[enable building with libdrm_intel support]),enable_libdrm_intel=$enableval,enable_libdrm_intel=no)
62-AM_CONDITIONAL(ENABLE_LIBDRM_INTEL, [test "$enable_libdrm_intel" = yes])
63-
64-if test x$enable_libdrm_intel = xyes; then
65- PKG_CHECK_MODULES(DRM_INTEL, [libdrm libdrm_intel])
66- OLD_CFLAGS="$CFLAGS"
67- CFLAGS="$CFLAGS $DRM_INTEL_CFLAGS"
68- AC_MSG_CHECKING([if i915_drm.h is in include path])
69- AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
70- [[
71- #include <stdint.h>
72- #include <stdlib.h>
73- #include "i915_drm.h"
74- ]],[[]]),[found_drm_intel_kernel_headers=yes],[found_drm_intel_kernel_headers=no])
75-
76- if test "$found_drm_intel_kernel_headers" = "yes"; then
77- AC_MSG_RESULT([yes])
78- else
79- AC_MSG_RESULT([no])
80- AC_MSG_CHECKING([if we can find them anyway])
81-
82- MORE_DRM_CFLAGS="-I`$PKG_CONFIG --variable includedir libdrm`/drm"
83- CFLAGS="$CFLAGS $MORE_DRM_CFLAGS"
84- AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
85- [[
86- #include <stdint.h>
87- #include <stdlib.h>
88- #include "i915_drm.h"
89- ]],[[]]),[found_drm_intel_kernel_headers=yes],[found_drm_intel_kernel_headers=no])
90-
91- if test "$found_drm_intel_kernel_headers" = "yes"; then
92- AC_MSG_RESULT([yes])
93- DRM_INTEL_CFLAGS="$DRM_INTEL_CFLAGS $MORE_DRM_CFLAGS"
94- else
95- AC_MSG_RESULT([no])
96- AC_MSG_ERROR([Could not find i915_drm.h])
97- fi
98- fi
99-
100- AC_SUBST(DRM_INTEL_CFLAGS)
101- AC_SUBST(DRM_INTEL_LIBS)
102- AC_DEFINE(PLY_ENABLE_LIBDRM_INTEL, 1, [Enable support for libdrm_intel driver])
103-fi
104-
105-AC_ARG_ENABLE(libdrm_radeon, AS_HELP_STRING([--enable-libdrm_radeon],[enable building with libdrm_radeon support]),enable_libdrm_radeon=$enableval,enable_libdrm_radeon=no)
106-AM_CONDITIONAL(ENABLE_LIBDRM_RADEON, [test "$enable_libdrm_radeon" = yes])
107-
108-if test x$enable_libdrm_radeon = xyes; then
109- PKG_CHECK_MODULES(DRM_RADEON, [libdrm libdrm_radeon])
110- OLD_CFLAGS="$CFLAGS"
111- CFLAGS="$CFLAGS $DRM_RADEON_CFLAGS"
112- AC_MSG_CHECKING([if radeon_drm.h is in include path])
113- AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
114- [[
115- #include <stdint.h>
116- #include <stdlib.h>
117- #include "radeon_drm.h"
118- ]],[[]]),[found_drm_radeon_kernel_headers=yes],[found_drm_radeon_kernel_headers=no])
119-
120- if test "$found_drm_radeon_kernel_headers" = "yes"; then
121- AC_MSG_RESULT([yes])
122- else
123- AC_MSG_RESULT([no])
124- AC_MSG_CHECKING([if we can find them anyway])
125-
126- MORE_DRM_CFLAGS="-I`$PKG_CONFIG --variable includedir libdrm`/drm"
127- CFLAGS="$CFLAGS $MORE_DRM_RADEON_CFLAGS"
128- AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
129- [[
130- #include <stdint.h>
131- #include <stdlib.h>
132- #include "radeon_drm.h"
133- ]],[[]]),[found_drm_radeon_kernel_headers=yes],[found_drm_radeon_kernel_headers=no])
134-
135- if test "$found_drm_radeon_kernel_headers" = "yes"; then
136- AC_MSG_RESULT([yes])
137- DRM_RADEON_CFLAGS="$DRM_RADEON_CFLAGS $MORE_DRM_CFLAGS"
138- else
139- AC_MSG_RESULT([no])
140- AC_MSG_ERROR([Could not find radeon_drm.h])
141- fi
142- fi
143-
144- AC_SUBST(DRM_RADEON_CFLAGS)
145- AC_SUBST(DRM_RADEON_LIBS)
146- AC_DEFINE(PLY_ENABLE_LIBDRM_RADEON, 1, [Enable support for libdrm_radeon driver])
147-fi
148-
149-AC_ARG_ENABLE(libdrm_nouveau, AS_HELP_STRING([--enable-libdrm_nouveau],[enable building with libdrm_nouveau support]),enable_libdrm_nouveau=$enableval,enable_libdrm_nouveau=no)
150-AM_CONDITIONAL(ENABLE_LIBDRM_NOUVEAU, [test "$enable_libdrm_nouveau" = yes])
151-
152-if test x$enable_libdrm_nouveau = xyes; then
153- PKG_CHECK_MODULES(DRM_NOUVEAU, [libdrm libdrm_nouveau])
154- OLD_CFLAGS="$CFLAGS"
155- CFLAGS="$CFLAGS $DRM_NOUVEAU_CFLAGS"
156- AC_MSG_CHECKING([if nouveau_drm.h is in include path])
157- AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
158- [[
159- #include <stdint.h>
160- #include <stdlib.h>
161- #include "nouveau_drm.h"
162- ]],[[]]),[found_drm_nouveau_kernel_headers=yes],[found_drm_nouveau_kernel_headers=no])
163-
164- if test "$found_drm_nouveau_kernel_headers" = "yes"; then
165- AC_MSG_RESULT([yes])
166- else
167- AC_MSG_RESULT([no])
168- AC_MSG_CHECKING([if we can find them anyway])
169-
170- MORE_DRM_CFLAGS="-I`$PKG_CONFIG --variable includedir libdrm`/drm"
171- CFLAGS="$CFLAGS $MORE_DRM_CFLAGS"
172- AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
173- [[
174- #include <stdint.h>
175- #include <stdlib.h>
176- #include "nouveau_drm.h"
177- ]],[[]]),[found_drm_nouveau_kernel_headers=yes],[found_drm_nouveau_kernel_headers=no])
178-
179- if test "$found_drm_nouveau_kernel_headers" = "yes"; then
180- AC_MSG_RESULT([yes])
181- DRM_NOUVEAU_CFLAGS="$DRM_NOUVEAU_CFLAGS $MORE_DRM_CFLAGS"
182- else
183- AC_MSG_RESULT([no])
184- AC_MSG_ERROR([Could not find nouveau_drm.h])
185- fi
186- fi
187-
188- AC_SUBST(DRM_NOUVEAU_CFLAGS)
189- AC_SUBST(DRM_NOUVEAU_LIBS)
190- AC_DEFINE(PLY_ENABLE_LIBDRM_NOUVEAU, 1, [Enable support for libdrm_nouveau driver])
191-fi
192-
193-AC_ARG_ENABLE(libkms, AS_HELP_STRING([--enable-libkms],[enable building with libkms support]),enable_libkms=$enableval,enable_libkms=no)
194-AM_CONDITIONAL(ENABLE_LIBKMS, [test "$enable_libkms" = yes])
195-
196-if test x$enable_libkms = xyes; then
197- PKG_CHECK_MODULES(LIBKMS, [libdrm libkms])
198- AC_SUBST(LIBKMS_CFLAGS)
199- AC_SUBST(LIBKMS_LIBS)
200- AC_DEFINE(PLY_ENABLE_LIBKMS, 1, [Enable support for libkms abstraction over drm drivers])
201-fi
202-
203 AC_ARG_ENABLE(drm, AS_HELP_STRING([--enable-drm-renderer],[enable building drm kms support]),enable_drm_renderer=$enableval,enable_drm_renderer=yes)
204 AM_CONDITIONAL(ENABLE_DRM_RENDERER, [test "$enable_drm_renderer" = yes])
205
206@@ -211,10 +76,17 @@ if test x$enable_drm_renderer = xyes; then
207 PKG_CHECK_MODULES(DRM, [libdrm])
208 fi
209
210-DRM_CFLAGS="$DRM_CFLAGS $DRM_INTEL_CFLAGS $DRM_RADEON_CFLAGS $DRM_NOUVEAU_CFLAGS $LIBKMS_CFLAG"
211-DRM_LIBS="$DRM_LIBS $DRM_INTEL_LIBS $DRM_RADEON_LIBS $DRM_NOUVEAU_LIBS $LIBKMS_LIBS"
212-AC_SUBST(DRM_CFLAGS)
213-AC_SUBST(DRM_LIBS)
214+AC_ARG_ENABLE(documentation,
215+ AS_HELP_STRING([--enable-documentation],
216+ [build documentation]),,
217+ enable_documentation=yes)
218+if test x$enable_documentation = xyes; then
219+ AC_PATH_PROG([XSLTPROC], [xsltproc])
220+ if test x$XSLTPROC = x; then
221+ AC_MSG_ERROR([xsltproc is required to build documentation])
222+ fi
223+fi
224+AM_CONDITIONAL(BUILD_DOCUMENTATION, test x$enable_documentation = xyes)
225
226 AC_ARG_ENABLE(tracing, AS_HELP_STRING([--enable-tracing],[enable verbose tracing code]),enable_tracing=$enableval,enable_tracing=yes)
227
228@@ -222,10 +94,6 @@ if test x$enable_tracing = xyes; then
229 AC_DEFINE(PLY_ENABLE_TRACING, 1, [Build in verbose debug tracing spew])
230 fi
231
232-AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[build tests]),enable_tests=$enableval,enable_tests=yes)
233-
234-AM_CONDITIONAL(ENABLE_TESTS, [test "$enable_tests" = yes])
235-
236 AC_ARG_ENABLE(gdm-transition, AS_HELP_STRING([--enable-gdm-transition],[enable smooth transition to gdm]),enable_gdm_transition=$enableval,enable_gdm_transition=no)
237
238 if test x$enable_gdm_transition = xyes; then
239@@ -254,7 +122,7 @@ AM_CONDITIONAL(ENABLE_SYSTEMD_INTEGRATION, [test "$enable_systemd_integration" =
240
241 if test x$enable_systemd_integration = xyes; then
242 AC_DEFINE(PLY_ENABLE_SYSTEMD_INTEGRATION, 1, [Coordinate boot up with systemd])
243- SYSTEMD_UNIT_DIR=/lib/systemd/system
244+ SYSTEMD_UNIT_DIR=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
245 AC_SUBST(SYSTEMD_UNIT_DIR)
246 fi
247
248@@ -278,7 +146,7 @@ AS_AC_EXPAND(PLYMOUTH_CLIENT_DIR, $plymouthclientdir)
249 AS_AC_EXPAND(PLYMOUTH_DAEMON_DIR, $plymouthdaemondir)
250 AS_AC_EXPAND(PLYMOUTH_RUNTIME_DIR, $plymouthruntimedir)
251
252-AC_ARG_WITH(rhgb-compat-link, AS_HELP_STRING([--with-rhgb-compat-link],[Install /usr/bin/rhgb-client compatability symlink]),with_rhgb_compat_link=${withval},with_rhgb_compat_link=yes)
253+AC_ARG_WITH(rhgb-compat-link, AS_HELP_STRING([--with-rhgb-compat-link],[Install /usr/bin/rhgb-client compatability symlink]),with_rhgb_compat_link=${withval},with_rhgb_compat_link=no)
254 AM_CONDITIONAL(WITH_RHGB_COMPAT_LINK, [test "$with_rhgb_compat_link" = yes])
255
256 AC_ARG_WITH(log-viewer, AS_HELP_STRING([--with-log-viewer],[Install plymouth log viewer]),with_log_viewer=${withval},with_log_viewer=no)
257@@ -328,7 +196,7 @@ AC_DEFUN([PLYMOUTH_CC_TRY_FLAG], [
258 plymouth_save_CFLAGS="$CFLAGS"
259 CFLAGS="$CFLAGS $1"
260
261- AC_COMPILE_IFELSE([ ], [plymouth_cc_flag=yes], [plymouth_cc_flag=no])
262+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])], [plymouth_cc_flag=yes], [plymouth_cc_flag=no])
263 CFLAGS="$plymouth_save_CFLAGS"
264
265 if test "x$plymouth_cc_flag" = "xyes"; then
266@@ -357,7 +225,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
267 -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
268 -Wwrite-strings -Wnested-externs -Wpointer-arith \
269 -Wswitch-enum -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
270- -Wno-missing-field-initializers -Wno-unused-parameter \
271+ -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-result \
272 -Wcast-align -Wsign-compare -Wp,-D_FORTIFY_SOURCE=2"
273 elif test "$GCC" = "yes"; then
274 AC_MSG_RESULT(no)
275@@ -427,6 +295,7 @@ AC_CONFIG_FILES([Makefile
276 src/plugins/splash/Makefile
277 src/plugins/splash/throbgress/Makefile
278 src/plugins/splash/fade-throbber/Makefile
279+ src/plugins/splash/tribar/Makefile
280 src/plugins/splash/text/Makefile
281 src/plugins/splash/details/Makefile
282 src/plugins/splash/space-flares/Makefile
283@@ -439,12 +308,10 @@ AC_CONFIG_FILES([Makefile
284 src/client/Makefile
285 src/viewer/Makefile
286 src/upstart-bridge/Makefile
287- src/tests/Makefile
288- src/libply/tests/Makefile
289- src/client/tests/Makefile
290 themes/Makefile
291 themes/spinfinity/Makefile
292 themes/fade-in/Makefile
293+ themes/tribar/Makefile
294 themes/text/Makefile
295 themes/details/Makefile
296 themes/solar/Makefile
297diff --git a/docs/Makefile.am b/docs/Makefile.am
298index dedda55..1a9f7ea 100644
299--- a/docs/Makefile.am
300+++ b/docs/Makefile.am
301@@ -1,4 +1,31 @@
302-dist_man_MANS = plymouth.8
303+XSLTPROC_FLAGS = \
304+ --nonet \
305+ --stringparam man.output.quietly 1 \
306+ --stringparam funcsynopsis.style ansi \
307+ --stringparam man.th.extra1.suppress 1 \
308+ --stringparam man.authors.section.enabled 0 \
309+ --stringparam man.copyright.section.enabled 0
310
311-%.html: %.txt
312- asciidoc $(ASCIIDOC_OPTS) -a toc $*.txt
313+
314+plymouth.1: plymouth1.xml
315+ $(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
316+
317+%.8: %.xml
318+ $(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
319+
320+%.1: %.xml
321+ $(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
322+
323+man_MANS = \
324+ plymouth.1 \
325+ plymouth.8 \
326+ plymouthd.8 \
327+ plymouth-set-default-theme.1
328+
329+EXTRA_DIST = \
330+ plymouth.xml \
331+ plymouth1.xml \
332+ plymouth-set-default-theme.xml \
333+ plymouthd.xml
334+
335+CLEANFILES = $(man_MANS)
336diff --git a/docs/plymouth-set-default-theme.xml b/docs/plymouth-set-default-theme.xml
337new file mode 100644
338index 0000000..efb051e
339--- /dev/null
340+++ b/docs/plymouth-set-default-theme.xml
341@@ -0,0 +1,103 @@
342+<?xml version='1.0'?>
343+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
344+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
345+
346+<refentry id="plymouth-set-default-theme">
347+
348+ <refentryinfo>
349+ <title>plymouth-set-default-theme</title>
350+ <productname>plymouth</productname>
351+
352+ <authorgroup>
353+ <author>
354+ <contrib>Developer</contrib>
355+ <firstname>Kristian</firstname>
356+ <surname>Høgsberg</surname>
357+ </author>
358+ <author>
359+ <contrib>Developer</contrib>
360+ <firstname>Ray</firstname>
361+ <surname>Strode</surname>
362+ </author>
363+ </authorgroup>
364+
365+ </refentryinfo>
366+
367+ <refmeta>
368+ <refentrytitle>plymouth-set-default-theme</refentrytitle>
369+ <manvolnum>1</manvolnum>
370+ <refmiscinfo class="manual">User Commands</refmiscinfo>
371+ </refmeta>
372+
373+ <refnamediv>
374+ <refname>plymouth-set-default-theme</refname>
375+ <refpurpose>Set the plymouth theme</refpurpose>
376+ </refnamediv>
377+
378+ <refsynopsisdiv>
379+ <cmdsynopsis>
380+ <command>plymouth-set-default-theme <arg choice="opt" rep="repeat">OPTION</arg> <arg choice="opt" rep="norepeat">THEME</arg></command>
381+ </cmdsynopsis>
382+ </refsynopsisdiv>
383+
384+ <refsect1>
385+ <title>Description</title>
386+
387+<para>
388+When called with a <option>THEME</option> argument,
389+the <command>plymouth-set-default-theme</command> command
390+changes the preferred boot theme and also performs the necessary
391+regeneration of the initial ramdisk (initrd) since plymouth is loaded
392+from the boot loader from the initrd prior to the mounting of the root
393+filesystem.
394+</para>
395+
396+<para>
397+If <command>plymouth-set-default-theme</command> is invoked with no options
398+or parameters, it shows the currently selected theme by default. This output
399+is used by the helper scripts plymouth-generate-initrd and
400+plymouth-update-initrd to set the proper theme in the initial ramdisk.
401+</para>
402+
403+ </refsect1>
404+
405+ <refsect1>
406+ <title>Options</title>
407+
408+ <para>The following options are understood:</para>
409+
410+ <variablelist>
411+ <varlistentry>
412+ <term><option>-h</option>, <option>--help</option></term>
413+ <listitem><para>Show summary of options.</para></listitem>
414+ </varlistentry>
415+
416+ <varlistentry>
417+ <term><option>-l</option>, <option>--list</option></term>
418+ <listitem><para>List available themes.</para></listitem>
419+ </varlistentry>
420+
421+ <varlistentry>
422+ <term><option>-r</option>, <option>--reset</option></term>
423+ <listitem><para>Reset to default theme.</para></listitem>
424+ </varlistentry>
425+
426+ <varlistentry>
427+ <term><option>-R</option>, <option>--rebuild-initrd</option></term>
428+ <listitem><para>Rebuild initrd (necessary after changing theme).</para></listitem>
429+ </varlistentry>
430+ </variablelist>
431+ </refsect1>
432+
433+ <refsect1>
434+ <title>See Also</title>
435+ <para>
436+ <citerefentry><refentrytitle>grub</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
437+ <citerefentry><refentrytitle>plymouth</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
438+ <citerefentry><refentrytitle>plymouthd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
439+ <citerefentry><refentrytitle>plymouth</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
440+ <ulink url="http://www.freedesktop.org/wiki/Software/Plymouth">http://www.freedesktop.org/wiki/Software/Plymouth</ulink>
441+ </para>
442+ </refsect1>
443+
444+</refentry>
445diff --git a/docs/plymouth.8 b/docs/plymouth.8
446deleted file mode 100644
447index 7f4766b..0000000
448--- a/docs/plymouth.8
449+++ /dev/null
450@@ -1,62 +0,0 @@
451-\" Hey, EMACS: -*- nroff -*-
452-.TH PLYMOUTH 8 "December 15, 2009"
453-.SH NAME
454-plymouth \- A graphical boot system and logger
455-.SH SYNOPSIS
456-.B plymouth-set-default-theme
457-.RI [ options ] " \<theme\>"
458-.SH DESCRIPTION
459-\fBplymouth\fP is a graphical boot system for Linux which takes advantage of the kernel-based
460-mode setting (KMS) available for modern graphic cards to provide a seamless, flickerfree
461-and attractive boot screen. It allows to choose between various, static or
462-animated graphical themes to spruce up the startup and avoid the noise
463-generated by the vast amount of kernel messages while the machine boots into X.
464-On systems where kernel-based mode setting is not available, plymouth falls
465-back to a text mode boot screen which provides a simple progress bar to provide
466-feedback during boot.
467-.PP
468-To configure plymouth, that is to choose and install the preferred boot theme, the
469-user has to invoke \fBplymouth-set-default-theme\fP. It changes the configuration
470-to the new theme and also performs the necessary regeneration of the initial ramdisk
471-(initrd) since plymouth is loaded from the boot loader from the initrd
472-prior to the mounting of the root filesystem. The options available to this
473-script are explained in the \fBOPTIONS\fP paragraph.
474-.PP
475-In order for the configured default plymouth theme to be loaded during boot,
476-the option `splash' (or `rhgb' for backward compatibility with the RHGB boot
477-splash) must be provided at the kernel command line. With this command line
478-option, plymouth will default to showing detailed boot output.
479-.SH OPTIONS
480-plymouth-set-default-theme follows the usual GNU command line syntax, with long
481-options starting with two dashes (`-') and short variants of each of them.
482-.TP
483-.B \-h, \-\-help
484-Show summary of options.
485-.TP
486-.B \-l, \-\-list
487-List available themes.
488-.TP
489-.B \-r, \-\-reset
490-Reset to default theme.
491-.TP
492-.B \-R, \-\-rebuild\-initrd
493-Rebuild initrd (necessary after changing theme).
494-.TP
495-.B \<theme-name\>
496-Name of new theme to use. If you want to see which themes are available, invoke the script with just \-\-list.
497-.PP
498-If plymouth-set-default-theme is invoked with no options or parameters, it shows the currently selected theme
499-by default. This output is used by the helper scripts `plymouth-generate-initrd' and `plymouth-update-initrd'
500-to set the proper theme in the initial ramdisk.
501-.SH SEE ALSO
502-.BR grub (8)
503-.br
504-.SH AUTHOR
505-plymouth was originally prototyped and named by Kristian Høgsberg <krh@bitplanet.net>,
506-originally written by Ray Strode <halfline@gmail.com> and has had significant contributions
507-from Charlie Brej <cbrej@cs.man.ac.uk>. It has also had contributions from
508-Peter Jones <pjones@redhat.com>, Adam Jackson <ajax@nwnk.net>,
509-Frederic Crozat <fcrozat@mandriva.com> and others.
510-It can be downloaded here: <http://www.freedesktop.org/wiki/Software/Plymouth>.
511-.PP
512-This manual page was written by Adrian Glaubitz <glaubitz@physik.fu-berlin.de>.
513diff --git a/docs/plymouth.xml b/docs/plymouth.xml
514new file mode 100644
515index 0000000..0f196c6
516--- /dev/null
517+++ b/docs/plymouth.xml
518@@ -0,0 +1,86 @@
519+<?xml version='1.0'?>
520+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
521+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
522+
523+<refentry id="plymouth">
524+
525+ <refentryinfo>
526+ <title>plymouth</title>
527+ <productname>plymouth</productname>
528+
529+ <authorgroup>
530+ <author>
531+ <contrib>Developer</contrib>
532+ <firstname>Kristian</firstname>
533+ <surname>Høgsberg</surname>
534+ </author>
535+ <author>
536+ <contrib>Developer</contrib>
537+ <firstname>Ray</firstname>
538+ <surname>Strode</surname>
539+ </author>
540+ </authorgroup>
541+
542+ </refentryinfo>
543+
544+ <refmeta>
545+ <refentrytitle>plymouth</refentrytitle>
546+ <manvolnum>8</manvolnum>
547+ <refmiscinfo class="manual">System Administration</refmiscinfo>
548+ </refmeta>
549+
550+ <refnamediv>
551+ <refname>plymouth</refname>
552+ <refpurpose>A graphical boot system and logger</refpurpose>
553+ </refnamediv>
554+
555+ <refsect1>
556+ <title>Description</title>
557+
558+<para>
559+<command>plymouth</command> is a graphical boot system for Linux which takes advantage of
560+the kernel-based mode setting (KMS) available for modern graphic cards
561+to provide a seamless, flickerfree and attractive boot screen. It
562+allows to choose between various, static or animated graphical themes
563+to spruce up the startup and avoid the noise generated by the vast
564+amount of kernel messages while the machine boots into X. On systems
565+where kernel-based mode setting is not available, plymouth falls back
566+to a text mode boot screen which provides a simple progress bar to pro‐
567+vide feedback during boot.
568+</para>
569+<para>
570+In order for the configured default plymouth theme to be loaded during
571+boot, the option `splash' (or `rhgb' for backward compatibility with
572+the RHGB boot splash) must be provided at the kernel command line.
573+Without this command line option, plymouth will default to showing
574+detailed boot output.
575+</para>
576+
577+<para>
578+During the boot process, the user can switch between the graphical theme
579+and the detailed boot output using the Escape key.
580+</para>
581+
582+ </refsect1>
583+
584+ <refsect1>
585+ <title>See Also</title>
586+ <para>
587+ <citerefentry><refentrytitle>grub</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
588+ <citerefentry><refentrytitle>plymouth-set-theme</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
589+ <citerefentry><refentrytitle>plymouthd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
590+ <citerefentry><refentrytitle>plymouth</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
591+ <ulink url="http://www.freedesktop.org/wiki/Software/Plymouth">http://www.freedesktop.org/wiki/Software/Plymouth</ulink>
592+ </para>
593+ </refsect1>
594+
595+ <refsect1>
596+ <title>Authors</title>
597+ <para>
598+plymouth was originally prototyped and named by Kristian Høgsberg,
599+originally written by Ray Strode and has had significant contributions from
600+Charlie Brej. It has also had contributions from Peter Jones, Adam Jackson,
601+Frederic Crozat and others.
602+ </para>
603+ </refsect1>
604+</refentry>
605diff --git a/docs/plymouth1.xml b/docs/plymouth1.xml
606new file mode 100644
607index 0000000..b484599
608--- /dev/null
609+++ b/docs/plymouth1.xml
610@@ -0,0 +1,351 @@
611+<?xml version='1.0'?>
612+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
613+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
614+
615+<refentry id="plymouth-set-default-theme">
616+
617+ <refentryinfo>
618+ <title>plymouth</title>
619+ <productname>plymouth</productname>
620+
621+ <authorgroup>
622+ <author>
623+ <contrib>Developer</contrib>
624+ <firstname>Kristian</firstname>
625+ <surname>Høgsberg</surname>
626+ </author>
627+ <author>
628+ <contrib>Developer</contrib>
629+ <firstname>Ray</firstname>
630+ <surname>Strode</surname>
631+ </author>
632+ </authorgroup>
633+
634+ </refentryinfo>
635+
636+ <refmeta>
637+ <refentrytitle>plymouth</refentrytitle>
638+ <manvolnum>1</manvolnum>
639+ <refmiscinfo class="manual">User Commands</refmiscinfo>
640+ </refmeta>
641+
642+ <refnamediv>
643+ <refname>plymouth</refname>
644+ <refpurpose>Send commands to plymouthd</refpurpose>
645+ </refnamediv>
646+
647+ <refsynopsisdiv>
648+ <cmdsynopsis>
649+ <command>plymouth <arg choice="opt" rep="repeat">OPTION</arg></command>
650+ </cmdsynopsis>
651+ <cmdsynopsis>
652+ <command>plymouth <arg choice="plain">COMMAND <arg choice="opt" rep="repeat">OPTION</arg></arg></command>
653+ </cmdsynopsis>
654+ </refsynopsisdiv>
655+
656+ <refsect1>
657+ <title>Description</title>
658+
659+<para>
660+The <command>plymouth</command> sends commands to a running
661+<command>plymouthd</command>. This is used during the boot
662+process to control the display of the graphical boot splash.
663+</para>
664+
665+ </refsect1>
666+
667+ <refsect1>
668+ <title>Options</title>
669+
670+ <para>
671+The following options are understood. These options are supported
672+for compatibility with the old <command>rhgb-client</command> interface,
673+and have been replaced by the commands that are described in the
674+next section.
675+</para>
676+
677+ <variablelist>
678+ <varlistentry>
679+ <term><option>--help</option></term>
680+ <listitem><para>Show summary of options.</para></listitem>
681+ </varlistentry>
682+
683+ <varlistentry>
684+ <term><option>--debug</option></term>
685+ <listitem><para>Enable verbose debug logging.</para></listitem>
686+ </varlistentry>
687+
688+ <varlistentry>
689+ <term><option>--get-splash-plugin-path</option></term>
690+ <listitem><para>Get directory where splash plugins are installed.</para></listitem>
691+ </varlistentry>
692+
693+ <varlistentry>
694+ <term><option>--newroot=<arg>STRING</arg></option></term>
695+ <listitem><para>Tell plymouthd that the new root filesystem is mounted.</para></listitem>
696+ </varlistentry>
697+
698+ <varlistentry>
699+ <term><option>--quit</option></term>
700+ <listitem><para>Tell plymouthd to quit.</para></listitem>
701+ </varlistentry>
702+
703+ <varlistentry>
704+ <term><option>--ping</option></term>
705+ <listitem><para>Check if plymouthd is running.</para></listitem>
706+ </varlistentry>
707+
708+ <varlistentry>
709+ <term><option>--has-active-vt</option></term>
710+ <listitem><para>Check if plymouthd has an active vt.</para></listitem>
711+ </varlistentry>
712+
713+ <varlistentry>
714+ <term><option>--sysinit</option></term>
715+ <listitem><para>Tell plymouthd root filesystem is mounted read-write.</para></listitem>
716+ </varlistentry>
717+
718+ <varlistentry>
719+ <term><option>--show-splash</option></term>
720+ <listitem><para>Show the splash screen.</para></listitem>
721+ </varlistentry>
722+
723+ <varlistentry>
724+ <term><option>--hide-splash</option></term>
725+ <listitem><para>Hide the splash screen.</para></listitem>
726+ </varlistentry>
727+
728+ <varlistentry>
729+ <term><option>--ask-for-password</option></term>
730+ <listitem><para>Ask the user for a password.</para></listitem>
731+ </varlistentry>
732+
733+ <varlistentry>
734+ <term><option>--ignore-keystroke=<arg>STRING</arg></option></term>
735+ <listitem><para>Remove sensitivity to a keystroke.</para></listitem>
736+ </varlistentry>
737+
738+ <varlistentry>
739+ <term><option>--update=<arg>STRING</arg></option></term>
740+ <listitem><para>Tell plymouthd an update about boot progress.</para></listitem>
741+ </varlistentry>
742+
743+ <varlistentry>
744+ <term><option>--details</option></term>
745+ <listitem><para>Tell plymouthd there were errors during boot.</para></listitem>
746+ </varlistentry>
747+
748+ <varlistentry>
749+ <term><option>--wait</option></term>
750+ <listitem><para>Wait for plymouthd to quit.</para></listitem>
751+ </varlistentry>
752+ </variablelist>
753+ </refsect1>
754+
755+ <refsect1>
756+ <title>Commands</title>
757+
758+<para>
759+The following commands are understood:
760+</para>
761+ <variablelist>
762+ <varlistentry>
763+ <term><command>change-mode <arg choice="plain">OPTION</arg></command></term>
764+ <listitem><para>Change the operation mode.</para>
765+<variablelist>
766+<varlistentry>
767+ <term><option>--boot-up</option></term>
768+ <listitem><para>Start the system up</para></listitem>
769+</varlistentry>
770+<varlistentry>
771+ <term><option>--shutdown</option></term>
772+ <listitem><para>Shutting the system up</para></listitem>
773+</varlistentry>
774+<varlistentry>
775+ <term><option>--updates</option></term>
776+ <listitem><para>Applying updates</para></listitem>
777+</varlistentry>
778+</variablelist>
779+</listitem>
780+ </varlistentry>
781+ <varlistentry>
782+ <term><command>system-update <arg choice="plain">OPTION</arg></command></term>
783+ <listitem><para>Tell plymouthd about boot progress.</para>
784+<variablelist>
785+<varlistentry>
786+ <term><option>--progress=INTEGER</option></term>
787+ <listitem><para>The percentage progress of the updates</para></listitem>
788+</varlistentry>
789+</variablelist>
790+</listitem>
791+ </varlistentry>
792+ <varlistentry>
793+ <term><command>update <arg choice="plain">OPTION</arg></command></term>
794+ <listitem><para>Tell plymouthd about boot status changes.</para>
795+<variablelist>
796+<varlistentry>
797+ <term><option>--status=STRING</option></term>
798+ <listitem><para>Tell plymouthd the current boot status</para></listitem>
799+</varlistentry>
800+</variablelist>
801+</listitem>
802+ </varlistentry>
803+ <varlistentry>
804+ <term><command>update-root-fs <arg choice="plain">OPTION</arg></command></term>
805+ <listitem><para>Tell plymouthd about root filesystem changes.</para>
806+<variablelist>
807+<varlistentry>
808+ <term><option>--new-root-dir=STRING</option></term>
809+ <listitem><para>Root filesystem is about to change</para></listitem>
810+</varlistentry>
811+<varlistentry>
812+ <term><option>--read-write</option></term>
813+ <listitem><para>Root filesystem is no longer read-only</para></listitem>
814+</varlistentry>
815+</variablelist>
816+</listitem>
817+ </varlistentry>
818+ <varlistentry>
819+ <term><command>show-splash</command></term>
820+ <listitem><para>Tell plymouthd to show splash screen.</para></listitem>
821+ </varlistentry>
822+ <varlistentry>
823+ <term><command>hide-splash</command></term>
824+ <listitem><para>Tell plymouthd to hide splash screen.</para></listitem>
825+ </varlistentry>
826+ <varlistentry>
827+ <term><command>ask-for-password <arg choice="plain">OPTION</arg></command></term>
828+ <listitem><para>Ask the user for a password.</para>
829+<variablelist>
830+<varlistentry>
831+ <term><option>--command=STRING</option></term>
832+ <listitem><para>Command to send password to via standard input</para></listitem>
833+</varlistentry>
834+<varlistentry>
835+ <term><option>--prompt=STRING</option></term>
836+ <listitem><para>Message to display when asking for password</para></listitem>
837+</varlistentry>
838+<varlistentry>
839+ <term><option>--number-of-tries=INTEGER</option></term>
840+ <listitem><para>Number of times to ask before giving up (requires <option>--command</option>)</para></listitem>
841+</varlistentry>
842+<varlistentry>
843+ <term><option>--dont-pause-progress</option></term>
844+ <listitem><para>Don't pause boot progress bar while asking</para></listitem>
845+</varlistentry>
846+</variablelist>
847+</listitem>
848+ </varlistentry>
849+ <varlistentry>
850+ <term><command>ask-question</command></term>
851+ <listitem><para>Ask the user a question.</para>
852+<variablelist>
853+<varlistentry>
854+ <term><option>--command=STRING</option></term>
855+ <listitem><para>Command to send the answer to via standard input</para></listitem>
856+</varlistentry>
857+<varlistentry>
858+ <term><option>--prompt=STRING</option></term>
859+ <listitem><para>Message to display when asking the question</para></listitem>
860+</varlistentry>
861+<varlistentry>
862+ <term><option>--dont-pause-progress</option></term>
863+ <listitem><para>Don't pause boot progress bar while asking</para></listitem>
864+</varlistentry>
865+</variablelist>
866+</listitem>
867+ </varlistentry>
868+ <varlistentry>
869+ <term><command>display-message <arg choice="plain">OPTION</arg></command></term>
870+ <listitem><para>Display a message.</para>
871+<variablelist>
872+<varlistentry>
873+ <term><option>--text=STRING</option></term>
874+ <listitem><para>The message text</para></listitem>
875+</varlistentry>
876+</variablelist>
877+</listitem>
878+ </varlistentry>
879+ <varlistentry>
880+ <term><command>hide-message <arg choice="plain">OPTION</arg></command></term>
881+ <listitem><para>Hide a message.</para>
882+<variablelist>
883+<varlistentry>
884+ <term><option>--text=STRING</option></term>
885+ <listitem><para>The message text</para></listitem>
886+</varlistentry>
887+</variablelist>
888+</listitem>
889+ </varlistentry>
890+ <varlistentry>
891+ <term><command>watch-keystroke <arg choice="plain">OPTION</arg></command></term>
892+ <listitem><para>Become sensitive to a keystroke.</para>
893+<variablelist>
894+<varlistentry>
895+ <term><option>--command=STRING</option></term>
896+ <listitem><para>Command to send keystroke to via standard input</para></listitem>
897+</varlistentry>
898+<varlistentry>
899+ <term><option>--keys=STRING</option></term>
900+ <listitem><para>Keys to become sensitive to</para></listitem>
901+</varlistentry>
902+</variablelist>
903+</listitem>
904+ </varlistentry>
905+ <varlistentry>
906+ <term><command>ignore-keystroke <arg choice="plain">OPTION</arg></command></term>
907+ <listitem><para>Remove sensitivity to a keystroke.</para>
908+<variablelist>
909+<varlistentry>
910+ <term><option>--keys=STRING</option></term>
911+ <listitem><para>Keys to remove sensitivitiy from</para></listitem>
912+</varlistentry>
913+</variablelist>
914+</listitem>
915+ </varlistentry>
916+ <varlistentry>
917+ <term><command>pause-progress</command></term>
918+ <listitem><para>Pause boot progress bar.</para></listitem>
919+ </varlistentry>
920+ <varlistentry>
921+ <term><command>unpause-progress</command></term>
922+ <listitem><para>Unpause boot progress bar.</para></listitem>
923+ </varlistentry>
924+ <varlistentry>
925+ <term><command>report-error</command></term>
926+ <listitem><para>Tell plymouthd there were errors during boot.</para></listitem>
927+ </varlistentry>
928+ <varlistentry>
929+ <term><command>deactivate</command></term>
930+ <listitem><para>Tell plymouthd to deactivate.</para></listitem>
931+ </varlistentry>
932+ <varlistentry>
933+ <term><command>reactivate</command></term>
934+ <listitem><para>Tell plymouthd to reactivate.</para></listitem>
935+ </varlistentry>
936+ <varlistentry>
937+ <term><command>quit <arg choice="plain">OPTION</arg></command></term>
938+ <listitem><para>Tell plymouthd to quit.</para>
939+<variablelist>
940+<varlistentry>
941+ <term><option>--retain-splash</option></term>
942+ <listitem><para>Don't explicitly hide boot splash on exit</para></listitem>
943+</varlistentry>
944+</variablelist>
945+</listitem>
946+ </varlistentry>
947+ </variablelist>
948+
949+ </refsect1>
950+
951+ <refsect1>
952+ <title>See Also</title>
953+ <para>
954+ <citerefentry><refentrytitle>grub</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
955+ <citerefentry><refentrytitle>plymouth</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
956+ <citerefentry><refentrytitle>plymouthd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
957+ <ulink url="http://www.freedesktop.org/wiki/Software/Plymouth">http://www.freedesktop.org/wiki/Software/Plymouth</ulink>
958+ </para>
959+ </refsect1>
960+
961+</refentry>
962diff --git a/docs/plymouthd.xml b/docs/plymouthd.xml
963new file mode 100644
964index 0000000..4e7e499
965--- /dev/null
966+++ b/docs/plymouthd.xml
967@@ -0,0 +1,121 @@
968+<?xml version='1.0'?>
969+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
970+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
971+
972+<refentry id="plymouthd">
973+
974+ <refentryinfo>
975+ <title>plymouthd</title>
976+ <productname>plymouth</productname>
977+
978+ <authorgroup>
979+ <author>
980+ <contrib>Developer</contrib>
981+ <firstname>Kristian</firstname>
982+ <surname>Høgsberg</surname>
983+ </author>
984+ <author>
985+ <contrib>Developer</contrib>
986+ <firstname>Ray</firstname>
987+ <surname>Strode</surname>
988+ </author>
989+ </authorgroup>
990+
991+ </refentryinfo>
992+
993+ <refmeta>
994+ <refentrytitle>plymouthd</refentrytitle>
995+ <manvolnum>8</manvolnum>
996+ <refmiscinfo class="manual">System Administration</refmiscinfo>
997+ </refmeta>
998+
999+ <refnamediv>
1000+ <refname>plymouthd</refname>
1001+ <refpurpose>The plymouth daemon</refpurpose>
1002+ </refnamediv>
1003+
1004+ <refsynopsisdiv>
1005+ <cmdsynopsis>
1006+ <command>plymouthd <arg choice="opt" rep="repeat">OPTION</arg></command>
1007+ </cmdsynopsis>
1008+ </refsynopsisdiv>
1009+
1010+ <refsect1>
1011+ <title>Description</title>
1012+
1013+<para>
1014+The <command>plymouthd</command> daemon is usually run out of
1015+the initrd. It does the heavy lifting of the plymouth system, logging
1016+the session and showing the splash screen.
1017+</para>
1018+<para>
1019+The <command>plymouth</command> is used to send commands to plymouthd
1020+that control its behaviour.
1021+</para>
1022+
1023+ </refsect1>
1024+
1025+ <refsect1>
1026+ <title>Options</title>
1027+
1028+ <para>The following options are understood:</para>
1029+
1030+ <variablelist>
1031+ <varlistentry>
1032+ <term><option>--help</option></term>
1033+ <listitem><para>Show summary of options.</para></listitem>
1034+ </varlistentry>
1035+
1036+ <varlistentry>
1037+ <term><option>--attach-to-session</option></term>
1038+ <listitem><para>Redirect console messages from screen to log.</para></listitem>
1039+ </varlistentry>
1040+
1041+ <varlistentry>
1042+ <term><option>--no-daemon</option></term>
1043+ <listitem><para>Do not daemonize.</para></listitem>
1044+ </varlistentry>
1045+
1046+ <varlistentry>
1047+ <term><option>--debug</option></term>
1048+ <listitem><para>Output debugging information.</para></listitem>
1049+ </varlistentry>
1050+
1051+ <varlistentry>
1052+ <term><option>--debug-file=STRING</option></term>
1053+ <listitem><para>File to write debugging information to.</para></listitem>
1054+ </varlistentry>
1055+
1056+ <varlistentry>
1057+ <term><option>--mode=MODE</option></term>
1058+ <listitem><para>Set mode to either boot or shutdown.</para></listitem>
1059+ </varlistentry>
1060+
1061+ <varlistentry>
1062+ <term><option>--pid-file=STRING</option></term>
1063+ <listitem><para>Write the PID of the daemon to a file.</para></listitem>
1064+ </varlistentry>
1065+
1066+ <varlistentry>
1067+ <term><option>--kernel-command-line=STRING</option></term>
1068+ <listitem><para>Fake kernel commandline to use.</para></listitem>
1069+ </varlistentry>
1070+
1071+ <varlistentry>
1072+ <term><option>--tty=STRING</option></term>
1073+ <listitem><para>TTY to ues instead of default.</para></listitem>
1074+ </varlistentry>
1075+ </variablelist>
1076+ </refsect1>
1077+
1078+ <refsect1>
1079+ <title>See Also</title>
1080+ <para>
1081+ <citerefentry><refentrytitle>grub</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1082+ <citerefentry><refentrytitle>plymouth</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1083+ <citerefentry><refentrytitle>plymouth</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1084+ <ulink url="http://www.freedesktop.org/wiki/Software/Plymouth">http://www.freedesktop.org/wiki/Software/Plymouth</ulink>
1085+ </para>
1086+ </refsect1>
1087+
1088+</refentry>
1089diff --git a/scripts/plymouth-generate-initrd.in b/scripts/plymouth-generate-initrd.in
1090index 35509a1..c44ca4c 100755
1091--- a/scripts/plymouth-generate-initrd.in
1092+++ b/scripts/plymouth-generate-initrd.in
1093@@ -13,11 +13,12 @@ PLYMOUTH_INITRD_DIR="$(mktemp --tmpdir -d plymouth-XXXXXXX)"
1094 $PLYMOUTH_POPULATE_INITRD -t "$PLYMOUTH_INITRD_DIR"
1095
1096 if [ $? -eq 0 ]; then
1097+ command -v pigz &>/dev/null && gzip=pigz || gzip=gzip
1098 (cd $PLYMOUTH_INITRD_DIR;
1099 # FIXME: might make sense to add a flag to plymouth-populate-initrd to
1100 # skip these from the start
1101 rm -f lib*/{ld*,libc*,libdl*,libm*,libz*,libpthread*}
1102- find | cpio -Hnewc -o | gzip -9 > $PLYMOUTH_IMAGE_FILE
1103+ find | cpio -Hnewc -o | $gzip -9 > $PLYMOUTH_IMAGE_FILE
1104 )
1105 fi
1106
1107diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in
1108index 8d1eec0..43c7f22 100755
1109--- a/scripts/plymouth-populate-initrd.in
1110+++ b/scripts/plymouth-populate-initrd.in
1111@@ -8,6 +8,7 @@
1112 [ -z "$PLYMOUTH_DATADIR" ] && PLYMOUTH_DATADIR="@PLYMOUTH_DATADIR@"
1113 [ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
1114 [ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@PLYMOUTH_LOGO_FILE@"
1115+[ -n "$PLYMOUTH_THEME_NAME" ] && THEME_OVERRIDE=1
1116 [ -z "$PLYMOUTH_THEME_NAME" ] && PLYMOUTH_THEME_NAME=$(plymouth-set-default-theme)
1117 [ -z "$PLYMOUTH_CONFDIR" ] && PLYMOUTH_CONFDIR="@PLYMOUTH_CONF_DIR@"
1118 [ -z "$PLYMOUTH_POLICYDIR" ] && PLYMOUTH_POLICYDIR="@PLYMOUTH_POLICY_DIR@"
1119@@ -372,8 +373,8 @@ done
1120 [ -z "$INITRDDIR" ] && usage error
1121
1122 mkdir -p ${INITRDDIR}${PLYMOUTH_DATADIR}/plymouth/themes
1123-inst ${PLYMOUTH_DAEMON_PATH} $INITRDDIR /sbin/plymouthd
1124-inst ${PLYMOUTH_CLIENT_PATH} $INITRDDIR /bin/plymouth
1125+inst ${PLYMOUTH_DAEMON_PATH} $INITRDDIR
1126+inst ${PLYMOUTH_CLIENT_PATH} $INITRDDIR
1127 inst ${PLYMOUTH_DATADIR}/plymouth/themes/text/text.plymouth $INITRDDIR
1128 inst ${PLYMOUTH_PLUGIN_PATH}/text.so $INITRDDIR
1129 inst ${PLYMOUTH_DATADIR}/plymouth/themes/details/details.plymouth $INITRDDIR
1130@@ -388,6 +389,12 @@ if [ -z "$PLYMOUTH_THEME_NAME" ]; then
1131 exit 1
1132 fi
1133
1134+if [ $THEME_OVERRIDE ]; then
1135+ conf=$INITRDDIR/${PLYMOUTH_CONFDIR}/plymouthd.conf
1136+ echo "modifying plymouthd.conf: Theme=$PLYMOUTH_THEME_NAME" > /dev/stderr
1137+ sed -i "s/^ *Theme *=.*/# theme modified by plymouth-populate-initrd\nTheme=$PLYMOUTH_THEME_NAME/" $conf
1138+fi
1139+
1140 PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')
1141
1142 if [ ! -f ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so ]; then
1143@@ -425,6 +432,7 @@ if [ -n "$SYSTEMD_UNIT_DIR" -a -d "$SYSTEMD_UNIT_DIR" ]; then
1144 inst $SYSTEMD_UNIT_DIR/plymouth-halt.service $INITRDDIR
1145
1146 inst $SYSTEMD_UNIT_DIR/initrd-switch-root.target.wants/plymouth-switch-root.service $INITRDDIR
1147+ inst $SYSTEMD_UNIT_DIR/initrd-switch-root.target.wants/plymouth-start.service $INITRDDIR
1148 inst $SYSTEMD_UNIT_DIR/sysinit.target.wants/plymouth-start.service $INITRDDIR
1149 inst $SYSTEMD_UNIT_DIR/multi-user.target.wants/plymouth-quit.service $INITRDDIR
1150 inst $SYSTEMD_UNIT_DIR/multi-user.target.wants/plymouth-quit-wait.service $INITRDDIR
1151diff --git a/scripts/plymouth-update-initrd b/scripts/plymouth-update-initrd
1152index 1403b8b..4ed5709 100755
1153--- a/scripts/plymouth-update-initrd
1154+++ b/scripts/plymouth-update-initrd
1155@@ -1,2 +1,2 @@
1156 #!/bin/bash
1157-mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)
1158+dracut -f
1159diff --git a/src/Makefile.am b/src/Makefile.am
1160index a9e6eb1..fc2f5da 100644
1161--- a/src/Makefile.am
1162+++ b/src/Makefile.am
1163@@ -1,8 +1,8 @@
1164-SUBDIRS = libply libply-splash-core libply-splash-graphics . plugins client viewer tests
1165+SUBDIRS = libply libply-splash-core libply-splash-graphics . plugins client viewer
1166 if ENABLE_UPSTART_MONITORING
1167 SUBDIRS += upstart-bridge
1168 endif
1169-INCLUDES = -I$(top_srcdir) \
1170+AM_CPPFLAGS = -I$(top_srcdir) \
1171 -I$(srcdir)/libply \
1172 -I$(srcdir)/libply-splash-core \
1173 -I$(srcdir) \
1174@@ -15,6 +15,7 @@ plymouthdbindir = $(plymouthdaemondir)
1175 plymouthdbin_PROGRAMS = plymouthd
1176
1177 plymouthd_CFLAGS = $(PLYMOUTH_CFLAGS) \
1178+ -rdynamic \
1179 -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\" \
1180 -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\" \
1181 -DPLYMOUTH_POLICY_DIR=\"$(PLYMOUTH_POLICY_DIR)/\" \
1182diff --git a/src/client/Makefile.am b/src/client/Makefile.am
1183index 9487901..83b19cc 100644
1184--- a/src/client/Makefile.am
1185+++ b/src/client/Makefile.am
1186@@ -1,6 +1,4 @@
1187-SUBDIRS = . tests
1188-
1189-INCLUDES = -I$(top_srcdir) \
1190+AM_CPPFLAGS = -I$(top_srcdir) \
1191 -I$(top_srcdir)/src \
1192 -I$(top_srcdir)/src/libply \
1193 -I$(srcdir)
1194diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c
1195index 56458ce..3480676 100644
1196--- a/src/client/ply-boot-client.c
1197+++ b/src/client/ply-boot-client.c
1198@@ -869,137 +869,4 @@ ply_boot_client_attach_to_event_loop (ply_boot_client_t *client,
1199
1200 }
1201
1202-#ifdef PLY_BOOT_CLIENT_ENABLE_TEST
1203-
1204-#include <stdio.h>
1205-
1206-#include "ply-event-loop.h"
1207-#include "ply-boot-client.h"
1208-
1209-static void
1210-on_pinged (ply_event_loop_t *loop)
1211-{
1212- printf ("PING!\n");
1213-}
1214-
1215-static void
1216-on_ping_failed (ply_event_loop_t *loop)
1217-{
1218- printf ("PING FAILED! %m\n");
1219- ply_event_loop_exit (loop, 1);
1220-}
1221-
1222-static void
1223-on_update (ply_event_loop_t *loop)
1224-{
1225- printf ("UPDATE!\n");
1226-}
1227-
1228-static void
1229-on_update_failed (ply_event_loop_t *loop)
1230-{
1231- printf ("UPDATE FAILED! %m\n");
1232- ply_event_loop_exit (loop, 1);
1233-}
1234-
1235-static void
1236-on_newroot (ply_event_loop_t *loop)
1237-{
1238- printf ("NEWROOT!\n");
1239-}
1240-
1241-static void
1242-on_system_initialized (ply_event_loop_t *loop)
1243-{
1244- printf ("SYSTEM INITIALIZED!\n");
1245-}
1246-
1247-static void
1248-on_system_initialized_failed (ply_event_loop_t *loop)
1249-{
1250- printf ("SYSTEM INITIALIZATION REQUEST FAILED!\n");
1251- ply_event_loop_exit (loop, 1);
1252-}
1253-
1254-static void
1255-on_quit (ply_event_loop_t *loop)
1256-{
1257- printf ("QUIT!\n");
1258- ply_event_loop_exit (loop, 0);
1259-}
1260-
1261-static void
1262-on_quit_failed (ply_event_loop_t *loop)
1263-{
1264- printf ("QUIT FAILED! %m\n");
1265- ply_event_loop_exit (loop, 2);
1266-}
1267-
1268-static void
1269-on_disconnect (ply_event_loop_t *loop)
1270-{
1271- printf ("DISCONNECT!\n");
1272- ply_event_loop_exit (loop, 1);
1273-}
1274-
1275-int
1276-main (int argc,
1277- char **argv)
1278-{
1279- ply_event_loop_t *loop;
1280- ply_boot_client_t *client;
1281- int exit_code;
1282-
1283- exit_code = 0;
1284-
1285- loop = ply_event_loop_new ();
1286-
1287- client = ply_boot_client_new ();
1288-
1289- if (!ply_boot_client_connect (client,
1290- (ply_boot_client_disconnect_handler_t) on_disconnect,
1291- loop))
1292- {
1293- perror ("could not start boot client");
1294- return errno;
1295- }
1296-
1297- ply_boot_client_attach_to_event_loop (client, loop);
1298- ply_boot_client_ping_daemon (client,
1299- (ply_boot_client_response_handler_t) on_pinged,
1300- (ply_boot_client_response_handler_t) on_ping_failed,
1301- loop);
1302-
1303- ply_boot_client_update_daemon (client,
1304- "loading",
1305- (ply_boot_client_response_handler_t) on_update,
1306- (ply_boot_client_response_handler_t) on_update_failed,
1307- loop);
1308-
1309- ply_boot_client_update_daemon (client,
1310- "loading more",
1311- (ply_boot_client_response_handler_t) on_update,
1312- (ply_boot_client_response_handler_t) on_update_failed,
1313- loop);
1314-
1315- ply_boot_client_tell_daemon_system_is_initialized (client,
1316- (ply_boot_client_response_handler_t)
1317- on_system_initialized,
1318- (ply_boot_client_response_handler_t)
1319- on_system_initialized_failed,
1320- loop);
1321-
1322- ply_boot_client_tell_daemon_to_quit (client,
1323- (ply_boot_client_response_handler_t) on_quit,
1324- (ply_boot_client_response_handler_t) on_quit_failed,
1325- loop);
1326-
1327- exit_code = ply_event_loop_run (loop);
1328-
1329- ply_boot_client_free (client);
1330-
1331- return exit_code;
1332-}
1333-
1334-#endif /* PLY_BOOT_CLIENT_ENABLE_TEST */
1335 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
1336diff --git a/src/client/plymouth.c b/src/client/plymouth.c
1337index e00208d..b22e90c 100644
1338--- a/src/client/plymouth.c
1339+++ b/src/client/plymouth.c
1340@@ -1173,7 +1173,8 @@ main (int argc,
1341
1342 if (get_kernel_command_line (&state))
1343 {
1344- if (strstr (state.kernel_command_line, "plymouth:debug") != NULL
1345+ if ((strstr (state.kernel_command_line, "plymouth.debug") != NULL ||
1346+ strstr (state.kernel_command_line, "plymouth:debug") != NULL)
1347 && !ply_is_tracing ())
1348 ply_toggle_tracing ();
1349 }
1350diff --git a/src/client/tests/Makefile.am b/src/client/tests/Makefile.am
1351deleted file mode 100644
1352index c6dbfdb..0000000
1353--- a/src/client/tests/Makefile.am
1354+++ /dev/null
1355@@ -1,10 +0,0 @@
1356-INCLUDES = \
1357- -I$(top_srcdir) \
1358- -I$(srcdir)/.. \
1359- -I$(srcdir)/../.. \
1360- -I$(srcdir)
1361-TESTS =
1362-
1363-noinst_PROGRAMS = $(TESTS)
1364-
1365-MAINTAINERCLEANFILES = Makefile.in
1366diff --git a/src/libply-splash-core/Makefile.am b/src/libply-splash-core/Makefile.am
1367index b289b65..d07d7f1 100644
1368--- a/src/libply-splash-core/Makefile.am
1369+++ b/src/libply-splash-core/Makefile.am
1370@@ -1,4 +1,4 @@
1371-INCLUDES = -I$(top_srcdir) \
1372+AM_CPPFLAGS = -I$(top_srcdir) \
1373 -I$(srcdir) \
1374 -I$(srcdir)/../libply \
1375 -I$(srcdir)/../plugins/controls
1376@@ -15,33 +15,39 @@ libply_splash_coredir = $(includedir)/plymouth-1/ply-splash-core
1377 libply_splash_core_HEADERS = \
1378 ply-boot-splash.h \
1379 ply-boot-splash-plugin.h \
1380+ ply-device-manager.h \
1381 ply-keyboard.h \
1382 ply-pixel-buffer.h \
1383 ply-pixel-display.h \
1384 ply-renderer.h \
1385 ply-renderer-plugin.h \
1386+ ply-seat.h \
1387 ply-terminal.h \
1388 ply-text-display.h \
1389- ply-text-progress-bar.h
1390+ ply-text-progress-bar.h \
1391+ ply-text-step-bar.h
1392
1393-libply_splash_core_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
1394+libply_splash_core_la_CFLAGS = $(PLYMOUTH_CFLAGS) $(UDEV_CFLAGS) \
1395 -DPLYMOUTH_BACKGROUND_COLOR=$(background_color) \
1396 -DPLYMOUTH_BACKGROUND_END_COLOR=$(background_end_color) \
1397 -DPLYMOUTH_BACKGROUND_START_COLOR=$(background_start_color) \
1398 -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\"
1399-libply_splash_core_la_LIBADD = $(PLYMOUTH_LIBS) ../libply/libply.la
1400+libply_splash_core_la_LIBADD = $(PLYMOUTH_LIBS) $(UDEV_LIBS) ../libply/libply.la
1401 libply_splash_core_la_LDFLAGS = -export-symbols-regex '^[^_].*' \
1402 -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
1403 -no-undefined
1404 libply_splash_core_la_SOURCES = \
1405 $(libply_splash_core_HEADERS) \
1406+ ply-device-manager.c \
1407 ply-keyboard.c \
1408 ply-pixel-display.c \
1409 ply-text-display.c \
1410 ply-text-progress-bar.c \
1411+ ply-text-step-bar.c \
1412 ply-terminal.c \
1413 ply-pixel-buffer.c \
1414 ply-renderer.c \
1415+ ply-seat.c \
1416 ply-boot-splash.c
1417
1418 MAINTAINERCLEANFILES = Makefile.in
1419diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c
1420index 93d9345..160ce45 100644
1421--- a/src/libply-splash-core/ply-boot-splash.c
1422+++ b/src/libply-splash-core/ply-boot-splash.c
1423@@ -48,10 +48,6 @@
1424 #define UPDATES_PER_SECOND 30
1425 #endif
1426
1427-#define KEY_CTRL_L ('\100' ^'L')
1428-#define KEY_CTRL_T ('\100' ^'T')
1429-#define KEY_CTRL_V ('\100' ^'V')
1430-
1431 struct _ply_boot_splash
1432 {
1433 ply_event_loop_t *loop;
1434@@ -59,11 +55,9 @@ struct _ply_boot_splash
1435 const ply_boot_splash_plugin_interface_t *plugin_interface;
1436 ply_boot_splash_plugin_t *plugin;
1437 ply_boot_splash_mode_t mode;
1438- ply_keyboard_t *keyboard;
1439 ply_buffer_t *boot_buffer;
1440 ply_trigger_t *idle_trigger;
1441- ply_list_t *pixel_displays;
1442- ply_list_t *text_displays;
1443+ ply_list_t *seats;
1444
1445 char *theme_path;
1446 char *plugin_dir;
1447@@ -100,18 +94,30 @@ ply_boot_splash_new (const char *theme_path,
1448 splash->mode = PLY_BOOT_SPLASH_MODE_INVALID;
1449
1450 splash->boot_buffer = boot_buffer;
1451- splash->pixel_displays = ply_list_new ();
1452- splash->text_displays = ply_list_new ();
1453+ splash->seats = ply_list_new ();
1454
1455 return splash;
1456 }
1457
1458 static void
1459-refresh_displays (ply_boot_splash_t *splash)
1460+detach_from_seat (ply_boot_splash_t *splash,
1461+ ply_seat_t *seat)
1462 {
1463- ply_list_node_t *node;
1464+ ply_keyboard_t *keyboard;
1465+ ply_list_t *displays;
1466+ ply_list_node_t *node, *next_node;
1467
1468- node = ply_list_get_first_node (splash->pixel_displays);
1469+ ply_trace ("removing keyboard");
1470+ if (splash->plugin_interface->unset_keyboard != NULL)
1471+ {
1472+ keyboard = ply_seat_get_keyboard (seat);
1473+ splash->plugin_interface->unset_keyboard (splash->plugin, keyboard);
1474+ }
1475+
1476+ ply_trace ("removing pixel displays");
1477+ displays = ply_seat_get_pixel_displays (seat);
1478+
1479+ node = ply_list_get_first_node (displays);
1480 while (node != NULL)
1481 {
1482 ply_pixel_display_t *display;
1483@@ -119,184 +125,137 @@ refresh_displays (ply_boot_splash_t *splash)
1484 unsigned long width, height;
1485
1486 display = ply_list_node_get_data (node);
1487- next_node = ply_list_get_next_node (splash->pixel_displays, node);
1488+ next_node = ply_list_get_next_node (displays, node);
1489
1490 width = ply_pixel_display_get_width (display);
1491 height = ply_pixel_display_get_height (display);
1492
1493- ply_pixel_display_draw_area (display, 0, 0, width, height);
1494+ ply_trace ("Removing %lux%lu pixel display", width, height);
1495+
1496+ if (splash->plugin_interface->remove_pixel_display != NULL)
1497+ splash->plugin_interface->remove_pixel_display (splash->plugin, display);
1498+
1499 node = next_node;
1500 }
1501
1502- node = ply_list_get_first_node (splash->text_displays);
1503+ ply_trace ("removing text displays");
1504+ displays = ply_seat_get_text_displays (seat);
1505+
1506+ node = ply_list_get_first_node (displays);
1507 while (node != NULL)
1508 {
1509 ply_text_display_t *display;
1510- ply_list_node_t *next_node;
1511 int number_of_columns, number_of_rows;
1512
1513 display = ply_list_node_get_data (node);
1514- next_node = ply_list_get_next_node (splash->text_displays, node);
1515+ next_node = ply_list_get_next_node (displays, node);
1516
1517 number_of_columns = ply_text_display_get_number_of_columns (display);
1518 number_of_rows = ply_text_display_get_number_of_rows (display);
1519
1520- ply_text_display_draw_area (display, 0, 0,
1521- number_of_columns,
1522- number_of_rows);
1523+ ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
1524+
1525+ if (splash->plugin_interface->remove_text_display != NULL)
1526+ splash->plugin_interface->remove_text_display (splash->plugin, display);
1527+
1528 node = next_node;
1529 }
1530 }
1531
1532-static ply_terminal_t *
1533-find_local_console_terminal (ply_boot_splash_t *splash)
1534+static void
1535+attach_to_seat (ply_boot_splash_t *splash,
1536+ ply_seat_t *seat)
1537 {
1538- ply_list_node_t *node;
1539- node = ply_list_get_first_node (splash->text_displays);
1540+ ply_keyboard_t *keyboard;
1541+ ply_list_t *displays;
1542+ ply_list_node_t *node, *next_node;
1543
1544- while (node != NULL)
1545+ if (splash->plugin_interface->set_keyboard != NULL)
1546 {
1547- ply_text_display_t *display;
1548- ply_terminal_t *terminal;
1549- ply_list_node_t *next_node;
1550+ keyboard = ply_seat_get_keyboard (seat);
1551+ splash->plugin_interface->set_keyboard (splash->plugin, keyboard);
1552+ }
1553
1554- display = ply_list_node_get_data (node);
1555- next_node = ply_list_get_next_node (splash->text_displays, node);
1556+ if (splash->plugin_interface->add_pixel_display != NULL)
1557+ {
1558+ displays = ply_seat_get_pixel_displays (seat);
1559
1560- terminal = ply_text_display_get_terminal (display);
1561+ ply_trace ("adding pixel displays");
1562+ node = ply_list_get_first_node (displays);
1563+ while (node != NULL)
1564+ {
1565+ ply_pixel_display_t *display;
1566+ ply_list_node_t *next_node;
1567+ unsigned long width, height;
1568
1569- if (terminal != NULL && ply_terminal_is_vt (terminal))
1570- return terminal;
1571+ display = ply_list_node_get_data (node);
1572+ next_node = ply_list_get_next_node (displays, node);
1573
1574- node = next_node;
1575- }
1576+ width = ply_pixel_display_get_width (display);
1577+ height = ply_pixel_display_get_height (display);
1578
1579- return NULL;
1580-}
1581+ ply_trace ("Adding %lux%lu pixel display", width, height);
1582
1583-static void
1584-on_keyboard_input (ply_boot_splash_t *splash,
1585- const char *keyboard_input,
1586- size_t character_size)
1587-{
1588- wchar_t key;
1589+ splash->plugin_interface->add_pixel_display (splash->plugin, display);
1590
1591- if ((ssize_t) mbrtowc (&key, keyboard_input, character_size, NULL) > 0)
1592- {
1593- switch (key)
1594- {
1595- case KEY_CTRL_L:
1596- refresh_displays (splash);
1597- return;
1598-
1599- case KEY_CTRL_T:
1600- ply_trace ("toggle text mode!");
1601- splash->should_force_text_mode = !splash->should_force_text_mode;
1602-
1603- if (ply_list_get_length (splash->pixel_displays) >= 1)
1604- {
1605- ply_terminal_t *terminal;
1606-
1607- terminal = find_local_console_terminal (splash);
1608-
1609- if (terminal != NULL)
1610- {
1611- if (splash->should_force_text_mode)
1612- {
1613- ply_terminal_set_mode (terminal, PLY_TERMINAL_MODE_TEXT);
1614- ply_terminal_ignore_mode_changes (terminal, true);
1615- }
1616- else
1617- ply_terminal_ignore_mode_changes (terminal, false);
1618- }
1619- }
1620- ply_trace ("text mode toggled!");
1621- return;
1622-
1623- case KEY_CTRL_V:
1624- ply_trace ("toggle verbose mode!");
1625- ply_toggle_tracing ();
1626- ply_trace ("verbose mode toggled!");
1627- return;
1628+ node = next_node;
1629 }
1630 }
1631-}
1632
1633-void
1634-ply_boot_splash_set_keyboard (ply_boot_splash_t *splash,
1635- ply_keyboard_t *keyboard)
1636-{
1637- splash->keyboard = keyboard;
1638+ if (splash->plugin_interface->add_text_display != NULL)
1639+ {
1640+ displays = ply_seat_get_text_displays (seat);
1641
1642- ply_keyboard_add_input_handler (keyboard,
1643- (ply_keyboard_input_handler_t)
1644- on_keyboard_input, splash);
1645+ ply_trace ("adding text displays");
1646+ node = ply_list_get_first_node (displays);
1647+ while (node != NULL)
1648+ {
1649+ ply_text_display_t *display;
1650+ int number_of_columns, number_of_rows;
1651
1652- if (splash->plugin_interface->set_keyboard == NULL)
1653- return;
1654+ display = ply_list_node_get_data (node);
1655+ next_node = ply_list_get_next_node (displays, node);
1656
1657- splash->plugin_interface->set_keyboard (splash->plugin, keyboard);
1658-}
1659+ number_of_columns = ply_text_display_get_number_of_columns (display);
1660+ number_of_rows = ply_text_display_get_number_of_rows (display);
1661
1662-void
1663-ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash)
1664-{
1665- ply_keyboard_remove_input_handler (splash->keyboard,
1666- (ply_keyboard_input_handler_t)
1667- on_keyboard_input);
1668+ ply_trace ("Adding %dx%d text display", number_of_columns, number_of_rows);
1669
1670- if (splash->plugin_interface->set_keyboard == NULL)
1671- return;
1672+ splash->plugin_interface->add_text_display (splash->plugin, display);
1673
1674- splash->plugin_interface->unset_keyboard (splash->plugin, splash->keyboard);
1675+ node = next_node;
1676+ }
1677+ }
1678 }
1679
1680 void
1681-ply_boot_splash_add_pixel_display (ply_boot_splash_t *splash,
1682- ply_pixel_display_t *display)
1683+ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash,
1684+ ply_seat_t *seat)
1685 {
1686- ply_list_append_data (splash->pixel_displays, display);
1687-
1688- if (splash->plugin_interface->add_pixel_display == NULL)
1689- return;
1690-
1691- splash->plugin_interface->add_pixel_display (splash->plugin, display);
1692-}
1693+ ply_list_node_t *node;
1694
1695-void
1696-ply_boot_splash_remove_pixel_display (ply_boot_splash_t *splash,
1697- ply_pixel_display_t *display)
1698-{
1699- ply_list_remove_data (splash->pixel_displays, display);
1700+ node = ply_list_find_node (splash->seats, seat);
1701
1702- if (splash->plugin_interface->remove_pixel_display == NULL)
1703+ if (node != NULL)
1704 return;
1705
1706- splash->plugin_interface->remove_pixel_display (splash->plugin, display);
1707+ ply_list_append_data (splash->seats, seat);
1708+ attach_to_seat (splash, seat);
1709 }
1710
1711 void
1712-ply_boot_splash_add_text_display (ply_boot_splash_t *splash,
1713- ply_text_display_t *display)
1714+ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash,
1715+ ply_seat_t *seat)
1716 {
1717- ply_list_append_data (splash->text_displays, display);
1718+ ply_list_node_t *node;
1719
1720- if (splash->plugin_interface->add_text_display == NULL)
1721- return;
1722+ node = ply_list_find_node (splash->seats, seat);
1723
1724- splash->plugin_interface->add_text_display (splash->plugin, display);
1725-}
1726-
1727-void
1728-ply_boot_splash_remove_text_display (ply_boot_splash_t *splash,
1729- ply_text_display_t *display)
1730-{
1731- ply_list_remove_data (splash->text_displays, display);
1732-
1733- if (splash->plugin_interface->remove_pixel_display == NULL)
1734+ if (node == NULL)
1735 return;
1736
1737- splash->plugin_interface->remove_text_display (splash->plugin, display);
1738+ ply_list_remove_data (splash->seats, seat);
1739+ detach_from_seat (splash, seat);
1740 }
1741
1742 bool
1743@@ -432,56 +391,24 @@ ply_boot_splash_unload (ply_boot_splash_t *splash)
1744 }
1745
1746 static void
1747-remove_displays (ply_boot_splash_t *splash)
1748+detach_from_seats (ply_boot_splash_t *splash)
1749 {
1750- ply_list_node_t *node, *next_node;
1751+ ply_list_node_t *node;
1752
1753- ply_trace ("removing pixel displays");
1754+ ply_trace ("detaching from seats");
1755
1756- node = ply_list_get_first_node (splash->pixel_displays);
1757+ node = ply_list_get_first_node (splash->seats);
1758 while (node != NULL)
1759 {
1760- ply_pixel_display_t *display;
1761+ ply_seat_t *seat;
1762 ply_list_node_t *next_node;
1763- unsigned long width, height;
1764
1765- display = ply_list_node_get_data (node);
1766- next_node = ply_list_get_next_node (splash->pixel_displays, node);
1767+ seat = ply_list_node_get_data (node);
1768+ next_node = ply_list_get_next_node (splash->seats, node);
1769
1770- width = ply_pixel_display_get_width (display);
1771- height = ply_pixel_display_get_height (display);
1772+ detach_from_seat (splash, seat);
1773
1774- ply_trace ("Removing %lux%lu pixel display", width, height);
1775-
1776- if (splash->plugin_interface->remove_pixel_display != NULL)
1777- splash->plugin_interface->remove_pixel_display (splash->plugin, display);
1778-
1779- ply_trace ("Removing node");
1780- ply_list_remove_node (splash->pixel_displays, node);
1781-
1782- node = next_node;
1783- }
1784-
1785- ply_trace ("removing text displays");
1786- node = ply_list_get_first_node (splash->text_displays);
1787- while (node != NULL)
1788- {
1789- ply_text_display_t *display;
1790- int number_of_columns, number_of_rows;
1791-
1792- display = ply_list_node_get_data (node);
1793- next_node = ply_list_get_next_node (splash->text_displays, node);
1794-
1795- number_of_columns = ply_text_display_get_number_of_columns (display);
1796- number_of_rows = ply_text_display_get_number_of_rows (display);
1797-
1798- ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
1799-
1800- if (splash->plugin_interface->remove_text_display != NULL)
1801- splash->plugin_interface->remove_text_display (splash->plugin, display);
1802-
1803- ply_trace ("Removing node");
1804- ply_list_remove_node (splash->text_displays, node);
1805+ ply_list_remove_node (splash->seats, node);
1806
1807 node = next_node;
1808 }
1809@@ -508,9 +435,8 @@ ply_boot_splash_free (ply_boot_splash_t *splash)
1810 splash);
1811 }
1812
1813- remove_displays (splash);
1814- ply_list_free (splash->pixel_displays);
1815- ply_list_free (splash->text_displays);
1816+ detach_from_seats (splash);
1817+ ply_list_free (splash->seats);
1818
1819 if (splash->module_handle != NULL)
1820 ply_boot_splash_unload (splash);
1821@@ -676,16 +602,6 @@ ply_boot_splash_hide (ply_boot_splash_t *splash)
1822 splash->plugin_interface->hide_splash_screen (splash->plugin,
1823 splash->loop);
1824
1825- if (ply_list_get_length (splash->pixel_displays) >= 1)
1826- {
1827- ply_terminal_t *terminal;
1828-
1829- terminal = find_local_console_terminal (splash);
1830-
1831- if (terminal != NULL)
1832- ply_terminal_set_mode (terminal, PLY_TERMINAL_MODE_TEXT);
1833- }
1834-
1835 splash->mode = PLY_BOOT_SPLASH_MODE_INVALID;
1836
1837 if (splash->loop != NULL)
1838@@ -820,148 +736,4 @@ ply_boot_splash_become_idle (ply_boot_splash_t *splash,
1839 splash->plugin_interface->become_idle (splash->plugin, splash->idle_trigger);
1840 }
1841
1842-#ifdef PLY_BOOT_SPLASH_ENABLE_TEST
1843-
1844-#include <stdio.h>
1845-
1846-#include "ply-event-loop.h"
1847-#include "ply-boot-splash.h"
1848-
1849-typedef struct test_state test_state_t;
1850-struct test_state {
1851- ply_event_loop_t *loop;
1852- ply_boot_splash_t *splash;
1853- ply_buffer_t *buffer;
1854-};
1855-
1856-static void
1857-on_timeout (ply_boot_splash_t *splash)
1858-{
1859- ply_boot_splash_update_status (splash, "foo");
1860- ply_event_loop_watch_for_timeout (splash->loop,
1861- 5.0,
1862- (ply_event_loop_timeout_handler_t)
1863- on_timeout,
1864- splash);
1865-}
1866-
1867-static void
1868-on_quit (test_state_t *state)
1869-{
1870- ply_boot_splash_hide (state->splash);
1871- ply_event_loop_exit (state->loop, 0);
1872-}
1873-
1874-static void
1875-add_displays_to_splash_from_renderer (test_state_t *state,
1876- ply_renderer_t *renderer)
1877-{
1878- ply_list_t *heads;
1879- ply_list_node_t *node;
1880-
1881- heads = ply_renderer_get_heads (renderer);
1882-
1883- node = ply_list_get_first_node (heads);
1884- while (node != NULL)
1885- {
1886- ply_list_node_t *next_node;
1887- ply_renderer_head_t *head;
1888- ply_pixel_display_t *display;
1889-
1890- head = ply_list_node_get_data (node);
1891- next_node = ply_list_get_next_node (heads, node);
1892-
1893- display = ply_pixel_display_new (renderer, head);
1894-
1895- ply_boot_splash_add_pixel_display (state->splash, display);
1896-
1897- node = next_node;
1898- }
1899-}
1900-
1901-int
1902-main (int argc,
1903- char **argv)
1904-{
1905- int exit_code;
1906- test_state_t state;
1907- char *tty_name;
1908- const char *theme_path;
1909- ply_text_display_t *text_display;
1910- ply_renderer_t *renderer;
1911- ply_terminal_t *terminal;
1912- ply_keyboard_t *keyboard;
1913-
1914- exit_code = 0;
1915-
1916- state.loop = ply_event_loop_new ();
1917-
1918- if (argc > 1)
1919- theme_path = argv[1];
1920- else
1921- theme_path = PLYMOUTH_THEME_PATH "/fade-in/fade-in.plymouth";
1922-
1923- if (argc > 2)
1924- asprintf(&tty_name, "tty%s", argv[2]);
1925- else
1926- tty_name = strdup("tty0");
1927-
1928- terminal = ply_terminal_new (tty_name);
1929-
1930- if (!ply_terminal_open (terminal))
1931- {
1932- perror ("could not open tty");
1933- return errno;
1934- }
1935-
1936- renderer = ply_renderer_new (NULL, terminal);
1937- free(tty_name);
1938-
1939- if (!ply_renderer_open (renderer))
1940- {
1941- perror ("could not open renderer /dev/fb");
1942- ply_renderer_free (renderer);
1943- return errno;
1944- }
1945-
1946- keyboard = ply_keyboard_new_for_renderer (renderer);
1947- ply_keyboard_add_escape_handler (keyboard,
1948- (ply_keyboard_escape_handler_t) on_quit, &state);
1949-
1950- state.buffer = ply_buffer_new ();
1951- state.splash = ply_boot_splash_new (theme_path, PLYMOUTH_PLUGIN_PATH, state.buffer);
1952-
1953- if (!ply_boot_splash_load (state.splash))
1954- {
1955- perror ("could not load splash screen");
1956- return errno;
1957- }
1958-
1959- ply_boot_splash_set_keyboard (state.splash, keyboard);
1960- add_displays_to_splash_from_renderer (&state, renderer);
1961-
1962- text_display = ply_text_display_new (terminal);
1963- ply_boot_splash_add_text_display (state.splash, text_display);
1964-
1965- ply_boot_splash_attach_to_event_loop (state.splash, state.loop);
1966-
1967- if (!ply_boot_splash_show (state.splash, PLY_BOOT_SPLASH_MODE_BOOT_UP))
1968- {
1969- perror ("could not show splash screen");
1970- return errno;
1971- }
1972-
1973- ply_event_loop_watch_for_timeout (state.loop,
1974- 1.0,
1975- (ply_event_loop_timeout_handler_t)
1976- on_timeout,
1977- state.splash);
1978- exit_code = ply_event_loop_run (state.loop);
1979- ply_boot_splash_free (state.splash);
1980- ply_buffer_free (state.buffer);
1981-
1982- return exit_code;
1983-}
1984-
1985-#endif /* PLY_BOOT_SPLASH_ENABLE_TEST */
1986 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
1987diff --git a/src/libply-splash-core/ply-boot-splash.h b/src/libply-splash-core/ply-boot-splash.h
1988index a79e939..335039b 100644
1989--- a/src/libply-splash-core/ply-boot-splash.h
1990+++ b/src/libply-splash-core/ply-boot-splash.h
1991@@ -33,10 +33,12 @@
1992 #include "ply-pixel-display.h"
1993 #include "ply-text-display.h"
1994 #include "ply-progress.h"
1995+#include "ply-seat.h"
1996
1997 #include "ply-boot-splash-plugin.h"
1998
1999 typedef struct _ply_boot_splash ply_boot_splash_t;
2000+typedef struct _ply_seat ply_seat_t;
2001
2002 typedef void (* ply_boot_splash_on_idle_handler_t) (void *user_data);
2003
2004@@ -48,17 +50,10 @@ ply_boot_splash_t *ply_boot_splash_new (const char * theme_path,
2005 bool ply_boot_splash_load (ply_boot_splash_t *splash);
2006 bool ply_boot_splash_load_built_in (ply_boot_splash_t *splash);
2007 void ply_boot_splash_unload (ply_boot_splash_t *splash);
2008-void ply_boot_splash_set_keyboard (ply_boot_splash_t *splash,
2009- ply_keyboard_t *keyboard);
2010-void ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash);
2011-void ply_boot_splash_add_pixel_display (ply_boot_splash_t *splash,
2012- ply_pixel_display_t *display);
2013-void ply_boot_splash_remove_pixel_display (ply_boot_splash_t *splash,
2014- ply_pixel_display_t *display);
2015-void ply_boot_splash_add_text_display (ply_boot_splash_t *splash,
2016- ply_text_display_t *display);
2017-void ply_boot_splash_remove_text_display (ply_boot_splash_t *splash,
2018- ply_text_display_t *display);
2019+void ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash,
2020+ ply_seat_t *seat);
2021+void ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash,
2022+ ply_seat_t *seat);
2023 void ply_boot_splash_free (ply_boot_splash_t *splash);
2024 bool ply_boot_splash_show (ply_boot_splash_t *splash,
2025 ply_boot_splash_mode_t mode);
2026diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
2027new file mode 100644
2028index 0000000..dbc203d
2029--- /dev/null
2030+++ b/src/libply-splash-core/ply-device-manager.c
2031@@ -0,0 +1,935 @@
2032+/* ply-device-manager.c - device manager
2033+ *
2034+ * Copyright (C) 2013 Red Hat, Inc.
2035+ *
2036+ * This program is free software; you can redistribute it and/or modify
2037+ * it under the terms of the GNU General Public License as published by
2038+ * the Free Software Foundation; either version 2, or (at your option)
2039+ * any later version.
2040+ *
2041+ * This program is distributed in the hope that it will be useful,
2042+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2043+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2044+ * GNU General Public License for more details.
2045+ *
2046+ * You should have received a copy of the GNU General Public License
2047+ * along with this program; if not, write to the Free Software
2048+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2049+ * 02111-1307, USA.
2050+ */
2051+#include "config.h"
2052+#include "ply-device-manager.h"
2053+
2054+#include <assert.h>
2055+#include <fcntl.h>
2056+#include <stdbool.h>
2057+#include <stdlib.h>
2058+#include <stdio.h>
2059+#include <string.h>
2060+#include <sys/inotify.h>
2061+#include <sys/stat.h>
2062+#include <sys/types.h>
2063+
2064+#include <libudev.h>
2065+
2066+#include "ply-logger.h"
2067+#include "ply-event-loop.h"
2068+#include "ply-hashtable.h"
2069+#include "ply-list.h"
2070+#include "ply-utils.h"
2071+
2072+#define SUBSYSTEM_DRM "drm"
2073+#define SUBSYSTEM_FRAME_BUFFER "graphics"
2074+
2075+static void create_seat_for_terminal_and_renderer_type (ply_device_manager_t *manager,
2076+ const char *device_path,
2077+ ply_terminal_t *terminal,
2078+ ply_renderer_type_t renderer_type);
2079+struct _ply_device_manager
2080+{
2081+ ply_device_manager_flags_t flags;
2082+ ply_event_loop_t *loop;
2083+ ply_hashtable_t *terminals;
2084+ ply_terminal_t *local_console_terminal;
2085+ ply_seat_t *local_console_seat;
2086+ ply_list_t *seats;
2087+ struct udev *udev_context;
2088+ struct udev_queue *udev_queue;
2089+ int udev_queue_fd;
2090+ ply_fd_watch_t *udev_queue_fd_watch;
2091+ struct udev_monitor *udev_monitor;
2092+
2093+ ply_seat_added_handler_t seat_added_handler;
2094+ ply_seat_removed_handler_t seat_removed_handler;
2095+ void *seat_event_handler_data;
2096+};
2097+
2098+static void
2099+detach_from_event_loop (ply_device_manager_t *manager)
2100+{
2101+ assert (manager != NULL);
2102+
2103+ manager->loop = NULL;
2104+}
2105+
2106+static void
2107+attach_to_event_loop (ply_device_manager_t *manager,
2108+ ply_event_loop_t *loop)
2109+{
2110+ assert (manager != NULL);
2111+ assert (loop != NULL);
2112+ assert (manager->loop == NULL);
2113+
2114+ manager->loop = loop;
2115+
2116+ ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
2117+ detach_from_event_loop,
2118+ manager);
2119+}
2120+
2121+static bool
2122+device_is_for_local_console (ply_device_manager_t *manager,
2123+ struct udev_device *device)
2124+{
2125+ const char *device_path;
2126+ struct udev_device *bus_device;
2127+ char *bus_device_path;
2128+ const char *boot_vga;
2129+ bool for_local_console;
2130+
2131+ /* Look at the associated bus device to see if this card is the
2132+ * card the kernel is using for its console. */
2133+ device_path = udev_device_get_syspath (device);
2134+ asprintf (&bus_device_path, "%s/device", device_path);
2135+ bus_device = udev_device_new_from_syspath (manager->udev_context, bus_device_path);
2136+
2137+ boot_vga = udev_device_get_sysattr_value (bus_device, "boot_vga");
2138+ free (bus_device_path);
2139+
2140+ if (boot_vga != NULL && strcmp (boot_vga, "1") == 0)
2141+ for_local_console = true;
2142+ else
2143+ for_local_console = false;
2144+
2145+ return for_local_console;
2146+}
2147+
2148+static bool
2149+fb_device_has_drm_device (ply_device_manager_t *manager,
2150+ struct udev_device *fb_device)
2151+{
2152+ struct udev_enumerate *card_matches;
2153+ struct udev_list_entry *card_entry;
2154+ const char *id_path;
2155+ bool has_drm_device = false;
2156+
2157+ /* We want to see if the framebuffer is associated with a DRM-capable
2158+ * graphics card, if it is, we'll use the DRM device */
2159+ card_matches = udev_enumerate_new (manager->udev_context);
2160+ udev_enumerate_add_match_is_initialized(card_matches);
2161+ udev_enumerate_add_match_parent (card_matches, udev_device_get_parent (fb_device));
2162+ udev_enumerate_add_match_subsystem (card_matches, "drm");
2163+ id_path = udev_device_get_property_value (fb_device, "ID_PATH");
2164+ udev_enumerate_add_match_property (card_matches, "ID_PATH", id_path);
2165+
2166+ ply_trace ("trying to find associated drm node for fb device (path: %s)", id_path);
2167+
2168+ udev_enumerate_scan_devices (card_matches);
2169+
2170+ /* there should only ever be at most one match so we don't iterate through
2171+ * the list, but just look at the first entry */
2172+ card_entry = udev_enumerate_get_list_entry (card_matches);
2173+
2174+ if (card_entry != NULL)
2175+ {
2176+ struct udev_device *card_device = NULL;
2177+ const char *card_node;
2178+ const char *card_path;
2179+
2180+ card_path = udev_list_entry_get_name (card_entry);
2181+ card_device = udev_device_new_from_syspath (manager->udev_context, card_path);
2182+ card_node = udev_device_get_devnode (card_device);
2183+ if (card_node != NULL)
2184+ has_drm_device = true;
2185+ else
2186+ ply_trace ("no card node!");
2187+
2188+ udev_device_unref (card_device);
2189+ }
2190+ else
2191+ {
2192+ ply_trace ("no card entry!");
2193+ }
2194+
2195+ udev_enumerate_unref (card_matches);
2196+ return has_drm_device;
2197+}
2198+
2199+static void
2200+create_seat_for_udev_device (ply_device_manager_t *manager,
2201+ struct udev_device *device)
2202+{
2203+ bool for_local_console;
2204+ const char *device_path;
2205+ ply_terminal_t *terminal = NULL;
2206+
2207+ for_local_console = device_is_for_local_console (manager, device);
2208+
2209+ ply_trace ("device is for local console: %s", for_local_console? "yes" : "no");
2210+
2211+ if (for_local_console)
2212+ terminal = manager->local_console_terminal;
2213+
2214+ device_path = udev_device_get_devnode (device);
2215+
2216+ if (device_path != NULL)
2217+ {
2218+ const char *subsystem;
2219+ ply_renderer_type_t renderer_type = PLY_RENDERER_TYPE_NONE;
2220+
2221+ subsystem = udev_device_get_subsystem (device);
2222+ ply_trace ("device subsystem is %s", subsystem);
2223+
2224+ if (subsystem != NULL && strcmp (subsystem, SUBSYSTEM_DRM) == 0)
2225+ {
2226+ ply_trace ("found DRM device %s", device_path);
2227+ renderer_type = PLY_RENDERER_TYPE_DRM;
2228+ }
2229+ else if (strcmp (subsystem, SUBSYSTEM_FRAME_BUFFER) == 0)
2230+ {
2231+ ply_trace ("found frame buffer device %s", device_path);
2232+ if (!fb_device_has_drm_device (manager, device))
2233+ {
2234+ renderer_type = PLY_RENDERER_TYPE_FRAME_BUFFER;
2235+ }
2236+ else
2237+ {
2238+ ply_trace ("ignoring, since there's a DRM device associated with it");
2239+ }
2240+ }
2241+
2242+ if (renderer_type != PLY_RENDERER_TYPE_NONE)
2243+ create_seat_for_terminal_and_renderer_type (manager,
2244+ device_path,
2245+ terminal,
2246+ renderer_type);
2247+ }
2248+}
2249+
2250+static void
2251+free_seat_from_device_path (ply_device_manager_t *manager,
2252+ const char *device_path)
2253+{
2254+ ply_list_node_t *node;
2255+
2256+ node = ply_list_get_first_node (manager->seats);
2257+ while (node != NULL)
2258+ {
2259+ ply_seat_t *seat;
2260+ ply_renderer_t *renderer;
2261+ ply_list_node_t *next_node;
2262+ const char *renderer_device_path;
2263+
2264+ seat = ply_list_node_get_data (node);
2265+ next_node = ply_list_get_next_node (manager->seats, node);
2266+ renderer = ply_seat_get_renderer (seat);
2267+
2268+ if (renderer != NULL)
2269+ {
2270+ renderer_device_path = ply_renderer_get_device_name (renderer);
2271+
2272+ if (renderer_device_path != NULL)
2273+ {
2274+ if (strcmp (device_path, renderer_device_path) == 0)
2275+ {
2276+ ply_trace ("removing seat associated with %s", device_path);
2277+
2278+ if (manager->seat_removed_handler != NULL)
2279+ manager->seat_removed_handler (manager->seat_event_handler_data, seat);
2280+
2281+ ply_seat_free (seat);
2282+ ply_list_remove_node (manager->seats, node);
2283+ break;
2284+ }
2285+ }
2286+ }
2287+
2288+ node = next_node;
2289+ }
2290+}
2291+
2292+static void
2293+free_seat_for_udev_device (ply_device_manager_t *manager,
2294+ struct udev_device *device)
2295+{
2296+ const char *device_path;
2297+
2298+ device_path = udev_device_get_devnode (device);
2299+
2300+ if (device_path != NULL)
2301+ free_seat_from_device_path (manager, device_path);
2302+}
2303+
2304+static bool
2305+create_seats_for_subsystem (ply_device_manager_t *manager,
2306+ const char *subsystem)
2307+{
2308+ struct udev_enumerate *matches;
2309+ struct udev_list_entry *entry;
2310+ bool found_device = false;
2311+
2312+ ply_trace ("creating seats for %s devices",
2313+ strcmp (subsystem, SUBSYSTEM_FRAME_BUFFER) == 0?
2314+ "frame buffer":
2315+ subsystem);
2316+
2317+ matches = udev_enumerate_new (manager->udev_context);
2318+ udev_enumerate_add_match_subsystem (matches, subsystem);
2319+ udev_enumerate_scan_devices (matches);
2320+
2321+ udev_list_entry_foreach (entry, udev_enumerate_get_list_entry (matches))
2322+ {
2323+ struct udev_device *device = NULL;
2324+ const char *path;
2325+
2326+ path = udev_list_entry_get_name (entry);
2327+
2328+ if (path == NULL)
2329+ {
2330+ ply_trace ("path was null!");
2331+ continue;
2332+ }
2333+
2334+ ply_trace ("found device %s", path);
2335+
2336+ device = udev_device_new_from_syspath (manager->udev_context, path);
2337+
2338+ /* if device isn't fully initialized, we'll get an add event later
2339+ */
2340+ if (udev_device_get_is_initialized (device))
2341+ {
2342+ ply_trace ("device is initialized");
2343+
2344+ /* We only care about devices assigned to a (any) seat. Floating
2345+ * devices should be ignored.
2346+ */
2347+ if (udev_device_has_tag (device, "seat"))
2348+ {
2349+ const char *node;
2350+ node = udev_device_get_devnode (device);
2351+ if (node != NULL)
2352+ {
2353+ ply_trace ("found node %s", node);
2354+ found_device = true;
2355+ create_seat_for_udev_device (manager, device);
2356+ }
2357+ }
2358+ else
2359+ {
2360+ ply_trace ("device doesn't have a seat tag");
2361+ }
2362+ }
2363+ else
2364+ {
2365+ ply_trace ("it's not initialized");
2366+ }
2367+
2368+ udev_device_unref (device);
2369+ }
2370+
2371+ udev_enumerate_unref (matches);
2372+
2373+ return found_device;
2374+}
2375+
2376+static void
2377+on_udev_event (ply_device_manager_t *manager)
2378+{
2379+ struct udev_device *device;
2380+ const char *action;
2381+
2382+ device = udev_monitor_receive_device (manager->udev_monitor);
2383+ if (device == NULL)
2384+ return;
2385+
2386+ action = udev_device_get_action (device);
2387+
2388+ ply_trace ("got %s event for device %s", action, udev_device_get_sysname (device));
2389+
2390+ if (action == NULL)
2391+ return;
2392+
2393+ if (strcmp (action, "add") == 0)
2394+ {
2395+ const char *subsystem;
2396+ bool coldplug_complete = manager->udev_queue_fd_watch == NULL;
2397+
2398+ subsystem = udev_device_get_subsystem (device);
2399+
2400+ if (strcmp (subsystem, SUBSYSTEM_DRM) == 0 ||
2401+ coldplug_complete)
2402+ {
2403+ create_seat_for_udev_device (manager, device);
2404+ }
2405+ else
2406+ {
2407+ ply_trace ("ignoring since we only handle subsystem %s devices after coldplug completes", subsystem);
2408+ }
2409+ }
2410+ else if (strcmp (action, "remove") == 0)
2411+ {
2412+ free_seat_for_udev_device (manager, device);
2413+ }
2414+
2415+ udev_device_unref (device);
2416+}
2417+
2418+static void
2419+watch_for_udev_events (ply_device_manager_t *manager)
2420+{
2421+ int fd;
2422+ assert (manager != NULL);
2423+ assert (manager->udev_monitor == NULL);
2424+
2425+ ply_trace ("watching for udev graphics device add and remove events");
2426+
2427+ manager->udev_monitor = udev_monitor_new_from_netlink (manager->udev_context, "udev");
2428+
2429+ udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_DRM, NULL);
2430+ udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_FRAME_BUFFER, NULL);
2431+ udev_monitor_filter_add_match_tag (manager->udev_monitor, "seat");
2432+ udev_monitor_enable_receiving (manager->udev_monitor);
2433+
2434+ fd = udev_monitor_get_fd (manager->udev_monitor);
2435+ ply_event_loop_watch_fd (manager->loop,
2436+ fd,
2437+ PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
2438+ (ply_event_handler_t)
2439+ on_udev_event,
2440+ NULL,
2441+ manager);
2442+}
2443+
2444+static void
2445+free_seats (ply_device_manager_t *manager)
2446+{
2447+ ply_list_node_t *node;
2448+
2449+ ply_trace ("removing seats");
2450+ node = ply_list_get_first_node (manager->seats);
2451+ while (node != NULL)
2452+ {
2453+ ply_seat_t *seat;
2454+ ply_list_node_t *next_node;
2455+
2456+ seat = ply_list_node_get_data (node);
2457+ next_node = ply_list_get_next_node (manager->seats, node);
2458+
2459+ if (manager->seat_removed_handler != NULL)
2460+ manager->seat_removed_handler (manager->seat_event_handler_data, seat);
2461+
2462+ ply_seat_free (seat);
2463+ ply_list_remove_node (manager->seats, node);
2464+
2465+ node = next_node;
2466+ }
2467+}
2468+
2469+static void
2470+free_terminal (char *device,
2471+ ply_terminal_t *terminal,
2472+ ply_device_manager_t *manager)
2473+{
2474+ ply_hashtable_remove (manager->terminals, device);
2475+
2476+ ply_terminal_close (terminal);
2477+ ply_terminal_free (terminal);
2478+}
2479+
2480+static void
2481+free_terminals (ply_device_manager_t *manager)
2482+{
2483+ ply_hashtable_foreach (manager->terminals,
2484+ (ply_hashtable_foreach_func_t *)
2485+ free_terminal,
2486+ manager);
2487+}
2488+
2489+static ply_terminal_t *
2490+get_terminal (ply_device_manager_t *manager,
2491+ const char *device_name)
2492+{
2493+ char *full_name = NULL;
2494+ ply_terminal_t *terminal;
2495+
2496+ if (strncmp (device_name, "/dev/", strlen ("/dev/")) == 0)
2497+ full_name = strdup (device_name);
2498+ else
2499+ asprintf (&full_name, "/dev/%s", device_name);
2500+
2501+ if (strcmp (full_name, "/dev/tty0") == 0 ||
2502+ strcmp (full_name, "/dev/tty") == 0 ||
2503+ strcmp (full_name, ply_terminal_get_name (manager->local_console_terminal)) == 0)
2504+ {
2505+ terminal = manager->local_console_terminal;
2506+ goto done;
2507+ }
2508+
2509+ terminal = ply_hashtable_lookup (manager->terminals, full_name);
2510+
2511+ if (terminal == NULL)
2512+ {
2513+ terminal = ply_terminal_new (full_name);
2514+
2515+ ply_hashtable_insert (manager->terminals,
2516+ (void *) ply_terminal_get_name (terminal),
2517+ terminal);
2518+ }
2519+
2520+done:
2521+ free (full_name);
2522+ return terminal;
2523+}
2524+
2525+ply_device_manager_t *
2526+ply_device_manager_new (const char *default_tty,
2527+ ply_device_manager_flags_t flags)
2528+{
2529+ ply_device_manager_t *manager;
2530+
2531+ manager = calloc (1, sizeof (ply_device_manager_t));
2532+ manager->loop = NULL;
2533+ manager->terminals = ply_hashtable_new (ply_hashtable_string_hash, ply_hashtable_string_compare);
2534+ manager->local_console_terminal = ply_terminal_new (default_tty);
2535+ ply_hashtable_insert (manager->terminals,
2536+ (void *) ply_terminal_get_name (manager->local_console_terminal),
2537+ manager->local_console_terminal);
2538+ manager->seats = ply_list_new ();
2539+ manager->flags = flags;
2540+
2541+ if (!(flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV))
2542+ manager->udev_context = udev_new ();
2543+
2544+ attach_to_event_loop (manager, ply_event_loop_get_default ());
2545+
2546+ return manager;
2547+}
2548+
2549+void
2550+ply_device_manager_free (ply_device_manager_t *manager)
2551+{
2552+ ply_trace ("freeing device manager");
2553+
2554+ if (manager == NULL)
2555+ return;
2556+
2557+ ply_event_loop_stop_watching_for_exit (manager->loop,
2558+ (ply_event_loop_exit_handler_t)
2559+ detach_from_event_loop,
2560+ manager);
2561+ free_seats (manager);
2562+ ply_list_free (manager->seats);
2563+
2564+ free_terminals (manager);
2565+ ply_hashtable_free (manager->terminals);
2566+
2567+ if (manager->udev_monitor != NULL)
2568+ udev_monitor_unref (manager->udev_monitor);
2569+
2570+ if (manager->udev_context != NULL)
2571+ udev_unref (manager->udev_context);
2572+
2573+ free (manager);
2574+}
2575+
2576+static bool
2577+add_consoles_from_file (ply_device_manager_t *manager,
2578+ const char *path)
2579+{
2580+ int fd;
2581+ char contents[512] = "";
2582+ ssize_t contents_length;
2583+ bool has_serial_consoles;
2584+ const char *remaining_file_contents;
2585+
2586+ ply_trace ("opening %s", path);
2587+ fd = open (path, O_RDONLY);
2588+
2589+ if (fd < 0)
2590+ {
2591+ ply_trace ("couldn't open it: %m");
2592+ return false;
2593+ }
2594+
2595+ ply_trace ("reading file");
2596+ contents_length = read (fd, contents, sizeof (contents) - 1);
2597+
2598+ if (contents_length <= 0)
2599+ {
2600+ ply_trace ("couldn't read it: %m");
2601+ close (fd);
2602+ return false;
2603+ }
2604+ close (fd);
2605+
2606+ remaining_file_contents = contents;
2607+ has_serial_consoles = false;
2608+
2609+ while (remaining_file_contents < contents + contents_length)
2610+ {
2611+ char *console;
2612+ size_t console_length;
2613+ const char *console_device;
2614+ ply_terminal_t *terminal;
2615+
2616+ /* Advance past any leading whitespace */
2617+ remaining_file_contents += strspn (remaining_file_contents, " \n\t\v");
2618+
2619+ if (*remaining_file_contents == '\0')
2620+ {
2621+ /* There's nothing left after the whitespace, we're done */
2622+ break;
2623+ }
2624+
2625+ /* Find trailing whitespace and NUL terminate. If strcspn
2626+ * doesn't find whitespace, it gives us the length of the string
2627+ * until the next NUL byte, which we'll just overwrite with
2628+ * another NUL byte anyway. */
2629+ console_length = strcspn (remaining_file_contents, " \n\t\v");
2630+ console = strndup (remaining_file_contents, console_length);
2631+
2632+ terminal = get_terminal (manager, console);
2633+ console_device = ply_terminal_get_name (terminal);
2634+
2635+ free (console);
2636+
2637+ ply_trace ("console %s found!", console_device);
2638+
2639+ if (terminal != manager->local_console_terminal)
2640+ has_serial_consoles = true;
2641+
2642+ /* Move past the parsed console string, and the whitespace we
2643+ * may have found above. If we found a NUL above and not whitespace,
2644+ * then we're going to jump past the end of the buffer and the loop
2645+ * will terminate
2646+ */
2647+ remaining_file_contents += console_length + 1;
2648+ }
2649+
2650+ return has_serial_consoles;
2651+}
2652+
2653+static void
2654+create_seat_for_terminal_and_renderer_type (ply_device_manager_t *manager,
2655+ const char *device_path,
2656+ ply_terminal_t *terminal,
2657+ ply_renderer_type_t renderer_type)
2658+{
2659+ ply_seat_t *seat;
2660+ bool is_local_terminal = false;
2661+
2662+ if (terminal != NULL && manager->local_console_terminal == terminal)
2663+ is_local_terminal = true;
2664+
2665+ if (is_local_terminal && manager->local_console_seat != NULL)
2666+ {
2667+ ply_trace ("trying to create seat for local console when one already exists");
2668+ return;
2669+ }
2670+
2671+ ply_trace ("creating seat for %s (renderer type: %u) (terminal: %s)",
2672+ device_path? : "", renderer_type, terminal? ply_terminal_get_name (terminal): "none");
2673+ seat = ply_seat_new (terminal);
2674+
2675+ if (!ply_seat_open (seat, renderer_type, device_path))
2676+ {
2677+ ply_trace ("could not create seat");
2678+ ply_seat_free (seat);
2679+ return;
2680+ }
2681+
2682+ ply_list_append_data (manager->seats, seat);
2683+
2684+ if (is_local_terminal)
2685+ manager->local_console_seat = seat;
2686+
2687+ if (manager->seat_added_handler != NULL)
2688+ manager->seat_added_handler (manager->seat_event_handler_data, seat);
2689+}
2690+
2691+static void
2692+create_seat_for_terminal (const char *device_path,
2693+ ply_terminal_t *terminal,
2694+ ply_device_manager_t *manager)
2695+{
2696+ create_seat_for_terminal_and_renderer_type (manager,
2697+ device_path,
2698+ terminal,
2699+ PLY_RENDERER_TYPE_NONE);
2700+}
2701+static bool
2702+create_seats_from_terminals (ply_device_manager_t *manager)
2703+{
2704+ bool has_serial_consoles;
2705+
2706+ ply_trace ("checking for consoles");
2707+
2708+ if (manager->flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES)
2709+ {
2710+ has_serial_consoles = false;
2711+ ply_trace ("ignoring all consoles but default console because explicitly told to.");
2712+ }
2713+ else
2714+ {
2715+ has_serial_consoles = add_consoles_from_file (manager, "/sys/class/tty/console/active");
2716+ }
2717+
2718+ if (has_serial_consoles)
2719+ {
2720+ ply_trace ("serial consoles detected, managing them with details forced");
2721+ ply_hashtable_foreach (manager->terminals,
2722+ (ply_hashtable_foreach_func_t *)
2723+ create_seat_for_terminal,
2724+ manager);
2725+ return true;
2726+ }
2727+
2728+ return false;
2729+}
2730+
2731+static void
2732+create_seats_from_udev (ply_device_manager_t *manager)
2733+{
2734+ bool found_drm_device, found_fb_device;
2735+
2736+ ply_trace ("Looking for devices from udev");
2737+
2738+ found_drm_device = create_seats_for_subsystem (manager, SUBSYSTEM_DRM);
2739+ found_fb_device = create_seats_for_subsystem (manager, SUBSYSTEM_FRAME_BUFFER);
2740+
2741+ if (found_drm_device || found_fb_device)
2742+ return;
2743+
2744+ ply_trace ("Creating non-graphical seat, since there's no suitable graphics hardware");
2745+ create_seat_for_terminal_and_renderer_type (manager,
2746+ ply_terminal_get_name (manager->local_console_terminal),
2747+ manager->local_console_terminal,
2748+ PLY_RENDERER_TYPE_NONE);
2749+}
2750+
2751+static void
2752+create_fallback_seat (ply_device_manager_t *manager)
2753+{
2754+ create_seat_for_terminal_and_renderer_type (manager,
2755+ ply_terminal_get_name (manager->local_console_terminal),
2756+ manager->local_console_terminal,
2757+ PLY_RENDERER_TYPE_AUTO);
2758+}
2759+
2760+static void
2761+on_udev_queue_changed (ply_device_manager_t *manager)
2762+{
2763+
2764+ if (!udev_queue_get_queue_is_empty (manager->udev_queue))
2765+ return;
2766+
2767+ ply_trace ("udev coldplug complete");
2768+ ply_event_loop_stop_watching_fd (manager->loop, manager->udev_queue_fd_watch);
2769+ manager->udev_queue_fd_watch = NULL;
2770+ udev_queue_unref (manager->udev_queue);
2771+
2772+ close (manager->udev_queue_fd);
2773+ manager->udev_queue_fd = -1;
2774+
2775+ manager->udev_queue = NULL;
2776+
2777+ create_seats_from_udev (manager);
2778+}
2779+
2780+static void
2781+watch_for_coldplug_completion (ply_device_manager_t *manager)
2782+{
2783+ int fd;
2784+ int result;
2785+
2786+ manager->udev_queue = udev_queue_new (manager->udev_context);
2787+
2788+ if (udev_queue_get_queue_is_empty (manager->udev_queue))
2789+ {
2790+ ply_trace ("udev coldplug completed already ");
2791+ create_seats_from_udev (manager);
2792+ return;
2793+ }
2794+
2795+ fd = inotify_init1 (IN_CLOEXEC);
2796+ result = inotify_add_watch (fd, "/run/udev", IN_MOVED_TO);
2797+
2798+ if (result < 0)
2799+ {
2800+ ply_trace ("could not watch for udev to show up: %m");
2801+ close (fd);
2802+
2803+ create_fallback_seat (manager);
2804+ return;
2805+ }
2806+
2807+ manager->udev_queue_fd = fd;
2808+
2809+ manager->udev_queue_fd_watch = ply_event_loop_watch_fd (manager->loop,
2810+ fd,
2811+ PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
2812+ (ply_event_handler_t)
2813+ on_udev_queue_changed,
2814+ NULL,
2815+ manager);
2816+
2817+}
2818+
2819+void
2820+ply_device_manager_watch_seats (ply_device_manager_t *manager,
2821+ ply_seat_added_handler_t seat_added_handler,
2822+ ply_seat_removed_handler_t seat_removed_handler,
2823+ void *data)
2824+{
2825+ bool done_with_initial_seat_setup;
2826+
2827+ manager->seat_added_handler = seat_added_handler;
2828+ manager->seat_removed_handler = seat_removed_handler;
2829+ manager->seat_event_handler_data = data;
2830+
2831+ /* Try to create seats for each serial device right away, if possible
2832+ */
2833+ done_with_initial_seat_setup = create_seats_from_terminals (manager);
2834+
2835+ if (done_with_initial_seat_setup)
2836+ return;
2837+
2838+ if ((manager->flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV))
2839+ {
2840+ ply_trace ("udev support disabled, creating fallback seat");
2841+ create_fallback_seat (manager);
2842+ return;
2843+ }
2844+
2845+ watch_for_udev_events (manager);
2846+ watch_for_coldplug_completion (manager);
2847+}
2848+
2849+bool
2850+ply_device_manager_has_open_seats (ply_device_manager_t *manager)
2851+{
2852+ ply_list_node_t *node;
2853+
2854+ node = ply_list_get_first_node (manager->seats);
2855+ while (node != NULL)
2856+ {
2857+ ply_seat_t *seat;
2858+ ply_list_node_t *next_node;
2859+
2860+ seat = ply_list_node_get_data (node);
2861+ next_node = ply_list_get_next_node (manager->seats, node);
2862+
2863+ if (ply_seat_is_open (seat))
2864+ return true;
2865+
2866+ node = next_node;
2867+ }
2868+
2869+ return false;
2870+}
2871+
2872+ply_list_t *
2873+ply_device_manager_get_seats (ply_device_manager_t *manager)
2874+{
2875+ return manager->seats;
2876+}
2877+
2878+ply_terminal_t *
2879+ply_device_manager_get_default_terminal (ply_device_manager_t *manager)
2880+{
2881+ return manager->local_console_terminal;
2882+}
2883+
2884+void
2885+ply_device_manager_activate_renderers (ply_device_manager_t *manager)
2886+{
2887+ ply_list_node_t *node;
2888+
2889+ ply_trace ("activating renderers");
2890+ node = ply_list_get_first_node (manager->seats);
2891+ while (node != NULL)
2892+ {
2893+ ply_seat_t *seat;
2894+ ply_list_node_t *next_node;
2895+
2896+ seat = ply_list_node_get_data (node);
2897+ next_node = ply_list_get_next_node (manager->seats, node);
2898+
2899+ ply_seat_activate_renderer (seat);
2900+
2901+ node = next_node;
2902+ }
2903+}
2904+
2905+void
2906+ply_device_manager_deactivate_renderers (ply_device_manager_t *manager)
2907+{
2908+ ply_list_node_t *node;
2909+
2910+ ply_trace ("deactivating renderers");
2911+ node = ply_list_get_first_node (manager->seats);
2912+ while (node != NULL)
2913+ {
2914+ ply_seat_t *seat;
2915+ ply_list_node_t *next_node;
2916+
2917+ seat = ply_list_node_get_data (node);
2918+ next_node = ply_list_get_next_node (manager->seats, node);
2919+
2920+ ply_seat_deactivate_renderer (seat);
2921+
2922+ node = next_node;
2923+ }
2924+}
2925+
2926+void
2927+ply_device_manager_activate_keyboards (ply_device_manager_t *manager)
2928+{
2929+ ply_list_node_t *node;
2930+
2931+ ply_trace ("activating keyboards");
2932+ node = ply_list_get_first_node (manager->seats);
2933+ while (node != NULL)
2934+ {
2935+ ply_seat_t *seat;
2936+ ply_list_node_t *next_node;
2937+
2938+ seat = ply_list_node_get_data (node);
2939+ next_node = ply_list_get_next_node (manager->seats, node);
2940+
2941+ ply_seat_activate_keyboard (seat);
2942+
2943+ node = next_node;
2944+ }
2945+}
2946+
2947+void
2948+ply_device_manager_deactivate_keyboards (ply_device_manager_t *manager)
2949+{
2950+ ply_list_node_t *node;
2951+
2952+ ply_trace ("deactivating keyboards");
2953+ node = ply_list_get_first_node (manager->seats);
2954+ while (node != NULL)
2955+ {
2956+ ply_seat_t *seat;
2957+ ply_list_node_t *next_node;
2958+
2959+ seat = ply_list_node_get_data (node);
2960+ next_node = ply_list_get_next_node (manager->seats, node);
2961+
2962+ ply_seat_deactivate_keyboard (seat);
2963+
2964+ node = next_node;
2965+ }
2966+}
2967diff --git a/src/libply-splash-core/ply-device-manager.h b/src/libply-splash-core/ply-device-manager.h
2968new file mode 100644
2969index 0000000..d9c58e8
2970--- /dev/null
2971+++ b/src/libply-splash-core/ply-device-manager.h
2972@@ -0,0 +1,56 @@
2973+/* ply-device-manager.h - udev monitor
2974+ *
2975+ * Copyright (C) 2013 Red Hat, Inc.
2976+ *
2977+ * This program is free software; you can redistribute it and/or modify
2978+ * it under the terms of the GNU General Public License as published by
2979+ * the Free Software Foundation; either version 2, or (at your option)
2980+ * any later version.
2981+ *
2982+ * This program is distributed in the hope that it will be useful,
2983+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2984+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2985+ * GNU General Public License for more details.
2986+ *
2987+ * You should have received a copy of the GNU General Public License
2988+ * along with this program; if not, write to the Free Software
2989+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2990+ * 02111-1307, USA.
2991+ */
2992+#ifndef PLY_DEVICE_MANAGER_H
2993+#define PLY_DEVICE_MANAGER_H
2994+
2995+#include <stdbool.h>
2996+#include "ply-seat.h"
2997+
2998+typedef enum
2999+{
3000+ PLY_DEVICE_MANAGER_FLAGS_NONE = 0,
3001+ PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES = 1 << 0,
3002+ PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV = 1 << 1
3003+} ply_device_manager_flags_t;
3004+
3005+typedef struct _ply_device_manager ply_device_manager_t;
3006+typedef void (* ply_seat_added_handler_t) (void *, ply_seat_t *);
3007+typedef void (* ply_seat_removed_handler_t) (void *, ply_seat_t *);
3008+
3009+#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
3010+ply_device_manager_t *ply_device_manager_new (const char *default_tty,
3011+ ply_device_manager_flags_t flags);
3012+void ply_device_manager_watch_seats (ply_device_manager_t *manager,
3013+ ply_seat_added_handler_t seat_added_handler,
3014+ ply_seat_removed_handler_t seat_removed_handler,
3015+ void *data);
3016+bool ply_device_manager_has_open_seats (ply_device_manager_t *manager);
3017+ply_list_t *ply_device_manager_get_seats (ply_device_manager_t *manager);
3018+void ply_device_manager_free (ply_device_manager_t *manager);
3019+void ply_device_manager_activate_keyboards (ply_device_manager_t *manager);
3020+void ply_device_manager_deactivate_keyboards (ply_device_manager_t *manager);
3021+void ply_device_manager_activate_renderers (ply_device_manager_t *manager);
3022+void ply_device_manager_deactivate_renderers (ply_device_manager_t *manager);
3023+ply_terminal_t *ply_device_manager_get_default_terminal (ply_device_manager_t *manager);
3024+
3025+#endif
3026+
3027+#endif
3028+/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
3029diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c
3030index a612990..a860b7f 100644
3031--- a/src/libply-splash-core/ply-pixel-buffer.c
3032+++ b/src/libply-splash-core/ply-pixel-buffer.c
3033@@ -848,5 +848,35 @@ ply_pixel_buffer_rotate (ply_pixel_buffer_t *old_buffer,
3034 return buffer;
3035 }
3036
3037+ply_pixel_buffer_t *
3038+ply_pixel_buffer_tile (ply_pixel_buffer_t *old_buffer,
3039+ long width,
3040+ long height)
3041+{
3042+ long x, y;
3043+ long old_x, old_y;
3044+ long old_width, old_height;
3045+ uint32_t *bytes, *old_bytes;
3046+ ply_pixel_buffer_t *buffer;
3047+
3048+ buffer = ply_pixel_buffer_new (width, height);
3049+
3050+ old_bytes = ply_pixel_buffer_get_argb32_data (old_buffer);
3051+ bytes = ply_pixel_buffer_get_argb32_data (buffer);
3052+
3053+ old_width = old_buffer->area.width;
3054+ old_height = old_buffer->area.height;
3055+
3056+ for (y = 0; y < height; y++)
3057+ {
3058+ old_y = y % old_height;
3059+ for (x = 0; x < width; x++)
3060+ {
3061+ old_x = x % old_width;
3062+ bytes[x + y * width] = old_bytes[old_x + old_y * old_width];
3063+ }
3064+ }
3065+ return buffer;
3066+}
3067
3068 /* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
3069diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h
3070index 47cdd52..e0dffda 100644
3071--- a/src/libply-splash-core/ply-pixel-buffer.h
3072+++ b/src/libply-splash-core/ply-pixel-buffer.h
3073@@ -124,6 +124,10 @@ ply_pixel_buffer_t *ply_pixel_buffer_rotate (ply_pixel_buffer_t *old_buffer,
3074 long center_y,
3075 double theta_offset);
3076
3077+ply_pixel_buffer_t *ply_pixel_buffer_tile (ply_pixel_buffer_t *old_buffer,
3078+ long width,
3079+ long height);
3080+
3081 #endif
3082
3083 #endif /* PLY_PIXEL_BUFFER_H */
3084diff --git a/src/libply-splash-core/ply-renderer.c b/src/libply-splash-core/ply-renderer.c
3085index 3559e01..04a99ce 100644
3086--- a/src/libply-splash-core/ply-renderer.c
3087+++ b/src/libply-splash-core/ply-renderer.c
3088@@ -49,7 +49,7 @@ struct _ply_renderer
3089 const ply_renderer_plugin_interface_t *plugin_interface;
3090 ply_renderer_backend_t *backend;
3091
3092- char *plugin_path;
3093+ ply_renderer_type_t type;
3094 char *device_name;
3095 ply_terminal_t *terminal;
3096
3097@@ -63,16 +63,15 @@ typedef const ply_renderer_plugin_interface_t *
3098 static void ply_renderer_unload_plugin (ply_renderer_t *renderer);
3099
3100 ply_renderer_t *
3101-ply_renderer_new (const char *plugin_path,
3102- const char *device_name,
3103- ply_terminal_t *terminal)
3104+ply_renderer_new (ply_renderer_type_t renderer_type,
3105+ const char *device_name,
3106+ ply_terminal_t *terminal)
3107 {
3108 ply_renderer_t *renderer;
3109
3110 renderer = calloc (1, sizeof (struct _ply_renderer));
3111
3112- if (plugin_path != NULL)
3113- renderer->plugin_path = strdup (plugin_path);
3114+ renderer->type = renderer_type;
3115
3116 if (device_name != NULL)
3117 renderer->device_name = strdup (device_name);
3118@@ -95,10 +94,15 @@ ply_renderer_free (ply_renderer_t *renderer)
3119 }
3120
3121 free (renderer->device_name);
3122- free (renderer->plugin_path);
3123 free (renderer);
3124 }
3125
3126+const char *
3127+ply_renderer_get_device_name (ply_renderer_t *renderer)
3128+{
3129+ return renderer->device_name;
3130+}
3131+
3132 static bool
3133 ply_renderer_load_plugin (ply_renderer_t *renderer,
3134 const char *module_path)
3135@@ -258,29 +262,28 @@ ply_renderer_open (ply_renderer_t *renderer)
3136 {
3137 int i;
3138
3139- /* FIXME: at some point we may want to make this
3140- * part more dynamic (so you don't have to edit this
3141- * list to add a new renderer)
3142- */
3143- const char *known_plugins[] =
3144+ struct
3145 {
3146- PLYMOUTH_PLUGIN_PATH "renderers/x11.so",
3147- PLYMOUTH_PLUGIN_PATH "renderers/drm.so",
3148- PLYMOUTH_PLUGIN_PATH "renderers/frame-buffer.so",
3149- NULL
3150+ ply_renderer_type_t type;
3151+ const char *path;
3152+ } known_plugins[] =
3153+ {
3154+ { PLY_RENDERER_TYPE_X11, PLYMOUTH_PLUGIN_PATH "renderers/x11.so" },
3155+ { PLY_RENDERER_TYPE_DRM, PLYMOUTH_PLUGIN_PATH "renderers/drm.so" },
3156+ { PLY_RENDERER_TYPE_FRAME_BUFFER, PLYMOUTH_PLUGIN_PATH "renderers/frame-buffer.so" },
3157+ { PLY_RENDERER_TYPE_NONE, NULL }
3158 };
3159
3160- if (renderer->plugin_path != NULL)
3161+ for (i = 0; known_plugins[i].type != PLY_RENDERER_TYPE_NONE; i++)
3162 {
3163- return ply_renderer_open_plugin (renderer, renderer->plugin_path);
3164+ if (renderer->type == known_plugins[i].type ||
3165+ renderer->type == PLY_RENDERER_TYPE_AUTO)
3166+ {
3167+ if (ply_renderer_open_plugin (renderer, known_plugins[i].path))
3168+ return true;
3169+ }
3170 }
3171
3172- for (i = 0; known_plugins[i] != NULL; i++)
3173- {
3174- if (ply_renderer_open_plugin (renderer, known_plugins[i]))
3175- return true;
3176- }
3177-
3178 ply_trace ("could not find suitable rendering plugin");
3179 return false;
3180 }
3181diff --git a/src/libply-splash-core/ply-renderer.h b/src/libply-splash-core/ply-renderer.h
3182index 4b3bd1a..3d48341 100644
3183--- a/src/libply-splash-core/ply-renderer.h
3184+++ b/src/libply-splash-core/ply-renderer.h
3185@@ -35,12 +35,21 @@ typedef struct _ply_renderer ply_renderer_t;
3186 typedef struct _ply_renderer_head ply_renderer_head_t;
3187 typedef struct _ply_renderer_input_source ply_renderer_input_source_t;
3188
3189+typedef enum
3190+{
3191+ PLY_RENDERER_TYPE_NONE = -1,
3192+ PLY_RENDERER_TYPE_AUTO,
3193+ PLY_RENDERER_TYPE_DRM,
3194+ PLY_RENDERER_TYPE_FRAME_BUFFER,
3195+ PLY_RENDERER_TYPE_X11
3196+} ply_renderer_type_t;
3197+
3198 typedef void (* ply_renderer_input_source_handler_t) (void *user_data,
3199 ply_buffer_t *key_buffer,
3200 ply_renderer_input_source_t *input_source);
3201
3202 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
3203-ply_renderer_t *ply_renderer_new (const char *plugin_path,
3204+ply_renderer_t *ply_renderer_new (ply_renderer_type_t renderer_type,
3205 const char *device_name,
3206 ply_terminal_t *terminal);
3207 void ply_renderer_free (ply_renderer_t *renderer);
3208@@ -48,6 +57,7 @@ bool ply_renderer_open (ply_renderer_t *renderer);
3209 void ply_renderer_close (ply_renderer_t *renderer);
3210 void ply_renderer_activate (ply_renderer_t *renderer);
3211 void ply_renderer_deactivate (ply_renderer_t *renderer);
3212+const char *ply_renderer_get_device_name (ply_renderer_t *renderer);
3213 ply_list_t *ply_renderer_get_heads (ply_renderer_t *renderer);
3214 ply_pixel_buffer_t *ply_renderer_get_buffer_for_head (ply_renderer_t *renderer,
3215 ply_renderer_head_t *head);
3216diff --git a/src/libply-splash-core/ply-seat.c b/src/libply-splash-core/ply-seat.c
3217new file mode 100644
3218index 0000000..2ac8bf7
3219--- /dev/null
3220+++ b/src/libply-splash-core/ply-seat.c
3221@@ -0,0 +1,387 @@
3222+/* ply-seat.c - APIs for encapsulating a keyboard and one or more displays
3223+ *
3224+ * Copyright (C) 2013 Red Hat, Inc.
3225+ *
3226+ * This program is free software; you can redistribute it and/or modify
3227+ * it under the terms of the GNU General Public License as published by
3228+ * the Free Software Foundation; either version 2, or (at your option)
3229+ * any later version.
3230+ *
3231+ * This program is distributed in the hope that it will be useful,
3232+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3233+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3234+ * GNU General Public License for more details.
3235+ *
3236+ * You should have received a copy of the GNU General Public License
3237+ * along with this program; if not, write to the Free Software
3238+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3239+ * 02111-1307, USA.
3240+ *
3241+ * Written by: Ray Strode <rstrode@redhat.com>
3242+ */
3243+#include "config.h"
3244+#include "ply-seat.h"
3245+
3246+#include <assert.h>
3247+#include <errno.h>
3248+#include <stdint.h>
3249+#include <stdio.h>
3250+#include <stdlib.h>
3251+#include <unistd.h>
3252+
3253+#include "ply-boot-splash.h"
3254+#include "ply-event-loop.h"
3255+#include "ply-keyboard.h"
3256+#include "ply-pixel-display.h"
3257+#include "ply-text-display.h"
3258+#include "ply-list.h"
3259+#include "ply-logger.h"
3260+#include "ply-utils.h"
3261+
3262+struct _ply_seat
3263+{
3264+ ply_event_loop_t *loop;
3265+
3266+ ply_boot_splash_t *splash;
3267+ ply_terminal_t *terminal;
3268+ ply_renderer_t *renderer;
3269+ ply_keyboard_t *keyboard;
3270+ ply_list_t *text_displays;
3271+ ply_list_t *pixel_displays;
3272+
3273+ uint32_t renderer_active : 1;
3274+ uint32_t keyboard_active : 1;
3275+};
3276+
3277+ply_seat_t *
3278+ply_seat_new (ply_terminal_t *terminal)
3279+{
3280+ ply_seat_t *seat;
3281+
3282+ seat = calloc (1, sizeof (ply_seat_t));
3283+
3284+ seat->loop = ply_event_loop_get_default ();
3285+ seat->terminal = terminal;
3286+ seat->text_displays = ply_list_new ();
3287+ seat->pixel_displays = ply_list_new ();
3288+
3289+ return seat;
3290+}
3291+
3292+static void
3293+add_pixel_displays (ply_seat_t *seat)
3294+{
3295+ ply_list_t *heads;
3296+ ply_list_node_t *node;
3297+
3298+ heads = ply_renderer_get_heads (seat->renderer);
3299+
3300+ ply_trace ("Adding displays for %d heads",
3301+ ply_list_get_length (heads));
3302+
3303+ node = ply_list_get_first_node (heads);
3304+ while (node != NULL)
3305+ {
3306+ ply_list_node_t *next_node;
3307+ ply_renderer_head_t *head;
3308+ ply_pixel_display_t *display;
3309+
3310+ head = ply_list_node_get_data (node);
3311+ next_node = ply_list_get_next_node (heads, node);
3312+
3313+ display = ply_pixel_display_new (seat->renderer, head);
3314+
3315+ ply_list_append_data (seat->pixel_displays, display);
3316+
3317+ node = next_node;
3318+ }
3319+}
3320+
3321+static void
3322+add_text_displays (ply_seat_t *seat)
3323+{
3324+ ply_text_display_t *display;
3325+
3326+ if (!ply_terminal_is_open (seat->terminal))
3327+ {
3328+ if (!ply_terminal_open (seat->terminal))
3329+ {
3330+ ply_trace ("could not add terminal %s: %m",
3331+ ply_terminal_get_name (seat->terminal));
3332+ return;
3333+ }
3334+ }
3335+
3336+ ply_trace ("adding text display for terminal %s",
3337+ ply_terminal_get_name (seat->terminal));
3338+
3339+ display = ply_text_display_new (seat->terminal);
3340+ ply_list_append_data (seat->text_displays, display);
3341+}
3342+
3343+bool
3344+ply_seat_open (ply_seat_t *seat,
3345+ ply_renderer_type_t renderer_type,
3346+ const char *device)
3347+{
3348+ if (renderer_type != PLY_RENDERER_TYPE_NONE)
3349+ {
3350+ ply_renderer_t *renderer;
3351+
3352+ renderer = ply_renderer_new (renderer_type, device, seat->terminal);
3353+
3354+ if (!ply_renderer_open (renderer))
3355+ {
3356+ ply_trace ("could not open renderer for %s", device);
3357+ ply_renderer_free (renderer);
3358+
3359+ seat->renderer = NULL;
3360+ seat->renderer_active = false;
3361+
3362+ if (renderer_type != PLY_RENDERER_TYPE_AUTO)
3363+ return false;
3364+ }
3365+ else
3366+ {
3367+ seat->renderer = renderer;
3368+ seat->renderer_active = true;
3369+ }
3370+ }
3371+
3372+ if (seat->renderer != NULL)
3373+ {
3374+ seat->keyboard = ply_keyboard_new_for_renderer (seat->renderer);
3375+ add_pixel_displays (seat);
3376+
3377+ }
3378+ else
3379+ {
3380+ seat->keyboard = ply_keyboard_new_for_terminal (seat->terminal);
3381+ }
3382+ add_text_displays (seat);
3383+
3384+ ply_keyboard_watch_for_input (seat->keyboard);
3385+ seat->keyboard_active = true;
3386+
3387+ return true;
3388+}
3389+
3390+bool
3391+ply_seat_is_open (ply_seat_t *seat)
3392+{
3393+ return ply_list_get_length (seat->pixel_displays) > 0 ||
3394+ ply_list_get_length (seat->text_displays) > 0;
3395+}
3396+
3397+void
3398+ply_seat_deactivate_keyboard (ply_seat_t *seat)
3399+{
3400+ if (!seat->keyboard_active)
3401+ return;
3402+
3403+ seat->keyboard_active = false;
3404+
3405+ if (seat->keyboard == NULL)
3406+ return;
3407+
3408+ ply_trace ("deactivating keybord");
3409+ ply_keyboard_stop_watching_for_input (seat->keyboard);
3410+}
3411+
3412+void
3413+ply_seat_deactivate_renderer (ply_seat_t *seat)
3414+{
3415+ if (!seat->renderer_active)
3416+ return;
3417+
3418+ seat->renderer_active = false;
3419+
3420+ if (seat->renderer == NULL)
3421+ return;
3422+
3423+ ply_trace ("deactivating renderer");
3424+ ply_renderer_deactivate (seat->renderer);
3425+}
3426+
3427+void
3428+ply_seat_activate_keyboard (ply_seat_t *seat)
3429+{
3430+ if (seat->keyboard_active)
3431+ return;
3432+
3433+ if (seat->keyboard == NULL)
3434+ return;
3435+
3436+ ply_trace ("activating keyboard");
3437+ ply_keyboard_watch_for_input (seat->keyboard);
3438+
3439+ seat->keyboard_active = true;
3440+}
3441+
3442+void
3443+ply_seat_activate_renderer (ply_seat_t *seat)
3444+{
3445+ if (seat->renderer_active)
3446+ return;
3447+
3448+ if (seat->renderer == NULL)
3449+ return;
3450+
3451+ ply_trace ("activating renderer");
3452+ ply_renderer_activate (seat->renderer);
3453+
3454+ seat->renderer_active = true;
3455+}
3456+
3457+void
3458+ply_seat_refresh_displays (ply_seat_t *seat)
3459+{
3460+ ply_list_node_t *node;
3461+
3462+ node = ply_list_get_first_node (seat->pixel_displays);
3463+ while (node != NULL)
3464+ {
3465+ ply_pixel_display_t *display;
3466+ ply_list_node_t *next_node;
3467+ unsigned long width, height;
3468+
3469+ display = ply_list_node_get_data (node);
3470+ next_node = ply_list_get_next_node (seat->pixel_displays, node);
3471+
3472+ width = ply_pixel_display_get_width (display);
3473+ height = ply_pixel_display_get_height (display);
3474+
3475+ ply_pixel_display_draw_area (display, 0, 0, width, height);
3476+ node = next_node;
3477+ }
3478+
3479+ node = ply_list_get_first_node (seat->text_displays);
3480+ while (node != NULL)
3481+ {
3482+ ply_text_display_t *display;
3483+ ply_list_node_t *next_node;
3484+ int number_of_columns, number_of_rows;
3485+
3486+ display = ply_list_node_get_data (node);
3487+ next_node = ply_list_get_next_node (seat->text_displays, node);
3488+
3489+ number_of_columns = ply_text_display_get_number_of_columns (display);
3490+ number_of_rows = ply_text_display_get_number_of_rows (display);
3491+
3492+ ply_text_display_draw_area (display, 0, 0,
3493+ number_of_columns,
3494+ number_of_rows);
3495+ node = next_node;
3496+ }
3497+}
3498+
3499+void
3500+ply_seat_close (ply_seat_t *seat)
3501+{
3502+ if (seat->renderer == NULL)
3503+ return;
3504+
3505+ ply_trace ("destroying renderer");
3506+ ply_renderer_close (seat->renderer);
3507+ ply_renderer_free (seat->renderer);
3508+ seat->renderer = NULL;
3509+}
3510+
3511+void
3512+ply_seat_set_splash (ply_seat_t *seat,
3513+ ply_boot_splash_t *splash)
3514+{
3515+ if (seat->splash == splash)
3516+ return;
3517+
3518+ if (seat->splash != NULL)
3519+ ply_boot_splash_detach_from_seat (splash, seat);
3520+
3521+ if (splash != NULL)
3522+ ply_boot_splash_attach_to_seat (splash, seat);
3523+
3524+ seat->splash = splash;
3525+}
3526+
3527+static void
3528+free_pixel_displays (ply_seat_t *seat)
3529+{
3530+ ply_list_node_t *node;
3531+
3532+ ply_trace ("freeing %d pixel displays", ply_list_get_length (seat->pixel_displays));
3533+ node = ply_list_get_first_node (seat->pixel_displays);
3534+ while (node != NULL)
3535+ {
3536+ ply_list_node_t *next_node;
3537+ ply_pixel_display_t *display;
3538+
3539+ next_node = ply_list_get_next_node (seat->pixel_displays, node);
3540+ display = ply_list_node_get_data (node);
3541+ ply_pixel_display_free (display);
3542+
3543+ ply_list_remove_node (seat->pixel_displays, node);
3544+
3545+ node = next_node;
3546+ }
3547+}
3548+
3549+static void
3550+free_text_displays (ply_seat_t *seat)
3551+{
3552+ ply_list_node_t *node;
3553+
3554+ ply_trace ("freeing %d text displays", ply_list_get_length (seat->text_displays));
3555+ node = ply_list_get_first_node (seat->text_displays);
3556+ while (node != NULL)
3557+ {
3558+ ply_list_node_t *next_node;
3559+ ply_text_display_t *display;
3560+
3561+ next_node = ply_list_get_next_node (seat->text_displays, node);
3562+ display = ply_list_node_get_data (node);
3563+ ply_text_display_free (display);
3564+
3565+ ply_list_remove_node (seat->text_displays, node);
3566+
3567+ node = next_node;
3568+ }
3569+}
3570+
3571+void
3572+ply_seat_free (ply_seat_t *seat)
3573+{
3574+ if (seat == NULL)
3575+ return;
3576+
3577+ free_pixel_displays (seat);
3578+ free_text_displays (seat);
3579+ ply_keyboard_free (seat->keyboard);
3580+
3581+ free (seat);
3582+}
3583+
3584+ply_list_t *
3585+ply_seat_get_pixel_displays (ply_seat_t *seat)
3586+{
3587+ return seat->pixel_displays;
3588+}
3589+
3590+ply_list_t *
3591+ply_seat_get_text_displays (ply_seat_t *seat)
3592+{
3593+ return seat->text_displays;
3594+}
3595+
3596+ply_keyboard_t *
3597+ply_seat_get_keyboard (ply_seat_t *seat)
3598+{
3599+ return seat->keyboard;
3600+}
3601+
3602+ply_renderer_t *
3603+ply_seat_get_renderer (ply_seat_t *seat)
3604+{
3605+ return seat->renderer;
3606+}
3607+
3608+/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
3609diff --git a/src/libply-splash-core/ply-seat.h b/src/libply-splash-core/ply-seat.h
3610new file mode 100644
3611index 0000000..d5d3397
3612--- /dev/null
3613+++ b/src/libply-splash-core/ply-seat.h
3614@@ -0,0 +1,66 @@
3615+/* ply-seat.h - APIs for encapsulating a keyboard and one or more displays
3616+ *
3617+ * Copyright (C) 2013 Red Hat, Inc.
3618+ *
3619+ * This program is free software; you can redistribute it and/or modify
3620+ * it under the terms of the GNU General Public License as published by
3621+ * the Free Software Foundation; either version 2, or (at your option)
3622+ * any later version.
3623+ *
3624+ * This program is distributed in the hope that it will be useful,
3625+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3626+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3627+ * GNU General Public License for more details.
3628+ *
3629+ * You should have received a copy of the GNU General Public License
3630+ * along with this program; if not, write to the Free Software
3631+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3632+ * 02111-1307, USA.
3633+ *
3634+ * Written By: Ray Strode <rstrode@redhat.com>
3635+ */
3636+#ifndef PLY_SEAT_H
3637+#define PLY_SEAT_H
3638+
3639+#include <stdarg.h>
3640+#include <stdbool.h>
3641+#include <stdint.h>
3642+#include <unistd.h>
3643+
3644+#include "ply-boot-splash.h"
3645+#include "ply-buffer.h"
3646+#include "ply-event-loop.h"
3647+#include "ply-keyboard.h"
3648+#include "ply-list.h"
3649+#include "ply-pixel-display.h"
3650+#include "ply-terminal.h"
3651+#include "ply-text-display.h"
3652+
3653+typedef struct _ply_boot_splash ply_boot_splash_t;
3654+typedef struct _ply_seat ply_seat_t;
3655+
3656+#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
3657+ply_seat_t *ply_seat_new (ply_terminal_t *terminal);
3658+
3659+void ply_seat_free (ply_seat_t *seat);
3660+bool ply_seat_open (ply_seat_t *seat,
3661+ ply_renderer_type_t renderer_type,
3662+ const char *device);
3663+bool ply_seat_is_open (ply_seat_t *seat);
3664+void ply_seat_deactivate_keyboard (ply_seat_t *seat);
3665+void ply_seat_activate_keyboard (ply_seat_t *seat);
3666+void ply_seat_deactivate_renderer (ply_seat_t *seat);
3667+void ply_seat_activate_renderer (ply_seat_t *seat);
3668+void ply_seat_refresh_displays (ply_seat_t *seat);
3669+void ply_seat_close (ply_seat_t *seat);
3670+void ply_seat_set_splash (ply_seat_t *seat,
3671+ ply_boot_splash_t *splash);
3672+
3673+ply_list_t *ply_seat_get_pixel_displays (ply_seat_t *seat);
3674+ply_list_t *ply_seat_get_text_displays (ply_seat_t *seat);
3675+ply_keyboard_t *ply_seat_get_keyboard (ply_seat_t *seat);
3676+ply_renderer_t *ply_seat_get_renderer (ply_seat_t *seat);
3677+#endif
3678+
3679+#endif /* PLY_SEAT_H */
3680+/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
3681diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c
3682index 2e95dc8..992dd3f 100644
3683--- a/src/libply-splash-core/ply-terminal.c
3684+++ b/src/libply-splash-core/ply-terminal.c
3685@@ -876,6 +876,12 @@ ply_terminal_free (ply_terminal_t *terminal)
3686 free (terminal);
3687 }
3688
3689+const char *
3690+ply_terminal_get_name (ply_terminal_t *terminal)
3691+{
3692+ return terminal->name;
3693+}
3694+
3695 int
3696 ply_terminal_get_vt_number (ply_terminal_t *terminal)
3697 {
3698diff --git a/src/libply-splash-core/ply-terminal.h b/src/libply-splash-core/ply-terminal.h
3699index 8b4b017..48b4f77 100644
3700--- a/src/libply-splash-core/ply-terminal.h
3701+++ b/src/libply-splash-core/ply-terminal.h
3702@@ -91,6 +91,7 @@ void ply_terminal_set_mode (ply_terminal_t *terminal,
3703 void ply_terminal_ignore_mode_changes (ply_terminal_t *terminal,
3704 bool should_ignore);
3705
3706+const char *ply_terminal_get_name (ply_terminal_t *terminal);
3707 int ply_terminal_get_vt_number (ply_terminal_t *terminal);
3708 bool ply_terminal_activate_vt (ply_terminal_t *terminal);
3709 bool ply_terminal_deactivate_vt (ply_terminal_t *terminal);
3710diff --git a/src/libply-splash-core/ply-text-progress-bar.c b/src/libply-splash-core/ply-text-progress-bar.c
3711index bf4b378..8c4e759 100644
3712--- a/src/libply-splash-core/ply-text-progress-bar.c
3713+++ b/src/libply-splash-core/ply-text-progress-bar.c
3714@@ -104,7 +104,7 @@ get_os_string (void)
3715
3716 buf = NULL;
3717
3718- fd = open (RELEASE_FILE, O_RDONLY);
3719+ fd = open (RELEASE_FILE, O_RDONLY|O_CLOEXEC);
3720 if (fd == -1)
3721 goto out;
3722
3723@@ -136,6 +136,8 @@ get_os_string (void)
3724
3725 if (pos2 != NULL)
3726 *pos2 = '\0';
3727+ else
3728+ pos2 = pos + strlen(pos) - 1;
3729
3730 if ((*pos == '\"' && pos2[-1] == '\"') ||
3731 (*pos == '\'' && pos2[-1] == '\''))
3732diff --git a/src/libply-splash-core/ply-text-step-bar.c b/src/libply-splash-core/ply-text-step-bar.c
3733new file mode 100644
3734index 0000000..552a39f
3735--- /dev/null
3736+++ b/src/libply-splash-core/ply-text-step-bar.c
3737@@ -0,0 +1,163 @@
3738+/*
3739+ * Copyright (C) 2008-2012 Red Hat, Inc.
3740+ *
3741+ * This program is free software; you can redistribute it and/or modify
3742+ * it under the terms of the GNU General Public License as published by
3743+ * the Free Software Foundation; either version 2, or (at your option)
3744+ * any later version.
3745+ *
3746+ * This program is distributed in the hope that it will be useful,
3747+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3748+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3749+ * GNU General Public License for more details.
3750+ *
3751+ * You should have received a copy of the GNU General Public License
3752+ * along with this program; if not, write to the Free Software
3753+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3754+ * 02111-1307, USA.
3755+ *
3756+ */
3757+#include "config.h"
3758+
3759+#include <assert.h>
3760+#include <stdio.h>
3761+#include <stdlib.h>
3762+#include <string.h>
3763+#include <unistd.h>
3764+
3765+#include "ply-text-display.h"
3766+#include "ply-text-step-bar.h"
3767+
3768+struct _ply_text_step_bar
3769+{
3770+ ply_text_display_t *display;
3771+
3772+ int column;
3773+ int row;
3774+ int number_of_rows;
3775+ int number_of_columns;
3776+
3777+ double percent_done;
3778+ uint32_t is_hidden : 1;
3779+};
3780+
3781+ply_text_step_bar_t *
3782+ply_text_step_bar_new (void)
3783+{
3784+ ply_text_step_bar_t *step_bar;
3785+
3786+ step_bar = calloc (1, sizeof (ply_text_step_bar_t));
3787+
3788+ step_bar->row = 0;
3789+ step_bar->column = 0;
3790+ step_bar->number_of_columns = 0;
3791+ step_bar->number_of_rows = 0;
3792+
3793+ return step_bar;
3794+}
3795+
3796+void
3797+ply_text_step_bar_free (ply_text_step_bar_t *step_bar)
3798+{
3799+ if (step_bar == NULL)
3800+ return;
3801+
3802+ free (step_bar);
3803+}
3804+
3805+void
3806+ply_text_step_bar_draw (ply_text_step_bar_t *step_bar)
3807+{
3808+ int i;
3809+ int cur;
3810+
3811+ if (step_bar->is_hidden)
3812+ return;
3813+
3814+ ply_text_display_set_background_color (step_bar->display,
3815+ PLY_TERMINAL_COLOR_BLACK);
3816+
3817+ ply_text_display_set_cursor_position (step_bar->display,
3818+ step_bar->column,
3819+ step_bar->row);
3820+
3821+ cur = step_bar->percent_done * step_bar->number_of_columns;
3822+ for (i = 0; i < step_bar->number_of_columns; i++)
3823+ {
3824+ if (i == cur)
3825+ {
3826+ ply_text_display_set_foreground_color (step_bar->display,
3827+ PLY_TERMINAL_COLOR_WHITE);
3828+ }
3829+ else
3830+ {
3831+ ply_text_display_set_foreground_color (step_bar->display,
3832+ PLY_TERMINAL_COLOR_BROWN);
3833+ }
3834+
3835+ ply_text_display_write (step_bar->display, "%c", '■');
3836+ ply_text_display_write (step_bar->display, "%c", ' ');
3837+ }
3838+
3839+ ply_text_display_set_foreground_color (step_bar->display,
3840+ PLY_TERMINAL_COLOR_DEFAULT);
3841+}
3842+
3843+void
3844+ply_text_step_bar_show (ply_text_step_bar_t *step_bar,
3845+ ply_text_display_t *display)
3846+{
3847+ int screen_rows;
3848+ int screen_cols;
3849+
3850+ assert (step_bar != NULL);
3851+
3852+ step_bar->display = display;
3853+
3854+
3855+ screen_rows = ply_text_display_get_number_of_rows (display);
3856+ screen_cols = ply_text_display_get_number_of_columns (display);
3857+
3858+ step_bar->number_of_rows = 1;
3859+ step_bar->row = screen_rows * .66;
3860+ step_bar->number_of_columns = 3;
3861+ step_bar->column = screen_cols / 2.0 - step_bar->number_of_columns / 2.0;
3862+
3863+ step_bar->is_hidden = false;
3864+
3865+ ply_text_step_bar_draw (step_bar);
3866+}
3867+
3868+void
3869+ply_text_step_bar_hide (ply_text_step_bar_t *step_bar)
3870+{
3871+ step_bar->display = NULL;
3872+ step_bar->is_hidden = true;
3873+}
3874+
3875+void
3876+ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar,
3877+ double percent_done)
3878+{
3879+ step_bar->percent_done = percent_done;
3880+}
3881+
3882+double
3883+ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar)
3884+{
3885+ return step_bar->percent_done;
3886+}
3887+
3888+int
3889+ply_text_step_bar_get_number_of_columns (ply_text_step_bar_t *step_bar)
3890+{
3891+ return step_bar->number_of_columns;
3892+}
3893+
3894+int
3895+ply_text_step_bar_get_number_of_rows (ply_text_step_bar_t *step_bar)
3896+{
3897+ return step_bar->number_of_rows;
3898+}
3899+
3900+/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
3901diff --git a/src/libply-splash-core/ply-text-step-bar.h b/src/libply-splash-core/ply-text-step-bar.h
3902new file mode 100644
3903index 0000000..0a4733f
3904--- /dev/null
3905+++ b/src/libply-splash-core/ply-text-step-bar.h
3906@@ -0,0 +1,49 @@
3907+/*
3908+ * Copyright (C) 2008-2012 Red Hat, Inc.
3909+ *
3910+ * This program is free software; you can redistribute it and/or modify
3911+ * it under the terms of the GNU General Public License as published by
3912+ * the Free Software Foundation; either version 2, or (at your option)
3913+ * any later version.
3914+ *
3915+ * This program is distributed in the hope that it will be useful,
3916+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3917+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3918+ * GNU General Public License for more details.
3919+ *
3920+ * You should have received a copy of the GNU General Public License
3921+ * along with this program; if not, write to the Free Software
3922+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3923+ * 02111-1307, USA.
3924+ *
3925+ */
3926+#ifndef PLY_TEXT_STEP_BAR_H
3927+#define PLY_TEXT_STEP_BAR_H
3928+
3929+#include <unistd.h>
3930+
3931+#include "ply-event-loop.h"
3932+#include "ply-text-display.h"
3933+
3934+typedef struct _ply_text_step_bar ply_text_step_bar_t;
3935+
3936+#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
3937+ply_text_step_bar_t *ply_text_step_bar_new (void);
3938+void ply_text_step_bar_free (ply_text_step_bar_t *step_bar);
3939+
3940+void ply_text_step_bar_draw (ply_text_step_bar_t *step_bar);
3941+void ply_text_step_bar_show (ply_text_step_bar_t *step_bar,
3942+ ply_text_display_t *display);
3943+void ply_text_step_bar_hide (ply_text_step_bar_t *step_bar);
3944+
3945+void ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar,
3946+ double percent_done);
3947+
3948+double ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar);
3949+
3950+int ply_text_step_bar_get_number_of_rows (ply_text_step_bar_t *step_bar);
3951+int ply_text_step_bar_get_number_of_columns (ply_text_step_bar_t *step_bar);
3952+#endif
3953+
3954+#endif /* PLY_TEXT_PULSER_H */
3955+/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
3956diff --git a/src/libply-splash-graphics/Makefile.am b/src/libply-splash-graphics/Makefile.am
3957index f70d1ed..9013e56 100644
3958--- a/src/libply-splash-graphics/Makefile.am
3959+++ b/src/libply-splash-graphics/Makefile.am
3960@@ -1,4 +1,4 @@
3961-INCLUDES = -I$(top_srcdir) \
3962+AM_CPPFLAGS = -I$(top_srcdir) \
3963 -I$(srcdir) \
3964 -I$(srcdir)/../libply \
3965 -I$(srcdir)/../libply-splash-core \
3966diff --git a/src/libply-splash-graphics/ply-animation.c b/src/libply-splash-graphics/ply-animation.c
3967index ed558cf..bba8490 100644
3968--- a/src/libply-splash-graphics/ply-animation.c
3969+++ b/src/libply-splash-graphics/ply-animation.c
3970@@ -182,14 +182,8 @@ on_timeout (ply_animation_t *animation)
3971 animation->previous_time = animation->now;
3972 animation->now = ply_get_timestamp ();
3973
3974-#ifdef REAL_TIME_ANIMATION
3975 should_continue = animate_at_time (animation,
3976 animation->now - animation->start_time);
3977-#else
3978- static double time = 0.0;
3979- time += 1.0 / FRAMES_PER_SECOND;
3980- should_continue = animate_at_time (animation, time);
3981-#endif
3982
3983 sleep_time = 1.0 / FRAMES_PER_SECOND;
3984 sleep_time = MAX (sleep_time - (ply_get_timestamp () - animation->now),
3985diff --git a/src/libply-splash-graphics/ply-image.c b/src/libply-splash-graphics/ply-image.c
3986index 3e09f68..7d21946 100644
3987--- a/src/libply-splash-graphics/ply-image.c
3988+++ b/src/libply-splash-graphics/ply-image.c
3989@@ -123,7 +123,7 @@ ply_image_load (ply_image_t *image)
3990
3991 assert (image != NULL);
3992
3993- fp = fopen (image->filename, "r");
3994+ fp = fopen (image->filename, "re");
3995 if (fp == NULL)
3996 return false;
3997
3998@@ -254,6 +254,21 @@ ply_image_rotate (ply_image_t *image,
3999 return new_image;
4000 }
4001
4002+ply_image_t *
4003+ply_image_tile (ply_image_t *image,
4004+ long width,
4005+ long height)
4006+{
4007+ ply_image_t *new_image;
4008+
4009+ new_image = ply_image_new (image->filename);
4010+
4011+ new_image->buffer = ply_pixel_buffer_tile (image->buffer,
4012+ width,
4013+ height);
4014+ return new_image;
4015+}
4016+
4017 ply_pixel_buffer_t *
4018 ply_image_get_buffer (ply_image_t *image)
4019 {
4020diff --git a/src/libply-splash-graphics/ply-image.h b/src/libply-splash-graphics/ply-image.h
4021index 66fa520..5bda567 100644
4022--- a/src/libply-splash-graphics/ply-image.h
4023+++ b/src/libply-splash-graphics/ply-image.h
4024@@ -39,6 +39,7 @@ long ply_image_get_width (ply_image_t *image);
4025 long ply_image_get_height (ply_image_t *image);
4026 ply_image_t *ply_image_resize (ply_image_t *image, long width, long height);
4027 ply_image_t *ply_image_rotate (ply_image_t *oldimage, long center_x, long center_y, double theta_offset);
4028+ply_image_t *ply_image_tile (ply_image_t *image, long width, long height);
4029 ply_pixel_buffer_t *ply_image_get_buffer (ply_image_t *image);
4030 ply_pixel_buffer_t *ply_image_convert_to_pixel_buffer (ply_image_t *image);
4031
4032diff --git a/src/libply-splash-graphics/ply-throbber.c b/src/libply-splash-graphics/ply-throbber.c
4033index 59cf10c..42044ba 100644
4034--- a/src/libply-splash-graphics/ply-throbber.c
4035+++ b/src/libply-splash-graphics/ply-throbber.c
4036@@ -178,14 +178,8 @@ on_timeout (ply_throbber_t *throbber)
4037 bool should_continue;
4038 throbber->now = ply_get_timestamp ();
4039
4040-#ifdef REAL_TIME_ANIMATION
4041 should_continue = animate_at_time (throbber,
4042- throbber->now - throbber->start_time);
4043-#else
4044- static double time = 0.0;
4045- time += 1.0 / FRAMES_PER_SECOND;
4046- should_continue = animate_at_time (throbber, time);
4047-#endif
4048+ throbber->now - throbber->start_time);
4049
4050 sleep_time = 1.0 / FRAMES_PER_SECOND;
4051 sleep_time = MAX (sleep_time - (ply_get_timestamp () - throbber->now),
4052diff --git a/src/libply/Makefile.am b/src/libply/Makefile.am
4053index 302e47d..de15808 100644
4054--- a/src/libply/Makefile.am
4055+++ b/src/libply/Makefile.am
4056@@ -1,5 +1,4 @@
4057-SUBDIRS = tests
4058-INCLUDES = -I$(top_srcdir) \
4059+AM_CPPFLAGS = -I$(top_srcdir) \
4060 -I$(srcdir) \
4061 -DPLYMOUTH_TIME_DIRECTORY=\"$(localstatedir)/lib/plymouth/\"
4062
4063diff --git a/src/libply/ply-array.c b/src/libply/ply-array.c
4064index 41134b8..999c86e 100644
4065--- a/src/libply/ply-array.c
4066+++ b/src/libply/ply-array.c
4067@@ -171,34 +171,4 @@ ply_array_steal_uint32_elements (ply_array_t *array)
4068 return data;
4069 }
4070
4071-#ifdef PLY_ARRAY_ENABLE_TEST
4072-#include <stdio.h>
4073-
4074-int
4075-main (int argc,
4076- char **argv)
4077-{
4078- ply_array_t *array;
4079- int i;
4080- char **data;
4081-
4082- array = ply_array_new (PLY_ARRAY_ELEMENT_TYPE_POINTER);
4083-
4084- ply_array_add_pointer_element (array, "foo");
4085- ply_array_add_pointer_element (array, "bar");
4086- ply_array_add_pointer_element (array, "baz");
4087- ply_array_add_pointer_element (array, "qux");
4088-
4089- data = (char **) ply_array_get_pointer_elements (array);
4090- for (i = 0; data[i] != NULL; i++)
4091- {
4092- printf ("element '%d' has data '%s'\n", i, data[i]);
4093- i++;
4094- }
4095-
4096- ply_array_free (array);
4097- return 0;
4098-}
4099-
4100-#endif
4101 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4102diff --git a/src/libply/ply-bitarray.c b/src/libply/ply-bitarray.c
4103index 89e2216..3d0cdd0 100644
4104--- a/src/libply/ply-bitarray.c
4105+++ b/src/libply/ply-bitarray.c
4106@@ -42,64 +42,4 @@ ply_bitarray_count (ply_bitarray_t *bitarray,
4107 return count;
4108 }
4109
4110-
4111-
4112-
4113-#ifdef PLY_BITARRAY_ENABLE_TEST
4114-#include <stdio.h>
4115-
4116-int
4117-main (int argc,
4118- char **argv)
4119-{
4120- ply_bitarray_t *bitarray;
4121- int i, i2;
4122- printf ("bitarray test start\n");
4123- bitarray = ply_bitarray_new (134);
4124-
4125- for (i=0; i<64; i++)
4126- {
4127- if (ply_bitarray_lookup (bitarray, i))
4128- printf ("1");
4129- else
4130- printf ("0");
4131- }
4132- printf ("\n");
4133-
4134- for (i=0; i<64; i++)
4135- if ((6654654654654654654ll >> i) & 1)
4136- ply_bitarray_set (bitarray, i);
4137-
4138- for (i=0; i<64; i++)
4139- {
4140- if (ply_bitarray_lookup (bitarray, i))
4141- printf ("1");
4142- else
4143- printf ("0");
4144- }
4145- printf ("\n");
4146-
4147- for (i = 63; i > 0; i--)
4148- {
4149- if ((6654654654654654654ll >> i) & 1)
4150- {
4151- ply_bitarray_clear (bitarray, i);
4152- for (i2 = 0; i2 < 64; i2++)
4153- {
4154- if (ply_bitarray_lookup (bitarray, i2))
4155- printf ("1");
4156- else
4157- printf ("0");
4158- }
4159- printf ("\n");
4160- }
4161- }
4162-
4163- ply_bitarray_free (bitarray);
4164-
4165- printf ("bitarray test end\n");
4166- return 0;
4167-}
4168-
4169-#endif
4170 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4171diff --git a/src/libply/ply-buffer.c b/src/libply/ply-buffer.c
4172index c65634f..0d0406f 100644
4173--- a/src/libply/ply-buffer.c
4174+++ b/src/libply/ply-buffer.c
4175@@ -263,22 +263,4 @@ ply_buffer_clear (ply_buffer_t *buffer)
4176 buffer->size = 0;
4177 }
4178
4179-#ifdef PLY_BUFFER_ENABLE_TEST
4180-int
4181-main (int argc,
4182- char **argv)
4183-{
4184- int exit_code;
4185- ply_buffer_t *buffer;
4186-
4187- exit_code = 0;
4188- buffer = ply_buffer_new ();
4189-
4190- ply_buffer_append (buffer, "yo yo yo\n");
4191- ply_buffer_free (buffer);
4192-
4193- return exit_code;
4194-}
4195-
4196-#endif /* PLY_BUFFER_ENABLE_TEST */
4197 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4198diff --git a/src/libply/ply-command-parser.c b/src/libply/ply-command-parser.c
4199index 6ab323b..2768668 100644
4200--- a/src/libply/ply-command-parser.c
4201+++ b/src/libply/ply-command-parser.c
4202@@ -968,100 +968,4 @@ ply_command_parser_parse_arguments (ply_command_parser_t *parser,
4203 return parsed_arguments;
4204 }
4205
4206-#ifdef PLY_COMMAND_PARSER_ENABLE_TEST
4207-
4208-#include <stdio.h>
4209-
4210-#include "ply-command-parser.h"
4211-#include "ply-event-loop.h"
4212-#include "ply-logger.h"
4213-
4214-static void
4215-on_ask_for_password (ply_command_parser_t *parser,
4216- const char *command)
4217-{
4218- char *prompt;
4219- char *program;
4220-
4221- prompt = NULL;
4222- program = NULL;
4223- ply_command_parser_get_command_options (parser, command, "prompt", &prompt, "command", &program, NULL);
4224-
4225- printf ("ask for password with prompt '%s' feed result to '%s'\n", prompt, program);
4226- free (prompt);
4227- free (program);
4228-}
4229-
4230-static void
4231-on_show_splash (ply_command_parser_t *parser,
4232- const char *command)
4233-{
4234- char *plugin_name;
4235-
4236- plugin_name = NULL;
4237- ply_command_parser_get_command_options (parser, command, "plugin-name", &plugin_name, NULL);
4238-
4239- printf ("show splash plugin '%s'\n", plugin_name);
4240- free (plugin_name);
4241-}
4242-
4243-int
4244-main (int argc,
4245- char **argv)
4246-{
4247- ply_event_loop_t *loop;
4248- ply_command_parser_t *parser;
4249- bool should_help;
4250-
4251- loop = ply_event_loop_new ();
4252- parser = ply_command_parser_new (argv[0], "Test Program");
4253-
4254- ply_command_parser_add_options (parser,
4255- "help", "This help message", PLY_COMMAND_OPTION_TYPE_FLAG,
4256- NULL);
4257-
4258- ply_command_parser_add_command (parser,
4259- "ask-for-password",
4260- "Ask user for password",
4261- (ply_command_handler_t)
4262- on_ask_for_password, parser,
4263- "command", "command to pipe result to", PLY_COMMAND_OPTION_TYPE_STRING,
4264- "prompt", "string to present to user", PLY_COMMAND_OPTION_TYPE_STRING,
4265- "output-result", "print result", PLY_COMMAND_OPTION_TYPE_BOOLEAN,
4266- NULL);
4267-
4268- ply_command_parser_add_command (parser,
4269- "show-splash",
4270- "Show splash to user",
4271- (ply_command_handler_t)
4272- on_show_splash, parser,
4273- "plugin-name", "name of the plugin to run", PLY_COMMAND_OPTION_TYPE_STRING,
4274- NULL);
4275-
4276- if (!ply_command_parser_parse_arguments (parser, loop, argv, argc))
4277- {
4278- ply_error ("couldn't parse arguments");
4279- return 1;
4280- }
4281-
4282-
4283- ply_command_parser_get_options (parser, "help", &should_help, NULL);
4284-
4285- if (should_help)
4286- {
4287- char *usage;
4288- usage = ply_command_parser_get_help_string (parser);
4289- printf ("%s\n", usage);
4290- free (usage);
4291- return 0;
4292- }
4293-
4294- ply_event_loop_run (loop);
4295-
4296- ply_command_parser_free (parser);
4297-
4298- return 0;
4299-}
4300-
4301-#endif
4302 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4303diff --git a/src/libply/ply-event-loop.c b/src/libply/ply-event-loop.c
4304index 3cfad76..0c85cb9 100644
4305--- a/src/libply/ply-event-loop.c
4306+++ b/src/libply/ply-event-loop.c
4307@@ -491,7 +491,7 @@ ply_event_loop_new (void)
4308
4309 loop = calloc (1, sizeof (ply_event_loop_t));
4310
4311- loop->epoll_fd = epoll_create (PLY_EVENT_LOOP_NUM_EVENT_HANDLERS);
4312+ loop->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
4313 loop->wakeup_time = PLY_EVENT_LOOP_NO_TIMED_WAKEUP;
4314
4315 assert (loop->epoll_fd >= 0);
4316@@ -1376,88 +1376,4 @@ ply_event_loop_run (ply_event_loop_t *loop)
4317 return loop->exit_code;
4318 }
4319
4320-#ifdef PLY_EVENT_LOOP_ENABLE_TEST
4321-
4322-static ply_event_loop_t *loop;
4323-
4324-static void
4325-alrm_signal_handler (void)
4326-{
4327- write (1, "times up!\n", sizeof ("times up!\n") - 1);
4328- ply_event_loop_exit (loop, 0);
4329-}
4330-
4331-static void
4332-usr1_signal_handler (void)
4333-{
4334- write (1, "got sigusr1\n", sizeof ("got sigusr1\n") - 1);
4335-}
4336-
4337-static void
4338-hangup_signal_handler (void)
4339-{
4340- write (1, "got hangup\n", sizeof ("got hangup\n") - 1);
4341-}
4342-
4343-static void
4344-terminate_signal_handler (void)
4345-{
4346- write (1, "got terminate\n", sizeof ("got terminate\n") - 1);
4347- ply_event_loop_exit (loop, 0);
4348-}
4349-
4350-static void
4351-line_received_handler (void)
4352-{
4353- char line[512] = { 0 };
4354- printf ("Received line: ");
4355- fflush (stdout);
4356-
4357- fgets (line, sizeof (line), stdin);
4358- printf ("%s", line);
4359-}
4360-
4361-static void
4362-on_timeout (ply_event_loop_t *loop)
4363-{
4364- printf ("timeout elapsed\n");
4365-}
4366-
4367-int
4368-main (int argc,
4369- char **argv)
4370-{
4371- int exit_code;
4372-
4373- loop = ply_event_loop_new ();
4374-
4375- ply_event_loop_watch_signal (loop, SIGHUP,
4376- (ply_event_handler_t) hangup_signal_handler,
4377- NULL);
4378- ply_event_loop_watch_signal (loop, SIGTERM,
4379- (ply_event_handler_t)
4380- terminate_signal_handler, NULL);
4381- ply_event_loop_watch_signal (loop, SIGUSR1,
4382- (ply_event_handler_t)
4383- usr1_signal_handler, NULL);
4384- ply_event_loop_watch_signal (loop, SIGALRM,
4385- (ply_event_handler_t)
4386- alrm_signal_handler, NULL);
4387-
4388- ply_event_loop_watch_for_timeout (loop, 2.0,
4389- (ply_event_loop_timeout_handler_t)
4390- on_timeout, loop);
4391- ply_event_loop_watch_fd (loop, 0, PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
4392- (ply_event_handler_t) line_received_handler,
4393- (ply_event_handler_t) line_received_handler,
4394- NULL);
4395-
4396- alarm (5);
4397- exit_code = ply_event_loop_run (loop);
4398-
4399- ply_event_loop_free (loop);
4400-
4401- return exit_code;
4402-}
4403-#endif /* PLY_EVENT_LOOP_ENABLE_TEST */
4404 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4405diff --git a/src/libply/ply-hashtable.c b/src/libply/ply-hashtable.c
4406index 7d8d648..7b03d87 100644
4407--- a/src/libply/ply-hashtable.c
4408+++ b/src/libply/ply-hashtable.c
4409@@ -130,14 +130,6 @@ ply_hashtable_insert_internal (ply_hashtable_t *hashtable,
4410 {
4411 unsigned int hash_index;
4412 int step = 0;
4413-
4414-#ifdef PLY_HASHTABLE_ENABLE_TEST
4415- /* Make sure the counts are synchronised with bitmap */
4416- assert (ply_bitarray_count (hashtable->dirty_node_bitmap, hashtable->total_node_count) ==
4417- (int) hashtable->dirty_node_count);
4418- assert (ply_bitarray_count (hashtable->live_node_bitmap, hashtable->total_node_count) ==
4419- (int) hashtable->live_node_count);
4420-#endif /* PLY_HASHTABLE_ENABLE_TEST */
4421
4422 hash_index = hashtable->hash_func (key);
4423 hash_index &= hashtable->total_node_count - 1;
4424@@ -281,56 +273,10 @@ ply_hashtable_foreach (ply_hashtable_t *hashtable,
4425 }
4426 }
4427
4428-
4429-#ifdef PLY_HASHTABLE_ENABLE_TEST
4430-#include <stdio.h>
4431-
4432-static void
4433-foreach_func (void *key,
4434- void *data,
4435- void *user_data)
4436-{
4437- printf ("foreach key:%s data:%s\n", (char*) key, (char*) data);
4438-}
4439-
4440-
4441 int
4442-main (int argc,
4443- char **argv)
4444+ply_hashtable_get_size (ply_hashtable_t *hashtable)
4445 {
4446- ply_hashtable_t *hashtable;
4447- int i;
4448- const char* key[10] = {"k1", "k2", "k3", "k4", "k5", "k6", "k7", "k8", "k9", "k10"};
4449- const char* data[10] = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10"};
4450- char* reply_key = NULL;
4451- char* reply_data = NULL;
4452-
4453- printf ("hashtable test start\n");
4454- hashtable = ply_hashtable_new (ply_hashtable_string_hash, ply_hashtable_string_compare);
4455- for (i=0; i<10; i++)
4456- {
4457- ply_hashtable_insert (hashtable, (void *) key[i], (void *) data[9-i]);
4458- }
4459- for (i=0; i<10; i++)
4460- {
4461- reply_data = ply_hashtable_lookup (hashtable, (void *) key[i]);
4462- printf ("got:%s\n", reply_data);
4463- }
4464- for (i=0; i<10; i++)
4465- {
4466- ply_hashtable_remove (hashtable, (void *) key[i]);
4467- ply_hashtable_insert (hashtable, (void *) key[i], (void *) data[i]);
4468- }
4469- for (i=0; i<10; i++)
4470- {
4471- if (ply_hashtable_lookup_full (hashtable, (void *) key[i], (void**) &reply_key, (void**) &reply_data))
4472- printf ("got key:%s data:%s\n", reply_key, reply_data);
4473- }
4474- ply_hashtable_foreach (hashtable, foreach_func, NULL);
4475- ply_hashtable_free(hashtable);
4476- printf ("hashtable test end\n");
4477- return 0;
4478+ return hashtable->live_node_count;
4479 }
4480
4481-#endif
4482 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4483diff --git a/src/libply/ply-hashtable.h b/src/libply/ply-hashtable.h
4484index 016c781..e7e1a6e 100644
4485--- a/src/libply/ply-hashtable.h
4486+++ b/src/libply/ply-hashtable.h
4487@@ -57,6 +57,8 @@ int ply_hashtable_lookup_full (ply_hashtable_t *hashtable,
4488 void ply_hashtable_foreach (ply_hashtable_t *hashtable,
4489 ply_hashtable_foreach_func_t func,
4490 void *user_data);
4491+
4492+int ply_hashtable_get_size (ply_hashtable_t *hashtable);
4493 #endif
4494
4495 #endif /* PLY_HASHTABLE_H */
4496diff --git a/src/libply/ply-key-file.c b/src/libply/ply-key-file.c
4497index a3d5a11..c62551e 100644
4498--- a/src/libply/ply-key-file.c
4499+++ b/src/libply/ply-key-file.c
4500@@ -25,6 +25,7 @@
4501 #include "ply-key-file.h"
4502
4503 #include <assert.h>
4504+#include <ctype.h>
4505 #include <errno.h>
4506 #include <fcntl.h>
4507 #include <string.h>
4508@@ -75,7 +76,7 @@ ply_key_file_open_file (ply_key_file_t *key_file)
4509 {
4510 assert (key_file != NULL);
4511
4512- key_file->fp = fopen (key_file->filename, "r");
4513+ key_file->fp = fopen (key_file->filename, "re");
4514
4515 if (key_file->fp == NULL)
4516 {
4517@@ -173,13 +174,18 @@ ply_key_file_load_group (ply_key_file_t *key_file,
4518 ply_key_file_entry_t *entry;
4519 char *key;
4520 char *value;
4521- long offset;
4522+ off_t offset;
4523 int first_byte;
4524
4525 key = NULL;
4526 value = NULL;
4527
4528- first_byte = fgetc (key_file->fp);
4529+ do
4530+ {
4531+ first_byte = fgetc (key_file->fp);
4532+ }
4533+ while (isspace (first_byte));
4534+
4535 if (first_byte == '#')
4536 {
4537 char *line_to_toss;
4538@@ -196,13 +202,13 @@ ply_key_file_load_group (ply_key_file_t *key_file,
4539 }
4540 ungetc (first_byte, key_file->fp);
4541
4542- offset = ftell (key_file->fp);
4543- items_matched = fscanf (key_file->fp, " %a[^= \t\n] = %a[^\n] ", &key, &value);
4544+ offset = ftello (key_file->fp);
4545+ items_matched = fscanf (key_file->fp, " %m[^= \t\n] = %m[^\n] ", &key, &value);
4546
4547 if (items_matched != 2)
4548 {
4549 if (items_matched == 1)
4550- fseek (key_file->fp, offset, SEEK_SET);
4551+ fseeko (key_file->fp, offset, SEEK_SET);
4552
4553 free (key);
4554 free (value);
4555@@ -254,7 +260,7 @@ ply_key_file_load_groups (ply_key_file_t *key_file)
4556 ungetc (first_byte, key_file->fp);
4557
4558 group_name = NULL;
4559- items_matched = fscanf (key_file->fp, " [ %a[^]] ] ", &group_name);
4560+ items_matched = fscanf (key_file->fp, " [ %m[^]] ] ", &group_name);
4561
4562 if (items_matched <= 0)
4563 {
4564diff --git a/src/libply/ply-list.c b/src/libply/ply-list.c
4565index 85262ab..8c589c2 100644
4566--- a/src/libply/ply-list.c
4567+++ b/src/libply/ply-list.c
4568@@ -375,85 +375,4 @@ ply_list_node_get_data (ply_list_node_t *node)
4569 return node->data;
4570 }
4571
4572-#ifdef PLY_LIST_ENABLE_TEST
4573-#include <stdio.h>
4574-
4575-static int
4576-compare_int_ptr (void *element_a,
4577- void *element_b)
4578-{
4579- int *int_a = element_a;
4580- int *int_b = element_b;
4581- return *int_a - *int_b;
4582-
4583-}
4584-
4585-int
4586-main (int argc,
4587- char **argv)
4588-{
4589- ply_list_t *list;
4590- ply_list_node_t *node;
4591- int i, lastval;
4592- int *value;
4593- int errors;
4594-
4595- errors = 0;
4596-
4597- list = ply_list_new ();
4598-
4599- ply_list_append_data (list, (void *) "foo");
4600- ply_list_append_data (list, (void *) "bar");
4601- ply_list_append_data (list, (void *) "baz");
4602- ply_list_prepend_data (list, (void *) "qux");
4603- ply_list_prepend_data (list, (void *) "quux");
4604- ply_list_remove_data (list, (void *) "baz");
4605- ply_list_remove_data (list, (void *) "foo");
4606-
4607- node = ply_list_get_first_node (list);
4608- i = 0;
4609- while (node != NULL)
4610- {
4611- printf ("node '%d' has data '%s'\n", i,
4612- (char *) ply_list_node_get_data (node));
4613- node = ply_list_get_next_node (list, node);
4614- i++;
4615- }
4616-
4617- printf ("\n");
4618- ply_list_remove_all_nodes (list);
4619- srandom(1);
4620-
4621- for (i = 0; i<100; i++)
4622- {
4623- value = malloc (sizeof (int));
4624- *value = random() % 100;
4625- ply_list_append_data (list, (void *) value);
4626- }
4627-
4628- ply_list_sort (list, compare_int_ptr);
4629-
4630- node = ply_list_get_first_node (list);
4631- i = 0;
4632- lastval = 0;
4633-
4634- while (node != NULL)
4635- {
4636- value = (int *) ply_list_node_get_data (node);
4637- if (*value < lastval)
4638- {
4639- printf ("ERROR: incorrect order\n");
4640- errors = 1;
4641- }
4642- lastval = *value;
4643- printf ("node '%d' has data '%d'\n", i, *value);
4644- node = ply_list_get_next_node (list, node);
4645- i++;
4646- }
4647-
4648- ply_list_free (list);
4649- return errors;
4650-}
4651-
4652-#endif
4653 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4654diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c
4655index f51bb84..740c30e 100644
4656--- a/src/libply/ply-logger.c
4657+++ b/src/libply/ply-logger.c
4658@@ -40,7 +40,7 @@
4659 #include "ply-list.h"
4660
4661 #ifndef PLY_LOGGER_OPEN_FLAGS
4662-#define PLY_LOGGER_OPEN_FLAGS (O_WRONLY | O_TRUNC | O_CREAT | O_NOFOLLOW)
4663+#define PLY_LOGGER_OPEN_FLAGS (O_WRONLY | O_TRUNC | O_CREAT | O_NOFOLLOW | O_CLOEXEC)
4664 #endif
4665
4666 #ifndef PLY_LOGGER_MAX_INJECTION_SIZE
4667@@ -357,6 +357,9 @@ ply_logger_close_file (ply_logger_t *logger)
4668 {
4669 assert (logger != NULL);
4670
4671+ if (logger->output_fd < 0)
4672+ return;
4673+
4674 close (logger->output_fd);
4675 ply_logger_set_output_fd (logger, -1);
4676 }
4677@@ -595,26 +598,4 @@ ply_logger_is_tracing_enabled (ply_logger_t *logger)
4678 }
4679 #endif /* PLY_ENABLE_TRACING */
4680
4681-#ifdef PLY_LOGGER_ENABLE_TEST
4682-
4683-int
4684-main (int argc,
4685- char **argv)
4686-{
4687- int exit_code;
4688- ply_logger_t *logger;
4689-
4690- exit_code = 0;
4691- logger = ply_logger_new ();
4692-
4693- ply_logger_inject (logger, "yo yo yo\n");
4694- ply_logger_set_output_fd (logger, 1);
4695- ply_logger_inject (logger, "yo yo yo yo\n");
4696- ply_logger_flush (logger);
4697- ply_logger_free (logger);
4698-
4699- return exit_code;
4700-}
4701-
4702-#endif /* PLY_LOGGER_ENABLE_TEST */
4703 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4704diff --git a/src/libply/ply-logger.h b/src/libply/ply-logger.h
4705index 36fe7d1..596bed5 100644
4706--- a/src/libply/ply-logger.h
4707+++ b/src/libply/ply-logger.h
4708@@ -91,8 +91,8 @@ do \
4709 ply_logger_flush (logger); \
4710 errno = _old_errno; \
4711 ply_logger_inject (logger, \
4712- "[%s] %45.45s:" format "\r\n", \
4713- __FILE__, __func__, ##args); \
4714+ "[%s:%d] %45.45s:" format "\r\n", \
4715+ __FILE__, __LINE__, __func__, ##args); \
4716 ply_logger_flush (logger); \
4717 errno = _old_errno; \
4718 } \
4719diff --git a/src/libply/ply-progress.c b/src/libply/ply-progress.c
4720index 2091a27..4a16556 100644
4721--- a/src/libply/ply-progress.c
4722+++ b/src/libply/ply-progress.c
4723@@ -22,6 +22,10 @@
4724 * Charlie Brej <cbrej@cs.man.ac.uk>
4725 */
4726
4727+#ifdef HAVE_CONFIG_H
4728+#include "config.h"
4729+#endif
4730+
4731 #include <assert.h>
4732 #include <errno.h>
4733 #include <math.h>
4734@@ -212,9 +216,14 @@ ply_progress_save_cache (ply_progress_t* progress,
4735 ply_list_node_t *node;
4736 double cur_time = ply_progress_get_time(progress);
4737
4738+ ply_trace ("saving progress cache to %s", filename);
4739+
4740 fp = fopen (filename,"w");
4741 if (fp == NULL)
4742- return;
4743+ {
4744+ ply_trace ("failed to save cache: %m");
4745+ return;
4746+ }
4747
4748 node = ply_list_get_first_node (progress->current_message_list);
4749
4750@@ -326,75 +335,5 @@ ply_progress_status_update (ply_progress_t* progress,
4751 }
4752 }
4753
4754-#ifdef PLY_PROGRESS_ENABLE_TEST
4755-
4756-#include <stdio.h>
4757-
4758-int
4759-main (int argc,
4760- char **argv)
4761-{
4762- double percent;
4763- int slowness;
4764- double time;
4765- int i;
4766- const char* strings[10]={"foobar", "barfoo", "barbar", "foo", "foo", "bar", "foo", "more", "even more", "even even more"};
4767- ply_progress_t* progress = ply_progress_new ();
4768-
4769- progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/
4770-
4771- percent = ply_progress_get_percentage (progress);
4772- time = ply_progress_get_time (progress);
4773- printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
4774- srand ((int) ply_get_timestamp ());
4775-
4776- slowness = rand () % 500000 + 50000;
4777-
4778- for (i=0; i<2; i++)
4779- {
4780- usleep ((rand () % slowness+slowness));
4781- percent = ply_progress_get_percentage (progress);
4782- time = ply_progress_get_time (progress);
4783- printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
4784- }
4785- printf("Load cache\n");
4786- ply_progress_load_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
4787-
4788- for (i=0; i<10; i++)
4789- {
4790- ply_progress_status_update (progress, strings[i]);
4791- usleep ((rand () % slowness+slowness));
4792- percent = ply_progress_get_percentage (progress);
4793- time = ply_progress_get_time (progress);
4794- printf("Time:%f \t Percentage: %f%% \tScalar:%f\n", time, percent*100, progress->scalar);
4795- }
4796- printf("Save and free cache\n");
4797- ply_progress_save_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
4798- ply_progress_free(progress);
4799-
4800- printf("\nManual set percentage run\n\n");
4801-
4802- progress = ply_progress_new ();
4803- progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/
4804-
4805- percent = ply_progress_get_percentage (progress);
4806- time = ply_progress_get_time (progress);
4807- printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
4808- srand ((int) ply_get_timestamp ());
4809-
4810- for (i=0; i<12; i++)
4811- {
4812- ply_progress_set_percentage (progress, (double)i/12);
4813- usleep ((rand () % slowness+slowness));
4814- percent = ply_progress_get_percentage (progress);
4815- time = ply_progress_get_time (progress);
4816- printf("Time:%f \t Percentage: %f%% (%f%%)\tScalar:%f\n", time, percent*100, (double)i/12*100, progress->scalar);
4817- }
4818- ply_progress_free(progress);
4819-
4820- return 0;
4821-}
4822-
4823-#endif /* PLY_PROGRESS_ENABLE_TEST */
4824 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4825
4826diff --git a/src/libply/ply-region.c b/src/libply/ply-region.c
4827index cbaca40..92d3574 100644
4828--- a/src/libply/ply-region.c
4829+++ b/src/libply/ply-region.c
4830@@ -467,141 +467,4 @@ ply_region_get_sorted_rectangle_list (ply_region_t *region)
4831 return region->rectangle_list;
4832 }
4833
4834-#ifdef PLY_REGION_ENABLE_TEST
4835-#include <stdio.h>
4836-
4837-#define COVER_SIZE 100
4838-#define RECTANGLE_COUNT 1000
4839-
4840-static void
4841-cover_with_rect(char cover[COVER_SIZE][COVER_SIZE],
4842- ply_rectangle_t *rectangle,
4843- char value)
4844-{ /* is value is not zero, the entry will be set to the value,
4845- otherwise entry is incremented*/
4846- unsigned long x, y;
4847- for (y=0; y<rectangle->height; y++)
4848- {
4849- for (x=0; x<rectangle->width; x++)
4850- {
4851- if (rectangle->x + x < COVER_SIZE &&
4852- rectangle->y + y < COVER_SIZE)
4853- {
4854- if (value)
4855- cover[rectangle->y + y][rectangle->x + x] = value;
4856- else
4857- cover[rectangle->y + y][rectangle->x + x]++;
4858- }
4859- }
4860- }
4861-}
4862-
4863-static int
4864-do_test (void)
4865-{
4866- ply_rectangle_t rectangle;
4867- char cover[COVER_SIZE][COVER_SIZE];
4868- int i;
4869- unsigned long x, y;
4870- ply_region_t *region;
4871- ply_list_node_t *node;
4872-
4873- region = ply_region_new ();
4874-
4875- for (y = 0; y < COVER_SIZE; y++)
4876- {
4877- for (x = 0; x < COVER_SIZE; x++)
4878- {
4879- cover[y][x] = 0;
4880- }
4881- }
4882-
4883- for (i = 0; i < RECTANGLE_COUNT; i++)
4884- {
4885- rectangle.x = random() % COVER_SIZE-5;
4886- rectangle.y = random() % COVER_SIZE-5;
4887- rectangle.width = 1 + random() % 20;
4888- rectangle.height = 1 + random() % 20;
4889- printf("Adding X=%ld Y=%ld W=%ld H=%ld\n",
4890- rectangle.x,
4891- rectangle.y,
4892- rectangle.width,
4893- rectangle.height);
4894- cover_with_rect(cover, &rectangle, 100); /* 100 means covered by origial squares */
4895- ply_region_add_rectangle (region, &rectangle);
4896- }
4897-
4898- printf("Converted to:\n");
4899- int count = 0;
4900-
4901- ply_list_t *rectangle_list = ply_region_get_rectangle_list (region);
4902- for (node = ply_list_get_first_node (rectangle_list);
4903- node;
4904- node = ply_list_get_next_node (rectangle_list, node))
4905- {
4906- ply_rectangle_t *small_rectangle = ply_list_node_get_data (node);
4907- printf("Processed X=%ld Y=%ld W=%ld H=%ld\n",
4908- small_rectangle->x,
4909- small_rectangle->y,
4910- small_rectangle->width,
4911- small_rectangle->height);
4912- cover_with_rect(cover, small_rectangle, 0);
4913- count++;
4914- }
4915- printf("Rectangles in:%d out:%d\n", RECTANGLE_COUNT, count);
4916-
4917- count=0;
4918-
4919- for (y = 0; y < COVER_SIZE; y++)
4920- {
4921- printf("%03ld ", y);
4922- for (x = 0; x < COVER_SIZE; x++)
4923- {
4924- if (cover[y][x] >= 100)
4925- {
4926- if (cover[y][x] == 100)
4927- {
4928- printf("-"); /* "-" means should have been covered but wasn't */
4929- count++;
4930- }
4931- else
4932- {
4933- if (cover[y][x] == 101)
4934- printf("O"); /* "O" means correctly covered */
4935- else
4936- {
4937- printf("%d", cover[y][x] - 101);
4938- count++; /* 1+ means covered multiple times*/
4939- }
4940- }
4941- }
4942- else
4943- {
4944- if (cover[y][x] == 0)
4945- printf("o"); /* "o" means not involved*/
4946- else
4947- {
4948- printf("%c", 'A' - 1 + cover[y][x]);
4949- count++; /* A+ means covered despite being not involved*/
4950- }
4951- }
4952- }
4953- printf("\n");
4954- }
4955- printf("errors:%d\n", count);
4956- return count;
4957-}
4958-int
4959-main (int argc,
4960- char **argv)
4961-{
4962- int i;
4963- srandom(312);
4964- for (i=0; i<100; i++)
4965- {
4966- if (do_test ()) return 1;
4967- }
4968- return 0;
4969-}
4970-#endif
4971 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4972diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c
4973index 3d43709..379035c 100644
4974--- a/src/libply/ply-terminal-session.c
4975+++ b/src/libply/ply-terminal-session.c
4976@@ -148,7 +148,8 @@ ply_terminal_session_free (ply_terminal_session_t *session)
4977
4978 ply_free_string_array (session->argv);
4979
4980- close (session->pseudoterminal_master_fd);
4981+ if (session->pseudoterminal_master_fd >= 0)
4982+ close (session->pseudoterminal_master_fd);
4983 free (session);
4984 }
4985
4986@@ -213,8 +214,12 @@ ply_terminal_session_unredirect_console (ply_terminal_session_t *session)
4987 assert (session->console_is_redirected);
4988
4989 fd = open ("/dev/console", O_RDWR | O_NOCTTY);
4990- if (fd >= 0)
4991+ if (fd >= 0) {
4992 ioctl (fd, TIOCCONS);
4993+ close (fd);
4994+ } else {
4995+ ply_trace ("couldn't open /dev/console to stop redirecting it: %m");
4996+ }
4997
4998 session->console_is_redirected = false;
4999 }
5000@@ -582,57 +587,4 @@ ply_terminal_session_close_log (ply_terminal_session_t *session)
5001 return ply_logger_close_file (session->logger);
5002 }
5003
5004-#ifdef PLY_TERMINAL_SESSION_ENABLE_TEST
5005-
5006-#include <stdio.h>
5007-
5008-#include "ply-event-loop.h"
5009-#include "ply-terminal-session.h"
5010-
5011-static void
5012-on_finished (ply_event_loop_t *loop)
5013-{
5014- ply_event_loop_exit (loop, 0);
5015-}
5016-
5017-int
5018-main (int argc,
5019- char **argv)
5020-{
5021- ply_event_loop_t *loop;
5022- ply_terminal_session_t *session;
5023- int exit_code;
5024- ply_terminal_session_flags_t flags;
5025-
5026- exit_code = 0;
5027-
5028- loop = ply_event_loop_new ();
5029-
5030- session = ply_terminal_session_new ((const char * const *) (argv + 1));
5031-
5032- flags = PLY_TERMINAL_SESSION_FLAGS_RUN_IN_PARENT;
5033- flags |= PLY_TERMINAL_SESSION_FLAGS_LOOK_IN_PATH;
5034-
5035- ply_terminal_session_attach_to_event_loop (session, loop);
5036-
5037- if (!ply_terminal_session_run (session, flags,
5038- (ply_terminal_session_begin_handler_t) NULL,
5039- (ply_terminal_session_output_handler_t) NULL,
5040- (ply_terminal_session_hangup_handler_t)
5041- on_finished, loop))
5042- {
5043- perror ("could not start terminal session");
5044- return errno;
5045- }
5046-
5047- ply_terminal_session_open_log (session, "foo.log");
5048-
5049- exit_code = ply_event_loop_run (loop);
5050-
5051- ply_terminal_session_free (session);
5052-
5053- return exit_code;
5054-}
5055-
5056-#endif /* PLY_TERMINAL_SESSION_ENABLE_TEST */
5057 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
5058diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c
5059index 60d59d1..8333485 100644
5060--- a/src/libply/ply-utils.c
5061+++ b/src/libply/ply-utils.c
5062@@ -87,27 +87,9 @@ ply_open_unidirectional_pipe (int *sender_fd,
5063 assert (sender_fd != NULL);
5064 assert (receiver_fd != NULL);
5065
5066- if (pipe (pipe_fds) < 0)
5067+ if (pipe2 (pipe_fds, O_CLOEXEC) < 0)
5068 return false;
5069
5070- if (fcntl (pipe_fds[0], F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
5071- {
5072- ply_save_errno ();
5073- close (pipe_fds[0]);
5074- close (pipe_fds[1]);
5075- ply_restore_errno ();
5076- return false;
5077- }
5078-
5079- if (fcntl (pipe_fds[1], F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
5080- {
5081- ply_save_errno ();
5082- close (pipe_fds[0]);
5083- close (pipe_fds[1]);
5084- ply_restore_errno ();
5085- return false;
5086- }
5087-
5088 *sender_fd = pipe_fds[1];
5089 *receiver_fd = pipe_fds[0];
5090
5091@@ -120,20 +102,11 @@ ply_open_unix_socket (void)
5092 int fd;
5093 const int should_pass_credentials = true;
5094
5095- fd = socket (PF_UNIX, SOCK_STREAM, 0);
5096+ fd = socket (PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
5097
5098 if (fd < 0)
5099 return -1;
5100
5101- if (fcntl (fd, F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
5102- {
5103- ply_save_errno ();
5104- close (fd);
5105- ply_restore_errno ();
5106-
5107- return -1;
5108- }
5109-
5110 if (setsockopt (fd, SOL_SOCKET, SO_PASSCRED,
5111 &should_pass_credentials, sizeof (should_pass_credentials)) < 0)
5112 {
5113@@ -822,11 +795,12 @@ ply_create_daemon (void)
5114
5115 if (!ply_read (receiver_fd, &byte, sizeof (uint8_t)))
5116 {
5117+ int read_error = errno;
5118 int status;
5119
5120 if (waitpid (pid, &status, WNOHANG) <= 0)
5121 {
5122- ply_error ("failed to read status from child immediately after starting to daemonize");
5123+ ply_error ("failed to read status from child immediately after starting to daemonize: %s", strerror (read_error));
5124 }
5125 else if (WIFEXITED (status))
5126 {
5127@@ -971,7 +945,7 @@ ply_get_process_parent_pid (pid_t pid)
5128 asprintf (&path, "/proc/%ld/stat", (long) pid);
5129
5130 ppid = 0;
5131- fp = fopen (path, "r");
5132+ fp = fopen (path, "re");
5133
5134 if (fp == NULL)
5135 {
5136diff --git a/src/libply/tests/Makefile.am b/src/libply/tests/Makefile.am
5137deleted file mode 100644
5138index bc4da58..0000000
5139--- a/src/libply/tests/Makefile.am
5140+++ /dev/null
5141@@ -1,25 +0,0 @@
5142-INCLUDES = \
5143- -I$(top_srcdir) \
5144- -I$(srcdir)/.. \
5145- -I$(srcdir)
5146-TESTS =
5147-
5148-if ENABLE_TESTS
5149-include $(srcdir)/ply-terminal-session-test.am
5150-include $(srcdir)/ply-logger-test.am
5151-include $(srcdir)/ply-array-test.am
5152-include $(srcdir)/ply-bitarray-test.am
5153-include $(srcdir)/ply-list-test.am
5154-include $(srcdir)/ply-hashtable-test.am
5155-include $(srcdir)/ply-event-loop-test.am
5156-include $(srcdir)/ply-command-parser-test.am
5157-include $(srcdir)/ply-progress-test.am
5158-include $(srcdir)/ply-region.am
5159-endif
5160-
5161-noinst_PROGRAMS = $(TESTS)
5162-
5163-# Our tests aren't unit tests so clear for now
5164-TESTS =
5165-
5166-MAINTAINERCLEANFILES = Makefile.in
5167diff --git a/src/libply/tests/ply-array-test.am b/src/libply/tests/ply-array-test.am
5168deleted file mode 100644
5169index 4f8ecc4..0000000
5170--- a/src/libply/tests/ply-array-test.am
5171+++ /dev/null
5172@@ -1,16 +0,0 @@
5173-TESTS += ply-array-test
5174-
5175-ply_array_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_ARRAY_ENABLE_TEST
5176-ply_array_test_LDADD = $(PLYMOUTH_LIBS)
5177-
5178-ply_array_test_SOURCES = \
5179- $(srcdir)/../ply-buffer.h \
5180- $(srcdir)/../ply-buffer.c \
5181- $(srcdir)/../ply-list.h \
5182- $(srcdir)/../ply-list.c \
5183- $(srcdir)/../ply-logger.h \
5184- $(srcdir)/../ply-logger.c \
5185- $(srcdir)/../ply-utils.h \
5186- $(srcdir)/../ply-utils.c \
5187- $(srcdir)/../ply-array.h \
5188- $(srcdir)/../ply-array.c
5189diff --git a/src/libply/tests/ply-bitarray-test.am b/src/libply/tests/ply-bitarray-test.am
5190deleted file mode 100644
5191index 85c3608..0000000
5192--- a/src/libply/tests/ply-bitarray-test.am
5193+++ /dev/null
5194@@ -1,8 +0,0 @@
5195-TESTS += ply-bitarray-test
5196-
5197-ply_bitarray_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BITARRAY_ENABLE_TEST
5198-ply_bitarray_test_LDADD = $(PLYMOUTH_LIBS)
5199-
5200-ply_bitarray_test_SOURCES = \
5201- $(srcdir)/../ply-bitarray.h \
5202- $(srcdir)/../ply-bitarray.c
5203diff --git a/src/libply/tests/ply-command-parser-test.am b/src/libply/tests/ply-command-parser-test.am
5204deleted file mode 100644
5205index 91649d5..0000000
5206--- a/src/libply/tests/ply-command-parser-test.am
5207+++ /dev/null
5208@@ -1,18 +0,0 @@
5209-TESTS += ply-command-parser-test
5210-
5211-ply_command_parser_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_COMMAND_PARSER_ENABLE_TEST
5212-ply_command_parser_test_LDADD = $(PLYMOUTH_LIBS)
5213-
5214-ply_command_parser_test_SOURCES = \
5215- $(srcdir)/../ply-buffer.h \
5216- $(srcdir)/../ply-buffer.c \
5217- $(srcdir)/../ply-event-loop.h \
5218- $(srcdir)/../ply-event-loop.c \
5219- $(srcdir)/../ply-list.h \
5220- $(srcdir)/../ply-list.c \
5221- $(srcdir)/../ply-logger.h \
5222- $(srcdir)/../ply-logger.c \
5223- $(srcdir)/../ply-utils.h \
5224- $(srcdir)/../ply-utils.c \
5225- $(srcdir)/../ply-command-parser.h \
5226- $(srcdir)/../ply-command-parser.c
5227diff --git a/src/libply/tests/ply-event-loop-test.am b/src/libply/tests/ply-event-loop-test.am
5228deleted file mode 100644
5229index c666ea6..0000000
5230--- a/src/libply/tests/ply-event-loop-test.am
5231+++ /dev/null
5232@@ -1,14 +0,0 @@
5233-TESTS += ply-event-loop-test
5234-
5235-ply_event_loop_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_EVENT_LOOP_ENABLE_TEST
5236-ply_event_loop_test_LDADD = $(PLYMOUTH_LIBS)
5237-
5238-ply_event_loop_test_SOURCES = \
5239- $(srcdir)/../ply-utils.h \
5240- $(srcdir)/../ply-utils.c \
5241- $(srcdir)/../ply-list.h \
5242- $(srcdir)/../ply-list.c \
5243- $(srcdir)/../ply-logger.h \
5244- $(srcdir)/../ply-logger.c \
5245- $(srcdir)/../ply-event-loop.h \
5246- $(srcdir)/../ply-event-loop.c
5247diff --git a/src/libply/tests/ply-hashtable-test.am b/src/libply/tests/ply-hashtable-test.am
5248deleted file mode 100644
5249index d3410fc..0000000
5250--- a/src/libply/tests/ply-hashtable-test.am
5251+++ /dev/null
5252@@ -1,10 +0,0 @@
5253-TESTS += ply-hashtable-test
5254-
5255-ply_hashtable_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_HASHTABLE_ENABLE_TEST
5256-ply_hashtable_test_LDADD = $(PLYMOUTH_LIBS)
5257-
5258-ply_hashtable_test_SOURCES = \
5259- $(srcdir)/../ply-hashtable.h \
5260- $(srcdir)/../ply-hashtable.c \
5261- $(srcdir)/../ply-bitarray.h \
5262- $(srcdir)/../ply-bitarray.c
5263diff --git a/src/libply/tests/ply-list-test.am b/src/libply/tests/ply-list-test.am
5264deleted file mode 100644
5265index 8beb578..0000000
5266--- a/src/libply/tests/ply-list-test.am
5267+++ /dev/null
5268@@ -1,8 +0,0 @@
5269-TESTS += ply-list-test
5270-
5271-ply_list_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_LIST_ENABLE_TEST
5272-ply_list_test_LDADD = $(PLYMOUTH_LIBS)
5273-
5274-ply_list_test_SOURCES = \
5275- $(srcdir)/../ply-list.h \
5276- $(srcdir)/../ply-list.c
5277diff --git a/src/libply/tests/ply-logger-test.am b/src/libply/tests/ply-logger-test.am
5278deleted file mode 100644
5279index a589fb9..0000000
5280--- a/src/libply/tests/ply-logger-test.am
5281+++ /dev/null
5282@@ -1,12 +0,0 @@
5283-TESTS += ply-logger-test
5284-
5285-ply_logger_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_LOGGER_ENABLE_TEST
5286-ply_logger_test_LDADD = $(PLYMOUTH_LIBS)
5287-
5288-ply_logger_test_SOURCES = \
5289- $(srcdir)/../ply-list.h \
5290- $(srcdir)/../ply-list.c \
5291- $(srcdir)/../ply-utils.h \
5292- $(srcdir)/../ply-utils.c \
5293- $(srcdir)/../ply-logger.h \
5294- $(srcdir)/../ply-logger.c
5295diff --git a/src/libply/tests/ply-progress-test.am b/src/libply/tests/ply-progress-test.am
5296deleted file mode 100644
5297index 6279fac..0000000
5298--- a/src/libply/tests/ply-progress-test.am
5299+++ /dev/null
5300@@ -1,15 +0,0 @@
5301-TESTS += ply-progress-test
5302-
5303-ply_progress_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_PROGRESS_ENABLE_TEST \
5304- -DPLYMOUTH_TIME_DIRECTORY=\"$(localstatedir)/lib/plymouth/\"
5305-ply_progress_test_LDADD = $(PLYMOUTH_LIBS)
5306-
5307-ply_progress_test_SOURCES = \
5308- $(srcdir)/../ply-progress.h \
5309- $(srcdir)/../ply-progress.c \
5310- $(srcdir)/../ply-list.h \
5311- $(srcdir)/../ply-list.c \
5312- $(srcdir)/../ply-logger.h \
5313- $(srcdir)/../ply-logger.c \
5314- $(srcdir)/../ply-utils.h \
5315- $(srcdir)/../ply-utils.c
5316diff --git a/src/libply/tests/ply-region.am b/src/libply/tests/ply-region.am
5317deleted file mode 100644
5318index 1883833..0000000
5319--- a/src/libply/tests/ply-region.am
5320+++ /dev/null
5321@@ -1,12 +0,0 @@
5322-TESTS += ply-region-test
5323-
5324-ply_region_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_REGION_ENABLE_TEST
5325-ply_region_test_LDADD = $(PLYMOUTH_LIBS)
5326-
5327-ply_region_test_SOURCES = \
5328- $(srcdir)/../ply-region.h \
5329- $(srcdir)/../ply-region.c \
5330- $(srcdir)/../ply-rectangle.h \
5331- $(srcdir)/../ply-rectangle.c \
5332- $(srcdir)/../ply-list.h \
5333- $(srcdir)/../ply-list.c
5334diff --git a/src/libply/tests/ply-terminal-session-test.am b/src/libply/tests/ply-terminal-session-test.am
5335deleted file mode 100644
5336index decb531..0000000
5337--- a/src/libply/tests/ply-terminal-session-test.am
5338+++ /dev/null
5339@@ -1,18 +0,0 @@
5340-TESTS += ply-terminal-session-test
5341-
5342-ply_terminal_session_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_TERMINAL_SESSION_ENABLE_TEST
5343-ply_terminal_session_test_LDADD = $(PLYMOUTH_LIBS)
5344-
5345-ply_terminal_session_test_SOURCES = \
5346- $(srcdir)/../ply-utils.h \
5347- $(srcdir)/../ply-utils.c \
5348- $(srcdir)/../ply-buffer.h \
5349- $(srcdir)/../ply-buffer.c \
5350- $(srcdir)/../ply-logger.h \
5351- $(srcdir)/../ply-logger.c \
5352- $(srcdir)/../ply-list.h \
5353- $(srcdir)/../ply-list.c \
5354- $(srcdir)/../ply-event-loop.h \
5355- $(srcdir)/../ply-event-loop.c \
5356- $(srcdir)/../ply-terminal-session.h \
5357- $(srcdir)/../ply-terminal-session.c
5358diff --git a/src/main.c b/src/main.c
5359index 88e5002..c3daac0 100644
5360--- a/src/main.c
5361+++ b/src/main.c
5362@@ -23,6 +23,7 @@
5363
5364 #include <sys/stat.h>
5365 #include <sys/types.h>
5366+#include <math.h>
5367 #include <ctype.h>
5368 #include <limits.h>
5369 #include <dirent.h>
5370@@ -35,6 +36,7 @@
5371 #include <wchar.h>
5372 #include <paths.h>
5373 #include <assert.h>
5374+#include <values.h>
5375
5376 #include <linux/kd.h>
5377 #include <linux/vt.h>
5378@@ -43,10 +45,12 @@
5379 #include "ply-command-parser.h"
5380 #include "ply-boot-server.h"
5381 #include "ply-boot-splash.h"
5382+#include "ply-device-manager.h"
5383 #include "ply-event-loop.h"
5384 #include "ply-hashtable.h"
5385 #include "ply-list.h"
5386 #include "ply-logger.h"
5387+#include "ply-renderer.h"
5388 #include "ply-terminal-session.h"
5389 #include "ply-trigger.h"
5390 #include "ply-utils.h"
5391@@ -84,9 +88,6 @@ typedef struct
5392 {
5393 ply_event_loop_t *loop;
5394 ply_boot_server_t *boot_server;
5395- ply_list_t *pixel_displays;
5396- ply_list_t *text_displays;
5397- ply_keyboard_t *keyboard;
5398 ply_boot_splash_t *boot_splash;
5399 ply_terminal_session_t *session;
5400 ply_buffer_t *boot_buffer;
5401@@ -97,12 +98,15 @@ typedef struct
5402 ply_list_t *messages;
5403 ply_command_parser_t *command_parser;
5404 ply_mode_t mode;
5405- ply_renderer_t *renderer;
5406 ply_terminal_t *local_console_terminal;
5407+ ply_device_manager_t *device_manager;
5408
5409 ply_trigger_t *deactivate_trigger;
5410 ply_trigger_t *quit_trigger;
5411
5412+ double start_time;
5413+ double splash_delay;
5414+
5415 char kernel_command_line[PLY_MAX_COMMAND_LINE_SIZE];
5416 uint32_t kernel_command_line_is_set : 1;
5417 uint32_t no_boot_log : 1;
5418@@ -113,9 +117,9 @@ typedef struct
5419 uint32_t should_be_attached : 1;
5420 uint32_t should_retain_splash : 1;
5421 uint32_t is_inactive : 1;
5422+ uint32_t is_shown : 1;
5423 uint32_t should_force_details : 1;
5424
5425- char *kernel_console_tty;
5426 char *override_splash_path;
5427 char *system_default_splash_path;
5428 char *distribution_default_splash_path;
5429@@ -124,15 +128,15 @@ typedef struct
5430 int number_of_errors;
5431 } state_t;
5432
5433-static ply_boot_splash_t *start_boot_splash (state_t *state,
5434- const char *theme_path,
5435- bool fall_back_if_neccessary);
5436-
5437-static void add_display_and_keyboard_for_terminal (state_t *state,
5438- ply_terminal_t *terminal);
5439-
5440-static void add_default_displays_and_keyboard (state_t *state);
5441+static void show_splash (state_t *state);
5442+static ply_boot_splash_t *load_built_in_theme (state_t *state);
5443+static ply_boot_splash_t *load_theme (state_t *state,
5444+ const char *theme_path);
5445+static ply_boot_splash_t *show_theme (state_t *state,
5446+ const char *theme_path);
5447
5448+static void attach_splash_to_seats (state_t *state,
5449+ ply_boot_splash_t *splash);
5450 static bool attach_to_running_session (state_t *state);
5451 static void detach_from_running_session (state_t *state);
5452 static void on_escape_pressed (state_t *state);
5453@@ -145,12 +149,19 @@ static void on_error_message (ply_buffer_t *debug_buffer,
5454 static ply_buffer_t *debug_buffer;
5455 static char *debug_buffer_path = NULL;
5456 static char *pid_file = NULL;
5457-static void check_for_consoles (state_t *state,
5458- const char *default_tty,
5459- bool should_add_displays);
5460 static void toggle_between_splash_and_details (state_t *state);
5461+#ifdef PLY_ENABLE_SYSTEMD_INTEGRATION
5462 static void tell_systemd_to_print_details (state_t *state);
5463 static void tell_systemd_to_stop_printing_details (state_t *state);
5464+#endif
5465+static const char * get_cache_file_for_mode (ply_mode_t mode);
5466+static void on_escape_pressed (state_t *state);
5467+static void on_enter (state_t *state,
5468+ const char *line);
5469+static void on_keyboard_input (state_t *state,
5470+ const char *keyboard_input,
5471+ size_t character_size);
5472+static void on_backspace (state_t *state);
5473
5474 static void
5475 on_session_output (state_t *state,
5476@@ -249,21 +260,68 @@ show_messages (state_t *state)
5477 }
5478 }
5479
5480+static bool
5481+load_settings (state_t *state,
5482+ const char *path,
5483+ char **theme_path)
5484+{
5485+ ply_key_file_t *key_file = NULL;
5486+ const char *delay_string;
5487+ bool settings_loaded = false;
5488+ const char *splash_string;
5489+
5490+ ply_trace ("Trying to load %s", path);
5491+ key_file = ply_key_file_new (path);
5492+
5493+ if (!ply_key_file_load (key_file))
5494+ goto out;
5495+
5496+ splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
5497+
5498+ if (splash_string == NULL)
5499+ goto out;
5500+
5501+ asprintf (theme_path,
5502+ PLYMOUTH_THEME_PATH "%s/%s.plymouth",
5503+ splash_string, splash_string);
5504+
5505+ if (isnan (state->splash_delay))
5506+ {
5507+ delay_string = ply_key_file_get_value (key_file, "Daemon", "ShowDelay");
5508+
5509+ if (delay_string != NULL)
5510+ {
5511+ state->splash_delay = atof (delay_string);
5512+ ply_trace ("Splash delay is set to %lf", state->splash_delay);
5513+ }
5514+ }
5515+
5516+ settings_loaded = true;
5517+out:
5518+ ply_key_file_free (key_file);
5519+
5520+ return settings_loaded;
5521+}
5522+
5523 static void
5524 show_detailed_splash (state_t *state)
5525 {
5526+ ply_boot_splash_t *splash;
5527+
5528 if (state->boot_splash != NULL)
5529 return;
5530
5531 ply_trace ("Showing detailed splash screen");
5532- state->boot_splash = start_boot_splash (state,
5533- PLYMOUTH_THEME_PATH "details/details.plymouth",
5534- true);
5535+ splash = show_theme (state, NULL);
5536
5537- if (state->boot_splash == NULL)
5538+ if (splash == NULL)
5539 {
5540 ply_trace ("Could not start detailed splash screen, this could be a problem.");
5541+ return;
5542 }
5543+
5544+ state->boot_splash = splash;
5545+ update_display (state);
5546 }
5547
5548 static const char *
5549@@ -326,64 +384,46 @@ find_override_splash (state_t *state)
5550 PLYMOUTH_THEME_PATH "%*.*s/%*.*s.plymouth",
5551 length, length, splash_string, length, length, splash_string);
5552 }
5553+
5554+ if (isnan (state->splash_delay))
5555+ {
5556+ const char *delay_string;
5557+
5558+ delay_string = command_line_get_string_after_prefix (state->kernel_command_line, "plymouth.splash-delay=");
5559+
5560+ if (delay_string != NULL)
5561+ state->splash_delay = atof (delay_string);
5562+ }
5563 }
5564
5565 static void
5566 find_system_default_splash (state_t *state)
5567 {
5568- ply_key_file_t *key_file;
5569- char *splash_string;
5570-
5571 if (state->system_default_splash_path != NULL)
5572 return;
5573
5574- ply_trace ("Trying to load " PLYMOUTH_CONF_DIR "plymouthd.conf");
5575- key_file = ply_key_file_new (PLYMOUTH_CONF_DIR "plymouthd.conf");
5576-
5577- if (!ply_key_file_load (key_file))
5578+ if (!load_settings (state, PLYMOUTH_CONF_DIR "plymouthd.conf", &state->system_default_splash_path))
5579 {
5580 ply_trace ("failed to load " PLYMOUTH_CONF_DIR "plymouthd.conf");
5581- ply_key_file_free (key_file);
5582 return;
5583 }
5584
5585- splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
5586-
5587- ply_trace ("System default splash is configured to be '%s'", splash_string);
5588-
5589- asprintf (&state->system_default_splash_path,
5590- PLYMOUTH_THEME_PATH "%s/%s.plymouth",
5591- splash_string, splash_string);
5592- free (splash_string);
5593+ ply_trace ("System configured theme file is '%s'", state->system_default_splash_path);
5594 }
5595
5596 static void
5597 find_distribution_default_splash (state_t *state)
5598 {
5599- ply_key_file_t *key_file;
5600- char *splash_string;
5601-
5602 if (state->distribution_default_splash_path != NULL)
5603 return;
5604
5605- ply_trace ("Trying to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults");
5606- key_file = ply_key_file_new (PLYMOUTH_POLICY_DIR "plymouthd.defaults");
5607-
5608- if (!ply_key_file_load (key_file))
5609+ if (!load_settings (state, PLYMOUTH_POLICY_DIR "plymouthd.defaults", &state->distribution_default_splash_path))
5610 {
5611 ply_trace ("failed to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults");
5612- ply_key_file_free (key_file);
5613 return;
5614 }
5615
5616- splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
5617-
5618- ply_trace ("Distribution default splash is configured to be '%s'", splash_string);
5619-
5620- asprintf (&state->distribution_default_splash_path,
5621- PLYMOUTH_THEME_PATH "%s/%s.plymouth",
5622- splash_string, splash_string);
5623- free (splash_string);
5624+ ply_trace ("Distribution default theme file is '%s'", state->distribution_default_splash_path);
5625 }
5626
5627 static void
5628@@ -393,63 +433,66 @@ show_default_splash (state_t *state)
5629 return;
5630
5631 ply_trace ("Showing splash screen");
5632- find_override_splash (state);
5633 if (state->override_splash_path != NULL)
5634 {
5635 ply_trace ("Trying override splash at '%s'", state->override_splash_path);
5636- state->boot_splash = start_boot_splash (state,
5637- state->override_splash_path,
5638- false);
5639+ state->boot_splash = show_theme (state, state->override_splash_path);
5640 }
5641
5642- find_system_default_splash (state);
5643 if (state->boot_splash == NULL &&
5644 state->system_default_splash_path != NULL)
5645 {
5646 ply_trace ("Trying system default splash");
5647- state->boot_splash = start_boot_splash (state,
5648- state->system_default_splash_path,
5649- false);
5650+ state->boot_splash = show_theme (state, state->system_default_splash_path);
5651 }
5652
5653- find_distribution_default_splash (state);
5654 if (state->boot_splash == NULL &&
5655 state->distribution_default_splash_path != NULL)
5656 {
5657 ply_trace ("Trying distribution default splash");
5658- state->boot_splash = start_boot_splash (state,
5659- state->distribution_default_splash_path,
5660- false);
5661+ state->boot_splash = show_theme (state, state->distribution_default_splash_path);
5662 }
5663
5664 if (state->boot_splash == NULL)
5665 {
5666 ply_trace ("Trying old scheme for default splash");
5667- state->boot_splash = start_boot_splash (state,
5668- PLYMOUTH_THEME_PATH "default.plymouth",
5669- false);
5670+ state->boot_splash = show_theme (state, PLYMOUTH_THEME_PATH "default.plymouth");
5671 }
5672
5673 if (state->boot_splash == NULL)
5674 {
5675 ply_trace ("Could not start default splash screen,"
5676 "showing text splash screen");
5677- state->boot_splash = start_boot_splash (state,
5678- PLYMOUTH_THEME_PATH "text/text.plymouth",
5679- false);
5680+ state->boot_splash = show_theme (state, PLYMOUTH_THEME_PATH "text/text.plymouth");
5681 }
5682
5683 if (state->boot_splash == NULL)
5684 {
5685 ply_trace ("Could not start text splash screen,"
5686- "showing built-in fallback");
5687- state->boot_splash = start_boot_splash (state,
5688- PLYMOUTH_THEME_PATH "text/text.plymouth",
5689- true);
5690+ "showing built-in splash screen");
5691+ state->boot_splash = show_theme (state, NULL);
5692 }
5693
5694 if (state->boot_splash == NULL)
5695- ply_error ("plymouthd: could not start boot splash: %m");
5696+ {
5697+ ply_error ("plymouthd: could not start boot splash: %m");
5698+ return;
5699+ }
5700+
5701+ update_display (state);
5702+}
5703+
5704+static void
5705+cancel_pending_delayed_show (state_t *state)
5706+{
5707+ if (isnan (state->splash_delay))
5708+ return;
5709+
5710+ ply_event_loop_stop_watching_for_timeout (state->loop,
5711+ (ply_event_loop_timeout_handler_t)
5712+ show_splash,
5713+ state);
5714+ state->splash_delay = NAN;
5715 }
5716
5717 static void
5718@@ -459,13 +502,36 @@ on_ask_for_password (state_t *state,
5719 {
5720 ply_entry_trigger_t *entry_trigger;
5721
5722- /* No splash, client will have to get password
5723- */
5724 if (state->boot_splash == NULL)
5725 {
5726- ply_trace ("no splash loaded, replying immediately with no password");
5727- ply_trigger_pull (answer, NULL);
5728- return;
5729+ /* Waiting to be shown, boot splash will
5730+ * arrive shortly so just sit tight
5731+ */
5732+ if (state->is_shown)
5733+ {
5734+ bool has_open_seats;
5735+
5736+ cancel_pending_delayed_show (state);
5737+
5738+ has_open_seats = ply_device_manager_has_open_seats (state->device_manager);
5739+
5740+ if (has_open_seats)
5741+ {
5742+ ply_trace ("seats open now, showing splash immediately");
5743+ show_splash (state);
5744+ }
5745+ else
5746+ {
5747+ ply_trace ("splash still coming up, waiting a bit");
5748+ }
5749+ }
5750+ else
5751+ {
5752+ /* No splash, client will have to get password */
5753+ ply_trace ("no splash loaded, replying immediately with no password");
5754+ ply_trigger_pull (answer, NULL);
5755+ return;
5756+ }
5757 }
5758
5759 entry_trigger = calloc (1, sizeof (ply_entry_trigger_t));
5760@@ -587,17 +653,11 @@ static void
5761 on_newroot (state_t *state,
5762 const char *root_dir)
5763 {
5764- if (state->mode != PLY_MODE_BOOT)
5765- {
5766- ply_trace ("new root is only supported in boot mode ");
5767- return;
5768- }
5769-
5770 ply_trace ("new root mounted at \"%s\", switching to it", root_dir);
5771 chdir(root_dir);
5772 chroot(".");
5773 chdir("/");
5774- ply_progress_load_cache (state->progress, BOOT_DURATION_FILE);
5775+ ply_progress_load_cache (state->progress, get_cache_file_for_mode (state->mode));
5776 if (state->boot_splash != NULL)
5777 ply_boot_splash_root_mounted (state->boot_splash);
5778 }
5779@@ -619,7 +679,7 @@ get_cache_file_for_mode (ply_mode_t mode)
5780 filename = NULL;
5781 break;
5782 default:
5783- fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
5784+ ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
5785 abort ();
5786 break;
5787 }
5788@@ -629,21 +689,24 @@ get_cache_file_for_mode (ply_mode_t mode)
5789 }
5790
5791 static const char *
5792-get_log_file_for_mode (ply_mode_t mode)
5793+get_log_file_for_state (state_t *state)
5794 {
5795 const char *filename;
5796
5797- switch ((int)mode)
5798+ switch ((int)state->mode)
5799 {
5800 case PLY_MODE_BOOT:
5801- filename = PLYMOUTH_LOG_DIRECTORY "/boot.log";
5802+ if (state->no_boot_log)
5803+ filename = NULL;
5804+ else
5805+ filename = PLYMOUTH_LOG_DIRECTORY "/boot.log";
5806 break;
5807 case PLY_MODE_SHUTDOWN:
5808 case PLY_MODE_UPDATES:
5809 filename = _PATH_DEVNULL;
5810 break;
5811 default:
5812- fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
5813+ ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
5814 abort ();
5815 break;
5816 }
5817@@ -667,7 +730,7 @@ get_log_spool_file_for_mode (ply_mode_t mode)
5818 filename = NULL;
5819 break;
5820 default:
5821- fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
5822+ ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
5823 abort ();
5824 break;
5825 }
5826@@ -684,7 +747,7 @@ spool_error (state_t *state)
5827
5828 ply_trace ("spooling error for viewer");
5829
5830- logfile = get_log_file_for_mode (state->mode);
5831+ logfile = get_log_file_for_state (state);
5832 logspool = get_log_spool_file_for_mode (state->mode);
5833
5834 if (logfile != NULL && logspool != NULL)
5835@@ -712,11 +775,16 @@ prepare_logging (state_t *state)
5836 return;
5837 }
5838
5839- logfile = get_log_file_for_mode (state->mode);
5840+ logfile = get_log_file_for_state (state);
5841 if (logfile != NULL)
5842 {
5843+ bool log_opened;
5844 ply_trace ("opening log '%s'", logfile);
5845- ply_terminal_session_open_log (state->session, logfile);
5846+
5847+ log_opened = ply_terminal_session_open_log (state->session, logfile);
5848+
5849+ if (!log_opened)
5850+ ply_trace ("failed to open log: %m");
5851
5852 if (state->number_of_errors > 0)
5853 spool_error (state);
5854@@ -821,55 +889,15 @@ plymouth_should_show_default_splash (state_t *state)
5855 }
5856
5857 static void
5858-remove_displays_and_keyboard (state_t *state)
5859+on_show_splash (state_t *state)
5860 {
5861- ply_list_node_t *node;
5862- ply_trace ("removing displays and keyboard");
5863-
5864- node = ply_list_get_first_node (state->pixel_displays);
5865- while (node != NULL)
5866- {
5867- ply_list_node_t *next_node;
5868- ply_pixel_display_t *display;
5869-
5870- ply_trace ("removing pixel display");
5871- next_node = ply_list_get_next_node (state->pixel_displays, node);
5872- display = ply_list_node_get_data (node);
5873- ply_pixel_display_free (display);
5874-
5875- ply_list_remove_node (state->pixel_displays, node);
5876-
5877- node = next_node;
5878- }
5879-
5880- node = ply_list_get_first_node (state->text_displays);
5881- while (node != NULL)
5882- {
5883- ply_list_node_t *next_node;
5884- ply_text_display_t *display;
5885+ bool has_open_seats;
5886
5887- ply_trace ("removing text display");
5888- next_node = ply_list_get_next_node (state->text_displays, node);
5889- display = ply_list_node_get_data (node);
5890- ply_text_display_free (display);
5891-
5892- ply_list_remove_node (state->text_displays, node);
5893-
5894- node = next_node;
5895- }
5896-
5897- if (state->keyboard != NULL)
5898+ if (state->is_shown)
5899 {
5900- ply_trace ("removing keyboard");
5901- ply_keyboard_free (state->keyboard);
5902- state->keyboard = NULL;
5903+ ply_trace ("show splash called while already shown");
5904+ return;
5905 }
5906-}
5907-
5908-static void
5909-on_show_splash (state_t *state)
5910-{
5911- bool has_display;
5912
5913 if (state->is_inactive)
5914 {
5915@@ -884,18 +912,81 @@ on_show_splash (state_t *state)
5916 return;
5917 }
5918
5919- check_for_consoles (state, state->default_tty, true);
5920-
5921- has_display = ply_list_get_length (state->pixel_displays) > 0 ||
5922- ply_list_get_length (state->text_displays) > 0;
5923+ state->is_shown = true;
5924+ has_open_seats = ply_device_manager_has_open_seats (state->device_manager);
5925
5926- if (!state->is_attached && state->should_be_attached && has_display)
5927+ if (!state->is_attached && state->should_be_attached && has_open_seats)
5928 attach_to_running_session (state);
5929
5930- if (!has_display)
5931+ if (has_open_seats)
5932+ {
5933+ ply_trace ("at least one seat already open, so loading splash");
5934+ show_splash (state);
5935+ }
5936+ else
5937 {
5938- ply_trace ("no open seats");
5939- detach_from_running_session (state);
5940+ ply_trace ("no seats available to show splash on, waiting...");
5941+ }
5942+}
5943+
5944+static void
5945+on_seat_removed (state_t *state,
5946+ ply_seat_t *seat)
5947+{
5948+ ply_keyboard_t *keyboard;
5949+
5950+ keyboard = ply_seat_get_keyboard (seat);
5951+
5952+ ply_trace ("no longer listening for keystrokes");
5953+ ply_keyboard_remove_input_handler (keyboard,
5954+ (ply_keyboard_input_handler_t)
5955+ on_keyboard_input);
5956+ ply_trace ("no longer listening for escape");
5957+ ply_keyboard_remove_escape_handler (keyboard,
5958+ (ply_keyboard_escape_handler_t)
5959+ on_escape_pressed);
5960+ ply_trace ("no longer listening for backspace");
5961+ ply_keyboard_remove_backspace_handler (keyboard,
5962+ (ply_keyboard_backspace_handler_t)
5963+ on_backspace);
5964+ ply_trace ("no longer listening for enter");
5965+ ply_keyboard_remove_enter_handler (keyboard,
5966+ (ply_keyboard_enter_handler_t)
5967+ on_enter);
5968+
5969+ if (state->boot_splash != NULL)
5970+ ply_boot_splash_detach_from_seat (state->boot_splash, seat);
5971+}
5972+
5973+static void
5974+show_splash (state_t *state)
5975+{
5976+ if (state->boot_splash != NULL)
5977+ return;
5978+
5979+ if (!isnan (state->splash_delay))
5980+ {
5981+ double now, running_time;
5982+
5983+ now = ply_get_timestamp ();
5984+ running_time = now - state->start_time;
5985+ if (state->splash_delay > running_time)
5986+ {
5987+ double time_left = state->splash_delay - running_time;
5988+
5989+ ply_trace ("delaying show splash for %lf seconds",
5990+ time_left);
5991+ ply_event_loop_stop_watching_for_timeout (state->loop,
5992+ (ply_event_loop_timeout_handler_t)
5993+ show_splash,
5994+ state);
5995+ ply_event_loop_watch_for_timeout (state->loop,
5996+ time_left,
5997+ (ply_event_loop_timeout_handler_t)
5998+ show_splash,
5999+ state);
6000+ return;
6001+ }
6002 }
6003
6004 if (plymouth_should_show_default_splash (state))
6005@@ -908,65 +999,67 @@ on_show_splash (state_t *state)
6006 show_detailed_splash (state);
6007 state->showing_details = true;
6008 }
6009- show_messages (state);
6010 }
6011
6012-static ply_list_t *
6013-get_tracked_terminals (state_t *state)
6014+static void
6015+on_seat_added (state_t *state,
6016+ ply_seat_t *seat)
6017 {
6018- ply_list_t *terminals;
6019- ply_list_node_t *node;
6020-
6021- terminals = ply_list_new ();
6022+ ply_keyboard_t *keyboard;
6023
6024- node = ply_list_get_first_node (state->text_displays);
6025- while (node != NULL)
6026+ if (state->is_shown)
6027 {
6028- ply_list_node_t *next_node;
6029- ply_text_display_t *display;
6030- ply_terminal_t *terminal;
6031-
6032- next_node = ply_list_get_next_node (state->text_displays, node);
6033- display = ply_list_node_get_data (node);
6034- terminal = ply_text_display_get_terminal (display);
6035+ if (state->boot_splash == NULL)
6036+ {
6037+ ply_trace ("seat added before splash loaded, so loading splash now");
6038+ show_splash (state);
6039+ }
6040+ else
6041+ {
6042+ ply_trace ("seat added after splash loaded, so attaching to splash");
6043+ ply_boot_splash_attach_to_seat (state->boot_splash, seat);
6044+ }
6045+ }
6046
6047- ply_list_append_data (terminals, terminal);
6048+ keyboard = ply_seat_get_keyboard (seat);
6049
6050- node = next_node;
6051- }
6052+ ply_trace ("listening for keystrokes");
6053+ ply_keyboard_add_input_handler (keyboard,
6054+ (ply_keyboard_input_handler_t)
6055+ on_keyboard_input, state);
6056+ ply_trace ("listening for escape");
6057+ ply_keyboard_add_escape_handler (keyboard,
6058+ (ply_keyboard_escape_handler_t)
6059+ on_escape_pressed, state);
6060+ ply_trace ("listening for backspace");
6061+ ply_keyboard_add_backspace_handler (keyboard,
6062+ (ply_keyboard_backspace_handler_t)
6063+ on_backspace, state);
6064+ ply_trace ("listening for enter");
6065+ ply_keyboard_add_enter_handler (keyboard,
6066+ (ply_keyboard_enter_handler_t)
6067+ on_enter, state);
6068
6069- return terminals;
6070 }
6071
6072 static void
6073-free_terminals (state_t *state,
6074- ply_list_t *terminals)
6075+load_devices (state_t *state,
6076+ ply_device_manager_flags_t flags)
6077 {
6078- ply_list_node_t *node;
6079- node = ply_list_get_first_node (terminals);
6080- while (node != NULL)
6081- {
6082- ply_list_node_t *next_node;
6083- ply_terminal_t *terminal;
6084+ state->device_manager = ply_device_manager_new (state->default_tty, flags);
6085+ state->local_console_terminal = ply_device_manager_get_default_terminal (state->device_manager);
6086
6087- next_node = ply_list_get_next_node (state->text_displays, node);
6088- terminal = ply_list_node_get_data (node);
6089-
6090- ply_terminal_close (terminal);
6091- ply_terminal_free (terminal);
6092- ply_list_remove_node (terminals, node);
6093-
6094- node = next_node;
6095- }
6096-
6097- ply_list_free (terminals);
6098+ ply_device_manager_watch_seats (state->device_manager,
6099+ (ply_seat_added_handler_t)
6100+ on_seat_added,
6101+ (ply_seat_removed_handler_t)
6102+ on_seat_removed,
6103+ state);
6104 }
6105
6106 static void
6107 quit_splash (state_t *state)
6108 {
6109- ply_list_t *terminals;
6110-
6111 ply_trace ("quiting splash");
6112 if (state->boot_splash != NULL)
6113 {
6114@@ -975,17 +1068,7 @@ quit_splash (state_t *state)
6115 state->boot_splash = NULL;
6116 }
6117
6118- terminals = get_tracked_terminals (state);
6119-
6120- ply_trace ("removing displays and keyboard");
6121- remove_displays_and_keyboard (state);
6122-
6123- if (state->renderer != NULL)
6124- {
6125- ply_renderer_close (state->renderer);
6126- ply_renderer_free (state->renderer);
6127- state->renderer = NULL;
6128- }
6129+ ply_device_manager_deactivate_keyboards (state->device_manager);
6130
6131 if (state->local_console_terminal != NULL)
6132 {
6133@@ -993,25 +1076,37 @@ quit_splash (state_t *state)
6134 {
6135 ply_trace ("Not retaining splash, so deallocating VT");
6136 ply_terminal_deactivate_vt (state->local_console_terminal);
6137+ ply_terminal_close (state->local_console_terminal);
6138 }
6139- state->local_console_terminal = NULL;
6140 }
6141- free_terminals (state, terminals);
6142
6143 detach_from_running_session (state);
6144 }
6145
6146 static void
6147+hide_splash (state_t *state)
6148+{
6149+ state->is_shown = false;
6150+
6151+ cancel_pending_delayed_show (state);
6152+
6153+ if (state->boot_splash == NULL)
6154+ return;
6155+
6156+ ply_boot_splash_hide (state->boot_splash);
6157+
6158+ if (state->local_console_terminal != NULL)
6159+ ply_terminal_set_mode (state->local_console_terminal, PLY_TERMINAL_MODE_TEXT);
6160+}
6161+
6162+static void
6163 dump_details_and_quit_splash (state_t *state)
6164 {
6165 state->showing_details = false;
6166 toggle_between_splash_and_details (state);
6167
6168- if (state->renderer != NULL)
6169- ply_renderer_deactivate (state->renderer);
6170- if (state->boot_splash != NULL)
6171- ply_boot_splash_hide (state->boot_splash);
6172-
6173+ ply_device_manager_deactivate_renderers (state->device_manager);
6174+ hide_splash (state);
6175 quit_splash (state);
6176 }
6177
6178@@ -1042,6 +1137,9 @@ tell_gdm_to_transition (void)
6179 static void
6180 quit_program (state_t *state)
6181 {
6182+ ply_trace ("cleaning up devices");
6183+ ply_device_manager_free (state->device_manager);
6184+
6185 ply_trace ("exiting event loop");
6186 ply_event_loop_exit (state->loop, 0);
6187
6188@@ -1077,11 +1175,7 @@ deactivate_splash (state_t *state)
6189 {
6190 assert (!state->is_inactive);
6191
6192- if (state->renderer != NULL)
6193- {
6194- ply_trace ("deactivating renderer");
6195- ply_renderer_deactivate (state->renderer);
6196- }
6197+ ply_device_manager_deactivate_renderers (state->device_manager);
6198
6199 detach_from_running_session (state);
6200
6201@@ -1090,7 +1184,13 @@ deactivate_splash (state_t *state)
6202 ply_trace ("deactivating terminal");
6203 ply_terminal_stop_watching_for_vt_changes (state->local_console_terminal);
6204 ply_terminal_set_buffered_input (state->local_console_terminal);
6205- ply_terminal_ignore_mode_changes (state->local_console_terminal, true);
6206+ ply_terminal_close (state->local_console_terminal);
6207+ }
6208+
6209+ /* do not let any tty opened where we could write after deactivate */
6210+ if (command_line_has_argument (state->kernel_command_line, "plymouth.debug"))
6211+ {
6212+ ply_logger_close_file (ply_logger_get_error_default ());
6213 }
6214
6215 state->is_inactive = true;
6216@@ -1112,10 +1212,8 @@ on_boot_splash_idle (state_t *state)
6217 if (!state->should_retain_splash)
6218 {
6219 ply_trace ("hiding splash");
6220- if (state->renderer != NULL)
6221- ply_renderer_deactivate (state->renderer);
6222- if (state->boot_splash != NULL)
6223- ply_boot_splash_hide (state->boot_splash);
6224+ ply_device_manager_deactivate_renderers (state->device_manager);
6225+ hide_splash (state);
6226 }
6227
6228 ply_trace ("quitting splash");
6229@@ -1130,12 +1228,17 @@ on_boot_splash_idle (state_t *state)
6230 }
6231 }
6232
6233-
6234 static void
6235 on_deactivate (state_t *state,
6236 ply_trigger_t *deactivate_trigger)
6237 {
6238- if ((state->deactivate_trigger != NULL) || state->is_inactive)
6239+ if (state->is_inactive)
6240+ {
6241+ ply_trigger_pull (deactivate_trigger, NULL);
6242+ return;
6243+ }
6244+
6245+ if (state->deactivate_trigger != NULL)
6246 {
6247 ply_trigger_add_handler (state->deactivate_trigger,
6248 (ply_trigger_handler_t)
6249@@ -1147,12 +1250,9 @@ on_deactivate (state_t *state,
6250 state->deactivate_trigger = deactivate_trigger;
6251
6252 ply_trace ("deactivating");
6253+ cancel_pending_delayed_show (state);
6254
6255- if (state->keyboard != NULL)
6256- {
6257- ply_trace ("deactivating keyboard");
6258- ply_keyboard_stop_watching_for_input (state->keyboard);
6259- }
6260+ ply_device_manager_deactivate_keyboards (state->device_manager);
6261
6262 if (state->boot_splash != NULL)
6263 {
6264@@ -1176,6 +1276,7 @@ on_reactivate (state_t *state)
6265
6266 if (state->local_console_terminal != NULL)
6267 {
6268+ ply_terminal_open (state->local_console_terminal);
6269 ply_terminal_watch_for_vt_changes (state->local_console_terminal);
6270 ply_terminal_set_unbuffered_input (state->local_console_terminal);
6271 ply_terminal_ignore_mode_changes (state->local_console_terminal, false);
6272@@ -1187,17 +1288,8 @@ on_reactivate (state_t *state)
6273 attach_to_running_session (state);
6274 }
6275
6276- if (state->keyboard != NULL)
6277- {
6278- ply_trace ("activating keyboard");
6279- ply_keyboard_watch_for_input (state->keyboard);
6280- }
6281-
6282- if (state->renderer != NULL)
6283- {
6284- ply_trace ("activating renderer");
6285- ply_renderer_activate (state->renderer);
6286- }
6287+ ply_device_manager_activate_keyboards (state->device_manager);
6288+ ply_device_manager_activate_renderers (state->device_manager);
6289
6290 state->is_inactive = false;
6291
6292@@ -1209,8 +1301,11 @@ on_quit (state_t *state,
6293 bool retain_splash,
6294 ply_trigger_t *quit_trigger)
6295 {
6296+ ply_trace ("quitting (retain splash: %s)", retain_splash? "true" : "false");
6297+
6298 if (state->quit_trigger != NULL)
6299 {
6300+ ply_trace ("quit trigger already pending, so chaining to it");
6301 ply_trigger_add_handler (state->quit_trigger,
6302 (ply_trigger_handler_t)
6303 ply_trigger_pull,
6304@@ -1219,9 +1314,16 @@ on_quit (state_t *state,
6305 }
6306
6307 if (state->system_initialized)
6308- ply_progress_save_cache (state->progress,
6309- get_cache_file_for_mode (state->mode));
6310-
6311+ {
6312+ ply_trace ("system initialized so saving boot-duration file");
6313+ ply_create_directory (PLYMOUTH_TIME_DIRECTORY);
6314+ ply_progress_save_cache (state->progress,
6315+ get_cache_file_for_mode (state->mode));
6316+ }
6317+ else
6318+ {
6319+ ply_trace ("system not initialized so skipping saving boot-duration file");
6320+ }
6321 state->quit_trigger = quit_trigger;
6322 state->should_retain_splash = retain_splash;
6323
6324@@ -1229,15 +1331,11 @@ on_quit (state_t *state,
6325 tell_systemd_to_stop_printing_details (state);
6326 #endif
6327
6328- ply_trace ("time to quit, closing log");
6329+ ply_trace ("closing log");
6330 if (state->session != NULL)
6331 ply_terminal_session_close_log (state->session);
6332
6333- if (state->keyboard != NULL)
6334- {
6335- ply_trace ("deactivating keyboard");
6336- ply_keyboard_stop_watching_for_input (state->keyboard);
6337- }
6338+ ply_device_manager_deactivate_keyboards (state->device_manager);
6339
6340 ply_trace ("unloading splash");
6341 if (state->is_inactive && !retain_splash)
6342@@ -1351,7 +1449,7 @@ toggle_between_splash_and_details (state_t *state)
6343 if (state->boot_splash != NULL)
6344 {
6345 ply_trace ("hiding and freeing current splash");
6346- ply_boot_splash_hide (state->boot_splash);
6347+ hide_splash (state);
6348 ply_boot_splash_free (state->boot_splash);
6349 state->boot_splash = NULL;
6350 }
6351@@ -1366,8 +1464,6 @@ toggle_between_splash_and_details (state_t *state)
6352 show_default_splash (state);
6353 state->showing_details = false;
6354 }
6355- update_display (state);
6356- show_messages (state);
6357 }
6358
6359 static void
6360@@ -1479,140 +1575,24 @@ on_enter (state_t *state,
6361 }
6362
6363 static void
6364-set_keyboard (state_t *state,
6365- ply_keyboard_t *keyboard)
6366-{
6367- state->keyboard = keyboard;
6368-
6369- ply_keyboard_add_escape_handler (keyboard, (ply_keyboard_escape_handler_t)
6370- on_escape_pressed, state);
6371- ply_trace ("listening for keystrokes");
6372- ply_keyboard_add_input_handler (keyboard,
6373- (ply_keyboard_input_handler_t)
6374- on_keyboard_input, state);
6375- ply_trace ("listening for backspace");
6376- ply_keyboard_add_backspace_handler (keyboard,
6377- (ply_keyboard_backspace_handler_t)
6378- on_backspace, state);
6379- ply_trace ("listening for enter");
6380- ply_keyboard_add_enter_handler (keyboard,
6381- (ply_keyboard_enter_handler_t)
6382- on_enter, state);
6383-}
6384-static void
6385-add_display_and_keyboard_for_terminal (state_t *state,
6386- ply_terminal_t *terminal)
6387-{
6388- ply_text_display_t *display;
6389- ply_keyboard_t *keyboard;
6390-
6391- keyboard = ply_keyboard_new_for_terminal (terminal);
6392- display = ply_text_display_new (terminal);
6393-
6394- ply_list_append_data (state->text_displays, display);
6395- set_keyboard (state, keyboard);
6396-}
6397-
6398-static void
6399-add_pixel_displays_from_renderer (state_t *state,
6400- ply_renderer_t *renderer)
6401-{
6402- ply_list_t *heads;
6403- ply_list_node_t *node;
6404-
6405- heads = ply_renderer_get_heads (renderer);
6406-
6407- ply_trace ("Adding displays for %d heads",
6408- ply_list_get_length (heads));
6409-
6410- node = ply_list_get_first_node (heads);
6411- while (node != NULL)
6412- {
6413- ply_list_node_t *next_node;
6414- ply_renderer_head_t *head;
6415- ply_pixel_display_t *display;
6416-
6417- head = ply_list_node_get_data (node);
6418- next_node = ply_list_get_next_node (heads, node);
6419-
6420- display = ply_pixel_display_new (renderer, head);
6421-
6422- ply_list_append_data (state->pixel_displays, display);
6423-
6424- node = next_node;
6425- }
6426-
6427-}
6428-
6429-static void
6430-add_default_displays_and_keyboard (state_t *state)
6431+attach_splash_to_seats (state_t *state,
6432+ ply_boot_splash_t *splash)
6433 {
6434- ply_renderer_t *renderer;
6435- ply_keyboard_t *keyboard;
6436- ply_text_display_t *text_display;
6437-
6438- ply_trace ("adding default displays and keyboard");
6439
6440- state->local_console_terminal = ply_terminal_new (state->default_tty);
6441-
6442- renderer = ply_renderer_new (NULL, NULL, state->local_console_terminal);
6443-
6444- if (!ply_renderer_open (renderer))
6445- {
6446- ply_trace ("could not open renderer /dev/fb");
6447- ply_renderer_free (renderer);
6448-
6449- ply_trace ("adding text display and keyboard for %s", state->default_tty);
6450- add_display_and_keyboard_for_terminal (state, state->local_console_terminal);
6451- return;
6452- }
6453-
6454- keyboard = ply_keyboard_new_for_renderer (renderer);
6455- set_keyboard (state, keyboard);
6456-
6457- add_pixel_displays_from_renderer (state, renderer);
6458-
6459- text_display = ply_text_display_new (state->local_console_terminal);
6460- ply_list_append_data (state->text_displays, text_display);
6461-
6462- state->renderer = renderer;
6463-}
6464-
6465-static void
6466-add_displays_and_keyboard_to_boot_splash (state_t *state,
6467- ply_boot_splash_t *splash)
6468-{
6469+ ply_list_t *seats;
6470 ply_list_node_t *node;
6471
6472- ply_trace ("setting keyboard on boot splash");
6473- if (state->keyboard != NULL)
6474- ply_boot_splash_set_keyboard (splash, state->keyboard);
6475-
6476- node = ply_list_get_first_node (state->pixel_displays);
6477+ seats = ply_device_manager_get_seats (state->device_manager);
6478+ node = ply_list_get_first_node (seats);
6479 while (node != NULL)
6480 {
6481- ply_pixel_display_t *display;
6482+ ply_seat_t *seat;
6483 ply_list_node_t *next_node;
6484
6485- display = ply_list_node_get_data (node);
6486- next_node = ply_list_get_next_node (state->pixel_displays, node);
6487- ply_trace ("adding pixel display on boot splash");
6488- ply_boot_splash_add_pixel_display (splash, display);
6489+ seat = ply_list_node_get_data (node);
6490+ next_node = ply_list_get_next_node (seats, node);
6491
6492- node = next_node;
6493- }
6494-
6495- node = ply_list_get_first_node (state->text_displays);
6496- while (node != NULL)
6497- {
6498- ply_text_display_t *display;
6499- ply_list_node_t *next_node;
6500-
6501- display = ply_list_node_get_data (node);
6502- next_node = ply_list_get_next_node (state->text_displays, node);
6503-
6504- ply_trace ("adding text display on boot splash");
6505- ply_boot_splash_add_text_display (splash, display);
6506+ ply_boot_splash_attach_to_seat (splash, seat);
6507
6508 node = next_node;
6509 }
6510@@ -1637,12 +1617,41 @@ tell_systemd_to_stop_printing_details (state_t *state)
6511 #endif
6512
6513 static ply_boot_splash_t *
6514-start_boot_splash (state_t *state,
6515- const char *theme_path,
6516- bool fall_back_if_neccessary)
6517+load_built_in_theme (state_t *state)
6518+{
6519+ ply_boot_splash_t *splash;
6520+ bool is_loaded;
6521+
6522+ ply_trace ("Loading built-in theme");
6523+
6524+ splash = ply_boot_splash_new ("",
6525+ PLYMOUTH_PLUGIN_PATH,
6526+ state->boot_buffer);
6527+
6528+ is_loaded = ply_boot_splash_load_built_in (splash);
6529+
6530+ if (!is_loaded)
6531+ {
6532+ ply_save_errno ();
6533+ ply_boot_splash_free (splash);
6534+ ply_restore_errno ();
6535+ return NULL;
6536+ }
6537+
6538+ ply_trace ("attaching plugin to event loop");
6539+ ply_boot_splash_attach_to_event_loop (splash, state->loop);
6540+
6541+ ply_trace ("attaching progress to plugin");
6542+ ply_boot_splash_attach_progress (splash, state->progress);
6543+
6544+ return splash;
6545+}
6546+
6547+static ply_boot_splash_t *
6548+load_theme (state_t *state,
6549+ const char *theme_path)
6550 {
6551 ply_boot_splash_t *splash;
6552- ply_boot_splash_mode_t splash_mode;
6553 bool is_loaded;
6554
6555 ply_trace ("Loading boot splash theme '%s'",
6556@@ -1653,13 +1662,6 @@ start_boot_splash (state_t *state,
6557 state->boot_buffer);
6558
6559 is_loaded = ply_boot_splash_load (splash);
6560- if (!is_loaded && fall_back_if_neccessary)
6561- {
6562- ply_trace ("Splash couldn't be loaded: %m");
6563-
6564- ply_trace ("Loading built in splash");
6565- is_loaded = ply_boot_splash_load_built_in (splash);
6566- }
6567
6568 if (!is_loaded)
6569 {
6570@@ -1675,9 +1677,27 @@ start_boot_splash (state_t *state,
6571 ply_trace ("attaching progress to plugin");
6572 ply_boot_splash_attach_progress (splash, state->progress);
6573
6574- add_displays_and_keyboard_to_boot_splash (state, splash);
6575+ return splash;
6576+}
6577+
6578+static ply_boot_splash_t *
6579+show_theme (state_t *state,
6580+ const char *theme_path)
6581+{
6582+ ply_boot_splash_mode_t splash_mode;
6583+ ply_boot_splash_t *splash;
6584+
6585+ if (theme_path != NULL)
6586+ splash = load_theme (state, theme_path);
6587+ else
6588+ splash = load_built_in_theme (state);
6589+
6590+ if (splash == NULL)
6591+ return NULL;
6592+
6593+ attach_splash_to_seats (state, splash);
6594+ ply_device_manager_activate_renderers (state->device_manager);
6595
6596- ply_trace ("showing plugin");
6597 if (state->mode == PLY_MODE_SHUTDOWN)
6598 splash_mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN;
6599 else
6600@@ -1686,7 +1706,6 @@ start_boot_splash (state_t *state,
6601 if (!ply_boot_splash_show (splash, splash_mode))
6602 {
6603 ply_save_errno ();
6604- ply_boot_splash_unset_keyboard (splash);
6605 ply_boot_splash_free (splash);
6606 ply_restore_errno ();
6607 return NULL;
6608@@ -1697,10 +1716,9 @@ start_boot_splash (state_t *state,
6609 tell_systemd_to_print_details (state);
6610 #endif
6611
6612- if (state->keyboard != NULL)
6613- ply_keyboard_watch_for_input (state->keyboard);
6614+ ply_device_manager_activate_keyboards (state->device_manager);
6615+ show_messages (state);
6616
6617- update_display (state);
6618 return splash;
6619 }
6620
6621@@ -1875,6 +1893,30 @@ check_verbosity (state_t *state)
6622 ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
6623 }
6624 free (stream_copy);
6625+ } else {
6626+ const char* device;
6627+ char *file;
6628+
6629+ device = state->default_tty;
6630+
6631+ ply_trace ("redirecting debug output to %s", device);
6632+
6633+ if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
6634+ file = strdup (device);
6635+ else
6636+ asprintf (&file, "/dev/%s", device);
6637+
6638+ fd = open (file, O_RDWR | O_APPEND);
6639+
6640+ if (fd < 0)
6641+ {
6642+ ply_trace ("could not redirected debug output to %s: %m", device);
6643+ }
6644+ else {
6645+ ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
6646+ }
6647+
6648+ free (file);
6649 }
6650 }
6651 else
6652@@ -1896,267 +1938,26 @@ check_verbosity (state_t *state)
6653 static void
6654 check_logging (state_t *state)
6655 {
6656- ply_trace ("checking if console messages should be redirected and logged");
6657-
6658- if (command_line_has_argument (state->kernel_command_line, "plymouth.nolog"))
6659- {
6660- ply_trace ("logging won't be enabled!");
6661- state->no_boot_log = true;
6662- }
6663- else
6664- {
6665- ply_trace ("logging will be enabled!");
6666- state->no_boot_log = false;
6667- }
6668-}
6669-
6670-static void
6671-add_display_and_keyboard_for_console (const char *console,
6672- const char *null,
6673- state_t *state)
6674-{
6675- ply_terminal_t *terminal;
6676-
6677- terminal = ply_terminal_new (console);
6678-
6679- if (strcmp (console, state->default_tty) == 0)
6680- state->local_console_terminal = terminal;
6681+ bool kernel_no_log;
6682
6683- ply_trace ("adding display and keyboard for console %s", console);
6684- add_display_and_keyboard_for_terminal (state, terminal);
6685-}
6686-
6687-static int
6688-add_consoles_from_file (state_t *state,
6689- ply_hashtable_t *consoles,
6690- const char *path)
6691-{
6692- int fd;
6693- char contents[512] = "";
6694- ssize_t contents_length;
6695- int num_consoles;
6696- const char *remaining_file_contents;
6697-
6698- ply_trace ("opening %s", path);
6699- fd = open (path, O_RDONLY);
6700-
6701- if (fd < 0)
6702- {
6703- ply_trace ("couldn't open it: %m");
6704- return 0;
6705- }
6706-
6707- ply_trace ("reading file");
6708- contents_length = read (fd, contents, sizeof (contents));
6709-
6710- if (contents_length <= 0)
6711- {
6712- ply_trace ("couldn't read it: %m");
6713- close (fd);
6714- return 0;
6715- }
6716- close (fd);
6717-
6718- remaining_file_contents = contents;
6719- num_consoles = 0;
6720-
6721- while (remaining_file_contents < contents + contents_length)
6722- {
6723- char *console;
6724- size_t console_length;
6725- char *console_device;
6726-
6727- /* Advance past any leading whitespace */
6728- remaining_file_contents += strspn (remaining_file_contents, " \n\t\v");
6729-
6730- if (*remaining_file_contents == '\0')
6731- {
6732- /* There's nothing left after the whitespace, we're done */
6733- break;
6734- }
6735-
6736- /* Find trailing whitespace and NUL terminate. If strcspn
6737- * doesn't find whitespace, it gives us the length of the string
6738- * until the next NUL byte, which we'll just overwrite with
6739- * another NUL byte anyway. */
6740- console_length = strcspn (remaining_file_contents, " \n\t\v");
6741- console = strndup (remaining_file_contents, console_length);
6742-
6743- /* If this console is anything besides tty0, then the user is sort
6744- * of a weird case (uses a serial console or whatever) and they
6745- * most likely don't want a graphical splash, so force details.
6746- */
6747- if (strcmp (console, "tty0") != 0)
6748- state->should_force_details = true;
6749-
6750- asprintf (&console_device, "/dev/%s", console);
6751-
6752- free (console);
6753-
6754- ply_trace ("console %s found!", console_device);
6755- ply_hashtable_insert (consoles, console_device, console_device);
6756- num_consoles++;
6757-
6758- /* Move past the parsed console string, and the whitespace we
6759- * may have found above. If we found a NUL above and not whitespace,
6760- * then we're going to jump past the end of the buffer and the loop
6761- * will terminate
6762- */
6763- remaining_file_contents += console_length + 1;
6764- }
6765-
6766- return num_consoles;
6767-}
6768-
6769-static int
6770-add_consoles_from_kernel_command_line (state_t *state,
6771- ply_hashtable_t *consoles)
6772-{
6773- const char *console_string;
6774- const char *remaining_command_line;
6775- char *console;
6776- int num_consoles;
6777-
6778- remaining_command_line = state->kernel_command_line;
6779-
6780- num_consoles = 0;
6781- console = NULL;
6782- while ((console_string = command_line_get_string_after_prefix (remaining_command_line,
6783- "console=")) != NULL)
6784- {
6785- char *end;
6786- size_t console_length;
6787- char *console_device;
6788-
6789- remaining_command_line = console_string;
6790-
6791- state->should_force_details = true;
6792-
6793- console = strdup (console_string);
6794-
6795- end = strpbrk (console, " \n\t\v,");
6796-
6797- if (end != NULL)
6798- *end = '\0';
6799-
6800- console_length = strlen (console);
6801-
6802- if (strncmp (console, "/dev/", strlen ("/dev/")) == 0)
6803- {
6804- console_device = console;
6805- console = NULL;
6806- }
6807- else
6808- {
6809- asprintf (&console_device, "/dev/%s", console);
6810- free (console);
6811- console = NULL;
6812- }
6813-
6814- ply_trace ("console %s found!", console_device);
6815- ply_hashtable_insert (consoles, console_device, console_device);
6816- num_consoles++;
6817- remaining_command_line += console_length;
6818- }
6819-
6820- return num_consoles;
6821-}
6822-
6823-static void
6824-check_for_consoles (state_t *state,
6825- const char *default_tty,
6826- bool should_add_displays)
6827-{
6828- char *console;
6829- ply_hashtable_t *consoles;
6830- int num_consoles;
6831- bool ignore_serial_consoles;
6832-
6833- ply_trace ("checking for consoles%s",
6834- should_add_displays? " and adding displays": "");
6835-
6836- consoles = ply_hashtable_new (ply_hashtable_string_hash,
6837- ply_hashtable_string_compare);
6838- ignore_serial_consoles = command_line_has_argument (state->kernel_command_line, "plymouth.ignore-serial-consoles");
6839-
6840- num_consoles = 0;
6841+ ply_trace ("checking if console messages should be redirected and logged");
6842
6843- if (!ignore_serial_consoles)
6844- {
6845- num_consoles = add_consoles_from_file (state, consoles, "/sys/class/tty/console/active");
6846+ kernel_no_log = command_line_has_argument (state->kernel_command_line, "plymouth.nolog");
6847+ if (kernel_no_log)
6848+ state->no_boot_log = true;
6849
6850- if (num_consoles == 0)
6851- {
6852- ply_trace ("falling back to kernel command line");
6853- num_consoles = add_consoles_from_kernel_command_line (state, consoles);
6854- }
6855- }
6856+ if (state->no_boot_log)
6857+ ply_trace ("logging won't be enabled!");
6858 else
6859- {
6860- ply_trace ("ignoring all consoles but default console because of plymouth.ignore-serial-consoles");
6861- }
6862-
6863- console = ply_hashtable_remove (consoles, (void *) "/dev/tty0");
6864- if (console != NULL)
6865- {
6866- free (console);
6867- console = strdup (default_tty);
6868- ply_hashtable_insert (consoles, console, console);
6869- }
6870-
6871- console = ply_hashtable_remove (consoles, (void *) "/dev/tty");
6872- if (console != NULL)
6873- {
6874- free (console);
6875- console = strdup (default_tty);
6876- ply_hashtable_insert (consoles, console, console);
6877- }
6878-
6879- free (state->kernel_console_tty);
6880- state->kernel_console_tty = NULL;
6881-
6882- if (console != NULL)
6883- state->kernel_console_tty = strdup (console);
6884-
6885- if (should_add_displays)
6886- {
6887- /* Do a full graphical splash if there's no weird serial console
6888- * stuff going on, otherwise just prepare text splashes
6889- */
6890- if ((num_consoles == 0) ||
6891- ((num_consoles == 1) &&
6892- (ply_hashtable_lookup (consoles, (void *) default_tty) != NULL)))
6893- add_default_displays_and_keyboard (state);
6894- else
6895- ply_hashtable_foreach (consoles,
6896- (ply_hashtable_foreach_func_t *)
6897- add_display_and_keyboard_for_console,
6898- state);
6899- }
6900-
6901- ply_hashtable_foreach (consoles, (ply_hashtable_foreach_func_t *) free, NULL);
6902- ply_hashtable_free (consoles);
6903-
6904- ply_trace ("After processing serial consoles there are now %d text displays",
6905- ply_list_get_length (state->text_displays));
6906+ ply_trace ("logging will be enabled!");
6907 }
6908
6909 static bool
6910-redirect_standard_io_to_device (const char *device)
6911+redirect_standard_io_to_dev_null (void)
6912 {
6913 int fd;
6914- char *file;
6915-
6916- ply_trace ("redirecting stdio to %s", device);
6917-
6918- if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
6919- file = strdup (device);
6920- else
6921- asprintf (&file, "/dev/%s", device);
6922
6923- fd = open (file, O_RDWR | O_APPEND);
6924-
6925- free (file);
6926+ fd = open ("/dev/null", O_RDWR | O_APPEND);
6927
6928 if (fd < 0)
6929 return false;
6930@@ -2199,19 +2000,11 @@ initialize_environment (state_t *state)
6931 if (!get_kernel_command_line (state))
6932 return false;
6933
6934- check_verbosity (state);
6935- check_logging (state);
6936-
6937- ply_trace ("source built on %s", __DATE__);
6938-
6939- state->keystroke_triggers = ply_list_new ();
6940- state->entry_triggers = ply_list_new ();
6941- state->entry_buffer = ply_buffer_new();
6942- state->pixel_displays = ply_list_new ();
6943- state->text_displays = ply_list_new ();
6944- state->messages = ply_list_new ();
6945- state->keyboard = NULL;
6946-
6947+ if (!state->default_tty)
6948+ {
6949+ if (getenv ("DISPLAY") != NULL && access (PLYMOUTH_PLUGIN_PATH "renderers/x11.so", F_OK) == 0)
6950+ state->default_tty = "/dev/tty";
6951+ }
6952 if (!state->default_tty)
6953 {
6954 if (state->mode == PLY_MODE_SHUTDOWN)
6955@@ -2232,12 +2025,17 @@ initialize_environment (state_t *state)
6956 }
6957 }
6958
6959- check_for_consoles (state, state->default_tty, false);
6960+ check_verbosity (state);
6961+ check_logging (state);
6962
6963- if (state->kernel_console_tty != NULL)
6964- redirect_standard_io_to_device (state->kernel_console_tty);
6965- else
6966- redirect_standard_io_to_device (state->default_tty);
6967+ ply_trace ("source built on %s", __DATE__);
6968+
6969+ state->keystroke_triggers = ply_list_new ();
6970+ state->entry_triggers = ply_list_new ();
6971+ state->entry_buffer = ply_buffer_new();
6972+ state->messages = ply_list_new ();
6973+
6974+ redirect_standard_io_to_dev_null ();
6975
6976 ply_trace ("Making sure " PLYMOUTH_RUNTIME_DIR " exists");
6977 if (!ply_create_directory (PLYMOUTH_RUNTIME_DIR))
6978@@ -2338,6 +2136,7 @@ main (int argc,
6979 state_t state = { 0 };
6980 int exit_code;
6981 bool should_help = false;
6982+ bool no_boot_log = false;
6983 bool no_daemon = false;
6984 bool debug = false;
6985 bool attach_to_session;
6986@@ -2345,7 +2144,9 @@ main (int argc,
6987 char *mode_string = NULL;
6988 char *kernel_command_line = NULL;
6989 char *tty = NULL;
6990+ ply_device_manager_flags_t device_manager_flags = PLY_DEVICE_MANAGER_FLAGS_NONE;
6991
6992+ state.start_time = ply_get_timestamp ();
6993 state.command_parser = ply_command_parser_new ("plymouthd", "Splash server");
6994
6995 state.loop = ply_event_loop_get_default ();
6996@@ -2360,6 +2161,7 @@ main (int argc,
6997 "pid-file", "Write the pid of the daemon to a file", PLY_COMMAND_OPTION_TYPE_STRING,
6998 "kernel-command-line", "Fake kernel command line to use", PLY_COMMAND_OPTION_TYPE_STRING,
6999 "tty", "TTY to use instead of default", PLY_COMMAND_OPTION_TYPE_STRING,
7000+ "no-boot-log", "Do not write boot log file", PLY_COMMAND_OPTION_TYPE_FLAG,
7001 NULL);
7002
7003 if (!ply_command_parser_parse_arguments (state.command_parser, state.loop, argv, argc))
7004@@ -2378,6 +2180,7 @@ main (int argc,
7005 "help", &should_help,
7006 "attach-to-session", &attach_to_session,
7007 "mode", &mode_string,
7008+ "no-boot-log", &no_boot_log,
7009 "no-daemon", &no_daemon,
7010 "debug", &debug,
7011 "debug-file", &debug_buffer_path,
7012@@ -2434,6 +2237,8 @@ main (int argc,
7013 return EX_OSERR;
7014 }
7015
7016+ state.no_boot_log = no_boot_log;
7017+
7018 chdir ("/");
7019 signal (SIGPIPE, SIG_IGN);
7020
7021@@ -2505,6 +2310,7 @@ main (int argc,
7022 }
7023
7024 state.progress = ply_progress_new ();
7025+ state.splash_delay = NAN;
7026
7027 ply_progress_load_cache (state.progress,
7028 get_cache_file_for_mode (state.mode));
7029@@ -2519,6 +2325,28 @@ main (int argc,
7030 return EX_UNAVAILABLE;
7031 }
7032
7033+ find_override_splash (&state);
7034+ find_system_default_splash (&state);
7035+ find_distribution_default_splash (&state);
7036+
7037+ if (command_line_has_argument (state.kernel_command_line, "plymouth.ignore-serial-consoles"))
7038+ device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES;
7039+
7040+ if (command_line_has_argument (state.kernel_command_line, "plymouth.ignore-udev") ||
7041+ (getenv ("DISPLAY") != NULL))
7042+ device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV;
7043+
7044+ if (!plymouth_should_show_default_splash (&state))
7045+ {
7046+ /* don't bother listening for udev events if we're forcing details */
7047+ device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV;
7048+
7049+ /* don't ever delay showing the detailed splash */
7050+ state.splash_delay = NAN;
7051+ }
7052+
7053+ load_devices (&state, device_manager_flags);
7054+
7055 ply_trace ("entering event loop");
7056 exit_code = ply_event_loop_run (state.loop);
7057 ply_trace ("exited event loop");
7058diff --git a/src/plugins/controls/label/Makefile.am b/src/plugins/controls/label/Makefile.am
7059index 296203b..219930a 100644
7060--- a/src/plugins/controls/label/Makefile.am
7061+++ b/src/plugins/controls/label/Makefile.am
7062@@ -1,4 +1,4 @@
7063-INCLUDES = -I$(top_srcdir) \
7064+AM_CPPFLAGS = -I$(top_srcdir) \
7065 -I$(srcdir)/../../../libply \
7066 -I$(srcdir)/../../../libply-splash-core \
7067 -I$(srcdir)/../../../libply-splash-graphics \
7068diff --git a/src/plugins/renderers/drm/Makefile.am b/src/plugins/renderers/drm/Makefile.am
7069index 2209b30..747f202 100644
7070--- a/src/plugins/renderers/drm/Makefile.am
7071+++ b/src/plugins/renderers/drm/Makefile.am
7072@@ -1,5 +1,5 @@
7073 if ENABLE_DRM_RENDERER
7074-INCLUDES = -I$(top_srcdir) \
7075+AM_CPPFLAGS = -I$(top_srcdir) \
7076 -I$(srcdir)/../../../libply \
7077 -I$(srcdir)/../../../libply-splash-core \
7078 -I$(srcdir)/../../.. \
7079@@ -21,27 +21,7 @@ drm_la_SOURCES = $(srcdir)/plugin.c \
7080 drm_la_SOURCES += $(srcdir)/ply-renderer-generic-driver.h \
7081 $(srcdir)/ply-renderer-generic-driver.c
7082
7083-if ENABLE_LIBDRM_INTEL
7084-drm_la_SOURCES += $(srcdir)/ply-renderer-i915-driver.h \
7085- $(srcdir)/ply-renderer-i915-driver.c
7086-endif
7087-
7088-if ENABLE_LIBDRM_RADEON
7089-drm_la_SOURCES += $(srcdir)/ply-renderer-radeon-driver.h \
7090- $(srcdir)/ply-renderer-radeon-driver.c
7091-endif
7092
7093-if ENABLE_LIBDRM_NOUVEAU
7094-drm_la_SOURCES += $(srcdir)/ply-renderer-nouveau-driver.h \
7095- $(srcdir)/ply-renderer-nouveau-driver.c
7096-endif
7097-
7098-if ENABLE_LIBKMS
7099-drm_la_LIBADD += $(LIBKMS_LIBS)
7100-drm_la_CFLAGS += $(LIBKMS_CFLAGS)
7101-drm_la_SOURCES += $(srcdir)/ply-renderer-libkms-driver.h \
7102- $(srcdir)/ply-renderer-libkms-driver.c
7103-endif
7104
7105 endif
7106
7107diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c
7108index db953e6..6677279 100644
7109--- a/src/plugins/renderers/drm/plugin.c
7110+++ b/src/plugins/renderers/drm/plugin.c
7111@@ -60,19 +60,6 @@
7112 #include "ply-renderer-plugin.h"
7113 #include "ply-renderer-driver.h"
7114 #include "ply-renderer-generic-driver.h"
7115-#ifdef PLY_ENABLE_LIBDRM_INTEL
7116-#include "ply-renderer-i915-driver.h"
7117-#endif
7118-#ifdef PLY_ENABLE_LIBDRM_RADEON
7119-#include "ply-renderer-radeon-driver.h"
7120-#endif
7121-#ifdef PLY_ENABLE_LIBDRM_NOUVEAU
7122-#include "ply-renderer-nouveau-driver.h"
7123-#endif
7124-
7125-#ifdef PLY_ENABLE_LIBKMS
7126-#include "ply-renderer-libkms-driver.h"
7127-#endif
7128
7129 #define BYTES_PER_PIXEL (4)
7130
7131@@ -412,42 +399,6 @@ destroy_backend (ply_renderer_backend_t *backend)
7132 free (backend);
7133 }
7134
7135-static char *
7136-find_driver_for_device (const char *device_name)
7137-{
7138- char *driver;
7139- int major_number, minor_number;
7140- struct stat file_attributes;
7141- char *device_path;
7142- char device_link_path[PATH_MAX + 1] = "";
7143-
7144- if (stat (device_name, &file_attributes) < 0)
7145- return NULL;
7146-
7147- if (!S_ISCHR (file_attributes.st_mode))
7148- return NULL;
7149-
7150- major_number = major (file_attributes.st_rdev);
7151- minor_number = minor (file_attributes.st_rdev);
7152-
7153- asprintf (&device_path, "/sys/dev/char/%d:%d/device/driver",
7154- major_number, minor_number);
7155-
7156- if (readlink (device_path, device_link_path, sizeof (device_link_path) - 1) < 0)
7157- {
7158- free (device_path);
7159- return NULL;
7160- }
7161- free (device_path);
7162-
7163- driver = strrchr (device_link_path, '/');
7164-
7165- if (driver == NULL)
7166- return NULL;
7167-
7168- return strdup (driver + strlen ("/"));
7169-}
7170-
7171 static void
7172 activate (ply_renderer_backend_t *backend)
7173 {
7174@@ -508,72 +459,24 @@ on_active_vt_changed (ply_renderer_backend_t *backend)
7175 static bool
7176 load_driver (ply_renderer_backend_t *backend)
7177 {
7178- char *driver_name;
7179 int device_fd;
7180
7181- driver_name = find_driver_for_device (backend->device_name);
7182- ply_trace ("Attempting to load driver '%s'", driver_name);
7183- device_fd = drmOpen (driver_name, NULL);
7184+ ply_trace ("Opening '%s'", backend->device_name);
7185+ device_fd = open (backend->device_name, O_RDWR);
7186
7187 if (device_fd < 0)
7188 {
7189- ply_trace ("drmOpen failed");
7190- free (driver_name);
7191+ ply_trace ("open failed: %m");
7192 return false;
7193 }
7194- backend->driver_interface = NULL;
7195
7196-/* Try intel driver first if we're supporting the legacy GDM transition
7197- * since it can map the kernel console, which gives us the ability to do
7198- * a more seamless transition when plymouth quits before X starts
7199- */
7200-#if defined(PLY_ENABLE_DEPRECATED_GDM_TRANSITION) && defined(PLY_ENABLE_LIBDRM_INTEL)
7201- if (backend->driver_interface == NULL && strcmp (driver_name, "i915") == 0)
7202- {
7203- backend->driver_interface = ply_renderer_i915_driver_get_interface ();
7204- backend->driver_supports_mapping_console = true;
7205- }
7206-#endif
7207+ backend->driver_interface = ply_renderer_generic_driver_get_interface (device_fd);
7208+ backend->driver_supports_mapping_console = false;
7209
7210 if (backend->driver_interface == NULL)
7211 {
7212- backend->driver_interface = ply_renderer_generic_driver_get_interface (device_fd);
7213- backend->driver_supports_mapping_console = false;
7214- }
7215-
7216-#ifdef PLY_ENABLE_LIBDRM_INTEL
7217- if (backend->driver_interface == NULL && strcmp (driver_name, "i915") == 0)
7218- {
7219- backend->driver_interface = ply_renderer_i915_driver_get_interface ();
7220- backend->driver_supports_mapping_console = true;
7221- }
7222-#endif
7223-#ifdef PLY_ENABLE_LIBDRM_RADEON
7224- if (backend->driver_interface == NULL && strcmp (driver_name, "radeon") == 0)
7225- {
7226- backend->driver_interface = ply_renderer_radeon_driver_get_interface ();
7227- backend->driver_supports_mapping_console = false;
7228- }
7229-#endif
7230-#ifdef PLY_ENABLE_LIBDRM_NOUVEAU
7231- if (backend->driver_interface == NULL && strcmp (driver_name, "nouveau") == 0)
7232- {
7233- backend->driver_interface = ply_renderer_nouveau_driver_get_interface ();
7234- backend->driver_supports_mapping_console = false;
7235- }
7236-#endif
7237-
7238- free (driver_name);
7239-
7240- if (backend->driver_interface == NULL)
7241- {
7242-#ifdef PLY_ENABLE_LIBKMS
7243- backend->driver_interface = ply_renderer_libkms_driver_get_interface ();
7244- backend->driver_supports_mapping_console = false;
7245-#else
7246 close (device_fd);
7247 return false;
7248-#endif
7249 }
7250
7251 backend->driver = backend->driver_interface->create_driver (device_fd);
7252@@ -619,6 +522,9 @@ open_device (ply_renderer_backend_t *backend)
7253 if (!load_driver (backend))
7254 return false;
7255
7256+ if (backend->terminal == NULL)
7257+ return true;
7258+
7259 if (!ply_terminal_open (backend->terminal))
7260 {
7261 ply_trace ("could not open terminal: %m");
7262@@ -647,10 +553,11 @@ close_device (ply_renderer_backend_t *backend)
7263
7264 free_heads (backend);
7265
7266- ply_terminal_stop_watching_for_active_vt_change (backend->terminal,
7267- (ply_terminal_active_vt_changed_handler_t)
7268- on_active_vt_changed,
7269- backend);
7270+ if (backend->terminal != NULL)
7271+ ply_terminal_stop_watching_for_active_vt_change (backend->terminal,
7272+ (ply_terminal_active_vt_changed_handler_t)
7273+ on_active_vt_changed,
7274+ backend);
7275
7276 unload_driver (backend);
7277 }
7278@@ -985,10 +892,17 @@ map_to_device (ply_renderer_backend_t *backend)
7279 node = next_node;
7280 }
7281
7282- if (ply_terminal_is_active (backend->terminal))
7283- activate (backend);
7284+ if (backend->terminal != NULL)
7285+ {
7286+ if (ply_terminal_is_active (backend->terminal))
7287+ activate (backend);
7288+ else
7289+ ply_terminal_activate_vt (backend->terminal);
7290+ }
7291 else
7292- ply_terminal_activate_vt (backend->terminal);
7293+ {
7294+ activate (backend);
7295+ }
7296
7297 return head_mapped;
7298 }
7299@@ -1116,8 +1030,11 @@ reset_scan_out_buffer_if_needed (ply_renderer_backend_t *backend,
7300 drmModeCrtc *controller;
7301 bool did_reset = false;
7302
7303- if (!ply_terminal_is_active (backend->terminal))
7304- return false;
7305+ if (backend->terminal != NULL)
7306+ {
7307+ if (!ply_terminal_is_active (backend->terminal))
7308+ return false;
7309+ }
7310
7311 controller = drmModeGetCrtc (backend->device_fd, head->controller_id);
7312
7313@@ -1151,8 +1068,11 @@ flush_head (ply_renderer_backend_t *backend,
7314 if (!backend->is_active)
7315 return;
7316
7317- ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
7318- ply_terminal_set_unbuffered_input (backend->terminal);
7319+ if (backend->terminal != NULL)
7320+ {
7321+ ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
7322+ ply_terminal_set_unbuffered_input (backend->terminal);
7323+ }
7324 pixel_buffer = head->pixel_buffer;
7325 updated_region = ply_pixel_buffer_get_updated_areas (pixel_buffer);
7326 areas_to_flush = ply_region_get_sorted_rectangle_list (updated_region);
7327@@ -1260,6 +1180,9 @@ open_input_source (ply_renderer_backend_t *backend,
7328 assert (backend != NULL);
7329 assert (has_input_source (backend, input_source));
7330
7331+ if (backend->terminal == NULL)
7332+ return false;
7333+
7334 terminal_fd = ply_terminal_get_fd (backend->terminal);
7335
7336 input_source->backend = backend;
7337@@ -1290,6 +1213,9 @@ close_input_source (ply_renderer_backend_t *backend,
7338 assert (backend != NULL);
7339 assert (has_input_source (backend, input_source));
7340
7341+ if (backend->terminal == NULL)
7342+ return;
7343+
7344 ply_event_loop_stop_watching_fd (backend->loop, input_source->terminal_input_watch);
7345 input_source->terminal_input_watch = NULL;
7346 input_source->backend = NULL;
7347diff --git a/src/plugins/renderers/drm/ply-renderer-generic-driver.c b/src/plugins/renderers/drm/ply-renderer-generic-driver.c
7348index 50fde64..45a8faa 100644
7349--- a/src/plugins/renderers/drm/ply-renderer-generic-driver.c
7350+++ b/src/plugins/renderers/drm/ply-renderer-generic-driver.c
7351@@ -71,6 +71,8 @@ struct _ply_renderer_driver
7352 {
7353 int device_fd;
7354 ply_hashtable_t *buffers;
7355+
7356+ uint32_t requires_explicit_flushing : 1;
7357 };
7358
7359 static bool
7360@@ -123,7 +125,7 @@ create_driver (int device_fd)
7361
7362 driver = calloc (1, sizeof (ply_renderer_driver_t));
7363 driver->device_fd = device_fd;
7364-
7365+ driver->requires_explicit_flushing = true;
7366 driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
7367 ply_hashtable_direct_compare);
7368
7369@@ -330,6 +332,22 @@ end_flush (ply_renderer_driver_t *driver,
7370 buffer = get_buffer_from_id (driver, buffer_id);
7371
7372 assert (buffer != NULL);
7373+
7374+ if (driver->requires_explicit_flushing)
7375+ {
7376+ struct drm_clip_rect flush_area;
7377+ int ret;
7378+
7379+ flush_area.x1 = 0;
7380+ flush_area.y1 = 0;
7381+ flush_area.x2 = buffer->width;
7382+ flush_area.y2 = buffer->height;
7383+
7384+ ret = drmModeDirtyFB (driver->device_fd, buffer->id, &flush_area, 1);
7385+
7386+ if (ret == -ENOSYS)
7387+ driver->requires_explicit_flushing = false;
7388+ }
7389 }
7390
7391 static void
7392diff --git a/src/plugins/renderers/drm/ply-renderer-i915-driver.c b/src/plugins/renderers/drm/ply-renderer-i915-driver.c
7393deleted file mode 100644
7394index 907a061..0000000
7395--- a/src/plugins/renderers/drm/ply-renderer-i915-driver.c
7396+++ /dev/null
7397@@ -1,383 +0,0 @@
7398-/* ply-renderer-i915-driver.c - interface to i915 drm driver
7399- *
7400- * Copyright (C) 2009 Red Hat, Inc.
7401- *
7402- * This program is free software; you can redistribute it and/or modify
7403- * it under the terms of the GNU General Public License as published by
7404- * the Free Software Foundation; either version 2, or (at your option)
7405- * any later version.
7406- *
7407- * This program is distributed in the hope that it will be useful,
7408- * but WITHOUT ANY WARRANTY; without even the implied warranty of
7409- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7410- * GNU General Public License for more details.
7411- *
7412- * You should have received a copy of the GNU General Public License
7413- * along with this program; if not, write to the Free Software
7414- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
7415- * 02111-1307, USA.
7416- *
7417- * Written by: Ray Strode <rstrode@redhat.com>
7418- */
7419-#include "config.h"
7420-
7421-#include "ply-renderer-i915-driver.h"
7422-
7423-#include <arpa/inet.h>
7424-#include <assert.h>
7425-#include <errno.h>
7426-#include <fcntl.h>
7427-#include <signal.h>
7428-#include <string.h>
7429-#include <stdbool.h>
7430-#include <stdint.h>
7431-#include <stdio.h>
7432-#include <stdlib.h>
7433-#include <sys/ioctl.h>
7434-#include <sys/mman.h>
7435-#include <sys/stat.h>
7436-#include <sys/types.h>
7437-#include <values.h>
7438-#include <unistd.h>
7439-
7440-#include <drm.h>
7441-#include <i915_drm.h>
7442-#include <intel_bufmgr.h>
7443-#include <xf86drm.h>
7444-#include <xf86drmMode.h>
7445-
7446-#include "ply-hashtable.h"
7447-#include "ply-logger.h"
7448-#include "ply-renderer-driver.h"
7449-
7450-typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
7451-
7452-struct _ply_renderer_buffer
7453-{
7454- drm_intel_bo *object;
7455- uint32_t id;
7456- unsigned long width;
7457- unsigned long height;
7458- unsigned long row_stride;
7459-
7460- uint32_t added_fb : 1;
7461-};
7462-
7463-struct _ply_renderer_driver
7464-{
7465- int device_fd;
7466- drm_intel_bufmgr *manager;
7467-
7468- ply_hashtable_t *buffers;
7469-};
7470-
7471-static ply_renderer_driver_t *
7472-create_driver (int device_fd)
7473-{
7474- ply_renderer_driver_t *driver;
7475- int page_size;
7476-
7477- driver = calloc (1, sizeof (ply_renderer_driver_t));
7478- driver->device_fd = device_fd;
7479-
7480- page_size = (int) sysconf (_SC_PAGE_SIZE);
7481-
7482- driver->manager = drm_intel_bufmgr_gem_init (driver->device_fd, page_size);
7483- if (driver->manager == NULL)
7484- {
7485- ply_trace ("intel buffer manager could not be initialized");
7486- free (driver);
7487- return NULL;
7488- }
7489-
7490- driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
7491- ply_hashtable_direct_compare);
7492-
7493- return driver;
7494-}
7495-
7496-static void
7497-destroy_driver (ply_renderer_driver_t *driver)
7498-{
7499- ply_hashtable_free (driver->buffers);
7500-
7501- ply_trace ("uninitializing intel buffer manager");
7502- drm_intel_bufmgr_destroy (driver->manager);
7503- free (driver);
7504-}
7505-
7506-static ply_renderer_buffer_t *
7507-ply_renderer_buffer_new (ply_renderer_driver_t *driver,
7508- drm_intel_bo *buffer_object,
7509- uint32_t id,
7510- unsigned long width,
7511- unsigned long height,
7512- unsigned long row_stride)
7513-{
7514- ply_renderer_buffer_t *buffer;
7515-
7516- buffer = calloc (1, sizeof (ply_renderer_buffer_t));
7517- buffer->object = buffer_object;
7518- buffer->id = id;
7519- buffer->width = width;
7520- buffer->height = height;
7521- buffer->row_stride = row_stride;
7522-
7523- ply_trace ("returning %lux%lu buffer with stride %lu",
7524- width, height, row_stride);
7525-
7526- return buffer;
7527-}
7528-
7529-static drm_intel_bo *
7530-create_intel_bo_from_handle (ply_renderer_driver_t *driver,
7531- uint32_t handle)
7532-{
7533- struct drm_gem_flink flink_request;
7534- char *name;
7535- drm_intel_bo *buffer_object;
7536-
7537- /* FIXME: This can't be the right way to do this.
7538- *
7539- * 1) It requires skirting around the API and using ioctls
7540- * 2) It requires taking a local handle, turning it into a
7541- * a global handle ("name"), just so we can use an api that
7542- * will open the global name and grab the local handle from it.
7543- */
7544-
7545- memset (&flink_request, 0, sizeof (struct drm_gem_flink));
7546- flink_request.handle = handle;
7547-
7548- if (ioctl (driver->device_fd, DRM_IOCTL_GEM_FLINK, &flink_request) < 0)
7549- {
7550- ply_trace ("Could not export global name for handle %u", handle);
7551- return NULL;
7552- }
7553-
7554- asprintf (&name, "buffer %u", handle);
7555-
7556- buffer_object = drm_intel_bo_gem_create_from_name (driver->manager,
7557- name, flink_request.name);
7558- free (name);
7559-
7560- return buffer_object;
7561-}
7562-
7563-static ply_renderer_buffer_t *
7564-ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
7565- uint32_t buffer_id)
7566-{
7567- ply_renderer_buffer_t *buffer;
7568- drmModeFB *fb;
7569- drm_intel_bo *buffer_object;
7570-
7571- fb = drmModeGetFB (driver->device_fd, buffer_id);
7572-
7573- if (fb == NULL)
7574- {
7575- ply_trace ("could not get FB with buffer id %u", buffer_id);
7576- return NULL;
7577- }
7578-
7579- buffer_object = create_intel_bo_from_handle (driver, fb->handle);
7580-
7581- if (buffer_object == NULL)
7582- {
7583- ply_trace ("could not create buffer object from handle %lu",
7584- (unsigned long) fb->handle);
7585- drmModeFreeFB (fb);
7586- return NULL;
7587- }
7588-
7589- buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
7590- fb->width, fb->height, fb->pitch);
7591- drmModeFreeFB (fb);
7592-
7593- return buffer;
7594-}
7595-
7596-static ply_renderer_buffer_t *
7597-get_buffer_from_id (ply_renderer_driver_t *driver,
7598- uint32_t buffer_id)
7599-{
7600- static ply_renderer_buffer_t *buffer;
7601-
7602- buffer = ply_hashtable_lookup (driver->buffers,
7603- (void *) (uintptr_t) buffer_id);
7604-
7605- return buffer;
7606-}
7607-
7608-static bool
7609-fetch_buffer (ply_renderer_driver_t *driver,
7610- uint32_t buffer_id,
7611- unsigned long *width,
7612- unsigned long *height,
7613- unsigned long *row_stride)
7614-{
7615- ply_renderer_buffer_t *buffer;
7616-
7617- buffer = get_buffer_from_id (driver, buffer_id);
7618-
7619- if (buffer == NULL)
7620- {
7621- ply_trace ("could not fetch buffer %u, creating one", buffer_id);
7622- buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
7623-
7624- if (buffer == NULL)
7625- {
7626- ply_trace ("could not create buffer either %u", buffer_id);
7627- return false;
7628- }
7629-
7630- ply_hashtable_insert (driver->buffers,
7631- (void *) (uintptr_t) buffer_id,
7632- buffer);
7633- }
7634-
7635- if (width != NULL)
7636- *width = buffer->width;
7637-
7638- if (height != NULL)
7639- *height = buffer->height;
7640-
7641- if (row_stride != NULL)
7642- *row_stride = buffer->row_stride;
7643-
7644- ply_trace ("fetched %lux%lu buffer with stride %lu",
7645- buffer->width, buffer->height, buffer->row_stride);
7646- return true;
7647-}
7648-
7649-static uint32_t
7650-create_buffer (ply_renderer_driver_t *driver,
7651- unsigned long width,
7652- unsigned long height,
7653- unsigned long *row_stride)
7654-{
7655- drm_intel_bo *buffer_object;
7656- ply_renderer_buffer_t *buffer;
7657- uint32_t buffer_id;
7658-
7659- *row_stride = ply_round_to_multiple (width * 4, 256);
7660-
7661- buffer_object = drm_intel_bo_alloc (driver->manager,
7662- "frame buffer",
7663- height * *row_stride, 0);
7664-
7665- if (buffer_object == NULL)
7666- {
7667- ply_trace ("Could not allocate GEM object for frame buffer: %m");
7668- return 0;
7669- }
7670-
7671- if (drmModeAddFB (driver->device_fd, width, height,
7672- 24, 32, *row_stride, buffer_object->handle,
7673- &buffer_id) != 0)
7674- {
7675- ply_trace ("Could not set up GEM object as frame buffer: %m");
7676- drm_intel_bo_unreference (buffer_object);
7677- return 0;
7678- }
7679-
7680- buffer = ply_renderer_buffer_new (driver,
7681- buffer_object, buffer_id,
7682- width, height, *row_stride);
7683- buffer->added_fb = true;
7684- ply_hashtable_insert (driver->buffers,
7685- (void *) (uintptr_t) buffer_id,
7686- buffer);
7687-
7688- return buffer_id;
7689-}
7690-
7691-static bool
7692-map_buffer (ply_renderer_driver_t *driver,
7693- uint32_t buffer_id)
7694-{
7695- ply_renderer_buffer_t *buffer;
7696-
7697- buffer = get_buffer_from_id (driver, buffer_id);
7698-
7699- assert (buffer != NULL);
7700- drm_intel_gem_bo_map_gtt (buffer->object);
7701-
7702- return true;
7703-}
7704-
7705-static void
7706-unmap_buffer (ply_renderer_driver_t *driver,
7707- uint32_t buffer_id)
7708-{
7709- ply_renderer_buffer_t *buffer;
7710-
7711- buffer = get_buffer_from_id (driver, buffer_id);
7712-
7713- assert (buffer != NULL);
7714- drm_intel_gem_bo_unmap_gtt (buffer->object);
7715-}
7716-
7717-static char *
7718-begin_flush (ply_renderer_driver_t *driver,
7719- uint32_t buffer_id)
7720-{
7721- ply_renderer_buffer_t *buffer;
7722-
7723- buffer = get_buffer_from_id (driver, buffer_id);
7724-
7725- assert (buffer != NULL);
7726-
7727- return buffer->object->virtual;
7728-}
7729-
7730-static void
7731-end_flush (ply_renderer_driver_t *driver,
7732- uint32_t buffer_id)
7733-{
7734- ply_renderer_buffer_t *buffer;
7735-
7736- buffer = get_buffer_from_id (driver, buffer_id);
7737-
7738- assert (buffer != NULL);
7739-}
7740-
7741-static void
7742-destroy_buffer (ply_renderer_driver_t *driver,
7743- uint32_t buffer_id)
7744-{
7745- ply_renderer_buffer_t *buffer;
7746-
7747- buffer = get_buffer_from_id (driver, buffer_id);
7748-
7749- assert (buffer != NULL);
7750-
7751- if (buffer->added_fb)
7752- drmModeRmFB (driver->device_fd, buffer->id);
7753-
7754- drm_intel_bo_unreference (buffer->object);
7755-
7756- ply_hashtable_remove (driver->buffers,
7757- (void *) (uintptr_t) buffer_id);
7758- free (buffer);
7759-}
7760-
7761-ply_renderer_driver_interface_t *
7762-ply_renderer_i915_driver_get_interface (void)
7763-{
7764- static ply_renderer_driver_interface_t driver_interface =
7765- {
7766- .create_driver = create_driver,
7767- .destroy_driver = destroy_driver,
7768- .create_buffer = create_buffer,
7769- .fetch_buffer = fetch_buffer,
7770- .map_buffer = map_buffer,
7771- .unmap_buffer = unmap_buffer,
7772- .begin_flush = begin_flush,
7773- .end_flush = end_flush,
7774- .destroy_buffer = destroy_buffer,
7775- };
7776-
7777- return &driver_interface;
7778-}
7779-
7780-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
7781diff --git a/src/plugins/renderers/drm/ply-renderer-i915-driver.h b/src/plugins/renderers/drm/ply-renderer-i915-driver.h
7782deleted file mode 100644
7783index dcc983c..0000000
7784--- a/src/plugins/renderers/drm/ply-renderer-i915-driver.h
7785+++ /dev/null
7786@@ -1,32 +0,0 @@
7787-/* ply-renderer-i915-driver.h
7788- *
7789- * Copyright (C) 2009 Red Hat, Inc.
7790- *
7791- * This program is free software; you can redistribute it and/or modify
7792- * it under the terms of the GNU General Public License as published by
7793- * the Free Software Foundation; either version 2, or (at your option)
7794- * any later version.
7795- *
7796- * This program is distributed in the hope that it will be useful,
7797- * but WITHOUT ANY WARRANTY; without even the implied warranty of
7798- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7799- * GNU General Public License for more details.
7800- *
7801- * You should have received a copy of the GNU General Public License
7802- * along with this program; if not, write to the Free Software
7803- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
7804- * 02111-1307, USA.
7805- *
7806- * Written By: Ray Strode <rstrode@redhat.com>
7807- */
7808-#ifndef PLY_RENDERER_I915_DRIVER_H
7809-#define PLY_RENDERER_I915_DRIVER_H
7810-
7811-#include "ply-renderer-driver.h"
7812-
7813-#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
7814-ply_renderer_driver_interface_t *ply_renderer_i915_driver_get_interface (void);
7815-#endif
7816-
7817-#endif /* PLY_RENDERER_I915_DRIVER_H */
7818-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
7819diff --git a/src/plugins/renderers/drm/ply-renderer-libkms-driver.c b/src/plugins/renderers/drm/ply-renderer-libkms-driver.c
7820deleted file mode 100644
7821index 18c7ccf..0000000
7822--- a/src/plugins/renderers/drm/ply-renderer-libkms-driver.c
7823+++ /dev/null
7824@@ -1,430 +0,0 @@
7825-/* ply-renderer-libkms-driver.c - interface to libkms abstraction over drm drivers
7826- *
7827- * Copyright (C) 2010 Red Hat, Inc.
7828- *
7829- * This program is free software; you can redistribute it and/or modify
7830- * it under the terms of the GNU General Public License as published by
7831- * the Free Software Foundation; either version 2, or (at your option)
7832- * any later version.
7833- *
7834- * This program is distributed in the hope that it will be useful,
7835- * but WITHOUT ANY WARRANTY; without even the implied warranty of
7836- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7837- * GNU General Public License for more details.
7838- *
7839- * You should have received a copy of the GNU General Public License
7840- * along with this program; if not, write to the Free Software
7841- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
7842- * 02111-1307, USA.
7843- *
7844- * Written by: Ray Strode <rstrode@redhat.com>
7845- */
7846-#include "config.h"
7847-
7848-#include "ply-renderer-libkms-driver.h"
7849-
7850-#include <arpa/inet.h>
7851-#include <assert.h>
7852-#include <errno.h>
7853-#include <fcntl.h>
7854-#include <signal.h>
7855-#include <string.h>
7856-#include <stdbool.h>
7857-#include <stdint.h>
7858-#include <stdio.h>
7859-#include <stdlib.h>
7860-#include <sys/ioctl.h>
7861-#include <sys/mman.h>
7862-#include <sys/stat.h>
7863-#include <sys/types.h>
7864-#include <values.h>
7865-#include <unistd.h>
7866-
7867-#include <drm.h>
7868-#include <libkms.h>
7869-#include <xf86drm.h>
7870-#include <xf86drmMode.h>
7871-
7872-#include "ply-array.h"
7873-#include "ply-hashtable.h"
7874-#include "ply-logger.h"
7875-#include "ply-renderer-driver.h"
7876-
7877-typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
7878-
7879-struct _ply_renderer_buffer
7880-{
7881- struct kms_bo *object;
7882- uint32_t id;
7883- unsigned long width;
7884- unsigned long height;
7885- unsigned long row_stride;
7886-
7887- void *map_address;
7888-
7889- uint32_t added_fb : 1;
7890-};
7891-
7892-struct _ply_renderer_driver
7893-{
7894- int device_fd;
7895- struct kms_driver *driver;
7896-
7897- ply_hashtable_t *buffers;
7898-};
7899-
7900-static ply_renderer_driver_t *
7901-create_driver (int device_fd)
7902-{
7903- ply_renderer_driver_t *driver;
7904- int result;
7905-
7906- driver = calloc (1, sizeof (ply_renderer_driver_t));
7907- driver->device_fd = device_fd;
7908-
7909- result = kms_create (driver->device_fd, &driver->driver);
7910- if (result != 0)
7911- {
7912- ply_trace ("kms buffer driver could not be initialized: %d", result);
7913- free (driver);
7914- return NULL;
7915- }
7916-
7917- driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
7918- ply_hashtable_direct_compare);
7919-
7920- return driver;
7921-}
7922-
7923-static void
7924-destroy_driver (ply_renderer_driver_t *driver)
7925-{
7926- ply_hashtable_free (driver->buffers);
7927-
7928- ply_trace ("uninitializing kms buffer driver");
7929- kms_destroy (&driver->driver);
7930- free (driver);
7931-}
7932-
7933-static ply_renderer_buffer_t *
7934-ply_renderer_buffer_new (ply_renderer_driver_t *driver,
7935- struct kms_bo *buffer_object,
7936- uint32_t id,
7937- unsigned long width,
7938- unsigned long height,
7939- unsigned long row_stride)
7940-{
7941- ply_renderer_buffer_t *buffer;
7942-
7943- buffer = calloc (1, sizeof (ply_renderer_buffer_t));
7944- buffer->object = buffer_object;
7945- buffer->id = id;
7946- buffer->width = width;
7947- buffer->height = height;
7948- buffer->row_stride = row_stride;
7949-
7950- ply_trace ("returning %lux%lu buffer with stride %lu",
7951- width, height, row_stride);
7952-
7953- return buffer;
7954-}
7955-
7956-static ply_renderer_buffer_t *
7957-get_buffer_from_id (ply_renderer_driver_t *driver,
7958- uint32_t id)
7959-{
7960- static ply_renderer_buffer_t *buffer;
7961-
7962- buffer = ply_hashtable_lookup (driver->buffers, (void *) (uintptr_t) id);
7963-
7964- return buffer;
7965-}
7966-
7967-static struct kms_bo *
7968-create_kms_bo_from_handle (ply_renderer_driver_t *driver,
7969- uint32_t handle)
7970-{
7971- struct drm_gem_flink flink_request;
7972- struct kms_bo *buffer_object;
7973- ply_array_t *attributes;
7974- int result;
7975-
7976- /* FIXME: This can't be the right way to do this.
7977- *
7978- * 1) It requires skirting around the API and using ioctls
7979- * 2) It requires taking a local handle, turning it into a
7980- * a global handle ("name"), just so we can use an api that
7981- * will open the global name and grab the local handle from it.
7982- */
7983-
7984- memset (&flink_request, 0, sizeof (struct drm_gem_flink));
7985- flink_request.handle = handle;
7986-
7987- if (ioctl (driver->device_fd, DRM_IOCTL_GEM_FLINK, &flink_request) < 0)
7988- {
7989- ply_trace ("Could not export global name for handle %u", handle);
7990- return NULL;
7991- }
7992-
7993- attributes = ply_array_new (PLY_ARRAY_ELEMENT_TYPE_UINT32);
7994- ply_array_add_uint32_element (attributes, KMS_HANDLE);
7995- ply_array_add_uint32_element (attributes, flink_request.name);
7996- ply_array_add_uint32_element (attributes, KMS_TERMINATE_PROP_LIST);
7997- result = kms_bo_create (driver->driver,
7998- (const unsigned *)
7999- ply_array_get_uint32_elements (attributes),
8000- &buffer_object);
8001- ply_array_free (attributes);
8002-
8003- if (result != 0)
8004- {
8005- ply_trace ("could not create buffer object from global name %u: %d",
8006- flink_request.name, result);
8007- return NULL;
8008- }
8009-
8010- return buffer_object;
8011-}
8012-
8013-static ply_renderer_buffer_t *
8014-ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
8015- uint32_t buffer_id)
8016-{
8017- ply_renderer_buffer_t *buffer;
8018- drmModeFB *fb;
8019- struct kms_bo *buffer_object;
8020-
8021- fb = drmModeGetFB (driver->device_fd, buffer_id);
8022-
8023- if (fb == NULL)
8024- {
8025- ply_trace ("could not get FB with buffer id %u", buffer_id);
8026- return NULL;
8027- }
8028-
8029- buffer_object = create_kms_bo_from_handle (driver, fb->handle);
8030-
8031- if (buffer_object == NULL)
8032- {
8033- ply_trace ("could not create buffer object from handle %lu",
8034- (unsigned long) fb->handle);
8035- drmModeFreeFB (fb);
8036- return NULL;
8037- }
8038-
8039- buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
8040- fb->width, fb->height, fb->pitch);
8041- drmModeFreeFB (fb);
8042-
8043- return buffer;
8044-}
8045-
8046-static bool
8047-fetch_buffer (ply_renderer_driver_t *driver,
8048- uint32_t buffer_id,
8049- unsigned long *width,
8050- unsigned long *height,
8051- unsigned long *row_stride)
8052-{
8053- ply_renderer_buffer_t *buffer;
8054-
8055- buffer = get_buffer_from_id (driver, buffer_id);
8056-
8057- if (buffer == NULL)
8058- {
8059- ply_trace ("could not fetch buffer %u, creating one", buffer_id);
8060- buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
8061-
8062- if (buffer == NULL)
8063- {
8064- ply_trace ("could not create buffer either %u", buffer_id);
8065- return false;
8066- }
8067-
8068- ply_hashtable_insert (driver->buffers,
8069- (void *) (uintptr_t) buffer_id,
8070- buffer);
8071- }
8072-
8073- if (width != NULL)
8074- *width = buffer->width;
8075-
8076- if (height != NULL)
8077- *height = buffer->height;
8078-
8079- if (row_stride != NULL)
8080- *row_stride = buffer->row_stride;
8081-
8082- ply_trace ("fetched %lux%lu buffer with stride %lu",
8083- buffer->width, buffer->height, buffer->row_stride);
8084- return true;
8085-}
8086-
8087-static uint32_t
8088-create_buffer (ply_renderer_driver_t *driver,
8089- unsigned long width,
8090- unsigned long height,
8091- unsigned long *row_stride)
8092-{
8093- struct kms_bo *buffer_object;
8094- ply_renderer_buffer_t *buffer;
8095- uint32_t buffer_id;
8096- int result;
8097- unsigned int handle;
8098- ply_array_t *attributes;
8099-
8100- *row_stride = ply_round_to_multiple (width * 4, 256);
8101-
8102- attributes = ply_array_new (PLY_ARRAY_ELEMENT_TYPE_UINT32);
8103- ply_array_add_uint32_element (attributes, KMS_BO_TYPE);
8104- ply_array_add_uint32_element (attributes, KMS_BO_TYPE_SCANOUT_X8R8G8B8);
8105- ply_array_add_uint32_element (attributes, KMS_WIDTH);
8106- ply_array_add_uint32_element (attributes, (uint32_t) width);
8107- ply_array_add_uint32_element (attributes, KMS_HEIGHT);
8108- ply_array_add_uint32_element (attributes, (uint32_t) height);
8109- ply_array_add_uint32_element (attributes, KMS_PITCH);
8110- ply_array_add_uint32_element (attributes, (uint32_t) *row_stride);
8111- ply_array_add_uint32_element (attributes, KMS_TERMINATE_PROP_LIST);
8112- result = kms_bo_create (driver->driver,
8113- (const unsigned *)
8114- ply_array_get_uint32_elements (attributes),
8115- &buffer_object);
8116- ply_array_free (attributes);
8117-
8118- if (result != 0)
8119- {
8120- ply_trace ("Could not allocate GEM object for frame buffer: %d", result);
8121- return 0;
8122- }
8123-
8124- result = kms_bo_get_prop (buffer_object, KMS_HANDLE, &handle);
8125-
8126- if (result != 0)
8127- {
8128- ply_trace ("Could not retrieve handle from GEM object: %d", result);
8129-
8130- kms_bo_destroy (&buffer_object);
8131- return 0;
8132- }
8133-
8134- if (drmModeAddFB (driver->device_fd, width, height,
8135- 24, 32, *row_stride, handle,
8136- &buffer_id) != 0)
8137- {
8138- ply_trace ("Could not set up GEM object as frame buffer: %m");
8139- kms_bo_destroy (&buffer_object);
8140- return 0;
8141- }
8142-
8143- buffer = ply_renderer_buffer_new (driver,
8144- buffer_object, buffer_id,
8145- width, height, *row_stride);
8146- buffer->added_fb = true;
8147- ply_hashtable_insert (driver->buffers,
8148- (void *) (uintptr_t) buffer_id,
8149- buffer);
8150-
8151- return buffer_id;
8152-}
8153-
8154-static bool
8155-map_buffer (ply_renderer_driver_t *driver,
8156- uint32_t buffer_id)
8157-{
8158- ply_renderer_buffer_t *buffer;
8159- int result;
8160-
8161- buffer = get_buffer_from_id (driver, buffer_id);
8162-
8163- assert (buffer != NULL);
8164-
8165- result = kms_bo_map (buffer->object, &buffer->map_address);
8166-
8167- if (result != 0)
8168- {
8169- ply_trace ("could not map buffer %u: %d", buffer_id, result);
8170- buffer->map_address = MAP_FAILED;
8171- return false;
8172- }
8173-
8174- return true;
8175-}
8176-
8177-static void
8178-unmap_buffer (ply_renderer_driver_t *driver,
8179- uint32_t buffer_id)
8180-{
8181- ply_renderer_buffer_t *buffer;
8182-
8183- buffer = get_buffer_from_id (driver, buffer_id);
8184-
8185- assert (buffer != NULL);
8186-
8187- kms_bo_unmap (buffer->object);
8188- buffer->map_address = MAP_FAILED;
8189-}
8190-
8191-static char *
8192-begin_flush (ply_renderer_driver_t *driver,
8193- uint32_t buffer_id)
8194-{
8195- ply_renderer_buffer_t *buffer;
8196-
8197- buffer = get_buffer_from_id (driver, buffer_id);
8198-
8199- assert (buffer != NULL);
8200-
8201- return (char *) buffer->map_address;
8202-}
8203-
8204-static void
8205-end_flush (ply_renderer_driver_t *driver,
8206- uint32_t buffer_id)
8207-{
8208- ply_renderer_buffer_t *buffer;
8209-
8210- buffer = get_buffer_from_id (driver, buffer_id);
8211-
8212- assert (buffer != NULL);
8213-}
8214-
8215-static void
8216-destroy_buffer (ply_renderer_driver_t *driver,
8217- uint32_t buffer_id)
8218-{
8219- ply_renderer_buffer_t *buffer;
8220-
8221- buffer = get_buffer_from_id (driver, buffer_id);
8222-
8223- assert (buffer != NULL);
8224-
8225- if (buffer->added_fb)
8226- drmModeRmFB (driver->device_fd, buffer->id);
8227-
8228- kms_bo_destroy (&buffer->object);
8229-
8230- ply_hashtable_remove (driver->buffers,
8231- (void *) (uintptr_t) buffer_id);
8232- free (buffer);
8233-}
8234-
8235-ply_renderer_driver_interface_t *
8236-ply_renderer_libkms_driver_get_interface (void)
8237-{
8238- static ply_renderer_driver_interface_t driver_interface =
8239- {
8240- .create_driver = create_driver,
8241- .destroy_driver = destroy_driver,
8242- .create_buffer = create_buffer,
8243- .fetch_buffer = fetch_buffer,
8244- .map_buffer = map_buffer,
8245- .unmap_buffer = unmap_buffer,
8246- .begin_flush = begin_flush,
8247- .end_flush = end_flush,
8248- .destroy_buffer = destroy_buffer,
8249- };
8250-
8251- return &driver_interface;
8252-}
8253-
8254-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
8255diff --git a/src/plugins/renderers/drm/ply-renderer-libkms-driver.h b/src/plugins/renderers/drm/ply-renderer-libkms-driver.h
8256deleted file mode 100644
8257index b419a94..0000000
8258--- a/src/plugins/renderers/drm/ply-renderer-libkms-driver.h
8259+++ /dev/null
8260@@ -1,32 +0,0 @@
8261-/* ply-renderer-kms-driver.h
8262- *
8263- * Copyright (C) 2009 Red Hat, Inc.
8264- *
8265- * This program is free software; you can redistribute it and/or modify
8266- * it under the terms of the GNU General Public License as published by
8267- * the Free Software Foundation; either version 2, or (at your option)
8268- * any later version.
8269- *
8270- * This program is distributed in the hope that it will be useful,
8271- * but WITHOUT ANY WARRANTY; without even the implied warranty of
8272- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8273- * GNU General Public License for more details.
8274- *
8275- * You should have received a copy of the GNU General Public License
8276- * along with this program; if not, write to the Free Software
8277- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
8278- * 02111-1307, USA.
8279- *
8280- * Written By: Ray Strode <rstrode@redhat.com>
8281- */
8282-#ifndef PLY_RENDERER_LIBKMS_DRIVER_H
8283-#define PLY_RENDERER_LIBKMS_DRIVER_H
8284-
8285-#include "ply-renderer-driver.h"
8286-
8287-#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
8288-ply_renderer_driver_interface_t *ply_renderer_libkms_driver_get_interface (void);
8289-#endif
8290-
8291-#endif /* PLY_RENDERER_LIBKMS_DRIVER_H */
8292-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
8293diff --git a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.c b/src/plugins/renderers/drm/ply-renderer-nouveau-driver.c
8294deleted file mode 100644
8295index 2cef56e..0000000
8296--- a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.c
8297+++ /dev/null
8298@@ -1,352 +0,0 @@
8299-/* ply-renderer-nouveau-driver.c - interface to nouveau drm driver
8300- *
8301- * Copyright (C) 2009 Red Hat, Inc.
8302- *
8303- * This program is free software; you can redistribute it and/or modify
8304- * it under the terms of the GNU General Public License as published by
8305- * the Free Software Foundation; either version 2, or (at your option)
8306- * any later version.
8307- *
8308- * This program is distributed in the hope that it will be useful,
8309- * but WITHOUT ANY WARRANTY; without even the implied warranty of
8310- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8311- * GNU General Public License for more details.
8312- *
8313- * You should have received a copy of the GNU General Public License
8314- * along with this program; if not, write to the Free Software
8315- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
8316- * 02111-1307, USA.
8317- *
8318- * Written by: Ray Strode <rstrode@redhat.com>
8319- */
8320-#include "config.h"
8321-
8322-#include "ply-renderer-nouveau-driver.h"
8323-
8324-#include <arpa/inet.h>
8325-#include <assert.h>
8326-#include <errno.h>
8327-#include <fcntl.h>
8328-#include <signal.h>
8329-#include <string.h>
8330-#include <stdbool.h>
8331-#include <stdint.h>
8332-#include <stdio.h>
8333-#include <stdlib.h>
8334-#include <sys/ioctl.h>
8335-#include <sys/mman.h>
8336-#include <sys/stat.h>
8337-#include <sys/types.h>
8338-#include <values.h>
8339-#include <unistd.h>
8340-
8341-#include <drm.h>
8342-#include <nouveau_drm.h>
8343-#include <nouveau_drmif.h>
8344-#include <nouveau_bo.h>
8345-#include <xf86drm.h>
8346-#include <xf86drmMode.h>
8347-
8348-#include "ply-hashtable.h"
8349-#include "ply-logger.h"
8350-#include "ply-renderer-driver.h"
8351-
8352-typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
8353-
8354-struct _ply_renderer_buffer
8355-{
8356- struct nouveau_bo *object;
8357- uint32_t id;
8358- unsigned long width;
8359- unsigned long height;
8360- unsigned long row_stride;
8361-
8362- uint32_t added_fb : 1;
8363-};
8364-
8365-struct _ply_renderer_driver
8366-{
8367- int device_fd;
8368- struct nouveau_device *device;
8369-
8370- ply_hashtable_t *buffers;
8371-};
8372-
8373-static ply_renderer_driver_t *
8374-create_driver (int device_fd)
8375-{
8376- ply_renderer_driver_t *driver;
8377-
8378- driver = calloc (1, sizeof (ply_renderer_driver_t));
8379- driver->device_fd = device_fd;
8380-
8381- if (nouveau_device_open_existing (&driver->device, true,
8382- driver->device_fd, 0) < 0)
8383- {
8384- ply_trace ("could not open nouveau device");
8385- free (driver);
8386- return NULL;
8387- }
8388-
8389- driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
8390- ply_hashtable_direct_compare);
8391-
8392- return driver;
8393-}
8394-
8395-static void
8396-destroy_driver (ply_renderer_driver_t *driver)
8397-{
8398- ply_hashtable_free (driver->buffers);
8399-
8400- ply_trace ("closing nouveau device");
8401- nouveau_device_close (&driver->device);
8402- free (driver);
8403-}
8404-
8405-static ply_renderer_buffer_t *
8406-ply_renderer_buffer_new (ply_renderer_driver_t *driver,
8407- struct nouveau_bo *buffer_object,
8408- uint32_t id,
8409- unsigned long width,
8410- unsigned long height,
8411- unsigned long row_stride)
8412-{
8413- ply_renderer_buffer_t *buffer;
8414-
8415- buffer = calloc (1, sizeof (ply_renderer_buffer_t));
8416- buffer->object = buffer_object;
8417- buffer->id = id;
8418- buffer->width = width;
8419- buffer->height = height;
8420- buffer->row_stride = row_stride;
8421-
8422- ply_trace ("returning %lux%lu buffer with stride %lu",
8423- width, height, row_stride);
8424-
8425- return buffer;
8426-}
8427-
8428-static ply_renderer_buffer_t *
8429-ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
8430- uint32_t buffer_id)
8431-{
8432- ply_renderer_buffer_t *buffer;
8433- drmModeFB *fb;
8434- struct nouveau_bo *buffer_object;
8435-
8436- fb = drmModeGetFB (driver->device_fd, buffer_id);
8437-
8438- if (fb == NULL)
8439- {
8440- ply_trace ("could not get FB with buffer id %u", buffer_id);
8441- return NULL;
8442- }
8443-
8444- if (nouveau_bo_wrap (driver->device,
8445- fb->handle, &buffer_object) < 0)
8446- {
8447- ply_trace ("could not create buffer object from handle %lu",
8448- (unsigned long) fb->handle);
8449- drmModeFreeFB (fb);
8450- return NULL;
8451- }
8452-
8453- buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
8454- fb->width, fb->height, fb->pitch);
8455- drmModeFreeFB (fb);
8456-
8457- return buffer;
8458-}
8459-
8460-static ply_renderer_buffer_t *
8461-get_buffer_from_id (ply_renderer_driver_t *driver,
8462- uint32_t id)
8463-{
8464- static ply_renderer_buffer_t *buffer;
8465-
8466- buffer = ply_hashtable_lookup (driver->buffers, (void *) (uintptr_t) id);
8467-
8468- return buffer;
8469-}
8470-
8471-static bool
8472-fetch_buffer (ply_renderer_driver_t *driver,
8473- uint32_t buffer_id,
8474- unsigned long *width,
8475- unsigned long *height,
8476- unsigned long *row_stride)
8477-{
8478- ply_renderer_buffer_t *buffer;
8479-
8480- buffer = get_buffer_from_id (driver, buffer_id);
8481-
8482- if (buffer == NULL)
8483- {
8484- ply_trace ("could not fetch buffer %u, creating one", buffer_id);
8485- buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
8486-
8487- if (buffer == NULL)
8488- {
8489- ply_trace ("could not create buffer either %u", buffer_id);
8490- return false;
8491- }
8492-
8493- ply_hashtable_insert (driver->buffers,
8494- (void *) (uintptr_t) buffer_id,
8495- buffer);
8496- }
8497-
8498- if (width != NULL)
8499- *width = buffer->width;
8500-
8501- if (height != NULL)
8502- *height = buffer->height;
8503-
8504- if (row_stride != NULL)
8505- *row_stride = buffer->row_stride;
8506-
8507- ply_trace ("fetched %lux%lu buffer with stride %lu",
8508- buffer->width, buffer->height, buffer->row_stride);
8509- return true;
8510-}
8511-
8512-
8513-static uint32_t
8514-create_buffer (ply_renderer_driver_t *driver,
8515- unsigned long width,
8516- unsigned long height,
8517- unsigned long *row_stride)
8518-{
8519- struct nouveau_bo *buffer_object;
8520- ply_renderer_buffer_t *buffer;
8521- uint32_t buffer_id;
8522-
8523- *row_stride = ply_round_to_multiple (width * 4, 256);
8524-
8525- buffer_object = NULL;
8526- if (nouveau_bo_new (driver->device,
8527- NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, 0,
8528- height * *row_stride, &buffer_object) < 0)
8529- {
8530- ply_trace ("Could not allocate GEM object for frame buffer: %m");
8531- return 0;
8532- }
8533-
8534- /* The map here forces the buffer object to be instantiated
8535- * immediately (it's normally instantiated lazily when needed
8536- * by other nouveau_bo api)
8537- */
8538- nouveau_bo_map (buffer_object, NOUVEAU_BO_WR);
8539- if (drmModeAddFB (driver->device_fd, width, height,
8540- 24, 32, *row_stride, buffer_object->handle,
8541- &buffer_id) != 0)
8542- {
8543- nouveau_bo_unmap (buffer_object);
8544- ply_trace ("Could not set up GEM object as frame buffer: %m");
8545- nouveau_bo_ref (NULL, &buffer_object);
8546- return 0;
8547- }
8548- nouveau_bo_unmap (buffer_object);
8549-
8550- buffer = ply_renderer_buffer_new (driver,
8551- buffer_object, buffer_id,
8552- width, height, *row_stride);
8553- buffer->added_fb = true;
8554- ply_hashtable_insert (driver->buffers,
8555- (void *) (uintptr_t) buffer_id,
8556- buffer);
8557-
8558- return buffer_id;
8559-}
8560-
8561-static bool
8562-map_buffer (ply_renderer_driver_t *driver,
8563- uint32_t buffer_id)
8564-{
8565- ply_renderer_buffer_t *buffer;
8566-
8567- buffer = get_buffer_from_id (driver, buffer_id);
8568-
8569- assert (buffer != NULL);
8570-
8571- return nouveau_bo_map (buffer->object, NOUVEAU_BO_WR) == 0;
8572-}
8573-
8574-static void
8575-unmap_buffer (ply_renderer_driver_t *driver,
8576- uint32_t buffer_id)
8577-{
8578- ply_renderer_buffer_t *buffer;
8579-
8580- buffer = get_buffer_from_id (driver, buffer_id);
8581-
8582- assert (buffer != NULL);
8583-
8584- nouveau_bo_unmap (buffer->object);
8585-}
8586-
8587-static char *
8588-begin_flush (ply_renderer_driver_t *driver,
8589- uint32_t buffer_id)
8590-{
8591- ply_renderer_buffer_t *buffer;
8592-
8593- buffer = get_buffer_from_id (driver, buffer_id);
8594-
8595- assert (buffer != NULL);
8596-
8597- return buffer->object->map;
8598-}
8599-
8600-static void
8601-end_flush (ply_renderer_driver_t *driver,
8602- uint32_t buffer_id)
8603-{
8604- ply_renderer_buffer_t *buffer;
8605-
8606- buffer = get_buffer_from_id (driver, buffer_id);
8607-
8608- assert (buffer != NULL);
8609-}
8610-
8611-static void
8612-destroy_buffer (ply_renderer_driver_t *driver,
8613- uint32_t buffer_id)
8614-{
8615- ply_renderer_buffer_t *buffer;
8616-
8617- buffer = get_buffer_from_id (driver, buffer_id);
8618-
8619- assert (buffer != NULL);
8620-
8621- if (buffer->added_fb)
8622- drmModeRmFB (driver->device_fd, buffer->id);
8623-
8624- nouveau_bo_ref (NULL, &buffer->object);
8625-
8626- ply_hashtable_remove (driver->buffers,
8627- (void *) (uintptr_t) buffer_id);
8628- free (buffer);
8629-}
8630-
8631-ply_renderer_driver_interface_t *
8632-ply_renderer_nouveau_driver_get_interface (void)
8633-{
8634- static ply_renderer_driver_interface_t driver_interface =
8635- {
8636- .create_driver = create_driver,
8637- .destroy_driver = destroy_driver,
8638- .create_buffer = create_buffer,
8639- .fetch_buffer = fetch_buffer,
8640- .map_buffer = map_buffer,
8641- .unmap_buffer = unmap_buffer,
8642- .begin_flush = begin_flush,
8643- .end_flush = end_flush,
8644- .destroy_buffer = destroy_buffer,
8645- };
8646-
8647- return &driver_interface;
8648-}
8649-
8650-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
8651diff --git a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.h b/src/plugins/renderers/drm/ply-renderer-nouveau-driver.h
8652deleted file mode 100644
8653index 1baed4a..0000000
8654--- a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.h
8655+++ /dev/null
8656@@ -1,32 +0,0 @@
8657-/* ply-renderer-nouveau-driver.h
8658- *
8659- * Copyright (C) 2009 Red Hat, Inc.
8660- *
8661- * This program is free software; you can redistribute it and/or modify
8662- * it under the terms of the GNU General Public License as published by
8663- * the Free Software Foundation; either version 2, or (at your option)
8664- * any later version.
8665- *
8666- * This program is distributed in the hope that it will be useful,
8667- * but WITHOUT ANY WARRANTY; without even the implied warranty of
8668- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8669- * GNU General Public License for more details.
8670- *
8671- * You should have received a copy of the GNU General Public License
8672- * along with this program; if not, write to the Free Software
8673- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
8674- * 02111-1307, USA.
8675- *
8676- * Written By: Ray Strode <rstrode@redhat.com>
8677- */
8678-#ifndef PLY_RENDERER_NOUVEAU_DRIVER_H
8679-#define PLY_RENDERER_NOUVEAU_DRIVER_H
8680-
8681-#include "ply-renderer-driver.h"
8682-
8683-#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
8684-ply_renderer_driver_interface_t *ply_renderer_nouveau_driver_get_interface (void);
8685-#endif
8686-
8687-#endif /* PLY_RENDERER_NOUVEAU_DRIVER_H */
8688-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
8689diff --git a/src/plugins/renderers/drm/ply-renderer-radeon-driver.c b/src/plugins/renderers/drm/ply-renderer-radeon-driver.c
8690deleted file mode 100644
8691index 36cee47..0000000
8692--- a/src/plugins/renderers/drm/ply-renderer-radeon-driver.c
8693+++ /dev/null
8694@@ -1,377 +0,0 @@
8695-/* ply-renderer-radeon-driver.c - interface to radeon drm driver
8696- *
8697- * Copyright (C) 2009 Red Hat, Inc.
8698- *
8699- * This program is free software; you can redistribute it and/or modify
8700- * it under the terms of the GNU General Public License as published by
8701- * the Free Software Foundation; either version 2, or (at your option)
8702- * any later version.
8703- *
8704- * This program is distributed in the hope that it will be useful,
8705- * but WITHOUT ANY WARRANTY; without even the implied warranty of
8706- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8707- * GNU General Public License for more details.
8708- *
8709- * You should have received a copy of the GNU General Public License
8710- * along with this program; if not, write to the Free Software
8711- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
8712- * 02111-1307, USA.
8713- *
8714- * Written by: Ray Strode <rstrode@redhat.com>
8715- */
8716-#include "config.h"
8717-
8718-#include "ply-renderer-radeon-driver.h"
8719-
8720-#include <arpa/inet.h>
8721-#include <assert.h>
8722-#include <errno.h>
8723-#include <fcntl.h>
8724-#include <signal.h>
8725-#include <string.h>
8726-#include <stdbool.h>
8727-#include <stdint.h>
8728-#include <stdio.h>
8729-#include <stdlib.h>
8730-#include <sys/ioctl.h>
8731-#include <sys/mman.h>
8732-#include <sys/stat.h>
8733-#include <sys/types.h>
8734-#include <values.h>
8735-#include <unistd.h>
8736-
8737-#include <drm.h>
8738-#include <radeon_drm.h>
8739-#include <radeon_bo.h>
8740-#include <radeon_bo_gem.h>
8741-#include <xf86drm.h>
8742-#include <xf86drmMode.h>
8743-
8744-#include "ply-hashtable.h"
8745-#include "ply-logger.h"
8746-#include "ply-renderer-driver.h"
8747-
8748-typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
8749-
8750-struct _ply_renderer_buffer
8751-{
8752- struct radeon_bo *object;
8753- uint32_t id;
8754- unsigned long width;
8755- unsigned long height;
8756- unsigned long row_stride;
8757-
8758- uint32_t added_fb : 1;
8759-};
8760-
8761-struct _ply_renderer_driver
8762-{
8763- int device_fd;
8764- struct radeon_bo_manager *manager;
8765-
8766- ply_hashtable_t *buffers;
8767-};
8768-
8769-static ply_renderer_driver_t *
8770-create_driver (int device_fd)
8771-{
8772- ply_renderer_driver_t *driver;
8773-
8774- driver = calloc (1, sizeof (ply_renderer_driver_t));
8775- driver->device_fd = device_fd;
8776-
8777- driver->manager = radeon_bo_manager_gem_ctor (driver->device_fd);
8778- if (driver->manager == NULL)
8779- {
8780- ply_trace ("radeon buffer manager could not be initialized");
8781- free (driver);
8782- return NULL;
8783- }
8784-
8785- driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
8786- ply_hashtable_direct_compare);
8787-
8788- return driver;
8789-}
8790-
8791-static void
8792-destroy_driver (ply_renderer_driver_t *driver)
8793-{
8794- ply_hashtable_free (driver->buffers);
8795-
8796- ply_trace ("uninitializing radeon buffer manager");
8797- radeon_bo_manager_gem_dtor (driver->manager);
8798- free (driver);
8799-}
8800-
8801-static ply_renderer_buffer_t *
8802-ply_renderer_buffer_new (ply_renderer_driver_t *driver,
8803- struct radeon_bo *buffer_object,
8804- uint32_t id,
8805- unsigned long width,
8806- unsigned long height,
8807- unsigned long row_stride)
8808-{
8809- ply_renderer_buffer_t *buffer;
8810-
8811- buffer = calloc (1, sizeof (ply_renderer_buffer_t));
8812- buffer->object = buffer_object;
8813- buffer->id = id;
8814- buffer->width = width;
8815- buffer->height = height;
8816- buffer->row_stride = row_stride;
8817-
8818- ply_trace ("returning %lux%lu buffer with stride %lu",
8819- width, height, row_stride);
8820-
8821- return buffer;
8822-}
8823-
8824-static ply_renderer_buffer_t *
8825-get_buffer_from_id (ply_renderer_driver_t *driver,
8826- uint32_t id)
8827-{
8828- static ply_renderer_buffer_t *buffer;
8829-
8830- buffer = ply_hashtable_lookup (driver->buffers, (void *) (uintptr_t) id);
8831-
8832- return buffer;
8833-}
8834-
8835-static struct radeon_bo *
8836-create_radeon_bo_from_handle (ply_renderer_driver_t *driver,
8837- uint32_t handle)
8838-{
8839- struct drm_gem_flink flink_request;
8840- struct radeon_bo *buffer_object;
8841-
8842- /* FIXME: This can't be the right way to do this.
8843- *
8844- * 1) It requires skirting around the API and using ioctls
8845- * 2) It requires taking a local handle, turning it into a
8846- * a global handle ("name"), just so we can use an api that
8847- * will open the global name and grab the local handle from it.
8848- */
8849-
8850- memset (&flink_request, 0, sizeof (struct drm_gem_flink));
8851- flink_request.handle = handle;
8852-
8853- if (ioctl (driver->device_fd, DRM_IOCTL_GEM_FLINK, &flink_request) < 0)
8854- {
8855- ply_trace ("Could not export global name for handle %u", handle);
8856- return NULL;
8857- }
8858-
8859- buffer_object = radeon_bo_open (driver->manager, flink_request.name,
8860- 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
8861-
8862- return buffer_object;
8863-}
8864-
8865-static ply_renderer_buffer_t *
8866-ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
8867- uint32_t buffer_id)
8868-{
8869- ply_renderer_buffer_t *buffer;
8870- drmModeFB *fb;
8871- struct radeon_bo *buffer_object;
8872-
8873- fb = drmModeGetFB (driver->device_fd, buffer_id);
8874-
8875- if (fb == NULL)
8876- {
8877- ply_trace ("could not get FB with buffer id %u", buffer_id);
8878- return NULL;
8879- }
8880-
8881- buffer_object = create_radeon_bo_from_handle (driver, fb->handle);
8882-
8883- if (buffer_object == NULL)
8884- {
8885- ply_trace ("could not create buffer object from handle %lu",
8886- (unsigned long) fb->handle);
8887- drmModeFreeFB (fb);
8888- return NULL;
8889- }
8890-
8891- buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
8892- fb->width, fb->height, fb->pitch);
8893- drmModeFreeFB (fb);
8894-
8895- return buffer;
8896-}
8897-
8898-
8899-static bool
8900-fetch_buffer (ply_renderer_driver_t *driver,
8901- uint32_t buffer_id,
8902- unsigned long *width,
8903- unsigned long *height,
8904- unsigned long *row_stride)
8905-{
8906- ply_renderer_buffer_t *buffer;
8907-
8908- buffer = get_buffer_from_id (driver, buffer_id);
8909-
8910- if (buffer == NULL)
8911- {
8912- ply_trace ("could not fetch buffer %u, creating one", buffer_id);
8913- buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
8914-
8915- if (buffer == NULL)
8916- {
8917- ply_trace ("could not create buffer either %u", buffer_id);
8918- return false;
8919- }
8920-
8921- ply_hashtable_insert (driver->buffers,
8922- (void *) (uintptr_t) buffer_id,
8923- buffer);
8924- }
8925-
8926- if (width != NULL)
8927- *width = buffer->width;
8928-
8929- if (height != NULL)
8930- *height = buffer->height;
8931-
8932- if (row_stride != NULL)
8933- *row_stride = buffer->row_stride;
8934-
8935- ply_trace ("fetched %lux%lu buffer with stride %lu",
8936- buffer->width, buffer->height, buffer->row_stride);
8937- return true;
8938-}
8939-
8940-static uint32_t
8941-create_buffer (ply_renderer_driver_t *driver,
8942- unsigned long width,
8943- unsigned long height,
8944- unsigned long *row_stride)
8945-{
8946- struct radeon_bo *buffer_object;
8947- ply_renderer_buffer_t *buffer;
8948- uint32_t buffer_id;
8949-
8950- *row_stride = ply_round_to_multiple (width * 4, 256);
8951-
8952- buffer_object = radeon_bo_open (driver->manager, 0,
8953- height * *row_stride,
8954- 0, RADEON_GEM_DOMAIN_GTT, 0);
8955-
8956- if (buffer_object == NULL)
8957- {
8958- ply_trace ("Could not allocate GEM object for frame buffer: %m");
8959- return 0;
8960- }
8961-
8962- if (drmModeAddFB (driver->device_fd, width, height,
8963- 24, 32, *row_stride, buffer_object->handle,
8964- &buffer_id) != 0)
8965- {
8966- ply_trace ("Could not set up GEM object as frame buffer: %m");
8967- radeon_bo_unref (buffer_object);
8968- return 0;
8969- }
8970-
8971- buffer = ply_renderer_buffer_new (driver,
8972- buffer_object, buffer_id,
8973- width, height, *row_stride);
8974- buffer->added_fb = true;
8975- ply_hashtable_insert (driver->buffers,
8976- (void *) (uintptr_t) buffer_id,
8977- buffer);
8978-
8979- return buffer_id;
8980-}
8981-
8982-static bool
8983-map_buffer (ply_renderer_driver_t *driver,
8984- uint32_t buffer_id)
8985-{
8986- ply_renderer_buffer_t *buffer;
8987-
8988- buffer = get_buffer_from_id (driver, buffer_id);
8989-
8990- assert (buffer != NULL);
8991-
8992- return radeon_bo_map (buffer->object, true) == 0;
8993-}
8994-
8995-static void
8996-unmap_buffer (ply_renderer_driver_t *driver,
8997- uint32_t buffer_id)
8998-{
8999- ply_renderer_buffer_t *buffer;
9000-
9001- buffer = get_buffer_from_id (driver, buffer_id);
9002-
9003- assert (buffer != NULL);
9004-
9005- radeon_bo_unmap (buffer->object);
9006-}
9007-
9008-static char *
9009-begin_flush (ply_renderer_driver_t *driver,
9010- uint32_t buffer_id)
9011-{
9012- ply_renderer_buffer_t *buffer;
9013-
9014- buffer = get_buffer_from_id (driver, buffer_id);
9015-
9016- assert (buffer != NULL);
9017-
9018- return buffer->object->ptr;
9019-}
9020-
9021-static void
9022-end_flush (ply_renderer_driver_t *driver,
9023- uint32_t buffer_id)
9024-{
9025- ply_renderer_buffer_t *buffer;
9026-
9027- buffer = get_buffer_from_id (driver, buffer_id);
9028-
9029- assert (buffer != NULL);
9030-}
9031-
9032-static void
9033-destroy_buffer (ply_renderer_driver_t *driver,
9034- uint32_t buffer_id)
9035-{
9036- ply_renderer_buffer_t *buffer;
9037-
9038- buffer = get_buffer_from_id (driver, buffer_id);
9039-
9040- assert (buffer != NULL);
9041-
9042- if (buffer->added_fb)
9043- drmModeRmFB (driver->device_fd, buffer->id);
9044-
9045- radeon_bo_unref (buffer->object);
9046-
9047- ply_hashtable_remove (driver->buffers,
9048- (void *) (uintptr_t) buffer_id);
9049- free (buffer);
9050-}
9051-
9052-ply_renderer_driver_interface_t *
9053-ply_renderer_radeon_driver_get_interface (void)
9054-{
9055- static ply_renderer_driver_interface_t driver_interface =
9056- {
9057- .create_driver = create_driver,
9058- .destroy_driver = destroy_driver,
9059- .create_buffer = create_buffer,
9060- .fetch_buffer = fetch_buffer,
9061- .map_buffer = map_buffer,
9062- .unmap_buffer = unmap_buffer,
9063- .begin_flush = begin_flush,
9064- .end_flush = end_flush,
9065- .destroy_buffer = destroy_buffer,
9066- };
9067-
9068- return &driver_interface;
9069-}
9070-
9071-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
9072diff --git a/src/plugins/renderers/drm/ply-renderer-radeon-driver.h b/src/plugins/renderers/drm/ply-renderer-radeon-driver.h
9073deleted file mode 100644
9074index dcec1b1..0000000
9075--- a/src/plugins/renderers/drm/ply-renderer-radeon-driver.h
9076+++ /dev/null
9077@@ -1,32 +0,0 @@
9078-/* ply-renderer-radeon-driver.h
9079- *
9080- * Copyright (C) 2009 Red Hat, Inc.
9081- *
9082- * This program is free software; you can redistribute it and/or modify
9083- * it under the terms of the GNU General Public License as published by
9084- * the Free Software Foundation; either version 2, or (at your option)
9085- * any later version.
9086- *
9087- * This program is distributed in the hope that it will be useful,
9088- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9089- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9090- * GNU General Public License for more details.
9091- *
9092- * You should have received a copy of the GNU General Public License
9093- * along with this program; if not, write to the Free Software
9094- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
9095- * 02111-1307, USA.
9096- *
9097- * Written By: Ray Strode <rstrode@redhat.com>
9098- */
9099-#ifndef PLY_RENDERER_RADEON_DRIVER_H
9100-#define PLY_RENDERER_RADEON_DRIVER_H
9101-
9102-#include "ply-renderer-driver.h"
9103-
9104-#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
9105-ply_renderer_driver_interface_t *ply_renderer_radeon_driver_get_interface (void);
9106-#endif
9107-
9108-#endif /* PLY_RENDERER_RADEON_DRIVER_H */
9109-/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
9110diff --git a/src/plugins/renderers/frame-buffer/Makefile.am b/src/plugins/renderers/frame-buffer/Makefile.am
9111index 44f9d6a..12e1470 100644
9112--- a/src/plugins/renderers/frame-buffer/Makefile.am
9113+++ b/src/plugins/renderers/frame-buffer/Makefile.am
9114@@ -1,4 +1,4 @@
9115-INCLUDES = -I$(top_srcdir) \
9116+AM_CPPFLAGS = -I$(top_srcdir) \
9117 -I$(srcdir)/../../../libply \
9118 -I$(srcdir)/../../../libply-splash-core \
9119 -I$(srcdir)/../../.. \
9120diff --git a/src/plugins/renderers/frame-buffer/plugin.c b/src/plugins/renderers/frame-buffer/plugin.c
9121index 0e07943..dd73a0f 100644
9122--- a/src/plugins/renderers/frame-buffer/plugin.c
9123+++ b/src/plugins/renderers/frame-buffer/plugin.c
9124@@ -351,6 +351,9 @@ open_device (ply_renderer_backend_t *backend)
9125 return false;
9126 }
9127
9128+ if (backend->terminal == NULL)
9129+ return true;
9130+
9131 if (!ply_terminal_open (backend->terminal))
9132 {
9133 ply_trace ("could not open terminal: %m");
9134@@ -376,10 +379,11 @@ static void
9135 close_device (ply_renderer_backend_t *backend)
9136 {
9137
9138- ply_terminal_stop_watching_for_active_vt_change (backend->terminal,
9139- (ply_terminal_active_vt_changed_handler_t)
9140- on_active_vt_changed,
9141- backend);
9142+ if (backend->terminal != NULL)
9143+ ply_terminal_stop_watching_for_active_vt_change (backend->terminal,
9144+ (ply_terminal_active_vt_changed_handler_t)
9145+ on_active_vt_changed,
9146+ backend);
9147 uninitialize_head (backend, &backend->head);
9148
9149 close (backend->device_fd);
9150@@ -546,15 +550,22 @@ map_to_device (ply_renderer_backend_t *backend)
9151 return false;
9152 }
9153
9154- if (ply_terminal_is_active (backend->terminal))
9155+ if (backend->terminal != NULL)
9156 {
9157- ply_trace ("already on right vt, activating");
9158- activate (backend);
9159+ if (ply_terminal_is_active (backend->terminal))
9160+ {
9161+ ply_trace ("already on right vt, activating");
9162+ activate (backend);
9163+ }
9164+ else
9165+ {
9166+ ply_trace ("on wrong vt, changing vts");
9167+ ply_terminal_activate_vt (backend->terminal);
9168+ }
9169 }
9170 else
9171 {
9172- ply_trace ("on wrong vt, changing vts");
9173- ply_terminal_activate_vt (backend->terminal);
9174+ activate (backend);
9175 }
9176
9177 return true;
9178@@ -590,8 +601,11 @@ flush_head (ply_renderer_backend_t *backend,
9179 if (!backend->is_active)
9180 return;
9181
9182- ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
9183- ply_terminal_set_unbuffered_input (backend->terminal);
9184+ if (backend->terminal != NULL)
9185+ {
9186+ ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
9187+ ply_terminal_set_unbuffered_input (backend->terminal);
9188+ }
9189 pixel_buffer = head->pixel_buffer;
9190 updated_region = ply_pixel_buffer_get_updated_areas (pixel_buffer);
9191 areas_to_flush = ply_region_get_sorted_rectangle_list (updated_region);
9192@@ -685,6 +699,9 @@ open_input_source (ply_renderer_backend_t *backend,
9193 assert (backend != NULL);
9194 assert (has_input_source (backend, input_source));
9195
9196+ if (backend->terminal == NULL)
9197+ return false;
9198+
9199 terminal_fd = ply_terminal_get_fd (backend->terminal);
9200
9201 input_source->backend = backend;
9202@@ -715,6 +732,9 @@ close_input_source (ply_renderer_backend_t *backend,
9203 assert (backend != NULL);
9204 assert (has_input_source (backend, input_source));
9205
9206+ if (backend->terminal == NULL)
9207+ return;
9208+
9209 ply_event_loop_stop_watching_fd (backend->loop, input_source->terminal_input_watch);
9210 input_source->terminal_input_watch = NULL;
9211 input_source->backend = NULL;
9212diff --git a/src/plugins/renderers/x11/Makefile.am b/src/plugins/renderers/x11/Makefile.am
9213index fd142c0..33513ac 100644
9214--- a/src/plugins/renderers/x11/Makefile.am
9215+++ b/src/plugins/renderers/x11/Makefile.am
9216@@ -1,4 +1,4 @@
9217-INCLUDES = -I$(top_srcdir) \
9218+AM_CPPFLAGS = -I$(top_srcdir) \
9219 -I$(srcdir)/../../../libply \
9220 -I$(srcdir)/../../../libply-splash-core \
9221 -I$(srcdir)/../../.. \
9222diff --git a/src/plugins/splash/Makefile.am b/src/plugins/splash/Makefile.am
9223index 02f94fa..a19197b 100644
9224--- a/src/plugins/splash/Makefile.am
9225+++ b/src/plugins/splash/Makefile.am
9226@@ -1,2 +1,2 @@
9227-SUBDIRS = throbgress fade-throbber text details space-flares two-step script
9228+SUBDIRS = throbgress fade-throbber text details space-flares two-step script tribar
9229 MAINTAINERCLEANFILES = Makefile.in
9230diff --git a/src/plugins/splash/details/Makefile.am b/src/plugins/splash/details/Makefile.am
9231index a656129..3be4755 100644
9232--- a/src/plugins/splash/details/Makefile.am
9233+++ b/src/plugins/splash/details/Makefile.am
9234@@ -1,4 +1,4 @@
9235-INCLUDES = -I$(top_srcdir) \
9236+AM_CPPFLAGS = -I$(top_srcdir) \
9237 -I$(srcdir)/../../../libply \
9238 -I$(srcdir)/../../../libply-splash-core \
9239 -I$(srcdir)/../../.. \
9240diff --git a/src/plugins/splash/fade-throbber/Makefile.am b/src/plugins/splash/fade-throbber/Makefile.am
9241index f7b559b..6bbb490 100644
9242--- a/src/plugins/splash/fade-throbber/Makefile.am
9243+++ b/src/plugins/splash/fade-throbber/Makefile.am
9244@@ -1,4 +1,4 @@
9245-INCLUDES = -I$(top_srcdir) \
9246+AM_CPPFLAGS = -I$(top_srcdir) \
9247 -I$(srcdir)/../../../libply \
9248 -I$(srcdir)/../../../libply-splash-core \
9249 -I$(srcdir)/../../../libply-splash-graphics \
9250diff --git a/src/plugins/splash/script/Makefile.am b/src/plugins/splash/script/Makefile.am
9251index 0f2b0f7..ce46df6 100644
9252--- a/src/plugins/splash/script/Makefile.am
9253+++ b/src/plugins/splash/script/Makefile.am
9254@@ -1,4 +1,4 @@
9255-INCLUDES = -I$(top_srcdir) \
9256+AM_CPPFLAGS = -I$(top_srcdir) \
9257 -I$(srcdir)/../../../libply \
9258 -I$(srcdir)/../../../libply-splash-core \
9259 -I$(srcdir)/../../../libply-splash-graphics \
9260diff --git a/src/plugins/splash/script/script-debug.c b/src/plugins/splash/script/script-debug.c
9261index 355c2b2..118574b 100644
9262--- a/src/plugins/splash/script/script-debug.c
9263+++ b/src/plugins/splash/script/script-debug.c
9264@@ -19,6 +19,10 @@
9265 *
9266 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9267 */
9268+#ifdef HAVE_CONFIG_H
9269+#include "config.h"
9270+#endif
9271+
9272 #include "ply-hashtable.h"
9273 #include <stdlib.h>
9274 #include <string.h>
9275diff --git a/src/plugins/splash/script/script-execute.c b/src/plugins/splash/script/script-execute.c
9276index 6abd3a6..c06959b 100644
9277--- a/src/plugins/splash/script/script-execute.c
9278+++ b/src/plugins/splash/script/script-execute.c
9279@@ -19,7 +19,11 @@
9280 *
9281 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9282 */
9283-#define _GNU_SOURCE
9284+
9285+#ifdef HAVE_CONFIG_H
9286+#include "config.h"
9287+#endif
9288+
9289 #include "ply-hashtable.h"
9290 #include "ply-list.h"
9291 #include "ply-logger.h"
9292diff --git a/src/plugins/splash/script/script-lib-image.c b/src/plugins/splash/script/script-lib-image.c
9293index 5be27fb..f08be31 100644
9294--- a/src/plugins/splash/script/script-lib-image.c
9295+++ b/src/plugins/splash/script/script-lib-image.c
9296@@ -19,7 +19,9 @@
9297 *
9298 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9299 */
9300-#define _GNU_SOURCE
9301+
9302+#include "config.h"
9303+
9304 #include "ply-image.h"
9305 #include "ply-label.h"
9306 #include "ply-pixel-buffer.h"
9307@@ -36,8 +38,6 @@
9308 #include <stdlib.h>
9309 #include <string.h>
9310
9311-#include "config.h"
9312-
9313 #include "script-lib-image.script.h"
9314
9315 static void image_free (script_obj_t *obj)
9316diff --git a/src/plugins/splash/script/script-lib-math.c b/src/plugins/splash/script/script-lib-math.c
9317index a1afc04..3f2dc79 100644
9318--- a/src/plugins/splash/script/script-lib-math.c
9319+++ b/src/plugins/splash/script/script-lib-math.c
9320@@ -19,7 +19,10 @@
9321 *
9322 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9323 */
9324-#define _GNU_SOURCE
9325+
9326+#include "config.h"
9327+
9328+#include "ply-utils.h"
9329 #include "script.h"
9330 #include "script-parse.h"
9331 #include "script-execute.h"
9332@@ -31,7 +34,6 @@
9333 #include <string.h>
9334 #include <math.h>
9335
9336-#include "config.h"
9337
9338 #include "script-lib-math.script.h"
9339
9340diff --git a/src/plugins/splash/script/script-lib-plymouth.c b/src/plugins/splash/script/script-lib-plymouth.c
9341index 5c648a6..ab2ec44 100644
9342--- a/src/plugins/splash/script/script-lib-plymouth.c
9343+++ b/src/plugins/splash/script/script-lib-plymouth.c
9344@@ -19,7 +19,9 @@
9345 *
9346 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9347 */
9348-#define _GNU_SOURCE
9349+
9350+#include "config.h"
9351+
9352 #include "ply-boot-splash-plugin.h"
9353 #include "ply-utils.h"
9354 #include "script.h"
9355@@ -32,8 +34,6 @@
9356 #include <stdlib.h>
9357 #include <string.h>
9358
9359-#include "config.h"
9360-
9361 #include "script-lib-plymouth.script.h"
9362
9363 static script_return_t plymouth_set_function (script_state_t *state,
9364@@ -64,6 +64,7 @@ static script_return_t plymouth_get_mode (script_state_t *state,
9365 case PLY_BOOT_SPLASH_MODE_UPDATES:
9366 obj = script_obj_new_string ("updates");
9367 break;
9368+ case PLY_BOOT_SPLASH_MODE_INVALID:
9369 default:
9370 obj = script_obj_new_string ("unknown");
9371 break;
9372diff --git a/src/plugins/splash/script/script-lib-string.c b/src/plugins/splash/script/script-lib-string.c
9373index dbd63fe..0b836eb 100644
9374--- a/src/plugins/splash/script/script-lib-string.c
9375+++ b/src/plugins/splash/script/script-lib-string.c
9376@@ -19,7 +19,9 @@
9377 *
9378 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9379 */
9380-#define _GNU_SOURCE
9381+
9382+#include "config.h"
9383+
9384 #include "script.h"
9385 #include "script-parse.h"
9386 #include "script-execute.h"
9387@@ -31,8 +33,6 @@
9388 #include <stdlib.h>
9389 #include <string.h>
9390
9391-#include "config.h"
9392-
9393 #include "script-lib-string.script.h"
9394
9395
9396diff --git a/src/plugins/splash/script/script-object.c b/src/plugins/splash/script/script-object.c
9397index 465fef6..7c16c94 100644
9398--- a/src/plugins/splash/script/script-object.c
9399+++ b/src/plugins/splash/script/script-object.c
9400@@ -19,7 +19,11 @@
9401 *
9402 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9403 */
9404-#define _GNU_SOURCE
9405+
9406+#ifdef HAVE_CONFIG_H
9407+#include "config.h"
9408+#endif
9409+
9410 #include "ply-hashtable.h"
9411 #include "ply-list.h"
9412 #include "ply-bitarray.h"
9413diff --git a/src/plugins/splash/script/script-parse.c b/src/plugins/splash/script/script-parse.c
9414index 10eb667..4adf273 100644
9415--- a/src/plugins/splash/script/script-parse.c
9416+++ b/src/plugins/splash/script/script-parse.c
9417@@ -19,7 +19,11 @@
9418 *
9419 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9420 */
9421-#define _GNU_SOURCE
9422+
9423+#ifdef HAVE_CONFIG_H
9424+#include "config.h"
9425+#endif
9426+
9427 #include "ply-hashtable.h"
9428 #include "ply-list.h"
9429 #include "ply-bitarray.h"
9430diff --git a/src/plugins/splash/script/script-scan.c b/src/plugins/splash/script/script-scan.c
9431index ead752f..5d1aa64 100644
9432--- a/src/plugins/splash/script/script-scan.c
9433+++ b/src/plugins/splash/script/script-scan.c
9434@@ -19,6 +19,10 @@
9435 *
9436 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9437 */
9438+#ifdef HAVE_CONFIG_H
9439+#include "config.h"
9440+#endif
9441+
9442 #include <stdio.h>
9443 #include <stdlib.h>
9444 #include <fcntl.h>
9445@@ -26,6 +30,7 @@
9446 #include <stdbool.h>
9447 #include <unistd.h>
9448 #include <string.h>
9449+#include <limits.h>
9450
9451 #include "ply-bitarray.h"
9452 #include "script-scan.h"
9453@@ -61,7 +66,7 @@ static script_scan_t *script_scan_new (void)
9454
9455 script_scan_t *script_scan_file (const char *filename)
9456 {
9457- int fd = open (filename, O_RDONLY);
9458+ int fd = open (filename, O_RDONLY|O_CLOEXEC);
9459 if (fd < 0) return NULL;
9460 script_scan_t *scan = script_scan_new ();
9461 scan->name = strdup (filename);
9462@@ -367,11 +372,13 @@ static script_scan_token_t *script_scan_peek_token (script_scan_t *scan,
9463 {
9464 int i;
9465
9466- if (scan->tokencount <= n)
9467+ /* we're screwed long before we ever actually hit INT_MAX; but at least
9468+ * we shouldn't get ourselves stuck in an infinite loop. */
9469+ if (scan->tokencount <= n && n < INT_MAX)
9470 {
9471 scan->tokens =
9472 realloc (scan->tokens, (n + 1) * sizeof (script_scan_token_t *));
9473- for (i = scan->tokencount; i <= n; i++) /* FIXME warning about possibely inifnite loop */
9474+ for (i = scan->tokencount; i <= n; i++)
9475 {
9476 scan->tokens[i] = malloc (sizeof (script_scan_token_t));
9477 scan->tokens[i]->type = SCRIPT_SCAN_TOKEN_TYPE_EMPTY;
9478diff --git a/src/plugins/splash/script/script.c b/src/plugins/splash/script/script.c
9479index 635a8b4..3290825 100644
9480--- a/src/plugins/splash/script/script.c
9481+++ b/src/plugins/splash/script/script.c
9482@@ -19,7 +19,11 @@
9483 *
9484 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9485 */
9486-#define _GNU_SOURCE
9487+
9488+#ifdef HAVE_CONFIG_H
9489+#include "config.h"
9490+#endif
9491+
9492 #include "ply-hashtable.h"
9493 #include "ply-list.h"
9494 #include "ply-bitarray.h"
9495diff --git a/src/plugins/splash/space-flares/Makefile.am b/src/plugins/splash/space-flares/Makefile.am
9496index 0d22a2e..24fdb39 100644
9497--- a/src/plugins/splash/space-flares/Makefile.am
9498+++ b/src/plugins/splash/space-flares/Makefile.am
9499@@ -1,4 +1,4 @@
9500-INCLUDES = -I$(top_srcdir) \
9501+AM_CPPFLAGS = -I$(top_srcdir) \
9502 -I$(srcdir)/../../../libply \
9503 -I$(srcdir)/../../../libply-splash-core \
9504 -I$(srcdir)/../../../libply-splash-graphics \
9505diff --git a/src/plugins/splash/text/Makefile.am b/src/plugins/splash/text/Makefile.am
9506index f4c21a8..7ccefb2 100644
9507--- a/src/plugins/splash/text/Makefile.am
9508+++ b/src/plugins/splash/text/Makefile.am
9509@@ -1,4 +1,4 @@
9510-INCLUDES = -I$(top_srcdir) \
9511+AM_CPPFLAGS = -I$(top_srcdir) \
9512 -I$(srcdir)/../../../libply \
9513 -I$(srcdir)/../../../libply-splash-core \
9514 -I$(srcdir)/../../.. \
9515diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c
9516index af81635..fb97c14 100644
9517--- a/src/plugins/splash/text/plugin.c
9518+++ b/src/plugins/splash/text/plugin.c
9519@@ -1,6 +1,5 @@
9520-/* text.c - boot splash plugin
9521- *
9522- * Copyright (C) 2008 Red Hat, Inc.
9523+/*
9524+ * Copyright (C) 2008-2012 Red Hat, Inc.
9525 *
9526 * This program is free software; you can redistribute it and/or modify
9527 * it under the terms of the GNU General Public License as published by
9528@@ -17,8 +16,6 @@
9529 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
9530 * 02111-1307, USA.
9531 *
9532- * Written by: Adam Jackson <ajax@redhat.com>
9533- * Ray Strode <rstrode@redhat.com>
9534 */
9535 #include "config.h"
9536
9537@@ -49,7 +46,7 @@
9538 #include "ply-list.h"
9539 #include "ply-logger.h"
9540 #include "ply-text-display.h"
9541-#include "ply-text-progress-bar.h"
9542+#include "ply-text-step-bar.h"
9543 #include "ply-utils.h"
9544
9545 #include <linux/kd.h>
9546@@ -78,7 +75,7 @@ typedef struct
9547 {
9548 ply_boot_splash_plugin_t *plugin;
9549 ply_text_display_t *display;
9550- ply_text_progress_bar_t *progress_bar;
9551+ ply_text_step_bar_t *step_bar;
9552
9553 } view_t;
9554
9555@@ -97,7 +94,7 @@ view_new (ply_boot_splash_plugin_t *plugin,
9556 view->plugin = plugin;
9557 view->display = display;
9558
9559- view->progress_bar = ply_text_progress_bar_new ();
9560+ view->step_bar = ply_text_step_bar_new ();
9561
9562 return view;
9563 }
9564@@ -105,7 +102,7 @@ view_new (ply_boot_splash_plugin_t *plugin,
9565 static void
9566 view_free (view_t *view)
9567 {
9568- ply_text_progress_bar_free (view->progress_bar);
9569+ ply_text_step_bar_free (view->step_bar);
9570
9571 free (view);
9572 }
9573@@ -180,10 +177,10 @@ view_start_animation (view_t *view)
9574 0xffffff);
9575 ply_terminal_set_color_hex_value (terminal,
9576 PLY_TERMINAL_COLOR_BLUE,
9577- 0x0073B3);
9578+ 0x3465a4);
9579 ply_terminal_set_color_hex_value (terminal,
9580 PLY_TERMINAL_COLOR_BROWN,
9581- 0x00457E);
9582+ 0x979a9b);
9583
9584 ply_text_display_set_background_color (view->display,
9585 PLY_TERMINAL_COLOR_BLACK);
9586@@ -192,11 +189,11 @@ view_start_animation (view_t *view)
9587
9588 if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
9589 {
9590- ply_text_progress_bar_hide (view->progress_bar);
9591+ ply_text_step_bar_hide (view->step_bar);
9592 return;
9593 }
9594
9595- ply_text_progress_bar_show (view->progress_bar,
9596+ ply_text_step_bar_show (view->step_bar,
9597 view->display);
9598 }
9599
9600@@ -452,7 +449,7 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
9601 view = ply_list_node_get_data (node);
9602 next_node = ply_list_get_next_node (plugin->views, node);
9603
9604- ply_text_progress_bar_hide (view->progress_bar);
9605+ ply_text_step_bar_hide (view->step_bar);
9606
9607 node = next_node;
9608 }
9609@@ -571,8 +568,8 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
9610 view = ply_list_node_get_data (node);
9611 next_node = ply_list_get_next_node (plugin->views, node);
9612
9613- ply_text_progress_bar_set_percent_done (view->progress_bar, percent_done);
9614- ply_text_progress_bar_draw (view->progress_bar);
9615+ ply_text_step_bar_set_percent_done (view->step_bar, percent_done);
9616+ ply_text_step_bar_draw (view->step_bar);
9617
9618 node = next_node;
9619 }
9620diff --git a/src/plugins/splash/throbgress/Makefile.am b/src/plugins/splash/throbgress/Makefile.am
9621index 8f93fd2..2ac1b0c 100644
9622--- a/src/plugins/splash/throbgress/Makefile.am
9623+++ b/src/plugins/splash/throbgress/Makefile.am
9624@@ -1,4 +1,4 @@
9625-INCLUDES = -I$(top_srcdir) \
9626+AM_CPPFLAGS = -I$(top_srcdir) \
9627 -I$(srcdir)/../../../libply \
9628 -I$(srcdir)/../../../libply-splash-core \
9629 -I$(srcdir)/../../../libply-splash-graphics \
9630diff --git a/src/plugins/splash/throbgress/plugin.c b/src/plugins/splash/throbgress/plugin.c
9631index 5ed6c06..fba809b 100644
9632--- a/src/plugins/splash/throbgress/plugin.c
9633+++ b/src/plugins/splash/throbgress/plugin.c
9634@@ -247,6 +247,8 @@ pause_views (ply_boot_splash_plugin_t *plugin)
9635 {
9636 ply_list_node_t *node;
9637
9638+ ply_trace ("pausing views");
9639+
9640 node = ply_list_get_first_node (plugin->views);
9641 while (node != NULL)
9642 {
9643@@ -267,6 +269,8 @@ unpause_views (ply_boot_splash_plugin_t *plugin)
9644 {
9645 ply_list_node_t *node;
9646
9647+ ply_trace ("unpausing views");
9648+
9649 node = ply_list_get_first_node (plugin->views);
9650 while (node != NULL)
9651 {
9652@@ -431,6 +435,8 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
9653 if (plugin == NULL)
9654 return;
9655
9656+ ply_trace ("destroying plugin");
9657+
9658 if (plugin->loop != NULL)
9659 {
9660 ply_event_loop_stop_watching_for_exit (plugin->loop, (ply_event_loop_exit_handler_t)
9661@@ -510,6 +516,8 @@ start_animation (ply_boot_splash_plugin_t *plugin)
9662 if (plugin->is_animating)
9663 return;
9664
9665+ ply_trace ("starting animation");
9666+
9667 node = ply_list_get_first_node (plugin->views);
9668 while (node != NULL)
9669 {
9670@@ -542,6 +550,9 @@ stop_animation (ply_boot_splash_plugin_t *plugin,
9671 if (!plugin->is_animating)
9672 return;
9673
9674+ ply_trace ("stopping animation%s",
9675+ trigger != NULL? " with trigger" : "");
9676+
9677 plugin->is_animating = false;
9678
9679 node = ply_list_get_first_node (plugin->views);
9680@@ -619,6 +630,7 @@ add_pixel_display (ply_boot_splash_plugin_t *plugin,
9681 {
9682 view_t *view;
9683
9684+ ply_trace ("adding pixel display to plugin");
9685 view = view_new (plugin, display);
9686
9687 ply_pixel_display_set_draw_handler (view->display,
9688@@ -634,6 +646,7 @@ remove_pixel_display (ply_boot_splash_plugin_t *plugin,
9689 {
9690 ply_list_node_t *node;
9691
9692+ ply_trace ("removing pixel display from plugin");
9693 node = ply_list_get_first_node (plugin->views);
9694 while (node != NULL)
9695 {
9696@@ -745,6 +758,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
9697 {
9698 assert (plugin != NULL);
9699
9700+ ply_trace ("hiding splash");
9701 if (plugin->loop != NULL)
9702 {
9703 stop_animation (plugin, NULL);
9704@@ -765,6 +779,7 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
9705 {
9706 ply_list_node_t *node;
9707
9708+ ply_trace ("showing password prompt");
9709 node = ply_list_get_first_node (plugin->views);
9710 while (node != NULL)
9711 {
9712@@ -788,6 +803,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
9713 {
9714 ply_list_node_t *node;
9715
9716+ ply_trace ("showing prompt");
9717 node = ply_list_get_first_node (plugin->views);
9718 while (node != NULL)
9719 {
9720@@ -807,6 +823,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
9721 static void
9722 on_root_mounted (ply_boot_splash_plugin_t *plugin)
9723 {
9724+ ply_trace ("root filesystem mounted");
9725 plugin->root_is_mounted = true;
9726 }
9727
9728@@ -814,8 +831,10 @@ static void
9729 become_idle (ply_boot_splash_plugin_t *plugin,
9730 ply_trigger_t *idle_trigger)
9731 {
9732+ ply_trace ("deactivation requested");
9733 if (plugin->is_idle)
9734 {
9735+ ply_trace ("plugin is already idle");
9736 ply_trigger_pull (idle_trigger, NULL);
9737 return;
9738 }
9739@@ -829,6 +848,7 @@ hide_prompt (ply_boot_splash_plugin_t *plugin)
9740 {
9741 ply_list_node_t *node;
9742
9743+ ply_trace ("hiding prompt");
9744 node = ply_list_get_first_node (plugin->views);
9745 while (node != NULL)
9746 {
9747@@ -844,6 +864,7 @@ hide_prompt (ply_boot_splash_plugin_t *plugin)
9748 }
9749 }
9750
9751+
9752 static void
9753 show_message (ply_boot_splash_plugin_t *plugin,
9754 const char *message)
9755diff --git a/src/plugins/splash/tribar/Makefile.am b/src/plugins/splash/tribar/Makefile.am
9756new file mode 100644
9757index 0000000..9b11502
9758--- /dev/null
9759+++ b/src/plugins/splash/tribar/Makefile.am
9760@@ -0,0 +1,23 @@
9761+AM_CPPFLAGS = -I$(top_srcdir) \
9762+ -I$(srcdir)/../../../libply \
9763+ -I$(srcdir)/../../../libply-splash-core \
9764+ -I$(srcdir)/../../.. \
9765+ -I$(srcdir)/../.. \
9766+ -I$(srcdir)/.. \
9767+ -I$(srcdir)
9768+
9769+plugindir = $(libdir)/plymouth
9770+plugin_LTLIBRARIES = tribar.la
9771+
9772+tribar_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
9773+ -DPLYMOUTH_BACKGROUND_COLOR=$(background_color) \
9774+ -DPLYMOUTH_BACKGROUND_END_COLOR=$(background_end_color) \
9775+ -DPLYMOUTH_BACKGROUND_START_COLOR=$(background_start_color)
9776+
9777+tribar_la_LDFLAGS = -module -avoid-version -export-dynamic
9778+tribar_la_LIBADD = $(PLYMOUTH_LIBS) \
9779+ ../../../libply/libply.la \
9780+ ../../../libply-splash-core/libply-splash-core.la
9781+tribar_la_SOURCES = $(srcdir)/plugin.c
9782+
9783+MAINTAINERCLEANFILES = Makefile.in
9784diff --git a/src/plugins/splash/tribar/plugin.c b/src/plugins/splash/tribar/plugin.c
9785new file mode 100644
9786index 0000000..4458bad
9787--- /dev/null
9788+++ b/src/plugins/splash/tribar/plugin.c
9789@@ -0,0 +1,740 @@
9790+/*
9791+ *
9792+ * Copyright (C) 2008 Red Hat, Inc.
9793+ *
9794+ * This program is free software; you can redistribute it and/or modify
9795+ * it under the terms of the GNU General Public License as published by
9796+ * the Free Software Foundation; either version 2, or (at your option)
9797+ * any later version.
9798+ *
9799+ * This program is distributed in the hope that it will be useful,
9800+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9801+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9802+ * GNU General Public License for more details.
9803+ *
9804+ * You should have received a copy of the GNU General Public License
9805+ * along with this program; if not, write to the Free Software
9806+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
9807+ * 02111-1307, USA.
9808+ *
9809+ * Written by: Adam Jackson <ajax@redhat.com>
9810+ * Ray Strode <rstrode@redhat.com>
9811+ */
9812+#include "config.h"
9813+
9814+#include <assert.h>
9815+#include <errno.h>
9816+#include <fcntl.h>
9817+#include <math.h>
9818+#include <signal.h>
9819+#include <stdbool.h>
9820+#include <stdio.h>
9821+#include <stdint.h>
9822+#include <stdlib.h>
9823+#include <string.h>
9824+#include <sys/ioctl.h>
9825+#include <sys/stat.h>
9826+#include <sys/time.h>
9827+#include <sys/types.h>
9828+#include <termios.h>
9829+#include <unistd.h>
9830+#include <values.h>
9831+#include <wchar.h>
9832+
9833+#include "ply-trigger.h"
9834+#include "ply-boot-splash-plugin.h"
9835+#include "ply-buffer.h"
9836+#include "ply-event-loop.h"
9837+#include "ply-key-file.h"
9838+#include "ply-list.h"
9839+#include "ply-logger.h"
9840+#include "ply-text-display.h"
9841+#include "ply-text-progress-bar.h"
9842+#include "ply-utils.h"
9843+
9844+#include <linux/kd.h>
9845+
9846+typedef enum {
9847+ PLY_BOOT_SPLASH_DISPLAY_NORMAL,
9848+ PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY,
9849+ PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY
9850+} ply_boot_splash_display_type_t;
9851+
9852+struct _ply_boot_splash_plugin
9853+{
9854+ ply_event_loop_t *loop;
9855+ ply_boot_splash_mode_t mode;
9856+
9857+ ply_list_t *views;
9858+
9859+ ply_boot_splash_display_type_t state;
9860+
9861+ char *message;
9862+
9863+ uint32_t is_animating : 1;
9864+};
9865+
9866+typedef struct
9867+{
9868+ ply_boot_splash_plugin_t *plugin;
9869+ ply_text_display_t *display;
9870+ ply_text_progress_bar_t *progress_bar;
9871+
9872+} view_t;
9873+
9874+ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
9875+
9876+static void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
9877+ ply_event_loop_t *loop);
9878+
9879+static view_t *
9880+view_new (ply_boot_splash_plugin_t *plugin,
9881+ ply_text_display_t *display)
9882+{
9883+ view_t *view;
9884+
9885+ view = calloc (1, sizeof (view_t));
9886+ view->plugin = plugin;
9887+ view->display = display;
9888+
9889+ view->progress_bar = ply_text_progress_bar_new ();
9890+
9891+ return view;
9892+}
9893+
9894+static void
9895+view_free (view_t *view)
9896+{
9897+ ply_text_progress_bar_free (view->progress_bar);
9898+
9899+ free (view);
9900+}
9901+
9902+static void
9903+view_show_message (view_t *view)
9904+{
9905+ ply_boot_splash_plugin_t *plugin;
9906+ int display_width, display_height;
9907+
9908+ plugin = view->plugin;
9909+
9910+ display_width = ply_text_display_get_number_of_columns (view->display);
9911+ display_height = ply_text_display_get_number_of_rows (view->display);
9912+
9913+ ply_text_display_set_cursor_position (view->display, 0,
9914+ display_height / 2);
9915+ ply_text_display_clear_line (view->display);
9916+ ply_text_display_set_cursor_position (view->display,
9917+ (display_width -
9918+ strlen (plugin->message)) / 2,
9919+ display_height / 2);
9920+
9921+ ply_text_display_write (view->display, "%s", plugin->message);
9922+}
9923+
9924+static void
9925+view_show_prompt (view_t *view,
9926+ const char *prompt,
9927+ const char *entered_text)
9928+{
9929+
9930+ int display_width, display_height;
9931+ int i;
9932+
9933+ display_width = ply_text_display_get_number_of_columns (view->display);
9934+ display_height = ply_text_display_get_number_of_rows (view->display);
9935+ ply_text_display_set_background_color (view->display, PLY_TERMINAL_COLOR_DEFAULT);
9936+ ply_text_display_clear_screen (view->display);
9937+
9938+ ply_text_display_set_cursor_position (view->display, 0, display_height / 2);
9939+
9940+ for (i=0; i < display_width; i++)
9941+ ply_text_display_write (view->display, "%c", ' ');
9942+
9943+ ply_text_display_set_cursor_position (view->display,
9944+ display_width / 2 - (strlen (prompt)),
9945+ display_height / 2);
9946+
9947+ ply_text_display_write (view->display, "%s:%s", prompt, entered_text);
9948+
9949+ ply_text_display_show_cursor (view->display);
9950+}
9951+
9952+static void
9953+view_start_animation (view_t *view)
9954+{
9955+ ply_boot_splash_plugin_t *plugin;
9956+ ply_terminal_t *terminal;
9957+
9958+ assert (view != NULL);
9959+
9960+ plugin = view->plugin;
9961+
9962+ terminal = ply_text_display_get_terminal (view->display);
9963+
9964+ ply_terminal_set_color_hex_value (terminal,
9965+ PLY_TERMINAL_COLOR_BLACK,
9966+ 0x000000);
9967+ ply_terminal_set_color_hex_value (terminal,
9968+ PLY_TERMINAL_COLOR_WHITE,
9969+ 0xffffff);
9970+ ply_terminal_set_color_hex_value (terminal,
9971+ PLY_TERMINAL_COLOR_BLUE,
9972+ 0x0073B3);
9973+ ply_terminal_set_color_hex_value (terminal,
9974+ PLY_TERMINAL_COLOR_BROWN,
9975+ 0x00457E);
9976+
9977+ ply_text_display_set_background_color (view->display,
9978+ PLY_TERMINAL_COLOR_BLACK);
9979+ ply_text_display_clear_screen (view->display);
9980+ ply_text_display_hide_cursor (view->display);
9981+
9982+ if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
9983+ {
9984+ ply_text_progress_bar_hide (view->progress_bar);
9985+ return;
9986+ }
9987+
9988+ ply_text_progress_bar_show (view->progress_bar,
9989+ view->display);
9990+}
9991+
9992+static void
9993+view_redraw (view_t *view)
9994+{
9995+ unsigned long screen_width, screen_height;
9996+
9997+ screen_width = ply_text_display_get_number_of_columns (view->display);
9998+ screen_height = ply_text_display_get_number_of_rows (view->display);
9999+
10000+ ply_text_display_draw_area (view->display, 0, 0,
10001+ screen_width, screen_height);
10002+}
10003+
10004+static void
10005+redraw_views (ply_boot_splash_plugin_t *plugin)
10006+{
10007+ ply_list_node_t *node;
10008+
10009+ node = ply_list_get_first_node (plugin->views);
10010+ while (node != NULL)
10011+ {
10012+ ply_list_node_t *next_node;
10013+ view_t *view;
10014+
10015+ view = ply_list_node_get_data (node);
10016+ next_node = ply_list_get_next_node (plugin->views, node);
10017+
10018+ view_redraw (view);
10019+
10020+ node = next_node;
10021+ }
10022+}
10023+
10024+static void
10025+view_hide (view_t *view)
10026+{
10027+ if (view->display != NULL)
10028+ {
10029+ ply_terminal_t *terminal;
10030+
10031+ terminal = ply_text_display_get_terminal (view->display);
10032+
10033+ ply_text_display_set_background_color (view->display, PLY_TERMINAL_COLOR_DEFAULT);
10034+ ply_text_display_clear_screen (view->display);
10035+ ply_text_display_show_cursor (view->display);
10036+
10037+ ply_terminal_reset_colors (terminal);
10038+ }
10039+}
10040+
10041+static void
10042+hide_views (ply_boot_splash_plugin_t *plugin)
10043+{
10044+ ply_list_node_t *node;
10045+
10046+ node = ply_list_get_first_node (plugin->views);
10047+ while (node != NULL)
10048+ {
10049+ ply_list_node_t *next_node;
10050+ view_t *view;
10051+
10052+ view = ply_list_node_get_data (node);
10053+ next_node = ply_list_get_next_node (plugin->views, node);
10054+
10055+ view_hide (view);
10056+
10057+ node = next_node;
10058+ }
10059+}
10060+
10061+static void
10062+pause_views (ply_boot_splash_plugin_t *plugin)
10063+{
10064+ ply_list_node_t *node;
10065+
10066+ node = ply_list_get_first_node (plugin->views);
10067+ while (node != NULL)
10068+ {
10069+ ply_list_node_t *next_node;
10070+ view_t *view;
10071+
10072+ view = ply_list_node_get_data (node);
10073+ next_node = ply_list_get_next_node (plugin->views, node);
10074+
10075+ ply_text_display_pause_updates (view->display);
10076+
10077+ node = next_node;
10078+ }
10079+}
10080+
10081+static void
10082+unpause_views (ply_boot_splash_plugin_t *plugin)
10083+{
10084+ ply_list_node_t *node;
10085+
10086+ node = ply_list_get_first_node (plugin->views);
10087+ while (node != NULL)
10088+ {
10089+ ply_list_node_t *next_node;
10090+ view_t *view;
10091+
10092+ view = ply_list_node_get_data (node);
10093+ next_node = ply_list_get_next_node (plugin->views, node);
10094+
10095+ ply_text_display_unpause_updates (view->display);
10096+
10097+ node = next_node;
10098+ }
10099+}
10100+
10101+static ply_boot_splash_plugin_t *
10102+create_plugin (ply_key_file_t *key_file)
10103+{
10104+ ply_boot_splash_plugin_t *plugin;
10105+
10106+ ply_trace ("creating plugin");
10107+
10108+ plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
10109+ plugin->message = NULL;
10110+
10111+ plugin->views = ply_list_new ();
10112+
10113+ return plugin;
10114+}
10115+
10116+static void
10117+detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
10118+{
10119+ plugin->loop = NULL;
10120+
10121+ ply_trace ("detaching from event loop");
10122+}
10123+
10124+static void
10125+free_views (ply_boot_splash_plugin_t *plugin)
10126+{
10127+ ply_list_node_t *node;
10128+
10129+ node = ply_list_get_first_node (plugin->views);
10130+
10131+ while (node != NULL)
10132+ {
10133+ ply_list_node_t *next_node;
10134+ view_t *view;
10135+
10136+ view = ply_list_node_get_data (node);
10137+ next_node = ply_list_get_next_node (plugin->views, node);
10138+
10139+ view_free (view);
10140+ ply_list_remove_node (plugin->views, node);
10141+
10142+ node = next_node;
10143+ }
10144+
10145+ ply_list_free (plugin->views);
10146+ plugin->views = NULL;
10147+}
10148+
10149+static void
10150+destroy_plugin (ply_boot_splash_plugin_t *plugin)
10151+{
10152+ ply_trace ("destroying plugin");
10153+
10154+ if (plugin == NULL)
10155+ return;
10156+
10157+ /* It doesn't ever make sense to keep this plugin on screen
10158+ * after exit
10159+ */
10160+ hide_splash_screen (plugin, plugin->loop);
10161+
10162+ free_views (plugin);
10163+ if (plugin->message != NULL)
10164+ free (plugin->message);
10165+
10166+ free (plugin);
10167+}
10168+
10169+static void
10170+show_message (ply_boot_splash_plugin_t *plugin)
10171+{
10172+ ply_list_node_t *node;
10173+
10174+ node = ply_list_get_first_node (plugin->views);
10175+ while (node != NULL)
10176+ {
10177+ ply_list_node_t *next_node;
10178+ view_t *view;
10179+
10180+ view = ply_list_node_get_data (node);
10181+ next_node = ply_list_get_next_node (plugin->views, node);
10182+
10183+ view_show_message (view);
10184+
10185+ node = next_node;
10186+ }
10187+}
10188+
10189+static void
10190+start_animation (ply_boot_splash_plugin_t *plugin)
10191+{
10192+ ply_list_node_t *node;
10193+
10194+ assert (plugin != NULL);
10195+ assert (plugin->loop != NULL);
10196+
10197+ redraw_views (plugin);
10198+
10199+ if (plugin->message != NULL)
10200+ show_message (plugin);
10201+
10202+ if (plugin->is_animating)
10203+ return;
10204+
10205+ node = ply_list_get_first_node (plugin->views);
10206+ while (node != NULL)
10207+ {
10208+ ply_list_node_t *next_node;
10209+ view_t *view;
10210+
10211+ view = ply_list_node_get_data (node);
10212+ next_node = ply_list_get_next_node (plugin->views, node);
10213+
10214+ view_start_animation (view);
10215+
10216+ node = next_node;
10217+ }
10218+
10219+ plugin->is_animating = true;
10220+}
10221+
10222+static void
10223+stop_animation (ply_boot_splash_plugin_t *plugin)
10224+{
10225+ ply_list_node_t *node;
10226+
10227+ assert (plugin != NULL);
10228+ assert (plugin->loop != NULL);
10229+
10230+ if (!plugin->is_animating)
10231+ return;
10232+
10233+ plugin->is_animating = false;
10234+
10235+ node = ply_list_get_first_node (plugin->views);
10236+ while (node != NULL)
10237+ {
10238+ ply_list_node_t *next_node;
10239+ view_t *view;
10240+
10241+ view = ply_list_node_get_data (node);
10242+ next_node = ply_list_get_next_node (plugin->views, node);
10243+
10244+ ply_text_progress_bar_hide (view->progress_bar);
10245+
10246+ node = next_node;
10247+ }
10248+ redraw_views (plugin);
10249+}
10250+
10251+static void
10252+on_draw (view_t *view,
10253+ ply_terminal_t *terminal,
10254+ int x,
10255+ int y,
10256+ int width,
10257+ int height)
10258+{
10259+ ply_text_display_clear_screen (view->display);
10260+}
10261+
10262+static void
10263+add_text_display (ply_boot_splash_plugin_t *plugin,
10264+ ply_text_display_t *display)
10265+{
10266+ view_t *view;
10267+ ply_terminal_t *terminal;
10268+
10269+ view = view_new (plugin, display);
10270+
10271+ terminal = ply_text_display_get_terminal (view->display);
10272+ if (ply_terminal_open (terminal))
10273+ ply_terminal_activate_vt (terminal);
10274+
10275+ ply_text_display_set_draw_handler (view->display,
10276+ (ply_text_display_draw_handler_t)
10277+ on_draw, view);
10278+
10279+ ply_list_append_data (plugin->views, view);
10280+}
10281+
10282+static void
10283+remove_text_display (ply_boot_splash_plugin_t *plugin,
10284+ ply_text_display_t *display)
10285+{
10286+ ply_list_node_t *node;
10287+
10288+ node = ply_list_get_first_node (plugin->views);
10289+ while (node != NULL)
10290+ {
10291+ view_t *view;
10292+ ply_list_node_t *next_node;
10293+
10294+ view = ply_list_node_get_data (node);
10295+ next_node = ply_list_get_next_node (plugin->views, node);
10296+
10297+ if (view->display == display)
10298+ {
10299+ ply_text_display_set_draw_handler (view->display,
10300+ NULL, NULL);
10301+ view_free (view);
10302+ ply_list_remove_node (plugin->views, node);
10303+ return;
10304+ }
10305+
10306+ node = next_node;
10307+ }
10308+}
10309+
10310+static bool
10311+show_splash_screen (ply_boot_splash_plugin_t *plugin,
10312+ ply_event_loop_t *loop,
10313+ ply_buffer_t *boot_buffer,
10314+ ply_boot_splash_mode_t mode)
10315+{
10316+ assert (plugin != NULL);
10317+
10318+ plugin->loop = loop;
10319+ plugin->mode = mode;
10320+ ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
10321+ detach_from_event_loop,
10322+ plugin);
10323+
10324+ ply_show_new_kernel_messages (false);
10325+ start_animation (plugin);
10326+
10327+ return true;
10328+}
10329+
10330+static void
10331+update_status (ply_boot_splash_plugin_t *plugin,
10332+ const char *status)
10333+{
10334+ assert (plugin != NULL);
10335+
10336+ ply_trace ("status update");
10337+}
10338+
10339+static void
10340+on_boot_progress (ply_boot_splash_plugin_t *plugin,
10341+ double duration,
10342+ double percent_done)
10343+{
10344+ ply_list_node_t *node;
10345+ double total_duration;
10346+
10347+ total_duration = duration / percent_done;
10348+
10349+ /* Fun made-up smoothing function to make the growth asymptotic:
10350+ * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */
10351+ percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done);
10352+
10353+ node = ply_list_get_first_node (plugin->views);
10354+
10355+ while (node != NULL)
10356+ {
10357+ ply_list_node_t *next_node;
10358+ view_t *view;
10359+
10360+ view = ply_list_node_get_data (node);
10361+ next_node = ply_list_get_next_node (plugin->views, node);
10362+
10363+ ply_text_progress_bar_set_percent_done (view->progress_bar, percent_done);
10364+ ply_text_progress_bar_draw (view->progress_bar);
10365+
10366+ node = next_node;
10367+ }
10368+}
10369+
10370+static void
10371+hide_splash_screen (ply_boot_splash_plugin_t *plugin,
10372+ ply_event_loop_t *loop)
10373+{
10374+ assert (plugin != NULL);
10375+
10376+ ply_trace ("hiding splash screen");
10377+
10378+ if (plugin->loop != NULL)
10379+ {
10380+ stop_animation (plugin);
10381+
10382+ ply_event_loop_stop_watching_for_exit (plugin->loop,
10383+ (ply_event_loop_exit_handler_t)
10384+ detach_from_event_loop,
10385+ plugin);
10386+ detach_from_event_loop (plugin);
10387+ }
10388+
10389+ hide_views (plugin);
10390+ ply_show_new_kernel_messages (true);
10391+}
10392+
10393+static void
10394+display_normal (ply_boot_splash_plugin_t *plugin)
10395+{
10396+ pause_views (plugin);
10397+ if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10398+ {
10399+ plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
10400+ start_animation (plugin);
10401+ redraw_views (plugin);
10402+ }
10403+ unpause_views (plugin);
10404+}
10405+
10406+static void
10407+display_message (ply_boot_splash_plugin_t *plugin,
10408+ const char *message)
10409+{
10410+ if (plugin->message != NULL)
10411+ free (plugin->message);
10412+
10413+ plugin->message = strdup (message);
10414+ start_animation (plugin);
10415+}
10416+
10417+static void
10418+show_password_prompt (ply_boot_splash_plugin_t *plugin,
10419+ const char *prompt,
10420+ int bullets)
10421+{
10422+ ply_list_node_t *node;
10423+ int i;
10424+ char *entered_text;
10425+
10426+ entered_text = calloc (bullets + 1, sizeof (char));
10427+
10428+ for (i = 0; i < bullets; i++)
10429+ entered_text[i] = '*';
10430+
10431+ node = ply_list_get_first_node (plugin->views);
10432+ while (node != NULL)
10433+ {
10434+ ply_list_node_t *next_node;
10435+ view_t *view;
10436+
10437+ view = ply_list_node_get_data (node);
10438+ next_node = ply_list_get_next_node (plugin->views, node);
10439+
10440+ view_show_prompt (view, prompt, entered_text);
10441+
10442+ node = next_node;
10443+ }
10444+ free (entered_text);
10445+}
10446+
10447+static void
10448+show_prompt (ply_boot_splash_plugin_t *plugin,
10449+ const char *prompt,
10450+ const char *text)
10451+{
10452+ ply_list_node_t *node;
10453+
10454+ node = ply_list_get_first_node (plugin->views);
10455+ while (node != NULL)
10456+ {
10457+ ply_list_node_t *next_node;
10458+ view_t *view;
10459+
10460+ view = ply_list_node_get_data (node);
10461+ next_node = ply_list_get_next_node (plugin->views, node);
10462+
10463+ view_show_prompt (view, prompt, text);
10464+
10465+ node = next_node;
10466+ }
10467+}
10468+
10469+static void
10470+display_password (ply_boot_splash_plugin_t *plugin,
10471+ const char *prompt,
10472+ int bullets)
10473+{
10474+ pause_views (plugin);
10475+ if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10476+ stop_animation (plugin);
10477+
10478+ plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
10479+
10480+ if (!prompt)
10481+ prompt = "Password";
10482+
10483+ show_password_prompt (plugin, prompt, bullets);
10484+
10485+ unpause_views (plugin);
10486+}
10487+
10488+static void
10489+display_question (ply_boot_splash_plugin_t *plugin,
10490+ const char *prompt,
10491+ const char *entry_text)
10492+{
10493+ pause_views (plugin);
10494+ if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10495+ stop_animation (plugin);
10496+
10497+ plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
10498+
10499+ if (!prompt)
10500+ prompt = "Password";
10501+
10502+ show_prompt (plugin, prompt, entry_text);
10503+
10504+ unpause_views (plugin);
10505+}
10506+
10507+ply_boot_splash_plugin_interface_t *
10508+ply_boot_splash_plugin_get_interface (void)
10509+{
10510+ static ply_boot_splash_plugin_interface_t plugin_interface =
10511+ {
10512+ .create_plugin = create_plugin,
10513+ .destroy_plugin = destroy_plugin,
10514+ .add_text_display = add_text_display,
10515+ .remove_text_display = remove_text_display,
10516+ .show_splash_screen = show_splash_screen,
10517+ .update_status = update_status,
10518+ .on_boot_progress = on_boot_progress,
10519+ .hide_splash_screen = hide_splash_screen,
10520+ .display_normal = display_normal,
10521+ .display_message = display_message,
10522+ .display_password = display_password,
10523+ .display_question = display_question,
10524+ };
10525+
10526+ return &plugin_interface;
10527+}
10528+
10529+/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
10530diff --git a/src/plugins/splash/two-step/Makefile.am b/src/plugins/splash/two-step/Makefile.am
10531index 7310d6c..f3a6aaa 100644
10532--- a/src/plugins/splash/two-step/Makefile.am
10533+++ b/src/plugins/splash/two-step/Makefile.am
10534@@ -1,4 +1,4 @@
10535-INCLUDES = -I$(top_srcdir) \
10536+AM_CPPFLAGS = -I$(top_srcdir) \
10537 -I$(srcdir)/../../../libply \
10538 -I$(srcdir)/../../../libply-splash-core \
10539 -I$(srcdir)/../../../libply-splash-graphics \
10540diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c
10541index 2998beb..f48b41e 100644
10542--- a/src/plugins/splash/two-step/plugin.c
10543+++ b/src/plugins/splash/two-step/plugin.c
10544@@ -89,8 +89,9 @@ typedef struct
10545 ply_throbber_t *throbber;
10546 ply_label_t *label;
10547 ply_label_t *message_label;
10548- ply_rectangle_t box_area, lock_area;
10549+ ply_rectangle_t box_area, lock_area, watermark_area;
10550 ply_trigger_t *end_trigger;
10551+ ply_image_t *background_image;
10552 } view_t;
10553
10554 struct _ply_boot_splash_plugin
10555@@ -101,10 +102,15 @@ struct _ply_boot_splash_plugin
10556 ply_image_t *box_image;
10557 ply_image_t *corner_image;
10558 ply_image_t *header_image;
10559+ ply_image_t *background_tile_image;
10560+ ply_image_t *watermark_image;
10561 ply_list_t *views;
10562
10563 ply_boot_splash_display_type_t state;
10564
10565+ double watermark_horizontal_alignment;
10566+ double watermark_vertical_alignment;
10567+
10568 double animation_horizontal_alignment;
10569 double animation_vertical_alignment;
10570 char *animation_dir;
10571@@ -176,12 +182,37 @@ view_free (view_t *view)
10572 ply_label_free (view->label);
10573 ply_label_free (view->message_label);
10574
10575+ if (view->background_image != NULL)
10576+ ply_image_free (view->background_image);
10577+
10578 free (view);
10579 }
10580
10581 static bool
10582 view_load (view_t *view)
10583 {
10584+ unsigned long screen_width, screen_height;
10585+ ply_boot_splash_plugin_t *plugin;
10586+
10587+ plugin = view->plugin;
10588+
10589+ screen_width = ply_pixel_display_get_width (view->display);
10590+ screen_height = ply_pixel_display_get_height (view->display);
10591+
10592+ if (plugin->background_tile_image != NULL)
10593+ {
10594+ ply_trace ("tiling background to %lux%lu", screen_width, screen_height);
10595+ view->background_image = ply_image_tile (plugin->background_tile_image, screen_width, screen_height);
10596+ }
10597+
10598+ if (plugin->watermark_image != NULL)
10599+ {
10600+ view->watermark_area.width = ply_image_get_width (plugin->watermark_image);
10601+ view->watermark_area.height = ply_image_get_height (plugin->watermark_image);
10602+ view->watermark_area.x = screen_width * plugin->watermark_horizontal_alignment - ply_image_get_width (plugin->watermark_image) * plugin->watermark_horizontal_alignment;
10603+ view->watermark_area.y = screen_height * plugin->watermark_vertical_alignment - ply_image_get_height (plugin->watermark_image) * plugin->watermark_vertical_alignment;
10604+ }
10605+
10606 ply_trace ("loading entry");
10607 if (!ply_entry_load (view->entry))
10608 return false;
10609@@ -519,6 +550,14 @@ create_plugin (ply_key_file_t *key_file)
10610 plugin->header_image = ply_image_new (image_path);
10611 free (image_path);
10612
10613+ asprintf (&image_path, "%s/background-tile.png", image_dir);
10614+ plugin->background_tile_image = ply_image_new (image_path);
10615+ free (image_path);
10616+
10617+ asprintf (&image_path, "%s/watermark.png", image_dir);
10618+ plugin->watermark_image = ply_image_new (image_path);
10619+ free (image_path);
10620+
10621 plugin->animation_dir = image_dir;
10622
10623 alignment = ply_key_file_get_value (key_file, "two-step", "HorizontalAlignment");
10624@@ -535,6 +574,20 @@ create_plugin (ply_key_file_t *key_file)
10625 plugin->animation_vertical_alignment = .5;
10626 free (alignment);
10627
10628+ alignment = ply_key_file_get_value (key_file, "two-step", "WatermarkHorizontalAlignment");
10629+ if (alignment != NULL)
10630+ plugin->watermark_horizontal_alignment = strtod (alignment, NULL);
10631+ else
10632+ plugin->watermark_horizontal_alignment = 1.0;
10633+ free (alignment);
10634+
10635+ alignment = ply_key_file_get_value (key_file, "two-step", "WatermarkVerticalAlignment");
10636+ if (alignment != NULL)
10637+ plugin->watermark_vertical_alignment = strtod (alignment, NULL);
10638+ else
10639+ plugin->watermark_vertical_alignment = .5;
10640+ free (alignment);
10641+
10642 plugin->transition = PLY_PROGRESS_ANIMATION_TRANSITION_NONE;
10643 transition = ply_key_file_get_value (key_file, "two-step", "Transition");
10644 if (transition != NULL)
10645@@ -653,6 +706,12 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
10646 if (plugin->header_image != NULL)
10647 ply_image_free (plugin->header_image);
10648
10649+ if (plugin->background_tile_image != NULL)
10650+ ply_image_free (plugin->background_tile_image);
10651+
10652+ if (plugin->watermark_image != NULL)
10653+ ply_image_free (plugin->watermark_image);
10654+
10655 free (plugin->animation_dir);
10656 free_views (plugin);
10657 free (plugin);
10658@@ -813,6 +872,21 @@ draw_background (view_t *view,
10659 else
10660 ply_pixel_buffer_fill_with_hex_color (pixel_buffer, &area,
10661 plugin->background_start_color);
10662+
10663+ if (view->background_image != NULL)
10664+ {
10665+ uint32_t *data;
10666+ data = ply_image_get_data (view->background_image);
10667+ ply_pixel_buffer_fill_with_argb32_data (pixel_buffer, &area, data);
10668+ }
10669+
10670+ if (plugin->watermark_image != NULL)
10671+ {
10672+ uint32_t *data;
10673+
10674+ data = ply_image_get_data (plugin->watermark_image);
10675+ ply_pixel_buffer_fill_with_argb32_data (pixel_buffer, &view->watermark_area, data);
10676+ }
10677 }
10678
10679 static void
10680@@ -997,6 +1071,26 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
10681 }
10682 }
10683
10684+ if (plugin->background_tile_image != NULL)
10685+ {
10686+ ply_trace ("loading background tile image");
10687+ if (!ply_image_load (plugin->background_tile_image))
10688+ {
10689+ ply_image_free (plugin->background_tile_image);
10690+ plugin->background_tile_image = NULL;
10691+ }
10692+ }
10693+
10694+ if (plugin->watermark_image != NULL)
10695+ {
10696+ ply_trace ("loading watermark image");
10697+ if (!ply_image_load (plugin->watermark_image))
10698+ {
10699+ ply_image_free (plugin->watermark_image);
10700+ plugin->watermark_image = NULL;
10701+ }
10702+ }
10703+
10704 if (!load_views (plugin))
10705 {
10706 ply_trace ("couldn't load views");
10707@@ -1067,6 +1161,9 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
10708 if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10709 return;
10710
10711+ if (plugin->is_idle)
10712+ return;
10713+
10714 if (percent_done >= SHOW_ANIMATION_PERCENT)
10715 {
10716 if (plugin->stop_trigger == NULL)
10717diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c
10718index f15ade7..3e67bfb 100644
10719--- a/src/ply-boot-server.c
10720+++ b/src/ply-boot-server.c
10721@@ -776,7 +776,7 @@ ply_boot_server_on_new_connection (ply_boot_server_t *server)
10722
10723 assert (server != NULL);
10724
10725- fd = accept (server->socket_fd, NULL, NULL);
10726+ fd = accept4 (server->socket_fd, NULL, NULL, SOCK_CLOEXEC);
10727
10728 if (fd < 0)
10729 return;
10730@@ -831,183 +831,4 @@ ply_boot_server_attach_to_event_loop (ply_boot_server_t *server,
10731 server);
10732 }
10733
10734-#ifdef PLY_BOOT_SERVER_ENABLE_TEST
10735-
10736-#include <stdio.h>
10737-
10738-#include "ply-event-loop.h"
10739-#include "ply-boot-server.h"
10740-
10741-static void
10742-on_update (ply_event_loop_t *loop,
10743- const char *status)
10744-{
10745- printf ("new status is '%s'\n", status);
10746-}
10747-
10748-static void
10749-on_newroot (ply_event_loop_t *loop)
10750-{
10751- printf ("got newroot request\n");
10752-}
10753-
10754-static void
10755-on_system_initialized (ply_event_loop_t *loop)
10756-{
10757- printf ("got sysinit done request\n");
10758-}
10759-
10760-static void
10761-on_show_splash (ply_event_loop_t *loop)
10762-{
10763- printf ("got show splash request\n");
10764-}
10765-
10766-static void
10767-on_hide_splash (ply_event_loop_t *loop)
10768-{
10769- printf ("got hide splash request\n");
10770-}
10771-
10772-static void
10773-on_deactivate (ply_event_loop_t *loop)
10774-{
10775- printf ("got deactivate request\n");
10776-}
10777-
10778-static void
10779-on_reactivate (ply_event_loop_t *loop)
10780-{
10781- printf ("got reactivate request\n");
10782-}
10783-
10784-static void
10785-on_quit (ply_event_loop_t *loop)
10786-{
10787- printf ("got quit request, quiting...\n");
10788- ply_event_loop_exit (loop, 0);
10789-}
10790-
10791-static void
10792-on_error (ply_event_loop_t *loop)
10793-{
10794- printf ("got error starting service\n");
10795-}
10796-
10797-static char *
10798-on_ask_for_password (ply_event_loop_t *loop)
10799-{
10800- printf ("got password request, returning 'password'...\n");
10801-
10802- return strdup ("password");
10803-}
10804-
10805-static void
10806-on_ask_question (ply_event_loop_t *loop)
10807-{
10808- printf ("got question request\n");
10809- return;
10810-}
10811-
10812-static void
10813-on_display_message (ply_event_loop_t *loop)
10814-{
10815- printf ("got display message request\n");
10816- return;
10817-}
10818-
10819-static void
10820-on_hide_message (ply_event_loop_t *loop)
10821-{
10822- printf ("got hide message request\n");
10823- return;
10824-}
10825-
10826-static void
10827-on_watch_for_keystroke (ply_event_loop_t *loop)
10828-{
10829- printf ("got keystroke request\n");
10830-
10831- return;
10832-}
10833-
10834-static void
10835-on_progress_pause (ply_event_loop_t *loop)
10836-{
10837- printf ("got progress pause request\n");
10838-
10839- return;
10840-}
10841-
10842-static void
10843-on_progress_unpause (ply_event_loop_t *loop)
10844-{
10845- printf ("got progress unpause request\n");
10846-
10847- return;
10848-}
10849-
10850-static void
10851-on_ignore_keystroke (ply_event_loop_t *loop)
10852-{
10853- printf ("got keystroke ignore request\n");
10854-
10855- return;
10856-}
10857-
10858-static bool
10859-on_has_active_vt (ply_event_loop_t *loop)
10860-{
10861- printf ("got has_active vt? request\n");
10862- return true;
10863-}
10864-
10865-int
10866-main (int argc,
10867- char **argv)
10868-{
10869- ply_event_loop_t *loop;
10870- ply_boot_server_t *server;
10871- int exit_code;
10872-
10873- exit_code = 0;
10874-
10875- loop = ply_event_loop_new ();
10876-
10877- server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update,
10878- (ply_boot_server_change_mode_handler_t) on_change_mode,
10879- (ply_boot_server_system_update_handler_t) on_system_update,
10880- (ply_boot_server_ask_for_password_handler_t) on_ask_for_password,
10881- (ply_boot_server_ask_question_handler_t) on_ask_question,
10882- (ply_boot_server_display_message_handler_t) on_display_message,
10883- (ply_boot_server_hide_message_handler_t) on_hide_message,
10884- (ply_boot_server_watch_for_keystroke_handler_t) on_watch_for_keystroke,
10885- (ply_boot_server_ignore_keystroke_handler_t) on_ignore_keystroke,
10886- (ply_boot_server_progress_pause_handler_t) on_progress_pause,
10887- (ply_boot_server_progress_unpause_handler_t) on_progress_unpause,
10888- (ply_boot_server_show_splash_handler_t) on_show_splash,
10889- (ply_boot_server_hide_splash_handler_t) on_hide_splash,
10890- (ply_boot_server_newroot_handler_t) on_newroot,
10891- (ply_boot_server_system_initialized_handler_t) on_system_initialized,
10892- (ply_boot_server_error_handler_t) on_error,
10893- (ply_boot_server_deactivate_handler_t) on_deactivate,
10894- (ply_boot_server_reactivate_handler_t) on_reactivate,
10895- (ply_boot_server_quit_handler_t) on_quit,
10896- (ply_boot_server_has_active_vt_handler_t) on_has_active_vt,
10897- loop);
10898-
10899- if (!ply_boot_server_listen (server))
10900- {
10901- perror ("could not start boot status daemon");
10902- return errno;
10903- }
10904-
10905- ply_boot_server_attach_to_event_loop (server, loop);
10906- exit_code = ply_event_loop_run (loop);
10907- ply_boot_server_free (server);
10908-
10909- return exit_code;
10910-}
10911-
10912-#endif /* PLY_BOOT_SERVER_ENABLE_TEST */
10913 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
10914diff --git a/src/plymouthd.defaults b/src/plymouthd.defaults
10915index 46417d6..fc48b15 100644
10916--- a/src/plymouthd.defaults
10917+++ b/src/plymouthd.defaults
10918@@ -2,3 +2,4 @@
10919 # upgrades.
10920 [Daemon]
10921 Theme=spinner
10922+ShowDelay=5
10923diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
10924deleted file mode 100644
10925index 86a8ea6..0000000
10926--- a/src/tests/Makefile.am
10927+++ /dev/null
10928@@ -1,18 +0,0 @@
10929-INCLUDES = \
10930- -I$(top_srcdir) \
10931- -I$(srcdir)/.. \
10932- -I$(srcdir)/../libply \
10933- -I$(srcdir)/../libply-splash-core \
10934- -I$(srcdir)
10935-TESTS =
10936-
10937-if ENABLE_TESTS
10938-include $(srcdir)/ply-boot-server-test.am
10939-include $(srcdir)/ply-boot-splash-test.am
10940-endif
10941-
10942-noinst_PROGRAMS = $(TESTS)
10943-
10944-# our tests aren't unit tests, so clear for now
10945-TESTS =
10946-MAINTAINERCLEANFILES = Makefile.in
10947diff --git a/src/tests/ply-boot-server-test.am b/src/tests/ply-boot-server-test.am
10948deleted file mode 100644
10949index cc28348..0000000
10950--- a/src/tests/ply-boot-server-test.am
10951+++ /dev/null
10952@@ -1,8 +0,0 @@
10953-TESTS += ply-boot-server-test
10954-
10955-ply_boot_server_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SERVER_ENABLE_TEST
10956-ply_boot_server_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
10957-
10958-ply_boot_server_test_SOURCES = \
10959- $(srcdir)/../ply-boot-server.h \
10960- $(srcdir)/../ply-boot-server.c
10961diff --git a/src/tests/ply-boot-splash-test.am b/src/tests/ply-boot-splash-test.am
10962deleted file mode 100644
10963index 9dd1598..0000000
10964--- a/src/tests/ply-boot-splash-test.am
10965+++ /dev/null
10966@@ -1,25 +0,0 @@
10967-TESTS += ply-boot-splash-test
10968-
10969-ply_boot_splash_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SPLASH_ENABLE_TEST \
10970- -DPLYMOUTH_TIME_DIRECTORY=\"/var/lib/plymouth\" \
10971- -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\" \
10972- -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\"
10973-
10974-ply_boot_splash_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
10975-
10976-ply_boot_splash_test_SOURCES = \
10977- $(srcdir)/../libply-splash-core/ply-boot-splash-plugin.h \
10978- $(srcdir)/../libply-splash-core/ply-keyboard.h \
10979- $(srcdir)/../libply-splash-core/ply-keyboard.c \
10980- $(srcdir)/../libply-splash-core/ply-pixel-buffer.h \
10981- $(srcdir)/../libply-splash-core/ply-pixel-buffer.c \
10982- $(srcdir)/../libply-splash-core/ply-pixel-display.h \
10983- $(srcdir)/../libply-splash-core/ply-pixel-display.c \
10984- $(srcdir)/../libply-splash-core/ply-renderer.h \
10985- $(srcdir)/../libply-splash-core/ply-renderer.c \
10986- $(srcdir)/../libply-splash-core/ply-terminal.h \
10987- $(srcdir)/../libply-splash-core/ply-terminal.c \
10988- $(srcdir)/../libply-splash-core/ply-text-display.h \
10989- $(srcdir)/../libply-splash-core/ply-text-display.c \
10990- $(srcdir)/../libply-splash-core/ply-boot-splash.h \
10991- $(srcdir)/../libply-splash-core/ply-boot-splash.c
10992diff --git a/src/upstart-bridge/Makefile.am b/src/upstart-bridge/Makefile.am
10993index 628ef20..a16cd11 100644
10994--- a/src/upstart-bridge/Makefile.am
10995+++ b/src/upstart-bridge/Makefile.am
10996@@ -1,4 +1,4 @@
10997-INCLUDES = -I$(top_srcdir) \
10998+AM_CPPFLAGS = -I$(top_srcdir) \
10999 -I$(top_srcdir)/src \
11000 -I$(top_srcdir)/src/libply \
11001 -I$(top_srcdir)/src/client \
11002diff --git a/src/viewer/Makefile.am b/src/viewer/Makefile.am
11003index 6ade690..0c5c3ec 100644
11004--- a/src/viewer/Makefile.am
11005+++ b/src/viewer/Makefile.am
11006@@ -1,7 +1,7 @@
11007 SUBDIRS = .
11008 EXTRA_DIST=
11009
11010-INCLUDES = -I$(top_srcdir) \
11011+AM_CPPFLAGS = -I$(top_srcdir) \
11012 -I$(srcdir)
11013 if WITH_LOG_VIEWER
11014 plymouth_log_viewerdir = $(bindir)
11015diff --git a/src/viewer/plymouth-log-viewer.c b/src/viewer/plymouth-log-viewer.c
11016index c20e391..ca54e0f 100644
11017--- a/src/viewer/plymouth-log-viewer.c
11018+++ b/src/viewer/plymouth-log-viewer.c
11019@@ -20,6 +20,10 @@
11020 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
11021 */
11022
11023+#ifdef HAVE_CONFIG_H
11024+#include "config.h"
11025+#endif
11026+
11027 #include <stdlib.h>
11028 #include <string.h>
11029 #include <sys/types.h>
11030diff --git a/systemd-units/Makefile.am b/systemd-units/Makefile.am
11031index 3aa44df..89355ac 100644
11032--- a/systemd-units/Makefile.am
11033+++ b/systemd-units/Makefile.am
11034@@ -25,7 +25,8 @@ install-data-hook:
11035 $(DESTDIR)$(SYSTEMD_UNIT_DIR)/poweroff.target.wants \
11036 $(DESTDIR)$(SYSTEMD_UNIT_DIR)/halt.target.wants
11037 (cd $(DESTDIR)$(SYSTEMD_UNIT_DIR)/initrd-switch-root.target.wants && \
11038- rm -f plymouth-switch-root.service && \
11039+ rm -f plymouth-start.service plymouth-switch-root.service && \
11040+ $(LN_S) ../plymouth-start.service && \
11041 $(LN_S) ../plymouth-switch-root.service)
11042 (cd $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysinit.target.wants && \
11043 rm -f plymouth-start.service plymouth-read-write.service && \
11044@@ -51,7 +52,7 @@ install-data-hook:
11045 uninstall-hook:
11046 rm -f \
11047 (cd $(DESTDIR)$(SYSTEMD_UNIT_DIR)/initrd-switch-root.target.wants && \
11048- rm -f plymouth-switch-root.service) \
11049+ rm -f plymouth-start.service plymouth-switch-root.service) \
11050 (cd $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysinit.target.wants && \
11051 rm -f plymouth-start.service plymouth-read-write.service) \
11052 (cd $(DESTDIR)$(SYSTEMD_UNIT_DIR)/multi-user.target.wants && \
11053diff --git a/systemd-units/plymouth-halt.service.in b/systemd-units/plymouth-halt.service.in
11054index 8fd6c48..fd27e10 100644
11055--- a/systemd-units/plymouth-halt.service.in
11056+++ b/systemd-units/plymouth-halt.service.in
11057@@ -1,7 +1,7 @@
11058 [Unit]
11059 Description=Show Plymouth Halt Screen
11060-After=getty@tty1.service prefdm.service plymouth-start.service
11061-Before=halt.service
11062+After=getty@tty1.service display-manager.service plymouth-start.service
11063+Before=systemd-halt.service
11064 DefaultDependencies=no
11065 ConditionKernelCommandLine=!plymouth.enable=0
11066
11067@@ -9,3 +9,6 @@ ConditionKernelCommandLine=!plymouth.enable=0
11068 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
11069 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
11070 Type=forking
11071+
11072+[Install]
11073+WantedBy=halt.target
11074diff --git a/systemd-units/plymouth-kexec.service.in b/systemd-units/plymouth-kexec.service.in
11075index 6ee0461..8aa661d 100644
11076--- a/systemd-units/plymouth-kexec.service.in
11077+++ b/systemd-units/plymouth-kexec.service.in
11078@@ -1,7 +1,7 @@
11079 [Unit]
11080 Description=Show Plymouth Reboot with kexec Screen
11081-After=getty@tty1.service prefdm.service plymouth-start.service
11082-Before=kexec.service
11083+After=getty@tty1.service display-manager.service plymouth-start.service
11084+Before=systemd-kexec.service
11085 DefaultDependencies=no
11086 ConditionKernelCommandLine=!plymouth.enable=0
11087
11088@@ -9,3 +9,6 @@ ConditionKernelCommandLine=!plymouth.enable=0
11089 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
11090 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
11091 Type=forking
11092+
11093+[Install]
11094+WantedBy=kexec.target
11095diff --git a/systemd-units/plymouth-poweroff.service.in b/systemd-units/plymouth-poweroff.service.in
11096index 3e2a83c..305ece6 100644
11097--- a/systemd-units/plymouth-poweroff.service.in
11098+++ b/systemd-units/plymouth-poweroff.service.in
11099@@ -1,7 +1,7 @@
11100 [Unit]
11101 Description=Show Plymouth Power Off Screen
11102-After=getty@tty1.service prefdm.service plymouth-start.service
11103-Before=poweroff.service
11104+After=getty@tty1.service display-manager.service plymouth-start.service
11105+Before=systemd-poweroff.service
11106 DefaultDependencies=no
11107 ConditionKernelCommandLine=!plymouth.enable=0
11108
11109@@ -9,3 +9,5 @@ ConditionKernelCommandLine=!plymouth.enable=0
11110 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
11111 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
11112 Type=forking
11113+[Install]
11114+WantedBy=poweroff.target
11115diff --git a/systemd-units/plymouth-quit-wait.service.in b/systemd-units/plymouth-quit-wait.service.in
11116index 9fc20e7..1c431b6 100644
11117--- a/systemd-units/plymouth-quit-wait.service.in
11118+++ b/systemd-units/plymouth-quit-wait.service.in
11119@@ -5,4 +5,6 @@ After=rc-local.service plymouth-start.service systemd-user-sessions.service
11120 [Service]
11121 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth --wait
11122 Type=oneshot
11123-TimeoutSec=20
11124+TimeoutSec=0
11125+[Install]
11126+WantedBy=multi-user.target
11127diff --git a/systemd-units/plymouth-quit.service.in b/systemd-units/plymouth-quit.service.in
11128index cf9901e..24c11bb 100644
11129--- a/systemd-units/plymouth-quit.service.in
11130+++ b/systemd-units/plymouth-quit.service.in
11131@@ -6,3 +6,5 @@ After=rc-local.service plymouth-start.service systemd-user-sessions.service
11132 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth quit
11133 Type=oneshot
11134 TimeoutSec=20
11135+[Install]
11136+WantedBy=multi-user.target
11137diff --git a/systemd-units/plymouth-read-write.service.in b/systemd-units/plymouth-read-write.service.in
11138index 55b975e..5abfc49 100644
11139--- a/systemd-units/plymouth-read-write.service.in
11140+++ b/systemd-units/plymouth-read-write.service.in
11141@@ -8,3 +8,5 @@ ConditionPathExists=!/etc/initrd-release
11142 [Service]
11143 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth update-root-fs --read-write
11144 Type=oneshot
11145+[Install]
11146+WantedBy=sysinit.target
11147diff --git a/systemd-units/plymouth-reboot.service.in b/systemd-units/plymouth-reboot.service.in
11148index a6e86e4..ce56855 100644
11149--- a/systemd-units/plymouth-reboot.service.in
11150+++ b/systemd-units/plymouth-reboot.service.in
11151@@ -1,7 +1,7 @@
11152 [Unit]
11153 Description=Show Plymouth Reboot Screen
11154-After=getty@tty1.service prefdm.service plymouth-start.service
11155-Before=reboot.service
11156+After=getty@tty1.service display-manager.service plymouth-start.service
11157+Before=systemd-reboot.service
11158 DefaultDependencies=no
11159 ConditionKernelCommandLine=!plymouth.enable=0
11160
11161@@ -9,3 +9,5 @@ ConditionKernelCommandLine=!plymouth.enable=0
11162 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
11163 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
11164 Type=forking
11165+[Install]
11166+WantedBy=reboot.target
11167diff --git a/systemd-units/plymouth-start.service.in b/systemd-units/plymouth-start.service.in
11168index bbff9f5..0d5ff2a 100644
11169--- a/systemd-units/plymouth-start.service.in
11170+++ b/systemd-units/plymouth-start.service.in
11171@@ -1,14 +1,16 @@
11172 [Unit]
11173 Description=Show Plymouth Boot Screen
11174 DefaultDependencies=no
11175-Wants=systemd-ask-password-plymouth.path
11176-After=systemd-vconsole-setup.service systemd-udev-trigger.service
11177+Wants=systemd-ask-password-plymouth.path systemd-vconsole-setup.service
11178+After=systemd-vconsole-setup.service systemd-udev-trigger.service systemd-udevd.service
11179 Before=systemd-ask-password-plymouth.service
11180 ConditionKernelCommandLine=!plymouth.enable=0
11181
11182 [Service]
11183 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=boot --pid-file=@plymouthruntimedir@/pid --attach-to-session
11184-ExecStartPost=-/bin/udevadm settle --timeout=30 --exit-if-exists=/sys/class/drm/card0/dev ; /bin/udevadm settle --timeout=30 --exit-if-exists=/sys/class/graphics/fb0/dev ; @PLYMOUTH_CLIENT_DIR@/plymouth show-splash
11185+ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
11186 Type=forking
11187 KillMode=none
11188 SendSIGKILL=no
11189+[Install]
11190+WantedBy=sysinit.target
11191diff --git a/systemd-units/systemd-ask-password-plymouth.service.in b/systemd-units/systemd-ask-password-plymouth.service.in
11192index aa9ffc2..0c3acde 100644
11193--- a/systemd-units/systemd-ask-password-plymouth.service.in
11194+++ b/systemd-units/systemd-ask-password-plymouth.service.in
11195@@ -9,4 +9,4 @@ ConditionKernelCommandLine=!plymouth.enable=0
11196 ConditionPathExists=/run/plymouth/pid
11197
11198 [Service]
11199-ExecStart=/bin/systemd-tty-ask-password-agent --watch --plymouth
11200+ExecStart=@SYSTEMD_ASK_PASSWORD_AGENT@ --watch --plymouth
11201diff --git a/themes/Makefile.am b/themes/Makefile.am
11202index cfd149e..72e642b 100644
11203--- a/themes/Makefile.am
11204+++ b/themes/Makefile.am
11205@@ -1,2 +1,2 @@
11206-SUBDIRS = spinfinity fade-in text details solar glow script spinner
11207+SUBDIRS = spinfinity fade-in text details solar glow script spinner tribar
11208 MAINTAINERCLEANFILES = Makefile.in
11209diff --git a/themes/text/text.plymouth b/themes/text/text.plymouth
11210index a2db9e6..126eb09 100644
11211--- a/themes/text/text.plymouth
11212+++ b/themes/text/text.plymouth
11213@@ -1,4 +1,4 @@
11214 [Plymouth Theme]
11215 Name=Text
11216-Description=Text mode theme with tricolor progress bar
11217+Description=Text mode theme with a 3 box countdown
11218 ModuleName=text
11219diff --git a/themes/tribar/Makefile.am b/themes/tribar/Makefile.am
11220new file mode 100644
11221index 0000000..3066d2f
11222--- /dev/null
11223+++ b/themes/tribar/Makefile.am
11224@@ -0,0 +1,4 @@
11225+themedir = $(datadir)/plymouth/themes/tribar
11226+dist_theme_DATA = tribar.plymouth
11227+
11228+MAINTAINERCLEANFILES = Makefile.in
11229diff --git a/themes/tribar/tribar.plymouth b/themes/tribar/tribar.plymouth
11230new file mode 100644
11231index 0000000..6db7b4e
11232--- /dev/null
11233+++ b/themes/tribar/tribar.plymouth
11234@@ -0,0 +1,4 @@
11235+[Plymouth Theme]
11236+Name=Tribar
11237+Description=Text mode theme with tricolor progress bar
11238+ModuleName=tribar
This page took 1.327635 seconds and 4 git commands to generate.