I ate the meal which you cooked.
:I ate the meal is an independent clause, which you cooked is dependent.
- When I saw what you had done, I was happy.
:Two dependent clauses, and one indepedent.
A sentence with a relative clause like the first example does not count as a complex sentence. A sentence is complex only when it contains a subordinate clause which fulfils a syntactic function within the sentence. In the second example, the sub-clause "When I saw what you had done" functions as adverbial, it has a temporal meaning. The sub-clause "what you had done" is embedded in the first subclause and functios as direct object within it. (See is a transitive verb and takes a direct object) A clause may also function as subject, or subject complement. A relative clause has no function within the sentence, but is embedded in a noun phrase and only describes this noun phrase, thus it does not built a complex sentence.
Example for a complex sentence with a sub-clause functioning as subject:
That you love me makes me happy.
Example for a complex sentence with a sub-clause functioning as exraposed subject:
It makes me happy that you love me.
"It" (dummy-it) does not have a meaning, it only takes the position of the subject, but the real subject occurs at the end of the sentence.
Example for a complex sentence with a sub-clause functioning as subject complement:
The book is where you have put it.
"Be" is a copula verb, it links the sub-clause to the subject.
Contrast with:
- I was scared, but I didn't run away.
:Both clauses are independent. This is a compound sentence but not a complex sentence.
- The dog you gave me barked at me and bit my hand.
:Two independent clauses ("barked at me" and "bit my hand") and one dependent clause ("[which] you gave me"). This is a complex-compound sentence.