drmmode: fix showing cursor when it is loaded

When using drm planes it is not possible to update a hidden cursor's
position since drmModeSetPlane() always makes a plane visible.

Instead of tracking the cursor visibility status in the driver, we use
the xf86 provided cursor_shown variable.  However, this is only updated
*after* xf86 calls the DDX's ->show_cursor().  Thus, if the cursor was
currently hidden when a cursor image update occurred, when show_cursor()
called ->drmmode_set_cursor_position(), cursor_shown was still false, and
we wouldn't actually show the cursor.

Instead, refactor drmmode_set_plane() out of drmmode_set_cursor_position()
and call it unconditionally in show_cursor(), and only call it from
drmmode_set_cursor_position() if the cursor is presently visible.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

  Move pointer one pixel to the left of a UI element that uses a different
  cursor.  For, example, next to the "shutdown button" on the peach_pi
  login screen:
    xdotool mousemove -- 14 1054
  Move pointer one pixel to the right
    xdotool mousemove_relative -- 1 0
  => cursor should change and stay visible (previously it would be hidden)
  Press a key to hide cursor
    xdotool key 'L'
  Move one pixel to reshow cursor (also switches back to previous cursor)
    xdotool mousemove_relative -- -1 0
TEST=powerd_dbus_suspend w/ cursor visible & not visible
TEST=slowly mouse over a link; cursor changes shape, but stays visible

Change-Id: I064c064a043b0c7dc6363e0bf978e669f656fed5
Reviewed-on: https://chromium-review.googlesource.com/203235
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
1 file changed