From 882b31aeaa38084a521ee56881b94074246256e6 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 28 May 2018 11:39:19 +1000 Subject: [PATCH] [client] add support for masked colour cursors (fixes #61) Also allows early SDL usage for cursor and keyboard control before the host application starts --- client/main.c | 12 ++++++++++++ client/renderers/opengl.c | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/client/main.c b/client/main.c index 99d6e050..751ebe6e 100644 --- a/client/main.c +++ b/client/main.c @@ -899,7 +899,19 @@ int run() DEBUG_INFO("Waiting for host to signal it's ready..."); __sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART); while(state.running && (state.shm->flags & KVMFR_HEADER_FLAG_RESTART)) + { + SDL_Event event; + while(SDL_PollEvent(&event)) + { + if (event.type == SDL_QUIT) + { + if (!params.ignoreQuit) + state.running = false; + break; + } + } usleep(1000); + } DEBUG_INFO("Host ready, starting session"); // check the header's magic and version are valid diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index cc1f1a58..0838e87e 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -867,9 +867,26 @@ static void update_mouse_shape(struct Inst * this, bool * newShape) const int pitch = this->mousePitch; const uint8_t * data = this->mouseData; + // tmp buffer for masked colour + uint32_t tmp[width * height]; + this->mouseType = cursor; switch(cursor) { + case LG_CURSOR_MASKED_COLOR: + { + for(int i = 0; i < width * height; ++i) + { + const uint32_t c = ((uint32_t *)data)[i]; + tmp[i] = (c & ~0xFF000000) | (c & 0xFF000000 ? 0x0 : 0xFF000000); + } + data = (uint8_t *)tmp; + // fall through to LG_CURSOR_COLOR + // + // technically we should also create an XOR texture from the data but this + // usage seems very rare in modern software. + } + case LG_CURSOR_COLOR: { glBindTexture(GL_TEXTURE_2D, this->textures[MOUSE_TEXTURE]); @@ -974,12 +991,6 @@ static void update_mouse_shape(struct Inst * this, bool * newShape) glEndList(); break; } - - case LG_CURSOR_MASKED_COLOR: - { - //TODO - break; - } } this->mouseUpdate = true;