mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[client] implement stream paused alert
This commit is contained in:
parent
697dbc7a96
commit
60070e6076
@ -118,7 +118,7 @@ typedef void (* LG_RendererOnResize )(void * opaque, const int width,
|
||||
typedef bool (* LG_RendererOnMouseShape)(void * opaque, const LG_RendererCursor cursor, const int width, const int height, const int pitch, const uint8_t * data);
|
||||
typedef bool (* LG_RendererOnMouseEvent)(void * opaque, const bool visible , const int x, const int y);
|
||||
typedef bool (* LG_RendererOnFrameEvent)(void * opaque, const LG_RendererFormat format, const uint8_t * data);
|
||||
typedef void (* LG_RendererOnAlert )(void * opaque, const LG_RendererAlert alert, const char * message);
|
||||
typedef void (* LG_RendererOnAlert )(void * opaque, const LG_RendererAlert alert, const char * message, bool ** closeFlag);
|
||||
typedef bool (* LG_RendererRender )(void * opaque, SDL_Window *window);
|
||||
|
||||
typedef struct LG_Renderer
|
||||
|
@ -540,7 +540,8 @@ int eventFilter(void * userdata, SDL_Event * event)
|
||||
state.lgr->on_alert(
|
||||
state.lgrData,
|
||||
serverMode ? LG_ALERT_SUCCESS : LG_ALERT_WARNING,
|
||||
serverMode ? "Capture Enabled" : "Capture Disabled"
|
||||
serverMode ? "Capture Enabled" : "Capture Disabled",
|
||||
NULL
|
||||
);
|
||||
|
||||
if (!serverMode)
|
||||
@ -970,6 +971,7 @@ int run()
|
||||
break;
|
||||
}
|
||||
|
||||
bool *closeAlert = NULL;
|
||||
while(state.running)
|
||||
{
|
||||
SDL_Event event;
|
||||
@ -982,6 +984,29 @@ int run()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (closeAlert == NULL)
|
||||
{
|
||||
if (state.shm->flags & KVMFR_HEADER_FLAG_PAUSED)
|
||||
{
|
||||
if (state.lgr && !params.disableAlerts)
|
||||
state.lgr->on_alert(
|
||||
state.lgrData,
|
||||
LG_ALERT_WARNING,
|
||||
"Stream Paused",
|
||||
&closeAlert
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(state.shm->flags & KVMFR_HEADER_FLAG_PAUSED))
|
||||
{
|
||||
*closeAlert = true;
|
||||
closeAlert = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#define ALERT_TEXTURE 2
|
||||
#define TEXTURE_COUNT 3
|
||||
|
||||
#define ALERT_TIMEOUT_FLAG ((uint64_t)-1)
|
||||
|
||||
#define FADE_TIME 1000000
|
||||
|
||||
struct Options
|
||||
@ -63,9 +65,13 @@ static struct Options defaultOptions =
|
||||
|
||||
struct Alert
|
||||
{
|
||||
bool ready;
|
||||
bool useCloseFlag;
|
||||
|
||||
SDL_Surface *text;
|
||||
float r, g, b, a;
|
||||
uint64_t timeout;
|
||||
bool closeFlag;
|
||||
};
|
||||
|
||||
struct Inst
|
||||
@ -343,7 +349,7 @@ bool opengl_on_frame_event(void * opaque, const LG_RendererFormat format, const
|
||||
return true;
|
||||
}
|
||||
|
||||
void opengl_on_alert(void * opaque, const LG_RendererAlert alert, const char * message)
|
||||
void opengl_on_alert(void * opaque, const LG_RendererAlert alert, const char * message, bool ** closeFlag)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
struct Alert * a = malloc(sizeof(struct Alert));
|
||||
@ -388,6 +394,12 @@ void opengl_on_alert(void * opaque, const LG_RendererAlert alert, const char * m
|
||||
return;
|
||||
}
|
||||
|
||||
if (closeFlag)
|
||||
{
|
||||
a->useCloseFlag = true;
|
||||
*closeFlag = &a->closeFlag;
|
||||
}
|
||||
|
||||
ll_push(this->alerts, a);
|
||||
}
|
||||
|
||||
@ -534,7 +546,7 @@ bool opengl_render(void * opaque, SDL_Window * window)
|
||||
struct Alert * alert;
|
||||
while(ll_peek_head(this->alerts, (void **)&alert))
|
||||
{
|
||||
if (alert->timeout == 0)
|
||||
if (!alert->ready)
|
||||
{
|
||||
surface_to_texture(alert->text, this->textures[ALERT_TEXTURE]);
|
||||
|
||||
@ -566,17 +578,29 @@ bool opengl_render(void * opaque, SDL_Window * window)
|
||||
glDisable(GL_BLEND);
|
||||
glEndList();
|
||||
|
||||
if (!alert->useCloseFlag)
|
||||
alert->timeout = microtime() + 2*1000000;
|
||||
alert->ready = true;
|
||||
|
||||
SDL_FreeSurface(alert->text);
|
||||
alert->text = NULL;
|
||||
alert->ready = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool close = false;
|
||||
if (alert->useCloseFlag)
|
||||
close = alert->closeFlag;
|
||||
else if (alert->timeout < microtime())
|
||||
close = true;
|
||||
|
||||
if (close)
|
||||
{
|
||||
free(alert);
|
||||
ll_shift(this->alerts, NULL);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
Loading…
Reference in New Issue
Block a user