about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-01-24 17:24:55 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-01-24 17:24:55 +0100
commit1f18466409aeb40e27b79814247dbda2d40369e2 (patch)
treee434423adaffc2854ba04a4842943e3d61455bcf
parentb65a1e33793b42f2718ccf6aa81dbd456f3fe7b9 (diff)
downloaddwm-1f18466409aeb40e27b79814247dbda2d40369e2.tar.gz
applied offscreen appearance hotfix
-rw-r--r--client.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/client.c b/client.c
index b89264c..6a178f8 100644
--- a/client.c
+++ b/client.c
@@ -142,14 +142,14 @@ manage(Window w, XWindowAttributes *wa) {
 	}
 	else {
 		c->border = BORDERPX;
-		if(c->x < wax)
-			c->x = wax;
-		if(c->y < way)
-			c->y = way;
 		if(c->x + c->w + 2 * c->border > wax + waw)
 			c->x = wax + waw - c->w - 2 * c->border;
 		if(c->y + c->h + 2 * c->border > way + wah)
 			c->y = way + wah - c->h - 2 * c->border;
+		if(c->x < wax)
+			c->x = wax;
+		if(c->y < way)
+			c->y = way;
 	}
 	updatesizehints(c);
 	c->proto = getproto(c->win);
@@ -197,14 +197,14 @@ resize(Client *c, Bool sizehints) {
 	else
 		c->border = BORDERPX;
 	/* offscreen appearance fixes */
-	if(c->x + c->w + 2 * c->border < sx)
-		c->x = sx;
-	if(c->y + c->h + 2 * c->border < sy)
-		c->y = sy;
 	if(c->x > sw)
 		c->x = sw - c->w - 2 * c->border;
 	if(c->y > sh)
 		c->y = sh - c->h - 2 * c->border;
+	if(c->x + c->w + 2 * c->border < sx)
+		c->x = sx;
+	if(c->y + c->h + 2 * c->border < sy)
+		c->y = sy;
 	wc.x = c->x;
 	wc.y = c->y;
 	wc.width = c->w;
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
           
                  
   
                         
 

                                       
 


                                                                                   
 














































































































                                                                               
discard """
  output: '''ok'''
"""
import strscans, strutils

proc raiseTestException*() =
  raise newException(Exception, "test")

proc matchStackTrace(actualEntries: openarray[StackTraceEntry], expected: string) =
  var expectedEntries = newSeq[StackTraceEntry]()
  var i = 0

  template checkEqual(actual, expected: typed, subject: string) =
    if actual != expected:
      echo "Unexpected ", subject, " on line ", i
      echo "Actual: ", actual
      echo "Expected: ", expected
      doAssert(false)

  for l in splitLines(expected.strip):
    var procname, filename: string
    var line: int
    if not scanf(l, "$s$w.nim($i) $w", filename, line, procname):
      doAssert(false, "Wrong expected stack trace")
    checkEqual($actualEntries[i].filename, filename & ".nim", "file name")
    if line != 0:
      checkEqual(actualEntries[i].line, line, "line number")
    checkEqual($actualEntries[i].procname, procname, "proc name")
    inc i

  doAssert(i == actualEntries.len, "Unexpected number of lines in stack trace")

template verifyStackTrace*(expectedStackTrace: string, body: untyped) =
  var verified = false
  try:
    body
  except Exception as e:
    verified = true
    # echo "Stack trace:"
    # echo e.getStackTrace
    matchStackTrace(e.getStackTraceEntries(), expectedStackTrace)

  doAssert(verified, "No exception was raised")

























when isMainModule:
# <-- Align with line 70 in the text editor
  block:
    proc bar() =
      raiseTestException()

    proc foo() =
      bar()

    const expectedStackTrace = """
      tproper_stacktrace.nim(86) tproper_stacktrace
      tproper_stacktrace.nim(76) foo
      tproper_stacktrace.nim(73) bar
      tproper_stacktrace.nim(7) raiseTestException
    """

    verifyStackTrace expectedStackTrace:
      foo()

  block:
    proc bar(x: int) =
      raiseTestException()

    template foo(x: int) =
      bar(x)

    const expectedStackTrace = """
      tproper_stacktrace.nim(103) tproper_stacktrace
      tproper_stacktrace.nim(90) bar
      tproper_stacktrace.nim(7) raiseTestException
    """

    verifyStackTrace expectedStackTrace:
      var x: int
      foo(x)

  block: #6803
    proc bar(x = 500) =
      raiseTestException()

    proc foo() =
      bar()

    const expectedStackTrace = """
      tproper_stacktrace.nim(120) tproper_stacktrace
      tproper_stacktrace.nim(110) foo
      tproper_stacktrace.nim(107) bar
      tproper_stacktrace.nim(7) raiseTestException
    """

    verifyStackTrace expectedStackTrace:
      foo()


  echo "ok"