$OpenBSD: patch-i3bar_src_xcb_c,v 1.8 2012/07/16 14:38:22 dcoppa Exp $

From 3daa3e052f2388f95ef525bdcb6cca840d4f9a32 Mon Sep 17 00:00:00 2001
From: Marcel Hellwig <keks@cookiesoft.de>
Date: Sun, 08 Jul 2012 19:31:34 +0000
Subject: Don't display empty strings from i3status in i3bar

From 599f7cc2a4ad0536759203cbdb03680389ae5e7b Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sun, 10 Jun 2012 19:04:51 +0000
Subject: i3bar: handle clicks with negative coordinates

From 4f93e0587a849de00a1f50bfcd48a549009178c0 Mon Sep 17 00:00:00 2001
From: TunnelWicht <MilkFreeze@web.de>
Date: Tue, 01 May 2012 11:35:34 +0000
Subject: don't wrap when changing workspaces by mouse wheel scrolling

From 8a3574f301725ba48484c05408e35ecec27aad65 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Tue, 10 Jul 2012 20:52:14 +0000
Subject: i3bar: inform _all_ clients of new tray selection owner

--- i3bar/src/xcb.c.orig	Wed Apr 25 23:21:25 2012
+++ i3bar/src/xcb.c	Mon Jul 16 16:30:28 2012
@@ -117,6 +117,9 @@ void refresh_statusline() {
     /* Convert all blocks from UTF-8 to UCS-2 and predict the text width (in
      * pixels). */
     TAILQ_FOREACH(block, &statusline_head, blocks) {
+        if (strlen(block->full_text) == 0)
+            continue;
+
         block->ucs2_full_text = (xcb_char2b_t*)convert_utf8_to_ucs2(block->full_text, &(block->glyph_count_full_text));
         block->width = predict_text_width((char*)block->ucs2_full_text, block->glyph_count_full_text, true);
         /* If this is not the last block, add some pixels for a separator. */
@@ -138,6 +141,9 @@ void refresh_statusline() {
     /* Draw the text of each block. */
     uint32_t x = 0;
     TAILQ_FOREACH(block, &statusline_head, blocks) {
+        if (strlen(block->full_text) == 0)
+            continue;
+
         uint32_t colorpixel = (block->color ? get_colorpixel(block->color) : colors.bar_fg);
         set_font_colors(statusline_ctx, colorpixel, colors.bar_bg);
         draw_text((char*)block->ucs2_full_text, block->glyph_count_full_text,
@@ -281,7 +287,7 @@ void handle_button(xcb_button_press_event_t *event) {
         return;
     }
 
-    int32_t x = event->event_x;
+    int32_t x = event->event_x >= 0 ? event->event_x : 0;
 
     DLOG("Got Button %d\n", event->detail);
 
@@ -302,17 +308,13 @@ void handle_button(xcb_button_press_event_t *event) {
             break;
         case 4:
             /* Mouse wheel down. We select the next ws */
-            if (cur_ws == TAILQ_FIRST(walk->workspaces)) {
-                cur_ws = TAILQ_LAST(walk->workspaces, ws_head);
-            } else {
+            if (cur_ws != TAILQ_FIRST(walk->workspaces)) {
                 cur_ws = TAILQ_PREV(cur_ws, ws_head, tailq);
             }
             break;
         case 5:
             /* Mouse wheel up. We select the previos ws */
-            if (cur_ws == TAILQ_LAST(walk->workspaces, ws_head)) {
-                cur_ws = TAILQ_FIRST(walk->workspaces);
-            } else {
+            if (cur_ws != TAILQ_LAST(walk->workspaces, ws_head)) {
                 cur_ws = TAILQ_NEXT(cur_ws, tailq);
             }
             break;
@@ -1046,7 +1048,7 @@ void init_tray() {
     xcb_send_event(xcb_connection,
                    0,
                    xcb_root,
-                   XCB_EVENT_MASK_STRUCTURE_NOTIFY,
+                   0xFFFFFF,
                    (char*)ev);
     free(event);
     free(tray_reply);
