Bug 151676 - Odd behavior when setting window position/size with setPosSize
Summary: Odd behavior when setting window position/size with setPosSize
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.3.7.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-21 09:45 UTC by Jordi
Modified: 2025-11-27 11:29 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jordi 2022-10-21 09:45:30 UTC
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?
Comment 1 Jordi 2022-10-21 09:50:09 UTC
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4


Similar behavior with above version on Windows 10.
Comment 2 Jordi 2022-10-21 09:54:58 UTC
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"?
Comment 3 Jordi 2022-10-21 10:00:53 UTC
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
Comment 4 Rafael Lima 2022-10-21 19:21:01 UTC
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.
Comment 5 Jordi 2022-10-23 18:37:31 UTC
(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.
Comment 6 QA Administrators 2025-11-27 11:29:17 UTC
Dear Jordi,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug