Home » U++ Library support » TopWindow&PopUp, TrayIcon » Trouble with IsMinimized / IsMaximized on X11
Trouble with IsMinimized / IsMaximized on X11 [message #30065] |
Mon, 06 December 2010 11:18  |
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
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 19:12:31 CEST 2025
Total time taken to generate the page: 0.00931 seconds
|