I am trying to position documents side by side using a macro. I started by using Windows 10 snap feature to position two windows and retrieved their position and size. Dim w: w = e.CurrentController.Frame.getContainerWindow() print "x=" & w.PosSize.X & " y=" & w.PosSize.Y _ & " w=" & w.PosSize.width & " h=" & w.PosSize.height Then I tried to use .setPosSize on other windows but it didn't work exactly. Position was off. Dim w: w = altDoc.CurrentController.Frame.ContainerWindow w.setPosSize(961,111,958,968,15) 'Coordinates for left side ' x=1 y=111 w=958 h=968 'Coordinates for right side ' x=961 y=111 w=958 h=968 Behavior is the same with v4.3 and latest v7.4.2.3 When snapping a window (sides or corners) and using the following code you can see the problem, Sub TestPosSize Dim oDoc, oWindow, posSize oDoc=ThisComponent oWindow=ThisComponent.CurrentController.frame.ContainerWindow oWindow.IsMaximized=False posSize=oWindow.posSize With posSize oWindow.setPosSize .X, .Y, .width, .Height, 15 End With End Sub In Windows10 the above code, - if the window is centered it does nothing. - if snapped it moves it by about 10px - if part of the window is outside viewable area (left/right), it moves it back in + 10px. - If window below bottom it snaps vertically!?! (I have Windows taskbar at the top should it matter). In Ubuntu 21 with LO 7.1 - if snapped it moves and resizes window - if centered, repeated runs makes window smaller Might this explain why when opening saved documents they never appear at their exact previous position?
LibreOffice 3.3.0 OOO330m19 (Build:6) tag libreoffice-3.3.0.4 Similar behavior with above version on Windows 10.
If this is a safety feature, so Windows don't get lost outside viewable area, might I suggest a new option under the Window menu, "Move window to viewable area"?
Additional info of versions tested: Version: 7.0.5.2 (x64) Build ID: 64390860c6cd0aca4beafafcfd84613dd9dfb63a CPU threads: 12; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win Locale: en-AU (en_AU); UI: en-GB Calc: CL Version: 7.4.2.3 (x64) / LibreOffice Community Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf CPU threads: 12; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win Locale: en-AU (en_AU); UI: en-GB Calc: CL Version: 7.1.5.2 / LibreOffice Community Build ID: 10(Build:2) CPU threads: 2; OS: Linux 5.11; UI render: default; VCL: gtk3 Locale: en-AU (en_AU.UTF-8); UI: en-US Ubuntu package version: 1:7.1.5-0ubuntu0.21.04.1 Calc: threaded
The problem is that the line oWindow.IsMaximized = False ... restores the window position, as when you double-click the header bar. So in your code it first restores the window and then the position/size is applied.
(In reply to Rafael Lima from comment #4) > The problem is that the line > > oWindow.IsMaximized = False > > ... restores the window position, as when you double-click the header bar. > So in your code it first restores the window and then the position/size is > applied. ok but even if I comment this line, and with a non-snapped window, if I do oWindow.setPosSize(1,1,958,968,15) the windows is still ~10px of the edge.