Bug 150772 - KMainWindow size restoring is broken wrt to maximization
Summary: KMainWindow size restoring is broken wrt to maximization
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: qt (show other bugs)
Version: 4.1
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-12 23:06 UTC by Christoph Pfister
Modified: 2008-11-20 11:04 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
testcase (726 bytes, application/octet-stream)
2007-10-12 23:08 UTC, Christoph Pfister
Details
Simple patch to restore maximized windows maximized (644 bytes, patch)
2008-02-13 02:38 UTC, Armin Berres
Details
testcase for r819912 (1.01 KB, text/plain)
2008-06-12 19:58 UTC, Christoph Pfister
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Pfister 2007-10-12 23:06:34 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

See attached testcase (intentionally no .ui file).
The size of the window is always correctly restored except if it was maximized when you closed the application. In this case it uses some default size when you launch it again.
Outcommenting "mainWindow->createGUI();" makes the whole thing working as expected.
PS: Yes, I know this bug is something _very_ fishy and I hope you're able to reproduce it ...
Comment 1 Christoph Pfister 2007-10-12 23:08:09 UTC
Created attachment 21811 [details]
testcase
Comment 2 Christoph Pfister 2007-11-18 13:17:33 UTC
not reproducible anymore ...
Comment 3 Pino Toscano 2007-11-18 14:18:14 UTC
Can this be the cause for bug #119393 (kde3) or bug #137108 (kde4)?
Comment 4 Christoph Pfister 2007-11-18 15:10:14 UTC
Although the testcase above works now, the real life behind it doesn't.
At least kaffeine and okular (and likely others too) don't restore their size correctly if they were maximized when you closed them.
Using QWidget::showMaximized() instead of KWindowSystem::setState() in KMainWindow::restoreWindowSize() solves it for both cases.
Comment 5 Armin Berres 2007-11-18 15:46:39 UTC
I can trigger this bug (in KDE4) with with okular, kbounce and kiriki, but not with but not with lkskat or kgoldrunner.
Comment 6 Armin Berres 2008-02-13 02:36:18 UTC
I spent some hours with debugging this issue. I still don't understand completely what's going on, but let me elaborate: 
When the window was maximized when it was closed, KMainWindow::restoreWindowSize(..) not set a window size, but it calls KWindowSystem::setState( winId(), state ) with "state = NET::MaxHoriz | NET::MaxVert". KWindowSystem::setState(..) then calls NETWinInfo::setState( state, state ) which will call XChangeProperty(..). Afterwards _NET_WM_STATE_MAXIMIZED_VERT and _NET_WM_STATE_MAXIMIZED_HORZ of the window will be set, but the size isn't changed. Why? I don't know. Is this a feature of XChangeProperty(..) which just sets the flags, but doesn't resize the window?
Anyway, setting the window size in KMainWindow::restoreWindowSize(..) to the desktop size solves the problem. The window behaves as expected. Find the simple patch attached. As I said I don't know, it the behaviour of KWindowSystem::setState(..) and everything it calls is the way it has to be, that's why the real solution may be something else...

The patch is at least a workaround for a very very nasty bug.
Comment 7 Armin Berres 2008-02-13 02:38:21 UTC
Created attachment 23551 [details]
Simple patch to restore maximized windows maximized
Comment 8 Rafael Fernández López 2008-02-13 03:25:49 UTC
Hmm... and setWindowState(Qt::WindowMaximized); doesn't work ? Just talking 
about the patch itself, don't know if that is even correct in this context.
Comment 9 Armin Berres 2008-02-13 11:03:18 UTC
setWindowState(Qt::WindowMaximized) also doesn't work.
Comment 10 Armin Berres 2008-02-13 11:47:05 UTC
Just to be sure I printed out width() and height() before and after the KWindowSystem::setState(..) call. They were both times (768,334).
Here the ouptut, repeated three times (why?)
----------
KMainWindow::restoreWindowSize (widht,height) before: (768,334)
NETWinInfo::NETWinInfo: constructing object with role 'Client'
NETWinInfo::setState: setting state property (2)
NETWinInfo::setState:   state 305 '_NET_WM_STATE_MAXIMIZED_VERT'
NETWinInfo::setState:   state 328 '_NET_WM_STATE_MAXIMIZED_HORZ'
NET: decrementing NETWinInfoPrivate::ref (0)
NET:    no more references, deleting
KMainWindow::restoreWindowSize after: (768,334)
KMainWindow::restoreWindowSize (widht,height) before: (768,334)
----------
Comment 11 Christoph Pfister 2008-06-12 19:58:15 UTC
Created attachment 25292 [details]
testcase for r819912

recreated the testcase for kdelibs r819912
it might or might not work for you though (when you look at the irreducible
lines you should notice that the issue here is indeed fishy)
Comment 12 Nicolas Bigaouette 2008-07-22 15:34:29 UTC
Patch from #c7 corrected the bad behaviour for Okular and Krusader for KDE 4.0.99
(ArchLinux with KDEMod)
Comment 13 Cyrill Helg 2008-08-20 15:09:14 UTC
I can confirm this bug on kde 4.1 svn. 
Comment 14 Armin Berres 2008-09-04 00:44:44 UTC
So, is anyone working on the issue?
It was brought up on k-c-d some time ago, but it seems as if nothing happened so far. It was a Qt-Bug, right?
Does anyone know if it has been reported to TT^WNokia?
Comment 15 Armin Berres 2008-09-04 00:57:30 UTC
Sorry for the noise. 
Hit enter by accident and assigned the bug to myself...
Comment 16 gdamjan 2008-09-26 21:00:39 UTC
KDE 4.1.2 still has this bug 
Comment 17 Nicolas Bigaouette 2008-11-05 03:08:53 UTC
Still there in 4.1.3
Comment 18 Cyrill Helg 2008-11-05 07:18:18 UTC
This is a qt bug and its fixed in qt 4.5.
Comment 19 Cyrill Helg 2008-11-05 07:21:39 UTC
Oh sorry I messed up with another bug, so ignore my previous message.
Comment 20 Nicolas Bigaouette 2008-11-05 15:54:34 UTC
I was hoping it was fixed :P
Comment 21 Rafael Fernández López 2008-11-05 18:20:26 UTC
Fixed on revision 880489
Comment 22 Nicolas Bigaouette 2008-11-05 18:23:28 UTC
Great! :)
It's sad it did not make it in time for 4.1.3... ;)
Thanx for commiting.
Comment 23 Cyrill Helg 2008-11-05 18:46:11 UTC
Sorry for the noice, but the fix went into kdelibs right?

Thanks in advance

PS: I'm asking because this is worth a recompile! :D
Comment 24 Rafael Fernández López 2008-11-05 18:48:17 UTC
Yes, the fix is on kdelibs (trunk).
Comment 25 Will Stephenson 2008-11-20 11:04:37 UTC
SVN commit 886844 by wstephens:

Backport r880489 to 4.1 
CCBUG:150772


 M  +4 -3      kmainwindow.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=886844