[client] add support for masked colour cursors (fixes #61)

Also allows early SDL usage for cursor and keyboard control before
the host application starts
This commit is contained in:
Geoffrey McRae 2018-05-28 11:39:19 +10:00
parent 871aee2aae
commit 882b31aeaa
2 changed files with 29 additions and 6 deletions

View File

@ -899,7 +899,19 @@ int run()
DEBUG_INFO("Waiting for host to signal it's ready..."); DEBUG_INFO("Waiting for host to signal it's ready...");
__sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART); __sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART);
while(state.running && (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); usleep(1000);
}
DEBUG_INFO("Host ready, starting session"); DEBUG_INFO("Host ready, starting session");
// check the header's magic and version are valid // check the header's magic and version are valid

View File

@ -867,9 +867,26 @@ static void update_mouse_shape(struct Inst * this, bool * newShape)
const int pitch = this->mousePitch; const int pitch = this->mousePitch;
const uint8_t * data = this->mouseData; const uint8_t * data = this->mouseData;
// tmp buffer for masked colour
uint32_t tmp[width * height];
this->mouseType = cursor; this->mouseType = cursor;
switch(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: case LG_CURSOR_COLOR:
{ {
glBindTexture(GL_TEXTURE_2D, this->textures[MOUSE_TEXTURE]); glBindTexture(GL_TEXTURE_2D, this->textures[MOUSE_TEXTURE]);
@ -974,12 +991,6 @@ static void update_mouse_shape(struct Inst * this, bool * newShape)
glEndList(); glEndList();
break; break;
} }
case LG_CURSOR_MASKED_COLOR:
{
//TODO
break;
}
} }
this->mouseUpdate = true; this->mouseUpdate = true;