Thinking he was having trouble getting our son to fall asleep, 现在分词短语做原因状语
I walked quietly to the baby’s room and looked into the dimly-lit(灯光暗淡的)room.
=Because I thought he was having trouble (in) getting our son to fall asleep, I walked quietly to the baby’s room and looked into the dimly-lit(灯光暗淡的)room.