Bug 460779

Summary: digiKam in the Windows 10 forgets the last opened window size.
Product: [Applications] digikam Reporter: Peter <benedekppeter>
Component: Usability-ErgonomyAssignee: Digikam Developers <digikam-bugs-null>
Status: VERIFIED FIXED    
Severity: normal CC: bjornh, caulier.gilles, metzpinguin, nate, Stephan.Kranz, twcunningham627
Priority: NOR    
Version: 7.9.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In: 8.1.0
Sentry Crash Report:
Attachments: 7zip archive of BaseDlg class sample

Description Peter 2022-10-20 18:26:30 UTC
digiKam 7.9 version not remember the last size of digiKam window. I tested in Linux Mint 20.x, but this works well there, in the digiKam 7.8 worked well too.

1) Open digiKam in Windows 10
2) Click full screen button on the digiKam window titlebar
3) Close digiKam
4) Open again the digiKam

Result: Window of digiKam again small size, digiKam not remember to the full screen size of the window

I try deleted digikamrc file and create again, but not helped me.
Comment 1 Maik Qualmann 2022-10-20 19:11:49 UTC
Yes, I can reproduce. Since we haven't made any changes here, I suspect the update to a newer KF5 version made things worse.

Maik
Comment 2 caulier.gilles 2022-10-20 19:48:16 UTC
Hi Maik,

Look here :

https://kde.org/announcements/frameworks/5/5.99.0/

Section KXMLGUI : "use same config for position restoration as for position saving"

Gilles
Comment 3 Maik Qualmann 2022-10-20 20:17:18 UTC
Hmm, I see that there is a new feature for saving via QScreen. But I also see that we probably need to implement save/restoreWindowPosition() in addition to save/restoreWindowSize().

Maik
Comment 4 Maik Qualmann 2022-11-17 15:53:03 UTC
*** Bug 461954 has been marked as a duplicate of this bug. ***
Comment 5 Maik Qualmann 2022-11-17 15:57:33 UTC
The problem is in a used KF5 library. It has also been reported for Linux with Wyland.

Maik
Comment 6 Maik Qualmann 2022-11-20 16:45:05 UTC
*** Bug 462068 has been marked as a duplicate of this bug. ***
Comment 7 caulier.gilles 2022-11-25 05:45:29 UTC
Hi Maik,

In KF5 5.100, i do not seen change in KXmlGui framework about this problem:

https://invent.kde.org/frameworks/kxmlgui/-/commits/master

There is also nothing to read in framework announcement :

https://kde.org/announcements/frameworks/5/5.100.0/

I can upgrade KF5 to release 100 (actually 99), but i doubt that something will be fixed...

Gilles

Note : i can reproduce the problem under Windows 10, but not under Linux and MacOS.
Comment 8 Maik Qualmann 2022-11-25 06:58:31 UTC
I think this recent bug report is related to this: Bug 461405

Maik
Comment 9 caulier.gilles 2022-11-25 15:46:15 UTC
Maik,

This is the commit change in KXMLGUI about to restore the window position on screen between application instances:

https://invent.kde.org/frameworks/kxmlgui/-/commit/72919b5ef9168a5419b80fb26b7241fc507cd63a#78c679f7f0f0a8423d30a5f6eb63a53f4fc17ccc

So the current code located at this place :

https://invent.kde.org/frameworks/kxmlgui/-/blob/master/src/kmainwindow.cpp#L745

Who turn on "AllowKDEAppsToRememberWindowPositions" value on the config file exactly ?

Gilles
Comment 10 caulier.gilles 2022-11-25 15:49:20 UTC
The entry in bugzilla relevant of this code in KXMLGUI :
https://bugs.kde.org/show_bug.cgi?id=426725

Gilles
Comment 11 caulier.gilles 2022-11-25 18:45:34 UTC
Maik,

Another entry interesting to read :

https://bugs.kde.org/show_bug.cgi?id=415150

Gilles
Comment 12 Maik Qualmann 2022-11-25 19:37:08 UTC
I see that not only the screen size is encoded in the size parameter, but also the screen itself. I think since the problem only occurs on Wyland and Windows and probably not on X11 that it is related to that.

Here's a history, it seems to have been changed several times, my monitor is always connected via display port, the port names vary.

DP-1 HDMI-A-1 Height 1200=894
DP-1 HDMI-A-1 Width 1920=1920
DP-1 Height 1200=894
DP-1 Height 1920x1200=894
DP-1 Width 1920=1920
DP-1 Width 1920x1200=1912
DP-1 XPosition 1920x1200=4
DP-1 YPosition 1920x1200=147
DisplayPort-0=DisplayPort-0
DisplayPort-0 HDMI-0 Height 1200=894
DisplayPort-0 HDMI-0 Width 1920=1920
DisplayPort-0 HDMI-0 XPosition=0
DisplayPort-0 HDMI-0 YPosition=31

Maik
Comment 13 Maik Qualmann 2022-11-25 19:49:11 UTC
The current values written in KF5.100 look like this:

DisplayPort-0=DisplayPort-0
DisplayPort-0 Height 1920x1200 DisplayPort-0=1021
DisplayPort-0 Width 1920x1200 DisplayPort-0=1912
DisplayPort-0 XPosition 1920x1200 DisplayPort-0=4
DisplayPort-0 YPosition 1920x1200 DisplayPort-0=32

Maik
Comment 14 Maik Qualmann 2022-11-25 20:02:05 UTC
A test with a Waland Plasma session shows that the values from X11 are not adopted. The size is then saved correctly, but not the position. It also shows the applied values that no position is saved under Wayland.

DP-1 Height 1920x1200 DP-1=931
DP-1 Width 1920x1200 DP-1=1511
DP-1 Window-Maximized 1920x1200 DP-1=true

Maik
Comment 15 Nate Graham 2022-11-29 17:54:51 UTC

*** This bug has been marked as a duplicate of bug 460260 ***
Comment 16 Nate Graham 2022-11-29 17:56:46 UTC
> A test with a Wayland Plasma session shows that the values from X11 are not adopted

That's a separate issue, basically Bug 385135.
Comment 17 Maik Qualmann 2022-11-29 17:58:11 UTC
These are the entries from a Windows 10 (VM) digiKamrc. The screen is missing at the beginning and the config starts with a "\". This is also output with many error messages in the log. It is clear that the window size cannot be found. We have 2 options, either we look for the problem in the KF5 library or we implement it ourselves as a workaround.

\sHeight 1600x1200=829
\sWidth 1600x1200=1238
\sXPosition 1600x1200=174
\sYPosition 1600x1200=168

Maik
Comment 18 caulier.gilles 2022-11-29 18:34:28 UTC
This problem is a recurrent issue since many years. It's clear for me there is a lack of Windows support somewhere. I vote for a simple solution based on QSettings file for ex, which work well under Windows (i use it  at work since a very long time).

Gilles
Comment 19 Maik Qualmann 2022-11-29 20:51:14 UTC
Git commit 329e06c8f0f804810adf8ef65ae873bf3f8e435d by Maik Qualmann.
Committed on 29/11/2022 at 20:50.
Pushed by mqualmann into branch 'master'.

save and restore window Size on Windows for testing

M  +2    -0    core/app/main/digikamapp.cpp
M  +67   -0    core/libs/widgets/mainview/dxmlguiwindow.cpp
M  +3    -0    core/libs/widgets/mainview/dxmlguiwindow.h
M  +2    -0    core/utilities/imageeditor/main/imagewindow.cpp
M  +2    -0    core/utilities/import/main/importui.cpp
M  +2    -0    core/utilities/lighttable/lighttablewindow.cpp
M  +2    -0    core/utilities/queuemanager/main/queuemgrwindow.cpp

https://invent.kde.org/graphics/digikam/commit/329e06c8f0f804810adf8ef65ae873bf3f8e435d
Comment 20 Maik Qualmann 2022-11-29 20:55:05 UTC
@Gilles, can you create a Windows digiKam-8.0.0 bundle to test? If it works, we can apply the patch to digiKam-7.9.0. Some checks to see if the window size still fits may need to be added. I only plan on keeping this code until it is fixed in KF5.

Maik
Comment 21 caulier.gilles 2022-11-29 20:58:14 UTC
yes 8.0.0 installer will be online tomorrow morning.

Gilles
Comment 22 caulier.gilles 2022-11-30 07:02:55 UTC
Windows 8.0.0 installer have been just updated online :

https://files.kde.org/digikam/unstable/

Gilles
Comment 23 caulier.gilles 2022-11-30 07:31:47 UTC
Maik,
I tested last 8.0.0 pre-release under Windows 7, and window sizes and positions are now properly restored as i can see...
Gilles
Comment 24 Peter 2022-11-30 08:02:01 UTC
(In reply to caulier.gilles from comment #23)
> Maik,
> I tested last 8.0.0 pre-release under Windows 7, and window sizes and
> positions are now properly restored as i can see...
> Gilles

Hi Maik and Gilles,
I tested last 8.0.0 pre-release under Windows 10.
It seems to work fine, but it doesn't...
...digiKam adjusts the set size only after every second start, but even then the program window is only apparently full screen. It's actually full screen, but a resizable window.
Comment 25 Maik Qualmann 2022-11-30 11:30:23 UTC
It is clear that it does not work the first time you start it, but then it always works here under Windows10.
Yes, the window is only resized to its previous size, currently it is not stored in the config that it is maximized. As said, this is only a workaround until the problem is fixed in the KF5 Library.

Maik
Comment 26 caulier.gilles 2022-11-30 11:39:00 UTC
yes i agree with Maik. the goal is to restore size and position between sessions, the first one is a special case.

Gilles
Comment 27 Maik Qualmann 2022-11-30 18:06:35 UTC
Git commit dfacb22f8819c5ac3150201aef2a2a833ddf396a by Maik Qualmann.
Committed on 30/11/2022 at 18:05.
Pushed by mqualmann into branch 'master'.

restore maximized state and check geometry

M  +20   -6    core/libs/widgets/mainview/dxmlguiwindow.cpp

https://invent.kde.org/graphics/digikam/commit/dfacb22f8819c5ac3150201aef2a2a833ddf396a
Comment 28 Peter 2022-11-30 19:10:22 UTC
Maik and Giles.
Thank you for your work
Regards
Peter
Comment 29 Maik Qualmann 2022-11-30 21:12:11 UTC
@Gilles, another digiKam-8.0.0 test version would be good before we merge the patch to digiKam-7.9.0.

Maik
Comment 30 caulier.gilles 2022-12-01 06:28:37 UTC
Done. Windows installers 8.0.0 are updated online at usual place...

Gilles
Comment 31 Maik Qualmann 2022-12-01 14:01:19 UTC
For a single screen it works fine. In a multiscreen setup, it doesn't work on the 2nd screen. I guess we are too fast and have to do it after the show event.

Maik
Comment 32 caulier.gilles 2022-12-01 14:20:48 UTC
Created attachment 154197 [details]
7zip archive of BaseDlg class sample

Hi Maik,

Class BaseDlg based on QDialog used in my office on multi-screen Windows computer, with code to restore and sample dialog size and position. It's use QDialog::showEvent().

Gilles
Comment 33 caulier.gilles 2022-12-01 14:22:12 UTC
>code to restore and sample dialog size and position
==> code to restore and save dialog size and position
Comment 34 Maik Qualmann 2022-12-01 19:14:20 UTC
Git commit 6415d9aef7477471e8b814ff03c9c07c7906ec31 by Maik Qualmann.
Committed on 01/12/2022 at 19:13.
Pushed by mqualmann into branch 'master'.

improved support for multiple monitors

M  +0    -2    core/app/main/digikamapp.cpp
M  +35   -22   core/libs/widgets/mainview/dxmlguiwindow.cpp
M  +5    -0    core/libs/widgets/mainview/dxmlguiwindow.h
M  +0    -2    core/utilities/imageeditor/main/imagewindow.cpp
M  +0    -2    core/utilities/lighttable/lighttablewindow.cpp
M  +0    -2    core/utilities/queuemanager/main/queuemgrwindow.cpp

https://invent.kde.org/graphics/digikam/commit/6415d9aef7477471e8b814ff03c9c07c7906ec31
Comment 35 caulier.gilles 2022-12-02 06:27:42 UTC
Maik,

New version of Windows installer 8.0.0 is online.

Gilles
Comment 36 Maik Qualmann 2022-12-02 11:30:10 UTC
Thanks Gilles, it seems to be working fine as a workaround so far. digiKam will reopen to the last used screen, with the same position and size or maximized. I will apply the patch to digiKam-7.9.0 tonight.

Maik
Comment 37 caulier.gilles 2022-12-02 12:12:35 UTC
Great. Well, i can plan the 7.9.0 tag on git while this week end.

Gilles
Comment 38 Maik Qualmann 2022-12-02 17:40:40 UTC
Git commit c111184751010a0cbae92ae4fa3aecfa4b780e01 by Maik Qualmann.
Committed on 02/12/2022 at 17:39.
Pushed by mqualmann into branch 'qt5-maintenance'.

backport from master workaround to fix window size and position on Windows

M  +94   -0    core/libs/widgets/mainview/dxmlguiwindow.cpp
M  +8    -0    core/libs/widgets/mainview/dxmlguiwindow.h

https://invent.kde.org/graphics/digikam/commit/c111184751010a0cbae92ae4fa3aecfa4b780e01
Comment 39 Tom Cunningham 2022-12-08 13:38:09 UTC
I noticed this behavior happens with the image editor window as well in digiKam 8.0 beta.
Comment 40 caulier.gilles 2022-12-08 13:47:02 UTC
Hi Tom,

And not in 7.9.0 just released ? Unix Linux, Mac or Windows ?

Gilles
Comment 41 Maik Qualmann 2022-12-08 13:57:20 UTC
The problem is also fixed under digiKam-8.0.0. But not for the first start, first for the further ones.

Maik
Comment 42 caulier.gilles 2023-05-10 14:33:05 UTC
Fixed with bug 460260