Hello,
I think that FLTK really should provide a maximize() method for a window.

This is my implementation of it (WIP), it works now for win32, 
and for linux/X11 (with not-acient windows managers)

Any remarks?
If all is fine then I will prepare a .path against current FLTK2 SVN 
(should I make patch for FLTK1 as well?)


Implemented as a method ::maximize() in my class, which is derived from
fltk::Window

Tested on x11/KDE and linux/wine and windows/xp


#ifdef __WIN32__
        #include <fltk/win32.h>
        #include <windows.h>
        #include <windowsx.h>
#elif __linux__
        #include <fltk/x11.h>
        #include <X11/Xlib.h>
#else
        #warning "implement me"
#endif

[...]

void cMainWindow::maximize() {
        #ifdef __WIN32__
                // ShowWindow - 
http://msdn.microsoft.com/en-us/library/ms633548.aspx
                // idea from Edzard Egberts - thanks

                HWND hWnd = fltk::xid(this);     
                UDBG("hWnd = "+STR(hWnd));
                ASSERT(hWnd);
                ShowWindow(hWnd, SW_MAXIMIZE);  

        #elif __linux__
                // coded by Rafał Maj, idea from Måns Rullgård 
http://tinyurl.com/68mvk3

                Display *dpy = xdisplay;

                XEvent xev;
                Atom wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
                Atom maximizeV = XInternAtom(dpy, 
"_NET_WM_STATE_MAXIMIZED_VERT", False);
                Atom maximizeH = XInternAtom(dpy, 
"_NET_WM_STATE_MAXIMIZED_HORZ", False);
                // XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); // that 
would give
true fullscreen

                memset(&xev, 0, sizeof(xev));
                xev.type = ClientMessage;
                xev.xclient.window = fltk::xid(this);
                xev.xclient.message_type = wm_state;
                xev.xclient.format = 32;
                xev.xclient.data.l[0] = 1;
                xev.xclient.data.l[1] = maximizeV;
                xev.xclient.data.l[2] = maximizeH;
                xev.xclient.data.l[3] = 0;
    XSendEvent(xdisplay, RootWindow(xdisplay, xscreen), 0,
                SubstructureNotifyMask|SubstructureRedirectMask, &xev);

                // flush it right away? Also works without this

        #else
                #warning "This code is not implemented yet for this 
target/environment/GUI
system (so it will do nothing.. but you CAN ignore this.)"
        #endif
}

later just call ::maximize()


Hmm it would seem that it must be called some time after the window is shown
fully.

So:

...create window...
window->show(argc,argv);

fltk::wait(1); // fully show the window etc
window->maximize(); // now maximize it!

and the main loop:

bool done=0;
while (!done) {
  fltk::wait(1);
  if (!fltk::Window::first()) done=1;
}
 
-- 
Rafał Maj







_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to