- if (!event_is_release) {
- child_handle_button(event, walk, x);
+ const int tray_width = get_tray_width(walk->trayclients);
+ /* Calculate the horizontal coordinate (x) of the start of the
+ * statusline by subtracting its width and the width of the tray from
+ * the bar width. */
+ const int offset = walk->rect.w - walk->statusline_width -
+ tray_width - logical_px((tray_width > 0) * sb_hoff_px);
+ if (x >= offset) {
+ /* Click was after the start of the statusline, return to avoid
+ * executing any other actions even if a click event is not
+ * produced eventually. */
+
+ if (!event_is_release) {
+ /* x of the click event relative to the start of the
+ * statusline. */
+ const uint32_t statusline_x = x - offset;
+ child_handle_button(event, walk, statusline_x);
+ }
+
+ return;