-
Notifications
You must be signed in to change notification settings - Fork 0
/
anal-getCoordinatesForNewWindow.pl~random
executable file
·59 lines (51 loc) · 1.22 KB
/
anal-getCoordinatesForNewWindow.pl~random
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl
$w = 0;
$h = 0;
$monitorX = 0;
$monitorWidth = 0;
$monitorHeight = 0;
$focusX = 0;
$focusY = 0;
$focusMonitorX = 0;
$focusMonitorY = 0;
$focusMonitorWidth = 0;
$focusMonitorHeight = 0;
foreach $arg (@ARGV) {
if ($arg =~ m/^([a-zA-Z]+):([0-9]+)/) {
$key = $1;
$val = $2;
if (defined($$key)) {
$$key = int($val);
}
}
}
# cascade from focus window
#$newX = $focusX + 20;
#$newY = $focusY + 40;
#if ($newX + $w < $focusMonitorX + $focusMonitorWidth) {
# if ($newY + $h < $focusMonitorY + $focusMonitorHeight - 20) {
# print "x:$newX y:$newY\n";
# exit 0;
# }
#}
# random placement
if ($w && $h && ($monitorWidth > $w) && ($monitorHeight - 20 > $h)) {
$rangeX = $monitorWidth - $w;
$rangeY = $monitorHeight - 20 - $h;
$x = $monitorX + int(rand($rangeX));
$y = 20 + int(rand($rangeY));
print "x:$x y:$y\n";
exit 0;
}
# centered
#if ($w && $h && ($monitorWidth > $w) && ($monitorHeight - 20 > $h)) {
# $rangeX = $monitorWidth - $w;
# $rangeY = $monitorHeight - 20 - $h;
#
# $x = $monitorX + int($rangeX/2);
# $y = 20 + int($rangeY/2);
# print "x:$x y:$y\n";
# exit 0;
#}
# top left corner
print "x:$monitorX y:0\n";