Hello,
I've been toying around with this patch for a while now, which seems
to work. Given that we have PositionPlacement which allows for
placingwindows at a specific location, StartMaximized will start a
window maximized, allowing for the usual arguments per the Maximize
command[1].
For instance:
Style somewindow PositionPlacement 0 50, \
StartMaximized growonlayers $[w.layer] -1 grow grow
Or more simply:
Style somewindow StartMaximized
Comments/suggestions welcome.
-- Thomas Adam
[1] I found it surprising that the Maximize command has no "error"
checking of its inputs, hence: "Maximize 0 50 jlksdjsdljlksdlk"
silently works, regardless. I might fix this at some point.
Index: AUTHORS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/AUTHORS,v
retrieving revision 1.130
diff -u -r1.130 AUTHORS
--- AUTHORS 19 Oct 2008 12:04:12 -0000 1.130
+++ AUTHORS 19 Jan 2009 06:18:20 -0000
@@ -15,6 +15,7 @@
StartShaded style option.
Introduce the command expansion placeholder: $[w.visiblename]
Make style matching honour a window's visible name (c.f. $[w.visiblename])
+StartMaximized style option.
Serge (gentoosiast) Koksharov:
Documentation fixes, bug fixes.
Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.3061
diff -u -r1.3061 ChangeLog
--- ChangeLog 30 Dec 2008 13:32:40 -0000 1.3061
+++ ChangeLog 19 Jan 2009 06:19:11 -0000
@@ -1,3 +1,12 @@
+2008-12-30 Thomas Adam <[email protected]>
+
+ * fvwm/add_window.c (AddWindow):
+ * fvwm/fvwm.h:
+ * fvwm/session.h:
+ * fvwm/style.c:
+ * fvwm/style.h:
+ Allow for StartMaximized as a style option.
+
2008-12-29 Alexandre Julliard <[email protected]>
* fvwm/ewmh_events.c (ewmh_WMStateMaxHoriz):
Index: NEWS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/NEWS,v
retrieving revision 1.767
diff -u -r1.767 NEWS
--- NEWS 30 Dec 2008 13:32:40 -0000 1.767
+++ NEWS 19 Jan 2009 06:19:15 -0000
@@ -7,6 +7,9 @@
* New features:
+ - New style option StartMaximized for maximizing a window when it is
+ initially mapped.
+
- New extended variable
$[w.visiblename]
Index: doc/commands/Style.xml
===================================================================
RCS file: /home/cvs/fvwm/fvwm/doc/commands/Style.xml,v
retrieving revision 1.9
diff -u -r1.9 Style.xml
--- doc/commands/Style.xml 19 Oct 2008 12:04:13 -0000 1.9
+++ doc/commands/Style.xml 19 Jan 2009 06:20:01 -0000
@@ -76,7 +76,7 @@
<emphasis remap='I'>StickyAcrossDesks</emphasis> / <emphasis remap='I'>!StickyAcrossDesks</emphasis>,
<emphasis remap='I'>!StickyStippledTitle</emphasis> / <emphasis remap='I'>StickyStippledTitle</emphasis>,
<emphasis remap='I'>!StickyStippledIconTitle</emphasis> / <emphasis remap='I'>StickyStippledIconTitle</emphasis>,
-<emphasis remap='I'>StartIconic</emphasis> / <emphasis remap='I'>StartNormal</emphasis>,
+<emphasis remap='I'>StartIconic</emphasis> / <emphasis remap='I'>StartMaximized</emphasis> / <emphasis remap='I'>StartNormal</emphasis>,
<emphasis remap='I'>Color</emphasis>, <emphasis remap='I'>ForeColor</emphasis>, <emphasis remap='I'>BackColor</emphasis>, <emphasis remap='I'>Colorset</emphasis>,
<emphasis remap='I'>HilightFore</emphasis>, <emphasis remap='I'>HilightBack</emphasis>, <emphasis remap='I'>HilightColorset</emphasis>,
<emphasis remap='I'>BorderColorset</emphasis>, <emphasis remap='I'>HilightBorderColorset</emphasis>,
@@ -1120,6 +1120,10 @@
<fvwmopt cmd="Style" opt="StartNormal"/>
style.</para>
+<para>If the style <fvwmopt cmd="Style" opt="StartMaximized"/> is used, then
+the window is maximized. Note that this option can accept the same
+arguments as the <fvwmref cmd="Maximize"/> command.</para>
+
<para><fvwmopt cmd="Style" opt="StickyIcon"/>
makes the window sticky when its iconified. It de-iconifies on
top the active desktop.
Index: fvwm/add_window.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/add_window.c,v
retrieving revision 1.398
diff -u -r1.398 add_window.c
--- fvwm/add_window.c 6 Aug 2008 17:55:28 -0000 1.398
+++ fvwm/add_window.c 19 Jan 2009 06:24:21 -0000
@@ -2524,6 +2524,22 @@
/****** window colormap ******/
ReInstallActiveColormap();
+ /* Handle maximization. */
+ if (state_args.do_start_maximized || SDO_START_MAXIMIZED(sflags))
+ {
+ /* Set the context window. */
+ ecc.w.fw = fw;
+ ecc.w.w = FW_W_FRAME(fw);
+ ecc.w.wcontext = C_WINDOW;
+ exc2 = exc_clone_context(
+ exc, &ecc, ECC_FW | ECC_W | ECC_WCONTEXT);
+
+ /* Actually maximize the window. */
+ CMD_Maximize(NULL, exc2,
+ SGET_START_MAXIMIZED_STRING(style));
+ exc_destroy_context(exc2);
+ }
+
/****** ewmh setup *******/
EWMH_WindowInit(fw);
Index: fvwm/fvwm.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.h,v
retrieving revision 1.259
diff -u -r1.259 fvwm.h
--- fvwm/fvwm.h 28 Nov 2008 23:29:27 -0000 1.259
+++ fvwm/fvwm.h 19 Jan 2009 06:25:28 -0000
@@ -532,7 +532,9 @@
unsigned do_start_iconic : 1;
unsigned do_start_lowered : 1;
unsigned do_start_shaded : 1;
+ unsigned do_start_maximized : 1;
unsigned start_shaded_dir : 3;
+ unsigned has_start_maximized_string : 1;
unsigned has_border_width : 1;
unsigned has_color_back : 1;
unsigned has_color_fore : 1;
@@ -679,6 +681,7 @@
pl_penalty_struct pl_penalty;
pl_percent_penalty_struct pl_percent_penalty;
char *pl_position_string;
+ char *start_maximized_string;
style_flags flags;
style_flags flag_default;
style_flags flag_mask;
Index: fvwm/session.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/session.h,v
retrieving revision 1.25
diff -u -r1.25 session.h
--- fvwm/session.h 7 Aug 2007 20:17:43 -0000 1.25
+++ fvwm/session.h 19 Jan 2009 06:26:06 -0000
@@ -51,6 +51,7 @@
unsigned do_shade : 1;
unsigned used_title_dir_for_shading : 1;
unsigned do_max : 1;
+ unsigned do_start_maximized : 1;
} mwtsm_state_args;
Bool MatchWinToSM(
Index: fvwm/style.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.c,v
retrieving revision 1.260
diff -u -r1.260 style.c
--- fvwm/style.c 19 Oct 2008 12:04:13 -0000 1.260
+++ fvwm/style.c 19 Jan 2009 06:26:15 -0000
@@ -706,6 +706,13 @@
*merged_style,
strdup(SGET_PLACEMENT_POSITION_STRING(*add_style)));
}
+ if (add_style->flags.has_start_maximized_string)
+ {
+ SAFEFREE(SGET_START_MAXIMIZED_STRING(*merged_style));
+ SSET_START_MAXIMIZED_STRING(
+ *merged_style,
+ strdup(SGET_START_MAXIMIZED_STRING(*add_style)));
+ }
/* merge the style flags */
/*** ATTENTION:
@@ -3933,6 +3940,25 @@
ps->flag_mask.do_start_shaded = 1;
ps->change_mask.do_start_shaded = 1;
}
+ else if (StrEquals(token, "StartMaximized"))
+ {
+ /* TA: No need to PeekToken() here since we let the
+ * Maximize command handle the tokenising for us.
+ */
+ char *string;
+
+ string = (rest != NULL) ? strdup(rest) : NULL;
+ rest = NULL; /* consume the entire string */
+ SSET_START_MAXIMIZED_STRING(*ps, string);
+
+ ps->flags.do_start_maximized = on;
+ ps->flag_mask.do_start_maximized = 1;
+ ps->change_mask.do_start_maximized = 1;
+
+ ps->flags.has_start_maximized_string = 1;
+ ps->flag_mask.has_start_maximized_string = 1;
+ ps->change_mask.has_start_maximized_string = 1;
+ }
else if (StrEquals(token, "SaveUnder"))
{
ps->flags.do_save_under = on;
Index: fvwm/style.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.h,v
retrieving revision 1.89
diff -u -r1.89 style.h
--- fvwm/style.h 17 Nov 2007 11:47:57 -0000 1.89
+++ fvwm/style.h 19 Jan 2009 06:26:15 -0000
@@ -19,6 +19,8 @@
((sf)->do_start_lowered)
#define SDO_START_SHADED(sf) \
((sf)->do_start_shaded)
+#define SDO_START_MAXIMIZED(sf) \
+ ((sf)->do_start_maximized)
#define SHAS_BORDER_WIDTH(sf) \
((sf)->has_border_width)
#define SHAS_COLOR_BACK(sf) \
@@ -657,6 +659,10 @@
((s).pl_position_string)
#define SSET_PLACEMENT_POSITION_STRING(s,x) \
((s).pl_position_string = (x))
+#define SGET_START_MAXIMIZED_STRING(s) \
+ ((s).start_maximized_string)
+#define SSET_START_MAXIMIZED_STRING(s,x) \
+ ((s).start_maximized_string = (x))
/* function prototypes */
void lookup_style(FvwmWindow *fw, window_style *styles);