SetDisplayAttributes() and Border
Posted: Thu Sep 18, 2025 3:59 pm
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.
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