@ -96,10 +96,7 @@ Atom class_atom;
Atom win_type_atom ;
Atom win_type_atom ;
Atom win_type [ NUM_WINTYPES ] ;
Atom win_type [ NUM_WINTYPES ] ;
// Window type settings
unsigned long fade_time ;
double win_type_opacity [ NUM_WINTYPES ] ;
Bool win_type_shadow [ NUM_WINTYPES ] ;
Bool win_type_fade [ NUM_WINTYPES ] ;
/**
/**
* Macros
* Macros
@ -112,7 +109,7 @@ Bool win_type_fade[NUM_WINTYPES];
* Options
* Options
*/
*/
static options_t opt ion s = {
static options_t opt s = {
. display = NULL ,
. display = NULL ,
. shadow_radius = 12 ,
. shadow_radius = 12 ,
. shadow_offset_x = - 15 ,
. shadow_offset_x = - 15 ,
@ -121,7 +118,6 @@ static options_t options = {
. fade_in_step = 0.028 * OPAQUE ,
. fade_in_step = 0.028 * OPAQUE ,
. fade_out_step = 0.03 * OPAQUE ,
. fade_out_step = 0.03 * OPAQUE ,
. fade_delta = 10 ,
. fade_delta = 10 ,
. fade_time = 0 ,
. fade_trans = False ,
. fade_trans = False ,
. clear_shadow = False ,
. clear_shadow = False ,
. inactive_opacity = 0 ,
. inactive_opacity = 0 ,
@ -129,20 +125,18 @@ static options_t options = {
. frame_opacity = 0.0 ,
. frame_opacity = 0.0 ,
. inactive_dim = 0.0 ,
. inactive_dim = 0.0 ,
. mark_wmwin_focused = False ,
. mark_wmwin_focused = False ,
. track_focus = False ,
. track_wdata = False ,
. shadow_blacklist = NULL ,
. shadow_blacklist = NULL ,
. fade_blacklist = NULL ,
. fade_blacklist = NULL ,
. fork_after_register = False ,
. fork_after_register = False ,
. shadow_red = 0.0 ,
. shadow_red = 0.0 ,
. shadow_green = 0.0 ,
. shadow_green = 0.0 ,
. shadow_blue = 0.0 ,
. shadow_blue = 0.0 ,
. wintype_opacity = { 0.0 } ,
. wintype_shadow = { False } ,
. wintype_fade = { False } ,
. synchronize = False ,
. synchronize = False ,
. shadow_enable = 0 ,
. track_focus = False ,
. fading_enable = 0 ,
. track_wdata = False ,
. no_dock_shadow = False ,
. no_dnd_shadow = False ,
. menu_opacity = 1.0
} ;
} ;
/**
/**
@ -171,7 +165,7 @@ get_time_in_milliseconds() {
*/
*/
static int
static int
fade_timeout ( void ) {
fade_timeout ( void ) {
int diff = opt ion s. fade_delta - get_time_in_milliseconds ( ) + options . fade_time ;
int diff = opt s. fade_delta - get_time_in_milliseconds ( ) + fade_time ;
if ( diff < 0 )
if ( diff < 0 )
diff = 0 ;
diff = 0 ;
@ -200,11 +194,11 @@ run_fade(Display *dpy, win *w, unsigned steps) {
// calculations
// calculations
if ( w - > opacity < w - > opacity_tgt )
if ( w - > opacity < w - > opacity_tgt )
w - > opacity = normalize_d_range (
w - > opacity = normalize_d_range (
( double ) w - > opacity + ( double ) opt ion s. fade_in_step * steps ,
( double ) w - > opacity + ( double ) opt s. fade_in_step * steps ,
0.0 , w - > opacity_tgt ) ;
0.0 , w - > opacity_tgt ) ;
else
else
w - > opacity = normalize_d_range (
w - > opacity = normalize_d_range (
( double ) w - > opacity - ( double ) opt ion s. fade_out_step * steps ,
( double ) w - > opacity - ( double ) opt s. fade_out_step * steps ,
w - > opacity_tgt , OPAQUE ) ;
w - > opacity_tgt , OPAQUE ) ;
}
}
@ -420,12 +414,12 @@ make_shadow(Display *dpy, double opacity,
* center ( fill the complete data array )
* center ( fill the complete data array )
*/
*/
// If options. clear_shadow is enabled and the border & corner shadow (which
// If clear_shadow is enabled and the border & corner shadow (which
// later will be filled) could entirely cover the area of the shadow
// later will be filled) could entirely cover the area of the shadow
// that will be displayed, do not bother filling other pixels. If it
// that will be displayed, do not bother filling other pixels. If it
// can't, we must fill the other pixels here.
// can't, we must fill the other pixels here.
if ( ! ( opt ion s. clear_shadow & & opt ion s. shadow_offset_x < = 0 & & opt ion s. shadow_offset_x > = - cgsize
if ( ! ( opt s. clear_shadow & & opt s. shadow_offset_x < = 0 & & opt s. shadow_offset_x > = - cgsize
& & opt ion s. shadow_offset_y < = 0 & & opt ion s. shadow_offset_y > = - cgsize ) ) {
& & opt s. shadow_offset_y < = 0 & & opt s. shadow_offset_y > = - cgsize ) ) {
if ( cgsize > 0 ) {
if ( cgsize > 0 ) {
d = shadow_top [ opacity_int * ( cgsize + 1 ) + cgsize ] ;
d = shadow_top [ opacity_int * ( cgsize + 1 ) + cgsize ] ;
} else {
} else {
@ -496,14 +490,14 @@ make_shadow(Display *dpy, double opacity,
}
}
}
}
if ( opt ion s. clear_shadow ) {
if ( opt s. clear_shadow ) {
// Clear the region in the shadow that the window would cover based
// Clear the region in the shadow that the window would cover based
// on shadow_offset_{x,y} user provides
// on shadow_offset_{x,y} user provides
int xstart = normalize_i_range ( - ( int ) opt ion s. shadow_offset_x , 0 , swidth ) ;
int xstart = normalize_i_range ( - ( int ) opt s. shadow_offset_x , 0 , swidth ) ;
int xrange = normalize_i_range ( width - ( int ) opt ion s. shadow_offset_x ,
int xrange = normalize_i_range ( width - ( int ) opt s. shadow_offset_x ,
0 , swidth ) - xstart ;
0 , swidth ) - xstart ;
int ystart = normalize_i_range ( - ( int ) opt ion s. shadow_offset_y , 0 , sheight ) ;
int ystart = normalize_i_range ( - ( int ) opt s. shadow_offset_y , 0 , sheight ) ;
int yend = normalize_i_range ( height - ( int ) opt ion s. shadow_offset_y ,
int yend = normalize_i_range ( height - ( int ) opt s. shadow_offset_y ,
0 , sheight ) ;
0 , sheight ) ;
int y ;
int y ;
@ -871,11 +865,11 @@ determine_evmask(Display *dpy, Window wid, win_evmode_t mode) {
if ( WIN_EVMODE_FRAME = = mode | | find_win ( dpy , wid ) ) {
if ( WIN_EVMODE_FRAME = = mode | | find_win ( dpy , wid ) ) {
evmask | = PropertyChangeMask ;
evmask | = PropertyChangeMask ;
if ( opt ion s. track_focus ) evmask | = FocusChangeMask ;
if ( opt s. track_focus ) evmask | = FocusChangeMask ;
}
}
if ( WIN_EVMODE_CLIENT = = mode | | find_toplevel ( dpy , wid ) ) {
if ( WIN_EVMODE_CLIENT = = mode | | find_toplevel ( dpy , wid ) ) {
if ( opt ion s. frame_opacity | | opt ion s. track_wdata )
if ( opt s. frame_opacity | | opt s. track_wdata )
evmask | = PropertyChangeMask ;
evmask | = PropertyChangeMask ;
}
}
@ -1177,10 +1171,10 @@ paint_preprocess(Display *dpy, win *list) {
// Sounds like the timeout in poll() frequently does not work
// Sounds like the timeout in poll() frequently does not work
// accurately, asking it to wait to 20ms, and often it would wait for
// accurately, asking it to wait to 20ms, and often it would wait for
// 19ms, so the step value has to be rounded.
// 19ms, so the step value has to be rounded.
unsigned steps = roundl ( ( double ) ( get_time_in_milliseconds ( ) - options. fade_time) / opt ion s. fade_delta ) ;
unsigned steps = roundl ( ( double ) ( get_time_in_milliseconds ( ) - fade_time) / opt s. fade_delta ) ;
// Reset options. fade_time
// Reset fade_time
options. fade_time = get_time_in_milliseconds ( ) ;
fade_time = get_time_in_milliseconds ( ) ;
for ( w = list ; w ; w = next ) {
for ( w = list ; w ; w = next ) {
// In case calling the fade callback function destroys this window
// In case calling the fade callback function destroys this window
@ -1255,9 +1249,9 @@ paint_preprocess(Display *dpy, win *list) {
w - > opacity_cur = w - > opacity ;
w - > opacity_cur = w - > opacity ;
}
}
// Calculate options. frame_opacity
// Calculate frame_opacity
if ( opt ion s. frame_opacity & & 1.0 ! = opt ion s. frame_opacity & & w - > top_width )
if ( opt s. frame_opacity & & 1.0 ! = opt s. frame_opacity & & w - > top_width )
w - > frame_opacity = get_opacity_percent ( dpy , w ) * opt ion s. frame_opacity ;
w - > frame_opacity = get_opacity_percent ( dpy , w ) * opt s. frame_opacity ;
else
else
w - > frame_opacity = 0.0 ;
w - > frame_opacity = 0.0 ;
@ -1273,9 +1267,9 @@ paint_preprocess(Display *dpy, win *list) {
// Calculate shadow opacity
// Calculate shadow opacity
if ( w - > frame_opacity )
if ( w - > frame_opacity )
w - > shadow_opacity = opt ion s. shadow_opacity * w - > frame_opacity ;
w - > shadow_opacity = opt s. shadow_opacity * w - > frame_opacity ;
else
else
w - > shadow_opacity = opt ion s. shadow_opacity * get_opacity_percent ( dpy , w ) ;
w - > shadow_opacity = opt s. shadow_opacity * get_opacity_percent ( dpy , w ) ;
// Rebuild shadow_pict if necessary
// Rebuild shadow_pict if necessary
if ( w - > flags & WFLAG_SIZE_CHANGE )
if ( w - > flags & WFLAG_SIZE_CHANGE )
@ -1561,7 +1555,7 @@ map_win(Display *dpy, Window id,
mark_client_win ( dpy , w , cw ) ;
mark_client_win ( dpy , w , cw ) ;
}
}
}
}
else if ( opt ion s. frame_opacity ) {
else if ( opt s. frame_opacity ) {
// Refetch frame extents just in case it changes when the window is
// Refetch frame extents just in case it changes when the window is
// unmapped
// unmapped
get_frame_extents ( dpy , w , w - > client_win ) ;
get_frame_extents ( dpy , w , w - > client_win ) ;
@ -1576,7 +1570,7 @@ map_win(Display *dpy, Window id,
# endif
# endif
// Get window name and class if we are tracking them
// Get window name and class if we are tracking them
if ( opt ion s. track_wdata ) {
if ( opt s. track_wdata ) {
win_get_name ( dpy , w ) ;
win_get_name ( dpy , w ) ;
win_get_class ( dpy , w ) ;
win_get_class ( dpy , w ) ;
}
}
@ -1587,11 +1581,11 @@ map_win(Display *dpy, Window id,
* XSelectInput ( ) is called too late . We have to recheck the focused
* XSelectInput ( ) is called too late . We have to recheck the focused
* window here .
* window here .
*/
*/
if ( opt ion s. track_focus ) {
if ( opt s. track_focus ) {
recheck_focus ( dpy ) ;
recheck_focus ( dpy ) ;
// Consider a window without client window a WM window and mark it
// Consider a window without client window a WM window and mark it
// focused if options. mark_wmwin_focused is on
// focused if mark_wmwin_focused is on
if ( opt ion s. mark_wmwin_focused & & ! w - > client_win )
if ( opt s. mark_wmwin_focused & & ! w - > client_win )
w - > focused = True ;
w - > focused = True ;
}
}
@ -1726,17 +1720,17 @@ determine_mode(Display *dpy, win *w) {
/**
/**
* Calculate and set the opacity of a window .
* Calculate and set the opacity of a window .
*
*
* If window is inactive and options. inactive_opacity_override is set , the
* If window is inactive and inactive_opacity_override is set , the
* priority is : ( Simulates the old behavior )
* priority is : ( Simulates the old behavior )
*
*
* options. inactive_opacity > _NET_WM_WINDOW_OPACITY ( if not opaque )
* inactive_opacity > _NET_WM_WINDOW_OPACITY ( if not opaque )
* > window type default opacity
* > window type default opacity
*
*
* Otherwise :
* Otherwise :
*
*
* _NET_WM_WINDOW_OPACITY ( if not opaque )
* _NET_WM_WINDOW_OPACITY ( if not opaque )
* > window type default opacity ( if not opaque )
* > window type default opacity ( if not opaque )
* > options. inactive_opacity
* > inactive_opacity
*
*
* @ param dpy X display to use
* @ param dpy X display to use
* @ param w struct _win object representing the window
* @ param w struct _win object representing the window
@ -1759,15 +1753,15 @@ calc_opacity(Display *dpy, win *w, Bool refetch_prop) {
}
}
if ( OPAQUE = = ( opacity = w - > opacity_prop ) ) {
if ( OPAQUE = = ( opacity = w - > opacity_prop ) ) {
if ( 1.0 ! = win_ type_opacity[ w - > window_type ] ) {
if ( 1.0 ! = opts. wintype_opacity[ w - > window_type ] ) {
opacity = win_ type_opacity[ w - > window_type ] * OPAQUE ;
opacity = opts. wintype_opacity[ w - > window_type ] * OPAQUE ;
}
}
}
}
// Respect options. inactive_opacity in some cases
// Respect inactive_opacity in some cases
if ( opt ion s. inactive_opacity & & is_normal_win ( w ) & & False = = w - > focused
if ( opt s. inactive_opacity & & is_normal_win ( w ) & & False = = w - > focused
& & ( OPAQUE = = opacity | | opt ion s. inactive_opacity_override ) ) {
& & ( OPAQUE = = opacity | | opt s. inactive_opacity_override ) ) {
opacity = opt ion s. inactive_opacity ;
opacity = opt s. inactive_opacity ;
}
}
w - > opacity_tgt = opacity ;
w - > opacity_tgt = opacity ;
@ -1777,7 +1771,7 @@ static void
calc_dim ( Display * dpy , win * w ) {
calc_dim ( Display * dpy , win * w ) {
Bool dim ;
Bool dim ;
if ( opt ion s. inactive_dim & & is_normal_win ( w ) & & ! ( w - > focused ) ) {
if ( opt s. inactive_dim & & is_normal_win ( w ) & & ! ( w - > focused ) ) {
dim = True ;
dim = True ;
} else {
} else {
dim = False ;
dim = False ;
@ -1794,7 +1788,7 @@ calc_dim(Display *dpy, win *w) {
*/
*/
static void
static void
determine_fade ( Display * dpy , win * w ) {
determine_fade ( Display * dpy , win * w ) {
w - > fade = win_ type_fade[ w - > window_type ] ;
w - > fade = opts. wintype_fade[ w - > window_type ] ;
}
}
/**
/**
@ -1805,8 +1799,8 @@ static void
determine_shadow ( Display * dpy , win * w ) {
determine_shadow ( Display * dpy , win * w ) {
Bool shadow_old = w - > shadow ;
Bool shadow_old = w - > shadow ;
w - > shadow = ( win_ type_shadow[ w - > window_type ]
w - > shadow = ( opts. wintype_shadow[ w - > window_type ]
& & ! win_match ( w , opt ion s. shadow_blacklist , & w - > cache_sblst ) ) ;
& & ! win_match ( w , opt s. shadow_blacklist , & w - > cache_sblst ) ) ;
// Window extents need update on shadow state change
// Window extents need update on shadow state change
if ( w - > shadow ! = shadow_old ) {
if ( w - > shadow ! = shadow_old ) {
@ -1843,8 +1837,8 @@ calc_win_size(Display *dpy, win *w) {
*/
*/
static void
static void
calc_shadow_geometry ( Display * dpy , win * w ) {
calc_shadow_geometry ( Display * dpy , win * w ) {
w - > shadow_dx = opt ion s. shadow_offset_x ;
w - > shadow_dx = opt s. shadow_offset_x ;
w - > shadow_dy = opt ion s. shadow_offset_y ;
w - > shadow_dy = opt s. shadow_offset_y ;
w - > shadow_width = w - > widthb + gaussian_map - > size ;
w - > shadow_width = w - > widthb + gaussian_map - > size ;
w - > shadow_height = w - > heightb + gaussian_map - > size ;
w - > shadow_height = w - > heightb + gaussian_map - > size ;
}
}
@ -1862,7 +1856,7 @@ mark_client_win(Display *dpy, win *w, Window client) {
// Get the frame width and monitor further frame width changes on client
// Get the frame width and monitor further frame width changes on client
// window if necessary
// window if necessary
if ( opt ion s. frame_opacity ) {
if ( opt s. frame_opacity ) {
get_frame_extents ( dpy , w , client ) ;
get_frame_extents ( dpy , w , client ) ;
}
}
XSelectInput ( dpy , client , determine_evmask ( dpy , client , WIN_EVMODE_CLIENT ) ) ;
XSelectInput ( dpy , client , determine_evmask ( dpy , client , WIN_EVMODE_CLIENT ) ) ;
@ -2199,9 +2193,9 @@ damage_win(Display *dpy, XDamageNotifyEvent *de) {
& & w - > damage_bounds . y < = 0
& & w - > damage_bounds . y < = 0
& & w - > a . width < = w - > damage_bounds . x + w - > damage_bounds . width
& & w - > a . width < = w - > damage_bounds . x + w - > damage_bounds . width
& & w - > a . height < = w - > damage_bounds . y + w - > damage_bounds . height ) {
& & w - > a . height < = w - > damage_bounds . y + w - > damage_bounds . height ) {
if ( win_ type_fade[ w - > window_type ] ) {
if ( opts. wintype_fade[ w - > window_type ] ) {
set_fade ( dpy , w , 0 , get_opacity_percent ( dpy , w ) ,
set_fade ( dpy , w , 0 , get_opacity_percent ( dpy , w ) ,
opt ion s. fade_in_step , 0 , True , True ) ;
opt s. fade_in_step , 0 , True , True ) ;
}
}
w - > usable = True ;
w - > usable = True ;
}
}
@ -2686,7 +2680,7 @@ ev_property_notify(XPropertyEvent *ev) {
}
}
// If frame extents property changes
// If frame extents property changes
if ( opt ion s. frame_opacity & & ev - > atom = = extents_atom ) {
if ( opt s. frame_opacity & & ev - > atom = = extents_atom ) {
win * w = find_toplevel ( dpy , ev - > window ) ;
win * w = find_toplevel ( dpy , ev - > window ) ;
if ( w ) {
if ( w ) {
get_frame_extents ( dpy , w , ev - > window ) ;
get_frame_extents ( dpy , w , ev - > window ) ;
@ -2696,7 +2690,7 @@ ev_property_notify(XPropertyEvent *ev) {
}
}
// If name changes
// If name changes
if ( opt ion s. track_wdata
if ( opt s. track_wdata
& & ( name_atom = = ev - > atom | | name_ewmh_atom = = ev - > atom ) ) {
& & ( name_atom = = ev - > atom | | name_ewmh_atom = = ev - > atom ) ) {
win * w = find_toplevel ( dpy , ev - > window ) ;
win * w = find_toplevel ( dpy , ev - > window ) ;
if ( w & & 1 = = win_get_name ( dpy , w ) )
if ( w & & 1 = = win_get_name ( dpy , w ) )
@ -2704,7 +2698,7 @@ ev_property_notify(XPropertyEvent *ev) {
}
}
// If class changes
// If class changes
if ( opt ion s. track_wdata & & class_atom = = ev - > atom ) {
if ( opt s. track_wdata & & class_atom = = ev - > atom ) {
win * w = find_toplevel ( dpy , ev - > window ) ;
win * w = find_toplevel ( dpy , ev - > window ) ;
if ( w ) {
if ( w ) {
win_get_class ( dpy , w ) ;
win_get_class ( dpy , w ) ;
@ -3051,7 +3045,7 @@ open_config_file(char *cpath, char **ppath) {
* Parse a configuration file from default location .
* Parse a configuration file from default location .
*/
*/
static void
static void
parse_config ( char * cpath ) {
parse_config ( char * cpath , struct options_tmp * pcfgtmp ) {
char * path = NULL , * parent = NULL ;
char * path = NULL , * parent = NULL ;
FILE * f ;
FILE * f ;
config_t cfg ;
config_t cfg ;
@ -3084,63 +3078,55 @@ parse_config(char *cpath) {
// Get options from the configuration file. We don't do range checking
// Get options from the configuration file. We don't do range checking
// right now. It will be done later
// right now. It will be done later
// -D ( options. fade_delta)
// -D ( fade_delta)
if ( config_lookup_int ( & cfg , " fade-delta " , & ival ) )
if ( config_lookup_int ( & cfg , " fade-delta " , & ival ) )
opt ion s. fade_delta = ival ;
opt s. fade_delta = ival ;
// -I ( options. fade_in_step)
// -I ( fade_in_step)
if ( config_lookup_float ( & cfg , " fade-in-step " , & dval ) )
if ( config_lookup_float ( & cfg , " fade-in-step " , & dval ) )
opt ion s. fade_in_step = normalize_d ( dval ) * OPAQUE ;
opt s. fade_in_step = normalize_d ( dval ) * OPAQUE ;
// -O ( options. fade_out_step)
// -O ( fade_out_step)
if ( config_lookup_float ( & cfg , " fade-out-step " , & dval ) )
if ( config_lookup_float ( & cfg , " fade-out-step " , & dval ) )
opt ion s. fade_out_step = normalize_d ( dval ) * OPAQUE ;
opt s. fade_out_step = normalize_d ( dval ) * OPAQUE ;
// -r ( options. shadow_radius)
// -r ( shadow_radius)
config_lookup_int ( & cfg , " shadow-radius " , & opt ion s. shadow_radius ) ;
config_lookup_int ( & cfg , " shadow-radius " , & opt s. shadow_radius ) ;
// -o ( options. shadow_opacity)
// -o ( shadow_opacity)
config_lookup_float ( & cfg , " shadow-opacity " , & opt ion s. shadow_opacity ) ;
config_lookup_float ( & cfg , " shadow-opacity " , & opt s. shadow_opacity ) ;
// -l ( options. shadow_offset_x)
// -l ( shadow_offset_x)
config_lookup_int ( & cfg , " shadow-offset-x " , & opt ion s. shadow_offset_x ) ;
config_lookup_int ( & cfg , " shadow-offset-x " , & opt s. shadow_offset_x ) ;
// -t ( options. shadow_offset_y)
// -t ( shadow_offset_y)
config_lookup_int ( & cfg , " shadow-offset-y " , & opt ion s. shadow_offset_y ) ;
config_lookup_int ( & cfg , " shadow-offset-y " , & opt s. shadow_offset_y ) ;
// -i ( options. inactive_opacity)
// -i ( inactive_opacity)
if ( config_lookup_float ( & cfg , " inactive-opacity " , & dval ) )
if ( config_lookup_float ( & cfg , " inactive-opacity " , & dval ) )
options . inactive_opacity = normalize_d ( dval ) * OPAQUE ;
opts . inactive_opacity = normalize_d ( dval ) * OPAQUE ;
// -e (options.frame_opacity)
// -e (frame_opacity)
config_lookup_float ( & cfg , " frame-opacity " , & options . frame_opacity ) ;
config_lookup_float ( & cfg , " frame-opacity " , & opts . frame_opacity ) ;
// -z (options.clear_shadow)
// -z (clear_shadow)
if ( config_lookup_bool ( & cfg , " clear-shadow " , & ival ) )
lcfg_lookup_bool ( & cfg , " clear-shadow " , & opts . clear_shadow ) ;
options . clear_shadow = ival ;
// -c (shadow_enable)
// -c (options.shadow_enable)
if ( config_lookup_bool ( & cfg , " shadow " , & ival ) & & ival )
if ( config_lookup_bool ( & cfg , " shadow " , & ival ) & & ival ) {
wintype_arr_enable ( opts . wintype_shadow ) ;
options . shadow_enable = 2 ;
// -C (no_dock_shadow)
wintype_arr_enable ( win_type_shadow ) ;
lcfg_lookup_bool ( & cfg , " no-dock-shadow " , & pcfgtmp - > no_dock_shadow ) ;
}
// -G (no_dnd_shadow)
// -C (options.no_dock_shadow)
lcfg_lookup_bool ( & cfg , " no-dnd-shadow " , & pcfgtmp - > no_dnd_shadow ) ;
if ( config_lookup_bool ( & cfg , " no-dock-shadow " , & ival ) )
// -m (menu_opacity)
options . no_dock_shadow = ival ;
config_lookup_float ( & cfg , " menu-opacity " , & pcfgtmp - > menu_opacity ) ;
// -G (options.no_dnd_shadow)
// -f (fading_enable)
if ( config_lookup_bool ( & cfg , " no-dnd-shadow " , & ival ) )
if ( config_lookup_bool ( & cfg , " fading " , & ival ) & & ival )
options . no_dnd_shadow = ival ;
wintype_arr_enable ( opts . wintype_fade ) ;
// -m (options.menu_opacity)
config_lookup_float ( & cfg , " menu-opacity " , & options . menu_opacity ) ;
// -f (options.fading_enable)
if ( config_lookup_bool ( & cfg , " fading " , & ival ) & & ival ) {
options . fading_enable = 2 ;
wintype_arr_enable ( win_type_fade ) ;
}
// --shadow-red
// --shadow-red
config_lookup_float ( & cfg , " shadow-red " , & opt ion s. shadow_red ) ;
config_lookup_float ( & cfg , " shadow-red " , & opts . shadow_red ) ;
// --shadow-green
// --shadow-green
config_lookup_float ( & cfg , " shadow-green " , & opt ion s. shadow_green ) ;
config_lookup_float ( & cfg , " shadow-green " , & opts . shadow_green ) ;
// --shadow-blue
// --shadow-blue
config_lookup_float ( & cfg , " shadow-blue " , & opt ion s. shadow_blue ) ;
config_lookup_float ( & cfg , " shadow-blue " , & opts . shadow_blue ) ;
// --inactive-opacity-override
// --inactive-opacity-override
if ( con fi g_lookup_bool( & cfg , " inactive-opacity-override " , & ival ) )
l cfg_lookup_bool( & cfg , " inactive-opacity-override " ,
options . inactive_opacity_override = ival ;
& opts . inactive_opacity_override ) ;
// --inactive-dim
// --inactive-dim
config_lookup_float ( & cfg , " inactive-dim " , & opt ion s. inactive_dim ) ;
config_lookup_float ( & cfg , " inactive-dim " , & opt s. inactive_dim ) ;
// --mark-wmwin-focused
// --mark-wmwin-focused
if ( config_lookup_bool ( & cfg , " mark-wmwin-focused " , & ival ) )
lcfg_lookup_bool ( & cfg , " mark-wmwin-focused " , & opts . mark_wmwin_focused ) ;
options . mark_wmwin_focused = ival ;
// --shadow-exclude
// --shadow-exclude
{
{
config_setting_t * setting =
config_setting_t * setting =
@ -3150,13 +3136,13 @@ parse_config(char *cpath) {
if ( config_setting_is_array ( setting ) ) {
if ( config_setting_is_array ( setting ) ) {
int i = config_setting_length ( setting ) ;
int i = config_setting_length ( setting ) ;
while ( i - - ) {
while ( i - - ) {
condlst_add ( & opt ion s. shadow_blacklist ,
condlst_add ( & opt s. shadow_blacklist ,
config_setting_get_string_elem ( setting , i ) ) ;
config_setting_get_string_elem ( setting , i ) ) ;
}
}
}
}
// Treat it as a single pattern if it's a string
// Treat it as a single pattern if it's a string
else if ( CONFIG_TYPE_STRING = = config_setting_type ( setting ) ) {
else if ( CONFIG_TYPE_STRING = = config_setting_type ( setting ) ) {
condlst_add ( & opt ion s. shadow_blacklist ,
condlst_add ( & opt s. shadow_blacklist ,
config_setting_get_string ( setting ) ) ;
config_setting_get_string ( setting ) ) ;
}
}
}
}
@ -3171,11 +3157,11 @@ parse_config(char *cpath) {
free ( str ) ;
free ( str ) ;
if ( setting ) {
if ( setting ) {
if ( config_setting_lookup_bool ( setting , " shadow " , & ival ) )
if ( config_setting_lookup_bool ( setting , " shadow " , & ival ) )
win_ type_shadow[ i ] = ( Bool ) ival ;
opts. wintype_shadow[ i ] = ( Bool ) ival ;
if ( config_setting_lookup_bool ( setting , " fade " , & ival ) )
if ( config_setting_lookup_bool ( setting , " fade " , & ival ) )
win_ type_fade[ i ] = ( Bool ) ival ;
opts. wintype_fade[ i ] = ( Bool ) ival ;
config_setting_lookup_float ( setting , " opacity " ,
config_setting_lookup_float ( setting , " opacity " ,
& win_ type_opacity[ i ] ) ;
& opts. wintype_opacity[ i ] ) ;
}
}
}
}
}
}
@ -3203,13 +3189,19 @@ get_cfg(int argc, char *const *argv) {
{ NULL , 0 , NULL , 0 } ,
{ NULL , 0 , NULL , 0 } ,
} ;
} ;
struct options_tmp cfgtmp = {
. no_dock_shadow = False ,
. no_dnd_shadow = False ,
. menu_opacity = 1.0 ,
} ;
Bool shadow_enable = False , fading_enable = False ;
int o , longopt_idx , i ;
int o , longopt_idx , i ;
char * config_file = NULL ;
char * config_file = NULL ;
for ( i = 0 ; i < NUM_WINTYPES ; + + i ) {
for ( i = 0 ; i < NUM_WINTYPES ; + + i ) {
win_type_fade [ i ] = False ;
opts. wintype_fade[ i ] = False ;
win_type_shadow [ i ] = False ;
opts. wintype_shadow[ i ] = False ;
win_ type_opacity[ i ] = 1.0 ;
opts. wintype_opacity[ i ] = 1.0 ;
}
}
// Pre-parse the commandline arguments to check for --config and invalid
// Pre-parse the commandline arguments to check for --config and invalid
@ -3223,7 +3215,7 @@ get_cfg(int argc, char *const *argv) {
}
}
# ifdef CONFIG_LIBCONFIG
# ifdef CONFIG_LIBCONFIG
parse_config ( config_file );
parse_config ( config_file , & cfgtmp );
# endif
# endif
// Parse commandline arguments. Range checking will be done later.
// Parse commandline arguments. Range checking will be done later.
@ -3233,57 +3225,58 @@ get_cfg(int argc, char *const *argv) {
switch ( o ) {
switch ( o ) {
// Short options
// Short options
case ' d ' :
case ' d ' :
opt ion s. display = optarg ;
opt s. display = optarg ;
break ;
break ;
case ' D ' :
case ' D ' :
opt ion s. fade_delta = atoi ( optarg ) ;
opt s. fade_delta = atoi ( optarg ) ;
break ;
break ;
case ' I ' :
case ' I ' :
opt ion s. fade_in_step = normalize_d ( atof ( optarg ) ) * OPAQUE ;
opt s. fade_in_step = normalize_d ( atof ( optarg ) ) * OPAQUE ;
break ;
break ;
case ' O ' :
case ' O ' :
opt ion s. fade_out_step = normalize_d ( atof ( optarg ) ) * OPAQUE ;
opt s. fade_out_step = normalize_d ( atof ( optarg ) ) * OPAQUE ;
break ;
break ;
case ' c ' :
case ' c ' :
if ( 2 ! = options . shadow_enable )
shadow_enable = True ;
options . shadow_enable = 1 ;
break ;
break ;
case ' C ' :
case ' C ' :
options . no_dock_shadow = True ;
cfgtmp . no_dock_shadow = True ;
break ;
case ' G ' :
cfgtmp . no_dnd_shadow = True ;
break ;
break ;
case ' m ' :
case ' m ' :
options . menu_opacity = atof ( optarg ) ;
cfgtmp . menu_opacity = atof ( optarg ) ;
break ;
break ;
case ' f ' :
case ' f ' :
if ( 2 ! = options . fading_enable )
fading_enable = True ;
options . fading_enable = 1 ;
break ;
break ;
case ' F ' :
case ' F ' :
opt ion s. fade_trans = True ;
opt s. fade_trans = True ;
break ;
break ;
case ' S ' :
case ' S ' :
opt ion s. synchronize = True ;
opt s. synchronize = True ;
break ;
break ;
case ' r ' :
case ' r ' :
opt ion s. shadow_radius = atoi ( optarg ) ;
opt s. shadow_radius = atoi ( optarg ) ;
break ;
break ;
case ' o ' :
case ' o ' :
opt ion s. shadow_opacity = atof ( optarg ) ;
opt s. shadow_opacity = atof ( optarg ) ;
break ;
break ;
case ' l ' :
case ' l ' :
opt ion s. shadow_offset_x = atoi ( optarg ) ;
opt s. shadow_offset_x = atoi ( optarg ) ;
break ;
break ;
case ' t ' :
case ' t ' :
opt ion s. shadow_offset_y = atoi ( optarg ) ;
opt s. shadow_offset_y = atoi ( optarg ) ;
break ;
break ;
case ' i ' :
case ' i ' :
opt ion s. inactive_opacity = ( normalize_d ( atof ( optarg ) ) * OPAQUE ) ;
opt s. inactive_opacity = ( normalize_d ( atof ( optarg ) ) * OPAQUE ) ;
break ;
break ;
case ' e ' :
case ' e ' :
opt ion s. frame_opacity = atof ( optarg ) ;
opt s. frame_opacity = atof ( optarg ) ;
break ;
break ;
case ' z ' :
case ' z ' :
opt ion s. clear_shadow = True ;
opt s. clear_shadow = True ;
break ;
break ;
case ' n ' :
case ' n ' :
case ' a ' :
case ' a ' :
@ -3291,11 +3284,8 @@ get_cfg(int argc, char *const *argv) {
fprintf ( stderr , " Warning: "
fprintf ( stderr , " Warning: "
" -n, -a, and -s have been removed. \n " ) ;
" -n, -a, and -s have been removed. \n " ) ;
break ;
break ;
case ' G ' :
options . no_dnd_shadow = True ;
break ;
case ' b ' :
case ' b ' :
opt ion s. fork_after_register = True ;
opts . fork_after_register = True ;
break ;
break ;
// Long options
// Long options
case 256 :
case 256 :
@ -3303,31 +3293,31 @@ get_cfg(int argc, char *const *argv) {
break ;
break ;
case 257 :
case 257 :
// --shadow-red
// --shadow-red
opt ion s. shadow_red = atof ( optarg ) ;
opt s. shadow_red = atof ( optarg ) ;
break ;
break ;
case 258 :
case 258 :
// --shadow-green
// --shadow-green
opt ion s. shadow_green = atof ( optarg ) ;
opt s. shadow_green = atof ( optarg ) ;
break ;
break ;
case 259 :
case 259 :
// --shadow-blue
// --shadow-blue
opt ion s. shadow_blue = atof ( optarg ) ;
opt s. shadow_blue = atof ( optarg ) ;
break ;
break ;
case 260 :
case 260 :
// --inactive-opacity-override
// --inactive-opacity-override
opt ion s. inactive_opacity_override = True ;
opt s. inactive_opacity_override = True ;
break ;
break ;
case 261 :
case 261 :
// --inactive-dim
// --inactive-dim
opt ion s. inactive_dim = atof ( optarg ) ;
opt s. inactive_dim = atof ( optarg ) ;
break ;
break ;
case 262 :
case 262 :
// --mark-wmwin-focused
// --mark-wmwin-focused
opt ion s. mark_wmwin_focused = True ;
opt s. mark_wmwin_focused = True ;
break ;
break ;
case 263 :
case 263 :
// --shadow-exclude
// --shadow-exclude
condlst_add ( & opt ion s. shadow_blacklist , optarg ) ;
condlst_add ( & opt s. shadow_blacklist , optarg ) ;
break ;
break ;
default :
default :
usage ( ) ;
usage ( ) ;
@ -3336,43 +3326,42 @@ get_cfg(int argc, char *const *argv) {
}
}
// Range checking and option assignments
// Range checking and option assignments
options . fade_delta = max_i ( options . fade_delta , 1 ) ;
opts . fade_delta = max_i ( opts . fade_delta , 1 ) ;
options . shadow_radius = max_i ( options . shadow_radius , 1 ) ;
opts . shadow_radius = max_i ( opts . shadow_radius , 1 ) ;
options . shadow_red = normalize_d ( options . shadow_red ) ;
opts . shadow_red = normalize_d ( opts . shadow_red ) ;
options . shadow_green = normalize_d ( options . shadow_green ) ;
opts . shadow_green = normalize_d ( opts . shadow_green ) ;
options . shadow_blue = normalize_d ( options . shadow_blue ) ;
opts . shadow_blue = normalize_d ( opts . shadow_blue ) ;
options . inactive_dim = normalize_d ( options . inactive_dim ) ;
opts . inactive_dim = normalize_d ( opts . inactive_dim ) ;
options . frame_opacity = normalize_d ( options . frame_opacity ) ;
opts . frame_opacity = normalize_d ( opts . frame_opacity ) ;
options . shadow_opacity = normalize_d ( options . shadow_opacity ) ;
opts . shadow_opacity = normalize_d ( opts . shadow_opacity ) ;
options . menu_opacity = normalize_d ( options . menu_opacity ) ;
cfgtmp . menu_opacity = normalize_d ( cfgtmp . menu_opacity ) ;
if ( OPAQUE = = options . inactive_opacity ) {
if ( OPAQUE = = opts . inactive_opacity ) {
options . inactive_opacity = 0 ;
opts . inactive_opacity = 0 ;
}
}
if ( 1 = = options . shadow_enable )
if ( shadow_enable )
wintype_arr_enable ( win_type_shadow ) ;
wintype_arr_enable ( opts . wintype_shadow ) ;
win_type_shadow [ WINTYPE_DESKTOP ] = False ;
opts . wintype_shadow [ WINTYPE_DESKTOP ] = False ;
if ( options . no_dock_shadow )
if ( cfgtmp . no_dock_shadow )
win_type_shadow [ WINTYPE_DOCK ] = False ;
opts . wintype_shadow [ WINTYPE_DOCK ] = False ;
if ( options . no_dnd_shadow )
if ( cfgtmp . no_dnd_shadow )
win_type_shadow [ WINTYPE_DND ] = False ;
opts . wintype_shadow [ WINTYPE_DND ] = False ;
if ( 1 = = options . fading_enable ) {
if ( fading_enable )
wintype_arr_enable ( win_type_fade ) ;
wintype_arr_enable ( opts . wintype_fade ) ;
}
if ( 1.0 ! = cfgtmp . menu_opacity ) {
if ( 1.0 ! = options . menu_opacity ) {
opts . wintype_opacity [ WINTYPE_DROPDOWN_MENU ] = cfgtmp . menu_opacity ;
win_type_opacity [ WINTYPE_DROPDOWN_MENU ] = options . menu_opacity ;
opts . wintype_opacity [ WINTYPE_POPUP_MENU ] = cfgtmp . menu_opacity ;
win_type_opacity [ WINTYPE_POPUP_MENU ] = options . menu_opacity ;
}
}
// Other variables determined by options
// Other variables determined by options
// Determine whether we need to track focus changes
// Determine whether we need to track focus changes
if ( opt ion s. inactive_opacity | | opt ion s. inactive_dim ) {
if ( opt s. inactive_opacity | | opt s. inactive_dim ) {
opt ion s. track_focus = True ;
opt s. track_focus = True ;
}
}
// Determine whether we need to track window name and class
// Determine whether we need to track window name and class
if ( opt ion s. shadow_blacklist | | opt ion s. fade_blacklist )
if ( opt s. shadow_blacklist | | opt s. fade_blacklist )
opt ion s. track_wdata = True ;
opt s. track_wdata = True ;
}
}
static void
static void
@ -3438,16 +3427,16 @@ main(int argc, char **argv) {
get_cfg ( argc , argv ) ;
get_cfg ( argc , argv ) ;
options. fade_time = get_time_in_milliseconds ( ) ;
fade_time = get_time_in_milliseconds ( ) ;
dpy = XOpenDisplay ( opt ion s. display ) ;
dpy = XOpenDisplay ( opt s. display ) ;
if ( ! dpy ) {
if ( ! dpy ) {
fprintf ( stderr , " Can't open display \n " ) ;
fprintf ( stderr , " Can't open display \n " ) ;
exit ( 1 ) ;
exit ( 1 ) ;
}
}
XSetErrorHandler ( error ) ;
XSetErrorHandler ( error ) ;
if ( opt ion s. synchronize ) {
if ( opt s. synchronize ) {
XSynchronize ( dpy , 1 ) ;
XSynchronize ( dpy , 1 ) ;
}
}
@ -3489,13 +3478,13 @@ main(int argc, char **argv) {
register_cm ( scr ) ;
register_cm ( scr ) ;
if ( opt ion s. fork_after_register ) fork_after ( ) ;
if ( opt s. fork_after_register ) fork_after ( ) ;
get_atoms ( ) ;
get_atoms ( ) ;
pa . subwindow_mode = IncludeInferiors ;
pa . subwindow_mode = IncludeInferiors ;
gaussian_map = make_gaussian_map ( dpy , opt ion s. shadow_radius ) ;
gaussian_map = make_gaussian_map ( dpy , opt s. shadow_radius ) ;
presum_gaussian ( gaussian_map ) ;
presum_gaussian ( gaussian_map ) ;
root_width = DisplayWidth ( dpy , scr ) ;
root_width = DisplayWidth ( dpy , scr ) ;
@ -3509,16 +3498,16 @@ main(int argc, char **argv) {
// Generates another Picture for shadows if the color is modified by
// Generates another Picture for shadows if the color is modified by
// user
// user
if ( ! opt ion s. shadow_red & & ! opt ion s. shadow_green & & ! opt ion s. shadow_blue ) {
if ( ! opt s. shadow_red & & ! opt s. shadow_green & & ! opt s. shadow_blue ) {
cshadow_picture = black_picture ;
cshadow_picture = black_picture ;
} else {
} else {
cshadow_picture = solid_picture ( dpy , True , 1 ,
cshadow_picture = solid_picture ( dpy , True , 1 ,
opt ion s. shadow_red , opt ion s. shadow_green , opt ion s. shadow_blue ) ;
opt s. shadow_red , opt s. shadow_green , opt s. shadow_blue ) ;
}
}
// Generates a picture for options. inactive_dim
// Generates a picture for inactive_dim
if ( opt ion s. inactive_dim ) {
if ( opt s. inactive_dim ) {
dim_picture = solid_picture ( dpy , True , opt ion s. inactive_dim , 0 , 0 , 0 ) ;
dim_picture = solid_picture ( dpy , True , opt s. inactive_dim , 0 , 0 , 0 ) ;
}
}
all_damage = None ;
all_damage = None ;
@ -3542,7 +3531,7 @@ main(int argc, char **argv) {
XFree ( children ) ;
XFree ( children ) ;
if ( opt ion s. track_focus ) {
if ( opt s. track_focus ) {
recheck_focus ( dpy ) ;
recheck_focus ( dpy ) ;
}
}