Re: FVWM: Changing titlebar buttons based on window state?

From: Mikhael Goikhman <migo_at_homemail.com>
Date: Fri, 6 Sep 2002 09:39:47 +0000

On 06 Sep 2002 10:41:38 +0200, Dominik Vogt wrote:
>
> On Thu, Sep 05, 2002 at 09:28:39PM -0500, Len Philpot wrote:
> > I have the following defined in my .fvwm2rc :
> >
> > Mouse 0 1 A Menu Window-Ops2 Close
> > Mouse 0 2 A Close
> > Mouse 0 4 A Maximize
> > Mouse 0 6 A Iconify
> >
> > # lightning bolt - system menu
> > ButtonStyle 1 8 35x15_at_1 20x50_at_1 40x50_at_0 30x80_at_1 75x40_at_0 50x40_at_1 75x15_at_0 35x15_at_1
> > # x - Close
> > ButtonStyle 2 17 20x20_at_1 30x20_at_1 50x40_at_1 70x20_at_1 80x20_at_1 80x30_at_0 60x50_at_0 80x70_at_1 80x80_at_0 70x80_at_0 50x60_at_0 30x80_at_0 20x80_at_0 20x70_at_0 40x50_at_1 20x30_at_0 20x20_at_1
> > # downward triangle - minimize
> > ButtonStyle 6 4 50x75_at_1 25x25_at_1 75x25_at_1 50x75_at_0
> > # large square - maximize
> > ButtonStyle 4 5 25x25_at_1 25x75_at_1 75x75_at_0 75x25_at_0 25x25_at_1
> > # small square - restore
> > #ButtonStyle 4 5 40x40_at_1 60x40_at_1 60x60_at_0 40x60_at_0 40x40_at_1
> >
> > (swiped straight from the website and sample files, obviously)
> >
> > What I want to do is use the small square for button 4 if the window is
> > fullscreen and the large square if it's neither fullscreen nor
> > iconified. I feel certain this is in the man pages somewhere, but I've
> > yet to come across it. I have no idea how to approach this.
>
> It's the default on button 2. If you want the same on another
> button you have to tell fvwm about it. Try this:
>
> ButtonStyle 4 - MWMDecorMax
> AddButtonStyle 4 5 25x25_at_1 25x75_at_1 75x75_at_0 75x25_at_0 25x25_at_1

Actually, Len wanted to have different vectors for toggled states.

Here is how to add a new button number 3 that shades a window and looks
differently when shaded or not:

  Style "*" MWMButtons # button relief follows the state

  Style * Button 3 # Button 1, Button 2, Button 3, Button 4, Button 6

  ButtonStyle 3 ActiveUp Vector 8 40x80_at_1 40x50_at_1 20x50_at_1 50x20_at_1 80x50_at_0 60x50_at_0 60x80_at_0 40x80_at_0
  ButtonStyle 3 ActiveDown Vector 8 40x80_at_1 40x50_at_1 20x50_at_1 50x20_at_1 80x50_at_0 60x50_at_0 60x80_at_0 40x80_at_0
  ButtonStyle 3 Inactive Vector 8 40x80_at_1 40x50_at_1 20x50_at_1 50x20_at_1 80x50_at_0 60x50_at_0 60x80_at_0 40x80_at_0
  ButtonStyle 3 ToggledActiveUp Vector 8 40x20_at_1 40x50_at_1 20x50_at_1 50x80_at_1 80x50_at_0 60x50_at_0 60x20_at_0 40x20_at_1
  ButtonStyle 3 ToggledActiveDown Vector 8 40x20_at_1 40x50_at_1 20x50_at_1 50x80_at_1 80x50_at_0 60x50_at_0 60x20_at_0 40x20_at_1
  ButtonStyle 3 ToggledInactive Vector 8 40x20_at_1 40x50_at_1 20x50_at_1 50x80_at_1 80x50_at_0 60x50_at_0 60x20_at_0 40x20_at_1

# I plan to add "Normal" and "Toggled" shortcuts for window states, so it
# would be possible to reduce these 6 lines above to just two in 2.5.4+.
# It is already possible to reduce this to 4 lines in cvs.

  ButtonStyle 3 - MWMDecorShade # MWMDecorMax for the maximizing button

  Mouse 1 3 A WindowShade toggle
  Mouse 2 3 A WindowShade true
  Mouse 3 3 A WindowShade false

> > I'd still like to work on (which may or may not be doable) :
> >
> > * How to make windows resizable by dragging on the borders, in
> > addition to the corner handles (and disabling moving via borders)
>
> Find the function in your config files that defines the action on
> the window borders. You should have something like
>
> Mouse 1 F N <resize command>
> Mouse 1 S N <move command>
>
> Change this to
>
> Mouse 1 FS N <resize command>

Actually this default is in our ConfigFvwmDefaults. I really think this is
a bad default, not very consistent and not very functional. Something like
this would be more consistent and functional:

  Mouse 1 FS A SomeComplexFunctionDoingResize
  Mouse 2 FS A SomeComplexFunctionDoingMove

Try to use "A" instead of "N" whenever is possible, otherwise you end up
with FAQ #0.1.

> > * How to make a window truly maximize, rather than stop a few pixels
> > short of fullscreen;
>
> Not at all. Windows often define their font size and want to be
> resized in multiples of it. The gap is there when the screen size
> isn't a multiple of the font size. Just get used to it.

Maybe it is possible to have an option to keep 2 geometries for a window,
one is the real one and another for decorations, the gap may be filled
with some colorset. But this is complex and probably not very intuitive.

> > a nice touch would be to make it _really_
> > maximize, with no border showing and no movement possible while
> > maximized
>
> There are some commands and styles in 2.5.x that make it possible,
> but I don't have the time to check it right now. I think Mikhael
> already wrote a setup for this.

It is possible to do with 2.4.x too, but the if-else is tricky in 2.4.x
and additionally BorderWidth should be hadcoded and handles are forced:

  DestroyFunc MaximizeFullScreen
  AddToFunc MaximizeFullScreen
  + I Style $n NoTitle, NoHandles, BorderWidth 0
  + I UpdateStyles
  + I WindowId "$w" Maximize true

  DestroyFunc UnmaximizeFullScreen
  AddToFunc UnmaximizeFullScreen
  + I WindowId "$w" Maximize false
  + I Style $n Title, Handles, BorderWidth 5

2.5.x has no such problems (except that individual styles would not hurt):

  DestroyFunc MaximizeFullScreen
  AddToFunc MaximizeFullScreen
  + I ThisWindow (Maximized) Style $n Title, Border
  + I CondCase (NoMatch) Style $n NoTitle, NoBorder
  + I CondCase (NoMatch) Raise
  + I CondCase (NoMatch) UpdateStyles
  + I Maximize

> > * How to get vector buttons to appear in a different color than the
> > titlebar
>
> This should be possible with colour sets, but I'm not sure if
> they work in title buttons. Mikhael?

This is tricky. There is no separate colorset for buttons for now.
In 2.4.1+ vector buttons may use 4 colors, but they are not different than
the ones titlebar uses. These colors are _at_0, @1, @2, @3 for sh, hi, bg, fg
and they are taken from "Style <pattern> Colorset <c>" if it is defined.

It is possible however to combine several tactics to separate colors of
button vectors from anything else by defining separate BorderColorset (to
let vectors and buttons to use separate colorsets) and define TitleStyle
to use different colors than colorset <c>. This colorset <c> is also used
by default in pager, so depending on the needs this may be changed too.

Another solution is to use images for decorations.

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Fri Sep 06 2002 - 04:40:55 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:53 BST