class OwnedDisplay extends DisplayInterface
System console manager.
It manages the output mode of the display. It is possible to switch between graphics mode and text mode. Graphics mode reserves the display for drawing operation and hides text output. On the other hand, text mode suspends drawing operations and shows the text on the Linux console. This class also manages VT (= Virtual Terminal = console) switches in the case of a VT switch occuring when graphics mode is set.
Implementation of this class is based on the GRX3 linuxfb plugin.
Modifier and Type | Field and Description |
---|---|
private java.lang.Thread |
deinitializer |
private java.lang.String |
fbPath |
private ILibc |
libc |
private int |
old_kbmode |
private NativeTTY |
ttyfd |
fbInstance
Constructor and Description |
---|
OwnedDisplay(ILibc libc)
Initialize the display, register event handlers and switch to text mode.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
private void |
deinitialize()
Put the display to a state where it is ready for returning.
|
private void |
initialize()
Initialize the display state.
|
JavaFramebuffer |
openFramebuffer()
Get the framebuffer for the system display.
|
void |
switchToGraphicsMode()
Switch the display to a graphics mode.
|
void |
switchToTextMode()
Switch the display to a text mode.
|
closeFramebuffer, initializeFramebuffer, releaseFramebuffer
private ILibc libc
private java.lang.String fbPath
private NativeTTY ttyfd
private int old_kbmode
private java.lang.Thread deinitializer
public OwnedDisplay(ILibc libc)
Initialize the display, register event handlers and switch to text mode.
java.lang.RuntimeException
- when initialization or mode switch fails.private void initialize() throws java.io.IOException
Initialize the display state.
Opens the current VT, saves keyboard mode and identifies the appropriate framebuffer device.
java.io.IOException
- When the initialization fails.public void close()
private void deinitialize()
Put the display to a state where it is ready for returning.
Keyboard mode is restored, text mode is set and VT autoswitch is enabled. Then, console file descriptor is closed.
public void switchToGraphicsMode()
Switch the display to a graphics mode.
It switches VT to graphics mode with keyboard turned off. Then, it tells kernel to notify Java when VT switch occurs. Also, framebuffer contents are restored and write access is enabled.
switchToGraphicsMode
in class DisplayInterface
java.lang.RuntimeException
- when the switch failspublic void switchToTextMode()
Switch the display to a text mode.
It stores framebuffer data and disables write access. Then, it switches VT to text mode and allows kernel to auto-switch it.
switchToTextMode
in class DisplayInterface
java.lang.RuntimeException
- when the switch failspublic JavaFramebuffer openFramebuffer()
Get the framebuffer for the system display.
The framebuffer is initialized only once, later calls return references to the same instance.
openFramebuffer
in class DisplayInterface
java.lang.RuntimeException
- when switch to graphics mode or the framebuffer initialization fails.