hide titlebar buttons if that won't move other buttons
This commit is contained in:
parent
f806e7f24e
commit
a430d7d3c8
1 changed files with 95 additions and 41 deletions
136
openbox/frame.c
136
openbox/frame.c
|
@ -661,75 +661,129 @@ void frame_release_client(ObFrame *self, ObClient *client)
|
||||||
frame_free(self);
|
frame_free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* is there anything present between us and the label? */
|
||||||
|
static gboolean is_button_present(const gchar *lc, gint dir,
|
||||||
|
gboolean n, gboolean d, gboolean s,
|
||||||
|
gboolean i, gboolean m, gboolean c) {
|
||||||
|
for (lc += dir; *lc != '\0'; lc += dir) {
|
||||||
|
if (c == ' ') continue; /* it was invalid */
|
||||||
|
if (c == 'N' && n) return TRUE;
|
||||||
|
if (c == 'D' && d) return TRUE;
|
||||||
|
if (c == 'S' && s) return TRUE;
|
||||||
|
if (c == 'I' && i) return TRUE;
|
||||||
|
if (c == 'M' && m) return TRUE;
|
||||||
|
if (c == 'C' && c) return TRUE;
|
||||||
|
if (c == 'L') return FALSE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void layout_title(ObFrame *self)
|
static void layout_title(ObFrame *self)
|
||||||
{
|
{
|
||||||
gchar *lc;
|
gchar *lc;
|
||||||
gint x;
|
gint x;
|
||||||
gboolean n, d, i, l, m, c, s;
|
/* which ones the user asked for */
|
||||||
|
gboolean has_n, has_d, has_i, has_m, has_c, has_s;
|
||||||
|
/* which ones to include in titlebar */
|
||||||
|
gboolean n, d, i, m, c, s, l;
|
||||||
|
gboolean before_label;
|
||||||
|
const gint bwidth = ob_rr_theme->button_size + ob_rr_theme->paddingx + 1;
|
||||||
|
|
||||||
n = d = i = l = m = c = s = FALSE;
|
has_n = has_d = has_s = has_i = has_m = has_c = FALSE;
|
||||||
|
l = FALSE;
|
||||||
|
|
||||||
/* figure out whats being shown, and the width of the label */
|
/* figure out whats being shown, and the width of the label */
|
||||||
self->label_width = self->width - (ob_rr_theme->paddingx + 1) * 2;
|
self->label_width = self->width - (ob_rr_theme->paddingx + 1) * 2;
|
||||||
for (lc = config_title_layout; *lc != '\0'; ++lc) {
|
for (lc = config_title_layout; *lc != '\0'; ++lc) {
|
||||||
switch (*lc) {
|
switch (*lc) {
|
||||||
case 'N':
|
case 'N':
|
||||||
if (n) { *lc = ' '; break; } /* rm duplicates */
|
if (has_n) { *lc = ' '; break; } /* rm duplicates */
|
||||||
n = TRUE;
|
has_n = TRUE;
|
||||||
self->label_width -= (ob_rr_theme->button_size + 2 +
|
|
||||||
ob_rr_theme->paddingx + 1);
|
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
if (d) { *lc = ' '; break; }
|
if (has_d) { *lc = ' '; break; }
|
||||||
if (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS)
|
has_d = TRUE;
|
||||||
&& config_theme_hidedisabled)
|
|
||||||
break;
|
|
||||||
d = TRUE;
|
|
||||||
self->label_width -= (ob_rr_theme->button_size +
|
|
||||||
ob_rr_theme->paddingx + 1);
|
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (s) { *lc = ' '; break; }
|
if (has_s) { *lc = ' '; break; }
|
||||||
if (!(self->decorations & OB_FRAME_DECOR_SHADE)
|
has_s = TRUE;
|
||||||
&& config_theme_hidedisabled)
|
|
||||||
break;
|
|
||||||
s = TRUE;
|
|
||||||
self->label_width -= (ob_rr_theme->button_size +
|
|
||||||
ob_rr_theme->paddingx + 1);
|
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
if (i) { *lc = ' '; break; }
|
if (has_i) { *lc = ' '; break; }
|
||||||
if (!(self->decorations & OB_FRAME_DECOR_ICONIFY)
|
has_i = TRUE;
|
||||||
&& config_theme_hidedisabled)
|
|
||||||
break;
|
|
||||||
i = TRUE;
|
|
||||||
self->label_width -= (ob_rr_theme->button_size +
|
|
||||||
ob_rr_theme->paddingx + 1);
|
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
if (l) { *lc = ' '; break; }
|
if (l) { *lc = ' '; break; }
|
||||||
l = TRUE;
|
l = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
if (m) { *lc = ' '; break; }
|
if (has_m) { *lc = ' '; break; }
|
||||||
if (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE)
|
has_m = TRUE;
|
||||||
&& config_theme_hidedisabled)
|
|
||||||
break;
|
|
||||||
m = TRUE;
|
|
||||||
self->label_width -= (ob_rr_theme->button_size +
|
|
||||||
ob_rr_theme->paddingx + 1);
|
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
if (c) { *lc = ' '; break; }
|
if (has_c) { *lc = ' '; break; }
|
||||||
if (!(self->decorations & OB_FRAME_DECOR_CLOSE)
|
has_c = TRUE;
|
||||||
&& config_theme_hidedisabled)
|
break;
|
||||||
break;
|
default:
|
||||||
c = TRUE;
|
*lc = ' '; /* invalid */
|
||||||
self->label_width -= (ob_rr_theme->button_size +
|
|
||||||
ob_rr_theme->paddingx + 1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n = d = i = m = c = s = FALSE;
|
||||||
|
before_label = TRUE;
|
||||||
|
|
||||||
|
/* go through again and see which buttons can hide */
|
||||||
|
for (lc = config_title_layout; *lc != '\0'; ++lc) {
|
||||||
|
switch (*lc) {
|
||||||
|
case 'N':
|
||||||
|
n = has_n && (self->decorations & OB_FRAME_DECOR_ICON ||
|
||||||
|
is_button_present(lc, (before_label?1:-1),
|
||||||
|
has_n, has_d, has_s, has_i,
|
||||||
|
has_m, has_c));
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
d = has_d && (self->decorations & OB_FRAME_DECOR_ALLDESKTOPS ||
|
||||||
|
is_button_present(lc, (before_label?1:-1),
|
||||||
|
has_n, has_d, has_s, has_i,
|
||||||
|
has_m, has_c));
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
s = has_s && (self->decorations & OB_FRAME_DECOR_SHADE ||
|
||||||
|
is_button_present(lc, (before_label?1:-1),
|
||||||
|
has_n, has_d, has_s, has_i,
|
||||||
|
has_m, has_c));
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
i = has_i && (self->decorations & OB_FRAME_DECOR_ICONIFY ||
|
||||||
|
is_button_present(lc, (before_label?1:-1),
|
||||||
|
has_n, has_d, has_s, has_i,
|
||||||
|
has_m, has_c));
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
before_label = FALSE;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
m = has_m && (self->decorations & OB_FRAME_DECOR_MAXIMIZE ||
|
||||||
|
is_button_present(lc, (before_label?1:-1),
|
||||||
|
has_n, has_d, has_s, has_i,
|
||||||
|
has_m, has_c));
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
c = has_c && (self->decorations & OB_FRAME_DECOR_CLOSE ||
|
||||||
|
is_button_present(lc, (before_label?1:-1),
|
||||||
|
has_n, has_d, has_s, has_i,
|
||||||
|
has_m, has_c));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n) self->label_width -= bwidth + 2; /* icon gets extra padding */
|
||||||
|
if (d) self->label_width -= bwidth;
|
||||||
|
if (s) self->label_width -= bwidth;
|
||||||
|
if (i) self->label_width -= bwidth;
|
||||||
|
if (m) self->label_width -= bwidth;
|
||||||
|
if (c) self->label_width -= bwidth;
|
||||||
if (self->label_width < 1) self->label_width = 1;
|
if (self->label_width < 1) self->label_width = 1;
|
||||||
|
|
||||||
if (!n) XUnmapWindow(ob_display, self->icon);
|
if (!n) XUnmapWindow(ob_display, self->icon);
|
||||||
|
|
Loading…
Reference in a new issue