diff --git a/README.md b/README.md index 4f1fe77..89dfdd7 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ A demo showing tdrop's ability to auto-hide windows when opening things from the - Allows for multiple dropdowns of the same type (works by window id) - Allows for auto-hiding a dropdown when opening programs from it - Can automatically start programs and tmux or tmuxinator sessions +- Supports automatic resizing based on the current monitor ## Requirements - xprop @@ -39,6 +40,15 @@ s. It is usually worse on tiling managers where the window must be re-floated ev 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. +### Monitor Awareness +Using the `-m`/`--monitor-aware` flag has two purposes. For those who use a single monitor, it allows specifying a negative number to `-w` or `-h`. For example, `-w -4` corresponds to a width 4 pixels less than 100% of the screen width. This may be useful when the window manager (possibly due to window decorations) causes a dropdown with `-w 100%` to go over the edge of the screen. + +For those who use multiple monitors, using `-m` will additionally alter the width and height options to correspond to the current monitor. This means that `-w 100%` will cause the dropdown to occupy the full width of the current monitor instead of spanning all monitors. Also, the `-m` option will automatically resize the dropdown when opening it on a different monitor if the width or height arguments are negative or percentages. + +Some window managers allow querying what the current monitor is (e.g. bspwm and i3), but for other window managers, tdrop determines the current monitor based on the position of the active window. This means that for window managers that have a concept of a focused but empty monitor, the `-m` option may not work properly on empty monitors. If you encounter this problem, please make an issue. + +See the manpage for more information. + ### Auto-hiding In addition to creating dropdowns, tdrop can automatically hide a window and later un-hide it. For example, if gvim is opened to write a git commit message from the terminal, tdrop can automatically hide the terminal (dropdown or not) and restore it after the user is finished writing the commit message: diff --git a/tdrop b/tdrop index 0e50aff..784b5a1 100755 --- a/tdrop +++ b/tdrop @@ -67,7 +67,7 @@ clearwid=false cancel_auto_show=true term=${*:0-1} auto_detect_wm=false -multiple_monitors=false +monitor_aware=false while getopts :h:w:x:y:s:n:p:P:M:O:d:z:Z:f:-:Wam opt do case $opt in @@ -89,7 +89,7 @@ do f) program_flags=$OPTARG;; W) normal_window=true;; a) auto_detect_wm=true;; - m) multiple_monitors=true;; + m) monitor_aware=true;; -) OPTION=$(echo "$OPTARG" | awk -F '=' '{print $1}') OPTARG=$(echo "$OPTARG" | awk -F '=' '{print $2}') @@ -112,7 +112,7 @@ do program-flags) program_flags=$OPTARG;; normal-window) normal_window=true;; auto-detect-wm) auto_detect_wm=true;; - multiple-monitors) multiple_monitors=true;; + monitor-aware) monitor_aware=true;; clear) clearwid=true;; no-cancel) cancel_auto_show=false;; help) print_help;; @@ -515,7 +515,7 @@ wid_toggle() { fi # update here so this doesn't cause a delay # between the window being remapped and resized - if $multiple_monitors; then + if $monitor_aware; then update_geometry_settings_for_monitor fi if ! $combine_map_post; then @@ -538,7 +538,7 @@ wid_toggle() { fi else # necessary to deal with negative width or height - if $multiple_monitors; then + if $monitor_aware; then update_geometry_settings_for_monitor fi # make it diff --git a/tdrop.groff b/tdrop.groff index 67da2d5..604782b 100644 --- a/tdrop.groff +++ b/tdrop.groff @@ -66,7 +66,7 @@ Specifies that the program is not a terminal or does not have the '-e' flag; tak \fB\-a\fR, \fB \-\-auto-detect-wm\fR If there are available settings for the detected window manager for the -p, -P, -M, and/or -d options, automatically set them; takes no argument. User set settings will still override these. This can be used with 'tdrop ', 'tdrop auto_hide', and 'tdrop auto_show'. For 'auto_hide', if the window manager is supported, it will check if the current window is tiled so that it is not changed to floating when auto-showing. (default: false) .TP -\fB\-m\fR, \fB \-\-multiple-monitors\fR +\fB\-m\fR, \fB \-\-monitor-aware\fR This option only applies for dropdowns (not auto-hiding and auto-showing). Specify that width and height percentages should be relative to the current monitor. If the monitor changes, this option will cause a dropdown to be resized to fit the given percentages. A negative argument is also allowed for '-w' and '-y' with this option (e.g. '-m -w -4') in which case the determined value will be that many pixels less than 100% of the screen size. This fixes the problem where 100% width may actually go over the screen due to window borders/decoration. Note that this option assumes xrandr is being used and requires xrandr to work. (default: false) .TP \fB \-\-clear\fR