Window size setting requests not being ignored while in full screen (2)
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 9h 45m
- Merged PRs (30d)
- 58
Description
### Describe the bug
As mentioned in https://github.com/beeware/toga/issues/2862#issuecomment-2559258650 , the new API for resizing the window should ignore resizing requests when in full screen.
But testing the provided code below with Toga v0.5.0, instead of ignored requests, I'm getting exceptions and consequential blocking of downstream code execution.
```
Error in handler: Cannot resize window while in WindowState.FULLSCREEN
Traceback (most recent call last):
File "/Users/user/full_screen_resize_issue/venv/lib/python3.13/site-packages/toga/handlers.py", line 161, in _handler
result = handler(interface, *args, **kwargs)
File "/Users/user/full_screen_resize_issue/fullscreenresizeissue/src/fullscreenresizeissue/app.py", line 95, in go_to_page_one
self.main_window.size = (800, 600)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/full_screen_resize_issue/venv/lib/python3.13/site-packages/toga/window.py", line 445, in size
raise RuntimeError(f"Cannot resize window while in {self.state}")
RuntimeError: Cannot resize window while in WindowState.FULLSCREEN
```
### Sample Code
[FullScreenResizeIssue - Hyuri.zip](https://github.com/user-attachments/files/17082615/FullScreenResizeIssue.-.Hyuri.zip)
When the "Go To Page 1" button is pressed, the `go_to_page_one` callback runs 1*) Resize the window and 2*) Change the window content. But the errors produced are blocking the execution of number 2. So, in this case, unless you leave full screen, you can't change the window content — not after resizing.
```
def go_to_page_one(self, widget):
self.main_window.size = (800, 600) # 1*
self.main_window.content = self.page_one # 2*
```
### Steps to reproduce
1. Have a page that sets a window size
2. Go into full screen, using the green window button
3. Go to another page
4. Come back to the page that sets a window size
5. See issue
### Expected behavior
Toga should ignore window size setting when app/window is in full screen, instead of raising exceptions, especially so that it doesn't block any downstream code within the same execution branch.
### Screenshots
_No response_
### Environment
- Operating System: macOS 13.7.4
- Python version: 3.13.2
- Software versions:
- Briefcase: 0.3.22
- Toga: 0.5.0
### Logs
```
```
### Additional context
Issue that led to the discovery of this issue: #2862
Contributor guide
Research direction
Start with toga/window.py, especially the size setter shown in the traceback, and review how full-screen state is handled. Reproduce the issue with the provided sample and steps, then verify that a size request during full screen does not raise and that the following content change still executes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100