| [ Return to Bugs & Features | Post Text | Post File | Prev | Next ]
STR #2083
Application: | FLTK Library |
Status: | 5 - New |
Priority: | 1 - Request for Enhancement, e.g. asking for a feature |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Core Library |
Summary: | Add maximize, minimize caps to FL_Window |
Version: | 1.4-feature |
Created By: | fabien |
Assigned To: | Unassigned |
Fix Version: | Unassigned |
Update Notification: | |
Trouble Report Files:
[ Post File ]No files
Trouble Report Comments:
[ Post Text ]
|
#1 | fabien 10:39 Nov 04, 2008 |
| This is a reminder of a recent discussion, so that we don't loose its benefit. It has been agreed many times that it would be worth adding fltk capabilities to : 1 - set the maximize,minimize windows state in a transparent portable way. 2 - Similarly to get the window maximize/minimize state
Here's the proposal that we should at least before an official 1.3 release: /** Maximizes or Unmaximizes the window */ virtual void Fl_Window::maximized(bool on_off); /** Minimizes or restore the window */ virtual void Fl_Window::minimized(bool on_off); /** Get minimized current state */ bool Fl_Window::minimized() const; /** Get maximized current state */ bool Fl_Window::maximized() const;
Also, some greg links and hints to make our task easier: Greg wrote: Here's a post showing how to do it under Microsoft Windows; specifically, see the Is_Maximized(Fl_Window*) function in this posting:
http://fltk.org/newsgroups.php?s1+gfltk.general+v2+T0+Q%22maximize+the+window%2C+icons%22
For X11, I think Mike posted this link describing the list of window manager "hints":
http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html
Sorry, I didn't see any posts suggesting on how to do this in OSX. | |
|
#2 | alvin 12:21 Nov 04, 2008 |
| FWIW, here is how to maximise a window in X:
Note that 'wnd' is a Fl_Window (or derivative thereof):
Window xid = fl_xid(wnd);
XEvent xev; Atom wm_state = XInternAtom(fl_display, "_NET_WM_STATE", False); Atom vmax = XInternAtom(fl_display, "_NET_WM_STATE_MAXIMIZED_VERT", False); Atom hmax = XInternAtom(fl_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
memset(&xev, 0, sizeof(xev)); xev.type = ClientMessage; xev.xclient.window = xid; xev.xclient.message_type = wm_state; xev.xclient.format = 32; xev.xclient.data.l[0] = 2; xev.xclient.data.l[1] = hmax; xev.xclient.data.l[2] = vmax;
XSendEvent(fl_display, DefaultRootWindow(fl_display), False, SubstructureNotifyMask, &xev); | |
|
#3 | greg.ercolano 23:10 Nov 04, 2008 |
| Hmm, one question: why is 'maximized()/minimized()' being suggested instead of 'maximize()/minimize()'?
Seems like they should be 'present tense' instead of past tense..? | |
|
#4 | fabien 00:27 Nov 05, 2008 |
| well, feel free to suggest a correct english name and thanks for doing so :-) I just wanted to keep the naming style as close as possible as what we already use, meaning keeping the exact same method name for get/set operations but it could be maximize() for the set method and maximized for the get method. BTW, if we want to harmonize even more with fltk1 existing Fl_Widget erived methods, we should use int parameters instead of bool, though it should be a bool here. Any suggestions welcome here before we add these functionality.
Fabien | |
|
#5 | AlbrechtS 00:54 Nov 05, 2008 |
| Please note that there is already Fl_Window::iconize(). This seems to be very similar to the proposed minimize() method, at least under Windows. It uses SW_SHOWMINNOACTIVE, which _may_ me better than SW_MINIMIZE.
For the naming: I thought about this, too. Fabiens argument for keeping the same name is good and consistent, but makes a strange "feeling" WRT the english language. Making it "present tense", as Greg suggested, is strange as well for the get methods.
Third possibility (I know, this is a deviation from normal FLTK conventions): minimze(int), maximize(int) for the set methods and is_minimized(), is_maximized() for the get methods (to avoid that single 'd' difference in the names). But I'm okay with any sensible naming.
WRT to bool/int: IMHO we should stay consistent within FLTK 1 and use int. | |
|
#6 | fabien 03:00 Nov 05, 2008 |
| Another increment: even simpler and powerful approach could be to further only 2 methods and one (bitmasked in power of 2) enum:
enum {FL_SHOW_NORMAL=0,FL_SHOW_MAXIMIZED=1, FL_SHOW_MINIMIZED=2}
/** Sets the window current showmode */ virtual void Fl_Window::show_mode(int mode);
/** Gets the current show mode state, not that a window could be minimized and also have the state maximized so that it is being restored this way when uniconized ... */ int Fl_Window::show_mode() const;
We can have all the functionalities enumerated (and more if we want as we could add more options in the enum without breaking compatibility) while keeping only 2 API to maintain, conforming to FLTK1 conventions. | |
|
#7 | greg.ercolano 12:52 Nov 05, 2008 |
| Yes, I'd agree on consistency with what's in FLTK 1.x already when it comes to naming and int return values.
It seems the FLTK API seems to like to use set_xxx() to set something, and xxx() to get it, eg:
widget->set_visible(); // make it visible if ( widget->visible() ) { .. } // check if visible
widget->set_changed(); // change it if ( widget->changed() ) { .. } // get it
widget->set_modal(); // set it if ( modal() ) { .. } // get it
So to be 'consistent', I guess that's what should be used, if that's the doctrine to be followed. I don't think the coding standards cover this:
http://fltk.org/cmp.php
..maybe it should. But that does seem to be the dominating method naming convention used in FLTK. (To find out, I just grepped the FL/*.H files for 'set_' vs. 'is_' and 'ed()'. Lots of hits for set_xxx(), and few at all for is_xxx() and xxxed())
However, I do like the way the suggestions in this STR read:
window->maximize(); // maximize the window if ( window->is_maximized() ) { .. } // check if maximized
Also, the suggestion to use -ed() seems fine for differentiating the 'get' and 'set' methods, as long as the -ed() is only used for 'get', eg:
window->maximize(); // maximize the window if ( window->maximized() ) { .. } // check if maximized
..but again, not many precedents for either of those in FLTK, if any.
Assuming it's even possible to 'get' these minimize/maximize values. I should point out that since these are 'hints' to the window manager, it is possible one can't ask the window manager if the window has been minimized/maximized().
I remember looking at some window manager code in an app that seemed to first 'ask' if eg. minimize() function was available in the window manager, and if not, tried to emulate it with its own code. | |
|
#8 | AlbrechtS 00:27 Aug 19, 2009 |
| According to a recent comment in fltk.general by SebHoll [3] we now have two links with code fragments: The link shown by Fabien above in another notation [1] and that from SebHoll [2].
Obviously the code in [1] has been added to FLTK 2 in svn -r 6150, but I didn't check if it has been changed.
Still missing code for MacOS, though.
--------------------------------------------------------------- [1] http://www.fltk.org/newsgroups.php?gfltk.development+v:5803 [2] http://www.fltk.org/newsgroups.php?gfltk.general+v:26098 [3] http://www.fltk.org/newsgroups.php?gfltk.general+v:29017 | |
[ Return to Bugs & Features | Post Text | Post File ]
|
| |