Desktop Manager and Applets
Kernel task executes a desktop manager application for a better user experience when its boot up process is complete. NeuroKernel does not need a desktop manager to execute applications but a simple one is offered by default for convenience. Devices with small screens are detected by the system and a smaller desktop can be initiated by the same desktop application. Developers can write their own desktop managers, it is also possible to write an entire application that runs as a desktop manager which would be desired if a multi-task workstation environment is not needed.
The class that is needed to inherit for a desktop manager is the NDesktopManager
class. This is a special class that also inherits NApplication
class. Desktop manager task is registered by the kernel to window manager so that it receives all windowing events. The NDesktopListener class is needed to be extended in order to properly manage the desktop. The listener is passed to the desktop manager using setDesktopListener
method.
Desktop window is specially treated by the window manager. It never gets any decorations and always made fullscreen except when in document window. If there is no desktop manager to run, kernel takes over the as desktop management however no icons or anything similar will be shown. This can be observed by killing the desktop manager application, and rerunning it. It is similar how Explorer task works on Windows Operating System.
1. A Simple Desktop Manager
Writing a desktop manager is very straight forward task in NeuroKernel. Extending the NDesktopManager
and implementing a NDesktopListener
interface is all it takes in most cases. The application must be registered as “desktop”, a system registry entry pointing to the desktop manager application named “DESKTOP” must be defined. The example below replaces the default desktop manager. The example code given is the actual code we use on our web site demo. It is a desktop manager that is designed to work in rootless mode embedded into a web page. It lets the web site know about the desktop changes, at least some of them if not all. After loading the desktop listener, it runs any registered startup applications which are registered with “startup” entry to the system registry. There could be more than one startup entry.
import com.neurokernel.system.annotation.Configure; import com.neurokernel.system.annotation.Include; import com.neurokernel.system.annotation.Executable; import com.neurokernel.system.constants.CodeSegment; import com.neurokernel.system.desktop.IWindow; import com.neurokernel.system.desktop.NDesktopListener; import com.neurokernel.system.desktop.NDesktopManager; @Configure( compileIn = { @Include(CodeSegment.USER_INTERFACE), @Include(CodeSegment.SERVICES), @Include(CodeSegment.PORTS) } ) @Executable("desktop") public final class WebDesktop extends NDesktopManager { private static final long serialVersionUID = 1L; @Override public void main(int argc, String[] argv) { super.main(argc, argv); this.setDesktopListener(new RootlessDesktopListener(this)); runStartups(); } private static final class RootlessDesktopListener extends NDesktopListener { private static final long serialVersionUID = 1L; private final WebDesktop desktop; private RootlessDesktopListener(WebDesktop desktop) { this.desktop=desktop; } private void sendOperation(IWindow source, int opt) { desktop.postMessage("{\"id\":\""+source.getId()+"\",\"name\":\""+ source.getAppName()+"\",\"title\":\""+source.getTitle()+"\",\"opt\":"+opt+"}"); } @Override public void onWindowUpdate(IWindow source) { sendOperation(source,6); } @Override public void onWindowOpen(IWindow source) { sendOperation(source,0); } @Override public void onWindowMap(IWindow source, boolean map) { sendOperation(source,map?1:2); } @Override public void onWindowIconify(IWindow source, boolean iconify) { sendOperation(source,iconify?3:4); } @Override public void onWindowClose(IWindow source) { sendOperation(source,5); } } }
2. Applets and Applet View
Web sites may deploy a desktop manager based application as an applet to their web pages. Approach is similar to Java applets but more powerful. When NeuroKernel /OS embedded into a web page and boots in rootless mode, it will immediately search for applets on the page if any defined.
<napplet name="myapplet" codebase="https://dev.neurokernel.com/" width="700" height="700" code="teapot"> <param name="context" value="demos/teapot"/> <param name="worker" value="true"/> <param name="trusted" value="true"/> </napplet>
Applet view on the other is a component that can be user by NeuroKernel applications. It is treated as a plugin application, but in fact entire system is loaded to the view with an application running in desktop mode. Windows created by Applet View can not break out of the viewport. Custom miniaturized NeuroKernel builds will be available to customers.