toga icon indicating copy to clipboard operation
toga copied to clipboard

Window size setting requests not being ignored while in full screen

Open hyuri opened this issue 1 year ago • 4 comments

Describe the bug

My app has multiple pages. Two of them set a specific window size. When I go into full screen, go to another page and come back, Toga still applies the size requested by the page, drawing it small from screen lower-left over a black background.

Shouldn't Toga ignore the size setting if the app/window is in full screen?

Edit: If I switch to another app (Command + Tab) and back, the issue is no longer present — meaning: the page fills the full screen again.

Proof-of-concept app capturing the issue: FullScreenResizeIssue - Hyuri.zip

Possibly Related:

When I enter full screen using the green window button (macOS) and check app.is_full_screen and window.full_screen, both report False. If I enter full screen by setting window.full_screen = True, window.full_screen does report True, while app.is_full_screen still reports False.

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.

Screenshots

image

Screen recording showing the issue: video

__

Environment

  • Operating System: macOS 13.6.9
  • Python version: 3.12.5
  • Software versions:
    • Briefcase: 0.3.19
    • Toga: 0.4.7

Logs

No response

Additional context

Related to the lower-left alignment aspect:

Is macOS using a flipped coordinate system? Seems to be the case considering the error above shows the page apparently being drawn from a lower-left origin, so maybe why #2855 is happening?

hyuri avatar Sep 20 '24 16:09 hyuri

I'm not able to reproduce the problem you're describing - but I'm not sure if that's because I'm misunderstanding your description of the problem. In particular, there's a difference between "full screen" (maximized) on a window, and "full screen" presentation mode on the app; I haven't been able to reproduce the behaviour your describe with either - but app-level presentation mode, I also don't have the ability to switch to a different workspace.

It's always a lot more helpful to have a proof-of-concept app, rather than a word description of a problem; that makes it a lot easier to triage a problem, as we can start with a "not working" case, rather than trying to work out how to manufacture one. If you can provide a worked example of this behavior, I can take another look and see what is going on.

Regarding the specific question about macOS coordinate systems - yes, macOS's default coordinate system puts 0,0 at the bottom left of the screen; however, that's unlikely to be the cause of what is going on here. It definitely impacts how the window is displayed, but it shouldn't be altering the resize behavior.

freakboy3742 avatar Sep 20 '24 18:09 freakboy3742

Here you go: FullScreenResizeIssue - Hyuri.zip

I've also added it to the original report.

Also: I forgot to mention that when I switch to another app and switch back, the issue is resolved — the window now fills the full screen again. I've updated the description to include that info.

hyuri avatar Sep 21 '24 03:09 hyuri

I've attached a screen recording, showing the issue, to the original report.

hyuri avatar Sep 21 '24 03:09 hyuri

Ok - I can confirm I can reproduce the problem with the provided code. Some more debugging is required to determine why the "non maximized" window size is being applied when the window isn't maximised.

freakboy3742 avatar Sep 22 '24 05:09 freakboy3742

This bug is currently not reproducible with the current main branch, maybe it was something with the old fullscreen APIs.

proneon267 avatar Dec 23 '24 09:12 proneon267

Oh, I see it now, so you were resizing the window after entering fullscreen, without exiting fullscreen mode first:

def go_to_page_one(self, widget):
		self.main_window.size = (800, 600)
		self.main_window.content = self.page_one
		print(f"Page 1: self.main_window.full_screen: {self.main_window.full_screen}")
		print(f"Page 1: self.is_full_screen: {self.is_full_screen}")

In the new APIs, window resizing and repositioning requests are ignored while the window is in certain states like FULLSCREEN & PRESENTATION, therefore the bug is not reproducible on the latest main branch.

proneon267 avatar Dec 23 '24 09:12 proneon267

In which case - I'll close this ticket.

freakboy3742 avatar Dec 26 '24 00:12 freakboy3742

Testing the provided code 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

When the "Go To Page 1" button is pressed, the callback runs 1) Resize the window and 2) Change the window content. But, with the errors produced, it's also 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)
	self.main_window.content = self.page_one

hyuri avatar Apr 04 '25 18:04 hyuri

@hyuri If you're seeing a different issue from the one that was originally reported, please open a new ticket with details of what you're seeing. This is an area where the specific details of your platform etc are critical.

freakboy3742 avatar Apr 05 '25 02:04 freakboy3742