commit 6a2570e
Michael Forney
·
2014-12-29 08:04:26 +0000 UTC
parent bf1a520
cursor_plane: Don't attempt to set cursor when not active
1 files changed,
+11,
-19
+11,
-19
1@@ -42,7 +42,6 @@ static bool update(struct view * view)
2 static int attach(struct view * view, struct wld_buffer * buffer)
3 {
4 struct cursor_plane * plane = wl_container_of(view, plane, view);
5- int ret;
6
7 if (buffer)
8 {
9@@ -56,22 +55,18 @@ static int attach(struct view * view, struct wld_buffer * buffer)
10 return -EINVAL;
11 }
12
13- ret = drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32,
14- buffer->width, buffer->height);
15-
16- if (ret < 0)
17+ if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32,
18+ buffer->width, buffer->height) < 0)
19 {
20- ERROR("Could not set cursor: %s\n", strerror(-ret));
21- return ret;
22+ ERROR("Could not set cursor: %s\n", strerror(errno));
23+ return -errno;
24 }
25 }
26- else
27+ else if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc,
28+ 0, 0, 0) < 0)
29 {
30- if ((ret = drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0)) < 0)
31- {
32- ERROR("Could not unset cursor: %s\n", strerror(-ret));
33- return ret;
34- }
35+ ERROR("Could not unset cursor: %s\n", strerror(errno));
36+ return -errno;
37 }
38
39 view_set_size_from_buffer(view, buffer);
40@@ -82,8 +77,9 @@ static bool move(struct view * view, int32_t x, int32_t y)
41 {
42 struct cursor_plane * plane = wl_container_of(view, plane, view);
43
44- if (drmModeMoveCursor(swc.drm->fd, plane->crtc,
45- x - plane->origin->x, y - plane->origin->y) != 0)
46+ if (swc.active && drmModeMoveCursor(swc.drm->fd, plane->crtc,
47+ x - plane->origin->x,
48+ y - plane->origin->y) != 0)
49 {
50 ERROR("Could not move cursor: %s\n", strerror(errno));
51 return false;
52@@ -118,9 +114,6 @@ static void handle_swc_event(struct wl_listener * listener, void * data)
53 bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc,
54 const struct swc_rectangle * origin)
55 {
56- if (drmModeSetCursor(swc.drm->fd, crtc, 0, 0, 0) != 0)
57- return false;
58-
59 plane->origin = origin;
60 plane->crtc = crtc;
61 plane->swc_listener.notify = &handle_swc_event;
62@@ -132,6 +125,5 @@ bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc,
63
64 void cursor_plane_finalize(struct cursor_plane * plane)
65 {
66- drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0);
67 }
68