harden app name passing

This commit is contained in:
Felix Kratz 2022-01-12 17:54:40 +01:00
parent aeb5771b87
commit bf82350f51
2 changed files with 7 additions and 3 deletions

View file

@ -396,7 +396,7 @@ void bar_manager_handle_mouse_exited(struct bar_manager* bar_manager) {
void bar_manager_handle_front_app_switch(struct bar_manager* bar_manager, char* info) {
struct env_vars env_vars;
env_vars_init(&env_vars);
env_vars_set(&env_vars, string_copy("INFO"), info);
if (info) env_vars_set(&env_vars, string_copy("INFO"), info);
bar_manager_custom_events_trigger(bar_manager, COMMAND_SUBSCRIBE_FRONT_APP_SWITCHED, &env_vars);
env_vars_destroy(&env_vars);
}

View file

@ -86,8 +86,12 @@ void workspace_create_custom_observer (void **context, char* notification) {
}
- (void)appSwitched:(NSNotification *)notification {
NSRunningApplication *app = [notification.userInfo objectForKey:NSWorkspaceApplicationKey];
struct event *event = event_create(&g_event_loop, APPLICATION_FRONT_SWITCHED, string_copy((char*)[[app localizedName] UTF8String]));
char* name = NULL;
if (notification && notification.userInfo) {
NSRunningApplication* app = [notification.userInfo objectForKey:NSWorkspaceApplicationKey];
if (app) name = string_copy((char*)[[app localizedName] UTF8String]);
}
struct event *event = event_create(&g_event_loop, APPLICATION_FRONT_SWITCHED, name);
event_loop_post(&g_event_loop, event);
}