Window position when toggling Borderless
Posted: Sat May 23, 2020 1:03 pm
When running the included Hollywood example named DisplayStyle you can tick and untick the borderless flag.
For each cycle the window will move up and left the same number of pixels that the size of the borders.
Repeating this and it will eventually move until you no longer can reach that button.
If the flag is assigned to a key, you can move the window as far out of the screen as you wish (at least on OS's that allow this). Apearently with not other option than to force quit the program.
Ideally I would prefer the content of the window to stay exactly at the current position, and just remove or add the border without moving the content. I made this piece of code to acheive that.
But I still think that it would be better that there was a default position like center, or similar behaviour as in my example when toggling the border on /off.
For each cycle the window will move up and left the same number of pixels that the size of the borders.
Repeating this and it will eventually move until you no longer can reach that button.
If the flag is assigned to a key, you can move the window as far out of the screen as you wish (at least on OS's that allow this). Apearently with not other option than to force quit the program.
Ideally I would prefer the content of the window to stay exactly at the current position, and just remove or add the border without moving the content. I made this piece of code to acheive that.
Code: Select all
borderless = GetAttribute(#DISPLAY, 0, #ATTRBORDERLESS)
If borderless
wxpos = GetAttribute(#DISPLAY, 0, #ATTRXPOS)
wypos = GetAttribute(#DISPLAY, 0, #ATTRYPOS)
SetDisplayAttributes({Borderless = False, X = wxpos, Y = wypos})
Else
wxpos = GetAttribute(#DISPLAY, 0, #ATTRXPOS)
wypos = GetAttribute(#DISPLAY, 0, #ATTRYPOS)
lbw = GetAttribute(#DISPLAY, 0, #ATTRBORDERLEFT)
tbw = GetAttribute(#DISPLAY, 0, #ATTRBORDERTOP)
SetDisplayAttributes({Borderless = True, X = wxpos+lbw, Y = wypos+tbw})
EndIf