parent
b2d478a418
commit
641d08ce7e
|
@ -469,7 +469,8 @@ static void wlr_drm_connector_transform(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
|
static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
|
||||||
|
int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
||||||
struct wlr_drm_backend *drm = conn->drm;
|
struct wlr_drm_backend *drm = conn->drm;
|
||||||
struct wlr_drm_renderer *renderer = &drm->renderer;
|
struct wlr_drm_renderer *renderer = &drm->renderer;
|
||||||
|
@ -534,6 +535,37 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (output->transform) {
|
||||||
|
case WL_OUTPUT_TRANSFORM_90:
|
||||||
|
output->cursor.hotspot_x = hotspot_x;
|
||||||
|
output->cursor.hotspot_y = -plane->surf.height + hotspot_y;
|
||||||
|
break;
|
||||||
|
case WL_OUTPUT_TRANSFORM_180:
|
||||||
|
output->cursor.hotspot_x = plane->surf.width - hotspot_x;
|
||||||
|
output->cursor.hotspot_y = plane->surf.height - hotspot_y;
|
||||||
|
break;
|
||||||
|
case WL_OUTPUT_TRANSFORM_270:
|
||||||
|
output->cursor.hotspot_x = -plane->surf.height + hotspot_x;
|
||||||
|
output->cursor.hotspot_y = hotspot_y;
|
||||||
|
break;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
||||||
|
output->cursor.hotspot_x = plane->surf.width - hotspot_x;
|
||||||
|
output->cursor.hotspot_y = hotspot_y;
|
||||||
|
break;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||||
|
output->cursor.hotspot_x = hotspot_x;
|
||||||
|
output->cursor.hotspot_y = -hotspot_y;
|
||||||
|
break;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||||
|
output->cursor.hotspot_x = hotspot_x;
|
||||||
|
output->cursor.hotspot_y = plane->surf.height - hotspot_y;
|
||||||
|
break;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||||
|
output->cursor.hotspot_x = -plane->surf.height + hotspot_x;
|
||||||
|
output->cursor.hotspot_y = plane->surf.width - hotspot_y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
struct gbm_bo *bo = plane->cursor_bo;
|
struct gbm_bo *bo = plane->cursor_bo;
|
||||||
uint32_t bo_width = gbm_bo_get_width(bo);
|
uint32_t bo_width = gbm_bo_get_width(bo);
|
||||||
uint32_t bo_height = gbm_bo_get_height(bo);
|
uint32_t bo_height = gbm_bo_get_height(bo);
|
||||||
|
@ -581,23 +613,22 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
|
||||||
|
|
||||||
switch (output->transform) {
|
switch (output->transform) {
|
||||||
case WL_OUTPUT_TRANSFORM_NORMAL:
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||||
// nothing to do
|
// nothing to do
|
||||||
break;
|
break;
|
||||||
case WL_OUTPUT_TRANSFORM_270:
|
case WL_OUTPUT_TRANSFORM_270:
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||||
tmp = x;
|
tmp = x;
|
||||||
x = y;
|
x = y;
|
||||||
y = -(tmp - width);
|
y = -(tmp - width);
|
||||||
break;
|
break;
|
||||||
case WL_OUTPUT_TRANSFORM_90:
|
case WL_OUTPUT_TRANSFORM_90:
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||||
tmp = x;
|
tmp = x;
|
||||||
x = -(y - height);
|
x = -(y - height);
|
||||||
y = tmp;
|
y = tmp;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
// TODO other transformations
|
|
||||||
wlr_log(L_ERROR, "TODO: handle surface to crtc for transformation = %d",
|
|
||||||
output->transform);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return drm->iface->crtc_move_cursor(drm, conn->crtc, x, y);
|
return drm->iface->crtc_move_cursor(drm, conn->crtc, x, y);
|
||||||
|
|
|
@ -53,7 +53,8 @@ static void wlr_wl_output_transform(struct wlr_output *_output,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
|
static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
|
||||||
|
int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
|
|
||||||
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
|
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
|
||||||
struct wlr_wl_backend *backend = output->backend;
|
struct wlr_wl_backend *backend = output->backend;
|
||||||
|
@ -110,7 +111,8 @@ static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
|
||||||
wl_surface_damage(output->cursor_surface, 0, 0, width, height);
|
wl_surface_damage(output->cursor_surface, 0, 0, width, height);
|
||||||
wl_surface_commit(output->cursor_surface);
|
wl_surface_commit(output->cursor_surface);
|
||||||
|
|
||||||
wlr_wl_output_update_cursor(output, output->enter_serial);
|
wlr_wl_output_update_cursor(output, output->enter_serial,
|
||||||
|
hotspot_x, hotspot_y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +145,11 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output, uint32_t serial) {
|
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output,
|
||||||
|
uint32_t serial, int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
if (output->cursor_surface && output->backend->pointer && serial) {
|
if (output->cursor_surface && output->backend->pointer && serial) {
|
||||||
wl_pointer_set_cursor(output->backend->pointer, serial,
|
wl_pointer_set_cursor(output->backend->pointer, serial,
|
||||||
output->cursor_surface, 0, 0);
|
output->cursor_surface, hotspot_x, hotspot_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
assert(output);
|
assert(output);
|
||||||
wlr_wl_pointer->current_output = output;
|
wlr_wl_pointer->current_output = output;
|
||||||
wlr_wl_pointer->current_output->enter_serial = serial;
|
wlr_wl_pointer->current_output->enter_serial = serial;
|
||||||
wlr_wl_output_update_cursor(wlr_wl_pointer->current_output, serial);
|
wlr_wl_output_update_cursor(wlr_wl_pointer->current_output, serial, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
|
static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
|
@ -112,7 +112,8 @@ static void handle_output_add(struct output_state *ostate) {
|
||||||
// TODO the cursor must be set depending on which surface it is displayed
|
// TODO the cursor must be set depending on which surface it is displayed
|
||||||
// over which should happen in the compositor.
|
// over which should happen in the compositor.
|
||||||
if (!wlr_output_set_cursor(wlr_output, image->buffer,
|
if (!wlr_output_set_cursor(wlr_output, image->buffer,
|
||||||
image->width, image->width, image->height)) {
|
image->width, image->width, image->height,
|
||||||
|
image->hotspot_x, image->hotspot_y)) {
|
||||||
wlr_log(L_DEBUG, "Failed to set hardware cursor");
|
wlr_log(L_DEBUG, "Failed to set hardware cursor");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,8 @@ struct wlr_wl_pointer {
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_wl_registry_poll(struct wlr_wl_backend *backend);
|
void wlr_wl_registry_poll(struct wlr_wl_backend *backend);
|
||||||
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output, uint32_t serial);
|
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output,
|
||||||
|
uint32_t serial, int32_t hotspot_x, int32_t hotspot_y);
|
||||||
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
|
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
|
||||||
struct wlr_wl_backend *backend, struct wl_surface *surface);
|
struct wlr_wl_backend *backend, struct wl_surface *surface);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ struct wlr_output_impl {
|
||||||
void (*transform)(struct wlr_output *output,
|
void (*transform)(struct wlr_output *output,
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
|
bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
|
||||||
int32_t stride, uint32_t width, uint32_t height);
|
int32_t stride, uint32_t width, uint32_t height,
|
||||||
|
int32_t hotspot_x, int32_t hotspot_y);
|
||||||
bool (*move_cursor)(struct wlr_output *output, int x, int y);
|
bool (*move_cursor)(struct wlr_output *output, int x, int y);
|
||||||
void (*destroy)(struct wlr_output *output);
|
void (*destroy)(struct wlr_output *output);
|
||||||
void (*make_current)(struct wlr_output *output);
|
void (*make_current)(struct wlr_output *output);
|
||||||
|
|
|
@ -45,6 +45,7 @@ struct wlr_output {
|
||||||
bool is_sw;
|
bool is_sw;
|
||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
|
int32_t hotspot_x, hotspot_y;
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
struct wlr_texture *texture;
|
struct wlr_texture *texture;
|
||||||
} cursor;
|
} cursor;
|
||||||
|
@ -58,7 +59,8 @@ bool wlr_output_set_mode(struct wlr_output *output,
|
||||||
void wlr_output_transform(struct wlr_output *output,
|
void wlr_output_transform(struct wlr_output *output,
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
bool wlr_output_set_cursor(struct wlr_output *output,
|
bool wlr_output_set_cursor(struct wlr_output *output,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height);
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
|
||||||
|
int32_t hotspot_x, int32_t hotspot_y);
|
||||||
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y);
|
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y);
|
||||||
void wlr_output_destroy(struct wlr_output *output);
|
void wlr_output_destroy(struct wlr_output *output);
|
||||||
void wlr_output_effective_resolution(struct wlr_output *output,
|
void wlr_output_effective_resolution(struct wlr_output *output,
|
||||||
|
|
|
@ -145,7 +145,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
||||||
// TODO the cursor must be set depending on which surface it is displayed
|
// TODO the cursor must be set depending on which surface it is displayed
|
||||||
// over which should happen in the compositor.
|
// over which should happen in the compositor.
|
||||||
if (!wlr_output_set_cursor(wlr_output, image->buffer,
|
if (!wlr_output_set_cursor(wlr_output, image->buffer,
|
||||||
image->width, image->width, image->height)) {
|
image->width, image->width, image->height,
|
||||||
|
image->hotspot_x, image->hotspot_y)) {
|
||||||
wlr_log(L_DEBUG, "Failed to set hardware cursor");
|
wlr_log(L_DEBUG, "Failed to set hardware cursor");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,15 +131,6 @@ static struct wlr_cursor_device *get_cursor_device(struct wlr_cursor *cur,
|
||||||
static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur,
|
static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur,
|
||||||
double x, double y) {
|
double x, double y) {
|
||||||
assert(cur->state->layout);
|
assert(cur->state->layout);
|
||||||
int hotspot_x = 0;
|
|
||||||
int hotspot_y = 0;
|
|
||||||
|
|
||||||
if (cur->state->xcursor && cur->state->xcursor->image_count > 0) {
|
|
||||||
struct wlr_xcursor_image *image = cur->state->xcursor->images[0];
|
|
||||||
hotspot_x = image->hotspot_x;
|
|
||||||
hotspot_y = image->hotspot_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct wlr_output_layout_output *l_output;
|
struct wlr_output_layout_output *l_output;
|
||||||
wl_list_for_each(l_output, &cur->state->layout->outputs, link) {
|
wl_list_for_each(l_output, &cur->state->layout->outputs, link) {
|
||||||
|
@ -148,8 +139,9 @@ static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur,
|
||||||
|
|
||||||
wlr_output_layout_output_coords(cur->state->layout,
|
wlr_output_layout_output_coords(cur->state->layout,
|
||||||
l_output->output, &output_x, &output_y);
|
l_output->output, &output_x, &output_y);
|
||||||
wlr_output_move_cursor(l_output->output, output_x - hotspot_x,
|
wlr_output_move_cursor(l_output->output,
|
||||||
output_y - hotspot_y);
|
output_x - l_output->output->cursor.hotspot_x,
|
||||||
|
output_y - l_output->output->cursor.hotspot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->x = x;
|
cur->x = x;
|
||||||
|
|
|
@ -125,9 +125,11 @@ void wlr_output_transform(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_set_cursor(struct wlr_output *output,
|
bool wlr_output_set_cursor(struct wlr_output *output,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
|
||||||
|
int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
if (output->impl->set_cursor
|
if (output->impl->set_cursor
|
||||||
&& output->impl->set_cursor(output, buf, stride, width, height)) {
|
&& output->impl->set_cursor(output, buf, stride, width, height,
|
||||||
|
hotspot_x, hotspot_y)) {
|
||||||
output->cursor.is_sw = false;
|
output->cursor.is_sw = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -137,6 +139,8 @@ bool wlr_output_set_cursor(struct wlr_output *output,
|
||||||
output->cursor.is_sw = true;
|
output->cursor.is_sw = true;
|
||||||
output->cursor.width = width;
|
output->cursor.width = width;
|
||||||
output->cursor.height = height;
|
output->cursor.height = height;
|
||||||
|
output->cursor.hotspot_x = hotspot_x;
|
||||||
|
output->cursor.hotspot_y = hotspot_y;
|
||||||
|
|
||||||
if (!output->cursor.renderer) {
|
if (!output->cursor.renderer) {
|
||||||
/* NULL egl is okay given that we are only using pixel buffers */
|
/* NULL egl is okay given that we are only using pixel buffers */
|
||||||
|
|
Loading…
Reference in New Issue