Page 1 of 1

SetDisplayAttributes() and Border

Posted: Thu Sep 18, 2025 3:59 pm
by Flinx
Hi,
When experimenting (on Windows) with switching between a normal and a semi-transparent window (which is borderless), I had difficulties with the window position. After switching back and forth several times, the window moved to the top and the left and the title bar eventually disappeared from the screen, so that it could only be retrieved with tricks.
I assumed that I could correct the position by taking the border size into account, but SetDisplayAttributes() did not do what I thought it should. After a few attempts, I found the workaround of moving the window back to the correct position with MoveDisplay() after SetDisplayAttributes(), but since the manual states that X,Y in SetDisplayAttributes() is the same as MoveDisplay(X,Y), I am reporting this behavior as a bug. I suspect it results from SetDisplayAttributes() wanting to avoid changing the position if it is unchanged, but not taking the changed border value into account.

Code: Select all

@DISPLAY {X=100, Y=100, Width = 800, Height = 600, Color = #GRAY, Layers = True}

gDisplayHeight=GetAttribute(#DISPLAY, 1, #ATTRHEIGHT)
gDisplayWidth=GetAttribute(#DISPLAY, 1, #ATTRWIDTH)

gLeftBorder=GetAttribute(#DISPLAY, 1, #ATTRBORDERLEFT)
gTopBorder=GetAttribute(#DISPLAY, 1, #ATTRBORDERTOP)
DebugPrint("gLeftBorder",gLeftBorder,"   gTopBorder",gTopBorder,"\n")


gX1=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY1=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("initial X/Y:",gX1,gY1)

SetDisplayAttributes({X=gX, Y=gY, Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless X/Y:",gX,gY)

SetDisplayAttributes({X=gX, Y=gY, Borderless=False})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Back to Border X/Y:",gX,gY) ; Result 97 74


DebugPrint("\nPart 2 (add LeftBorder)")
MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless X/Y:",gX,gY)

SetDisplayAttributes({X=gX+gLeftBorder, Y=gY, Borderless=False})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Back to Border X/Y:",gX,gY) ; Result 103 100


DebugPrint("\nPart 3 (X=100)")
MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless X/Y:",gX,gY)

SetDisplayAttributes({X=100, Y=gY, Borderless=False})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Back to Border X/Y:",gX,gY) ; Result 97 74


DebugPrint("\nPart 4 (X=101)")
MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless X/Y:",gX,gY)

SetDisplayAttributes({X=101, Y=gY, Borderless=False})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Back to Border X/Y:",gX,gY) ; Result 101 100


DebugPrint("\nPart 5 (add TopBorder)")
MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless X/Y:",gX,gY)

SetDisplayAttributes({X=gX, Y=gY+gTopBorder, Borderless=False})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Back to Border X/Y:",gX,gY) ; Result 100 126


DebugPrint("\nPart 6 (add both)")
MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless X/Y:",gX,gY)

SetDisplayAttributes({X=gX+gLeftBorder, Y=gY+gTopBorder, Borderless=False})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Back to Border X/Y:",gX,gY) ; Result 103 126

Re: SetDisplayAttributes() and Border

Posted: Thu Sep 18, 2025 7:05 pm
by plouf
not an answer but MAYBE , its related these two -> viewtopic.php?t=4232

Re: SetDisplayAttributes() and Border

Posted: Fri Sep 19, 2025 9:45 am
by Flinx
By the way, another interesting effect is that enabling the border with additional “Sizeable=True” causes an additional position deviation of 5. That doesn't seem to make sense to me either.

Code: Select all

@DISPLAY {Width = 800, Height = 600, Color = #GRAY, Layers = True}

DebugPrint("\nBorders:",GetAttribute(#DISPLAY, 1, #ATTRBORDERLEFT),GetAttribute(#DISPLAY, 1, #ATTRBORDERTOP),"\n")

MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless:",gX,gY)

SetDisplayAttributes({Borderless=False})
gXr=GetAttribute(#DISPLAY, gLRCdisplay, #ATTRXPOS)
gYr=GetAttribute(#DISPLAY, gLRCdisplay, #ATTRYPOS)
DebugPrint("back to Border:",gXr,gYr,"")
DebugPrint("diff:",gX-gXr,gY-gYr,"\n")


MoveDisplay(100, 100)
SetDisplayAttributes({Borderless=True})
gX=GetAttribute(#DISPLAY, 1, #ATTRXPOS)
gY=GetAttribute(#DISPLAY, 1, #ATTRYPOS)
DebugPrint("Borderless:",gX,gY)

SetDisplayAttributes({Borderless=False, Sizeable=True})
gXr=GetAttribute(#DISPLAY, gLRCdisplay, #ATTRXPOS)
gYr=GetAttribute(#DISPLAY, gLRCdisplay, #ATTRYPOS)
DebugPrint("back to Border with Sizeable:",gXr,gYr,"")
DebugPrint("diff:",gX-gXr,gY-gYr,"\n")


Re: SetDisplayAttributes() and Border

Posted: Fri Sep 19, 2025 8:56 pm
by airsoftsoftwair
Yes, it's a bug that apparently got introduced in Hollywood 5.0. When switching between borderless and bordered mode, SetDisplayAttributes() does some adjustment to the window position so that the window's content stays in its position but apparently this code somehow got broken after Hollywood 4.7. I've fixed it now and I've also introduced a new tag named "ForceXY" that can be used to disable this automatic position adjustment when switching between borderless and bordered mode because not everybody might want it...

Code: Select all

- New: Added "ForceXY" tag to SetDisplayAttributes(); if this is set, SetDisplayAttributes() won't do any 
  position adjustments when switching between bordered and borderless mode; normally, when switching the
  mode between bordered and borderless without specifying a new position, SetDisplayAttributes() will
  adjust the window position in a way so that the window's main content will keep its position; if you
  don't want that, set the new "ForceXY" tag to TRUE 
- Fix: When switching between bordered and borderless window mode using SetDisplayAttributes() the display 
  position changed slightly