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 » Extra libraries, Code snippets, applications etc. » OS Problems etc., Win32, POSIX, MacOS, FreeBSD, X11 etc » function TopWindow::Maximize does not work in linux.
function TopWindow::Maximize does not work in linux. [message #6105] Mon, 30 October 2006 20:41 Go to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
One first approach to solve this failure could be this.
void TopWindow::Maximize(bool effect)
{
  state = MAXIMIZED;
  // new lines added
  Rect r = Ctrl::GetWorkArea() ;
  SetFrameRect(r) ;
}

The problem to use this is that the window occupies all the screen available but its state is not maximized.

In order to be able to put the window in maximized way it is necessary to use a code like this
static void net_wm_state(const Ctrl* w, bool set, Atom one, Atom two = 0)
{

  XEvent e;
  e.xclient.type = ClientMessage;
  e.xclient.message_type = XAtom("_NET_WM_STATE");
  e.xclient.display = Xdisplay;
  e.xclient.window = w->GetWindow();
  e.xclient.format = 32;
  e.xclient.data.l[0] = set ? 1 : 0;
  e.xclient.data.l[1] = one;
  e.xclient.data.l[2] = two;
  e.xclient.data.l[3] = 0;
  e.xclient.data.l[4] = 0;
  XSendEvent(Xdisplay, Xroot, false, (SubstructureNotifyMask | SubstructureRedirectMask), &e);
}
void TopWindow::Maximize(bool effect)
{
  state = MAXIMIZED;
  net_wm_state(this, effect,
     XAtom("_NET_WM_STATE_MAXIMIZED_HORZ"),
     XAtom("_NET_WM_STATE_MAXIMIZED_VERT") ) ;
}

The bad thing of this code is that it requires that the X11 window exists... Good this is what I deduce nevertheless, because if I call this code in the constructor of my TopWindow does not do anything, but if I call it when the window already is, if that works well.

I had thought that in X11 something like the Windows WM_CREATE message would. I belivied there was a ok place to do the maximize operation, but believe that my little knowledge of X11 do not give for more. Confused

[Updated on: Mon, 30 October 2006 21:45] by Moderator

Report message to a moderator

Re: function TopWindow::Maximize does not work in linux. [message #6107 is a reply to message #6105] Mon, 30 October 2006 22:18 Go to previous messageGo to next message
guido is currently offline  guido
Messages: 169
Registered: April 2006
Experienced Member
Hi Nico!


In TopWindow::SyncCaption() please add:

if (state == MAXIMIZED) {
			wina[n++] = XAtom("_NET_WM_STATE_MAXIMIZED_HORZ");
			wina[n++] = XAtom("_NET_WM_STATE_MAXIMIZED_VERT");
		}


above or below this line:

if(topmost)
	wina[n++] = XAtom("_NET_WM_STATE_ABOVE");



and report if that works.

That would be my guess.

Guido
Re: function TopWindow::Maximize does not work in linux. [message #6112 is a reply to message #6107] Tue, 31 October 2006 09:26 Go to previous messageGo to next message
nicomesas is currently offline  nicomesas
Messages: 104
Registered: September 2006
Location: Barcelona, Spain
Experienced Member
It works perfectly!

Could be added this functionality in the next one release?

Now I do not understand why the Maximize function has a not-used parameter ¿?
Re: function TopWindow::Maximize does not work in linux. [message #6115 is a reply to message #6112] Tue, 31 October 2006 11:39 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Added.

Thanks Guido, without you U++/X11 would not exist...

Mirek
Previous Topic: plugin/sqlite3 case sensitive name on linux
Next Topic: Dynamic library load works rare in Linux
Goto Forum:
  


Current Time: Fri Mar 29 05:56:52 CET 2024

Total time taken to generate the page: 0.02368 seconds