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 » TopWindow&PopUp, TrayIcon » Trouble with IsMinimized / IsMaximized on X11
icon5.gif  Trouble with IsMinimized / IsMaximized on X11 [message #30065] Mon, 06 December 2010 11:18 Go to next message
oan1971 is currently offline  oan1971
Messages: 7
Registered: April 2010
Promising Member
The window state retrieval with TopWindow::IsMinimized / TopWindow::IsMaximized does not seem to work on X11.

When closing the TopWindow of the following program I always get the log entry "is_minimized: false, is_maximized: false" no matter if the window is minimized or maximized.

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class MinMaxTest : public TopWindow
{
public:
	typedef TopWindow BASECLASS;
	
	MinMaxTest()
	{
		Sizeable().MinimizeBox().MaximizeBox();
	}
	
	virtual void Close()
	{
		const bool is_minimized = IsMinimized();
		const bool is_maximized = IsMaximized();
		LOG("is_minimized: " << is_minimized << ", is_maximized: " << is_maximized);
		BASECLASS::Close();
	}
};

GUI_APP_MAIN
{
	MinMaxTest().Run();
}


The reason seems to be that TopWindow::state is updated on window state changes only for Win32. On X11 the corresponding code seems to be missing.

I don't know much about X11, but from various web resource I gather that something like the following code could be added to the if clause in TopWindow::EventProc in TopWinX11.cpp to detect a minimized / maximized window state:

else if(event->type == PropertyNotify) {
	if(event->xproperty.atom == XAtom("_NET_WM_STATE")) {
		bool minimized = false;
		bool maximizedhorz = false;
		bool maximizedvert = false;
		Atom type;
		int format;
		ulong numitems, bytesafter;
		byte * properties = 0;
		XGetWindowProperty(Xdisplay, event->xany.window, XAtom("_NET_WM_STATE"), 0, LONG_MAX,
			false, AnyPropertyType, &type, &format, &numitems, &bytesafter, &properties);
		if(properties && (format == 32)) {
			for(int i = 0; i < numitems; ++i) {
				const Atom prop = (reinterpret_cast<ulong *>(properties))[i];
				if (prop == XAtom("_NET_WM_STATE_MAXIMIZED_HORZ"))
					maximizedhorz = true;
				if (prop == XAtom("_NET_WM_STATE_MAXIMIZED_VERT"))
					maximizedvert = true;
				if (prop == XAtom("_NET_WM_STATE_HIDDEN"))
					minimized = true;
			}
		}
		XFree(properties);
		if(minimized)
			state = MINIMIZED;
		else if(maximizedhorz && maximizedvert)
			state = MAXIMIZED;
		else state = OVERLAPPED;
	}
}


Thanks and best regards,
Oliver


910eb20c14e026a87ffb2b0d38b9ddb7

[Updated on: Mon, 06 December 2010 11:38]

Report message to a moderator

Re: Trouble with IsMinimized / IsMaximized on X11 [message #30395 is a reply to message #30065] Mon, 27 December 2010 18:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, patch applied (after a bit of refactoring).

Mirek
Re: Trouble with IsMinimized / IsMaximized on X11 [message #30409 is a reply to message #30395] Wed, 29 December 2010 10:33 Go to previous message
oan1971 is currently offline  oan1971
Messages: 7
Registered: April 2010
Promising Member
That's really great. Thanks a lot!

Oliver


910eb20c14e026a87ffb2b0d38b9ddb7
Previous Topic: PROPOSAL: PopUp Example / Test
Next Topic: [FEATURE] Setting TopWindow to urgent/flashing state
Goto Forum:
  


Current Time: Tue Apr 16 18:52:41 CEST 2024

Total time taken to generate the page: 0.01922 seconds