Move title_format from window to container.

This patch moves the title_format information from windows to containers.
Furthermore, it allows correctly setting it on window-less containers and
displays the title accordingly for split containers.

We now also dump and read title_format in GET_TREE / during restarts.

fixes #2120
This commit is contained in:
Ingo Bürk
2015-12-29 12:01:51 -05:00
parent cd172da6ae
commit 1f660a4cc4
15 changed files with 188 additions and 113 deletions

View File

@ -433,3 +433,9 @@ char *con_get_tree_representation(Con *con);
*
*/
void con_force_split_parents_redraw(Con *con);
/**
* Returns the window title considering the current title format.
*
*/
i3String *con_parse_title_format(Con *con);

View File

@ -376,8 +376,6 @@ struct Window {
/** The name of the window. */
i3String *name;
/** The format with which the window's name should be displayed. */
char *title_format;
/** The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window
* sets "buddy list"). Useful to match specific windows in assignments or
@ -588,6 +586,9 @@ struct Con {
char *name;
/** The format with which the window's name should be displayed. */
char *title_format;
/* a sticky-group is an identifier which bundles several containers to a
* group. The contents are shared between all of them, that is they are
* displayed on whichever of the containers is currently visible */

View File

@ -504,6 +504,20 @@ char *get_config_path(const char *override_configpath, bool use_system_paths);
int mkdirp(const char *path, mode_t mode);
#endif
/** Helper structure for usage in format_placeholders(). */
typedef struct placeholder_t {
/* The placeholder to be replaced, e.g., "%title". */
char *name;
/* The value this placeholder should be replaced with. */
char *value;
} placeholder_t;
/**
* Replaces occurences of the defined placeholders in the format string.
*
*/
char *format_placeholders(char *format, placeholder_t *placeholders, int num);
#ifdef CAIRO_SUPPORT
/* We need to flush cairo surfaces twice to avoid an assertion bug. See #1989
* and https://bugs.freedesktop.org/show_bug.cgi?id=92455. */

View File

@ -20,7 +20,7 @@
if (pointer == NULL) \
die(__VA_ARGS__); \
}
#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)
#define STARTS_WITH(string, needle) (strncasecmp((string), (needle), strlen((needle))) == 0)
#define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? CIRCLEQ_NEXT(elm, field) : NULL)
#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? CIRCLEQ_PREV(elm, field) : NULL)
#define FOR_TABLE(workspace) \

View File

@ -81,10 +81,3 @@ void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *ur
*
*/
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style);
/**
* Returns the window title considering the current title format.
* If no format is set, this will simply return the window's name.
*
*/
i3String *window_parse_title_format(i3Window *win);