ctl: Emit event when output is added/removed
parent
d819ca477c
commit
5d55944dab
|
@ -40,6 +40,8 @@ enum event_type {
|
||||||
EVT_CLIENT_CONNECTED,
|
EVT_CLIENT_CONNECTED,
|
||||||
EVT_CLIENT_DISCONNECTED,
|
EVT_CLIENT_DISCONNECTED,
|
||||||
EVT_DETACHED,
|
EVT_DETACHED,
|
||||||
|
EVT_OUTPUT_ADDED,
|
||||||
|
EVT_OUTPUT_REMOVED,
|
||||||
EVT_UNKNOWN,
|
EVT_UNKNOWN,
|
||||||
};
|
};
|
||||||
#define EVT_LIST_LEN EVT_UNKNOWN
|
#define EVT_LIST_LEN EVT_UNKNOWN
|
||||||
|
|
|
@ -89,3 +89,6 @@ void ctl_server_event_capture_changed(struct ctl*,
|
||||||
const char* captured_output);
|
const char* captured_output);
|
||||||
|
|
||||||
void ctl_server_event_detached(struct ctl*);
|
void ctl_server_event_detached(struct ctl*);
|
||||||
|
|
||||||
|
void ctl_server_event_output_added(struct ctl*, const char* name);
|
||||||
|
void ctl_server_event_output_removed(struct ctl*, const char* name);
|
||||||
|
|
|
@ -128,6 +128,20 @@ struct cmd_info ctl_event_list[] = {
|
||||||
"Sent after detaching from compositor",
|
"Sent after detaching from compositor",
|
||||||
{}
|
{}
|
||||||
},
|
},
|
||||||
|
[EVT_OUTPUT_ADDED] = {"output-added",
|
||||||
|
"Sent when an output is added by the compositor",
|
||||||
|
{
|
||||||
|
{ "name", "Output name", "<string>" },
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[EVT_OUTPUT_REMOVED] = {"output-removed",
|
||||||
|
"Sent when an output is removed by the compositor",
|
||||||
|
{
|
||||||
|
{ "name", "Output name", "<string>" },
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cmd_type ctl_command_parse_name(const char* name)
|
enum cmd_type ctl_command_parse_name(const char* name)
|
||||||
|
|
|
@ -1005,3 +1005,15 @@ void ctl_server_event_detached(struct ctl* self)
|
||||||
{
|
{
|
||||||
ctl_server_enqueue_event(self, EVT_DETACHED, json_object());
|
ctl_server_enqueue_event(self, EVT_DETACHED, json_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctl_server_event_output_added(struct ctl* self, const char* name)
|
||||||
|
{
|
||||||
|
ctl_server_enqueue_event(self, EVT_OUTPUT_ADDED,
|
||||||
|
json_pack("{s:s}", "name", name));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctl_server_event_output_removed(struct ctl* self, const char* name)
|
||||||
|
{
|
||||||
|
ctl_server_enqueue_event(self, EVT_OUTPUT_REMOVED,
|
||||||
|
json_pack("{s:s}", "name", name));
|
||||||
|
}
|
||||||
|
|
|
@ -240,7 +240,10 @@ static void registry_add(void* data, struct wl_registry* registry,
|
||||||
if (!self->is_initializing) {
|
if (!self->is_initializing) {
|
||||||
wl_display_dispatch(self->display);
|
wl_display_dispatch(self->display);
|
||||||
wl_display_roundtrip(self->display);
|
wl_display_roundtrip(self->display);
|
||||||
|
|
||||||
|
ctl_server_event_output_added(self->ctl, output->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +325,8 @@ static void registry_remove(void* data, struct wl_registry* registry,
|
||||||
} else
|
} else
|
||||||
nvnc_log(NVNC_LOG_INFO, "Output %s went away", out->name);
|
nvnc_log(NVNC_LOG_INFO, "Output %s went away", out->name);
|
||||||
|
|
||||||
|
ctl_server_event_output_removed(self->ctl, out->name);
|
||||||
|
|
||||||
wl_list_remove(&out->link);
|
wl_list_remove(&out->link);
|
||||||
output_destroy(out);
|
output_destroy(out);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue