From 3b7ccf394f6e224677b807701f99e1cdb5f10a19 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Tue, 18 Jan 2011 19:43:12 +0000 Subject: [PATCH] Merge diff from FS#24 to show window title in status bar from Dimitri Sokolyuk demon@dim13.org --- scrotwm.1 | 3 +++ scrotwm.c | 33 +++++++++++++++++++++++++++++++-- scrotwm.conf | 1 + scrotwm_es.1 | 3 +++ scrotwm_pt.1 | 3 +++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/scrotwm.1 b/scrotwm.1 index 02c73e0..71c63c5 100644 --- 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. diff --git a/scrotwm.c b/scrotwm.c index 6277dcb..02b3bae 100644 --- 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; diff --git a/scrotwm.conf b/scrotwm.conf index 3d7ba7b..b731bc0 100644 --- a/scrotwm.conf +++ b/scrotwm.conf @@ -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 diff --git a/scrotwm_es.1 b/scrotwm_es.1 index a2c6f43..8fe69bc 100644 --- a/scrotwm_es.1 +++ b/scrotwm_es.1 @@ -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. diff --git a/scrotwm_pt.1 b/scrotwm_pt.1 index afc7e06..50a3f88 100644 --- a/scrotwm_pt.1 +++ b/scrotwm_pt.1 @@ -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. -- 1.7.10.4