Repository: tauri-apps/wry (language: rust)

Issue:
[wry-0.37.0] Build failed for Linux i686 and armv7 32-bit targets
**Describe the bug**

When building a Tauri v2.0-beta application (wry-0.37.0) on Ubuntu 22, the build succeeds for x86_64 and aarch64 architectures but fails for i686 and armv7 32-bit targets with the following error:

```shell
error[E0308]: mismatched types
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:66:72
   |
66 |         unsafe { (xlib.XDestroyWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap()) };
   |                  ---------------------                                 ^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
   |                  |
   |                  arguments to this function are incorrect
   |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
```

The cross-compilation environment has been correctly configured for the `i686-unknown-linux-gnu` and `armv7-unknown-linux-gnueabihf` targets, following the official documentation.

**Steps To Reproduce**

On Ubuntu 22 (x86_64), build the latest Tauri v2.0.0-beta example app targeting `i686-unknown-linux-gnu` or `armv7-unknown-linux-gnueabihf`.

**Expected behavior**

The i686 and armv7 versions of the app should build successfully.

**Screenshots**

<img width="1497" alt="图片" src="https://github.com/tauri-apps/wry/assets/35302658/f7473ef6-97e8-48ae-9531-013e50da372d">

**Platform and Versions (please complete the following information):**

Platform: Github Actions (ubuntu-latest)
Build Targets: `i686-unknown-linux-gnu`, `armv7-unknown-linux-gnueabihf`

**Additional context**

Github Action logs: https://github.com/idootop/feiyu-player/actions/runs/8398912429/job/23004365678

<details>
<summary>👉 Full error logs</summary>

```shell
error[E0308]: mismatched types
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:66:72
   |
66 |         unsafe { (xlib.XDestroyWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap()) };
   |                  ---------------------                                 ^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
   |                  |
   |                  arguments to this function are incorrect
   |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
   |
66 |         unsafe { (xlib.XDestroyWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap().try_into().unwrap()) };
   |                                                                                                ++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:168:27
    |
168 |       w.x11_window = Some(window);
    |                      ---- ^^^^^^ expected `u64`, found `u32`
    |                      |
    |                      arguments to this enum variant are incorrect
    |
help: the type constructed contains `u32` due to the type of the argument passed
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:168:22
    |
168 |       w.x11_window = Some(window);
    |                      ^^^^^------^
    |                           |
    |                           this argument influences the type of `Some`
note: tuple variant defined here
   --> /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/option.rs:578:5
help: you can convert a `u32` to a `u64`
    |
168 |       w.x11_window = Some(window.into());
    |                                 +++++++

error[E0308]: mismatched types
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:635:60
    |
635 |         let ok = (xlib.XGetWindowAttributes)(display as _, window_handle, &mut attributes);
    |                  ---------------------------               ^^^^^^^^^^^^^ expected `u32`, found `u64`
    |                  |
    |                  arguments to this function are incorrect
    |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
    |
635 |         let ok = (xlib.XGetWindowAttributes)(display as _, window_handle.try_into().unwrap(), &mut attributes);
    |                                                                         ++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:697:68
    |
697 |         unsafe { (xlib.XMapWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap()) };
    |                  -----------------                                 ^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
    |                  |
    |                  arguments to this function are incorrect
    |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
    |
697 |         unsafe { (xlib.XMapWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap().try_into().unwrap()) };
    |                                                                                            ++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.37.0/src/webkitgtk/mod.rs:699:70
    |
699 |         unsafe { (xlib.XUnmapWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap()) };
    |                  -------------------                                 ^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
    |                  |
    |                  arguments to this function are incorrect
    |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
    |
699 |         unsafe { (xlib.XUnmapWindow)(self.x11_display.unwrap() as _, self.x11_window.unwrap().try_into().unwrap()) };
    |                                                                                              ++++++++++++++++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `wry` (lib) due to 5 previous errors
warning: build failed, waiting for other jobs to finish...
    Error failed to build app: failed to build app
```

</details>



Discussion / hints:

Fix patch:
diff --git a/.changes/32bit-compilation.md b/.changes/32bit-compilation.md
new file mode 100644
index 000000000..c18e035c9
--- /dev/null
+++ b/.changes/32bit-compilation.md
@@ -0,0 +1,5 @@
+---
+wry: patch
+---
+
+Fixes compilation for 32bit Linux targets.
diff --git a/src/webkitgtk/mod.rs b/src/webkitgtk/mod.rs
index a0f343f93..39966bf7a 100644
--- a/src/webkitgtk/mod.rs
+++ b/src/webkitgtk/mod.rs
@@ -17,7 +17,10 @@ use javascriptcore::ValueExt;
 use raw_window_handle::{HasWindowHandle, RawWindowHandle};
 #[cfg(any(debug_assertions, feature = "devtools"))]
 use std::sync::atomic::{AtomicBool, Ordering};
-use std::sync::{Arc, Mutex};
+use std::{
+  ffi::c_ulong,
+  sync::{Arc, Mutex},
+};
 #[cfg(any(debug_assertions, feature = "devtools"))]
 use webkit2gtk::WebInspectorExt;
 use webkit2gtk::{
@@ -51,7 +54,7 @@ struct X11Data {
   is_child: bool,
   xlib: Xlib,
   x11_display: *mut std::ffi::c_void,
-  x11_window: u64,
+  x11_window: c_ulong,
   gtk_window: gtk::Window,
 }
 
@@ -152,9 +155,9 @@ impl InnerWebView {
   fn create_container_x11_window(
     xlib: &Xlib,
     display: *mut _XDisplay,
-    parent: u64,
+    parent: c_ulong,
     attributes: &WebViewAttributes,
-  ) -> u64 {
+  ) -> c_ulong {
     let window = unsafe {
       (xlib.XCreateSimpleWindow)(
         display,
@@ -179,7 +182,10 @@ impl InnerWebView {
     window
   }
 
-  pub fn create_gtk_window(raw: *mut GdkX11Display, x11_window: u64) -> (gtk::Window, gtk::Box) {
+  pub fn create_gtk_window(
+    raw: *mut GdkX11Display,
+    x11_window: c_ulong,
+  ) -> (gtk::Window, gtk::Box) {
     // Gdk.Window
     let gdk_window = unsafe { gdk_x11_window_foreign_new_for_display(raw, x11_window) };
     let gdk_window = unsafe { gdk::Window::from_glib_full(gdk_window) };


Test patch: