diff --git a/README.md b/README.md index f717605..aef1610 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ alt + s ### Basic Flags ### Flicker -For window managers that will require a window to be repositioned after re-mapping it, some flicker may be noticeable. It is usually worse on tiling managers where the window must be re-floated every time it is mapped. The way around this is to use rules to either always have the class floated or one-time rules to only float the next instance of a class. Since bspwm has oneshot rules and won't alter the size/position of a window, there isn't any flicker for it, and you don't you can still use tiled windows of the same class as your dropdown. +For some window managers that require a window to be repositioned after re-mapping it, some flicker may be noticeable. With a recent change, this flicker is pretty much gone for some window managers (e.g. in the Gnome Shell and Cinnamon DEs) and slightly better than before in other +s. It is usually worse on tiling managers where the window must be re-floated every time it is mapped. The way around this is to use rules to either always have the class floated or one-time rules to only float the next instance of a class. For example, since bspwm has oneshot rules and won't alter the size/position of a window, this flicker is not a problem. However, the consistent way to eliminate visual flickering due to moving/resizing for any window manager is to enable fade-in for the compositor. For compton this can be done by setting `fading = true;` and adjusting the `fade-delta` in the .compton.conf accordingly. @@ -77,6 +78,7 @@ For floating window managers, tdrop should also generally "just work", but you w That said, these are the floating window managers that currently have '-a' settings: - mutter (gnome shell) +- muffin (cinnamon) - xfwm4 - metacity - openbox diff --git a/tdrop b/tdrop index aa13666..ec8281a 100755 --- a/tdrop +++ b/tdrop @@ -117,6 +117,10 @@ done # necessary to account for differences in geometry/positioning output from xwininfo # for different WMs (matters when a window is in a corner or on the side) subtract_when_same=true +# will be set to true to eliminate or reduce flicker for WMs that alter window +# position when remapping; when true, windowmap and windowmove are combined, so that +# the window is correctly positioned earlier +combine_map_post=false # # WM Detection and Settings @@ -171,7 +175,7 @@ wm_autoset_for_all() { } # floating WMs that need extra sleep time to wait for dropdown to spawn initially - elif [[ $wm =~ ^(Fluxbox|Mutter|GNOME Shell)$ ]]; then + elif [[ $wm =~ ^(Fluxbox|Mutter|GNOME Shell|Mutter \(Muffin\))$ ]]; then if ! $sleep_term_user_set; then sleep_term_time=0.05 fi @@ -201,13 +205,21 @@ wm_autoset_for_hide_show() { elif [[ $wm =~ ^(Mutter|GNOME Shell)$ ]]; then dec_fix_auto="-10x-8" subtract_when_same=false + elif [[ $wm =~ ^(Mutter \(Muffin\))$ ]]; then + dec_fix_auto="-9x-8" # NOTE: # pekwm, xfwm4, sawfish, openbox need subtract_when_same to be true (default) # for fluxbox, blackbox, fvwm, and metacity, the value does not matter elif [[ $wm == GoomwW ]]; then subtract_when_same=false - + fi + + if [[ $wm =~ ^(pekwm|Fluxbox|Blackbox|xfwm4|Metacity|FVWM|Sawfish|GoomwW|Mutter|GNOME Shell|Mutter \(Muffin\))$ ]]; then + combine_map_post=true + map_post() { + xdotool windowmap "$1" windowmove "$1" "$2" "$3" + } fi } @@ -223,14 +235,14 @@ wm_autoset_for_dropdown() { herbstclient fullscreen off } - # stacking/floating wms: settings for maintaining geometry after mapping - # floating window managers that may both move and resize a window after unmapping then mapping it elif [[ $wm == Openbox ]]; then # openbox will resize window to be slightly less than the width of the screen when mapping # this is necessary when want width to be 100% + combine_map_post=true map_post() { - xdotool windowmove "$1" "$xoff" "$yoff" windowsize "$1" "$width" "$height" + xdotool windowmap "$1" windowmove "$1" "$xoff" "$yoff" \ + windowsize "$1" "$width" "$height" } # floating window managers that may move a window after unmapping then mapping it elif [[ $wm =~ ^(pekwm|Fluxbox|Blackbox|xfwm4|Metacity|FVWM|Sawfish|GoomwW|Mutter|GNOME Shell|Mutter \(Muffin\))$ ]]; then @@ -238,8 +250,9 @@ wm_autoset_for_dropdown() { # mutter/gnome shell will move to top centerish (just below panel on gnome shell) # xfwm4 will normally move to top left; metacity will move close to top left # sawfish just moves all over the place + combine_map_post=true map_post() { - xdotool windowmove "$1" "$xoff" "$yoff" + xdotool windowmap "$1" windowmove "$1" "$xoff" "$yoff" } fi } @@ -279,7 +292,7 @@ map_post_command() { elif [[ -n $map_post ]]; then eval "$map_post" elif [[ -n $(type map_post 2> /dev/null) ]]; then - map_post "$1" + map_post "$@" fi } @@ -373,8 +386,13 @@ wid_toggle() { else map_pre_command "$term" fi - xdotool windowmap "$wid" - map_post_command "$wid" + if ! $combine_map_post; then + xdotool windowmap "$wid" + map_post_command "$wid" + else + # combine mapping with resizing/moving when possible to reduce flicker + map_post_command "$wid" + fi maybe_cancel_auto_show "$wid" else xdotool windowunmap "$wid" @@ -437,7 +455,7 @@ get_geometry() { fi } -set_geometry() { +give_geometry() { eval "$(< /tmp/tdrop/auto_hidden/geometry)" if [[ -n $dec_fix ]]; then x_fix=$(echo "$dec_fix" | awk -F "x" '{print $1}') @@ -450,7 +468,11 @@ set_geometry() { X=$((X-x_fix)) Y=$((Y-y_fix)) fi - xdotool windowmove "$1" "$X" "$Y" + echo "$X $Y" +} + +set_geometry() { + xdotool windowmove "$1" "$(give_geometry)" } toggle_auto_hide() { @@ -488,10 +510,21 @@ auto_show() { if [[ $was_floating != false ]]; then map_pre_command "$class" fi - xdotool windowmap "$wid" + if ! $combine_map_post; then + xdotool windowmap "$wid" + fi if [[ $was_floating != false ]]; then - map_post_command "$wid" - set_geometry "$wid" + if $combine_map_post; then + XY=$(give_geometry "$wid") + X=$(echo "$XY" | awk '{print $1}') + Y=$(echo "$XY" | awk '{print $2}') + map_post_command "$wid" "$X" "$Y" + else + map_post_command "$wid" + set_geometry "$wid" + fi + else + xdotool windowmap "$wid" fi fi }