Home » U++ Library support » U++ Widgets - General questions or Mixed problems » [BUG] TheIDE doesn't restore window state correctly on Linux
[BUG] TheIDE doesn't restore window state correctly on Linux [message #30566] |
Sat, 08 January 2011 21:25 |
|
Hi,
Some of the recent changes to maximize/minimize handling and/or SerializePlacement() causes that theide is no longer started in maximized state. The problem is, that now it doesn't restore correctly the state after restart, i.e. if I close maximized ide, it opens in normal state next time.
The logs from serialization say (only ide serialization related logs shown here for clarity):// Backup serialization before loading new data from file
TopWindow::SerializePlacement / write
minimized = false, maximized = true
rect = [0, 0] - [0, 0] : (0, 0), overlapped = [0, 0] - [0, 0] : (0, 0)
// LoadFromFile(ide); (ide/idewin.cpp:1003)
TopWindow::SerializePlacement / read
minimized = false, maximized = true
rect = [0, 15] - [1024, 600] : (1024, 585), overlapped = [0, 0] - [0, 0] : (0, 0)
// StoreToFile(ide); (ide/idewin.cpp:1031)
TopWindow::SerializePlacement / write
minimized = false, maximized = false
rect = [8, 32] - [1016, 592] : (1008, 560), overlapped = [0, 0] - [0, 0] : (0, 0)
// StoreToFile(ide); (ide/idewin.cpp:1036)
TopWindow::SerializePlacement / write
minimized = false, maximized = false
rect = [8, 32] - [1016, 592] : (1008, 560), overlapped = [0, 0] - [0, 0] : (0, 0)
As you can see, the StoreToFile() is called twice and between the calls the ide.state changes its value. I tried to track down where the change occures and got into ProcessEvents() call Then I got lost (couldn't find out which event triggers the change). The backtrace at this point was:ProcessEvents () at /home/h/upp-production/uppsrc/CtrlCore/X11Wnd.cpp:362
Process (this=0xbffe4d88) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:199
Setxt (this=0xbffe4d88) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:206
Create (this=0xbffe4d88) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:183
Process (this=0xbffe4d88) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:193
Setxt (this=0xbffe4d88) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:206
Set (this=0xbffe4d88, apos=37, atotal=0) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:221
Step (this=0xbffe4d88, n=1) at /home/h/upp-production/uppsrc/CtrlLib/Progress.cpp:236
SyncRefsDir (dir=0xaf104210 "/home/h/MyApps/Wizard", rel=..., pi=...) at /home/h/upp-production/uppsrc/ide/Browser/TopicBase.cpp:178
SyncRefsDir (dir=0xaf10c518 "/home/h/MyApps", rel=..., pi=...) at /home/h/upp-production/uppsrc/ide/Browser/TopicBase.cpp:198
SyncRefs () at /home/h/upp-production/uppsrc/ide/Browser/TopicBase.cpp:209
SetMain (this=0xbffe58c0, package=...) at /home/h/upp-production/uppsrc/ide/ide.cpp:140
OpenMainPackage (this=0xbffe58c0) at /home/h/upp-production/uppsrc/ide/ide.cpp:172
GuiMainFn_ () at /home/h/upp-production/uppsrc/ide/idewin.cpp:1030
main (argc=1, argv=0xbffff984, envptr=0xbffff98c) at /home/h/upp-production/uppsrc/ide/idewin.cpp:731
I'm afraid that fixing this goes beyond my abilities Mirek, (or any other volunteer ), could you have a look at it? It is not really that much annoying to maximize theide every time, but my desire for perfection suffers
BTW: In GUI_APP_MAIN there is (ide/idewin.cpp:839):The call to Maximize is overwritten later, so it doesn't really matter and could be removed.
Best regards,
Honza
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30591 is a reply to message #30566] |
Mon, 10 January 2011 22:48 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
dolik.rce wrote on Sat, 08 January 2011 15:25 | Hi,
Some of the recent changes to maximize/minimize handling and/or SerializePlacement() causes that theide is no longer started in maximized state. The problem is, that now it doesn't restore correctly the state after restart, i.e. if I close maximized ide, it opens in normal state next time.
The logs from serialization say (only ide serialization related logs shown here for clarity):// Backup serialization before loading new data from file
TopWindow::SerializePlacement / write
minimized = false, maximized = true
rect = [0, 0] - [0, 0] : (0, 0), overlapped = [0, 0] - [0, 0] : (0, 0)
// LoadFromFile(ide); (ide/idewin.cpp:1003)
TopWindow::SerializePlacement / read
minimized = false, maximized = true
rect = [0, 15] - [1024, 600] : (1024, 585), overlapped = [0, 0] - [0, 0] : (0, 0)
// StoreToFile(ide); (ide/idewin.cpp:1031)
TopWindow::SerializePlacement / write
minimized = false, maximized = false
rect = [8, 32] - [1016, 592] : (1008, 560), overlapped = [0, 0] - [0, 0] : (0, 0)
// StoreToFile(ide); (ide/idewin.cpp:1036)
TopWindow::SerializePlacement / write
minimized = false, maximized = false
rect = [8, 32] - [1016, 592] : (1008, 560), overlapped = [0, 0] - [0, 0] : (0, 0)
As you can see, the StoreToFile() is called twice and between the calls the ide.state changes its value.
|
I do not see that...
Mirek
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30592 is a reply to message #30591] |
Mon, 10 January 2011 23:50 |
|
Weird Anyone else having this kind of trouble? If not, then it might be specific to my system (Arch Linux,GCC 4.5.2) in which case I would probably have to do all the work to figure it out...
SerializePlacement() itself works well, I tested it using uppdev/X11minmax. I only see this happen in theide. From where I stopped last time when debugging it looks like theide receives an event changing state, but that should only from user interaction (which I obviously didn't do). I will try to check the logs from ProcessEvents, maybe it'll tell something usefull.
Honza
|
|
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30595 is a reply to message #30594] |
Tue, 11 January 2011 11:44 |
|
unodgs wrote on Tue, 11 January 2011 10:06 | In my desktop (gnome, sometimes kde) upp also doesn't restore maximized state properly. Window is almost maximized - that means it occupies the whole screen with padding 5 pixels and still can be maximized. Strange
|
Finally someone who sees the problem The padding comes from TopwWindow::SerializePlacement(): Rect limit = GetWorkArea();
// ...
#ifdef PLATFORM_X11
Rect fm = windowFrameMargin; //<this returns empty Rect...
if((fm.left|fm.right|fm.top|fm.bottom) == 0)
fm = Rect(8, 32, 8, 8); // ... so this is chosen as safe values
limit.left += fm.left;
limit.right -= fm.right;
limit.top += fm.top;
limit.bottom -= fm.bottom;
#endif
But now I am even more puzzled, since you are using different desktop environments than me. So what else could cause that Mirek doesn't see the problem? The version of X? I am using pretty new one:Xorg -version |
This is a pre-release version of the X server from The X.Org Foundation.
It is not supported in any way.
Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.
Select the "xorg" product for bugs you find in this release.
Before reporting bugs in pre-release versions please check the
latest version in the X.Org Foundation git repository.
See http://wiki.x.org/wiki/GitPage for git access instructions.
X.Org X Server 1.9.3.901 (1.9.4 RC 1)
Release Date: 2011-01-07
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.36-ARCH i686
Current Operating System: Linux mrnous 2.6.37-ARCH #1 SMP PREEMPT Fri Jan 7 17:10:05 UTC 2011 i686
Kernel command line: root=/dev/disk/by-uuid/3d6a2cf7-1a7f-45f8-a6cb-ce2d9e12a03c resume=/dev/sda4 ro
Build Date: 08 January 2011 11:27:31PM
Current version of pixman: 0.20.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
|
Honza
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30600 is a reply to message #30595] |
Tue, 11 January 2011 14:53 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
dolik.rce wrote on Tue, 11 January 2011 05:44 |
But now I am even more puzzled, since you are using different desktop environments than me. So what else could cause that Mirek doesn't see the problem?
|
Ah sorry, this is misunderstanding. I was only commenting to
"As you can see, the StoreToFile() is called twice and between the calls the ide.state changes its value."
Because from the log:
// StoreToFile(ide); (ide/idewin.cpp:1031)
TopWindow::SerializePlacement / write
minimized = false, maximized = false
rect = [8, 32] - [1016, 592] : (1008, 560), overlapped = [0, 0] - [0, 0] : (0, 0)
// StoreToFile(ide); (ide/idewin.cpp:1036)
TopWindow::SerializePlacement / write
minimized = false, maximized = false
rect = [8, 32] - [1016, 592] : (1008, 560), overlapped = [0, 0] - [0, 0] : (0, 0)
I see no differences. I will have yet to test (and hopefully fix) this in Linux.
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30602 is a reply to message #30595] |
Tue, 11 January 2011 15:29 |
|
Quote: | The version of X? I am using pretty new one:
|
I'm also using the newest possible (but stable) version. Maximizing is not the only problem. The best show starts with compiz enabled. Resizing the window causes intensive flickering and restored maximized window is shifted down (I can't see part of the bottom window and I cant do anything about it (move or maximize)).
But the most irritating problem under gome no matter if compiz is enabled or not is debugging. If I click on the debugged window after a short while the parent window (theide) pops up. Can anyone confirm that?
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30605 is a reply to message #30600] |
Tue, 11 January 2011 17:26 |
|
mirek wrote on Tue, 11 January 2011 14:53 |
dolik.rce wrote on Tue, 11 January 2011 05:44 |
But now I am even more puzzled, since you are using different desktop environments than me. So what else could cause that Mirek doesn't see the problem?
|
Ah sorry, this is misunderstanding. I was only commenting to
"As you can see, the StoreToFile() is called twice and between the calls the ide.state changes its value."
| Oups, my mistake I actually meant to say that "the ide.state changes between the LoadFromFile() and first SaveToFile() call". Sorry for confusion
|
|
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30618 is a reply to message #30607] |
Wed, 12 January 2011 21:00 |
|
mirek wrote on Tue, 11 January 2011 23:41 | Well, it looks like X11 tries to reposition windows on its own on create, that is what is causing the mess.
I have tried to fix this by ignoring first set of ConfigureNotify (while waiting for FocusIn), then placing the new position to the window. Ugly hack for ugly system....
Please check!
|
Thanks Mirek,
I can confirm that it now works as expected. I just still wonder why the desktop environment sends such event... Thinking of it now, theide is not the only program that makes problem, evince (PDF viewer) usually starts shifted about half width to the left, off-screen. I suppose this is because xfce tries to position the windows to minimize overlaps (something like primitive tiling). It seems like not really well thought idea if it disrupts otherwise well written programs
Honza
|
|
|
|
|
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #32923 is a reply to message #30639] |
Tue, 21 June 2011 05:09 |
|
Strange. Function void TopWindow::SyncState0() (file TopWinX11.cpp, line 124) need to have opened window.
Because Maximize don't work until window realy not opened.
I use this code to work Maximize function:
void MainWindow::Setup(){
if(splitter<1000 || splitter>9000) sp.SetPos(7700); else sp.SetPos(splitter);
Open();
Ctrl::ProcessEvents();
LoadLocalSettings(); //Load settings from .cfg-file
if (maximized) Maximize();
}
But in this case, filling of window content exposed to user.
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
[Updated on: Tue, 21 June 2011 05:18] Report message to a moderator
|
|
|
Re: [SOLUTION FOUND!] TheIDE doesn't restore window state correctly on Linux [message #32924 is a reply to message #32923] |
Tue, 21 June 2011 05:26 |
|
Solution found! Please apply patch!
File TopWinX11.cpp
svn 3546
function
void TopWindow::Open(Ctrl *owner) (line 235-338)
Near end of function I add Line
result function will be:
void TopWindow::Open(Ctrl *owner)
{
GuiLock __;
if(dokeys && (!GUI_AKD_Conservative() || GetAccessKeysDeep() <= 1))
DistributeAccessKeys();
UsrLogT(3, "OPEN " + Desc(this));
LLOG("OPEN " << Name() << " owner: " << UPP::Name(owner));
IgnoreMouseUp();
bool weplace = owner && center == 1 || center == 2 || !GetRect().IsEmpty();
if(fullscreen)
SetRect(0, 0, Xwidth, Xheight);
else
CenterRect(owner);
LLOG("Open NextRequest " << NextRequest(Xdisplay));
Create(owner, false, false);
xminsize.cx = xmaxsize.cx = Null;
title2.Clear();
if(!weplace) {
LLOG("SyncCaption");
SyncCaption0();
}
LLOG("SyncSizeHints");
size_hints->flags = 0;
SyncSizeHints();
Rect r = GetRect();
size_hints->x = r.left;
size_hints->y = r.top;
size_hints->width = r.Width();
size_hints->height = r.Height();
size_hints->win_gravity = StaticGravity;
size_hints->flags |= PPosition|PSize|PWinGravity;
if(owner) {
ASSERT(owner->IsOpen());
LLOG("XSetTransientForHint");
XSetTransientForHint(Xdisplay, GetWindow(), owner->GetWindow());
}
LLOG("XSetWMNormalHints");
XSetWMNormalHints(Xdisplay, GetWindow(), size_hints);
Atom protocols[2];
protocols[0] = XAtom("WM_DELETE_WINDOW");
protocols[1] = XAtom("WM_TAKE_FOCUS");
LLOG("XSetWMProtocols");
XSetWMProtocols(Xdisplay, GetWindow(), protocols, 2);
String x = GetExeTitle().ToString();
const char *progname = ~x;
class_hint->res_name = (char *)progname;
class_hint->res_class = (char *)progname;
XSetClassHint(Xdisplay, GetWindow(), class_hint);
LLOG("WndShow(" << visible << ")");
WndShow(visible);
if(visible) {
XEvent e;
LLOG("XWindowEvent");
XWindowEvent(Xdisplay, top->window, VisibilityChangeMask, &e);
ignoretakefocus = true;
SetTimeCallback(500, THISBACK(EndIgnoreTakeFocus));
LLOG("SetWndFocus");
SetWndFocus();
for(int i = 0; i < 50; i++) {
// X11 tries to move our window, so ignore the first set of ConfigureNotify
// and move the window into position after FocusIn - but not if we want WM to
// place the window
if(weplace)
while(XCheckTypedWindowEvent(Xdisplay, top->window, ConfigureNotify, &e)) {
if(e.xconfigure.window != top->window)
ProcessEvent(&e);
}
if(XCheckTypedWindowEvent(Xdisplay, top->window, FocusIn, &e)) {
ProcessEvent(&e);
if(e.xfocus.window == top->window)
break;
}
Sleep(10);
}
}
if(weplace) {
WndSetPos0(GetRect());
LLOG("SyncCaption");
SyncCaption0();
}
LLOG(">Open NextRequest " << NextRequest(Xdisplay));
LLOG(">OPENED " << Name());
PlaceFocus();
StateH(OPEN);
Vector<int> fe = GetPropertyInts(top->window, XAtom("_NET_FRAME_EXTENTS"));
if(fe.GetCount() >= 4 &&
fe[0] >= 0 && fe[0] <= 16 && fe[1] >= 0 && fe[1] <= 16 && //fluxbox returns wrong numbers - quick&dirty workaround
fe[2] >= 0 && fe[2] <= 64 && fe[3] >= 0 && fe[3] <= 48)
{
GuiLock __;
windowFrameMargin.left = max(windowFrameMargin.left, fe[0]);
windowFrameMargin.right = max(windowFrameMargin.right, fe[1]);
windowFrameMargin.top = max(windowFrameMargin.top, fe[2]);
windowFrameMargin.bottom = max(windowFrameMargin.bottom, fe[3]);
}
if(IsOpen() && top)
top->owner = owner;
int version = 5;
XChangeProperty(Xdisplay, GetWindow(), XAtom("XdndAware"), XA_ATOM, 32,
0, (byte *)&version, 1);
SyncState0(); // ############ This Added line! ###########
FixIcons();
}
After this correction, function Maximize work perfectly.
And function SerializePlacement(s) fully work.
PS
I'm not shure about place of call SyncState0() may be we must place it a bit early.
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
[Updated on: Tue, 21 June 2011 05:28] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sun Apr 28 23:11:20 CEST 2024
Total time taken to generate the page: 0.04015 seconds
|