Re: [dwm] Master window width in pixels, not percent?

From: Anselm R. Garbe <arg_AT_10kloc.org>
Date: Mon, 28 Aug 2006 12:53:29 +0200

On Mon, Aug 28, 2006 at 01:48:01PM +0300, Ville Koskinen wrote:
> > In my eyes you don't need to introduce those defines, if you
> > know that MASTERW is a percent value, you can do:
> >
> > #define MASTERW ((<PIXEL> * 100) / sw)
> >
> > replacing <PIXEL> with the pixels you want to supply.
>
> Now that's a neat solution. I don't know how GCC optimizes that, though,
> i.e. if it notices that 100 and sw cancel themselves out in the final
> expression. If it doesn't, the end result might be inaccurate, as we are
> dealing with integer math... Okay, losing or gaining a couple of pixels
> due to rounding is not a big deal, as this isn't a nuclear power plant
> simulation. :)
>
> I'll hack along and try to figure out a better way to accomplish the
> 80-character terminals.

If it isn't precise enough use:

#define MASTERW ((float)(<PIXEL> * 100) / (float)sw)

Maybe the same should be done to main.c as well where mw is
calculated.

Regards,

-- 
 Anselm R. Garbe  ><><  www.ebrag.de  ><><  GPG key: 0D73F361
Received on Mon Aug 28 2006 - 12:53:29 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:30:37 UTC