JEP draft: Modernize the GTK3 Look and Feel implementation
|Component||client-libs / javax.swing|
|Discussion||swing dash dev at openjdk dot java dot net|
|Reviewed by||Sergey Bylokhov|
|Endorsed by||Alexander Scherbatiy|
Modernize the GTK3 Look and Feel implementation for OpenJDK.
While OpenJDK ships with a set of Look and Feel (LAF) implementations for Swing, they are old and don't always follow modern design guidelines.
This problem is particularly acute in the case of Platform specific Look and Feel, where the various platforms supported have diverged significantly from what OpenJDK provides. On Linux, for example, almost every modern distribution uses GTK3 as its predefined GUI toolkit, while OpenJDK is still using GTK2. This is not only an issue because the UI may diverge considerably from native applications, but it is also a problem in some cases when using OpenJDK with applications that use native rendering directly, which may lead to crashes or other issues (see, for example, the following bug reports here, here and here). There is a need to create new and improve existing implementations of Look and Feel in order to bring up the quality of GUI-based applications.
This proposal focuses on adapting/rewriting the existing GTK2 LAF to use GTK3 instead. The resulting LAF will be usable independently of the existing implementations and not replace them, however it will not be possible to use both implementations at runtime, in other words the user will see this new implementation not as a new LookAndFeel but as a different version of the current GTKLookAndFeel. If this proposal is accepted, the current GTKLookAndFeel will be refactored in order to properly detect the version of gtk running on the host system and load the appropriate libraries; based on the detected version of the gtk native library, either the old Look And Feel or the new one will be used. It will be possible for users to force a specific implementation if both options are available, to ensure backward compatibility and help diagnosing bugs.
The new code should use only the public SynthLookAndFeel API and will not produce any public API. Any class or method introduced to support this new LAF will be internal, and should be appropriately restricted.
It is a goal of this JEP to implement a working Look and Feel based on GTK3.
While other look and feel in OpenJDK necessitate the same level of update, at this stage is not a goal of this JEP to provide other implementations.
A valid implementation of a Look and Feel based on GTK3 that works well on most modern Linux Distribution with their default themes.
Risks and Assumptions
The only risk we foresee is the relationship of GTK2 and GTK3: those two API are not compatible and should not be mixed within one process. Since this proposal is about adding, not replacing, a GTK3 based implementation to the existing ones, the risk of breaking existing software is very minimal. Nevertheless, care must be taken to ensure that the new implementation will coexist correctly, for example ensuring that only one library between GTK2 and GTK3 can dlopened by OpenJDK.
Other than the JDK itself, the new code will only be dependent on GTK3 and related dependencies.
The code will have appropriate test coverage. Also, while it is impossible to test every combination of GTK3 provided themes and applications, we will perform extensive testing on some well known Swing using programs, like NetBeans, JConsole, Thermostat, JVisualVM and the open source version of IDEA.