From 181b165a4ba45eeedcd8d908b3e786b6ff7a1a35 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 25 Jul 2021 03:32:48 -0400 Subject: [PATCH] [client] egl: generate correct cursor damage with cursor rotation --- client/renderers/EGL/cursor.c | 38 +++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/client/renderers/EGL/cursor.c b/client/renderers/EGL/cursor.c index 164c4443..dba3dd69 100644 --- a/client/renderers/EGL/cursor.c +++ b/client/renderers/EGL/cursor.c @@ -296,12 +296,42 @@ struct CursorState egl_cursor_render(EGL_Cursor * cursor, LG_RendererRotate rota struct CursorState state = { .visible = true, - .rect.x = (pos.x * width + width) / 2, - .rect.y = (-pos.y * height + height) / 2 - size.h * height, - .rect.w = size.w * width + 2, - .rect.h = size.h * height + 2, }; + switch (rotate) + { + case LG_ROTATE_0: + state.rect.x = (pos.x * width + width) / 2; + state.rect.y = (-pos.y * height + height) / 2 - size.h * height; + state.rect.w = size.w * width + 2; + state.rect.h = size.h * height + 2; + break; + + case LG_ROTATE_90: + state.rect.x = (-pos.y * width + width) / 2 - size.h * width; + state.rect.y = (-pos.x * height + height) / 2 - size.w * height; + state.rect.w = size.h * width + 2; + state.rect.h = size.w * height + 2; + break; + + case LG_ROTATE_180: + state.rect.x = (-pos.x * width + width) / 2 - size.w * width; + state.rect.y = (pos.y * height + height) / 2; + state.rect.w = size.w * width + 2; + state.rect.h = size.h * height + 2; + break; + + case LG_ROTATE_270: + state.rect.x = (pos.y * width + width) / 2; + state.rect.y = (pos.x * height + height) / 2; + state.rect.w = size.h * width + 2; + state.rect.h = size.w * height + 2; + break; + + default: + assert(!"unreachable"); + } + glEnable(GL_BLEND); switch(cursor->type) {