From afa8591d50db2d08f1b3ab98584662a312abb705 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 24 Mar 2008 07:47:07 +0100 Subject: [PATCH] Change opacity between 0 and 1 and update validation Signed-off-by: Julien Danjou --- awesomerc.5.txt | 4 ++-- common/configopts.c | 6 ++++-- window.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/awesomerc.5.txt b/awesomerc.5.txt index b07b6d727..e594ecc49 100644 --- a/awesomerc.5.txt +++ b/awesomerc.5.txt @@ -53,10 +53,10 @@ new_become_master:: new_get_focus:: If this is set to true, new windows will get focus. opacity_unfocused:: - If this is set to a float value between 0 and 100, non-focused windows will have this opacity. + If this is set to a float value between 0 and 1, non-focused windows will have this opacity. This requires an external XComposite manager. opacity_focused:: - If this is set to a float value between 0 and 100, focused windows will have this opacity. + If this is set to a float value between 0 and 1, focused windows will have this opacity. This requires an external XComposite manager. resize_hints:: If this is set to true, resize hints given by the window will be respected. diff --git a/common/configopts.c b/common/configopts.c index a0f379913..376d4679c 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -377,7 +377,7 @@ cfg_opt_t rule_opts[] = CFG_STR((char *) "master", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "titlebar", titlebar_opts, CFGF_NONE), CFG_INT((char *) "screen", RULE_NOSCREEN, CFGF_NONE), - CFG_FLOAT((char *) "opacity", -1.0f, CFGF_NONE), + CFG_FLOAT((char *) "opacity", -1, CFGF_NONE), CFG_AWESOME_END() }; cfg_opt_t rules_opts[] = @@ -505,7 +505,6 @@ cfg_new(void) /* Check integers values */ cfg_set_validate_func(cfg, "screen|general|snap", config_validate_unsigned_int); cfg_set_validate_func(cfg, "screen|general|border", config_validate_unsigned_int); - cfg_set_validate_func(cfg, "screen|general|opacity_unfocused", config_validate_unsigned_int); cfg_set_validate_func(cfg, "screen|statusbar|width", config_validate_unsigned_int); cfg_set_validate_func(cfg, "screen|statusbar|height", config_validate_unsigned_int); cfg_set_validate_func(cfg, "screen|statusbar|textbox|width", config_validate_unsigned_int); @@ -518,6 +517,9 @@ cfg_new(void) cfg_set_validate_func(cfg, "screen|general|mwfact_lower_limit", config_validate_zero_one_float); cfg_set_validate_func(cfg, "screen|general|mwfact_upper_limit", config_validate_zero_one_float); cfg_set_validate_func(cfg, "screen|tags|tag|mwfact", config_validate_zero_one_float); + cfg_set_validate_func(cfg, "screen|general|opacity_unfocused", config_validate_zero_one_float); + cfg_set_validate_func(cfg, "screen|general|opacity_focused", config_validate_zero_one_float); + cfg_set_validate_func(cfg, "rules|rule|opacity", config_validate_zero_one_float); return cfg; } diff --git a/window.c b/window.c index 652cedfb3..4bcc30827 100644 --- a/window.c +++ b/window.c @@ -194,9 +194,9 @@ window_settrans(Window win, double opacity) int status; unsigned int real_opacity = 0xffffffff; - if(opacity >= 0 && opacity <= 100) + if(opacity >= 0 && opacity <= 1) { - real_opacity = ((opacity / 100.0) * 0xffffffff); + real_opacity = opacity * 0xffffffff; status = XChangeProperty(globalconf.display, win, XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L);