Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3,linux] fix: enable to run natively in wayland #3614

Merged
merged 1 commit into from
Aug 25, 2024

Conversation

stendler
Copy link

@stendler stendler commented Jul 16, 2024

Description

Incorporated from this v2 change:
#1811

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Linux

Verified using xeyes: if the eyes follow the mouse when entering the wails app window, then it is running on X11; if they stop following when entering the window it is running on wayland.

Test Configuration

# Build Environment
┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-alpha.4                           |
| Go Version   | go1.22.4                                 |
| Revision     | 5fcebd02741eea738dfcb7fc43d8d86f139293fe |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOOS         | linux                                    |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | 5fcebd02741eea738dfcb7fc43d8d86f139293fe |
| vcs.time     | 2024-07-02T08:49:19Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────┐
| npm        | 10.8.2                    |
| pkg-config | 2.1.1-1                   |
| webkit2gtk | 2.44.2-1                  |
| gcc        | 14.1.1+r58+gfc9fb69ad62-1 |
| gtk3       | 1:3.24.43-1               |
└─────── * - Optional Dependency ────────┘

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Updated changelog to include a fix for running natively in Wayland on Linux, enhancing cross-platform compatibility for Linux users.
  • Bug Fixes

    • Improved initialization logic for Linux applications to prevent conflicts with existing environment variable values.

Copy link
Contributor

coderabbitai bot commented Jul 16, 2024

Walkthrough

The changes involve updates to the changelog and modifications to the initialization logic in the Linux application code. A new entry in the changelog highlights a fix for native Wayland support, referencing previous pull requests. In the application code, a conditional check is introduced to prevent overwriting the GDK_BACKEND environment variable, ensuring smoother integration for users running Linux.

Changes

Files Change Summary
mkdocs-website/docs/en/changelog.md Added a new entry in the changelog under "Fixed" for Wayland support, referencing previous PRs.
v3/pkg/application/application_linux.go Introduced a conditional check for setting the GDK_BACKEND variable in the init function.

Poem

🐰 In a world where code does play,
Changes hop in, brightening the day.
With checks and fixes, oh what a sight!
Wayland support now feels just right!
Let's leap ahead, embrace the fun,
For every rabbit knows, the work's never done! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@stendler stendler changed the title fix: enable to run natively in wayland [v3,linux] fix: enable to run natively in wayland Jul 16, 2024
@atterpac
Copy link
Contributor

This looks fine to me. Have you noticed any other artifacts of using wayland backend in the webkit window?

@stendler
Copy link
Author

Haven't noticed any issues with wayland so far. Though, I've only used the cgo version. The purego code seems to set _ = os.Setenv("GDK_BACKEND", "x11") without any checks as well. But that also does not seem on par feature wise?

@leaanthony
Copy link
Member

Thanks 🙏 Please could you add an entry to the changelog located at mkdocs-website/docs/changelog.md? Thanks!

@stendler
Copy link
Author

Done!

@leaanthony
Copy link
Member

Can you please fix the merge conflicts 👍

Incorporated from this v2 change:
wailsapp#1811
Copy link

sonarcloud bot commented Aug 23, 2024

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 46dbbb3 and 18e461b.

Files selected for processing (2)
  • mkdocs-website/docs/en/changelog.md (1 hunks)
  • v3/pkg/application/application_linux.go (1 hunks)
Additional comments not posted (2)
v3/pkg/application/application_linux.go (1)

30-32: Conditional check for GDK_BACKEND is well-implemented.

The logic to set GDK_BACKEND only when necessary is a robust improvement, preventing potential conflicts with existing environment variable values.

mkdocs-website/docs/en/changelog.md (1)

25-25: Changelog entry is clear and informative.

The new entry under the "Fixed" section accurately describes the changes and references relevant pull requests, maintaining consistency with the existing format.

@stendler
Copy link
Author

stendler commented Aug 23, 2024

I've rebased and moved the changelog line to the new unreleased section.

Although now I seem to have trouble building on linux (likely due to changes in #3667):

 WARNING  -: # github.com/wailsapp/wails/v3/pkg/application                                                                                                                                                                                                                                                         
          wails/v3/pkg/application/webview_window_linux.go:383:69: could not determine kind of name for C.GDK_ALL_EVENTS_MASK
          wails/v3/pkg/application/webview_window_linux.go:381:69: could not determine kind of name for C.GDK_ENTER_NOTIFY_MASK
          wails/v3/pkg/application/webview_window_linux.go:381:93: could not determine kind of name for C.GDK_LEAVE_NOTIFY_MASK
          wails/v3/pkg/application/webview_window_linux.go:381:29: could not determine kind of name for C.GtkWidget
          wails/v3/pkg/application/webview_window_linux.go:381:3: could not determine kind of name for C.gtk_widget_set_events
 WARNING  /myapp/wails/v3/pkg/application/application_linux.go:15:8: could not import C (no metadata for C)                                                                                                                                                             
 WARNING  /myapp/wails/v3/pkg/application/webview_window_linux.go:285:25: undefined: options                                                                                                                                                                            
 WARNING  /myapp/wails/v3/pkg/application/webview_window_linux.go:381:42: undefined: unsafe                                                                                                                                                                             
 WARNING  /myapp/wails/v3/pkg/application/webview_window_linux.go:383:42: undefined: unsafe  

See also the CI in my fork: https://github.com/stendler/wails/actions/runs/10525939856/job/29165722019#step:6:381

EDIT: I got it to run, but ... (click to expand)

in webview_window_linux.go options was used instead of w.parent.options, and I've moved the C calls into linux_cgo.go.

But I could not get the "ignoreMouseEvents" behaviour to work correclty. Neither with the moved implementation, nor with the already existing windowIgnoreMouseEvents (which errors as the GdkWindow is not yet "realized"), and also not when detecting if the GdkWindow is not realised and deferring the gdk_window_set_pass_through with signal_connect on the "realize" signal.
The last one at least does not throw CRITICAL, but also does not work as I would expect.

At least it builds again, and the tests pass: https://github.com/stendler/wails/actions/runs/10530008414

@leaanthony leaanthony merged commit 88c9017 into wailsapp:v3-alpha Aug 25, 2024
12 of 13 checks passed
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.

None yet

3 participants