1 diff --git a/Makefile.am b/Makefile.am
2 index b322463..395c91b 100644
6 -SUBDIRS = src themes images scripts docs systemd-units
7 +SUBDIRS = src themes images scripts systemd-units
9 +if BUILD_DOCUMENTATION
13 DISTCHECK_CONFIGURE_FLAGS = --disable-tests --without-system-root-install
15 diff --git a/configure.ac b/configure.ac
16 index 2ab0893..9c8f863 100644
19 @@ -6,7 +6,7 @@ AC_CONFIG_AUX_DIR(build-tools)
20 AC_USE_SYSTEM_EXTENSIONS
28 @@ -16,7 +16,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
29 AM_MAINTAINER_MODE([enable])
33 +LT_INIT([dlopen disable-static pic-only])
35 ## increment if the interface has additions, changes, removals.
37 @@ -38,12 +38,19 @@ PKG_CHECK_MODULES(IMAGE, [libpng >= 1.2.16 ])
38 AC_SUBST(IMAGE_CFLAGS)
41 +PKG_CHECK_MODULES(UDEV, [libudev]);
42 +AC_SUBST(UDEV_CFLAGS)
46 PLYMOUTH_LIBS="-lm -lrt -ldl"
48 AC_SUBST(PLYMOUTH_CFLAGS)
49 AC_SUBST(PLYMOUTH_LIBS)
51 +AC_PATH_PROG([SYSTEMD_ASK_PASSWORD_AGENT], [systemd-tty-ask-password-agent])
52 +AC_PATH_PROG([UDEVADM], [udevadm])
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])
57 @@ -62,148 +69,6 @@ if test x$enable_gtk = xyes; then
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])
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(
73 - #include "i915_drm.h"
74 - ]],[[]]),[found_drm_intel_kernel_headers=yes],[found_drm_intel_kernel_headers=no])
76 - if test "$found_drm_intel_kernel_headers" = "yes"; then
77 - AC_MSG_RESULT([yes])
80 - AC_MSG_CHECKING([if we can find them anyway])
82 - MORE_DRM_CFLAGS="-I`$PKG_CONFIG --variable includedir libdrm`/drm"
83 - CFLAGS="$CFLAGS $MORE_DRM_CFLAGS"
84 - AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
88 - #include "i915_drm.h"
89 - ]],[[]]),[found_drm_intel_kernel_headers=yes],[found_drm_intel_kernel_headers=no])
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"
96 - AC_MSG_ERROR([Could not find i915_drm.h])
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])
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])
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(
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])
120 - if test "$found_drm_radeon_kernel_headers" = "yes"; then
121 - AC_MSG_RESULT([yes])
123 - AC_MSG_RESULT([no])
124 - AC_MSG_CHECKING([if we can find them anyway])
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(
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])
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"
139 - AC_MSG_RESULT([no])
140 - AC_MSG_ERROR([Could not find radeon_drm.h])
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])
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])
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(
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])
164 - if test "$found_drm_nouveau_kernel_headers" = "yes"; then
165 - AC_MSG_RESULT([yes])
167 - AC_MSG_RESULT([no])
168 - AC_MSG_CHECKING([if we can find them anyway])
170 - MORE_DRM_CFLAGS="-I`$PKG_CONFIG --variable includedir libdrm`/drm"
171 - CFLAGS="$CFLAGS $MORE_DRM_CFLAGS"
172 - AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
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])
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"
183 - AC_MSG_RESULT([no])
184 - AC_MSG_ERROR([Could not find nouveau_drm.h])
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])
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])
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])
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])
206 @@ -211,10 +76,17 @@ if test x$enable_drm_renderer = xyes; then
207 PKG_CHECK_MODULES(DRM, [libdrm])
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)
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])
224 +AM_CONDITIONAL(BUILD_DOCUMENTATION, test x$enable_documentation = xyes)
226 AC_ARG_ENABLE(tracing, AS_HELP_STRING([--enable-tracing],[enable verbose tracing code]),enable_tracing=$enableval,enable_tracing=yes)
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])
232 -AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[build tests]),enable_tests=$enableval,enable_tests=yes)
234 -AM_CONDITIONAL(ENABLE_TESTS, [test "$enable_tests" = yes])
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)
238 if test x$enable_gdm_transition = xyes; then
239 @@ -254,7 +122,7 @@ AM_CONDITIONAL(ENABLE_SYSTEMD_INTEGRATION, [test "$enable_systemd_integration" =
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)
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)
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])
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"
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"
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
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
286 src/upstart-bridge/Makefile
288 - src/libply/tests/Makefile
289 - src/client/tests/Makefile
291 themes/spinfinity/Makefile
292 themes/fade-in/Makefile
293 + themes/tribar/Makefile
295 themes/details/Makefile
296 themes/solar/Makefile
297 diff --git a/docs/Makefile.am b/docs/Makefile.am
298 index dedda55..1a9f7ea 100644
299 --- a/docs/Makefile.am
300 +++ b/docs/Makefile.am
302 -dist_man_MANS = plymouth.8
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
312 - asciidoc $(ASCIIDOC_OPTS) -a toc $*.txt
314 +plymouth.1: plymouth1.xml
315 + $(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
318 + $(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
321 + $(AM_V_GEN) $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
327 + plymouth-set-default-theme.1
332 + plymouth-set-default-theme.xml \
335 +CLEANFILES = $(man_MANS)
336 diff --git a/docs/plymouth-set-default-theme.xml b/docs/plymouth-set-default-theme.xml
338 index 0000000..efb051e
340 +++ b/docs/plymouth-set-default-theme.xml
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">
346 +<refentry id="plymouth-set-default-theme">
349 + <title>plymouth-set-default-theme</title>
350 + <productname>plymouth</productname>
354 + <contrib>Developer</contrib>
355 + <firstname>Kristian</firstname>
356 + <surname>Høgsberg</surname>
359 + <contrib>Developer</contrib>
360 + <firstname>Ray</firstname>
361 + <surname>Strode</surname>
368 + <refentrytitle>plymouth-set-default-theme</refentrytitle>
369 + <manvolnum>1</manvolnum>
370 + <refmiscinfo class="manual">User Commands</refmiscinfo>
374 + <refname>plymouth-set-default-theme</refname>
375 + <refpurpose>Set the plymouth theme</refpurpose>
380 + <command>plymouth-set-default-theme <arg choice="opt" rep="repeat">OPTION</arg> <arg choice="opt" rep="norepeat">THEME</arg></command>
385 + <title>Description</title>
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
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.
406 + <title>Options</title>
408 + <para>The following options are understood:</para>
412 + <term><option>-h</option>, <option>--help</option></term>
413 + <listitem><para>Show summary of options.</para></listitem>
417 + <term><option>-l</option>, <option>--list</option></term>
418 + <listitem><para>List available themes.</para></listitem>
422 + <term><option>-r</option>, <option>--reset</option></term>
423 + <listitem><para>Reset to default theme.</para></listitem>
427 + <term><option>-R</option>, <option>--rebuild-initrd</option></term>
428 + <listitem><para>Rebuild initrd (necessary after changing theme).</para></listitem>
434 + <title>See Also</title>
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>
445 diff --git a/docs/plymouth.8 b/docs/plymouth.8
446 deleted file mode 100644
447 index 7f4766b..0000000
448 --- a/docs/plymouth.8
451 -\" Hey, EMACS: -*- nroff -*-
452 -.TH PLYMOUTH 8 "December 15, 2009"
454 -plymouth \- A graphical boot system and logger
456 -.B plymouth-set-default-theme
457 -.RI [ options ] " \<theme\>"
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.
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.
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.
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.
484 -Show summary of options.
487 -List available themes.
490 -Reset to default theme.
492 -.B \-R, \-\-rebuild\-initrd
493 -Rebuild initrd (necessary after changing theme).
496 -Name of new theme to use. If you want to see which themes are available, invoke the script with just \-\-list.
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.
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>.
512 -This manual page was written by Adrian Glaubitz <glaubitz@physik.fu-berlin.de>.
513 diff --git a/docs/plymouth.xml b/docs/plymouth.xml
515 index 0000000..0f196c6
517 +++ b/docs/plymouth.xml
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">
523 +<refentry id="plymouth">
526 + <title>plymouth</title>
527 + <productname>plymouth</productname>
531 + <contrib>Developer</contrib>
532 + <firstname>Kristian</firstname>
533 + <surname>Høgsberg</surname>
536 + <contrib>Developer</contrib>
537 + <firstname>Ray</firstname>
538 + <surname>Strode</surname>
545 + <refentrytitle>plymouth</refentrytitle>
546 + <manvolnum>8</manvolnum>
547 + <refmiscinfo class="manual">System Administration</refmiscinfo>
551 + <refname>plymouth</refname>
552 + <refpurpose>A graphical boot system and logger</refpurpose>
556 + <title>Description</title>
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.
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.
578 +During the boot process, the user can switch between the graphical theme
579 +and the detailed boot output using the Escape key.
585 + <title>See Also</title>
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>
596 + <title>Authors</title>
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.
605 diff --git a/docs/plymouth1.xml b/docs/plymouth1.xml
607 index 0000000..b484599
609 +++ b/docs/plymouth1.xml
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">
615 +<refentry id="plymouth-set-default-theme">
618 + <title>plymouth</title>
619 + <productname>plymouth</productname>
623 + <contrib>Developer</contrib>
624 + <firstname>Kristian</firstname>
625 + <surname>Høgsberg</surname>
628 + <contrib>Developer</contrib>
629 + <firstname>Ray</firstname>
630 + <surname>Strode</surname>
637 + <refentrytitle>plymouth</refentrytitle>
638 + <manvolnum>1</manvolnum>
639 + <refmiscinfo class="manual">User Commands</refmiscinfo>
643 + <refname>plymouth</refname>
644 + <refpurpose>Send commands to plymouthd</refpurpose>
649 + <command>plymouth <arg choice="opt" rep="repeat">OPTION</arg></command>
652 + <command>plymouth <arg choice="plain">COMMAND <arg choice="opt" rep="repeat">OPTION</arg></arg></command>
657 + <title>Description</title>
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.
668 + <title>Options</title>
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
679 + <term><option>--help</option></term>
680 + <listitem><para>Show summary of options.</para></listitem>
684 + <term><option>--debug</option></term>
685 + <listitem><para>Enable verbose debug logging.</para></listitem>
689 + <term><option>--get-splash-plugin-path</option></term>
690 + <listitem><para>Get directory where splash plugins are installed.</para></listitem>
694 + <term><option>--newroot=<arg>STRING</arg></option></term>
695 + <listitem><para>Tell plymouthd that the new root filesystem is mounted.</para></listitem>
699 + <term><option>--quit</option></term>
700 + <listitem><para>Tell plymouthd to quit.</para></listitem>
704 + <term><option>--ping</option></term>
705 + <listitem><para>Check if plymouthd is running.</para></listitem>
709 + <term><option>--has-active-vt</option></term>
710 + <listitem><para>Check if plymouthd has an active vt.</para></listitem>
714 + <term><option>--sysinit</option></term>
715 + <listitem><para>Tell plymouthd root filesystem is mounted read-write.</para></listitem>
719 + <term><option>--show-splash</option></term>
720 + <listitem><para>Show the splash screen.</para></listitem>
724 + <term><option>--hide-splash</option></term>
725 + <listitem><para>Hide the splash screen.</para></listitem>
729 + <term><option>--ask-for-password</option></term>
730 + <listitem><para>Ask the user for a password.</para></listitem>
734 + <term><option>--ignore-keystroke=<arg>STRING</arg></option></term>
735 + <listitem><para>Remove sensitivity to a keystroke.</para></listitem>
739 + <term><option>--update=<arg>STRING</arg></option></term>
740 + <listitem><para>Tell plymouthd an update about boot progress.</para></listitem>
744 + <term><option>--details</option></term>
745 + <listitem><para>Tell plymouthd there were errors during boot.</para></listitem>
749 + <term><option>--wait</option></term>
750 + <listitem><para>Wait for plymouthd to quit.</para></listitem>
756 + <title>Commands</title>
759 +The following commands are understood:
763 + <term><command>change-mode <arg choice="plain">OPTION</arg></command></term>
764 + <listitem><para>Change the operation mode.</para>
767 + <term><option>--boot-up</option></term>
768 + <listitem><para>Start the system up</para></listitem>
771 + <term><option>--shutdown</option></term>
772 + <listitem><para>Shutting the system up</para></listitem>
775 + <term><option>--updates</option></term>
776 + <listitem><para>Applying updates</para></listitem>
782 + <term><command>system-update <arg choice="plain">OPTION</arg></command></term>
783 + <listitem><para>Tell plymouthd about boot progress.</para>
786 + <term><option>--progress=INTEGER</option></term>
787 + <listitem><para>The percentage progress of the updates</para></listitem>
793 + <term><command>update <arg choice="plain">OPTION</arg></command></term>
794 + <listitem><para>Tell plymouthd about boot status changes.</para>
797 + <term><option>--status=STRING</option></term>
798 + <listitem><para>Tell plymouthd the current boot status</para></listitem>
804 + <term><command>update-root-fs <arg choice="plain">OPTION</arg></command></term>
805 + <listitem><para>Tell plymouthd about root filesystem changes.</para>
808 + <term><option>--new-root-dir=STRING</option></term>
809 + <listitem><para>Root filesystem is about to change</para></listitem>
812 + <term><option>--read-write</option></term>
813 + <listitem><para>Root filesystem is no longer read-only</para></listitem>
819 + <term><command>show-splash</command></term>
820 + <listitem><para>Tell plymouthd to show splash screen.</para></listitem>
823 + <term><command>hide-splash</command></term>
824 + <listitem><para>Tell plymouthd to hide splash screen.</para></listitem>
827 + <term><command>ask-for-password <arg choice="plain">OPTION</arg></command></term>
828 + <listitem><para>Ask the user for a password.</para>
831 + <term><option>--command=STRING</option></term>
832 + <listitem><para>Command to send password to via standard input</para></listitem>
835 + <term><option>--prompt=STRING</option></term>
836 + <listitem><para>Message to display when asking for password</para></listitem>
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>
843 + <term><option>--dont-pause-progress</option></term>
844 + <listitem><para>Don't pause boot progress bar while asking</para></listitem>
850 + <term><command>ask-question</command></term>
851 + <listitem><para>Ask the user a question.</para>
854 + <term><option>--command=STRING</option></term>
855 + <listitem><para>Command to send the answer to via standard input</para></listitem>
858 + <term><option>--prompt=STRING</option></term>
859 + <listitem><para>Message to display when asking the question</para></listitem>
862 + <term><option>--dont-pause-progress</option></term>
863 + <listitem><para>Don't pause boot progress bar while asking</para></listitem>
869 + <term><command>display-message <arg choice="plain">OPTION</arg></command></term>
870 + <listitem><para>Display a message.</para>
873 + <term><option>--text=STRING</option></term>
874 + <listitem><para>The message text</para></listitem>
880 + <term><command>hide-message <arg choice="plain">OPTION</arg></command></term>
881 + <listitem><para>Hide a message.</para>
884 + <term><option>--text=STRING</option></term>
885 + <listitem><para>The message text</para></listitem>
891 + <term><command>watch-keystroke <arg choice="plain">OPTION</arg></command></term>
892 + <listitem><para>Become sensitive to a keystroke.</para>
895 + <term><option>--command=STRING</option></term>
896 + <listitem><para>Command to send keystroke to via standard input</para></listitem>
899 + <term><option>--keys=STRING</option></term>
900 + <listitem><para>Keys to become sensitive to</para></listitem>
906 + <term><command>ignore-keystroke <arg choice="plain">OPTION</arg></command></term>
907 + <listitem><para>Remove sensitivity to a keystroke.</para>
910 + <term><option>--keys=STRING</option></term>
911 + <listitem><para>Keys to remove sensitivitiy from</para></listitem>
917 + <term><command>pause-progress</command></term>
918 + <listitem><para>Pause boot progress bar.</para></listitem>
921 + <term><command>unpause-progress</command></term>
922 + <listitem><para>Unpause boot progress bar.</para></listitem>
925 + <term><command>report-error</command></term>
926 + <listitem><para>Tell plymouthd there were errors during boot.</para></listitem>
929 + <term><command>deactivate</command></term>
930 + <listitem><para>Tell plymouthd to deactivate.</para></listitem>
933 + <term><command>reactivate</command></term>
934 + <listitem><para>Tell plymouthd to reactivate.</para></listitem>
937 + <term><command>quit <arg choice="plain">OPTION</arg></command></term>
938 + <listitem><para>Tell plymouthd to quit.</para>
941 + <term><option>--retain-splash</option></term>
942 + <listitem><para>Don't explicitly hide boot splash on exit</para></listitem>
952 + <title>See Also</title>
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>
962 diff --git a/docs/plymouthd.xml b/docs/plymouthd.xml
964 index 0000000..4e7e499
966 +++ b/docs/plymouthd.xml
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">
972 +<refentry id="plymouthd">
975 + <title>plymouthd</title>
976 + <productname>plymouth</productname>
980 + <contrib>Developer</contrib>
981 + <firstname>Kristian</firstname>
982 + <surname>Høgsberg</surname>
985 + <contrib>Developer</contrib>
986 + <firstname>Ray</firstname>
987 + <surname>Strode</surname>
994 + <refentrytitle>plymouthd</refentrytitle>
995 + <manvolnum>8</manvolnum>
996 + <refmiscinfo class="manual">System Administration</refmiscinfo>
1000 + <refname>plymouthd</refname>
1001 + <refpurpose>The plymouth daemon</refpurpose>
1006 + <command>plymouthd <arg choice="opt" rep="repeat">OPTION</arg></command>
1011 + <title>Description</title>
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.
1019 +The <command>plymouth</command> is used to send commands to plymouthd
1020 +that control its behaviour.
1026 + <title>Options</title>
1028 + <para>The following options are understood:</para>
1032 + <term><option>--help</option></term>
1033 + <listitem><para>Show summary of options.</para></listitem>
1037 + <term><option>--attach-to-session</option></term>
1038 + <listitem><para>Redirect console messages from screen to log.</para></listitem>
1042 + <term><option>--no-daemon</option></term>
1043 + <listitem><para>Do not daemonize.</para></listitem>
1047 + <term><option>--debug</option></term>
1048 + <listitem><para>Output debugging information.</para></listitem>
1052 + <term><option>--debug-file=STRING</option></term>
1053 + <listitem><para>File to write debugging information to.</para></listitem>
1057 + <term><option>--mode=MODE</option></term>
1058 + <listitem><para>Set mode to either boot or shutdown.</para></listitem>
1062 + <term><option>--pid-file=STRING</option></term>
1063 + <listitem><para>Write the PID of the daemon to a file.</para></listitem>
1067 + <term><option>--kernel-command-line=STRING</option></term>
1068 + <listitem><para>Fake kernel commandline to use.</para></listitem>
1072 + <term><option>--tty=STRING</option></term>
1073 + <listitem><para>TTY to ues instead of default.</para></listitem>
1079 + <title>See Also</title>
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>
1089 diff --git a/scripts/plymouth-generate-initrd.in b/scripts/plymouth-generate-initrd.in
1090 index 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"
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
1107 diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in
1108 index 8d1eec0..43c7f22 100755
1109 --- a/scripts/plymouth-populate-initrd.in
1110 +++ b/scripts/plymouth-populate-initrd.in
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
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
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
1140 PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')
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
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
1151 diff --git a/scripts/plymouth-update-initrd b/scripts/plymouth-update-initrd
1152 index 1403b8b..4ed5709 100755
1153 --- a/scripts/plymouth-update-initrd
1154 +++ b/scripts/plymouth-update-initrd
1157 -mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)
1159 diff --git a/src/Makefile.am b/src/Makefile.am
1160 index a9e6eb1..fc2f5da 100644
1161 --- a/src/Makefile.am
1162 +++ b/src/Makefile.am
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
1169 -INCLUDES = -I$(top_srcdir) \
1170 +AM_CPPFLAGS = -I$(top_srcdir) \
1171 -I$(srcdir)/libply \
1172 -I$(srcdir)/libply-splash-core \
1174 @@ -15,6 +15,7 @@ plymouthdbindir = $(plymouthdaemondir)
1175 plymouthdbin_PROGRAMS = plymouthd
1177 plymouthd_CFLAGS = $(PLYMOUTH_CFLAGS) \
1179 -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\" \
1180 -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\" \
1181 -DPLYMOUTH_POLICY_DIR=\"$(PLYMOUTH_POLICY_DIR)/\" \
1182 diff --git a/src/client/Makefile.am b/src/client/Makefile.am
1183 index 9487901..83b19cc 100644
1184 --- a/src/client/Makefile.am
1185 +++ b/src/client/Makefile.am
1189 -INCLUDES = -I$(top_srcdir) \
1190 +AM_CPPFLAGS = -I$(top_srcdir) \
1191 -I$(top_srcdir)/src \
1192 -I$(top_srcdir)/src/libply \
1194 diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c
1195 index 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,
1202 -#ifdef PLY_BOOT_CLIENT_ENABLE_TEST
1206 -#include "ply-event-loop.h"
1207 -#include "ply-boot-client.h"
1210 -on_pinged (ply_event_loop_t *loop)
1212 - printf ("PING!\n");
1216 -on_ping_failed (ply_event_loop_t *loop)
1218 - printf ("PING FAILED! %m\n");
1219 - ply_event_loop_exit (loop, 1);
1223 -on_update (ply_event_loop_t *loop)
1225 - printf ("UPDATE!\n");
1229 -on_update_failed (ply_event_loop_t *loop)
1231 - printf ("UPDATE FAILED! %m\n");
1232 - ply_event_loop_exit (loop, 1);
1236 -on_newroot (ply_event_loop_t *loop)
1238 - printf ("NEWROOT!\n");
1242 -on_system_initialized (ply_event_loop_t *loop)
1244 - printf ("SYSTEM INITIALIZED!\n");
1248 -on_system_initialized_failed (ply_event_loop_t *loop)
1250 - printf ("SYSTEM INITIALIZATION REQUEST FAILED!\n");
1251 - ply_event_loop_exit (loop, 1);
1255 -on_quit (ply_event_loop_t *loop)
1257 - printf ("QUIT!\n");
1258 - ply_event_loop_exit (loop, 0);
1262 -on_quit_failed (ply_event_loop_t *loop)
1264 - printf ("QUIT FAILED! %m\n");
1265 - ply_event_loop_exit (loop, 2);
1269 -on_disconnect (ply_event_loop_t *loop)
1271 - printf ("DISCONNECT!\n");
1272 - ply_event_loop_exit (loop, 1);
1279 - ply_event_loop_t *loop;
1280 - ply_boot_client_t *client;
1285 - loop = ply_event_loop_new ();
1287 - client = ply_boot_client_new ();
1289 - if (!ply_boot_client_connect (client,
1290 - (ply_boot_client_disconnect_handler_t) on_disconnect,
1293 - perror ("could not start boot client");
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,
1303 - ply_boot_client_update_daemon (client,
1305 - (ply_boot_client_response_handler_t) on_update,
1306 - (ply_boot_client_response_handler_t) on_update_failed,
1309 - ply_boot_client_update_daemon (client,
1311 - (ply_boot_client_response_handler_t) on_update,
1312 - (ply_boot_client_response_handler_t) on_update_failed,
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,
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,
1327 - exit_code = ply_event_loop_run (loop);
1329 - ply_boot_client_free (client);
1334 -#endif /* PLY_BOOT_CLIENT_ENABLE_TEST */
1335 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
1336 diff --git a/src/client/plymouth.c b/src/client/plymouth.c
1337 index e00208d..b22e90c 100644
1338 --- a/src/client/plymouth.c
1339 +++ b/src/client/plymouth.c
1340 @@ -1173,7 +1173,8 @@ main (int argc,
1342 if (get_kernel_command_line (&state))
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 ();
1350 diff --git a/src/client/tests/Makefile.am b/src/client/tests/Makefile.am
1351 deleted file mode 100644
1352 index c6dbfdb..0000000
1353 --- a/src/client/tests/Makefile.am
1359 - -I$(srcdir)/../.. \
1363 -noinst_PROGRAMS = $(TESTS)
1365 -MAINTAINERCLEANFILES = Makefile.in
1366 diff --git a/src/libply-splash-core/Makefile.am b/src/libply-splash-core/Makefile.am
1367 index b289b65..d07d7f1 100644
1368 --- a/src/libply-splash-core/Makefile.am
1369 +++ b/src/libply-splash-core/Makefile.am
1371 -INCLUDES = -I$(top_srcdir) \
1372 +AM_CPPFLAGS = -I$(top_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 = \
1379 ply-boot-splash-plugin.h \
1380 + ply-device-manager.h \
1382 ply-pixel-buffer.h \
1383 ply-pixel-display.h \
1385 ply-renderer-plugin.h \
1388 ply-text-display.h \
1389 - ply-text-progress-bar.h
1390 + ply-text-progress-bar.h \
1391 + ply-text-step-bar.h
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) \
1404 libply_splash_core_la_SOURCES = \
1405 $(libply_splash_core_HEADERS) \
1406 + ply-device-manager.c \
1408 ply-pixel-display.c \
1409 ply-text-display.c \
1410 ply-text-progress-bar.c \
1411 + ply-text-step-bar.c \
1413 ply-pixel-buffer.c \
1418 MAINTAINERCLEANFILES = Makefile.in
1419 diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c
1420 index 93d9345..160ce45 100644
1421 --- a/src/libply-splash-core/ply-boot-splash.c
1422 +++ b/src/libply-splash-core/ply-boot-splash.c
1424 #define UPDATES_PER_SECOND 30
1427 -#define KEY_CTRL_L ('\100' ^'L')
1428 -#define KEY_CTRL_T ('\100' ^'T')
1429 -#define KEY_CTRL_V ('\100' ^'V')
1431 struct _ply_boot_splash
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;
1447 @@ -100,18 +94,30 @@ ply_boot_splash_new (const char *theme_path,
1448 splash->mode = PLY_BOOT_SPLASH_MODE_INVALID;
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 ();
1459 -refresh_displays (ply_boot_splash_t *splash)
1460 +detach_from_seat (ply_boot_splash_t *splash,
1463 - ply_list_node_t *node;
1464 + ply_keyboard_t *keyboard;
1465 + ply_list_t *displays;
1466 + ply_list_node_t *node, *next_node;
1468 - node = ply_list_get_first_node (splash->pixel_displays);
1469 + ply_trace ("removing keyboard");
1470 + if (splash->plugin_interface->unset_keyboard != NULL)
1472 + keyboard = ply_seat_get_keyboard (seat);
1473 + splash->plugin_interface->unset_keyboard (splash->plugin, keyboard);
1476 + ply_trace ("removing pixel displays");
1477 + displays = ply_seat_get_pixel_displays (seat);
1479 + node = ply_list_get_first_node (displays);
1480 while (node != NULL)
1482 ply_pixel_display_t *display;
1483 @@ -119,184 +125,137 @@ refresh_displays (ply_boot_splash_t *splash)
1484 unsigned long width, height;
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);
1490 width = ply_pixel_display_get_width (display);
1491 height = ply_pixel_display_get_height (display);
1493 - ply_pixel_display_draw_area (display, 0, 0, width, height);
1494 + ply_trace ("Removing %lux%lu pixel display", width, height);
1496 + if (splash->plugin_interface->remove_pixel_display != NULL)
1497 + splash->plugin_interface->remove_pixel_display (splash->plugin, display);
1502 - node = ply_list_get_first_node (splash->text_displays);
1503 + ply_trace ("removing text displays");
1504 + displays = ply_seat_get_text_displays (seat);
1506 + node = ply_list_get_first_node (displays);
1507 while (node != NULL)
1509 ply_text_display_t *display;
1510 - ply_list_node_t *next_node;
1511 int number_of_columns, number_of_rows;
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);
1517 number_of_columns = ply_text_display_get_number_of_columns (display);
1518 number_of_rows = ply_text_display_get_number_of_rows (display);
1520 - ply_text_display_draw_area (display, 0, 0,
1521 - number_of_columns,
1523 + ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
1525 + if (splash->plugin_interface->remove_text_display != NULL)
1526 + splash->plugin_interface->remove_text_display (splash->plugin, display);
1532 -static ply_terminal_t *
1533 -find_local_console_terminal (ply_boot_splash_t *splash)
1535 +attach_to_seat (ply_boot_splash_t *splash,
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;
1544 - while (node != NULL)
1545 + if (splash->plugin_interface->set_keyboard != NULL)
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);
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)
1558 + displays = ply_seat_get_pixel_displays (seat);
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)
1565 + ply_pixel_display_t *display;
1566 + ply_list_node_t *next_node;
1567 + unsigned long width, height;
1569 - if (terminal != NULL && ply_terminal_is_vt (terminal))
1571 + display = ply_list_node_get_data (node);
1572 + next_node = ply_list_get_next_node (displays, node);
1576 + width = ply_pixel_display_get_width (display);
1577 + height = ply_pixel_display_get_height (display);
1581 + ply_trace ("Adding %lux%lu pixel display", width, height);
1584 -on_keyboard_input (ply_boot_splash_t *splash,
1585 - const char *keyboard_input,
1586 - size_t character_size)
1589 + splash->plugin_interface->add_pixel_display (splash->plugin, display);
1591 - if ((ssize_t) mbrtowc (&key, keyboard_input, character_size, NULL) > 0)
1596 - refresh_displays (splash);
1600 - ply_trace ("toggle text mode!");
1601 - splash->should_force_text_mode = !splash->should_force_text_mode;
1603 - if (ply_list_get_length (splash->pixel_displays) >= 1)
1605 - ply_terminal_t *terminal;
1607 - terminal = find_local_console_terminal (splash);
1609 - if (terminal != NULL)
1611 - if (splash->should_force_text_mode)
1613 - ply_terminal_set_mode (terminal, PLY_TERMINAL_MODE_TEXT);
1614 - ply_terminal_ignore_mode_changes (terminal, true);
1617 - ply_terminal_ignore_mode_changes (terminal, false);
1620 - ply_trace ("text mode toggled!");
1624 - ply_trace ("toggle verbose mode!");
1625 - ply_toggle_tracing ();
1626 - ply_trace ("verbose mode toggled!");
1634 -ply_boot_splash_set_keyboard (ply_boot_splash_t *splash,
1635 - ply_keyboard_t *keyboard)
1637 - splash->keyboard = keyboard;
1638 + if (splash->plugin_interface->add_text_display != NULL)
1640 + displays = ply_seat_get_text_displays (seat);
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)
1649 + ply_text_display_t *display;
1650 + int number_of_columns, number_of_rows;
1652 - if (splash->plugin_interface->set_keyboard == NULL)
1654 + display = ply_list_node_get_data (node);
1655 + next_node = ply_list_get_next_node (displays, node);
1657 - splash->plugin_interface->set_keyboard (splash->plugin, keyboard);
1659 + number_of_columns = ply_text_display_get_number_of_columns (display);
1660 + number_of_rows = ply_text_display_get_number_of_rows (display);
1663 -ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash)
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);
1670 - if (splash->plugin_interface->set_keyboard == NULL)
1672 + splash->plugin_interface->add_text_display (splash->plugin, display);
1674 - splash->plugin_interface->unset_keyboard (splash->plugin, splash->keyboard);
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,
1686 - ply_list_append_data (splash->pixel_displays, display);
1688 - if (splash->plugin_interface->add_pixel_display == NULL)
1691 - splash->plugin_interface->add_pixel_display (splash->plugin, display);
1693 + ply_list_node_t *node;
1696 -ply_boot_splash_remove_pixel_display (ply_boot_splash_t *splash,
1697 - ply_pixel_display_t *display)
1699 - ply_list_remove_data (splash->pixel_displays, display);
1700 + node = ply_list_find_node (splash->seats, seat);
1702 - if (splash->plugin_interface->remove_pixel_display == NULL)
1706 - splash->plugin_interface->remove_pixel_display (splash->plugin, display);
1707 + ply_list_append_data (splash->seats, seat);
1708 + attach_to_seat (splash, seat);
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,
1717 - ply_list_append_data (splash->text_displays, display);
1718 + ply_list_node_t *node;
1720 - if (splash->plugin_interface->add_text_display == NULL)
1722 + node = ply_list_find_node (splash->seats, seat);
1724 - splash->plugin_interface->add_text_display (splash->plugin, display);
1728 -ply_boot_splash_remove_text_display (ply_boot_splash_t *splash,
1729 - ply_text_display_t *display)
1731 - ply_list_remove_data (splash->text_displays, display);
1733 - if (splash->plugin_interface->remove_pixel_display == NULL)
1737 - splash->plugin_interface->remove_text_display (splash->plugin, display);
1738 + ply_list_remove_data (splash->seats, seat);
1739 + detach_from_seat (splash, seat);
1743 @@ -432,56 +391,24 @@ ply_boot_splash_unload (ply_boot_splash_t *splash)
1747 -remove_displays (ply_boot_splash_t *splash)
1748 +detach_from_seats (ply_boot_splash_t *splash)
1750 - ply_list_node_t *node, *next_node;
1751 + ply_list_node_t *node;
1753 - ply_trace ("removing pixel displays");
1754 + ply_trace ("detaching from seats");
1756 - node = ply_list_get_first_node (splash->pixel_displays);
1757 + node = ply_list_get_first_node (splash->seats);
1758 while (node != NULL)
1760 - ply_pixel_display_t *display;
1762 ply_list_node_t *next_node;
1763 - unsigned long width, height;
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);
1770 - width = ply_pixel_display_get_width (display);
1771 - height = ply_pixel_display_get_height (display);
1772 + detach_from_seat (splash, seat);
1774 - ply_trace ("Removing %lux%lu pixel display", width, height);
1776 - if (splash->plugin_interface->remove_pixel_display != NULL)
1777 - splash->plugin_interface->remove_pixel_display (splash->plugin, display);
1779 - ply_trace ("Removing node");
1780 - ply_list_remove_node (splash->pixel_displays, node);
1785 - ply_trace ("removing text displays");
1786 - node = ply_list_get_first_node (splash->text_displays);
1787 - while (node != NULL)
1789 - ply_text_display_t *display;
1790 - int number_of_columns, number_of_rows;
1792 - display = ply_list_node_get_data (node);
1793 - next_node = ply_list_get_next_node (splash->text_displays, node);
1795 - number_of_columns = ply_text_display_get_number_of_columns (display);
1796 - number_of_rows = ply_text_display_get_number_of_rows (display);
1798 - ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
1800 - if (splash->plugin_interface->remove_text_display != NULL)
1801 - splash->plugin_interface->remove_text_display (splash->plugin, display);
1803 - ply_trace ("Removing node");
1804 - ply_list_remove_node (splash->text_displays, node);
1805 + ply_list_remove_node (splash->seats, node);
1809 @@ -508,9 +435,8 @@ ply_boot_splash_free (ply_boot_splash_t *splash)
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);
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,
1825 - if (ply_list_get_length (splash->pixel_displays) >= 1)
1827 - ply_terminal_t *terminal;
1829 - terminal = find_local_console_terminal (splash);
1831 - if (terminal != NULL)
1832 - ply_terminal_set_mode (terminal, PLY_TERMINAL_MODE_TEXT);
1835 splash->mode = PLY_BOOT_SPLASH_MODE_INVALID;
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);
1842 -#ifdef PLY_BOOT_SPLASH_ENABLE_TEST
1846 -#include "ply-event-loop.h"
1847 -#include "ply-boot-splash.h"
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;
1857 -on_timeout (ply_boot_splash_t *splash)
1859 - ply_boot_splash_update_status (splash, "foo");
1860 - ply_event_loop_watch_for_timeout (splash->loop,
1862 - (ply_event_loop_timeout_handler_t)
1868 -on_quit (test_state_t *state)
1870 - ply_boot_splash_hide (state->splash);
1871 - ply_event_loop_exit (state->loop, 0);
1875 -add_displays_to_splash_from_renderer (test_state_t *state,
1876 - ply_renderer_t *renderer)
1878 - ply_list_t *heads;
1879 - ply_list_node_t *node;
1881 - heads = ply_renderer_get_heads (renderer);
1883 - node = ply_list_get_first_node (heads);
1884 - while (node != NULL)
1886 - ply_list_node_t *next_node;
1887 - ply_renderer_head_t *head;
1888 - ply_pixel_display_t *display;
1890 - head = ply_list_node_get_data (node);
1891 - next_node = ply_list_get_next_node (heads, node);
1893 - display = ply_pixel_display_new (renderer, head);
1895 - ply_boot_splash_add_pixel_display (state->splash, display);
1906 - test_state_t state;
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;
1916 - state.loop = ply_event_loop_new ();
1919 - theme_path = argv[1];
1921 - theme_path = PLYMOUTH_THEME_PATH "/fade-in/fade-in.plymouth";
1924 - asprintf(&tty_name, "tty%s", argv[2]);
1926 - tty_name = strdup("tty0");
1928 - terminal = ply_terminal_new (tty_name);
1930 - if (!ply_terminal_open (terminal))
1932 - perror ("could not open tty");
1936 - renderer = ply_renderer_new (NULL, terminal);
1939 - if (!ply_renderer_open (renderer))
1941 - perror ("could not open renderer /dev/fb");
1942 - ply_renderer_free (renderer);
1946 - keyboard = ply_keyboard_new_for_renderer (renderer);
1947 - ply_keyboard_add_escape_handler (keyboard,
1948 - (ply_keyboard_escape_handler_t) on_quit, &state);
1950 - state.buffer = ply_buffer_new ();
1951 - state.splash = ply_boot_splash_new (theme_path, PLYMOUTH_PLUGIN_PATH, state.buffer);
1953 - if (!ply_boot_splash_load (state.splash))
1955 - perror ("could not load splash screen");
1959 - ply_boot_splash_set_keyboard (state.splash, keyboard);
1960 - add_displays_to_splash_from_renderer (&state, renderer);
1962 - text_display = ply_text_display_new (terminal);
1963 - ply_boot_splash_add_text_display (state.splash, text_display);
1965 - ply_boot_splash_attach_to_event_loop (state.splash, state.loop);
1967 - if (!ply_boot_splash_show (state.splash, PLY_BOOT_SPLASH_MODE_BOOT_UP))
1969 - perror ("could not show splash screen");
1973 - ply_event_loop_watch_for_timeout (state.loop,
1975 - (ply_event_loop_timeout_handler_t)
1978 - exit_code = ply_event_loop_run (state.loop);
1979 - ply_boot_splash_free (state.splash);
1980 - ply_buffer_free (state.buffer);
1985 -#endif /* PLY_BOOT_SPLASH_ENABLE_TEST */
1986 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
1987 diff --git a/src/libply-splash-core/ply-boot-splash.h b/src/libply-splash-core/ply-boot-splash.h
1988 index a79e939..335039b 100644
1989 --- a/src/libply-splash-core/ply-boot-splash.h
1990 +++ b/src/libply-splash-core/ply-boot-splash.h
1992 #include "ply-pixel-display.h"
1993 #include "ply-text-display.h"
1994 #include "ply-progress.h"
1995 +#include "ply-seat.h"
1997 #include "ply-boot-splash-plugin.h"
1999 typedef struct _ply_boot_splash ply_boot_splash_t;
2000 +typedef struct _ply_seat ply_seat_t;
2002 typedef void (* ply_boot_splash_on_idle_handler_t) (void *user_data);
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);
2026 diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
2027 new file mode 100644
2028 index 0000000..dbc203d
2030 +++ b/src/libply-splash-core/ply-device-manager.c
2032 +/* ply-device-manager.c - device manager
2034 + * Copyright (C) 2013 Red Hat, Inc.
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.
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.
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.
2051 +#include "config.h"
2052 +#include "ply-device-manager.h"
2054 +#include <assert.h>
2056 +#include <stdbool.h>
2057 +#include <stdlib.h>
2059 +#include <string.h>
2060 +#include <sys/inotify.h>
2061 +#include <sys/stat.h>
2062 +#include <sys/types.h>
2064 +#include <libudev.h>
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"
2072 +#define SUBSYSTEM_DRM "drm"
2073 +#define SUBSYSTEM_FRAME_BUFFER "graphics"
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
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;
2093 + ply_seat_added_handler_t seat_added_handler;
2094 + ply_seat_removed_handler_t seat_removed_handler;
2095 + void *seat_event_handler_data;
2099 +detach_from_event_loop (ply_device_manager_t *manager)
2101 + assert (manager != NULL);
2103 + manager->loop = NULL;
2107 +attach_to_event_loop (ply_device_manager_t *manager,
2108 + ply_event_loop_t *loop)
2110 + assert (manager != NULL);
2111 + assert (loop != NULL);
2112 + assert (manager->loop == NULL);
2114 + manager->loop = loop;
2116 + ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
2117 + detach_from_event_loop,
2122 +device_is_for_local_console (ply_device_manager_t *manager,
2123 + struct udev_device *device)
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;
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);
2137 + boot_vga = udev_device_get_sysattr_value (bus_device, "boot_vga");
2138 + free (bus_device_path);
2140 + if (boot_vga != NULL && strcmp (boot_vga, "1") == 0)
2141 + for_local_console = true;
2143 + for_local_console = false;
2145 + return for_local_console;
2149 +fb_device_has_drm_device (ply_device_manager_t *manager,
2150 + struct udev_device *fb_device)
2152 + struct udev_enumerate *card_matches;
2153 + struct udev_list_entry *card_entry;
2154 + const char *id_path;
2155 + bool has_drm_device = false;
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);
2166 + ply_trace ("trying to find associated drm node for fb device (path: %s)", id_path);
2168 + udev_enumerate_scan_devices (card_matches);
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);
2174 + if (card_entry != NULL)
2176 + struct udev_device *card_device = NULL;
2177 + const char *card_node;
2178 + const char *card_path;
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;
2186 + ply_trace ("no card node!");
2188 + udev_device_unref (card_device);
2192 + ply_trace ("no card entry!");
2195 + udev_enumerate_unref (card_matches);
2196 + return has_drm_device;
2200 +create_seat_for_udev_device (ply_device_manager_t *manager,
2201 + struct udev_device *device)
2203 + bool for_local_console;
2204 + const char *device_path;
2205 + ply_terminal_t *terminal = NULL;
2207 + for_local_console = device_is_for_local_console (manager, device);
2209 + ply_trace ("device is for local console: %s", for_local_console? "yes" : "no");
2211 + if (for_local_console)
2212 + terminal = manager->local_console_terminal;
2214 + device_path = udev_device_get_devnode (device);
2216 + if (device_path != NULL)
2218 + const char *subsystem;
2219 + ply_renderer_type_t renderer_type = PLY_RENDERER_TYPE_NONE;
2221 + subsystem = udev_device_get_subsystem (device);
2222 + ply_trace ("device subsystem is %s", subsystem);
2224 + if (subsystem != NULL && strcmp (subsystem, SUBSYSTEM_DRM) == 0)
2226 + ply_trace ("found DRM device %s", device_path);
2227 + renderer_type = PLY_RENDERER_TYPE_DRM;
2229 + else if (strcmp (subsystem, SUBSYSTEM_FRAME_BUFFER) == 0)
2231 + ply_trace ("found frame buffer device %s", device_path);
2232 + if (!fb_device_has_drm_device (manager, device))
2234 + renderer_type = PLY_RENDERER_TYPE_FRAME_BUFFER;
2238 + ply_trace ("ignoring, since there's a DRM device associated with it");
2242 + if (renderer_type != PLY_RENDERER_TYPE_NONE)
2243 + create_seat_for_terminal_and_renderer_type (manager,
2251 +free_seat_from_device_path (ply_device_manager_t *manager,
2252 + const char *device_path)
2254 + ply_list_node_t *node;
2256 + node = ply_list_get_first_node (manager->seats);
2257 + while (node != NULL)
2260 + ply_renderer_t *renderer;
2261 + ply_list_node_t *next_node;
2262 + const char *renderer_device_path;
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);
2268 + if (renderer != NULL)
2270 + renderer_device_path = ply_renderer_get_device_name (renderer);
2272 + if (renderer_device_path != NULL)
2274 + if (strcmp (device_path, renderer_device_path) == 0)
2276 + ply_trace ("removing seat associated with %s", device_path);
2278 + if (manager->seat_removed_handler != NULL)
2279 + manager->seat_removed_handler (manager->seat_event_handler_data, seat);
2281 + ply_seat_free (seat);
2282 + ply_list_remove_node (manager->seats, node);
2293 +free_seat_for_udev_device (ply_device_manager_t *manager,
2294 + struct udev_device *device)
2296 + const char *device_path;
2298 + device_path = udev_device_get_devnode (device);
2300 + if (device_path != NULL)
2301 + free_seat_from_device_path (manager, device_path);
2305 +create_seats_for_subsystem (ply_device_manager_t *manager,
2306 + const char *subsystem)
2308 + struct udev_enumerate *matches;
2309 + struct udev_list_entry *entry;
2310 + bool found_device = false;
2312 + ply_trace ("creating seats for %s devices",
2313 + strcmp (subsystem, SUBSYSTEM_FRAME_BUFFER) == 0?
2317 + matches = udev_enumerate_new (manager->udev_context);
2318 + udev_enumerate_add_match_subsystem (matches, subsystem);
2319 + udev_enumerate_scan_devices (matches);
2321 + udev_list_entry_foreach (entry, udev_enumerate_get_list_entry (matches))
2323 + struct udev_device *device = NULL;
2326 + path = udev_list_entry_get_name (entry);
2330 + ply_trace ("path was null!");
2334 + ply_trace ("found device %s", path);
2336 + device = udev_device_new_from_syspath (manager->udev_context, path);
2338 + /* if device isn't fully initialized, we'll get an add event later
2340 + if (udev_device_get_is_initialized (device))
2342 + ply_trace ("device is initialized");
2344 + /* We only care about devices assigned to a (any) seat. Floating
2345 + * devices should be ignored.
2347 + if (udev_device_has_tag (device, "seat"))
2350 + node = udev_device_get_devnode (device);
2353 + ply_trace ("found node %s", node);
2354 + found_device = true;
2355 + create_seat_for_udev_device (manager, device);
2360 + ply_trace ("device doesn't have a seat tag");
2365 + ply_trace ("it's not initialized");
2368 + udev_device_unref (device);
2371 + udev_enumerate_unref (matches);
2373 + return found_device;
2377 +on_udev_event (ply_device_manager_t *manager)
2379 + struct udev_device *device;
2380 + const char *action;
2382 + device = udev_monitor_receive_device (manager->udev_monitor);
2383 + if (device == NULL)
2386 + action = udev_device_get_action (device);
2388 + ply_trace ("got %s event for device %s", action, udev_device_get_sysname (device));
2390 + if (action == NULL)
2393 + if (strcmp (action, "add") == 0)
2395 + const char *subsystem;
2396 + bool coldplug_complete = manager->udev_queue_fd_watch == NULL;
2398 + subsystem = udev_device_get_subsystem (device);
2400 + if (strcmp (subsystem, SUBSYSTEM_DRM) == 0 ||
2401 + coldplug_complete)
2403 + create_seat_for_udev_device (manager, device);
2407 + ply_trace ("ignoring since we only handle subsystem %s devices after coldplug completes", subsystem);
2410 + else if (strcmp (action, "remove") == 0)
2412 + free_seat_for_udev_device (manager, device);
2415 + udev_device_unref (device);
2419 +watch_for_udev_events (ply_device_manager_t *manager)
2422 + assert (manager != NULL);
2423 + assert (manager->udev_monitor == NULL);
2425 + ply_trace ("watching for udev graphics device add and remove events");
2427 + manager->udev_monitor = udev_monitor_new_from_netlink (manager->udev_context, "udev");
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);
2434 + fd = udev_monitor_get_fd (manager->udev_monitor);
2435 + ply_event_loop_watch_fd (manager->loop,
2437 + PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
2438 + (ply_event_handler_t)
2445 +free_seats (ply_device_manager_t *manager)
2447 + ply_list_node_t *node;
2449 + ply_trace ("removing seats");
2450 + node = ply_list_get_first_node (manager->seats);
2451 + while (node != NULL)
2454 + ply_list_node_t *next_node;
2456 + seat = ply_list_node_get_data (node);
2457 + next_node = ply_list_get_next_node (manager->seats, node);
2459 + if (manager->seat_removed_handler != NULL)
2460 + manager->seat_removed_handler (manager->seat_event_handler_data, seat);
2462 + ply_seat_free (seat);
2463 + ply_list_remove_node (manager->seats, node);
2470 +free_terminal (char *device,
2471 + ply_terminal_t *terminal,
2472 + ply_device_manager_t *manager)
2474 + ply_hashtable_remove (manager->terminals, device);
2476 + ply_terminal_close (terminal);
2477 + ply_terminal_free (terminal);
2481 +free_terminals (ply_device_manager_t *manager)
2483 + ply_hashtable_foreach (manager->terminals,
2484 + (ply_hashtable_foreach_func_t *)
2489 +static ply_terminal_t *
2490 +get_terminal (ply_device_manager_t *manager,
2491 + const char *device_name)
2493 + char *full_name = NULL;
2494 + ply_terminal_t *terminal;
2496 + if (strncmp (device_name, "/dev/", strlen ("/dev/")) == 0)
2497 + full_name = strdup (device_name);
2499 + asprintf (&full_name, "/dev/%s", device_name);
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)
2505 + terminal = manager->local_console_terminal;
2509 + terminal = ply_hashtable_lookup (manager->terminals, full_name);
2511 + if (terminal == NULL)
2513 + terminal = ply_terminal_new (full_name);
2515 + ply_hashtable_insert (manager->terminals,
2516 + (void *) ply_terminal_get_name (terminal),
2525 +ply_device_manager_t *
2526 +ply_device_manager_new (const char *default_tty,
2527 + ply_device_manager_flags_t flags)
2529 + ply_device_manager_t *manager;
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;
2541 + if (!(flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV))
2542 + manager->udev_context = udev_new ();
2544 + attach_to_event_loop (manager, ply_event_loop_get_default ());
2550 +ply_device_manager_free (ply_device_manager_t *manager)
2552 + ply_trace ("freeing device manager");
2554 + if (manager == NULL)
2557 + ply_event_loop_stop_watching_for_exit (manager->loop,
2558 + (ply_event_loop_exit_handler_t)
2559 + detach_from_event_loop,
2561 + free_seats (manager);
2562 + ply_list_free (manager->seats);
2564 + free_terminals (manager);
2565 + ply_hashtable_free (manager->terminals);
2567 + if (manager->udev_monitor != NULL)
2568 + udev_monitor_unref (manager->udev_monitor);
2570 + if (manager->udev_context != NULL)
2571 + udev_unref (manager->udev_context);
2577 +add_consoles_from_file (ply_device_manager_t *manager,
2581 + char contents[512] = "";
2582 + ssize_t contents_length;
2583 + bool has_serial_consoles;
2584 + const char *remaining_file_contents;
2586 + ply_trace ("opening %s", path);
2587 + fd = open (path, O_RDONLY);
2591 + ply_trace ("couldn't open it: %m");
2595 + ply_trace ("reading file");
2596 + contents_length = read (fd, contents, sizeof (contents) - 1);
2598 + if (contents_length <= 0)
2600 + ply_trace ("couldn't read it: %m");
2606 + remaining_file_contents = contents;
2607 + has_serial_consoles = false;
2609 + while (remaining_file_contents < contents + contents_length)
2612 + size_t console_length;
2613 + const char *console_device;
2614 + ply_terminal_t *terminal;
2616 + /* Advance past any leading whitespace */
2617 + remaining_file_contents += strspn (remaining_file_contents, " \n\t\v");
2619 + if (*remaining_file_contents == '\0')
2621 + /* There's nothing left after the whitespace, we're done */
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);
2632 + terminal = get_terminal (manager, console);
2633 + console_device = ply_terminal_get_name (terminal);
2637 + ply_trace ("console %s found!", console_device);
2639 + if (terminal != manager->local_console_terminal)
2640 + has_serial_consoles = true;
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
2647 + remaining_file_contents += console_length + 1;
2650 + return has_serial_consoles;
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)
2660 + bool is_local_terminal = false;
2662 + if (terminal != NULL && manager->local_console_terminal == terminal)
2663 + is_local_terminal = true;
2665 + if (is_local_terminal && manager->local_console_seat != NULL)
2667 + ply_trace ("trying to create seat for local console when one already exists");
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);
2675 + if (!ply_seat_open (seat, renderer_type, device_path))
2677 + ply_trace ("could not create seat");
2678 + ply_seat_free (seat);
2682 + ply_list_append_data (manager->seats, seat);
2684 + if (is_local_terminal)
2685 + manager->local_console_seat = seat;
2687 + if (manager->seat_added_handler != NULL)
2688 + manager->seat_added_handler (manager->seat_event_handler_data, seat);
2692 +create_seat_for_terminal (const char *device_path,
2693 + ply_terminal_t *terminal,
2694 + ply_device_manager_t *manager)
2696 + create_seat_for_terminal_and_renderer_type (manager,
2699 + PLY_RENDERER_TYPE_NONE);
2702 +create_seats_from_terminals (ply_device_manager_t *manager)
2704 + bool has_serial_consoles;
2706 + ply_trace ("checking for consoles");
2708 + if (manager->flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES)
2710 + has_serial_consoles = false;
2711 + ply_trace ("ignoring all consoles but default console because explicitly told to.");
2715 + has_serial_consoles = add_consoles_from_file (manager, "/sys/class/tty/console/active");
2718 + if (has_serial_consoles)
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,
2732 +create_seats_from_udev (ply_device_manager_t *manager)
2734 + bool found_drm_device, found_fb_device;
2736 + ply_trace ("Looking for devices from udev");
2738 + found_drm_device = create_seats_for_subsystem (manager, SUBSYSTEM_DRM);
2739 + found_fb_device = create_seats_for_subsystem (manager, SUBSYSTEM_FRAME_BUFFER);
2741 + if (found_drm_device || found_fb_device)
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);
2752 +create_fallback_seat (ply_device_manager_t *manager)
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);
2761 +on_udev_queue_changed (ply_device_manager_t *manager)
2764 + if (!udev_queue_get_queue_is_empty (manager->udev_queue))
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);
2772 + close (manager->udev_queue_fd);
2773 + manager->udev_queue_fd = -1;
2775 + manager->udev_queue = NULL;
2777 + create_seats_from_udev (manager);
2781 +watch_for_coldplug_completion (ply_device_manager_t *manager)
2786 + manager->udev_queue = udev_queue_new (manager->udev_context);
2788 + if (udev_queue_get_queue_is_empty (manager->udev_queue))
2790 + ply_trace ("udev coldplug completed already ");
2791 + create_seats_from_udev (manager);
2795 + fd = inotify_init1 (IN_CLOEXEC);
2796 + result = inotify_add_watch (fd, "/run/udev", IN_MOVED_TO);
2800 + ply_trace ("could not watch for udev to show up: %m");
2803 + create_fallback_seat (manager);
2807 + manager->udev_queue_fd = fd;
2809 + manager->udev_queue_fd_watch = ply_event_loop_watch_fd (manager->loop,
2811 + PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
2812 + (ply_event_handler_t)
2813 + on_udev_queue_changed,
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,
2825 + bool done_with_initial_seat_setup;
2827 + manager->seat_added_handler = seat_added_handler;
2828 + manager->seat_removed_handler = seat_removed_handler;
2829 + manager->seat_event_handler_data = data;
2831 + /* Try to create seats for each serial device right away, if possible
2833 + done_with_initial_seat_setup = create_seats_from_terminals (manager);
2835 + if (done_with_initial_seat_setup)
2838 + if ((manager->flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV))
2840 + ply_trace ("udev support disabled, creating fallback seat");
2841 + create_fallback_seat (manager);
2845 + watch_for_udev_events (manager);
2846 + watch_for_coldplug_completion (manager);
2850 +ply_device_manager_has_open_seats (ply_device_manager_t *manager)
2852 + ply_list_node_t *node;
2854 + node = ply_list_get_first_node (manager->seats);
2855 + while (node != NULL)
2858 + ply_list_node_t *next_node;
2860 + seat = ply_list_node_get_data (node);
2861 + next_node = ply_list_get_next_node (manager->seats, node);
2863 + if (ply_seat_is_open (seat))
2873 +ply_device_manager_get_seats (ply_device_manager_t *manager)
2875 + return manager->seats;
2879 +ply_device_manager_get_default_terminal (ply_device_manager_t *manager)
2881 + return manager->local_console_terminal;
2885 +ply_device_manager_activate_renderers (ply_device_manager_t *manager)
2887 + ply_list_node_t *node;
2889 + ply_trace ("activating renderers");
2890 + node = ply_list_get_first_node (manager->seats);
2891 + while (node != NULL)
2894 + ply_list_node_t *next_node;
2896 + seat = ply_list_node_get_data (node);
2897 + next_node = ply_list_get_next_node (manager->seats, node);
2899 + ply_seat_activate_renderer (seat);
2906 +ply_device_manager_deactivate_renderers (ply_device_manager_t *manager)
2908 + ply_list_node_t *node;
2910 + ply_trace ("deactivating renderers");
2911 + node = ply_list_get_first_node (manager->seats);
2912 + while (node != NULL)
2915 + ply_list_node_t *next_node;
2917 + seat = ply_list_node_get_data (node);
2918 + next_node = ply_list_get_next_node (manager->seats, node);
2920 + ply_seat_deactivate_renderer (seat);
2927 +ply_device_manager_activate_keyboards (ply_device_manager_t *manager)
2929 + ply_list_node_t *node;
2931 + ply_trace ("activating keyboards");
2932 + node = ply_list_get_first_node (manager->seats);
2933 + while (node != NULL)
2936 + ply_list_node_t *next_node;
2938 + seat = ply_list_node_get_data (node);
2939 + next_node = ply_list_get_next_node (manager->seats, node);
2941 + ply_seat_activate_keyboard (seat);
2948 +ply_device_manager_deactivate_keyboards (ply_device_manager_t *manager)
2950 + ply_list_node_t *node;
2952 + ply_trace ("deactivating keyboards");
2953 + node = ply_list_get_first_node (manager->seats);
2954 + while (node != NULL)
2957 + ply_list_node_t *next_node;
2959 + seat = ply_list_node_get_data (node);
2960 + next_node = ply_list_get_next_node (manager->seats, node);
2962 + ply_seat_deactivate_keyboard (seat);
2967 diff --git a/src/libply-splash-core/ply-device-manager.h b/src/libply-splash-core/ply-device-manager.h
2968 new file mode 100644
2969 index 0000000..d9c58e8
2971 +++ b/src/libply-splash-core/ply-device-manager.h
2973 +/* ply-device-manager.h - udev monitor
2975 + * Copyright (C) 2013 Red Hat, Inc.
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.
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.
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.
2992 +#ifndef PLY_DEVICE_MANAGER_H
2993 +#define PLY_DEVICE_MANAGER_H
2995 +#include <stdbool.h>
2996 +#include "ply-seat.h"
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;
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 *);
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,
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);
3028 +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
3029 diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c
3030 index 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,
3037 +ply_pixel_buffer_t *
3038 +ply_pixel_buffer_tile (ply_pixel_buffer_t *old_buffer,
3043 + long old_x, old_y;
3044 + long old_width, old_height;
3045 + uint32_t *bytes, *old_bytes;
3046 + ply_pixel_buffer_t *buffer;
3048 + buffer = ply_pixel_buffer_new (width, height);
3050 + old_bytes = ply_pixel_buffer_get_argb32_data (old_buffer);
3051 + bytes = ply_pixel_buffer_get_argb32_data (buffer);
3053 + old_width = old_buffer->area.width;
3054 + old_height = old_buffer->area.height;
3056 + for (y = 0; y < height; y++)
3058 + old_y = y % old_height;
3059 + for (x = 0; x < width; x++)
3061 + old_x = x % old_width;
3062 + bytes[x + y * width] = old_bytes[old_x + old_y * old_width];
3068 /* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
3069 diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h
3070 index 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,
3075 double theta_offset);
3077 +ply_pixel_buffer_t *ply_pixel_buffer_tile (ply_pixel_buffer_t *old_buffer,
3083 #endif /* PLY_PIXEL_BUFFER_H */
3084 diff --git a/src/libply-splash-core/ply-renderer.c b/src/libply-splash-core/ply-renderer.c
3085 index 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;
3092 - char *plugin_path;
3093 + ply_renderer_type_t type;
3095 ply_terminal_t *terminal;
3097 @@ -63,16 +63,15 @@ typedef const ply_renderer_plugin_interface_t *
3098 static void ply_renderer_unload_plugin (ply_renderer_t *renderer);
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)
3108 ply_renderer_t *renderer;
3110 renderer = calloc (1, sizeof (struct _ply_renderer));
3112 - if (plugin_path != NULL)
3113 - renderer->plugin_path = strdup (plugin_path);
3114 + renderer->type = renderer_type;
3116 if (device_name != NULL)
3117 renderer->device_name = strdup (device_name);
3118 @@ -95,10 +94,15 @@ ply_renderer_free (ply_renderer_t *renderer)
3121 free (renderer->device_name);
3122 - free (renderer->plugin_path);
3127 +ply_renderer_get_device_name (ply_renderer_t *renderer)
3129 + return renderer->device_name;
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)
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)
3143 - const char *known_plugins[] =
3146 - PLYMOUTH_PLUGIN_PATH "renderers/x11.so",
3147 - PLYMOUTH_PLUGIN_PATH "renderers/drm.so",
3148 - PLYMOUTH_PLUGIN_PATH "renderers/frame-buffer.so",
3150 + ply_renderer_type_t type;
3152 + } known_plugins[] =
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 }
3160 - if (renderer->plugin_path != NULL)
3161 + for (i = 0; known_plugins[i].type != PLY_RENDERER_TYPE_NONE; i++)
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)
3167 + if (ply_renderer_open_plugin (renderer, known_plugins[i].path))
3172 - for (i = 0; known_plugins[i] != NULL; i++)
3174 - if (ply_renderer_open_plugin (renderer, known_plugins[i]))
3178 ply_trace ("could not find suitable rendering plugin");
3181 diff --git a/src/libply-splash-core/ply-renderer.h b/src/libply-splash-core/ply-renderer.h
3182 index 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;
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;
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);
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);
3216 diff --git a/src/libply-splash-core/ply-seat.c b/src/libply-splash-core/ply-seat.c
3217 new file mode 100644
3218 index 0000000..2ac8bf7
3220 +++ b/src/libply-splash-core/ply-seat.c
3222 +/* ply-seat.c - APIs for encapsulating a keyboard and one or more displays
3224 + * Copyright (C) 2013 Red Hat, Inc.
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.
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.
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.
3241 + * Written by: Ray Strode <rstrode@redhat.com>
3243 +#include "config.h"
3244 +#include "ply-seat.h"
3246 +#include <assert.h>
3248 +#include <stdint.h>
3250 +#include <stdlib.h>
3251 +#include <unistd.h>
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"
3264 + ply_event_loop_t *loop;
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;
3273 + uint32_t renderer_active : 1;
3274 + uint32_t keyboard_active : 1;
3278 +ply_seat_new (ply_terminal_t *terminal)
3282 + seat = calloc (1, sizeof (ply_seat_t));
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 ();
3293 +add_pixel_displays (ply_seat_t *seat)
3295 + ply_list_t *heads;
3296 + ply_list_node_t *node;
3298 + heads = ply_renderer_get_heads (seat->renderer);
3300 + ply_trace ("Adding displays for %d heads",
3301 + ply_list_get_length (heads));
3303 + node = ply_list_get_first_node (heads);
3304 + while (node != NULL)
3306 + ply_list_node_t *next_node;
3307 + ply_renderer_head_t *head;
3308 + ply_pixel_display_t *display;
3310 + head = ply_list_node_get_data (node);
3311 + next_node = ply_list_get_next_node (heads, node);
3313 + display = ply_pixel_display_new (seat->renderer, head);
3315 + ply_list_append_data (seat->pixel_displays, display);
3322 +add_text_displays (ply_seat_t *seat)
3324 + ply_text_display_t *display;
3326 + if (!ply_terminal_is_open (seat->terminal))
3328 + if (!ply_terminal_open (seat->terminal))
3330 + ply_trace ("could not add terminal %s: %m",
3331 + ply_terminal_get_name (seat->terminal));
3336 + ply_trace ("adding text display for terminal %s",
3337 + ply_terminal_get_name (seat->terminal));
3339 + display = ply_text_display_new (seat->terminal);
3340 + ply_list_append_data (seat->text_displays, display);
3344 +ply_seat_open (ply_seat_t *seat,
3345 + ply_renderer_type_t renderer_type,
3346 + const char *device)
3348 + if (renderer_type != PLY_RENDERER_TYPE_NONE)
3350 + ply_renderer_t *renderer;
3352 + renderer = ply_renderer_new (renderer_type, device, seat->terminal);
3354 + if (!ply_renderer_open (renderer))
3356 + ply_trace ("could not open renderer for %s", device);
3357 + ply_renderer_free (renderer);
3359 + seat->renderer = NULL;
3360 + seat->renderer_active = false;
3362 + if (renderer_type != PLY_RENDERER_TYPE_AUTO)
3367 + seat->renderer = renderer;
3368 + seat->renderer_active = true;
3372 + if (seat->renderer != NULL)
3374 + seat->keyboard = ply_keyboard_new_for_renderer (seat->renderer);
3375 + add_pixel_displays (seat);
3380 + seat->keyboard = ply_keyboard_new_for_terminal (seat->terminal);
3382 + add_text_displays (seat);
3384 + ply_keyboard_watch_for_input (seat->keyboard);
3385 + seat->keyboard_active = true;
3391 +ply_seat_is_open (ply_seat_t *seat)
3393 + return ply_list_get_length (seat->pixel_displays) > 0 ||
3394 + ply_list_get_length (seat->text_displays) > 0;
3398 +ply_seat_deactivate_keyboard (ply_seat_t *seat)
3400 + if (!seat->keyboard_active)
3403 + seat->keyboard_active = false;
3405 + if (seat->keyboard == NULL)
3408 + ply_trace ("deactivating keybord");
3409 + ply_keyboard_stop_watching_for_input (seat->keyboard);
3413 +ply_seat_deactivate_renderer (ply_seat_t *seat)
3415 + if (!seat->renderer_active)
3418 + seat->renderer_active = false;
3420 + if (seat->renderer == NULL)
3423 + ply_trace ("deactivating renderer");
3424 + ply_renderer_deactivate (seat->renderer);
3428 +ply_seat_activate_keyboard (ply_seat_t *seat)
3430 + if (seat->keyboard_active)
3433 + if (seat->keyboard == NULL)
3436 + ply_trace ("activating keyboard");
3437 + ply_keyboard_watch_for_input (seat->keyboard);
3439 + seat->keyboard_active = true;
3443 +ply_seat_activate_renderer (ply_seat_t *seat)
3445 + if (seat->renderer_active)
3448 + if (seat->renderer == NULL)
3451 + ply_trace ("activating renderer");
3452 + ply_renderer_activate (seat->renderer);
3454 + seat->renderer_active = true;
3458 +ply_seat_refresh_displays (ply_seat_t *seat)
3460 + ply_list_node_t *node;
3462 + node = ply_list_get_first_node (seat->pixel_displays);
3463 + while (node != NULL)
3465 + ply_pixel_display_t *display;
3466 + ply_list_node_t *next_node;
3467 + unsigned long width, height;
3469 + display = ply_list_node_get_data (node);
3470 + next_node = ply_list_get_next_node (seat->pixel_displays, node);
3472 + width = ply_pixel_display_get_width (display);
3473 + height = ply_pixel_display_get_height (display);
3475 + ply_pixel_display_draw_area (display, 0, 0, width, height);
3479 + node = ply_list_get_first_node (seat->text_displays);
3480 + while (node != NULL)
3482 + ply_text_display_t *display;
3483 + ply_list_node_t *next_node;
3484 + int number_of_columns, number_of_rows;
3486 + display = ply_list_node_get_data (node);
3487 + next_node = ply_list_get_next_node (seat->text_displays, node);
3489 + number_of_columns = ply_text_display_get_number_of_columns (display);
3490 + number_of_rows = ply_text_display_get_number_of_rows (display);
3492 + ply_text_display_draw_area (display, 0, 0,
3493 + number_of_columns,
3500 +ply_seat_close (ply_seat_t *seat)
3502 + if (seat->renderer == NULL)
3505 + ply_trace ("destroying renderer");
3506 + ply_renderer_close (seat->renderer);
3507 + ply_renderer_free (seat->renderer);
3508 + seat->renderer = NULL;
3512 +ply_seat_set_splash (ply_seat_t *seat,
3513 + ply_boot_splash_t *splash)
3515 + if (seat->splash == splash)
3518 + if (seat->splash != NULL)
3519 + ply_boot_splash_detach_from_seat (splash, seat);
3521 + if (splash != NULL)
3522 + ply_boot_splash_attach_to_seat (splash, seat);
3524 + seat->splash = splash;
3528 +free_pixel_displays (ply_seat_t *seat)
3530 + ply_list_node_t *node;
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)
3536 + ply_list_node_t *next_node;
3537 + ply_pixel_display_t *display;
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);
3543 + ply_list_remove_node (seat->pixel_displays, node);
3550 +free_text_displays (ply_seat_t *seat)
3552 + ply_list_node_t *node;
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)
3558 + ply_list_node_t *next_node;
3559 + ply_text_display_t *display;
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);
3565 + ply_list_remove_node (seat->text_displays, node);
3572 +ply_seat_free (ply_seat_t *seat)
3577 + free_pixel_displays (seat);
3578 + free_text_displays (seat);
3579 + ply_keyboard_free (seat->keyboard);
3585 +ply_seat_get_pixel_displays (ply_seat_t *seat)
3587 + return seat->pixel_displays;
3591 +ply_seat_get_text_displays (ply_seat_t *seat)
3593 + return seat->text_displays;
3597 +ply_seat_get_keyboard (ply_seat_t *seat)
3599 + return seat->keyboard;
3603 +ply_seat_get_renderer (ply_seat_t *seat)
3605 + return seat->renderer;
3608 +/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
3609 diff --git a/src/libply-splash-core/ply-seat.h b/src/libply-splash-core/ply-seat.h
3610 new file mode 100644
3611 index 0000000..d5d3397
3613 +++ b/src/libply-splash-core/ply-seat.h
3615 +/* ply-seat.h - APIs for encapsulating a keyboard and one or more displays
3617 + * Copyright (C) 2013 Red Hat, Inc.
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.
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.
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.
3634 + * Written By: Ray Strode <rstrode@redhat.com>
3639 +#include <stdarg.h>
3640 +#include <stdbool.h>
3641 +#include <stdint.h>
3642 +#include <unistd.h>
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"
3653 +typedef struct _ply_boot_splash ply_boot_splash_t;
3654 +typedef struct _ply_seat ply_seat_t;
3656 +#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
3657 +ply_seat_t *ply_seat_new (ply_terminal_t *terminal);
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);
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);
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 */
3681 diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c
3682 index 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)
3690 +ply_terminal_get_name (ply_terminal_t *terminal)
3692 + return terminal->name;
3696 ply_terminal_get_vt_number (ply_terminal_t *terminal)
3698 diff --git a/src/libply-splash-core/ply-terminal.h b/src/libply-splash-core/ply-terminal.h
3699 index 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);
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);
3710 diff --git a/src/libply-splash-core/ply-text-progress-bar.c b/src/libply-splash-core/ply-text-progress-bar.c
3711 index 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)
3718 - fd = open (RELEASE_FILE, O_RDONLY);
3719 + fd = open (RELEASE_FILE, O_RDONLY|O_CLOEXEC);
3723 @@ -136,6 +136,8 @@ get_os_string (void)
3728 + pos2 = pos + strlen(pos) - 1;
3730 if ((*pos == '\"' && pos2[-1] == '\"') ||
3731 (*pos == '\'' && pos2[-1] == '\''))
3732 diff --git a/src/libply-splash-core/ply-text-step-bar.c b/src/libply-splash-core/ply-text-step-bar.c
3733 new file mode 100644
3734 index 0000000..552a39f
3736 +++ b/src/libply-splash-core/ply-text-step-bar.c
3739 + * Copyright (C) 2008-2012 Red Hat, Inc.
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.
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.
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.
3757 +#include "config.h"
3759 +#include <assert.h>
3761 +#include <stdlib.h>
3762 +#include <string.h>
3763 +#include <unistd.h>
3765 +#include "ply-text-display.h"
3766 +#include "ply-text-step-bar.h"
3768 +struct _ply_text_step_bar
3770 + ply_text_display_t *display;
3774 + int number_of_rows;
3775 + int number_of_columns;
3777 + double percent_done;
3778 + uint32_t is_hidden : 1;
3781 +ply_text_step_bar_t *
3782 +ply_text_step_bar_new (void)
3784 + ply_text_step_bar_t *step_bar;
3786 + step_bar = calloc (1, sizeof (ply_text_step_bar_t));
3788 + step_bar->row = 0;
3789 + step_bar->column = 0;
3790 + step_bar->number_of_columns = 0;
3791 + step_bar->number_of_rows = 0;
3797 +ply_text_step_bar_free (ply_text_step_bar_t *step_bar)
3799 + if (step_bar == NULL)
3806 +ply_text_step_bar_draw (ply_text_step_bar_t *step_bar)
3811 + if (step_bar->is_hidden)
3814 + ply_text_display_set_background_color (step_bar->display,
3815 + PLY_TERMINAL_COLOR_BLACK);
3817 + ply_text_display_set_cursor_position (step_bar->display,
3821 + cur = step_bar->percent_done * step_bar->number_of_columns;
3822 + for (i = 0; i < step_bar->number_of_columns; i++)
3826 + ply_text_display_set_foreground_color (step_bar->display,
3827 + PLY_TERMINAL_COLOR_WHITE);
3831 + ply_text_display_set_foreground_color (step_bar->display,
3832 + PLY_TERMINAL_COLOR_BROWN);
3835 + ply_text_display_write (step_bar->display, "%c", '■');
3836 + ply_text_display_write (step_bar->display, "%c", ' ');
3839 + ply_text_display_set_foreground_color (step_bar->display,
3840 + PLY_TERMINAL_COLOR_DEFAULT);
3844 +ply_text_step_bar_show (ply_text_step_bar_t *step_bar,
3845 + ply_text_display_t *display)
3850 + assert (step_bar != NULL);
3852 + step_bar->display = display;
3855 + screen_rows = ply_text_display_get_number_of_rows (display);
3856 + screen_cols = ply_text_display_get_number_of_columns (display);
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;
3863 + step_bar->is_hidden = false;
3865 + ply_text_step_bar_draw (step_bar);
3869 +ply_text_step_bar_hide (ply_text_step_bar_t *step_bar)
3871 + step_bar->display = NULL;
3872 + step_bar->is_hidden = true;
3876 +ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar,
3877 + double percent_done)
3879 + step_bar->percent_done = percent_done;
3883 +ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar)
3885 + return step_bar->percent_done;
3889 +ply_text_step_bar_get_number_of_columns (ply_text_step_bar_t *step_bar)
3891 + return step_bar->number_of_columns;
3895 +ply_text_step_bar_get_number_of_rows (ply_text_step_bar_t *step_bar)
3897 + return step_bar->number_of_rows;
3900 +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
3901 diff --git a/src/libply-splash-core/ply-text-step-bar.h b/src/libply-splash-core/ply-text-step-bar.h
3902 new file mode 100644
3903 index 0000000..0a4733f
3905 +++ b/src/libply-splash-core/ply-text-step-bar.h
3908 + * Copyright (C) 2008-2012 Red Hat, Inc.
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.
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.
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.
3926 +#ifndef PLY_TEXT_STEP_BAR_H
3927 +#define PLY_TEXT_STEP_BAR_H
3929 +#include <unistd.h>
3931 +#include "ply-event-loop.h"
3932 +#include "ply-text-display.h"
3934 +typedef struct _ply_text_step_bar ply_text_step_bar_t;
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);
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);
3945 +void ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar,
3946 + double percent_done);
3948 +double ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar);
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);
3954 +#endif /* PLY_TEXT_PULSER_H */
3955 +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
3956 diff --git a/src/libply-splash-graphics/Makefile.am b/src/libply-splash-graphics/Makefile.am
3957 index f70d1ed..9013e56 100644
3958 --- a/src/libply-splash-graphics/Makefile.am
3959 +++ b/src/libply-splash-graphics/Makefile.am
3961 -INCLUDES = -I$(top_srcdir) \
3962 +AM_CPPFLAGS = -I$(top_srcdir) \
3964 -I$(srcdir)/../libply \
3965 -I$(srcdir)/../libply-splash-core \
3966 diff --git a/src/libply-splash-graphics/ply-animation.c b/src/libply-splash-graphics/ply-animation.c
3967 index 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 ();
3974 -#ifdef REAL_TIME_ANIMATION
3975 should_continue = animate_at_time (animation,
3976 animation->now - animation->start_time);
3978 - static double time = 0.0;
3979 - time += 1.0 / FRAMES_PER_SECOND;
3980 - should_continue = animate_at_time (animation, time);
3983 sleep_time = 1.0 / FRAMES_PER_SECOND;
3984 sleep_time = MAX (sleep_time - (ply_get_timestamp () - animation->now),
3985 diff --git a/src/libply-splash-graphics/ply-image.c b/src/libply-splash-graphics/ply-image.c
3986 index 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)
3991 assert (image != NULL);
3993 - fp = fopen (image->filename, "r");
3994 + fp = fopen (image->filename, "re");
3998 @@ -254,6 +254,21 @@ ply_image_rotate (ply_image_t *image,
4003 +ply_image_tile (ply_image_t *image,
4007 + ply_image_t *new_image;
4009 + new_image = ply_image_new (image->filename);
4011 + new_image->buffer = ply_pixel_buffer_tile (image->buffer,
4017 ply_pixel_buffer_t *
4018 ply_image_get_buffer (ply_image_t *image)
4020 diff --git a/src/libply-splash-graphics/ply-image.h b/src/libply-splash-graphics/ply-image.h
4021 index 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);
4032 diff --git a/src/libply-splash-graphics/ply-throbber.c b/src/libply-splash-graphics/ply-throbber.c
4033 index 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 ();
4040 -#ifdef REAL_TIME_ANIMATION
4041 should_continue = animate_at_time (throbber,
4042 - throbber->now - throbber->start_time);
4044 - static double time = 0.0;
4045 - time += 1.0 / FRAMES_PER_SECOND;
4046 - should_continue = animate_at_time (throbber, time);
4048 + throbber->now - throbber->start_time);
4050 sleep_time = 1.0 / FRAMES_PER_SECOND;
4051 sleep_time = MAX (sleep_time - (ply_get_timestamp () - throbber->now),
4052 diff --git a/src/libply/Makefile.am b/src/libply/Makefile.am
4053 index 302e47d..de15808 100644
4054 --- a/src/libply/Makefile.am
4055 +++ b/src/libply/Makefile.am
4058 -INCLUDES = -I$(top_srcdir) \
4059 +AM_CPPFLAGS = -I$(top_srcdir) \
4061 -DPLYMOUTH_TIME_DIRECTORY=\"$(localstatedir)/lib/plymouth/\"
4063 diff --git a/src/libply/ply-array.c b/src/libply/ply-array.c
4064 index 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)
4071 -#ifdef PLY_ARRAY_ENABLE_TEST
4078 - ply_array_t *array;
4082 - array = ply_array_new (PLY_ARRAY_ELEMENT_TYPE_POINTER);
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");
4089 - data = (char **) ply_array_get_pointer_elements (array);
4090 - for (i = 0; data[i] != NULL; i++)
4092 - printf ("element '%d' has data '%s'\n", i, data[i]);
4096 - ply_array_free (array);
4101 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4102 diff --git a/src/libply/ply-bitarray.c b/src/libply/ply-bitarray.c
4103 index 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,
4113 -#ifdef PLY_BITARRAY_ENABLE_TEST
4120 - ply_bitarray_t *bitarray;
4122 - printf ("bitarray test start\n");
4123 - bitarray = ply_bitarray_new (134);
4125 - for (i=0; i<64; i++)
4127 - if (ply_bitarray_lookup (bitarray, i))
4134 - for (i=0; i<64; i++)
4135 - if ((6654654654654654654ll >> i) & 1)
4136 - ply_bitarray_set (bitarray, i);
4138 - for (i=0; i<64; i++)
4140 - if (ply_bitarray_lookup (bitarray, i))
4147 - for (i = 63; i > 0; i--)
4149 - if ((6654654654654654654ll >> i) & 1)
4151 - ply_bitarray_clear (bitarray, i);
4152 - for (i2 = 0; i2 < 64; i2++)
4154 - if (ply_bitarray_lookup (bitarray, i2))
4163 - ply_bitarray_free (bitarray);
4165 - printf ("bitarray test end\n");
4170 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4171 diff --git a/src/libply/ply-buffer.c b/src/libply/ply-buffer.c
4172 index 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)
4179 -#ifdef PLY_BUFFER_ENABLE_TEST
4185 - ply_buffer_t *buffer;
4188 - buffer = ply_buffer_new ();
4190 - ply_buffer_append (buffer, "yo yo yo\n");
4191 - ply_buffer_free (buffer);
4196 -#endif /* PLY_BUFFER_ENABLE_TEST */
4197 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4198 diff --git a/src/libply/ply-command-parser.c b/src/libply/ply-command-parser.c
4199 index 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;
4206 -#ifdef PLY_COMMAND_PARSER_ENABLE_TEST
4210 -#include "ply-command-parser.h"
4211 -#include "ply-event-loop.h"
4212 -#include "ply-logger.h"
4215 -on_ask_for_password (ply_command_parser_t *parser,
4216 - const char *command)
4223 - ply_command_parser_get_command_options (parser, command, "prompt", &prompt, "command", &program, NULL);
4225 - printf ("ask for password with prompt '%s' feed result to '%s'\n", prompt, program);
4231 -on_show_splash (ply_command_parser_t *parser,
4232 - const char *command)
4234 - char *plugin_name;
4236 - plugin_name = NULL;
4237 - ply_command_parser_get_command_options (parser, command, "plugin-name", &plugin_name, NULL);
4239 - printf ("show splash plugin '%s'\n", plugin_name);
4240 - free (plugin_name);
4247 - ply_event_loop_t *loop;
4248 - ply_command_parser_t *parser;
4251 - loop = ply_event_loop_new ();
4252 - parser = ply_command_parser_new (argv[0], "Test Program");
4254 - ply_command_parser_add_options (parser,
4255 - "help", "This help message", PLY_COMMAND_OPTION_TYPE_FLAG,
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,
4268 - ply_command_parser_add_command (parser,
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,
4276 - if (!ply_command_parser_parse_arguments (parser, loop, argv, argc))
4278 - ply_error ("couldn't parse arguments");
4283 - ply_command_parser_get_options (parser, "help", &should_help, NULL);
4288 - usage = ply_command_parser_get_help_string (parser);
4289 - printf ("%s\n", usage);
4294 - ply_event_loop_run (loop);
4296 - ply_command_parser_free (parser);
4302 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4303 diff --git a/src/libply/ply-event-loop.c b/src/libply/ply-event-loop.c
4304 index 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)
4309 loop = calloc (1, sizeof (ply_event_loop_t));
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;
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;
4320 -#ifdef PLY_EVENT_LOOP_ENABLE_TEST
4322 -static ply_event_loop_t *loop;
4325 -alrm_signal_handler (void)
4327 - write (1, "times up!\n", sizeof ("times up!\n") - 1);
4328 - ply_event_loop_exit (loop, 0);
4332 -usr1_signal_handler (void)
4334 - write (1, "got sigusr1\n", sizeof ("got sigusr1\n") - 1);
4338 -hangup_signal_handler (void)
4340 - write (1, "got hangup\n", sizeof ("got hangup\n") - 1);
4344 -terminate_signal_handler (void)
4346 - write (1, "got terminate\n", sizeof ("got terminate\n") - 1);
4347 - ply_event_loop_exit (loop, 0);
4351 -line_received_handler (void)
4353 - char line[512] = { 0 };
4354 - printf ("Received line: ");
4357 - fgets (line, sizeof (line), stdin);
4358 - printf ("%s", line);
4362 -on_timeout (ply_event_loop_t *loop)
4364 - printf ("timeout elapsed\n");
4373 - loop = ply_event_loop_new ();
4375 - ply_event_loop_watch_signal (loop, SIGHUP,
4376 - (ply_event_handler_t) hangup_signal_handler,
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);
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,
4397 - exit_code = ply_event_loop_run (loop);
4399 - ply_event_loop_free (loop);
4403 -#endif /* PLY_EVENT_LOOP_ENABLE_TEST */
4404 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4405 diff --git a/src/libply/ply-hashtable.c b/src/libply/ply-hashtable.c
4406 index 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,
4411 unsigned int hash_index;
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 */
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,
4429 -#ifdef PLY_HASHTABLE_ENABLE_TEST
4433 -foreach_func (void *key,
4437 - printf ("foreach key:%s data:%s\n", (char*) key, (char*) data);
4444 +ply_hashtable_get_size (ply_hashtable_t *hashtable)
4446 - ply_hashtable_t *hashtable;
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;
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++)
4457 - ply_hashtable_insert (hashtable, (void *) key[i], (void *) data[9-i]);
4459 - for (i=0; i<10; i++)
4461 - reply_data = ply_hashtable_lookup (hashtable, (void *) key[i]);
4462 - printf ("got:%s\n", reply_data);
4464 - for (i=0; i<10; i++)
4466 - ply_hashtable_remove (hashtable, (void *) key[i]);
4467 - ply_hashtable_insert (hashtable, (void *) key[i], (void *) data[i]);
4469 - for (i=0; i<10; i++)
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);
4474 - ply_hashtable_foreach (hashtable, foreach_func, NULL);
4475 - ply_hashtable_free(hashtable);
4476 - printf ("hashtable test end\n");
4478 + return hashtable->live_node_count;
4482 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4483 diff --git a/src/libply/ply-hashtable.h b/src/libply/ply-hashtable.h
4484 index 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,
4492 +int ply_hashtable_get_size (ply_hashtable_t *hashtable);
4495 #endif /* PLY_HASHTABLE_H */
4496 diff --git a/src/libply/ply-key-file.c b/src/libply/ply-key-file.c
4497 index a3d5a11..c62551e 100644
4498 --- a/src/libply/ply-key-file.c
4499 +++ b/src/libply/ply-key-file.c
4501 #include "ply-key-file.h"
4508 @@ -75,7 +76,7 @@ ply_key_file_open_file (ply_key_file_t *key_file)
4510 assert (key_file != NULL);
4512 - key_file->fp = fopen (key_file->filename, "r");
4513 + key_file->fp = fopen (key_file->filename, "re");
4515 if (key_file->fp == NULL)
4517 @@ -173,13 +174,18 @@ ply_key_file_load_group (ply_key_file_t *key_file,
4518 ply_key_file_entry_t *entry;
4528 - first_byte = fgetc (key_file->fp);
4531 + first_byte = fgetc (key_file->fp);
4533 + while (isspace (first_byte));
4535 if (first_byte == '#')
4538 @@ -196,13 +202,13 @@ ply_key_file_load_group (ply_key_file_t *key_file,
4540 ungetc (first_byte, key_file->fp);
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);
4547 if (items_matched != 2)
4549 if (items_matched == 1)
4550 - fseek (key_file->fp, offset, SEEK_SET);
4551 + fseeko (key_file->fp, offset, SEEK_SET);
4555 @@ -254,7 +260,7 @@ ply_key_file_load_groups (ply_key_file_t *key_file)
4556 ungetc (first_byte, key_file->fp);
4559 - items_matched = fscanf (key_file->fp, " [ %a[^]] ] ", &group_name);
4560 + items_matched = fscanf (key_file->fp, " [ %m[^]] ] ", &group_name);
4562 if (items_matched <= 0)
4564 diff --git a/src/libply/ply-list.c b/src/libply/ply-list.c
4565 index 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)
4572 -#ifdef PLY_LIST_ENABLE_TEST
4576 -compare_int_ptr (void *element_a,
4579 - int *int_a = element_a;
4580 - int *int_b = element_b;
4581 - return *int_a - *int_b;
4590 - ply_list_node_t *node;
4597 - list = ply_list_new ();
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");
4607 - node = ply_list_get_first_node (list);
4609 - while (node != NULL)
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);
4618 - ply_list_remove_all_nodes (list);
4621 - for (i = 0; i<100; i++)
4623 - value = malloc (sizeof (int));
4624 - *value = random() % 100;
4625 - ply_list_append_data (list, (void *) value);
4628 - ply_list_sort (list, compare_int_ptr);
4630 - node = ply_list_get_first_node (list);
4634 - while (node != NULL)
4636 - value = (int *) ply_list_node_get_data (node);
4637 - if (*value < lastval)
4639 - printf ("ERROR: incorrect order\n");
4643 - printf ("node '%d' has data '%d'\n", i, *value);
4644 - node = ply_list_get_next_node (list, node);
4648 - ply_list_free (list);
4653 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4654 diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c
4655 index f51bb84..740c30e 100644
4656 --- a/src/libply/ply-logger.c
4657 +++ b/src/libply/ply-logger.c
4659 #include "ply-list.h"
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)
4666 #ifndef PLY_LOGGER_MAX_INJECTION_SIZE
4667 @@ -357,6 +357,9 @@ ply_logger_close_file (ply_logger_t *logger)
4669 assert (logger != NULL);
4671 + if (logger->output_fd < 0)
4674 close (logger->output_fd);
4675 ply_logger_set_output_fd (logger, -1);
4677 @@ -595,26 +598,4 @@ ply_logger_is_tracing_enabled (ply_logger_t *logger)
4679 #endif /* PLY_ENABLE_TRACING */
4681 -#ifdef PLY_LOGGER_ENABLE_TEST
4688 - ply_logger_t *logger;
4691 - logger = ply_logger_new ();
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);
4702 -#endif /* PLY_LOGGER_ENABLE_TEST */
4703 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4704 diff --git a/src/libply/ply-logger.h b/src/libply/ply-logger.h
4705 index 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; \
4719 diff --git a/src/libply/ply-progress.c b/src/libply/ply-progress.c
4720 index 2091a27..4a16556 100644
4721 --- a/src/libply/ply-progress.c
4722 +++ b/src/libply/ply-progress.c
4724 * Charlie Brej <cbrej@cs.man.ac.uk>
4727 +#ifdef HAVE_CONFIG_H
4728 +#include "config.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);
4738 + ply_trace ("saving progress cache to %s", filename);
4740 fp = fopen (filename,"w");
4744 + ply_trace ("failed to save cache: %m");
4748 node = ply_list_get_first_node (progress->current_message_list);
4750 @@ -326,75 +335,5 @@ ply_progress_status_update (ply_progress_t* progress,
4754 -#ifdef PLY_PROGRESS_ENABLE_TEST
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 ();
4769 - progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/
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 ());
4776 - slowness = rand () % 500000 + 50000;
4778 - for (i=0; i<2; i++)
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);
4785 - printf("Load cache\n");
4786 - ply_progress_load_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
4788 - for (i=0; i<10; i++)
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);
4796 - printf("Save and free cache\n");
4797 - ply_progress_save_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
4798 - ply_progress_free(progress);
4800 - printf("\nManual set percentage run\n\n");
4802 - progress = ply_progress_new ();
4803 - progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/
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 ());
4810 - for (i=0; i<12; i++)
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);
4818 - ply_progress_free(progress);
4823 -#endif /* PLY_PROGRESS_ENABLE_TEST */
4824 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4826 diff --git a/src/libply/ply-region.c b/src/libply/ply-region.c
4827 index 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;
4834 -#ifdef PLY_REGION_ENABLE_TEST
4837 -#define COVER_SIZE 100
4838 -#define RECTANGLE_COUNT 1000
4841 -cover_with_rect(char cover[COVER_SIZE][COVER_SIZE],
4842 - ply_rectangle_t *rectangle,
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++)
4849 - for (x=0; x<rectangle->width; x++)
4851 - if (rectangle->x + x < COVER_SIZE &&
4852 - rectangle->y + y < COVER_SIZE)
4855 - cover[rectangle->y + y][rectangle->x + x] = value;
4857 - cover[rectangle->y + y][rectangle->x + x]++;
4866 - ply_rectangle_t rectangle;
4867 - char cover[COVER_SIZE][COVER_SIZE];
4869 - unsigned long x, y;
4870 - ply_region_t *region;
4871 - ply_list_node_t *node;
4873 - region = ply_region_new ();
4875 - for (y = 0; y < COVER_SIZE; y++)
4877 - for (x = 0; x < COVER_SIZE; x++)
4883 - for (i = 0; i < RECTANGLE_COUNT; i++)
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",
4893 - rectangle.height);
4894 - cover_with_rect(cover, &rectangle, 100); /* 100 means covered by origial squares */
4895 - ply_region_add_rectangle (region, &rectangle);
4898 - printf("Converted to:\n");
4901 - ply_list_t *rectangle_list = ply_region_get_rectangle_list (region);
4902 - for (node = ply_list_get_first_node (rectangle_list);
4904 - node = ply_list_get_next_node (rectangle_list, node))
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);
4915 - printf("Rectangles in:%d out:%d\n", RECTANGLE_COUNT, count);
4919 - for (y = 0; y < COVER_SIZE; y++)
4921 - printf("%03ld ", y);
4922 - for (x = 0; x < COVER_SIZE; x++)
4924 - if (cover[y][x] >= 100)
4926 - if (cover[y][x] == 100)
4928 - printf("-"); /* "-" means should have been covered but wasn't */
4933 - if (cover[y][x] == 101)
4934 - printf("O"); /* "O" means correctly covered */
4937 - printf("%d", cover[y][x] - 101);
4938 - count++; /* 1+ means covered multiple times*/
4944 - if (cover[y][x] == 0)
4945 - printf("o"); /* "o" means not involved*/
4948 - printf("%c", 'A' - 1 + cover[y][x]);
4949 - count++; /* A+ means covered despite being not involved*/
4955 - printf("errors:%d\n", count);
4964 - for (i=0; i<100; i++)
4966 - if (do_test ()) return 1;
4971 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
4972 diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c
4973 index 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)
4978 ply_free_string_array (session->argv);
4980 - close (session->pseudoterminal_master_fd);
4981 + if (session->pseudoterminal_master_fd >= 0)
4982 + close (session->pseudoterminal_master_fd);
4986 @@ -213,8 +214,12 @@ ply_terminal_session_unredirect_console (ply_terminal_session_t *session)
4987 assert (session->console_is_redirected);
4989 fd = open ("/dev/console", O_RDWR | O_NOCTTY);
4992 ioctl (fd, TIOCCONS);
4995 + ply_trace ("couldn't open /dev/console to stop redirecting it: %m");
4998 session->console_is_redirected = false;
5000 @@ -582,57 +587,4 @@ ply_terminal_session_close_log (ply_terminal_session_t *session)
5001 return ply_logger_close_file (session->logger);
5004 -#ifdef PLY_TERMINAL_SESSION_ENABLE_TEST
5008 -#include "ply-event-loop.h"
5009 -#include "ply-terminal-session.h"
5012 -on_finished (ply_event_loop_t *loop)
5014 - ply_event_loop_exit (loop, 0);
5021 - ply_event_loop_t *loop;
5022 - ply_terminal_session_t *session;
5024 - ply_terminal_session_flags_t flags;
5028 - loop = ply_event_loop_new ();
5030 - session = ply_terminal_session_new ((const char * const *) (argv + 1));
5032 - flags = PLY_TERMINAL_SESSION_FLAGS_RUN_IN_PARENT;
5033 - flags |= PLY_TERMINAL_SESSION_FLAGS_LOOK_IN_PATH;
5035 - ply_terminal_session_attach_to_event_loop (session, loop);
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))
5043 - perror ("could not start terminal session");
5047 - ply_terminal_session_open_log (session, "foo.log");
5049 - exit_code = ply_event_loop_run (loop);
5051 - ply_terminal_session_free (session);
5056 -#endif /* PLY_TERMINAL_SESSION_ENABLE_TEST */
5057 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
5058 diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c
5059 index 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);
5066 - if (pipe (pipe_fds) < 0)
5067 + if (pipe2 (pipe_fds, O_CLOEXEC) < 0)
5070 - if (fcntl (pipe_fds[0], F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
5072 - ply_save_errno ();
5073 - close (pipe_fds[0]);
5074 - close (pipe_fds[1]);
5075 - ply_restore_errno ();
5079 - if (fcntl (pipe_fds[1], F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
5081 - ply_save_errno ();
5082 - close (pipe_fds[0]);
5083 - close (pipe_fds[1]);
5084 - ply_restore_errno ();
5088 *sender_fd = pipe_fds[1];
5089 *receiver_fd = pipe_fds[0];
5091 @@ -120,20 +102,11 @@ ply_open_unix_socket (void)
5093 const int should_pass_credentials = true;
5095 - fd = socket (PF_UNIX, SOCK_STREAM, 0);
5096 + fd = socket (PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
5101 - if (fcntl (fd, F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
5103 - ply_save_errno ();
5105 - ply_restore_errno ();
5110 if (setsockopt (fd, SOL_SOCKET, SO_PASSCRED,
5111 &should_pass_credentials, sizeof (should_pass_credentials)) < 0)
5113 @@ -822,11 +795,12 @@ ply_create_daemon (void)
5115 if (!ply_read (receiver_fd, &byte, sizeof (uint8_t)))
5117 + int read_error = errno;
5120 if (waitpid (pid, &status, WNOHANG) <= 0)
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));
5125 else if (WIFEXITED (status))
5127 @@ -971,7 +945,7 @@ ply_get_process_parent_pid (pid_t pid)
5128 asprintf (&path, "/proc/%ld/stat", (long) pid);
5131 - fp = fopen (path, "r");
5132 + fp = fopen (path, "re");
5136 diff --git a/src/libply/tests/Makefile.am b/src/libply/tests/Makefile.am
5137 deleted file mode 100644
5138 index bc4da58..0000000
5139 --- a/src/libply/tests/Makefile.am
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
5161 -noinst_PROGRAMS = $(TESTS)
5163 -# Our tests aren't unit tests so clear for now
5166 -MAINTAINERCLEANFILES = Makefile.in
5167 diff --git a/src/libply/tests/ply-array-test.am b/src/libply/tests/ply-array-test.am
5168 deleted file mode 100644
5169 index 4f8ecc4..0000000
5170 --- a/src/libply/tests/ply-array-test.am
5173 -TESTS += ply-array-test
5175 -ply_array_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_ARRAY_ENABLE_TEST
5176 -ply_array_test_LDADD = $(PLYMOUTH_LIBS)
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
5189 diff --git a/src/libply/tests/ply-bitarray-test.am b/src/libply/tests/ply-bitarray-test.am
5190 deleted file mode 100644
5191 index 85c3608..0000000
5192 --- a/src/libply/tests/ply-bitarray-test.am
5195 -TESTS += ply-bitarray-test
5197 -ply_bitarray_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BITARRAY_ENABLE_TEST
5198 -ply_bitarray_test_LDADD = $(PLYMOUTH_LIBS)
5200 -ply_bitarray_test_SOURCES = \
5201 - $(srcdir)/../ply-bitarray.h \
5202 - $(srcdir)/../ply-bitarray.c
5203 diff --git a/src/libply/tests/ply-command-parser-test.am b/src/libply/tests/ply-command-parser-test.am
5204 deleted file mode 100644
5205 index 91649d5..0000000
5206 --- a/src/libply/tests/ply-command-parser-test.am
5209 -TESTS += ply-command-parser-test
5211 -ply_command_parser_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_COMMAND_PARSER_ENABLE_TEST
5212 -ply_command_parser_test_LDADD = $(PLYMOUTH_LIBS)
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
5227 diff --git a/src/libply/tests/ply-event-loop-test.am b/src/libply/tests/ply-event-loop-test.am
5228 deleted file mode 100644
5229 index c666ea6..0000000
5230 --- a/src/libply/tests/ply-event-loop-test.am
5233 -TESTS += ply-event-loop-test
5235 -ply_event_loop_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_EVENT_LOOP_ENABLE_TEST
5236 -ply_event_loop_test_LDADD = $(PLYMOUTH_LIBS)
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
5247 diff --git a/src/libply/tests/ply-hashtable-test.am b/src/libply/tests/ply-hashtable-test.am
5248 deleted file mode 100644
5249 index d3410fc..0000000
5250 --- a/src/libply/tests/ply-hashtable-test.am
5253 -TESTS += ply-hashtable-test
5255 -ply_hashtable_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_HASHTABLE_ENABLE_TEST
5256 -ply_hashtable_test_LDADD = $(PLYMOUTH_LIBS)
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
5263 diff --git a/src/libply/tests/ply-list-test.am b/src/libply/tests/ply-list-test.am
5264 deleted file mode 100644
5265 index 8beb578..0000000
5266 --- a/src/libply/tests/ply-list-test.am
5269 -TESTS += ply-list-test
5271 -ply_list_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_LIST_ENABLE_TEST
5272 -ply_list_test_LDADD = $(PLYMOUTH_LIBS)
5274 -ply_list_test_SOURCES = \
5275 - $(srcdir)/../ply-list.h \
5276 - $(srcdir)/../ply-list.c
5277 diff --git a/src/libply/tests/ply-logger-test.am b/src/libply/tests/ply-logger-test.am
5278 deleted file mode 100644
5279 index a589fb9..0000000
5280 --- a/src/libply/tests/ply-logger-test.am
5283 -TESTS += ply-logger-test
5285 -ply_logger_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_LOGGER_ENABLE_TEST
5286 -ply_logger_test_LDADD = $(PLYMOUTH_LIBS)
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
5295 diff --git a/src/libply/tests/ply-progress-test.am b/src/libply/tests/ply-progress-test.am
5296 deleted file mode 100644
5297 index 6279fac..0000000
5298 --- a/src/libply/tests/ply-progress-test.am
5301 -TESTS += ply-progress-test
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)
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
5316 diff --git a/src/libply/tests/ply-region.am b/src/libply/tests/ply-region.am
5317 deleted file mode 100644
5318 index 1883833..0000000
5319 --- a/src/libply/tests/ply-region.am
5322 -TESTS += ply-region-test
5324 -ply_region_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_REGION_ENABLE_TEST
5325 -ply_region_test_LDADD = $(PLYMOUTH_LIBS)
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
5334 diff --git a/src/libply/tests/ply-terminal-session-test.am b/src/libply/tests/ply-terminal-session-test.am
5335 deleted file mode 100644
5336 index decb531..0000000
5337 --- a/src/libply/tests/ply-terminal-session-test.am
5340 -TESTS += ply-terminal-session-test
5342 -ply_terminal_session_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_TERMINAL_SESSION_ENABLE_TEST
5343 -ply_terminal_session_test_LDADD = $(PLYMOUTH_LIBS)
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
5358 diff --git a/src/main.c b/src/main.c
5359 index 88e5002..c3daac0 100644
5364 #include <sys/stat.h>
5365 #include <sys/types.h>
5374 +#include <values.h>
5376 #include <linux/kd.h>
5377 #include <linux/vt.h>
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
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;
5405 - ply_renderer_t *renderer;
5406 ply_terminal_t *local_console_terminal;
5407 + ply_device_manager_t *device_manager;
5409 ply_trigger_t *deactivate_trigger;
5410 ply_trigger_t *quit_trigger;
5412 + double start_time;
5413 + double splash_delay;
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;
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;
5433 -static ply_boot_splash_t *start_boot_splash (state_t *state,
5434 - const char *theme_path,
5435 - bool fall_back_if_neccessary);
5437 -static void add_display_and_keyboard_for_terminal (state_t *state,
5438 - ply_terminal_t *terminal);
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);
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);
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);
5475 on_session_output (state_t *state,
5476 @@ -249,21 +260,68 @@ show_messages (state_t *state)
5481 +load_settings (state_t *state,
5483 + char **theme_path)
5485 + ply_key_file_t *key_file = NULL;
5486 + const char *delay_string;
5487 + bool settings_loaded = false;
5488 + const char *splash_string;
5490 + ply_trace ("Trying to load %s", path);
5491 + key_file = ply_key_file_new (path);
5493 + if (!ply_key_file_load (key_file))
5496 + splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
5498 + if (splash_string == NULL)
5501 + asprintf (theme_path,
5502 + PLYMOUTH_THEME_PATH "%s/%s.plymouth",
5503 + splash_string, splash_string);
5505 + if (isnan (state->splash_delay))
5507 + delay_string = ply_key_file_get_value (key_file, "Daemon", "ShowDelay");
5509 + if (delay_string != NULL)
5511 + state->splash_delay = atof (delay_string);
5512 + ply_trace ("Splash delay is set to %lf", state->splash_delay);
5516 + settings_loaded = true;
5518 + ply_key_file_free (key_file);
5520 + return settings_loaded;
5524 show_detailed_splash (state_t *state)
5526 + ply_boot_splash_t *splash;
5528 if (state->boot_splash != NULL)
5531 ply_trace ("Showing detailed splash screen");
5532 - state->boot_splash = start_boot_splash (state,
5533 - PLYMOUTH_THEME_PATH "details/details.plymouth",
5535 + splash = show_theme (state, NULL);
5537 - if (state->boot_splash == NULL)
5538 + if (splash == NULL)
5540 ply_trace ("Could not start detailed splash screen, this could be a problem.");
5544 + state->boot_splash = splash;
5545 + update_display (state);
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);
5554 + if (isnan (state->splash_delay))
5556 + const char *delay_string;
5558 + delay_string = command_line_get_string_after_prefix (state->kernel_command_line, "plymouth.splash-delay=");
5560 + if (delay_string != NULL)
5561 + state->splash_delay = atof (delay_string);
5566 find_system_default_splash (state_t *state)
5568 - ply_key_file_t *key_file;
5569 - char *splash_string;
5571 if (state->system_default_splash_path != NULL)
5574 - ply_trace ("Trying to load " PLYMOUTH_CONF_DIR "plymouthd.conf");
5575 - key_file = ply_key_file_new (PLYMOUTH_CONF_DIR "plymouthd.conf");
5577 - if (!ply_key_file_load (key_file))
5578 + if (!load_settings (state, PLYMOUTH_CONF_DIR "plymouthd.conf", &state->system_default_splash_path))
5580 ply_trace ("failed to load " PLYMOUTH_CONF_DIR "plymouthd.conf");
5581 - ply_key_file_free (key_file);
5585 - splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
5587 - ply_trace ("System default splash is configured to be '%s'", splash_string);
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);
5597 find_distribution_default_splash (state_t *state)
5599 - ply_key_file_t *key_file;
5600 - char *splash_string;
5602 if (state->distribution_default_splash_path != NULL)
5605 - ply_trace ("Trying to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults");
5606 - key_file = ply_key_file_new (PLYMOUTH_POLICY_DIR "plymouthd.defaults");
5608 - if (!ply_key_file_load (key_file))
5609 + if (!load_settings (state, PLYMOUTH_POLICY_DIR "plymouthd.defaults", &state->distribution_default_splash_path))
5611 ply_trace ("failed to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults");
5612 - ply_key_file_free (key_file);
5616 - splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme");
5618 - ply_trace ("Distribution default splash is configured to be '%s'", splash_string);
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);
5628 @@ -393,63 +433,66 @@ show_default_splash (state_t *state)
5631 ply_trace ("Showing splash screen");
5632 - find_override_splash (state);
5633 if (state->override_splash_path != NULL)
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,
5639 + state->boot_splash = show_theme (state, state->override_splash_path);
5642 - find_system_default_splash (state);
5643 if (state->boot_splash == NULL &&
5644 state->system_default_splash_path != NULL)
5646 ply_trace ("Trying system default splash");
5647 - state->boot_splash = start_boot_splash (state,
5648 - state->system_default_splash_path,
5650 + state->boot_splash = show_theme (state, state->system_default_splash_path);
5653 - find_distribution_default_splash (state);
5654 if (state->boot_splash == NULL &&
5655 state->distribution_default_splash_path != NULL)
5657 ply_trace ("Trying distribution default splash");
5658 - state->boot_splash = start_boot_splash (state,
5659 - state->distribution_default_splash_path,
5661 + state->boot_splash = show_theme (state, state->distribution_default_splash_path);
5664 if (state->boot_splash == NULL)
5666 ply_trace ("Trying old scheme for default splash");
5667 - state->boot_splash = start_boot_splash (state,
5668 - PLYMOUTH_THEME_PATH "default.plymouth",
5670 + state->boot_splash = show_theme (state, PLYMOUTH_THEME_PATH "default.plymouth");
5673 if (state->boot_splash == NULL)
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",
5680 + state->boot_splash = show_theme (state, PLYMOUTH_THEME_PATH "text/text.plymouth");
5683 if (state->boot_splash == NULL)
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",
5690 + "showing built-in splash screen");
5691 + state->boot_splash = show_theme (state, NULL);
5694 if (state->boot_splash == NULL)
5695 - ply_error ("plymouthd: could not start boot splash: %m");
5697 + ply_error ("plymouthd: could not start boot splash: %m");
5701 + update_display (state);
5705 +cancel_pending_delayed_show (state_t *state)
5707 + if (isnan (state->splash_delay))
5710 + ply_event_loop_stop_watching_for_timeout (state->loop,
5711 + (ply_event_loop_timeout_handler_t)
5714 + state->splash_delay = NAN;
5718 @@ -459,13 +502,36 @@ on_ask_for_password (state_t *state,
5720 ply_entry_trigger_t *entry_trigger;
5722 - /* No splash, client will have to get password
5724 if (state->boot_splash == NULL)
5726 - ply_trace ("no splash loaded, replying immediately with no password");
5727 - ply_trigger_pull (answer, NULL);
5729 + /* Waiting to be shown, boot splash will
5730 + * arrive shortly so just sit tight
5732 + if (state->is_shown)
5734 + bool has_open_seats;
5736 + cancel_pending_delayed_show (state);
5738 + has_open_seats = ply_device_manager_has_open_seats (state->device_manager);
5740 + if (has_open_seats)
5742 + ply_trace ("seats open now, showing splash immediately");
5743 + show_splash (state);
5747 + ply_trace ("splash still coming up, waiting a bit");
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);
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)
5764 - if (state->mode != PLY_MODE_BOOT)
5766 - ply_trace ("new root is only supported in boot mode ");
5770 ply_trace ("new root mounted at \"%s\", switching to it", root_dir);
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);
5779 @@ -619,7 +679,7 @@ get_cache_file_for_mode (ply_mode_t mode)
5783 - fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
5784 + ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
5788 @@ -629,21 +689,24 @@ get_cache_file_for_mode (ply_mode_t mode)
5792 -get_log_file_for_mode (ply_mode_t mode)
5793 +get_log_file_for_state (state_t *state)
5795 const char *filename;
5797 - switch ((int)mode)
5798 + switch ((int)state->mode)
5801 - filename = PLYMOUTH_LOG_DIRECTORY "/boot.log";
5802 + if (state->no_boot_log)
5805 + filename = PLYMOUTH_LOG_DIRECTORY "/boot.log";
5807 case PLY_MODE_SHUTDOWN:
5808 case PLY_MODE_UPDATES:
5809 filename = _PATH_DEVNULL;
5812 - fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
5813 + ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
5817 @@ -667,7 +730,7 @@ get_log_spool_file_for_mode (ply_mode_t mode)
5821 - fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
5822 + ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
5826 @@ -684,7 +747,7 @@ spool_error (state_t *state)
5828 ply_trace ("spooling error for viewer");
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);
5834 if (logfile != NULL && logspool != NULL)
5835 @@ -712,11 +775,16 @@ prepare_logging (state_t *state)
5839 - logfile = get_log_file_for_mode (state->mode);
5840 + logfile = get_log_file_for_state (state);
5841 if (logfile != NULL)
5844 ply_trace ("opening log '%s'", logfile);
5845 - ply_terminal_session_open_log (state->session, logfile);
5847 + log_opened = ply_terminal_session_open_log (state->session, logfile);
5850 + ply_trace ("failed to open log: %m");
5852 if (state->number_of_errors > 0)
5853 spool_error (state);
5854 @@ -821,55 +889,15 @@ plymouth_should_show_default_splash (state_t *state)
5858 -remove_displays_and_keyboard (state_t *state)
5859 +on_show_splash (state_t *state)
5861 - ply_list_node_t *node;
5862 - ply_trace ("removing displays and keyboard");
5864 - node = ply_list_get_first_node (state->pixel_displays);
5865 - while (node != NULL)
5867 - ply_list_node_t *next_node;
5868 - ply_pixel_display_t *display;
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);
5875 - ply_list_remove_node (state->pixel_displays, node);
5880 - node = ply_list_get_first_node (state->text_displays);
5881 - while (node != NULL)
5883 - ply_list_node_t *next_node;
5884 - ply_text_display_t *display;
5885 + bool has_open_seats;
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);
5892 - ply_list_remove_node (state->text_displays, node);
5897 - if (state->keyboard != NULL)
5898 + if (state->is_shown)
5900 - ply_trace ("removing keyboard");
5901 - ply_keyboard_free (state->keyboard);
5902 - state->keyboard = NULL;
5903 + ply_trace ("show splash called while already shown");
5909 -on_show_splash (state_t *state)
5913 if (state->is_inactive)
5915 @@ -884,18 +912,81 @@ on_show_splash (state_t *state)
5919 - check_for_consoles (state, state->default_tty, true);
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);
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);
5931 + if (has_open_seats)
5933 + ply_trace ("at least one seat already open, so loading splash");
5934 + show_splash (state);
5938 - ply_trace ("no open seats");
5939 - detach_from_running_session (state);
5940 + ply_trace ("no seats available to show splash on, waiting...");
5945 +on_seat_removed (state_t *state,
5948 + ply_keyboard_t *keyboard;
5950 + keyboard = ply_seat_get_keyboard (seat);
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)
5964 + ply_trace ("no longer listening for enter");
5965 + ply_keyboard_remove_enter_handler (keyboard,
5966 + (ply_keyboard_enter_handler_t)
5969 + if (state->boot_splash != NULL)
5970 + ply_boot_splash_detach_from_seat (state->boot_splash, seat);
5974 +show_splash (state_t *state)
5976 + if (state->boot_splash != NULL)
5979 + if (!isnan (state->splash_delay))
5981 + double now, running_time;
5983 + now = ply_get_timestamp ();
5984 + running_time = now - state->start_time;
5985 + if (state->splash_delay > running_time)
5987 + double time_left = state->splash_delay - running_time;
5989 + ply_trace ("delaying show splash for %lf seconds",
5991 + ply_event_loop_stop_watching_for_timeout (state->loop,
5992 + (ply_event_loop_timeout_handler_t)
5995 + ply_event_loop_watch_for_timeout (state->loop,
5997 + (ply_event_loop_timeout_handler_t)
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;
6009 - show_messages (state);
6012 -static ply_list_t *
6013 -get_tracked_terminals (state_t *state)
6015 +on_seat_added (state_t *state,
6018 - ply_list_t *terminals;
6019 - ply_list_node_t *node;
6021 - terminals = ply_list_new ();
6022 + ply_keyboard_t *keyboard;
6024 - node = ply_list_get_first_node (state->text_displays);
6025 - while (node != NULL)
6026 + if (state->is_shown)
6028 - ply_list_node_t *next_node;
6029 - ply_text_display_t *display;
6030 - ply_terminal_t *terminal;
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)
6037 + ply_trace ("seat added before splash loaded, so loading splash now");
6038 + show_splash (state);
6042 + ply_trace ("seat added after splash loaded, so attaching to splash");
6043 + ply_boot_splash_attach_to_seat (state->boot_splash, seat);
6047 - ply_list_append_data (terminals, terminal);
6048 + keyboard = ply_seat_get_keyboard (seat);
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)
6073 -free_terminals (state_t *state,
6074 - ply_list_t *terminals)
6075 +load_devices (state_t *state,
6076 + ply_device_manager_flags_t flags)
6078 - ply_list_node_t *node;
6079 - node = ply_list_get_first_node (terminals);
6080 - while (node != NULL)
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);
6087 - next_node = ply_list_get_next_node (state->text_displays, node);
6088 - terminal = ply_list_node_get_data (node);
6090 - ply_terminal_close (terminal);
6091 - ply_terminal_free (terminal);
6092 - ply_list_remove_node (terminals, node);
6097 - ply_list_free (terminals);
6098 + ply_device_manager_watch_seats (state->device_manager,
6099 + (ply_seat_added_handler_t)
6101 + (ply_seat_removed_handler_t)
6107 quit_splash (state_t *state)
6109 - ply_list_t *terminals;
6111 ply_trace ("quiting splash");
6112 if (state->boot_splash != NULL)
6114 @@ -975,17 +1068,7 @@ quit_splash (state_t *state)
6115 state->boot_splash = NULL;
6118 - terminals = get_tracked_terminals (state);
6120 - ply_trace ("removing displays and keyboard");
6121 - remove_displays_and_keyboard (state);
6123 - if (state->renderer != NULL)
6125 - ply_renderer_close (state->renderer);
6126 - ply_renderer_free (state->renderer);
6127 - state->renderer = NULL;
6129 + ply_device_manager_deactivate_keyboards (state->device_manager);
6131 if (state->local_console_terminal != NULL)
6133 @@ -993,25 +1076,37 @@ quit_splash (state_t *state)
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);
6139 - state->local_console_terminal = NULL;
6141 - free_terminals (state, terminals);
6143 detach_from_running_session (state);
6147 +hide_splash (state_t *state)
6149 + state->is_shown = false;
6151 + cancel_pending_delayed_show (state);
6153 + if (state->boot_splash == NULL)
6156 + ply_boot_splash_hide (state->boot_splash);
6158 + if (state->local_console_terminal != NULL)
6159 + ply_terminal_set_mode (state->local_console_terminal, PLY_TERMINAL_MODE_TEXT);
6163 dump_details_and_quit_splash (state_t *state)
6165 state->showing_details = false;
6166 toggle_between_splash_and_details (state);
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);
6173 + ply_device_manager_deactivate_renderers (state->device_manager);
6174 + hide_splash (state);
6175 quit_splash (state);
6178 @@ -1042,6 +1137,9 @@ tell_gdm_to_transition (void)
6180 quit_program (state_t *state)
6182 + ply_trace ("cleaning up devices");
6183 + ply_device_manager_free (state->device_manager);
6185 ply_trace ("exiting event loop");
6186 ply_event_loop_exit (state->loop, 0);
6188 @@ -1077,11 +1175,7 @@ deactivate_splash (state_t *state)
6190 assert (!state->is_inactive);
6192 - if (state->renderer != NULL)
6194 - ply_trace ("deactivating renderer");
6195 - ply_renderer_deactivate (state->renderer);
6197 + ply_device_manager_deactivate_renderers (state->device_manager);
6199 detach_from_running_session (state);
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);
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"))
6212 + ply_logger_close_file (ply_logger_get_error_default ());
6215 state->is_inactive = true;
6216 @@ -1112,10 +1212,8 @@ on_boot_splash_idle (state_t *state)
6217 if (!state->should_retain_splash)
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);
6228 ply_trace ("quitting splash");
6229 @@ -1130,12 +1228,17 @@ on_boot_splash_idle (state_t *state)
6235 on_deactivate (state_t *state,
6236 ply_trigger_t *deactivate_trigger)
6238 - if ((state->deactivate_trigger != NULL) || state->is_inactive)
6239 + if (state->is_inactive)
6241 + ply_trigger_pull (deactivate_trigger, NULL);
6245 + if (state->deactivate_trigger != NULL)
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;
6252 ply_trace ("deactivating");
6253 + cancel_pending_delayed_show (state);
6255 - if (state->keyboard != NULL)
6257 - ply_trace ("deactivating keyboard");
6258 - ply_keyboard_stop_watching_for_input (state->keyboard);
6260 + ply_device_manager_deactivate_keyboards (state->device_manager);
6262 if (state->boot_splash != NULL)
6264 @@ -1176,6 +1276,7 @@ on_reactivate (state_t *state)
6266 if (state->local_console_terminal != NULL)
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);
6276 - if (state->keyboard != NULL)
6278 - ply_trace ("activating keyboard");
6279 - ply_keyboard_watch_for_input (state->keyboard);
6282 - if (state->renderer != NULL)
6284 - ply_trace ("activating renderer");
6285 - ply_renderer_activate (state->renderer);
6287 + ply_device_manager_activate_keyboards (state->device_manager);
6288 + ply_device_manager_activate_renderers (state->device_manager);
6290 state->is_inactive = false;
6292 @@ -1209,8 +1301,11 @@ on_quit (state_t *state,
6294 ply_trigger_t *quit_trigger)
6296 + ply_trace ("quitting (retain splash: %s)", retain_splash? "true" : "false");
6298 if (state->quit_trigger != NULL)
6300 + ply_trace ("quit trigger already pending, so chaining to it");
6301 ply_trigger_add_handler (state->quit_trigger,
6302 (ply_trigger_handler_t)
6304 @@ -1219,9 +1314,16 @@ on_quit (state_t *state,
6307 if (state->system_initialized)
6308 - ply_progress_save_cache (state->progress,
6309 - get_cache_file_for_mode (state->mode));
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));
6319 + ply_trace ("system not initialized so skipping saving boot-duration file");
6321 state->quit_trigger = quit_trigger;
6322 state->should_retain_splash = retain_splash;
6324 @@ -1229,15 +1331,11 @@ on_quit (state_t *state,
6325 tell_systemd_to_stop_printing_details (state);
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);
6333 - if (state->keyboard != NULL)
6335 - ply_trace ("deactivating keyboard");
6336 - ply_keyboard_stop_watching_for_input (state->keyboard);
6338 + ply_device_manager_deactivate_keyboards (state->device_manager);
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)
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;
6351 @@ -1366,8 +1464,6 @@ toggle_between_splash_and_details (state_t *state)
6352 show_default_splash (state);
6353 state->showing_details = false;
6355 - update_display (state);
6356 - show_messages (state);
6360 @@ -1479,140 +1575,24 @@ on_enter (state_t *state,
6364 -set_keyboard (state_t *state,
6365 - ply_keyboard_t *keyboard)
6367 - state->keyboard = keyboard;
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)
6385 -add_display_and_keyboard_for_terminal (state_t *state,
6386 - ply_terminal_t *terminal)
6388 - ply_text_display_t *display;
6389 - ply_keyboard_t *keyboard;
6391 - keyboard = ply_keyboard_new_for_terminal (terminal);
6392 - display = ply_text_display_new (terminal);
6394 - ply_list_append_data (state->text_displays, display);
6395 - set_keyboard (state, keyboard);
6399 -add_pixel_displays_from_renderer (state_t *state,
6400 - ply_renderer_t *renderer)
6402 - ply_list_t *heads;
6403 - ply_list_node_t *node;
6405 - heads = ply_renderer_get_heads (renderer);
6407 - ply_trace ("Adding displays for %d heads",
6408 - ply_list_get_length (heads));
6410 - node = ply_list_get_first_node (heads);
6411 - while (node != NULL)
6413 - ply_list_node_t *next_node;
6414 - ply_renderer_head_t *head;
6415 - ply_pixel_display_t *display;
6417 - head = ply_list_node_get_data (node);
6418 - next_node = ply_list_get_next_node (heads, node);
6420 - display = ply_pixel_display_new (renderer, head);
6422 - ply_list_append_data (state->pixel_displays, display);
6430 -add_default_displays_and_keyboard (state_t *state)
6431 +attach_splash_to_seats (state_t *state,
6432 + ply_boot_splash_t *splash)
6434 - ply_renderer_t *renderer;
6435 - ply_keyboard_t *keyboard;
6436 - ply_text_display_t *text_display;
6438 - ply_trace ("adding default displays and keyboard");
6440 - state->local_console_terminal = ply_terminal_new (state->default_tty);
6442 - renderer = ply_renderer_new (NULL, NULL, state->local_console_terminal);
6444 - if (!ply_renderer_open (renderer))
6446 - ply_trace ("could not open renderer /dev/fb");
6447 - ply_renderer_free (renderer);
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);
6454 - keyboard = ply_keyboard_new_for_renderer (renderer);
6455 - set_keyboard (state, keyboard);
6457 - add_pixel_displays_from_renderer (state, renderer);
6459 - text_display = ply_text_display_new (state->local_console_terminal);
6460 - ply_list_append_data (state->text_displays, text_display);
6462 - state->renderer = renderer;
6466 -add_displays_and_keyboard_to_boot_splash (state_t *state,
6467 - ply_boot_splash_t *splash)
6469 + ply_list_t *seats;
6470 ply_list_node_t *node;
6472 - ply_trace ("setting keyboard on boot splash");
6473 - if (state->keyboard != NULL)
6474 - ply_boot_splash_set_keyboard (splash, state->keyboard);
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)
6481 - ply_pixel_display_t *display;
6483 ply_list_node_t *next_node;
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);
6495 - node = ply_list_get_first_node (state->text_displays);
6496 - while (node != NULL)
6498 - ply_text_display_t *display;
6499 - ply_list_node_t *next_node;
6501 - display = ply_list_node_get_data (node);
6502 - next_node = ply_list_get_next_node (state->text_displays, node);
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);
6510 @@ -1637,12 +1617,41 @@ tell_systemd_to_stop_printing_details (state_t *state)
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)
6519 + ply_boot_splash_t *splash;
6522 + ply_trace ("Loading built-in theme");
6524 + splash = ply_boot_splash_new ("",
6525 + PLYMOUTH_PLUGIN_PATH,
6526 + state->boot_buffer);
6528 + is_loaded = ply_boot_splash_load_built_in (splash);
6532 + ply_save_errno ();
6533 + ply_boot_splash_free (splash);
6534 + ply_restore_errno ();
6538 + ply_trace ("attaching plugin to event loop");
6539 + ply_boot_splash_attach_to_event_loop (splash, state->loop);
6541 + ply_trace ("attaching progress to plugin");
6542 + ply_boot_splash_attach_progress (splash, state->progress);
6547 +static ply_boot_splash_t *
6548 +load_theme (state_t *state,
6549 + const char *theme_path)
6551 ply_boot_splash_t *splash;
6552 - ply_boot_splash_mode_t splash_mode;
6555 ply_trace ("Loading boot splash theme '%s'",
6556 @@ -1653,13 +1662,6 @@ start_boot_splash (state_t *state,
6557 state->boot_buffer);
6559 is_loaded = ply_boot_splash_load (splash);
6560 - if (!is_loaded && fall_back_if_neccessary)
6562 - ply_trace ("Splash couldn't be loaded: %m");
6564 - ply_trace ("Loading built in splash");
6565 - is_loaded = ply_boot_splash_load_built_in (splash);
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);
6574 - add_displays_and_keyboard_to_boot_splash (state, splash);
6578 +static ply_boot_splash_t *
6579 +show_theme (state_t *state,
6580 + const char *theme_path)
6582 + ply_boot_splash_mode_t splash_mode;
6583 + ply_boot_splash_t *splash;
6585 + if (theme_path != NULL)
6586 + splash = load_theme (state, theme_path);
6588 + splash = load_built_in_theme (state);
6590 + if (splash == NULL)
6593 + attach_splash_to_seats (state, splash);
6594 + ply_device_manager_activate_renderers (state->device_manager);
6596 - ply_trace ("showing plugin");
6597 if (state->mode == PLY_MODE_SHUTDOWN)
6598 splash_mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN;
6600 @@ -1686,7 +1706,6 @@ start_boot_splash (state_t *state,
6601 if (!ply_boot_splash_show (splash, splash_mode))
6604 - ply_boot_splash_unset_keyboard (splash);
6605 ply_boot_splash_free (splash);
6606 ply_restore_errno ();
6608 @@ -1697,10 +1716,9 @@ start_boot_splash (state_t *state,
6609 tell_systemd_to_print_details (state);
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);
6617 - update_display (state);
6621 @@ -1875,6 +1893,30 @@ check_verbosity (state_t *state)
6622 ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
6626 + const char* device;
6629 + device = state->default_tty;
6631 + ply_trace ("redirecting debug output to %s", device);
6633 + if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
6634 + file = strdup (device);
6636 + asprintf (&file, "/dev/%s", device);
6638 + fd = open (file, O_RDWR | O_APPEND);
6642 + ply_trace ("could not redirected debug output to %s: %m", device);
6645 + ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
6652 @@ -1896,267 +1938,26 @@ check_verbosity (state_t *state)
6654 check_logging (state_t *state)
6656 - ply_trace ("checking if console messages should be redirected and logged");
6658 - if (command_line_has_argument (state->kernel_command_line, "plymouth.nolog"))
6660 - ply_trace ("logging won't be enabled!");
6661 - state->no_boot_log = true;
6665 - ply_trace ("logging will be enabled!");
6666 - state->no_boot_log = false;
6671 -add_display_and_keyboard_for_console (const char *console,
6675 - ply_terminal_t *terminal;
6677 - terminal = ply_terminal_new (console);
6679 - if (strcmp (console, state->default_tty) == 0)
6680 - state->local_console_terminal = terminal;
6681 + bool kernel_no_log;
6683 - ply_trace ("adding display and keyboard for console %s", console);
6684 - add_display_and_keyboard_for_terminal (state, terminal);
6688 -add_consoles_from_file (state_t *state,
6689 - ply_hashtable_t *consoles,
6693 - char contents[512] = "";
6694 - ssize_t contents_length;
6696 - const char *remaining_file_contents;
6698 - ply_trace ("opening %s", path);
6699 - fd = open (path, O_RDONLY);
6703 - ply_trace ("couldn't open it: %m");
6707 - ply_trace ("reading file");
6708 - contents_length = read (fd, contents, sizeof (contents));
6710 - if (contents_length <= 0)
6712 - ply_trace ("couldn't read it: %m");
6718 - remaining_file_contents = contents;
6721 - while (remaining_file_contents < contents + contents_length)
6724 - size_t console_length;
6725 - char *console_device;
6727 - /* Advance past any leading whitespace */
6728 - remaining_file_contents += strspn (remaining_file_contents, " \n\t\v");
6730 - if (*remaining_file_contents == '\0')
6732 - /* There's nothing left after the whitespace, we're done */
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);
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.
6747 - if (strcmp (console, "tty0") != 0)
6748 - state->should_force_details = true;
6750 - asprintf (&console_device, "/dev/%s", console);
6754 - ply_trace ("console %s found!", console_device);
6755 - ply_hashtable_insert (consoles, console_device, console_device);
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
6763 - remaining_file_contents += console_length + 1;
6766 - return num_consoles;
6770 -add_consoles_from_kernel_command_line (state_t *state,
6771 - ply_hashtable_t *consoles)
6773 - const char *console_string;
6774 - const char *remaining_command_line;
6778 - remaining_command_line = state->kernel_command_line;
6782 - while ((console_string = command_line_get_string_after_prefix (remaining_command_line,
6783 - "console=")) != NULL)
6786 - size_t console_length;
6787 - char *console_device;
6789 - remaining_command_line = console_string;
6791 - state->should_force_details = true;
6793 - console = strdup (console_string);
6795 - end = strpbrk (console, " \n\t\v,");
6800 - console_length = strlen (console);
6802 - if (strncmp (console, "/dev/", strlen ("/dev/")) == 0)
6804 - console_device = console;
6809 - asprintf (&console_device, "/dev/%s", console);
6814 - ply_trace ("console %s found!", console_device);
6815 - ply_hashtable_insert (consoles, console_device, console_device);
6817 - remaining_command_line += console_length;
6820 - return num_consoles;
6824 -check_for_consoles (state_t *state,
6825 - const char *default_tty,
6826 - bool should_add_displays)
6829 - ply_hashtable_t *consoles;
6831 - bool ignore_serial_consoles;
6833 - ply_trace ("checking for consoles%s",
6834 - should_add_displays? " and adding displays": "");
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");
6841 + ply_trace ("checking if console messages should be redirected and logged");
6843 - if (!ignore_serial_consoles)
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;
6850 - if (num_consoles == 0)
6852 - ply_trace ("falling back to kernel command line");
6853 - num_consoles = add_consoles_from_kernel_command_line (state, consoles);
6856 + if (state->no_boot_log)
6857 + ply_trace ("logging won't be enabled!");
6860 - ply_trace ("ignoring all consoles but default console because of plymouth.ignore-serial-consoles");
6863 - console = ply_hashtable_remove (consoles, (void *) "/dev/tty0");
6864 - if (console != NULL)
6867 - console = strdup (default_tty);
6868 - ply_hashtable_insert (consoles, console, console);
6871 - console = ply_hashtable_remove (consoles, (void *) "/dev/tty");
6872 - if (console != NULL)
6875 - console = strdup (default_tty);
6876 - ply_hashtable_insert (consoles, console, console);
6879 - free (state->kernel_console_tty);
6880 - state->kernel_console_tty = NULL;
6882 - if (console != NULL)
6883 - state->kernel_console_tty = strdup (console);
6885 - if (should_add_displays)
6887 - /* Do a full graphical splash if there's no weird serial console
6888 - * stuff going on, otherwise just prepare text splashes
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);
6895 - ply_hashtable_foreach (consoles,
6896 - (ply_hashtable_foreach_func_t *)
6897 - add_display_and_keyboard_for_console,
6901 - ply_hashtable_foreach (consoles, (ply_hashtable_foreach_func_t *) free, NULL);
6902 - ply_hashtable_free (consoles);
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!");
6910 -redirect_standard_io_to_device (const char *device)
6911 +redirect_standard_io_to_dev_null (void)
6916 - ply_trace ("redirecting stdio to %s", device);
6918 - if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
6919 - file = strdup (device);
6921 - asprintf (&file, "/dev/%s", device);
6923 - fd = open (file, O_RDWR | O_APPEND);
6926 + fd = open ("/dev/null", O_RDWR | O_APPEND);
6930 @@ -2199,19 +2000,11 @@ initialize_environment (state_t *state)
6931 if (!get_kernel_command_line (state))
6934 - check_verbosity (state);
6935 - check_logging (state);
6937 - ply_trace ("source built on %s", __DATE__);
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;
6947 + if (!state->default_tty)
6949 + if (getenv ("DISPLAY") != NULL && access (PLYMOUTH_PLUGIN_PATH "renderers/x11.so", F_OK) == 0)
6950 + state->default_tty = "/dev/tty";
6952 if (!state->default_tty)
6954 if (state->mode == PLY_MODE_SHUTDOWN)
6955 @@ -2232,12 +2025,17 @@ initialize_environment (state_t *state)
6959 - check_for_consoles (state, state->default_tty, false);
6960 + check_verbosity (state);
6961 + check_logging (state);
6963 - if (state->kernel_console_tty != NULL)
6964 - redirect_standard_io_to_device (state->kernel_console_tty);
6966 - redirect_standard_io_to_device (state->default_tty);
6967 + ply_trace ("source built on %s", __DATE__);
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 ();
6974 + redirect_standard_io_to_dev_null ();
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 };
6981 bool should_help = false;
6982 + bool no_boot_log = false;
6983 bool no_daemon = 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;
6990 + ply_device_manager_flags_t device_manager_flags = PLY_DEVICE_MANAGER_FLAGS_NONE;
6992 + state.start_time = ply_get_timestamp ();
6993 state.command_parser = ply_command_parser_new ("plymouthd", "Splash server");
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,
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,
7011 "debug-file", &debug_buffer_path,
7012 @@ -2434,6 +2237,8 @@ main (int argc,
7016 + state.no_boot_log = no_boot_log;
7019 signal (SIGPIPE, SIG_IGN);
7021 @@ -2505,6 +2310,7 @@ main (int argc,
7024 state.progress = ply_progress_new ();
7025 + state.splash_delay = NAN;
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;
7033 + find_override_splash (&state);
7034 + find_system_default_splash (&state);
7035 + find_distribution_default_splash (&state);
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;
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;
7044 + if (!plymouth_should_show_default_splash (&state))
7046 + /* don't bother listening for udev events if we're forcing details */
7047 + device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV;
7049 + /* don't ever delay showing the detailed splash */
7050 + state.splash_delay = NAN;
7053 + load_devices (&state, device_manager_flags);
7055 ply_trace ("entering event loop");
7056 exit_code = ply_event_loop_run (state.loop);
7057 ply_trace ("exited event loop");
7058 diff --git a/src/plugins/controls/label/Makefile.am b/src/plugins/controls/label/Makefile.am
7059 index 296203b..219930a 100644
7060 --- a/src/plugins/controls/label/Makefile.am
7061 +++ b/src/plugins/controls/label/Makefile.am
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 \
7068 diff --git a/src/plugins/renderers/drm/Makefile.am b/src/plugins/renderers/drm/Makefile.am
7069 index 2209b30..747f202 100644
7070 --- a/src/plugins/renderers/drm/Makefile.am
7071 +++ b/src/plugins/renderers/drm/Makefile.am
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
7083 -if ENABLE_LIBDRM_INTEL
7084 -drm_la_SOURCES += $(srcdir)/ply-renderer-i915-driver.h \
7085 - $(srcdir)/ply-renderer-i915-driver.c
7088 -if ENABLE_LIBDRM_RADEON
7089 -drm_la_SOURCES += $(srcdir)/ply-renderer-radeon-driver.h \
7090 - $(srcdir)/ply-renderer-radeon-driver.c
7093 -if ENABLE_LIBDRM_NOUVEAU
7094 -drm_la_SOURCES += $(srcdir)/ply-renderer-nouveau-driver.h \
7095 - $(srcdir)/ply-renderer-nouveau-driver.c
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
7107 diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c
7108 index db953e6..6677279 100644
7109 --- a/src/plugins/renderers/drm/plugin.c
7110 +++ b/src/plugins/renderers/drm/plugin.c
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"
7118 -#ifdef PLY_ENABLE_LIBDRM_RADEON
7119 -#include "ply-renderer-radeon-driver.h"
7121 -#ifdef PLY_ENABLE_LIBDRM_NOUVEAU
7122 -#include "ply-renderer-nouveau-driver.h"
7125 -#ifdef PLY_ENABLE_LIBKMS
7126 -#include "ply-renderer-libkms-driver.h"
7129 #define BYTES_PER_PIXEL (4)
7131 @@ -412,42 +399,6 @@ destroy_backend (ply_renderer_backend_t *backend)
7136 -find_driver_for_device (const char *device_name)
7139 - int major_number, minor_number;
7140 - struct stat file_attributes;
7141 - char *device_path;
7142 - char device_link_path[PATH_MAX + 1] = "";
7144 - if (stat (device_name, &file_attributes) < 0)
7147 - if (!S_ISCHR (file_attributes.st_mode))
7150 - major_number = major (file_attributes.st_rdev);
7151 - minor_number = minor (file_attributes.st_rdev);
7153 - asprintf (&device_path, "/sys/dev/char/%d:%d/device/driver",
7154 - major_number, minor_number);
7156 - if (readlink (device_path, device_link_path, sizeof (device_link_path) - 1) < 0)
7158 - free (device_path);
7161 - free (device_path);
7163 - driver = strrchr (device_link_path, '/');
7165 - if (driver == NULL)
7168 - return strdup (driver + strlen ("/"));
7172 activate (ply_renderer_backend_t *backend)
7174 @@ -508,72 +459,24 @@ on_active_vt_changed (ply_renderer_backend_t *backend)
7176 load_driver (ply_renderer_backend_t *backend)
7178 - char *driver_name;
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);
7189 - ply_trace ("drmOpen failed");
7190 - free (driver_name);
7191 + ply_trace ("open failed: %m");
7194 - backend->driver_interface = NULL;
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
7200 -#if defined(PLY_ENABLE_DEPRECATED_GDM_TRANSITION) && defined(PLY_ENABLE_LIBDRM_INTEL)
7201 - if (backend->driver_interface == NULL && strcmp (driver_name, "i915") == 0)
7203 - backend->driver_interface = ply_renderer_i915_driver_get_interface ();
7204 - backend->driver_supports_mapping_console = true;
7207 + backend->driver_interface = ply_renderer_generic_driver_get_interface (device_fd);
7208 + backend->driver_supports_mapping_console = false;
7210 if (backend->driver_interface == NULL)
7212 - backend->driver_interface = ply_renderer_generic_driver_get_interface (device_fd);
7213 - backend->driver_supports_mapping_console = false;
7216 -#ifdef PLY_ENABLE_LIBDRM_INTEL
7217 - if (backend->driver_interface == NULL && strcmp (driver_name, "i915") == 0)
7219 - backend->driver_interface = ply_renderer_i915_driver_get_interface ();
7220 - backend->driver_supports_mapping_console = true;
7223 -#ifdef PLY_ENABLE_LIBDRM_RADEON
7224 - if (backend->driver_interface == NULL && strcmp (driver_name, "radeon") == 0)
7226 - backend->driver_interface = ply_renderer_radeon_driver_get_interface ();
7227 - backend->driver_supports_mapping_console = false;
7230 -#ifdef PLY_ENABLE_LIBDRM_NOUVEAU
7231 - if (backend->driver_interface == NULL && strcmp (driver_name, "nouveau") == 0)
7233 - backend->driver_interface = ply_renderer_nouveau_driver_get_interface ();
7234 - backend->driver_supports_mapping_console = false;
7238 - free (driver_name);
7240 - if (backend->driver_interface == NULL)
7242 -#ifdef PLY_ENABLE_LIBKMS
7243 - backend->driver_interface = ply_renderer_libkms_driver_get_interface ();
7244 - backend->driver_supports_mapping_console = false;
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))
7256 + if (backend->terminal == NULL)
7259 if (!ply_terminal_open (backend->terminal))
7261 ply_trace ("could not open terminal: %m");
7262 @@ -647,10 +553,11 @@ close_device (ply_renderer_backend_t *backend)
7264 free_heads (backend);
7266 - ply_terminal_stop_watching_for_active_vt_change (backend->terminal,
7267 - (ply_terminal_active_vt_changed_handler_t)
7268 - on_active_vt_changed,
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,
7276 unload_driver (backend);
7278 @@ -985,10 +892,17 @@ map_to_device (ply_renderer_backend_t *backend)
7282 - if (ply_terminal_is_active (backend->terminal))
7283 - activate (backend);
7284 + if (backend->terminal != NULL)
7286 + if (ply_terminal_is_active (backend->terminal))
7287 + activate (backend);
7289 + ply_terminal_activate_vt (backend->terminal);
7292 - ply_terminal_activate_vt (backend->terminal);
7294 + activate (backend);
7299 @@ -1116,8 +1030,11 @@ reset_scan_out_buffer_if_needed (ply_renderer_backend_t *backend,
7300 drmModeCrtc *controller;
7301 bool did_reset = false;
7303 - if (!ply_terminal_is_active (backend->terminal))
7305 + if (backend->terminal != NULL)
7307 + if (!ply_terminal_is_active (backend->terminal))
7311 controller = drmModeGetCrtc (backend->device_fd, head->controller_id);
7313 @@ -1151,8 +1068,11 @@ flush_head (ply_renderer_backend_t *backend,
7314 if (!backend->is_active)
7317 - ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
7318 - ply_terminal_set_unbuffered_input (backend->terminal);
7319 + if (backend->terminal != NULL)
7321 + ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
7322 + ply_terminal_set_unbuffered_input (backend->terminal);
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));
7331 + if (backend->terminal == NULL)
7334 terminal_fd = ply_terminal_get_fd (backend->terminal);
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));
7341 + if (backend->terminal == NULL)
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;
7347 diff --git a/src/plugins/renderers/drm/ply-renderer-generic-driver.c b/src/plugins/renderers/drm/ply-renderer-generic-driver.c
7348 index 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
7354 ply_hashtable_t *buffers;
7356 + uint32_t requires_explicit_flushing : 1;
7360 @@ -123,7 +125,7 @@ create_driver (int device_fd)
7362 driver = calloc (1, sizeof (ply_renderer_driver_t));
7363 driver->device_fd = device_fd;
7365 + driver->requires_explicit_flushing = true;
7366 driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
7367 ply_hashtable_direct_compare);
7369 @@ -330,6 +332,22 @@ end_flush (ply_renderer_driver_t *driver,
7370 buffer = get_buffer_from_id (driver, buffer_id);
7372 assert (buffer != NULL);
7374 + if (driver->requires_explicit_flushing)
7376 + struct drm_clip_rect flush_area;
7379 + flush_area.x1 = 0;
7380 + flush_area.y1 = 0;
7381 + flush_area.x2 = buffer->width;
7382 + flush_area.y2 = buffer->height;
7384 + ret = drmModeDirtyFB (driver->device_fd, buffer->id, &flush_area, 1);
7386 + if (ret == -ENOSYS)
7387 + driver->requires_explicit_flushing = false;
7392 diff --git a/src/plugins/renderers/drm/ply-renderer-i915-driver.c b/src/plugins/renderers/drm/ply-renderer-i915-driver.c
7393 deleted file mode 100644
7394 index 907a061..0000000
7395 --- a/src/plugins/renderers/drm/ply-renderer-i915-driver.c
7398 -/* ply-renderer-i915-driver.c - interface to i915 drm driver
7400 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
7417 - * Written by: Ray Strode <rstrode@redhat.com>
7419 -#include "config.h"
7421 -#include "ply-renderer-i915-driver.h"
7423 -#include <arpa/inet.h>
7424 -#include <assert.h>
7427 -#include <signal.h>
7428 -#include <string.h>
7429 -#include <stdbool.h>
7430 -#include <stdint.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>
7441 -#include <i915_drm.h>
7442 -#include <intel_bufmgr.h>
7443 -#include <xf86drm.h>
7444 -#include <xf86drmMode.h>
7446 -#include "ply-hashtable.h"
7447 -#include "ply-logger.h"
7448 -#include "ply-renderer-driver.h"
7450 -typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
7452 -struct _ply_renderer_buffer
7454 - drm_intel_bo *object;
7456 - unsigned long width;
7457 - unsigned long height;
7458 - unsigned long row_stride;
7460 - uint32_t added_fb : 1;
7463 -struct _ply_renderer_driver
7466 - drm_intel_bufmgr *manager;
7468 - ply_hashtable_t *buffers;
7471 -static ply_renderer_driver_t *
7472 -create_driver (int device_fd)
7474 - ply_renderer_driver_t *driver;
7477 - driver = calloc (1, sizeof (ply_renderer_driver_t));
7478 - driver->device_fd = device_fd;
7480 - page_size = (int) sysconf (_SC_PAGE_SIZE);
7482 - driver->manager = drm_intel_bufmgr_gem_init (driver->device_fd, page_size);
7483 - if (driver->manager == NULL)
7485 - ply_trace ("intel buffer manager could not be initialized");
7490 - driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
7491 - ply_hashtable_direct_compare);
7497 -destroy_driver (ply_renderer_driver_t *driver)
7499 - ply_hashtable_free (driver->buffers);
7501 - ply_trace ("uninitializing intel buffer manager");
7502 - drm_intel_bufmgr_destroy (driver->manager);
7506 -static ply_renderer_buffer_t *
7507 -ply_renderer_buffer_new (ply_renderer_driver_t *driver,
7508 - drm_intel_bo *buffer_object,
7510 - unsigned long width,
7511 - unsigned long height,
7512 - unsigned long row_stride)
7514 - ply_renderer_buffer_t *buffer;
7516 - buffer = calloc (1, sizeof (ply_renderer_buffer_t));
7517 - buffer->object = buffer_object;
7519 - buffer->width = width;
7520 - buffer->height = height;
7521 - buffer->row_stride = row_stride;
7523 - ply_trace ("returning %lux%lu buffer with stride %lu",
7524 - width, height, row_stride);
7529 -static drm_intel_bo *
7530 -create_intel_bo_from_handle (ply_renderer_driver_t *driver,
7533 - struct drm_gem_flink flink_request;
7535 - drm_intel_bo *buffer_object;
7537 - /* FIXME: This can't be the right way to do this.
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.
7545 - memset (&flink_request, 0, sizeof (struct drm_gem_flink));
7546 - flink_request.handle = handle;
7548 - if (ioctl (driver->device_fd, DRM_IOCTL_GEM_FLINK, &flink_request) < 0)
7550 - ply_trace ("Could not export global name for handle %u", handle);
7554 - asprintf (&name, "buffer %u", handle);
7556 - buffer_object = drm_intel_bo_gem_create_from_name (driver->manager,
7557 - name, flink_request.name);
7560 - return buffer_object;
7563 -static ply_renderer_buffer_t *
7564 -ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
7565 - uint32_t buffer_id)
7567 - ply_renderer_buffer_t *buffer;
7569 - drm_intel_bo *buffer_object;
7571 - fb = drmModeGetFB (driver->device_fd, buffer_id);
7575 - ply_trace ("could not get FB with buffer id %u", buffer_id);
7579 - buffer_object = create_intel_bo_from_handle (driver, fb->handle);
7581 - if (buffer_object == NULL)
7583 - ply_trace ("could not create buffer object from handle %lu",
7584 - (unsigned long) fb->handle);
7585 - drmModeFreeFB (fb);
7589 - buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
7590 - fb->width, fb->height, fb->pitch);
7591 - drmModeFreeFB (fb);
7596 -static ply_renderer_buffer_t *
7597 -get_buffer_from_id (ply_renderer_driver_t *driver,
7598 - uint32_t buffer_id)
7600 - static ply_renderer_buffer_t *buffer;
7602 - buffer = ply_hashtable_lookup (driver->buffers,
7603 - (void *) (uintptr_t) buffer_id);
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)
7615 - ply_renderer_buffer_t *buffer;
7617 - buffer = get_buffer_from_id (driver, buffer_id);
7619 - if (buffer == NULL)
7621 - ply_trace ("could not fetch buffer %u, creating one", buffer_id);
7622 - buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
7624 - if (buffer == NULL)
7626 - ply_trace ("could not create buffer either %u", buffer_id);
7630 - ply_hashtable_insert (driver->buffers,
7631 - (void *) (uintptr_t) buffer_id,
7635 - if (width != NULL)
7636 - *width = buffer->width;
7638 - if (height != NULL)
7639 - *height = buffer->height;
7641 - if (row_stride != NULL)
7642 - *row_stride = buffer->row_stride;
7644 - ply_trace ("fetched %lux%lu buffer with stride %lu",
7645 - buffer->width, buffer->height, buffer->row_stride);
7650 -create_buffer (ply_renderer_driver_t *driver,
7651 - unsigned long width,
7652 - unsigned long height,
7653 - unsigned long *row_stride)
7655 - drm_intel_bo *buffer_object;
7656 - ply_renderer_buffer_t *buffer;
7657 - uint32_t buffer_id;
7659 - *row_stride = ply_round_to_multiple (width * 4, 256);
7661 - buffer_object = drm_intel_bo_alloc (driver->manager,
7663 - height * *row_stride, 0);
7665 - if (buffer_object == NULL)
7667 - ply_trace ("Could not allocate GEM object for frame buffer: %m");
7671 - if (drmModeAddFB (driver->device_fd, width, height,
7672 - 24, 32, *row_stride, buffer_object->handle,
7675 - ply_trace ("Could not set up GEM object as frame buffer: %m");
7676 - drm_intel_bo_unreference (buffer_object);
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,
7692 -map_buffer (ply_renderer_driver_t *driver,
7693 - uint32_t buffer_id)
7695 - ply_renderer_buffer_t *buffer;
7697 - buffer = get_buffer_from_id (driver, buffer_id);
7699 - assert (buffer != NULL);
7700 - drm_intel_gem_bo_map_gtt (buffer->object);
7706 -unmap_buffer (ply_renderer_driver_t *driver,
7707 - uint32_t buffer_id)
7709 - ply_renderer_buffer_t *buffer;
7711 - buffer = get_buffer_from_id (driver, buffer_id);
7713 - assert (buffer != NULL);
7714 - drm_intel_gem_bo_unmap_gtt (buffer->object);
7718 -begin_flush (ply_renderer_driver_t *driver,
7719 - uint32_t buffer_id)
7721 - ply_renderer_buffer_t *buffer;
7723 - buffer = get_buffer_from_id (driver, buffer_id);
7725 - assert (buffer != NULL);
7727 - return buffer->object->virtual;
7731 -end_flush (ply_renderer_driver_t *driver,
7732 - uint32_t buffer_id)
7734 - ply_renderer_buffer_t *buffer;
7736 - buffer = get_buffer_from_id (driver, buffer_id);
7738 - assert (buffer != NULL);
7742 -destroy_buffer (ply_renderer_driver_t *driver,
7743 - uint32_t buffer_id)
7745 - ply_renderer_buffer_t *buffer;
7747 - buffer = get_buffer_from_id (driver, buffer_id);
7749 - assert (buffer != NULL);
7751 - if (buffer->added_fb)
7752 - drmModeRmFB (driver->device_fd, buffer->id);
7754 - drm_intel_bo_unreference (buffer->object);
7756 - ply_hashtable_remove (driver->buffers,
7757 - (void *) (uintptr_t) buffer_id);
7761 -ply_renderer_driver_interface_t *
7762 -ply_renderer_i915_driver_get_interface (void)
7764 - static ply_renderer_driver_interface_t driver_interface =
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,
7777 - return &driver_interface;
7780 -/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
7781 diff --git a/src/plugins/renderers/drm/ply-renderer-i915-driver.h b/src/plugins/renderers/drm/ply-renderer-i915-driver.h
7782 deleted file mode 100644
7783 index dcc983c..0000000
7784 --- a/src/plugins/renderers/drm/ply-renderer-i915-driver.h
7787 -/* ply-renderer-i915-driver.h
7789 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
7806 - * Written By: Ray Strode <rstrode@redhat.com>
7808 -#ifndef PLY_RENDERER_I915_DRIVER_H
7809 -#define PLY_RENDERER_I915_DRIVER_H
7811 -#include "ply-renderer-driver.h"
7813 -#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
7814 -ply_renderer_driver_interface_t *ply_renderer_i915_driver_get_interface (void);
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 */
7819 diff --git a/src/plugins/renderers/drm/ply-renderer-libkms-driver.c b/src/plugins/renderers/drm/ply-renderer-libkms-driver.c
7820 deleted file mode 100644
7821 index 18c7ccf..0000000
7822 --- a/src/plugins/renderers/drm/ply-renderer-libkms-driver.c
7825 -/* ply-renderer-libkms-driver.c - interface to libkms abstraction over drm drivers
7827 - * Copyright (C) 2010 Red Hat, Inc.
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.
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.
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.
7844 - * Written by: Ray Strode <rstrode@redhat.com>
7846 -#include "config.h"
7848 -#include "ply-renderer-libkms-driver.h"
7850 -#include <arpa/inet.h>
7851 -#include <assert.h>
7854 -#include <signal.h>
7855 -#include <string.h>
7856 -#include <stdbool.h>
7857 -#include <stdint.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>
7868 -#include <libkms.h>
7869 -#include <xf86drm.h>
7870 -#include <xf86drmMode.h>
7872 -#include "ply-array.h"
7873 -#include "ply-hashtable.h"
7874 -#include "ply-logger.h"
7875 -#include "ply-renderer-driver.h"
7877 -typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
7879 -struct _ply_renderer_buffer
7881 - struct kms_bo *object;
7883 - unsigned long width;
7884 - unsigned long height;
7885 - unsigned long row_stride;
7887 - void *map_address;
7889 - uint32_t added_fb : 1;
7892 -struct _ply_renderer_driver
7895 - struct kms_driver *driver;
7897 - ply_hashtable_t *buffers;
7900 -static ply_renderer_driver_t *
7901 -create_driver (int device_fd)
7903 - ply_renderer_driver_t *driver;
7906 - driver = calloc (1, sizeof (ply_renderer_driver_t));
7907 - driver->device_fd = device_fd;
7909 - result = kms_create (driver->device_fd, &driver->driver);
7912 - ply_trace ("kms buffer driver could not be initialized: %d", result);
7917 - driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
7918 - ply_hashtable_direct_compare);
7924 -destroy_driver (ply_renderer_driver_t *driver)
7926 - ply_hashtable_free (driver->buffers);
7928 - ply_trace ("uninitializing kms buffer driver");
7929 - kms_destroy (&driver->driver);
7933 -static ply_renderer_buffer_t *
7934 -ply_renderer_buffer_new (ply_renderer_driver_t *driver,
7935 - struct kms_bo *buffer_object,
7937 - unsigned long width,
7938 - unsigned long height,
7939 - unsigned long row_stride)
7941 - ply_renderer_buffer_t *buffer;
7943 - buffer = calloc (1, sizeof (ply_renderer_buffer_t));
7944 - buffer->object = buffer_object;
7946 - buffer->width = width;
7947 - buffer->height = height;
7948 - buffer->row_stride = row_stride;
7950 - ply_trace ("returning %lux%lu buffer with stride %lu",
7951 - width, height, row_stride);
7956 -static ply_renderer_buffer_t *
7957 -get_buffer_from_id (ply_renderer_driver_t *driver,
7960 - static ply_renderer_buffer_t *buffer;
7962 - buffer = ply_hashtable_lookup (driver->buffers, (void *) (uintptr_t) id);
7967 -static struct kms_bo *
7968 -create_kms_bo_from_handle (ply_renderer_driver_t *driver,
7971 - struct drm_gem_flink flink_request;
7972 - struct kms_bo *buffer_object;
7973 - ply_array_t *attributes;
7976 - /* FIXME: This can't be the right way to do this.
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.
7984 - memset (&flink_request, 0, sizeof (struct drm_gem_flink));
7985 - flink_request.handle = handle;
7987 - if (ioctl (driver->device_fd, DRM_IOCTL_GEM_FLINK, &flink_request) < 0)
7989 - ply_trace ("Could not export global name for handle %u", handle);
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),
8001 - ply_array_free (attributes);
8005 - ply_trace ("could not create buffer object from global name %u: %d",
8006 - flink_request.name, result);
8010 - return buffer_object;
8013 -static ply_renderer_buffer_t *
8014 -ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
8015 - uint32_t buffer_id)
8017 - ply_renderer_buffer_t *buffer;
8019 - struct kms_bo *buffer_object;
8021 - fb = drmModeGetFB (driver->device_fd, buffer_id);
8025 - ply_trace ("could not get FB with buffer id %u", buffer_id);
8029 - buffer_object = create_kms_bo_from_handle (driver, fb->handle);
8031 - if (buffer_object == NULL)
8033 - ply_trace ("could not create buffer object from handle %lu",
8034 - (unsigned long) fb->handle);
8035 - drmModeFreeFB (fb);
8039 - buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
8040 - fb->width, fb->height, fb->pitch);
8041 - drmModeFreeFB (fb);
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)
8053 - ply_renderer_buffer_t *buffer;
8055 - buffer = get_buffer_from_id (driver, buffer_id);
8057 - if (buffer == NULL)
8059 - ply_trace ("could not fetch buffer %u, creating one", buffer_id);
8060 - buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
8062 - if (buffer == NULL)
8064 - ply_trace ("could not create buffer either %u", buffer_id);
8068 - ply_hashtable_insert (driver->buffers,
8069 - (void *) (uintptr_t) buffer_id,
8073 - if (width != NULL)
8074 - *width = buffer->width;
8076 - if (height != NULL)
8077 - *height = buffer->height;
8079 - if (row_stride != NULL)
8080 - *row_stride = buffer->row_stride;
8082 - ply_trace ("fetched %lux%lu buffer with stride %lu",
8083 - buffer->width, buffer->height, buffer->row_stride);
8088 -create_buffer (ply_renderer_driver_t *driver,
8089 - unsigned long width,
8090 - unsigned long height,
8091 - unsigned long *row_stride)
8093 - struct kms_bo *buffer_object;
8094 - ply_renderer_buffer_t *buffer;
8095 - uint32_t buffer_id;
8097 - unsigned int handle;
8098 - ply_array_t *attributes;
8100 - *row_stride = ply_round_to_multiple (width * 4, 256);
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),
8116 - ply_array_free (attributes);
8120 - ply_trace ("Could not allocate GEM object for frame buffer: %d", result);
8124 - result = kms_bo_get_prop (buffer_object, KMS_HANDLE, &handle);
8128 - ply_trace ("Could not retrieve handle from GEM object: %d", result);
8130 - kms_bo_destroy (&buffer_object);
8134 - if (drmModeAddFB (driver->device_fd, width, height,
8135 - 24, 32, *row_stride, handle,
8138 - ply_trace ("Could not set up GEM object as frame buffer: %m");
8139 - kms_bo_destroy (&buffer_object);
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,
8155 -map_buffer (ply_renderer_driver_t *driver,
8156 - uint32_t buffer_id)
8158 - ply_renderer_buffer_t *buffer;
8161 - buffer = get_buffer_from_id (driver, buffer_id);
8163 - assert (buffer != NULL);
8165 - result = kms_bo_map (buffer->object, &buffer->map_address);
8169 - ply_trace ("could not map buffer %u: %d", buffer_id, result);
8170 - buffer->map_address = MAP_FAILED;
8178 -unmap_buffer (ply_renderer_driver_t *driver,
8179 - uint32_t buffer_id)
8181 - ply_renderer_buffer_t *buffer;
8183 - buffer = get_buffer_from_id (driver, buffer_id);
8185 - assert (buffer != NULL);
8187 - kms_bo_unmap (buffer->object);
8188 - buffer->map_address = MAP_FAILED;
8192 -begin_flush (ply_renderer_driver_t *driver,
8193 - uint32_t buffer_id)
8195 - ply_renderer_buffer_t *buffer;
8197 - buffer = get_buffer_from_id (driver, buffer_id);
8199 - assert (buffer != NULL);
8201 - return (char *) buffer->map_address;
8205 -end_flush (ply_renderer_driver_t *driver,
8206 - uint32_t buffer_id)
8208 - ply_renderer_buffer_t *buffer;
8210 - buffer = get_buffer_from_id (driver, buffer_id);
8212 - assert (buffer != NULL);
8216 -destroy_buffer (ply_renderer_driver_t *driver,
8217 - uint32_t buffer_id)
8219 - ply_renderer_buffer_t *buffer;
8221 - buffer = get_buffer_from_id (driver, buffer_id);
8223 - assert (buffer != NULL);
8225 - if (buffer->added_fb)
8226 - drmModeRmFB (driver->device_fd, buffer->id);
8228 - kms_bo_destroy (&buffer->object);
8230 - ply_hashtable_remove (driver->buffers,
8231 - (void *) (uintptr_t) buffer_id);
8235 -ply_renderer_driver_interface_t *
8236 -ply_renderer_libkms_driver_get_interface (void)
8238 - static ply_renderer_driver_interface_t driver_interface =
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,
8251 - return &driver_interface;
8254 -/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
8255 diff --git a/src/plugins/renderers/drm/ply-renderer-libkms-driver.h b/src/plugins/renderers/drm/ply-renderer-libkms-driver.h
8256 deleted file mode 100644
8257 index b419a94..0000000
8258 --- a/src/plugins/renderers/drm/ply-renderer-libkms-driver.h
8261 -/* ply-renderer-kms-driver.h
8263 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
8280 - * Written By: Ray Strode <rstrode@redhat.com>
8282 -#ifndef PLY_RENDERER_LIBKMS_DRIVER_H
8283 -#define PLY_RENDERER_LIBKMS_DRIVER_H
8285 -#include "ply-renderer-driver.h"
8287 -#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
8288 -ply_renderer_driver_interface_t *ply_renderer_libkms_driver_get_interface (void);
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 */
8293 diff --git a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.c b/src/plugins/renderers/drm/ply-renderer-nouveau-driver.c
8294 deleted file mode 100644
8295 index 2cef56e..0000000
8296 --- a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.c
8299 -/* ply-renderer-nouveau-driver.c - interface to nouveau drm driver
8301 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
8318 - * Written by: Ray Strode <rstrode@redhat.com>
8320 -#include "config.h"
8322 -#include "ply-renderer-nouveau-driver.h"
8324 -#include <arpa/inet.h>
8325 -#include <assert.h>
8328 -#include <signal.h>
8329 -#include <string.h>
8330 -#include <stdbool.h>
8331 -#include <stdint.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>
8342 -#include <nouveau_drm.h>
8343 -#include <nouveau_drmif.h>
8344 -#include <nouveau_bo.h>
8345 -#include <xf86drm.h>
8346 -#include <xf86drmMode.h>
8348 -#include "ply-hashtable.h"
8349 -#include "ply-logger.h"
8350 -#include "ply-renderer-driver.h"
8352 -typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
8354 -struct _ply_renderer_buffer
8356 - struct nouveau_bo *object;
8358 - unsigned long width;
8359 - unsigned long height;
8360 - unsigned long row_stride;
8362 - uint32_t added_fb : 1;
8365 -struct _ply_renderer_driver
8368 - struct nouveau_device *device;
8370 - ply_hashtable_t *buffers;
8373 -static ply_renderer_driver_t *
8374 -create_driver (int device_fd)
8376 - ply_renderer_driver_t *driver;
8378 - driver = calloc (1, sizeof (ply_renderer_driver_t));
8379 - driver->device_fd = device_fd;
8381 - if (nouveau_device_open_existing (&driver->device, true,
8382 - driver->device_fd, 0) < 0)
8384 - ply_trace ("could not open nouveau device");
8389 - driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
8390 - ply_hashtable_direct_compare);
8396 -destroy_driver (ply_renderer_driver_t *driver)
8398 - ply_hashtable_free (driver->buffers);
8400 - ply_trace ("closing nouveau device");
8401 - nouveau_device_close (&driver->device);
8405 -static ply_renderer_buffer_t *
8406 -ply_renderer_buffer_new (ply_renderer_driver_t *driver,
8407 - struct nouveau_bo *buffer_object,
8409 - unsigned long width,
8410 - unsigned long height,
8411 - unsigned long row_stride)
8413 - ply_renderer_buffer_t *buffer;
8415 - buffer = calloc (1, sizeof (ply_renderer_buffer_t));
8416 - buffer->object = buffer_object;
8418 - buffer->width = width;
8419 - buffer->height = height;
8420 - buffer->row_stride = row_stride;
8422 - ply_trace ("returning %lux%lu buffer with stride %lu",
8423 - width, height, row_stride);
8428 -static ply_renderer_buffer_t *
8429 -ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
8430 - uint32_t buffer_id)
8432 - ply_renderer_buffer_t *buffer;
8434 - struct nouveau_bo *buffer_object;
8436 - fb = drmModeGetFB (driver->device_fd, buffer_id);
8440 - ply_trace ("could not get FB with buffer id %u", buffer_id);
8444 - if (nouveau_bo_wrap (driver->device,
8445 - fb->handle, &buffer_object) < 0)
8447 - ply_trace ("could not create buffer object from handle %lu",
8448 - (unsigned long) fb->handle);
8449 - drmModeFreeFB (fb);
8453 - buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
8454 - fb->width, fb->height, fb->pitch);
8455 - drmModeFreeFB (fb);
8460 -static ply_renderer_buffer_t *
8461 -get_buffer_from_id (ply_renderer_driver_t *driver,
8464 - static ply_renderer_buffer_t *buffer;
8466 - buffer = ply_hashtable_lookup (driver->buffers, (void *) (uintptr_t) id);
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)
8478 - ply_renderer_buffer_t *buffer;
8480 - buffer = get_buffer_from_id (driver, buffer_id);
8482 - if (buffer == NULL)
8484 - ply_trace ("could not fetch buffer %u, creating one", buffer_id);
8485 - buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
8487 - if (buffer == NULL)
8489 - ply_trace ("could not create buffer either %u", buffer_id);
8493 - ply_hashtable_insert (driver->buffers,
8494 - (void *) (uintptr_t) buffer_id,
8498 - if (width != NULL)
8499 - *width = buffer->width;
8501 - if (height != NULL)
8502 - *height = buffer->height;
8504 - if (row_stride != NULL)
8505 - *row_stride = buffer->row_stride;
8507 - ply_trace ("fetched %lux%lu buffer with stride %lu",
8508 - buffer->width, buffer->height, buffer->row_stride);
8514 -create_buffer (ply_renderer_driver_t *driver,
8515 - unsigned long width,
8516 - unsigned long height,
8517 - unsigned long *row_stride)
8519 - struct nouveau_bo *buffer_object;
8520 - ply_renderer_buffer_t *buffer;
8521 - uint32_t buffer_id;
8523 - *row_stride = ply_round_to_multiple (width * 4, 256);
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)
8530 - ply_trace ("Could not allocate GEM object for frame buffer: %m");
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)
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,
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);
8548 - nouveau_bo_unmap (buffer_object);
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,
8562 -map_buffer (ply_renderer_driver_t *driver,
8563 - uint32_t buffer_id)
8565 - ply_renderer_buffer_t *buffer;
8567 - buffer = get_buffer_from_id (driver, buffer_id);
8569 - assert (buffer != NULL);
8571 - return nouveau_bo_map (buffer->object, NOUVEAU_BO_WR) == 0;
8575 -unmap_buffer (ply_renderer_driver_t *driver,
8576 - uint32_t buffer_id)
8578 - ply_renderer_buffer_t *buffer;
8580 - buffer = get_buffer_from_id (driver, buffer_id);
8582 - assert (buffer != NULL);
8584 - nouveau_bo_unmap (buffer->object);
8588 -begin_flush (ply_renderer_driver_t *driver,
8589 - uint32_t buffer_id)
8591 - ply_renderer_buffer_t *buffer;
8593 - buffer = get_buffer_from_id (driver, buffer_id);
8595 - assert (buffer != NULL);
8597 - return buffer->object->map;
8601 -end_flush (ply_renderer_driver_t *driver,
8602 - uint32_t buffer_id)
8604 - ply_renderer_buffer_t *buffer;
8606 - buffer = get_buffer_from_id (driver, buffer_id);
8608 - assert (buffer != NULL);
8612 -destroy_buffer (ply_renderer_driver_t *driver,
8613 - uint32_t buffer_id)
8615 - ply_renderer_buffer_t *buffer;
8617 - buffer = get_buffer_from_id (driver, buffer_id);
8619 - assert (buffer != NULL);
8621 - if (buffer->added_fb)
8622 - drmModeRmFB (driver->device_fd, buffer->id);
8624 - nouveau_bo_ref (NULL, &buffer->object);
8626 - ply_hashtable_remove (driver->buffers,
8627 - (void *) (uintptr_t) buffer_id);
8631 -ply_renderer_driver_interface_t *
8632 -ply_renderer_nouveau_driver_get_interface (void)
8634 - static ply_renderer_driver_interface_t driver_interface =
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,
8647 - return &driver_interface;
8650 -/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
8651 diff --git a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.h b/src/plugins/renderers/drm/ply-renderer-nouveau-driver.h
8652 deleted file mode 100644
8653 index 1baed4a..0000000
8654 --- a/src/plugins/renderers/drm/ply-renderer-nouveau-driver.h
8657 -/* ply-renderer-nouveau-driver.h
8659 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
8676 - * Written By: Ray Strode <rstrode@redhat.com>
8678 -#ifndef PLY_RENDERER_NOUVEAU_DRIVER_H
8679 -#define PLY_RENDERER_NOUVEAU_DRIVER_H
8681 -#include "ply-renderer-driver.h"
8683 -#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
8684 -ply_renderer_driver_interface_t *ply_renderer_nouveau_driver_get_interface (void);
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 */
8689 diff --git a/src/plugins/renderers/drm/ply-renderer-radeon-driver.c b/src/plugins/renderers/drm/ply-renderer-radeon-driver.c
8690 deleted file mode 100644
8691 index 36cee47..0000000
8692 --- a/src/plugins/renderers/drm/ply-renderer-radeon-driver.c
8695 -/* ply-renderer-radeon-driver.c - interface to radeon drm driver
8697 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
8714 - * Written by: Ray Strode <rstrode@redhat.com>
8716 -#include "config.h"
8718 -#include "ply-renderer-radeon-driver.h"
8720 -#include <arpa/inet.h>
8721 -#include <assert.h>
8724 -#include <signal.h>
8725 -#include <string.h>
8726 -#include <stdbool.h>
8727 -#include <stdint.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>
8738 -#include <radeon_drm.h>
8739 -#include <radeon_bo.h>
8740 -#include <radeon_bo_gem.h>
8741 -#include <xf86drm.h>
8742 -#include <xf86drmMode.h>
8744 -#include "ply-hashtable.h"
8745 -#include "ply-logger.h"
8746 -#include "ply-renderer-driver.h"
8748 -typedef struct _ply_renderer_buffer ply_renderer_buffer_t;
8750 -struct _ply_renderer_buffer
8752 - struct radeon_bo *object;
8754 - unsigned long width;
8755 - unsigned long height;
8756 - unsigned long row_stride;
8758 - uint32_t added_fb : 1;
8761 -struct _ply_renderer_driver
8764 - struct radeon_bo_manager *manager;
8766 - ply_hashtable_t *buffers;
8769 -static ply_renderer_driver_t *
8770 -create_driver (int device_fd)
8772 - ply_renderer_driver_t *driver;
8774 - driver = calloc (1, sizeof (ply_renderer_driver_t));
8775 - driver->device_fd = device_fd;
8777 - driver->manager = radeon_bo_manager_gem_ctor (driver->device_fd);
8778 - if (driver->manager == NULL)
8780 - ply_trace ("radeon buffer manager could not be initialized");
8785 - driver->buffers = ply_hashtable_new (ply_hashtable_direct_hash,
8786 - ply_hashtable_direct_compare);
8792 -destroy_driver (ply_renderer_driver_t *driver)
8794 - ply_hashtable_free (driver->buffers);
8796 - ply_trace ("uninitializing radeon buffer manager");
8797 - radeon_bo_manager_gem_dtor (driver->manager);
8801 -static ply_renderer_buffer_t *
8802 -ply_renderer_buffer_new (ply_renderer_driver_t *driver,
8803 - struct radeon_bo *buffer_object,
8805 - unsigned long width,
8806 - unsigned long height,
8807 - unsigned long row_stride)
8809 - ply_renderer_buffer_t *buffer;
8811 - buffer = calloc (1, sizeof (ply_renderer_buffer_t));
8812 - buffer->object = buffer_object;
8814 - buffer->width = width;
8815 - buffer->height = height;
8816 - buffer->row_stride = row_stride;
8818 - ply_trace ("returning %lux%lu buffer with stride %lu",
8819 - width, height, row_stride);
8824 -static ply_renderer_buffer_t *
8825 -get_buffer_from_id (ply_renderer_driver_t *driver,
8828 - static ply_renderer_buffer_t *buffer;
8830 - buffer = ply_hashtable_lookup (driver->buffers, (void *) (uintptr_t) id);
8835 -static struct radeon_bo *
8836 -create_radeon_bo_from_handle (ply_renderer_driver_t *driver,
8839 - struct drm_gem_flink flink_request;
8840 - struct radeon_bo *buffer_object;
8842 - /* FIXME: This can't be the right way to do this.
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.
8850 - memset (&flink_request, 0, sizeof (struct drm_gem_flink));
8851 - flink_request.handle = handle;
8853 - if (ioctl (driver->device_fd, DRM_IOCTL_GEM_FLINK, &flink_request) < 0)
8855 - ply_trace ("Could not export global name for handle %u", handle);
8859 - buffer_object = radeon_bo_open (driver->manager, flink_request.name,
8860 - 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
8862 - return buffer_object;
8865 -static ply_renderer_buffer_t *
8866 -ply_renderer_buffer_new_from_id (ply_renderer_driver_t *driver,
8867 - uint32_t buffer_id)
8869 - ply_renderer_buffer_t *buffer;
8871 - struct radeon_bo *buffer_object;
8873 - fb = drmModeGetFB (driver->device_fd, buffer_id);
8877 - ply_trace ("could not get FB with buffer id %u", buffer_id);
8881 - buffer_object = create_radeon_bo_from_handle (driver, fb->handle);
8883 - if (buffer_object == NULL)
8885 - ply_trace ("could not create buffer object from handle %lu",
8886 - (unsigned long) fb->handle);
8887 - drmModeFreeFB (fb);
8891 - buffer = ply_renderer_buffer_new (driver, buffer_object, buffer_id,
8892 - fb->width, fb->height, fb->pitch);
8893 - drmModeFreeFB (fb);
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)
8906 - ply_renderer_buffer_t *buffer;
8908 - buffer = get_buffer_from_id (driver, buffer_id);
8910 - if (buffer == NULL)
8912 - ply_trace ("could not fetch buffer %u, creating one", buffer_id);
8913 - buffer = ply_renderer_buffer_new_from_id (driver, buffer_id);
8915 - if (buffer == NULL)
8917 - ply_trace ("could not create buffer either %u", buffer_id);
8921 - ply_hashtable_insert (driver->buffers,
8922 - (void *) (uintptr_t) buffer_id,
8926 - if (width != NULL)
8927 - *width = buffer->width;
8929 - if (height != NULL)
8930 - *height = buffer->height;
8932 - if (row_stride != NULL)
8933 - *row_stride = buffer->row_stride;
8935 - ply_trace ("fetched %lux%lu buffer with stride %lu",
8936 - buffer->width, buffer->height, buffer->row_stride);
8941 -create_buffer (ply_renderer_driver_t *driver,
8942 - unsigned long width,
8943 - unsigned long height,
8944 - unsigned long *row_stride)
8946 - struct radeon_bo *buffer_object;
8947 - ply_renderer_buffer_t *buffer;
8948 - uint32_t buffer_id;
8950 - *row_stride = ply_round_to_multiple (width * 4, 256);
8952 - buffer_object = radeon_bo_open (driver->manager, 0,
8953 - height * *row_stride,
8954 - 0, RADEON_GEM_DOMAIN_GTT, 0);
8956 - if (buffer_object == NULL)
8958 - ply_trace ("Could not allocate GEM object for frame buffer: %m");
8962 - if (drmModeAddFB (driver->device_fd, width, height,
8963 - 24, 32, *row_stride, buffer_object->handle,
8966 - ply_trace ("Could not set up GEM object as frame buffer: %m");
8967 - radeon_bo_unref (buffer_object);
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,
8983 -map_buffer (ply_renderer_driver_t *driver,
8984 - uint32_t buffer_id)
8986 - ply_renderer_buffer_t *buffer;
8988 - buffer = get_buffer_from_id (driver, buffer_id);
8990 - assert (buffer != NULL);
8992 - return radeon_bo_map (buffer->object, true) == 0;
8996 -unmap_buffer (ply_renderer_driver_t *driver,
8997 - uint32_t buffer_id)
8999 - ply_renderer_buffer_t *buffer;
9001 - buffer = get_buffer_from_id (driver, buffer_id);
9003 - assert (buffer != NULL);
9005 - radeon_bo_unmap (buffer->object);
9009 -begin_flush (ply_renderer_driver_t *driver,
9010 - uint32_t buffer_id)
9012 - ply_renderer_buffer_t *buffer;
9014 - buffer = get_buffer_from_id (driver, buffer_id);
9016 - assert (buffer != NULL);
9018 - return buffer->object->ptr;
9022 -end_flush (ply_renderer_driver_t *driver,
9023 - uint32_t buffer_id)
9025 - ply_renderer_buffer_t *buffer;
9027 - buffer = get_buffer_from_id (driver, buffer_id);
9029 - assert (buffer != NULL);
9033 -destroy_buffer (ply_renderer_driver_t *driver,
9034 - uint32_t buffer_id)
9036 - ply_renderer_buffer_t *buffer;
9038 - buffer = get_buffer_from_id (driver, buffer_id);
9040 - assert (buffer != NULL);
9042 - if (buffer->added_fb)
9043 - drmModeRmFB (driver->device_fd, buffer->id);
9045 - radeon_bo_unref (buffer->object);
9047 - ply_hashtable_remove (driver->buffers,
9048 - (void *) (uintptr_t) buffer_id);
9052 -ply_renderer_driver_interface_t *
9053 -ply_renderer_radeon_driver_get_interface (void)
9055 - static ply_renderer_driver_interface_t driver_interface =
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,
9068 - return &driver_interface;
9071 -/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
9072 diff --git a/src/plugins/renderers/drm/ply-renderer-radeon-driver.h b/src/plugins/renderers/drm/ply-renderer-radeon-driver.h
9073 deleted file mode 100644
9074 index dcec1b1..0000000
9075 --- a/src/plugins/renderers/drm/ply-renderer-radeon-driver.h
9078 -/* ply-renderer-radeon-driver.h
9080 - * Copyright (C) 2009 Red Hat, Inc.
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.
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.
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.
9097 - * Written By: Ray Strode <rstrode@redhat.com>
9099 -#ifndef PLY_RENDERER_RADEON_DRIVER_H
9100 -#define PLY_RENDERER_RADEON_DRIVER_H
9102 -#include "ply-renderer-driver.h"
9104 -#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
9105 -ply_renderer_driver_interface_t *ply_renderer_radeon_driver_get_interface (void);
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 */
9110 diff --git a/src/plugins/renderers/frame-buffer/Makefile.am b/src/plugins/renderers/frame-buffer/Makefile.am
9111 index 44f9d6a..12e1470 100644
9112 --- a/src/plugins/renderers/frame-buffer/Makefile.am
9113 +++ b/src/plugins/renderers/frame-buffer/Makefile.am
9115 -INCLUDES = -I$(top_srcdir) \
9116 +AM_CPPFLAGS = -I$(top_srcdir) \
9117 -I$(srcdir)/../../../libply \
9118 -I$(srcdir)/../../../libply-splash-core \
9119 -I$(srcdir)/../../.. \
9120 diff --git a/src/plugins/renderers/frame-buffer/plugin.c b/src/plugins/renderers/frame-buffer/plugin.c
9121 index 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)
9128 + if (backend->terminal == NULL)
9131 if (!ply_terminal_open (backend->terminal))
9133 ply_trace ("could not open terminal: %m");
9134 @@ -376,10 +379,11 @@ static void
9135 close_device (ply_renderer_backend_t *backend)
9138 - ply_terminal_stop_watching_for_active_vt_change (backend->terminal,
9139 - (ply_terminal_active_vt_changed_handler_t)
9140 - on_active_vt_changed,
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,
9147 uninitialize_head (backend, &backend->head);
9149 close (backend->device_fd);
9150 @@ -546,15 +550,22 @@ map_to_device (ply_renderer_backend_t *backend)
9154 - if (ply_terminal_is_active (backend->terminal))
9155 + if (backend->terminal != NULL)
9157 - ply_trace ("already on right vt, activating");
9158 - activate (backend);
9159 + if (ply_terminal_is_active (backend->terminal))
9161 + ply_trace ("already on right vt, activating");
9162 + activate (backend);
9166 + ply_trace ("on wrong vt, changing vts");
9167 + ply_terminal_activate_vt (backend->terminal);
9172 - ply_trace ("on wrong vt, changing vts");
9173 - ply_terminal_activate_vt (backend->terminal);
9174 + activate (backend);
9178 @@ -590,8 +601,11 @@ flush_head (ply_renderer_backend_t *backend,
9179 if (!backend->is_active)
9182 - ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
9183 - ply_terminal_set_unbuffered_input (backend->terminal);
9184 + if (backend->terminal != NULL)
9186 + ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
9187 + ply_terminal_set_unbuffered_input (backend->terminal);
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));
9196 + if (backend->terminal == NULL)
9199 terminal_fd = ply_terminal_get_fd (backend->terminal);
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));
9206 + if (backend->terminal == NULL)
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;
9212 diff --git a/src/plugins/renderers/x11/Makefile.am b/src/plugins/renderers/x11/Makefile.am
9213 index fd142c0..33513ac 100644
9214 --- a/src/plugins/renderers/x11/Makefile.am
9215 +++ b/src/plugins/renderers/x11/Makefile.am
9217 -INCLUDES = -I$(top_srcdir) \
9218 +AM_CPPFLAGS = -I$(top_srcdir) \
9219 -I$(srcdir)/../../../libply \
9220 -I$(srcdir)/../../../libply-splash-core \
9221 -I$(srcdir)/../../.. \
9222 diff --git a/src/plugins/splash/Makefile.am b/src/plugins/splash/Makefile.am
9223 index 02f94fa..a19197b 100644
9224 --- a/src/plugins/splash/Makefile.am
9225 +++ b/src/plugins/splash/Makefile.am
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
9230 diff --git a/src/plugins/splash/details/Makefile.am b/src/plugins/splash/details/Makefile.am
9231 index a656129..3be4755 100644
9232 --- a/src/plugins/splash/details/Makefile.am
9233 +++ b/src/plugins/splash/details/Makefile.am
9235 -INCLUDES = -I$(top_srcdir) \
9236 +AM_CPPFLAGS = -I$(top_srcdir) \
9237 -I$(srcdir)/../../../libply \
9238 -I$(srcdir)/../../../libply-splash-core \
9239 -I$(srcdir)/../../.. \
9240 diff --git a/src/plugins/splash/fade-throbber/Makefile.am b/src/plugins/splash/fade-throbber/Makefile.am
9241 index f7b559b..6bbb490 100644
9242 --- a/src/plugins/splash/fade-throbber/Makefile.am
9243 +++ b/src/plugins/splash/fade-throbber/Makefile.am
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 \
9250 diff --git a/src/plugins/splash/script/Makefile.am b/src/plugins/splash/script/Makefile.am
9251 index 0f2b0f7..ce46df6 100644
9252 --- a/src/plugins/splash/script/Makefile.am
9253 +++ b/src/plugins/splash/script/Makefile.am
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 \
9260 diff --git a/src/plugins/splash/script/script-debug.c b/src/plugins/splash/script/script-debug.c
9261 index 355c2b2..118574b 100644
9262 --- a/src/plugins/splash/script/script-debug.c
9263 +++ b/src/plugins/splash/script/script-debug.c
9266 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9268 +#ifdef HAVE_CONFIG_H
9269 +#include "config.h"
9272 #include "ply-hashtable.h"
9275 diff --git a/src/plugins/splash/script/script-execute.c b/src/plugins/splash/script/script-execute.c
9276 index 6abd3a6..c06959b 100644
9277 --- a/src/plugins/splash/script/script-execute.c
9278 +++ b/src/plugins/splash/script/script-execute.c
9281 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9283 -#define _GNU_SOURCE
9285 +#ifdef HAVE_CONFIG_H
9286 +#include "config.h"
9289 #include "ply-hashtable.h"
9290 #include "ply-list.h"
9291 #include "ply-logger.h"
9292 diff --git a/src/plugins/splash/script/script-lib-image.c b/src/plugins/splash/script/script-lib-image.c
9293 index 5be27fb..f08be31 100644
9294 --- a/src/plugins/splash/script/script-lib-image.c
9295 +++ b/src/plugins/splash/script/script-lib-image.c
9298 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9300 -#define _GNU_SOURCE
9302 +#include "config.h"
9304 #include "ply-image.h"
9305 #include "ply-label.h"
9306 #include "ply-pixel-buffer.h"
9311 -#include "config.h"
9313 #include "script-lib-image.script.h"
9315 static void image_free (script_obj_t *obj)
9316 diff --git a/src/plugins/splash/script/script-lib-math.c b/src/plugins/splash/script/script-lib-math.c
9317 index a1afc04..3f2dc79 100644
9318 --- a/src/plugins/splash/script/script-lib-math.c
9319 +++ b/src/plugins/splash/script/script-lib-math.c
9322 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9324 -#define _GNU_SOURCE
9326 +#include "config.h"
9328 +#include "ply-utils.h"
9330 #include "script-parse.h"
9331 #include "script-execute.h"
9336 -#include "config.h"
9338 #include "script-lib-math.script.h"
9340 diff --git a/src/plugins/splash/script/script-lib-plymouth.c b/src/plugins/splash/script/script-lib-plymouth.c
9341 index 5c648a6..ab2ec44 100644
9342 --- a/src/plugins/splash/script/script-lib-plymouth.c
9343 +++ b/src/plugins/splash/script/script-lib-plymouth.c
9346 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9348 -#define _GNU_SOURCE
9350 +#include "config.h"
9352 #include "ply-boot-splash-plugin.h"
9353 #include "ply-utils.h"
9359 -#include "config.h"
9361 #include "script-lib-plymouth.script.h"
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");
9368 + case PLY_BOOT_SPLASH_MODE_INVALID:
9370 obj = script_obj_new_string ("unknown");
9372 diff --git a/src/plugins/splash/script/script-lib-string.c b/src/plugins/splash/script/script-lib-string.c
9373 index dbd63fe..0b836eb 100644
9374 --- a/src/plugins/splash/script/script-lib-string.c
9375 +++ b/src/plugins/splash/script/script-lib-string.c
9378 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9380 -#define _GNU_SOURCE
9382 +#include "config.h"
9385 #include "script-parse.h"
9386 #include "script-execute.h"
9391 -#include "config.h"
9393 #include "script-lib-string.script.h"
9396 diff --git a/src/plugins/splash/script/script-object.c b/src/plugins/splash/script/script-object.c
9397 index 465fef6..7c16c94 100644
9398 --- a/src/plugins/splash/script/script-object.c
9399 +++ b/src/plugins/splash/script/script-object.c
9402 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9404 -#define _GNU_SOURCE
9406 +#ifdef HAVE_CONFIG_H
9407 +#include "config.h"
9410 #include "ply-hashtable.h"
9411 #include "ply-list.h"
9412 #include "ply-bitarray.h"
9413 diff --git a/src/plugins/splash/script/script-parse.c b/src/plugins/splash/script/script-parse.c
9414 index 10eb667..4adf273 100644
9415 --- a/src/plugins/splash/script/script-parse.c
9416 +++ b/src/plugins/splash/script/script-parse.c
9419 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9421 -#define _GNU_SOURCE
9423 +#ifdef HAVE_CONFIG_H
9424 +#include "config.h"
9427 #include "ply-hashtable.h"
9428 #include "ply-list.h"
9429 #include "ply-bitarray.h"
9430 diff --git a/src/plugins/splash/script/script-scan.c b/src/plugins/splash/script/script-scan.c
9431 index ead752f..5d1aa64 100644
9432 --- a/src/plugins/splash/script/script-scan.c
9433 +++ b/src/plugins/splash/script/script-scan.c
9436 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9438 +#ifdef HAVE_CONFIG_H
9439 +#include "config.h"
9446 #include <stdbool.h>
9449 +#include <limits.h>
9451 #include "ply-bitarray.h"
9452 #include "script-scan.h"
9453 @@ -61,7 +66,7 @@ static script_scan_t *script_scan_new (void)
9455 script_scan_t *script_scan_file (const char *filename)
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,
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)
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++)
9476 scan->tokens[i] = malloc (sizeof (script_scan_token_t));
9477 scan->tokens[i]->type = SCRIPT_SCAN_TOKEN_TYPE_EMPTY;
9478 diff --git a/src/plugins/splash/script/script.c b/src/plugins/splash/script/script.c
9479 index 635a8b4..3290825 100644
9480 --- a/src/plugins/splash/script/script.c
9481 +++ b/src/plugins/splash/script/script.c
9484 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
9486 -#define _GNU_SOURCE
9488 +#ifdef HAVE_CONFIG_H
9489 +#include "config.h"
9492 #include "ply-hashtable.h"
9493 #include "ply-list.h"
9494 #include "ply-bitarray.h"
9495 diff --git a/src/plugins/splash/space-flares/Makefile.am b/src/plugins/splash/space-flares/Makefile.am
9496 index 0d22a2e..24fdb39 100644
9497 --- a/src/plugins/splash/space-flares/Makefile.am
9498 +++ b/src/plugins/splash/space-flares/Makefile.am
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 \
9505 diff --git a/src/plugins/splash/text/Makefile.am b/src/plugins/splash/text/Makefile.am
9506 index f4c21a8..7ccefb2 100644
9507 --- a/src/plugins/splash/text/Makefile.am
9508 +++ b/src/plugins/splash/text/Makefile.am
9510 -INCLUDES = -I$(top_srcdir) \
9511 +AM_CPPFLAGS = -I$(top_srcdir) \
9512 -I$(srcdir)/../../../libply \
9513 -I$(srcdir)/../../../libply-splash-core \
9514 -I$(srcdir)/../../.. \
9515 diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c
9516 index af81635..fb97c14 100644
9517 --- a/src/plugins/splash/text/plugin.c
9518 +++ b/src/plugins/splash/text/plugin.c
9520 -/* text.c - boot splash plugin
9522 - * Copyright (C) 2008 Red Hat, Inc.
9524 + * Copyright (C) 2008-2012 Red Hat, Inc.
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
9529 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
9532 - * Written by: Adam Jackson <ajax@redhat.com>
9533 - * Ray Strode <rstrode@redhat.com>
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"
9545 #include <linux/kd.h>
9546 @@ -78,7 +75,7 @@ typedef struct
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;
9555 @@ -97,7 +94,7 @@ view_new (ply_boot_splash_plugin_t *plugin,
9556 view->plugin = plugin;
9557 view->display = display;
9559 - view->progress_bar = ply_text_progress_bar_new ();
9560 + view->step_bar = ply_text_step_bar_new ();
9564 @@ -105,7 +102,7 @@ view_new (ply_boot_splash_plugin_t *plugin,
9566 view_free (view_t *view)
9568 - ply_text_progress_bar_free (view->progress_bar);
9569 + ply_text_step_bar_free (view->step_bar);
9573 @@ -180,10 +177,10 @@ view_start_animation (view_t *view)
9575 ply_terminal_set_color_hex_value (terminal,
9576 PLY_TERMINAL_COLOR_BLUE,
9579 ply_terminal_set_color_hex_value (terminal,
9580 PLY_TERMINAL_COLOR_BROWN,
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)
9588 if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
9590 - ply_text_progress_bar_hide (view->progress_bar);
9591 + ply_text_step_bar_hide (view->step_bar);
9595 - ply_text_progress_bar_show (view->progress_bar,
9596 + ply_text_step_bar_show (view->step_bar,
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);
9604 - ply_text_progress_bar_hide (view->progress_bar);
9605 + ply_text_step_bar_hide (view->step_bar);
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);
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);
9620 diff --git a/src/plugins/splash/throbgress/Makefile.am b/src/plugins/splash/throbgress/Makefile.am
9621 index 8f93fd2..2ac1b0c 100644
9622 --- a/src/plugins/splash/throbgress/Makefile.am
9623 +++ b/src/plugins/splash/throbgress/Makefile.am
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 \
9630 diff --git a/src/plugins/splash/throbgress/plugin.c b/src/plugins/splash/throbgress/plugin.c
9631 index 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)
9636 ply_list_node_t *node;
9638 + ply_trace ("pausing views");
9640 node = ply_list_get_first_node (plugin->views);
9641 while (node != NULL)
9643 @@ -267,6 +269,8 @@ unpause_views (ply_boot_splash_plugin_t *plugin)
9645 ply_list_node_t *node;
9647 + ply_trace ("unpausing views");
9649 node = ply_list_get_first_node (plugin->views);
9650 while (node != NULL)
9652 @@ -431,6 +435,8 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
9656 + ply_trace ("destroying plugin");
9658 if (plugin->loop != NULL)
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)
9665 + ply_trace ("starting animation");
9667 node = ply_list_get_first_node (plugin->views);
9668 while (node != NULL)
9670 @@ -542,6 +550,9 @@ stop_animation (ply_boot_splash_plugin_t *plugin,
9671 if (!plugin->is_animating)
9674 + ply_trace ("stopping animation%s",
9675 + trigger != NULL? " with trigger" : "");
9677 plugin->is_animating = false;
9679 node = ply_list_get_first_node (plugin->views);
9680 @@ -619,6 +630,7 @@ add_pixel_display (ply_boot_splash_plugin_t *plugin,
9684 + ply_trace ("adding pixel display to plugin");
9685 view = view_new (plugin, display);
9687 ply_pixel_display_set_draw_handler (view->display,
9688 @@ -634,6 +646,7 @@ remove_pixel_display (ply_boot_splash_plugin_t *plugin,
9690 ply_list_node_t *node;
9692 + ply_trace ("removing pixel display from plugin");
9693 node = ply_list_get_first_node (plugin->views);
9694 while (node != NULL)
9696 @@ -745,6 +758,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
9698 assert (plugin != NULL);
9700 + ply_trace ("hiding splash");
9701 if (plugin->loop != NULL)
9703 stop_animation (plugin, NULL);
9704 @@ -765,6 +779,7 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
9706 ply_list_node_t *node;
9708 + ply_trace ("showing password prompt");
9709 node = ply_list_get_first_node (plugin->views);
9710 while (node != NULL)
9712 @@ -788,6 +803,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
9714 ply_list_node_t *node;
9716 + ply_trace ("showing prompt");
9717 node = ply_list_get_first_node (plugin->views);
9718 while (node != NULL)
9720 @@ -807,6 +823,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
9722 on_root_mounted (ply_boot_splash_plugin_t *plugin)
9724 + ply_trace ("root filesystem mounted");
9725 plugin->root_is_mounted = true;
9728 @@ -814,8 +831,10 @@ static void
9729 become_idle (ply_boot_splash_plugin_t *plugin,
9730 ply_trigger_t *idle_trigger)
9732 + ply_trace ("deactivation requested");
9733 if (plugin->is_idle)
9735 + ply_trace ("plugin is already idle");
9736 ply_trigger_pull (idle_trigger, NULL);
9739 @@ -829,6 +848,7 @@ hide_prompt (ply_boot_splash_plugin_t *plugin)
9741 ply_list_node_t *node;
9743 + ply_trace ("hiding prompt");
9744 node = ply_list_get_first_node (plugin->views);
9745 while (node != NULL)
9747 @@ -844,6 +864,7 @@ hide_prompt (ply_boot_splash_plugin_t *plugin)
9753 show_message (ply_boot_splash_plugin_t *plugin,
9754 const char *message)
9755 diff --git a/src/plugins/splash/tribar/Makefile.am b/src/plugins/splash/tribar/Makefile.am
9756 new file mode 100644
9757 index 0000000..9b11502
9759 +++ b/src/plugins/splash/tribar/Makefile.am
9761 +AM_CPPFLAGS = -I$(top_srcdir) \
9762 + -I$(srcdir)/../../../libply \
9763 + -I$(srcdir)/../../../libply-splash-core \
9764 + -I$(srcdir)/../../.. \
9765 + -I$(srcdir)/../.. \
9769 +plugindir = $(libdir)/plymouth
9770 +plugin_LTLIBRARIES = tribar.la
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)
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
9783 +MAINTAINERCLEANFILES = Makefile.in
9784 diff --git a/src/plugins/splash/tribar/plugin.c b/src/plugins/splash/tribar/plugin.c
9785 new file mode 100644
9786 index 0000000..4458bad
9788 +++ b/src/plugins/splash/tribar/plugin.c
9792 + * Copyright (C) 2008 Red Hat, Inc.
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.
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.
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.
9809 + * Written by: Adam Jackson <ajax@redhat.com>
9810 + * Ray Strode <rstrode@redhat.com>
9812 +#include "config.h"
9814 +#include <assert.h>
9818 +#include <signal.h>
9819 +#include <stdbool.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>
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"
9844 +#include <linux/kd.h>
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;
9852 +struct _ply_boot_splash_plugin
9854 + ply_event_loop_t *loop;
9855 + ply_boot_splash_mode_t mode;
9857 + ply_list_t *views;
9859 + ply_boot_splash_display_type_t state;
9863 + uint32_t is_animating : 1;
9868 + ply_boot_splash_plugin_t *plugin;
9869 + ply_text_display_t *display;
9870 + ply_text_progress_bar_t *progress_bar;
9874 +ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
9876 +static void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
9877 + ply_event_loop_t *loop);
9880 +view_new (ply_boot_splash_plugin_t *plugin,
9881 + ply_text_display_t *display)
9885 + view = calloc (1, sizeof (view_t));
9886 + view->plugin = plugin;
9887 + view->display = display;
9889 + view->progress_bar = ply_text_progress_bar_new ();
9895 +view_free (view_t *view)
9897 + ply_text_progress_bar_free (view->progress_bar);
9903 +view_show_message (view_t *view)
9905 + ply_boot_splash_plugin_t *plugin;
9906 + int display_width, display_height;
9908 + plugin = view->plugin;
9910 + display_width = ply_text_display_get_number_of_columns (view->display);
9911 + display_height = ply_text_display_get_number_of_rows (view->display);
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,
9918 + strlen (plugin->message)) / 2,
9919 + display_height / 2);
9921 + ply_text_display_write (view->display, "%s", plugin->message);
9925 +view_show_prompt (view_t *view,
9926 + const char *prompt,
9927 + const char *entered_text)
9930 + int display_width, display_height;
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);
9938 + ply_text_display_set_cursor_position (view->display, 0, display_height / 2);
9940 + for (i=0; i < display_width; i++)
9941 + ply_text_display_write (view->display, "%c", ' ');
9943 + ply_text_display_set_cursor_position (view->display,
9944 + display_width / 2 - (strlen (prompt)),
9945 + display_height / 2);
9947 + ply_text_display_write (view->display, "%s:%s", prompt, entered_text);
9949 + ply_text_display_show_cursor (view->display);
9953 +view_start_animation (view_t *view)
9955 + ply_boot_splash_plugin_t *plugin;
9956 + ply_terminal_t *terminal;
9958 + assert (view != NULL);
9960 + plugin = view->plugin;
9962 + terminal = ply_text_display_get_terminal (view->display);
9964 + ply_terminal_set_color_hex_value (terminal,
9965 + PLY_TERMINAL_COLOR_BLACK,
9967 + ply_terminal_set_color_hex_value (terminal,
9968 + PLY_TERMINAL_COLOR_WHITE,
9970 + ply_terminal_set_color_hex_value (terminal,
9971 + PLY_TERMINAL_COLOR_BLUE,
9973 + ply_terminal_set_color_hex_value (terminal,
9974 + PLY_TERMINAL_COLOR_BROWN,
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);
9982 + if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
9984 + ply_text_progress_bar_hide (view->progress_bar);
9988 + ply_text_progress_bar_show (view->progress_bar,
9993 +view_redraw (view_t *view)
9995 + unsigned long screen_width, screen_height;
9997 + screen_width = ply_text_display_get_number_of_columns (view->display);
9998 + screen_height = ply_text_display_get_number_of_rows (view->display);
10000 + ply_text_display_draw_area (view->display, 0, 0,
10001 + screen_width, screen_height);
10005 +redraw_views (ply_boot_splash_plugin_t *plugin)
10007 + ply_list_node_t *node;
10009 + node = ply_list_get_first_node (plugin->views);
10010 + while (node != NULL)
10012 + ply_list_node_t *next_node;
10015 + view = ply_list_node_get_data (node);
10016 + next_node = ply_list_get_next_node (plugin->views, node);
10018 + view_redraw (view);
10020 + node = next_node;
10025 +view_hide (view_t *view)
10027 + if (view->display != NULL)
10029 + ply_terminal_t *terminal;
10031 + terminal = ply_text_display_get_terminal (view->display);
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);
10037 + ply_terminal_reset_colors (terminal);
10042 +hide_views (ply_boot_splash_plugin_t *plugin)
10044 + ply_list_node_t *node;
10046 + node = ply_list_get_first_node (plugin->views);
10047 + while (node != NULL)
10049 + ply_list_node_t *next_node;
10052 + view = ply_list_node_get_data (node);
10053 + next_node = ply_list_get_next_node (plugin->views, node);
10055 + view_hide (view);
10057 + node = next_node;
10062 +pause_views (ply_boot_splash_plugin_t *plugin)
10064 + ply_list_node_t *node;
10066 + node = ply_list_get_first_node (plugin->views);
10067 + while (node != NULL)
10069 + ply_list_node_t *next_node;
10072 + view = ply_list_node_get_data (node);
10073 + next_node = ply_list_get_next_node (plugin->views, node);
10075 + ply_text_display_pause_updates (view->display);
10077 + node = next_node;
10082 +unpause_views (ply_boot_splash_plugin_t *plugin)
10084 + ply_list_node_t *node;
10086 + node = ply_list_get_first_node (plugin->views);
10087 + while (node != NULL)
10089 + ply_list_node_t *next_node;
10092 + view = ply_list_node_get_data (node);
10093 + next_node = ply_list_get_next_node (plugin->views, node);
10095 + ply_text_display_unpause_updates (view->display);
10097 + node = next_node;
10101 +static ply_boot_splash_plugin_t *
10102 +create_plugin (ply_key_file_t *key_file)
10104 + ply_boot_splash_plugin_t *plugin;
10106 + ply_trace ("creating plugin");
10108 + plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
10109 + plugin->message = NULL;
10111 + plugin->views = ply_list_new ();
10117 +detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
10119 + plugin->loop = NULL;
10121 + ply_trace ("detaching from event loop");
10125 +free_views (ply_boot_splash_plugin_t *plugin)
10127 + ply_list_node_t *node;
10129 + node = ply_list_get_first_node (plugin->views);
10131 + while (node != NULL)
10133 + ply_list_node_t *next_node;
10136 + view = ply_list_node_get_data (node);
10137 + next_node = ply_list_get_next_node (plugin->views, node);
10139 + view_free (view);
10140 + ply_list_remove_node (plugin->views, node);
10142 + node = next_node;
10145 + ply_list_free (plugin->views);
10146 + plugin->views = NULL;
10150 +destroy_plugin (ply_boot_splash_plugin_t *plugin)
10152 + ply_trace ("destroying plugin");
10154 + if (plugin == NULL)
10157 + /* It doesn't ever make sense to keep this plugin on screen
10160 + hide_splash_screen (plugin, plugin->loop);
10162 + free_views (plugin);
10163 + if (plugin->message != NULL)
10164 + free (plugin->message);
10170 +show_message (ply_boot_splash_plugin_t *plugin)
10172 + ply_list_node_t *node;
10174 + node = ply_list_get_first_node (plugin->views);
10175 + while (node != NULL)
10177 + ply_list_node_t *next_node;
10180 + view = ply_list_node_get_data (node);
10181 + next_node = ply_list_get_next_node (plugin->views, node);
10183 + view_show_message (view);
10185 + node = next_node;
10190 +start_animation (ply_boot_splash_plugin_t *plugin)
10192 + ply_list_node_t *node;
10194 + assert (plugin != NULL);
10195 + assert (plugin->loop != NULL);
10197 + redraw_views (plugin);
10199 + if (plugin->message != NULL)
10200 + show_message (plugin);
10202 + if (plugin->is_animating)
10205 + node = ply_list_get_first_node (plugin->views);
10206 + while (node != NULL)
10208 + ply_list_node_t *next_node;
10211 + view = ply_list_node_get_data (node);
10212 + next_node = ply_list_get_next_node (plugin->views, node);
10214 + view_start_animation (view);
10216 + node = next_node;
10219 + plugin->is_animating = true;
10223 +stop_animation (ply_boot_splash_plugin_t *plugin)
10225 + ply_list_node_t *node;
10227 + assert (plugin != NULL);
10228 + assert (plugin->loop != NULL);
10230 + if (!plugin->is_animating)
10233 + plugin->is_animating = false;
10235 + node = ply_list_get_first_node (plugin->views);
10236 + while (node != NULL)
10238 + ply_list_node_t *next_node;
10241 + view = ply_list_node_get_data (node);
10242 + next_node = ply_list_get_next_node (plugin->views, node);
10244 + ply_text_progress_bar_hide (view->progress_bar);
10246 + node = next_node;
10248 + redraw_views (plugin);
10252 +on_draw (view_t *view,
10253 + ply_terminal_t *terminal,
10259 + ply_text_display_clear_screen (view->display);
10263 +add_text_display (ply_boot_splash_plugin_t *plugin,
10264 + ply_text_display_t *display)
10267 + ply_terminal_t *terminal;
10269 + view = view_new (plugin, display);
10271 + terminal = ply_text_display_get_terminal (view->display);
10272 + if (ply_terminal_open (terminal))
10273 + ply_terminal_activate_vt (terminal);
10275 + ply_text_display_set_draw_handler (view->display,
10276 + (ply_text_display_draw_handler_t)
10279 + ply_list_append_data (plugin->views, view);
10283 +remove_text_display (ply_boot_splash_plugin_t *plugin,
10284 + ply_text_display_t *display)
10286 + ply_list_node_t *node;
10288 + node = ply_list_get_first_node (plugin->views);
10289 + while (node != NULL)
10292 + ply_list_node_t *next_node;
10294 + view = ply_list_node_get_data (node);
10295 + next_node = ply_list_get_next_node (plugin->views, node);
10297 + if (view->display == display)
10299 + ply_text_display_set_draw_handler (view->display,
10301 + view_free (view);
10302 + ply_list_remove_node (plugin->views, node);
10306 + node = next_node;
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)
10316 + assert (plugin != NULL);
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,
10324 + ply_show_new_kernel_messages (false);
10325 + start_animation (plugin);
10331 +update_status (ply_boot_splash_plugin_t *plugin,
10332 + const char *status)
10334 + assert (plugin != NULL);
10336 + ply_trace ("status update");
10340 +on_boot_progress (ply_boot_splash_plugin_t *plugin,
10342 + double percent_done)
10344 + ply_list_node_t *node;
10345 + double total_duration;
10347 + total_duration = duration / percent_done;
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);
10353 + node = ply_list_get_first_node (plugin->views);
10355 + while (node != NULL)
10357 + ply_list_node_t *next_node;
10360 + view = ply_list_node_get_data (node);
10361 + next_node = ply_list_get_next_node (plugin->views, node);
10363 + ply_text_progress_bar_set_percent_done (view->progress_bar, percent_done);
10364 + ply_text_progress_bar_draw (view->progress_bar);
10366 + node = next_node;
10371 +hide_splash_screen (ply_boot_splash_plugin_t *plugin,
10372 + ply_event_loop_t *loop)
10374 + assert (plugin != NULL);
10376 + ply_trace ("hiding splash screen");
10378 + if (plugin->loop != NULL)
10380 + stop_animation (plugin);
10382 + ply_event_loop_stop_watching_for_exit (plugin->loop,
10383 + (ply_event_loop_exit_handler_t)
10384 + detach_from_event_loop,
10386 + detach_from_event_loop (plugin);
10389 + hide_views (plugin);
10390 + ply_show_new_kernel_messages (true);
10394 +display_normal (ply_boot_splash_plugin_t *plugin)
10396 + pause_views (plugin);
10397 + if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10399 + plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
10400 + start_animation (plugin);
10401 + redraw_views (plugin);
10403 + unpause_views (plugin);
10407 +display_message (ply_boot_splash_plugin_t *plugin,
10408 + const char *message)
10410 + if (plugin->message != NULL)
10411 + free (plugin->message);
10413 + plugin->message = strdup (message);
10414 + start_animation (plugin);
10418 +show_password_prompt (ply_boot_splash_plugin_t *plugin,
10419 + const char *prompt,
10422 + ply_list_node_t *node;
10424 + char *entered_text;
10426 + entered_text = calloc (bullets + 1, sizeof (char));
10428 + for (i = 0; i < bullets; i++)
10429 + entered_text[i] = '*';
10431 + node = ply_list_get_first_node (plugin->views);
10432 + while (node != NULL)
10434 + ply_list_node_t *next_node;
10437 + view = ply_list_node_get_data (node);
10438 + next_node = ply_list_get_next_node (plugin->views, node);
10440 + view_show_prompt (view, prompt, entered_text);
10442 + node = next_node;
10444 + free (entered_text);
10448 +show_prompt (ply_boot_splash_plugin_t *plugin,
10449 + const char *prompt,
10450 + const char *text)
10452 + ply_list_node_t *node;
10454 + node = ply_list_get_first_node (plugin->views);
10455 + while (node != NULL)
10457 + ply_list_node_t *next_node;
10460 + view = ply_list_node_get_data (node);
10461 + next_node = ply_list_get_next_node (plugin->views, node);
10463 + view_show_prompt (view, prompt, text);
10465 + node = next_node;
10470 +display_password (ply_boot_splash_plugin_t *plugin,
10471 + const char *prompt,
10474 + pause_views (plugin);
10475 + if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10476 + stop_animation (plugin);
10478 + plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
10481 + prompt = "Password";
10483 + show_password_prompt (plugin, prompt, bullets);
10485 + unpause_views (plugin);
10489 +display_question (ply_boot_splash_plugin_t *plugin,
10490 + const char *prompt,
10491 + const char *entry_text)
10493 + pause_views (plugin);
10494 + if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
10495 + stop_animation (plugin);
10497 + plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
10500 + prompt = "Password";
10502 + show_prompt (plugin, prompt, entry_text);
10504 + unpause_views (plugin);
10507 +ply_boot_splash_plugin_interface_t *
10508 +ply_boot_splash_plugin_get_interface (void)
10510 + static ply_boot_splash_plugin_interface_t plugin_interface =
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,
10526 + return &plugin_interface;
10529 +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
10530 diff --git a/src/plugins/splash/two-step/Makefile.am b/src/plugins/splash/two-step/Makefile.am
10531 index 7310d6c..f3a6aaa 100644
10532 --- a/src/plugins/splash/two-step/Makefile.am
10533 +++ b/src/plugins/splash/two-step/Makefile.am
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 \
10540 diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c
10541 index 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;
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;
10563 ply_boot_splash_display_type_t state;
10565 + double watermark_horizontal_alignment;
10566 + double watermark_vertical_alignment;
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);
10575 + if (view->background_image != NULL)
10576 + ply_image_free (view->background_image);
10582 view_load (view_t *view)
10584 + unsigned long screen_width, screen_height;
10585 + ply_boot_splash_plugin_t *plugin;
10587 + plugin = view->plugin;
10589 + screen_width = ply_pixel_display_get_width (view->display);
10590 + screen_height = ply_pixel_display_get_height (view->display);
10592 + if (plugin->background_tile_image != NULL)
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);
10598 + if (plugin->watermark_image != NULL)
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;
10606 ply_trace ("loading entry");
10607 if (!ply_entry_load (view->entry))
10609 @@ -519,6 +550,14 @@ create_plugin (ply_key_file_t *key_file)
10610 plugin->header_image = ply_image_new (image_path);
10613 + asprintf (&image_path, "%s/background-tile.png", image_dir);
10614 + plugin->background_tile_image = ply_image_new (image_path);
10615 + free (image_path);
10617 + asprintf (&image_path, "%s/watermark.png", image_dir);
10618 + plugin->watermark_image = ply_image_new (image_path);
10619 + free (image_path);
10621 plugin->animation_dir = image_dir;
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;
10628 + alignment = ply_key_file_get_value (key_file, "two-step", "WatermarkHorizontalAlignment");
10629 + if (alignment != NULL)
10630 + plugin->watermark_horizontal_alignment = strtod (alignment, NULL);
10632 + plugin->watermark_horizontal_alignment = 1.0;
10633 + free (alignment);
10635 + alignment = ply_key_file_get_value (key_file, "two-step", "WatermarkVerticalAlignment");
10636 + if (alignment != NULL)
10637 + plugin->watermark_vertical_alignment = strtod (alignment, NULL);
10639 + plugin->watermark_vertical_alignment = .5;
10640 + free (alignment);
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);
10649 + if (plugin->background_tile_image != NULL)
10650 + ply_image_free (plugin->background_tile_image);
10652 + if (plugin->watermark_image != NULL)
10653 + ply_image_free (plugin->watermark_image);
10655 free (plugin->animation_dir);
10656 free_views (plugin);
10658 @@ -813,6 +872,21 @@ draw_background (view_t *view,
10660 ply_pixel_buffer_fill_with_hex_color (pixel_buffer, &area,
10661 plugin->background_start_color);
10663 + if (view->background_image != NULL)
10666 + data = ply_image_get_data (view->background_image);
10667 + ply_pixel_buffer_fill_with_argb32_data (pixel_buffer, &area, data);
10670 + if (plugin->watermark_image != NULL)
10674 + data = ply_image_get_data (plugin->watermark_image);
10675 + ply_pixel_buffer_fill_with_argb32_data (pixel_buffer, &view->watermark_area, data);
10680 @@ -997,6 +1071,26 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
10684 + if (plugin->background_tile_image != NULL)
10686 + ply_trace ("loading background tile image");
10687 + if (!ply_image_load (plugin->background_tile_image))
10689 + ply_image_free (plugin->background_tile_image);
10690 + plugin->background_tile_image = NULL;
10694 + if (plugin->watermark_image != NULL)
10696 + ply_trace ("loading watermark image");
10697 + if (!ply_image_load (plugin->watermark_image))
10699 + ply_image_free (plugin->watermark_image);
10700 + plugin->watermark_image = NULL;
10704 if (!load_views (plugin))
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)
10711 + if (plugin->is_idle)
10714 if (percent_done >= SHOW_ANIMATION_PERCENT)
10716 if (plugin->stop_trigger == NULL)
10717 diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c
10718 index 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)
10723 assert (server != NULL);
10725 - fd = accept (server->socket_fd, NULL, NULL);
10726 + fd = accept4 (server->socket_fd, NULL, NULL, SOCK_CLOEXEC);
10730 @@ -831,183 +831,4 @@ ply_boot_server_attach_to_event_loop (ply_boot_server_t *server,
10734 -#ifdef PLY_BOOT_SERVER_ENABLE_TEST
10736 -#include <stdio.h>
10738 -#include "ply-event-loop.h"
10739 -#include "ply-boot-server.h"
10742 -on_update (ply_event_loop_t *loop,
10743 - const char *status)
10745 - printf ("new status is '%s'\n", status);
10749 -on_newroot (ply_event_loop_t *loop)
10751 - printf ("got newroot request\n");
10755 -on_system_initialized (ply_event_loop_t *loop)
10757 - printf ("got sysinit done request\n");
10761 -on_show_splash (ply_event_loop_t *loop)
10763 - printf ("got show splash request\n");
10767 -on_hide_splash (ply_event_loop_t *loop)
10769 - printf ("got hide splash request\n");
10773 -on_deactivate (ply_event_loop_t *loop)
10775 - printf ("got deactivate request\n");
10779 -on_reactivate (ply_event_loop_t *loop)
10781 - printf ("got reactivate request\n");
10785 -on_quit (ply_event_loop_t *loop)
10787 - printf ("got quit request, quiting...\n");
10788 - ply_event_loop_exit (loop, 0);
10792 -on_error (ply_event_loop_t *loop)
10794 - printf ("got error starting service\n");
10798 -on_ask_for_password (ply_event_loop_t *loop)
10800 - printf ("got password request, returning 'password'...\n");
10802 - return strdup ("password");
10806 -on_ask_question (ply_event_loop_t *loop)
10808 - printf ("got question request\n");
10813 -on_display_message (ply_event_loop_t *loop)
10815 - printf ("got display message request\n");
10820 -on_hide_message (ply_event_loop_t *loop)
10822 - printf ("got hide message request\n");
10827 -on_watch_for_keystroke (ply_event_loop_t *loop)
10829 - printf ("got keystroke request\n");
10835 -on_progress_pause (ply_event_loop_t *loop)
10837 - printf ("got progress pause request\n");
10843 -on_progress_unpause (ply_event_loop_t *loop)
10845 - printf ("got progress unpause request\n");
10851 -on_ignore_keystroke (ply_event_loop_t *loop)
10853 - printf ("got keystroke ignore request\n");
10859 -on_has_active_vt (ply_event_loop_t *loop)
10861 - printf ("got has_active vt? request\n");
10869 - ply_event_loop_t *loop;
10870 - ply_boot_server_t *server;
10875 - loop = ply_event_loop_new ();
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,
10899 - if (!ply_boot_server_listen (server))
10901 - perror ("could not start boot status daemon");
10905 - ply_boot_server_attach_to_event_loop (server, loop);
10906 - exit_code = ply_event_loop_run (loop);
10907 - ply_boot_server_free (server);
10909 - return exit_code;
10912 -#endif /* PLY_BOOT_SERVER_ENABLE_TEST */
10913 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
10914 diff --git a/src/plymouthd.defaults b/src/plymouthd.defaults
10915 index 46417d6..fc48b15 100644
10916 --- a/src/plymouthd.defaults
10917 +++ b/src/plymouthd.defaults
10923 diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
10924 deleted file mode 100644
10925 index 86a8ea6..0000000
10926 --- a/src/tests/Makefile.am
10930 - -I$(top_srcdir) \
10932 - -I$(srcdir)/../libply \
10933 - -I$(srcdir)/../libply-splash-core \
10938 -include $(srcdir)/ply-boot-server-test.am
10939 -include $(srcdir)/ply-boot-splash-test.am
10942 -noinst_PROGRAMS = $(TESTS)
10944 -# our tests aren't unit tests, so clear for now
10946 -MAINTAINERCLEANFILES = Makefile.in
10947 diff --git a/src/tests/ply-boot-server-test.am b/src/tests/ply-boot-server-test.am
10948 deleted file mode 100644
10949 index cc28348..0000000
10950 --- a/src/tests/ply-boot-server-test.am
10953 -TESTS += ply-boot-server-test
10955 -ply_boot_server_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SERVER_ENABLE_TEST
10956 -ply_boot_server_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
10958 -ply_boot_server_test_SOURCES = \
10959 - $(srcdir)/../ply-boot-server.h \
10960 - $(srcdir)/../ply-boot-server.c
10961 diff --git a/src/tests/ply-boot-splash-test.am b/src/tests/ply-boot-splash-test.am
10962 deleted file mode 100644
10963 index 9dd1598..0000000
10964 --- a/src/tests/ply-boot-splash-test.am
10967 -TESTS += ply-boot-splash-test
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)/\"
10974 -ply_boot_splash_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
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
10992 diff --git a/src/upstart-bridge/Makefile.am b/src/upstart-bridge/Makefile.am
10993 index 628ef20..a16cd11 100644
10994 --- a/src/upstart-bridge/Makefile.am
10995 +++ b/src/upstart-bridge/Makefile.am
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 \
11002 diff --git a/src/viewer/Makefile.am b/src/viewer/Makefile.am
11003 index 6ade690..0c5c3ec 100644
11004 --- a/src/viewer/Makefile.am
11005 +++ b/src/viewer/Makefile.am
11010 -INCLUDES = -I$(top_srcdir) \
11011 +AM_CPPFLAGS = -I$(top_srcdir) \
11014 plymouth_log_viewerdir = $(bindir)
11015 diff --git a/src/viewer/plymouth-log-viewer.c b/src/viewer/plymouth-log-viewer.c
11016 index c20e391..ca54e0f 100644
11017 --- a/src/viewer/plymouth-log-viewer.c
11018 +++ b/src/viewer/plymouth-log-viewer.c
11020 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
11023 +#ifdef HAVE_CONFIG_H
11024 +#include "config.h"
11027 #include <stdlib.h>
11028 #include <string.h>
11029 #include <sys/types.h>
11030 diff --git a/systemd-units/Makefile.am b/systemd-units/Makefile.am
11031 index 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:
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 && \
11053 diff --git a/systemd-units/plymouth-halt.service.in b/systemd-units/plymouth-halt.service.in
11054 index 8fd6c48..fd27e10 100644
11055 --- a/systemd-units/plymouth-halt.service.in
11056 +++ b/systemd-units/plymouth-halt.service.in
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
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
11073 +WantedBy=halt.target
11074 diff --git a/systemd-units/plymouth-kexec.service.in b/systemd-units/plymouth-kexec.service.in
11075 index 6ee0461..8aa661d 100644
11076 --- a/systemd-units/plymouth-kexec.service.in
11077 +++ b/systemd-units/plymouth-kexec.service.in
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
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
11094 +WantedBy=kexec.target
11095 diff --git a/systemd-units/plymouth-poweroff.service.in b/systemd-units/plymouth-poweroff.service.in
11096 index 3e2a83c..305ece6 100644
11097 --- a/systemd-units/plymouth-poweroff.service.in
11098 +++ b/systemd-units/plymouth-poweroff.service.in
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
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
11114 +WantedBy=poweroff.target
11115 diff --git a/systemd-units/plymouth-quit-wait.service.in b/systemd-units/plymouth-quit-wait.service.in
11116 index 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
11121 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth --wait
11126 +WantedBy=multi-user.target
11127 diff --git a/systemd-units/plymouth-quit.service.in b/systemd-units/plymouth-quit.service.in
11128 index 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
11136 +WantedBy=multi-user.target
11137 diff --git a/systemd-units/plymouth-read-write.service.in b/systemd-units/plymouth-read-write.service.in
11138 index 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
11143 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth update-root-fs --read-write
11146 +WantedBy=sysinit.target
11147 diff --git a/systemd-units/plymouth-reboot.service.in b/systemd-units/plymouth-reboot.service.in
11148 index a6e86e4..ce56855 100644
11149 --- a/systemd-units/plymouth-reboot.service.in
11150 +++ b/systemd-units/plymouth-reboot.service.in
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
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
11166 +WantedBy=reboot.target
11167 diff --git a/systemd-units/plymouth-start.service.in b/systemd-units/plymouth-start.service.in
11168 index bbff9f5..0d5ff2a 100644
11169 --- a/systemd-units/plymouth-start.service.in
11170 +++ b/systemd-units/plymouth-start.service.in
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
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
11190 +WantedBy=sysinit.target
11191 diff --git a/systemd-units/systemd-ask-password-plymouth.service.in b/systemd-units/systemd-ask-password-plymouth.service.in
11192 index 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
11199 -ExecStart=/bin/systemd-tty-ask-password-agent --watch --plymouth
11200 +ExecStart=@SYSTEMD_ASK_PASSWORD_AGENT@ --watch --plymouth
11201 diff --git a/themes/Makefile.am b/themes/Makefile.am
11202 index cfd149e..72e642b 100644
11203 --- a/themes/Makefile.am
11204 +++ b/themes/Makefile.am
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
11209 diff --git a/themes/text/text.plymouth b/themes/text/text.plymouth
11210 index a2db9e6..126eb09 100644
11211 --- a/themes/text/text.plymouth
11212 +++ b/themes/text/text.plymouth
11216 -Description=Text mode theme with tricolor progress bar
11217 +Description=Text mode theme with a 3 box countdown
11219 diff --git a/themes/tribar/Makefile.am b/themes/tribar/Makefile.am
11220 new file mode 100644
11221 index 0000000..3066d2f
11223 +++ b/themes/tribar/Makefile.am
11225 +themedir = $(datadir)/plymouth/themes/tribar
11226 +dist_theme_DATA = tribar.plymouth
11228 +MAINTAINERCLEANFILES = Makefile.in
11229 diff --git a/themes/tribar/tribar.plymouth b/themes/tribar/tribar.plymouth
11230 new file mode 100644
11231 index 0000000..6db7b4e
11233 +++ b/themes/tribar/tribar.plymouth
11237 +Description=Text mode theme with tricolor progress bar