How in the world could a sliding glass door lock on your from the outside. I only open it at the handle and do not touch the latch or pin. This happened to me recently and got locked out while out on my patio. The lock to the sliding glass door in on the inside!
The latch mechanism ("hook deadlock" as mentioned by CactusCake) is generally installed so that the "hook" is facing up. But sometimes people install them upside down to where the hook faces down and if it is loose and sloppy, the hook falls down when you shut the door, locking you out.