Fixed crash on Wayland with DRM-backend.

Fixes #319.
Fixes #301.