Deciding which toolkit to use

Philip Race philip.race at oracle.com
Thu Oct 12 18:07:43 UTC 2023


During development of the pure Wayland toolkit, it is probably easiest 
to default to WAYLAND if WAYLAND_DISPLAY is set.
Use an environment variable to select X, something like AWT_TOOLKIT=XToolkit
This can be accessed by native code as well as Java code.

I suggest that name+value because it corresponds to what we did when we 
had XToolkit and MToolkit, many, many, years ago.
https://docs.oracle.com/javase/8/docs/technotes/guides/awt/1.5/xawt.html
but we could evolve it later if some other way of doing it makes more sense.

So,
If WAYLAND_DISPLAY is unset, then you default to Xawt.
If DISPLAY is unset you default to AWTWayland.
If both are unset, then .. well that's headless and we'd use 
HeadlessToolkit.
If both are set then that's when the value of AWT_TOOLKIT matters.

In some distant day when its integrated in JDK I expect the default to 
be the other way around for at least 2 releases whilst it bakes.

For now, put the code to read all this anywhere that is convenient. We 
can move it to platform-specific code later.

-phil.

On 9/25/23 3:53 AM, Maxim Kartashev wrote:
> I'd like to propose a topic for the upcoming Wakefield project 
> meeting, namely, how to best decide which toolkit to use at the start? 
> The question is relatively easily answered at the toolkit load time, 
> but we must decide much earlier because of the splash screen support. 
> That thing starts working when there's no Java yet, so the decision 
> must be made then and not change afterwards.
> Options for the decision making include (but not limited to):
> - look at $XDG_SESSION_TYPE,
> - check $DISPLAY, then $WAYLAND_DISPLAY (or the other way around),
> - try connecting to $DISPLAY, then $WAYLAND_DISPLAY.
>
> There is also a question on how to pass this decision down to the 
> toolkit initialization time, which must choose the same and 
> (preferably) regardless of whether or not the splash screen was shown.
> Options here include
> - pass a command line option,
> - implement the same logic in Java as in the early C startup code.
>
> Opinions and suggestions are welcomed!



More information about the wakefield-dev mailing list