From 5c8dc9cb73be8b3fde25475dbc3e5f931f73f642 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Tue, 31 Oct 2017 12:42:08 -0600 Subject: Correct context menu placement if bar is bottom Originally the context menu would draw at the top of the screen, which is incorrect. --- include/swaybar/bar.h | 1 + swaybar/bar.c | 2 ++ swaybar/tray/tray.c | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 50d36e76..6f2a7083 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -21,6 +21,7 @@ struct bar { struct output { struct window *window; struct registry *registry; + struct output_state *state; list_t *workspaces; #ifdef ENABLE_TRAY list_t *items; diff --git a/swaybar/bar.c b/swaybar/bar.c index f12923a8..9cd17303 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -247,6 +247,8 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { /* set window height */ set_window_height(bar_output->window, bar->config->height); + + bar_output->state = output; } /* spawn status command */ spawn_status_cmd_proc(bar); diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c index e926faae..924ff1a0 100644 --- a/swaybar/tray/tray.c +++ b/swaybar/tray/tray.c @@ -432,9 +432,13 @@ err: return -1; } -void tray_mouse_event(struct output *output, int x, int y, +void tray_mouse_event(struct output *output, int rel_x, int rel_y, uint32_t button, uint32_t state) { + int x = rel_x; + int y = rel_y + (swaybar.config->position == DESKTOP_SHELL_PANEL_POSITION_TOP + ? 0 : (output->state->height - output->window->height)); + struct window *window = output->window; uint32_t tray_padding = swaybar.config->tray_padding; int tray_width = window->width * window->scale; -- cgit v1.2.3