implement ext-idle-notify-v1
This commit is contained in:
36
src/call-idle-handler.c
Normal file
36
src/call-idle-handler.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <libguile.h>
|
||||
|
||||
#include "seat.h"
|
||||
#include "call-idle-handler.h"
|
||||
|
||||
static void *call_idle_handler_inner (void *data)
|
||||
{
|
||||
struct Call_idle_handler_parameters *params =
|
||||
(struct Call_idle_handler_parameters *)data;
|
||||
|
||||
SCM event;
|
||||
switch (params->event)
|
||||
{
|
||||
case IDLE: event = scm_from_utf8_symbol("idle"); break;
|
||||
case RESUME: event = scm_from_utf8_symbol("resume"); break;
|
||||
}
|
||||
|
||||
return scm_call_1(params->idle->handler, event);
|
||||
}
|
||||
|
||||
void *call_idle_handler (void *data)
|
||||
{
|
||||
/* Continuation barrier causes stack unwind on exceptions (i.e. errors
|
||||
* in the user defined ide handler) to stop here. Otherwise the entire
|
||||
* stack created by scm_with_guile() would be unwound. This makes
|
||||
* responding to exceptions nicer.
|
||||
*/
|
||||
SCM call_result = scm_c_with_continuation_barrier(
|
||||
call_idle_handler_inner, data
|
||||
);
|
||||
|
||||
if ( call_result == NULL )
|
||||
return (void *)"ERROR: An exception occured while calling the user-command handler.\n";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user