X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=70aee79463e69f5fa3e9ce508b4c40f896ade0dd;hb=6392bc78077595ba35d63693a54ab66bb00e9077;hp=ae5fd0df916c0b404aa9050a980d3450b4c51dea;hpb=0aa96eda7c9a049f7b61929a99dcfd78f6ada624;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index ae5fd0d..70aee79 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -3,6 +3,7 @@ * Copyright (c) 2009 Marco Peereboom * Copyright (c) 2009 Ryan McBride * Copyright (c) 2009 Darrin Chandler + * Copyright (c) 2009 Pierre-Yves Ritschard * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -135,7 +136,7 @@ u_int32_t swm_debug = 0 #define SWM_PROPLEN (16) #define SWM_FUNCNAME_LEN (32) #define SWM_KEYS_LEN (255) -#define SWM_QUIRK_LEN (32) +#define SWM_QUIRK_LEN (64) #define X(r) (r)->g.x #define Y(r) (r)->g.y #define WIDTH(r) (r)->g.w @@ -182,6 +183,8 @@ int bar_extra_running = 0; int bar_verbose = 1; int bar_height = 0; int clock_enabled = 1; +int title_name_enabled = 0; +int title_class_enabled = 0; pid_t bar_pid; GC bar_gc; XGCValues bar_gcv; @@ -692,6 +695,12 @@ conf_load(char *filename) case 't': if (!strncmp(var, "term_width", strlen("term_width"))) term_width = atoi(val); + else if (!strncmp(var, "title_class_enabled", + strlen("title_class_enabled"))) + title_class_enabled = atoi(val); + else if (!strncmp(var, "title_name_enabled", + strlen("title_name_enabled"))) + title_name_enabled = atoi(val); else goto bad; break; @@ -756,6 +765,8 @@ bar_update(void) char s[SWM_BAR_MAX]; char loc[SWM_BAR_MAX]; char *b; + XClassHint *xch; + Status status; if (bar_enabled == 0) return; @@ -781,10 +792,28 @@ bar_update(void) localtime_r(&tmt, &tm); strftime(s, sizeof s, "%a %b %d %R %Z %Y ", &tm); } + xch = NULL; + if ((title_name_enabled == 1 || title_class_enabled == 1) && + cur_focus != NULL) { + if ((xch = XAllocClassHint()) == NULL) + goto out; + status = XGetClassHint(display, cur_focus->id, xch); + if (status == BadWindow || status == BadAlloc) + goto out; + if (title_class_enabled) + strlcat(s, xch->res_class, sizeof s); + if (title_name_enabled && title_class_enabled) + strlcat(s, ":", sizeof s); + if (title_name_enabled) + strlcat(s, xch->res_name, sizeof s); + } +out: + if (xch) + XFree(xch); for (i = 0; i < ScreenCount(display); i++) { x = 1; TAILQ_FOREACH(r, &screens[i].rl, entry) { - snprintf(loc, sizeof loc, "%d:%d %s%s %s", + snprintf(loc, sizeof loc, "%d:%d %s %s %s", x++, r->ws->idx + 1, s, bar_ext, bar_vertext); bar_print(r, loc); } @@ -2249,6 +2278,8 @@ parsekeys(char *keystr, unsigned int currmod, unsigned int *mod, KeySym *ks) *mod |= Mod4Mask; else if (strncasecmp(name, "SHIFT", SWM_MODNAME_SIZE) == 0) *mod |= ShiftMask; + else if (strncasecmp(name, "CONTROL", SWM_MODNAME_SIZE) == 0) + *mod |= ControlMask; else { *ks = XStringToKeysym(name); XConvertCase(*ks, ks, &uks);