2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* ---------------------------- included header files ---------------------- */
23 #include "libs/fvwmlib.h"
24 #include "libs/Parse.h"
25 #include "libs/Strings.h"
28 #include "execcontext.h"
32 #include "module_list.h"
33 #include "module_interface.h"
41 /* ---------------------------- local definitions -------------------------- */
43 /* ---------------------------- local macros ------------------------------- */
45 /* ---------------------------- imports ------------------------------------ */
47 /* ---------------------------- included code files ------------------------ */
49 /* ---------------------------- local types -------------------------------- */
51 /* ---------------------------- forward declarations ----------------------- */
53 /* ---------------------------- local variables ---------------------------- */
55 /* ---------------------------- exported variables (globals) --------------- */
57 /* ---------------------------- local functions ---------------------------- */
59 /* ---------------------------- interface functions ------------------------ */
61 /* ---------------------------- builtin commands --------------------------- */
65 * WindowShade -- shades or unshades a window (veliaa@rpi.edu)
67 * Args: 1 -- shade, 2 -- unshade No Arg: toggle
70 void CMD_WindowShade(F_CMD_ARGS
)
72 direction_t shade_dir
;
74 frame_move_resize_mode resize_mode
;
77 frame_move_resize_args mr_args
;
80 Bool do_force_shading
;
82 FvwmWindow
* const fw
= exc
->w
.fw
;
84 if (IS_ICONIFIED(fw
) || IS_EWMH_FULLSCREEN(fw
))
88 token
= PeekToken(action
, &naction
);
89 if (StrEquals("shadeagain", token
))
91 do_force_shading
= True
;
93 token
= PeekToken(action
, &naction
);
97 do_force_shading
= False
;
100 if (StrEquals("Last", token
))
102 /* last given instead of a direction will make
103 * fvwm to reuse the last used shading direction.
104 * A new, nevershaded window will have
105 * USED_TITLE_DIR_FOR_SHADING set (in add_window.c:
106 * setup_window_structure)
109 if (!USED_TITLE_DIR_FOR_SHADING(fw
))
111 shade_dir
= SHADED_DIR(fw
);
115 shade_dir
= DIR_NONE
;
120 /* parse normal direction if last was not given */
121 shade_dir
= gravity_parse_dir_argument(action
, NULL
, -1);
124 if (shade_dir
>= 0 && shade_dir
<= DIR_MASK
)
127 toggle
= (!IS_SHADED(fw
) || SHADED_DIR(fw
) != shade_dir
);
132 toggle
= ParseToggleArgument(action
, NULL
, -1, 0);
134 GetIntegerArguments(action
, NULL
, &toggle
, 1) > 0)
140 else if (toggle
== 2)
151 toggle
= !(IS_SHADED(fw
));
153 if (!IS_SHADED(fw
) && toggle
== 1)
155 shade_dir
= GET_TITLE_DIR(fw
);
157 else if (IS_SHADED(fw
) && toggle
== 0)
159 shade_dir
= SHADED_DIR(fw
);
166 if (!IS_SHADED(fw
) && toggle
== 0)
171 if (IS_SHADED(fw
) && toggle
== 1)
173 if (has_dir
== False
)
178 else if (do_force_shading
== False
)
182 else if (shade_dir
== SHADED_DIR(fw
))
190 SET_USED_TITLE_DIR_FOR_SHADING(fw
, !has_dir
);
192 /* draw the animation */
193 start_g
= fw
->g
.frame
;
194 get_unshaded_geometry(fw
, &end_g
);
197 get_shaded_geometry_with_dir(fw
, &end_g
, &end_g
, shade_dir
);
199 resize_mode
= (DO_SHRINK_WINDOWSHADE(fw
)) ?
200 FRAME_MR_SHRINK
: FRAME_MR_SCROLL
;
201 mr_args
= frame_create_move_resize_args(
202 fw
, resize_mode
, &start_g
, &end_g
, fw
->shade_anim_steps
,
204 frame_move_resize(fw
, mr_args
);
205 /* Set the new shade value before destroying the args but after the
207 SET_SHADED(fw
, toggle
);
210 SET_SHADED_DIR(fw
, shade_dir
);
212 frame_free_move_resize_args(fw
, mr_args
);
213 border_draw_decorations(
214 fw
, PART_TITLEBAR
, (fw
== get_focus_window()) ? True
: False
,
215 0, CLEAR_BUTTONS
, NULL
, NULL
);
216 /* update hints and inform modules */
217 BroadcastConfig(M_CONFIGURE_WINDOW
, fw
);
219 (toggle
== 1) ? M_WINDOWSHADE
: M_DEWINDOWSHADE
, 3,
220 (long)FW_W(fw
), (long)FW_W_FRAME(fw
), (unsigned long)fw
);
221 FlushAllMessageQueues();
223 EWMH_SetWMState(fw
, False
);
225 GNOME_SetWinArea(fw
);
230 /* set the number or size of shade animation steps, N => steps, Np => pixels */
231 void CMD_WindowShadeAnimate(F_CMD_ARGS
)
240 ERR
, "CMD_WindowShadeAnimate",
241 "The WindowShadeAnimate command is obsolete. "
242 "Please use 'Style * WindowShadeSteps %s' instead.", action
);
243 buf
= safemalloc(strlen(action
) + 32);
244 sprintf(buf
, "* WindowShadeSteps %s", action
);
246 CMD_Style(F_PASS_ARGS
);