static void move_cursor(struct cursor *cursor, struct cursor_step *step) { int x = cursor->x; int y = cursor->y; if (!cursor->enabled) drmModeSetCursor(cursor->fd, cursor->crtc_id, cursor->bo_handle, cursor->w, cursor->h); /* calculate new cursor position: */ x += cursor->dx * step->arg; y += cursor->dy * step->arg; if (x < 0) { x = 0; cursor->dx = 1; } else if (x > (int)cursor->crtc_w) { x = cursor->crtc_w - 1; cursor->dx = -1; } if (y < 0) { y = 0; cursor->dy = 1; } else if (y > (int)cursor->crtc_h) { y = cursor->crtc_h - 1; cursor->dy = -1; } cursor->x = x; cursor->y = y; drmModeMoveCursor(cursor->fd, cursor->crtc_id, x, y); }
static void crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) { modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y); }
static void drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y) { drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; drmmode_ptr drmmode = drmmode_crtc->drmmode; drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, x, y); }
void QKmsCursor::pointerEvent(const QMouseEvent &event) { m_moved = true; int status = drmModeMoveCursor(m_screen->device()->fd(), m_screen->crtcId(), event.globalX(), event.globalY()); if (status) { qWarning("failed to move cursor: %d", status); } }
void mgm::RealKMSOutput::move_cursor(geometry::Point destination) { if (current_crtc) { if (auto result = drmModeMoveCursor(drm_fd, current_crtc->crtc_id, destination.x.as_uint32_t(), destination.y.as_uint32_t())) { fatal_error("drmModeMoveCursor failed (returned %d)", result); } } }
static bool move(struct view * view, int32_t x, int32_t y) { struct cursor_plane * plane = CONTAINER_OF(view, typeof(*plane), view); if (drmModeMoveCursor(swc.drm->fd, plane->crtc, x - plane->origin->x, y - plane->origin->y) != 0) { ERROR("Could not move cursor: %s\n", strerror(errno)); return false; } view_set_position(view, x, y); return true; }
static bool move(struct view * view, int32_t x, int32_t y) { struct cursor_plane * plane = wl_container_of(view, plane, view); if (swc.active && drmModeMoveCursor(swc.drm->fd, plane->crtc, x - plane->origin->x, y - plane->origin->y) != 0) { ERROR("Could not move cursor: %s\n", strerror(errno)); return false; } view_set_position(view, x, y); return true; }
static void set_mode(void) { int rc; front_fb = &fbs[0]; back_fb = &fbs[1]; rc = drmModeSetCrtc(drm.fd, modeset.crtc_id, front_fb->fb_id, 0, 0, &modeset.connector_id, 1, modeset.mode); igt_assert(rc == 0); /* TODO: it seems we need a cursor in order to reach PC7 on BDW. Why? */ rc = drmModeMoveCursor(drm.fd, modeset.crtc_id, 0, 0); igt_assert(rc == 0); rc = drmModeSetCursor(drm.fd, modeset.crtc_id, cursor.gem_handle, cursor.width, cursor.height); igt_assert(rc == 0); }
static void plane_cursor(struct kms_atomic_crtc_state *crtc, struct kms_atomic_plane_state *plane_old) { struct drm_mode_modeinfo *mode = crtc->mode.data; struct kms_atomic_plane_state plane = *plane_old; drmModeAtomicReq *req = drmModeAtomicAlloc(); struct igt_fb fb; uint64_t width, height; igt_assert(req); /* Any kernel new enough for atomic, also has the cursor size caps. */ do_or_die(drmGetCap(plane.state->desc->fd, DRM_CAP_CURSOR_WIDTH, &width)); do_or_die(drmGetCap(plane.state->desc->fd, DRM_CAP_CURSOR_HEIGHT, &height)); plane.src_x = 0; plane.src_y = 0; plane.src_w = width << 16; plane.src_h = height << 16; plane.crtc_x = mode->hdisplay / 2; plane.crtc_y = mode->vdisplay / 2; plane.crtc_w = width; plane.crtc_h = height; plane.crtc_id = crtc->obj; plane.fb_id = igt_create_color_fb(plane.state->desc->fd, width, height, DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE, 0.0, 0.0, 0.0, &fb); igt_assert_neq_u32(plane.fb_id, 0); /* Flip the cursor plane using the atomic API, and double-check * state is what we think it should be. */ plane_commit_atomic(&plane, req, ATOMIC_RELAX_NONE); /* Restore the cursor plane and check the state matches the old. */ plane_commit_atomic(plane_old, req, ATOMIC_RELAX_NONE); /* Re-enable the plane through the legacy cursor API, and verify * through atomic. */ do_or_die(drmModeMoveCursor(plane.state->desc->fd, plane.crtc_id, plane.crtc_x, plane.crtc_y)); do_or_die(drmModeSetCursor(plane.state->desc->fd, plane.crtc_id, fb.gem_handle, width, height)); plane_check_current_state(&plane, PLANE_RELAX_FB); /* Wiggle. */ plane.crtc_x -= 16; plane.crtc_y -= 16; do_or_die(drmModeMoveCursor(plane.state->desc->fd, plane.crtc_id, plane.crtc_x, plane.crtc_y)); plane_check_current_state(&plane, PLANE_RELAX_FB); /* Restore the plane to its original settings through the legacy cursor * API, and verify through atomic. */ do_or_die(drmModeSetCursor2(plane.state->desc->fd, plane.crtc_id, 0, 0, 0, 0, 0)); plane_check_current_state(plane_old, ATOMIC_RELAX_NONE); /* Finally, restore to the original state. */ plane_commit_atomic(plane_old, req, ATOMIC_RELAX_NONE); drmModeAtomicFree(req); }