about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-05-19 17:23:49 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-05-19 17:23:49 +0100
commit234b12eb73f5c6de3da4eb93cac2159e73647529 (patch)
tree326b0232bb552ae90ed3ecfb526c64151ffa2f0c
parentbd4deaebfc3bbcd72c032a5525c9f35e73e8a98e (diff)
downloaddwm-234b12eb73f5c6de3da4eb93cac2159e73647529.tar.gz
be more polite to clients which like to appear outside the window area, but still on the screen
-rw-r--r--dwm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/dwm.c b/dwm.c
index 507084c..37df864 100644
--- a/dwm.c
+++ b/dwm.c
@@ -958,12 +958,12 @@ manage(Window w, XWindowAttributes *wa) {
 		c->bw = wa->border_width;
 	}
 	else {
-		if(c->x + c->w + 2 * c->bw > wx + ww)
-			c->x = wx + ww - c->w - 2 * c->bw;
-		if(c->y + c->h + 2 * c->bw > wy + wh)
-			c->y = wy + wh - c->h - 2 * c->bw;
-		c->x = MAX(c->x, wx);
-		c->y = MAX(c->y, wy);
+		if(c->x + c->w + 2 * c->bw > sx + sw)
+			c->x = sx + sw - c->w - 2 * c->bw;
+		if(c->y + c->h + 2 * c->bw > sy + sh)
+			c->y = sy + sh - c->h - 2 * c->bw;
+		c->x = MAX(c->x, sx);
+		c->y = MAX(c->y, sy);
 		c->bw = borderpx;
 	}
 
200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.

from __future__ import (absolute_import, division, print_function)

import os.path


def next_available_filename(fname, directory="."):
    existing_files = os.listdir(directory)

    if fname not in existing_files:
        return fname
    if not fname.endswith("_"):
        fname += "_"
        if fname not in existing_files:
            return fname

    for i in range(1, len(existing_files) + 1):
        if fname + str(i) not in existing_files:
            return fname + str(i)
    return None