In a situation like this, depending on the width of the frame around the glass, I would mount the sensor to the sliding portion, then the magnet to the frame. What is possible/best will depend on the trim. It is ok if the sensor overhangs the edge a bit.