Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Sad Mirek, (or any other volunteer Smile ), 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 Wink

BTW: In GUI_APP_MAIN there is (ide/idewin.cpp:839):
		Ide ide;
		ide.Maximize();
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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Weird Confused 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 #30593 is a reply to message #30566] Tue, 11 January 2011 08:53 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

I tracked it down. Theide receives WM_STATE event, which it properly digests and switches to overlapped mode. So the last question remains: Where the hell does that event come from?? I suspect my desktop environment, that is XFCE.

Honza
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30594 is a reply to message #30593] Tue, 11 January 2011 10:06 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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 Smile
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile

Finally someone who sees the problem Smile 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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
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 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Embarassed I actually meant to say that "the ide.state changes between the LoadFromFile() and first SaveToFile() call". Sorry for confusion Rolling Eyes
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30606 is a reply to message #30605] Tue, 11 January 2011 23:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
OK, looks like everything is nuked after I have applied minimize/maximize patches. Confirming both problems.
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30607 is a reply to message #30606] Tue, 11 January 2011 23:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
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!
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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Confused

Honza
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30621 is a reply to message #30618] Wed, 12 January 2011 21:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
I guess it is not so bad in Ubuntu, it actually tries to move windows to quite inteligent positions. The problem, of course, is that sometimes you want this and sometimes you do not... Smile

But thankfully, now U++ can do both.
Re: [BUG] TheIDE doesn't restore window state correctly on Linux [message #30639 is a reply to message #30566] Thu, 13 January 2011 10:02 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
It's common behavior of *nix window managers, they *do* handle the placement of newly opened windows. Actually there are usually several options/strategies in desktop settings, how the window manager should place new windows on the desktop.

So it's not an defect, but effect. Smile
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 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

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 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

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

SyncState0();


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

Re: [SOLUTION FOUND!] TheIDE doesn't restore window state correctly on Linux [message #32989 is a reply to message #32924] Mon, 27 June 2011 21:52 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
patch applied, thanks.

Mirek
Previous Topic: WhenEnter in GridCtrl not fired
Next Topic: Found solution. On arrayctrl, you have addcolumn, but what about deleting a column
Goto Forum:
  


Current Time: Sun Jun 16 08:55:12 CEST 2024

Total time taken to generate the page: 0.01513 seconds