
An optical mouse shines light onto the surface beneath it. A small sensor takes pictures of the details in that surface many times a second. The mouse compares one picture with the next and works out how far the details shifted and in which direction.
Why can plain glass be a problem?
A sensor needs something it can recognize twice. Clean glass may give it little surface texture, or its reflections can be hard for the sensor to use. Some mice use different lighting or sensors that work better on difficult surfaces.
Does lifting the mouse always move the pointer?
The sensor has a range where it can see the surface clearly. Once it’s too far away, it can stop reporting useful motion. That helps you pick the mouse up and reposition it without moving the pointer very far.
For more on how electrical sensors turn physical changes into signals, see Basics of Electric Utilities 101.