Managing maximized windows on MacOS

Paul Dupuis paul at researchware.com
Wed Nov 20 08:17:33 EST 2019


On 11/20/2019 3:45 AM, Giovanni via use-livecode wrote:
> Hi everybody,
> as already said the main problem is that there is no way to intercept the maximization action and to understand if the window is maximized or not.
> screenrects or windowBoundingRect are not useful in this case mainly when the maximized window has a maxWidth or maxHeight value lower than the maximum width/height of the screenrect.
>
> Moreover due to the bug #21311 (https://quality.livecode.com/show_bug.cgi?id=21311 <https://quality.livecode.com/show_bug.cgi?id=21311>) it’s not possible to prevent the windows maximization for the resizable stacks.
>
> So, any other hint about this topic?

As this is really an issue mainly on recent versions of macOS where 
maximize goes to full screen and then really on on the primary monitor 
as it covers things like the menu bar, I think a work-around in 
resizeStack is the way to go. in the resizeStack handler see get the 
rect of the stack - this will be the stacks new rect. If the top in the 
space normally reserved for the menu bar. It doesn't have to equal the 
rect of the primary monitor. You just eed to check the top and see if it 
is less than the height of the macOS menubar (I think 44px?  Can't 
remember off the top of my head). If top is less than 44px then the 
stack has been maximized and then you can reset the rect to the 
effective working rect of the primary screen

so something like:

on resizeStack
   lock screen
   if the screen of this stack = 1 then -- this stack is on the primary 
monitor
    if (the effective top of this stack < (item 2 of the screenRect + 
44)) then -- this stack has been maximized as its top is "above" the menubar
     set the effective rect of this stack to the effective working 
screenRect
    end if
   end if
   -- do the rest of resizeStack based on the (now) revised stack rect, 
so don't use the height or width passed as params, but get the height, 
width, or rect after this line so you have the revised rect.
   ...
   unlock screen
end resizeStack

I have not tested this - I just wrote it off the top of my head, so 
check to see if it works.




More information about the use-livecode mailing list