JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Merge diff from FS#24 to show window title in status bar
authorMarco Peereboom <marco@conformal.com>
Tue, 18 Jan 2011 19:43:12 +0000 (19:43 +0000)
committerMarco Peereboom <marco@conformal.com>
Tue, 18 Jan 2011 19:43:12 +0000 (19:43 +0000)
from Dimitri Sokolyuk demon@dim13.org

scrotwm.1
scrotwm.c
scrotwm.conf
scrotwm_es.1
scrotwm_pt.1

index 02c73e0..71c63c5 100644 (file)
--- a/scrotwm.1
+++ b/scrotwm.1
@@ -141,6 +141,9 @@ Enable by setting to 1
 .It Cm title_name_enabled
 Enable or disable displaying the window title in the status bar.
 Enable by setting to 1
+.It Cm window_name_enamed
+Enable or disable displaying the window name in the status bar.
+Enable by setting to 1
 .It Cm modkey
 Change mod key.
 Mod1 is generally the ALT key and Mod4 is the windows key on a PC.
index 6277dcb..02b3bae 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -208,6 +208,7 @@ int                 clock_enabled = 1;
 char                   *clock_format = NULL;
 int                    title_name_enabled = 0;
 int                    title_class_enabled = 0;
+int                    window_name_enabled = 0;
 int                    focus_mode = SWM_FOCUS_DEFAULT;
 int                    disable_border = 0;
 pid_t                  bar_pid;
@@ -1116,6 +1117,23 @@ out:
 }
 
 void
+bar_window_name(char *s, ssize_t sz, struct ws_win *cur_focus)
+{
+       char                    *title;
+
+       if (window_name_enabled && cur_focus != NULL) {
+               XFetchName(display, cur_focus->id, &title);
+               if (title) {
+                       if (cur_focus->floating)
+                               strlcat(s, "(f) ", sz);
+                       strlcat(s, title, sz);
+                       strlcat(s, " ", sz);
+                       XFree(title);
+               }
+       }
+}
+
+void
 bar_update(void)
 {
        time_t                  tmt;
@@ -1159,8 +1177,10 @@ bar_update(void)
                x = 1;
                TAILQ_FOREACH(r, &screens[i].rl, entry) {
                        strlcpy(cn, "", sizeof cn);
-                       if (r && r->ws)
+                       if (r && r->ws) {
                                bar_class_name(cn, sizeof cn, r->ws->focus);
+                               bar_window_name(cn, sizeof cn, r->ws->focus);
+                       }
 
                        if (stack_enabled)
                                stack = r->ws->cur_layout->name;
@@ -1827,6 +1847,9 @@ focus_win(struct ws_win *win)
                    ewmh[_NET_ACTIVE_WINDOW].atom, XA_WINDOW, 32,
                    PropModeReplace, (unsigned char *)&win->id,1);
        }
+
+       if (window_name_enabled)
+               bar_update();
 }
 
 void
@@ -3945,7 +3968,7 @@ setup_quirks(void)
 enum   { SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, SWM_S_STACK_ENABLED,
          SWM_S_CLOCK_ENABLED, SWM_S_CLOCK_FORMAT, SWM_S_CYCLE_EMPTY,
          SWM_S_CYCLE_VISIBLE, SWM_S_SS_ENABLED, SWM_S_TERM_WIDTH,
-         SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_NAME_ENABLED,
+         SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_NAME_ENABLED, SWM_S_WINDOW_NAME_ENABLED,
          SWM_S_FOCUS_MODE, SWM_S_DISABLE_BORDER, SWM_S_BAR_FONT,
          SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM, SWM_S_SS_APP, SWM_S_DIALOG_RATIO,
          SWM_S_BAR_AT_BOTTOM
@@ -3992,6 +4015,9 @@ setconfvalue(char *selector, char *value, int flags)
        case SWM_S_TITLE_CLASS_ENABLED:
                title_class_enabled = atoi(value);
                break;
+       case SWM_S_WINDOW_NAME_ENABLED:
+               window_name_enabled = atoi(value);
+               break;
        case SWM_S_TITLE_NAME_ENABLED:
                title_name_enabled = atoi(value);
                break;
@@ -4097,6 +4123,7 @@ struct config_option configopt[] = {
        { "spawn_term",                 setconfvalue,   SWM_S_SPAWN_TERM },
        { "screenshot_enabled",         setconfvalue,   SWM_S_SS_ENABLED },
        { "screenshot_app",             setconfvalue,   SWM_S_SS_APP },
+       { "window_name_enabled",        setconfvalue,   SWM_S_WINDOW_NAME_ENABLED },
        { "term_width",                 setconfvalue,   SWM_S_TERM_WIDTH },
        { "title_class_enabled",        setconfvalue,   SWM_S_TITLE_CLASS_ENABLED },
        { "title_name_enabled",         setconfvalue,   SWM_S_TITLE_NAME_ENABLED },
@@ -4873,6 +4900,8 @@ propertynotify(XEvent *e)
                XMoveResizeWindow(display, win->id,
                    win->g.x, win->g.y, win->g.w, win->g.h);
 #endif
+               if (window_name_enabled)
+                       bar_update();
                break;
        default:
                break;
index 3d7ba7b..b731bc0 100644 (file)
@@ -18,6 +18,7 @@ clock_enabled         = 1
 #clock_format          = %a %b %d %R %Z %Y
 title_name_enabled     = 0
 title_class_enabled    = 0
+window_name_enabled    = 0
 #focus_mode            = default
 #disable_border                = 1
 
index a2c6f43..8fe69bc 100644 (file)
@@ -144,6 +144,9 @@ Habilitado seteando 1
 .It Cm title_name_enabled
 Habilitar o deshabilita el titulo de la ventana en la barra de estado.
 Habilitado seteando 1
+.It Cm window_name_enabled
+Habilitar o deshabilita el nombre de la ventana en la barra de estado.
+Habilitado seteando 1
 .It Cm modkey
 Cambiar mod key.
 Mod1 generalmente es la tecla ALT y Mod4 la tecla de windows en una PC.
index afc7e06..50a3f88 100644 (file)
@@ -143,6 +143,9 @@ Habilite configurando para 1.
 .It Cm title_name_enabled
 Habilita ou desabilita mostrar o t\('itulo da janela na barra de status.
 Habilite configurando para 1.
+.It Cm window_name_enabled
+Habilita ou desabilita mostrar a nome da janela na barra de status.
+Habilite configurando para 1.
 .It Cm modkey
 Muda a tecla de modifica\(,c\(~ao.
 Mod1 \('e geralmente a tecla ALT e Mod4 \('e a tecla windows em um PC.