Skip to content

fix: Native platform - LwjglCanvas (example)#2646

Open
JNightRider wants to merge 2 commits intojMonkeyEngine:masterfrom
JNightRider:fix/platform-native-context
Open

fix: Native platform - LwjglCanvas (example)#2646
JNightRider wants to merge 2 commits intojMonkeyEngine:masterfrom
JNightRider:fix/platform-native-context

Conversation

@JNightRider
Copy link
Contributor

Since lwjgl3 is the default module in the jme3 examples, enabling (forcing) it to use x11 for the awt canvas is already part of this example to make it work on Wayland (and not appear to have a bug)... since awt/swing still relies on x11 to manage its graphical components (this does not affect functionality on other platforms except Linux with Wayland).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a compatibility issue for the LwjglCanvas example, specifically TestCanvas, when executed on Linux environments utilizing Wayland. By explicitly configuring the AppSettings to prefer the X11 platform, it ensures that AWT/Swing components, which depend on X11 for graphical management, operate correctly, preventing the example from appearing non-functional on Wayland.

Highlights

  • LwjglCanvas Example Compatibility: Explicitly set x11PlatformPreferred(true) in AppSettings for the TestCanvas example to ensure proper functioning on Linux systems using Wayland, as AWT/Swing components still rely on X11.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue with running AWT-based examples on Linux with Wayland by forcing the use of an X11 context. The change is correct and well-contained within the example. The suggestion to include a comment explaining the purpose of this setting for future reference is valid and will improve code clarity for other developers looking at this example.

@SuppressWarnings("unchecked")
public static void createCanvas(String appClass){
AppSettings settings = new AppSettings(true);
settings.setX11PlatformPreferred(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the PR description explains the reason for this change, it would be beneficial to add a comment here in the code. This example serves as a reference for users, and a comment would clarify why this setting is necessary for AWT canvas integration on platforms like Wayland.

Suggested change
settings.setX11PlatformPreferred(true);
// On Linux with Wayland, AWT/Swing requires an X11 context.
// This forces the jME context to use X11 (via GLX) to be compatible.
settings.setX11PlatformPreferred(true);

@yaRnMcDonuts yaRnMcDonuts added this to the v3.10.0 milestone Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants