Browse Source

Add uicb_infobar_toggle_hide (Closes #18)

David Delassus 12 years ago
parent
commit
10089601c1
5 changed files with 55 additions and 1 deletions
  1. 9 0
      src/client.h
  2. 3 0
      src/config.h
  3. 40 0
      src/infobar.c
  4. 2 0
      src/infobar.h
  5. 1 1
      src/wmfs.h

+ 9 - 0
src/client.h

@@ -211,4 +211,13 @@ client_get_larger(struct tag *t, bool ignoring_tag)
      return lc;
 }
 
+static inline void
+clients_layout_refresh(void)
+{
+     struct client *c;
+
+     SLIST_FOREACH(c, &W->h.client, next)
+          layout_fix_hole(c);
+}
+
 #endif /* CLIENT_H */

+ 3 - 0
src/config.h

@@ -88,6 +88,9 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
      { "status" ,        uicb_status },
      { "status_surface", uicb_status_surface },
 
+     /* Infobar */
+     { "infobar_toggle_hide", uicb_infobar_toggle_hide },
+
      /* Mouse */
      { "mouse_resize", uicb_mouse_resize },
      { "mouse_move",   uicb_mouse_move },

+ 40 - 0
src/infobar.c

@@ -515,8 +515,48 @@ infobar_free(struct screen *s)
      }
 }
 
+void
+uicb_infobar_toggle_hide(Uicb iname)
+{
+     struct infobar *i;
 
+     if (iname)
+          i = infobar_gb_name(iname);
+     else
+          i = SLIST_FIRST(&W->screen->infobars);
 
+     if(i->pos == BarHide)
+     {
+          i->pos = i->opos;
 
+          if(infobar_placement(i, i->pos))
+          {
+               barwin_map(i->bar);
+               barwin_map_subwin(i->bar);
+               barwin_refresh_color(i->bar);
+               infobar_refresh(i);
+          }
+     }
+     else
+     {
+          i->opos = i->pos;
+          i->pos = BarHide;
+
+          barwin_unmap_subwin(i->bar);
+          barwin_unmap(i->bar);
+
+          switch(i->opos)
+          {
+               case BarTop:
+                    i->screen->ugeo.y -= i->geo.h;
+               case BarBottom:
+                    i->screen->ugeo.h += i->geo.h;
+               case BarHide:
+               default:
+                    break;
+          }
+     }
 
+     clients_layout_refresh();
+}
 

+ 2 - 0
src/infobar.h

@@ -88,4 +88,6 @@ infobar_gb_name(const char *name)
      return SLIST_FIRST(&s->infobars);
 }
 
+void uicb_infobar_toggle_hide(Uicb iname);
+
 #endif /* INFOBAR_H */

+ 1 - 1
src/wmfs.h

@@ -151,7 +151,7 @@ struct infobar
      struct screen *screen;
      struct theme *theme;
      struct status_ctx statusctx;
-     enum barpos pos;
+     enum barpos opos, pos;
      char *elemorder;
      char *name;
      TAILQ_HEAD(esub, element) elements;