Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mouse button code in INFO environment varaible (#356) #358

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/bar_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,25 @@ void bar_item_on_drag(struct bar_item* bar_item, CGPoint point) {
}
}

void bar_item_on_click(struct bar_item* bar_item, uint32_t type, uint32_t modifier, CGPoint point) {
void bar_item_on_click(struct bar_item* bar_item, uint32_t type, uint32_t mouse_button_code, uint32_t modifier, CGPoint point) {
if (!bar_item) return;

char info_str[256];
snprintf(info_str, 256, "{\n"
"\t\"button\": \"%s\",\n"
"\t\"button_code\": %u,\n"
"\t\"modifier\": \"%s\",\n"
"\t\"modfier_code\": %u\n"
"}\n",
get_type_description(type),
mouse_button_code,
get_modifier_description(modifier),
modifier );

env_vars_set(&bar_item->signal_args.env_vars,
string_copy("INFO"),
string_copy(info_str) );

env_vars_set(&bar_item->signal_args.env_vars,
string_copy("BUTTON"),
string_copy(get_type_description(type)));
Expand Down
2 changes: 1 addition & 1 deletion src/bar_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool bar_item_is_shown(struct bar_item* bar_item);
void bar_item_needs_update(struct bar_item* bar_item);
bool bar_item_update(struct bar_item* bar_item, char* sender, bool forced, struct env_vars* env_vars);

void bar_item_on_click(struct bar_item* bar_item, uint32_t type, uint32_t modifier, CGPoint point);
void bar_item_on_click(struct bar_item* bar_item, uint32_t type, uint32_t mouse_button_code, uint32_t modifier, CGPoint point);
void bar_item_on_drag(struct bar_item* bar_item, CGPoint point);
void bar_item_mouse_entered(struct bar_item* bar_item);
void bar_item_mouse_exited(struct bar_item* bar_item);
Expand Down
3 changes: 2 additions & 1 deletion src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP) {
CGPoint point = CGEventGetLocation(context);
uint32_t wid = get_window_id_from_cg_event(context);
CGEventType type = CGEventGetType(context);
uint32_t mouse_button_code = CGEventGetIntegerValueField(context, kCGMouseEventButtonNumber);
uint32_t modifier_keys = CGEventGetFlags(context);
uint32_t adid = display_arrangement(display_active_display_id());

Expand All @@ -123,7 +124,7 @@ EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP) {
}
}

bar_item_on_click(bar_item, type, modifier_keys, point_in_window_coords);
bar_item_on_click(bar_item, type, mouse_button_code, modifier_keys, point_in_window_coords);

if (bar_item && bar_item->needs_update)
bar_manager_refresh(&g_bar_manager, false);
Expand Down