Repository: wezterm/wezterm (language: rust)

Issue:
Maximize is not working and fullscreen is not fullscreen
### What Operating System(s) are you seeing this problem on?

Arch Linux (KDE)

### Which Wayland compositor or X11 Window manager(s) are you using?

Wayland

### WezTerm version

20240922-151228-2b76c63b

### Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

### Describe the bug

I set the wezterm gui to start maximized using `window:gui_window():maximize()` and the whole config is in the screenshot. Nothing happened and it started in a normal small window. I then replaced that line with `toggle_fullscreen()`. This time it started almost fullscreen except of the bottom edge. I thought first @wez has added a copyright border and I took a couple of seconds to realize that was `firefox` running in the background. I changed the theme to show the problem in a better way and attached a fullscreen of my display
![wezterm](https://github.com/user-attachments/assets/a55db594-97e6-4d15-aa76-32dbd8376dc1)

[wezterm-maximize.log](https://github.com/user-attachments/files/17175929/wezterm-maximize.log)


### To Reproduce

With my config, I set a keyboard shortcut to start `wezterm`. Every time I start it I get that problem. 

### Configuration

wezterm.on('gui-startup', function(cmd)
  local tab, pane, window = mux.spawn_window(cmd or {})
  --window:gui_window():maximize()
  window:gui_window():toggle_fullscreen()
end)

### Expected Behavior

To maximize in case of `maximize()` and really fullscreen in case of `toggle_fullscreen()`

### Logs

Attahced: WEZTERM_LOG=debug wezterm start --always-new-process 2> /tmp/wezterm-maximize.log

### Anything else?

_No response_


Discussion / hints:
I am too facing this issue on my computer.

**What Operating System(s) are you seeing this problem on?**
Fedora 40 (Gnome)

**Which Wayland compositor or X11 Window manager(s) are you using?**
Wayland

**WezTerm version**
wezterm-nightly-fedora40

**Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?**
Yes, I only have the nightly build available for my device.
Hello, I use Wayland too (KDE Neon).

I use this configuration to maximize the windows

```lua
local wezterm = require 'wezterm'
local mux = wezterm.mux
local config = wezterm.config_builder()

wezterm.on('gui-startup', function(cmd)
  local tab, pane, window = mux.spawn_window(cmd or {})
  window:gui_window():maximize()
end)

config.enable_wayland = false

return config
```

[enabled_wayland](https://wezfurlong.org/wezterm/config/lua/config/enable_wayland.html) will use X11 protocol instead of wayland (but surprisingly, when I set this as false, it make the maximize scripts works).
Facing the same issue 
![image](https://github.com/user-attachments/assets/fc3fa90a-5935-4d1b-98bf-5d056b625115)


Fix patch:
diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs
index 74ba5ae6b9f..79960b3e4a4 100644
--- a/window/src/os/wayland/window.rs
+++ b/window/src/os/wayland/window.rs
@@ -466,6 +466,14 @@ impl WindowOps for WaylandWindow {
             Ok(())
         });
     }
+
+    fn maximize(&self) {
+        WaylandConnection::with_window_inner(self.0, move |inner| Ok(inner.maximize()));
+    }
+
+    fn restore(&self) {
+        WaylandConnection::with_window_inner(self.0, move |inner| Ok(inner.restore()));
+    }
 }
 #[derive(Default, Clone, Debug)]
 pub(crate) struct PendingEvent {
@@ -1208,6 +1216,18 @@ impl WaylandWindowInner {
             _ => log::warn!("unhandled FrameAction: {:?}", action),
         }
     }
+
+    fn maximize(&mut self) {
+        if let Some(window) = self.window.as_mut() {
+            window.set_maximized();
+        }
+    }
+
+    fn restore(&mut self) {
+        if let Some(window) = self.window.as_mut() {
+            window.unset_maximized();
+        }
+    }
 }
 
 impl WaylandState {


Test patch: