@ -35,6 +35,22 @@ struct ipc_client {
enum ipc_command_type subscribed_events ;
enum ipc_command_type subscribed_events ;
} ;
} ;
static struct modifier_key {
char * name ;
uint32_t mod ;
} modifiers [ ] = {
{ XKB_MOD_NAME_SHIFT , WLC_BIT_MOD_SHIFT } ,
{ XKB_MOD_NAME_CAPS , WLC_BIT_MOD_CAPS } ,
{ XKB_MOD_NAME_CTRL , WLC_BIT_MOD_CTRL } ,
{ " Ctrl " , WLC_BIT_MOD_CTRL } ,
{ XKB_MOD_NAME_ALT , WLC_BIT_MOD_ALT } ,
{ " Alt " , WLC_BIT_MOD_ALT } ,
{ XKB_MOD_NAME_NUM , WLC_BIT_MOD_MOD2 } ,
{ " Mod3 " , WLC_BIT_MOD_MOD3 } ,
{ XKB_MOD_NAME_LOGO , WLC_BIT_MOD_LOGO } ,
{ " Mod5 " , WLC_BIT_MOD_MOD5 } ,
} ;
struct sockaddr_un * ipc_user_sockaddr ( void ) ;
struct sockaddr_un * ipc_user_sockaddr ( void ) ;
int ipc_handle_connection ( int fd , uint32_t mask , void * data ) ;
int ipc_handle_connection ( int fd , uint32_t mask , void * data ) ;
int ipc_client_handle_readable ( int client_fd , uint32_t mask , void * data ) ;
int ipc_client_handle_readable ( int client_fd , uint32_t mask , void * data ) ;
@ -295,6 +311,8 @@ void ipc_client_handle_command(struct ipc_client *client) {
client - > subscribed_events | = IPC_EVENT_BARCONFIG_UPDATE ;
client - > subscribed_events | = IPC_EVENT_BARCONFIG_UPDATE ;
} else if ( strcmp ( event_type , " mode " ) = = 0 ) {
} else if ( strcmp ( event_type , " mode " ) = = 0 ) {
client - > subscribed_events | = IPC_EVENT_MODE ;
client - > subscribed_events | = IPC_EVENT_MODE ;
} else if ( strcmp ( event_type , " modifier " ) = = 0 ) {
client - > subscribed_events | = IPC_EVENT_MODIFIER ;
} else {
} else {
ipc_send_reply ( client , " { \" success \" : false} " , 18 ) ;
ipc_send_reply ( client , " { \" success \" : false} " , 18 ) ;
ipc_client_disconnect ( client ) ;
ipc_client_disconnect ( client ) ;
@ -617,3 +635,24 @@ void ipc_event_mode(const char *mode) {
json_object_put ( obj ) ; // free
json_object_put ( obj ) ; // free
}
}
void ipc_event_modifier ( uint32_t modifier , const char * state ) {
json_object * obj = json_object_new_object ( ) ;
json_object_object_add ( obj , " change " , json_object_new_string ( state ) ) ;
const char * modifier_name = NULL ;
int i ;
for ( i = 0 ; i < ( int ) ( sizeof ( modifiers ) / sizeof ( struct modifier_key ) ) ; + + i ) {
if ( modifiers [ i ] . mod = = modifier ) {
modifier_name = modifiers [ i ] . name ;
break ;
}
}
json_object_object_add ( obj , " modifier " , json_object_new_string ( modifier_name ) ) ;
const char * json_string = json_object_to_json_string ( obj ) ;
ipc_send_event ( json_string , IPC_EVENT_MODIFIER ) ;
json_object_put ( obj ) ; // free
}