Просмотр исходного кода

dynamic changing of bar position

siduck76 3 лет назад
Родитель
Сommit
5cab27bccd
2 измененных файлов с 13 добавлено и 11 удалено
  1. 1 1
      chadwm/config.def.h
  2. 12 10
      chadwm/dwm.c

+ 1 - 1
chadwm/config.def.h

@@ -20,7 +20,7 @@ static const int showbar            = 1;        /* 0 means no bar */
 enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always };
 static const int showtab            = showtab_auto;
 static const int toptab             = True;
-static const int topbar             = 0;        /* 0 means bottom bar */
+static const int topbar             = 1;        /* 0 means bottom bar */
 static const int vertpad            = 10;       /* vertical padding of bar */
 static const int sidepad            = 10;       /* horizontal padding of bar */
 static const int horizpadbar        = 5;

+ 12 - 10
chadwm/dwm.c

@@ -2739,13 +2739,6 @@ void updatebarpos(Monitor *m) {
 
   m->wy = m->my;
   m->wh = m->mh;
-  if (m->showbar) {
-  m->wh = m->wh - vertpad - bh;
-  m->by = m->topbar ? m->wy + vertpad : m->wy + m->wh;
-  if (m->topbar)
-    	m->wy += bh + vertpad;
-  } else
-        m->by = -bh - vertpad;
   	
   for(c = m->clients; c; c = c->next) {
 		if(ISVISIBLE(c)) ++nvis;
@@ -2753,13 +2746,22 @@ void updatebarpos(Monitor *m) {
 
   if(m->showtab == showtab_always
 	   || ((m->showtab == showtab_auto) && (nvis > 1) && (m->lt[m->sellt]->arrange == monocle))) {
-         	m->wh -= th + ((topbar == toptab && m->showbar) ? 0 : vertpad) - gappov;
-		m->ty = m->toptab ? m->wy + ((topbar && m->showbar) ? 0 : vertpad) : m->wy + m->wh - gappov;
+    	  	m->topbar = !toptab;
+          	m->wh -= th + ((m->topbar == toptab && m->showbar) ? 0 : vertpad) - gappov;
+		m->ty = m->toptab ? m->wy + ((m->topbar && m->showbar) ? 0 : vertpad) : m->wy + m->wh - gappov;
 		if ( m->toptab )
-                   m->wy += th + ((topbar && m->showbar) ? 0 : vertpad) - gappov;
+                 m->wy += th + ((m->topbar && m->showbar) ? 0 : vertpad) - gappov;
 	} else {
             m->ty = -th - vertpad;
+            m->topbar = topbar;
    }
+   if (m->showbar) {
+  m->wh = m->wh - vertpad - bh;
+  m->by = m->topbar ? m->wy + vertpad : m->wy + m->wh;
+  if (m->topbar)
+	m->wy += bh + vertpad;
+  } else
+    m->by = -bh - vertpad;
 }
 
 void updateclientlist() {