Skip to content

Commit

Permalink
Merge pull request #631 from Taylor-Finch/master
Browse files Browse the repository at this point in the history
Implement Minimized window Style
  • Loading branch information
joewing authored Aug 1, 2024
2 parents 20a4d85 + 53dfe36 commit 63b2ff5
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 48 deletions.
4 changes: 4 additions & 0 deletions example.jwmrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
<Foreground>#FFFFFF</Foreground>
<Background>#555555</Background>
</Active>
<Minimized>
<Foreground>#FFFFFF</Foreground>
<Background>#111111</Background>
</Minimized>
<Foreground>#FFFFFF</Foreground>
<Background>#333333</Background>
</TaskListStyle>
Expand Down
27 changes: 27 additions & 0 deletions jwm.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,33 @@ two colors separated by a ':' to indicate the down and up colors
respectively.
.RE
.RE
.P
.B Minimized
.RS
The colors for the minimized items.
See the \fBCOLORS\fP section for more information.
The following tags are supported:
.P
.B Foreground
.RS
The foreground color for minimized items.
.RE
.P
.B Background
.RS
The background color for minimized items.
.RE
.P
.B Outline
.RS
The outline color for minimized items. See the \fBCOLORS\fP section for
more information.
The default is a darkened version of the background.
If \fBmotif\fP tray decorations are specified, this may be given as
two colors separated by a ':' to indicate the down and up colors
respectively.
.RE
.RE
.RE

.B "TRAY BUTTON STYLE"
Expand Down
8 changes: 8 additions & 0 deletions src/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ static void GetButtonColors(ButtonNode *bp, ColorType *fg, long *bg1, long *bg2,
*up = colors[COLOR_TASKLIST_ACTIVE_DOWN];
*decorations = settings.taskListDecorations;
break;
case BUTTON_TASK_MINIMIZED:
*fg = COLOR_TASKLIST_MINIMIZED_FG;
*bg1 = colors[COLOR_TASKLIST_MINIMIZED_BG1];
*bg2 = colors[COLOR_TASKLIST_MINIMIZED_BG2];
*down = colors[COLOR_TASKLIST_MINIMIZED_UP];
*up = colors[COLOR_TASKLIST_MINIMIZED_DOWN];
*decorations = settings.taskListDecorations;
break;
case BUTTON_MENU:
default:
*fg = COLOR_MENU_FG;
Expand Down
15 changes: 8 additions & 7 deletions src/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ struct IconNode;

/** Button types. */
typedef unsigned char ButtonType;
#define BUTTON_LABEL 0 /**< Label. */
#define BUTTON_MENU 1 /**< Menu item. */
#define BUTTON_MENU_ACTIVE 2 /**< Active menu item. */
#define BUTTON_TRAY 3 /**< Inactive tray button. */
#define BUTTON_TRAY_ACTIVE 4 /**< Active tray button. */
#define BUTTON_TASK 5 /**< Item in the task list. */
#define BUTTON_TASK_ACTIVE 6 /**< Active item in the task list. */
#define BUTTON_LABEL 0 /**< Label. */
#define BUTTON_MENU 1 /**< Menu item. */
#define BUTTON_MENU_ACTIVE 2 /**< Active menu item. */
#define BUTTON_TRAY 3 /**< Inactive tray button. */
#define BUTTON_TRAY_ACTIVE 4 /**< Active tray button. */
#define BUTTON_TASK 5 /**< Item in the task list. */
#define BUTTON_TASK_ACTIVE 6 /**< Active item in the task list. */
#define BUTTON_TASK_MINIMIZED 7 /**< Minimized item in the task list. */

/** Enumeration of button label positions. */
typedef unsigned char LabelPosition;
Expand Down
6 changes: 6 additions & 0 deletions src/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static XftColor *xftColors[COLOR_COUNT] = { NULL };
#define THEME_ACTIVE2 0x004488
#define THEME_INACTIVE 0x555555
#define THEME_INACTIVE2 0x333333
#define THEME_INACTIVE3 0x111111
#define THEME_OUTLINE 0x000000

static const DefaultColorNode DEFAULT_COLORS[] = {
Expand All @@ -63,6 +64,9 @@ static const DefaultColorNode DEFAULT_COLORS[] = {
{ COLOR_TASKLIST_ACTIVE_FG, THEME_TEXT },
{ COLOR_TASKLIST_ACTIVE_BG1, THEME_ACTIVE },
{ COLOR_TASKLIST_ACTIVE_BG2, THEME_ACTIVE },
{ COLOR_TASKLIST_MINIMIZED_FG, THEME_TEXT },
{ COLOR_TASKLIST_MINIMIZED_BG1, THEME_INACTIVE3 },
{ COLOR_TASKLIST_MINIMIZED_BG2, THEME_INACTIVE3 },

{ COLOR_TRAYBUTTON_FG, THEME_TEXT },
{ COLOR_TRAYBUTTON_BG1, THEME_INACTIVE },
Expand Down Expand Up @@ -137,6 +141,8 @@ static struct {
{ COLOR_TASKLIST_BG1, COLOR_TASKLIST_UP, COLOR_TASKLIST_DOWN },
{ COLOR_TASKLIST_ACTIVE_BG1,
COLOR_TASKLIST_ACTIVE_UP, COLOR_TASKLIST_ACTIVE_DOWN },
{ COLOR_TASKLIST_MINIMIZED_BG1,
COLOR_TASKLIST_MINIMIZED_UP, COLOR_TASKLIST_MINIMIZED_DOWN },
{ COLOR_TRAYBUTTON_BG1, COLOR_TRAYBUTTON_UP, COLOR_TRAYBUTTON_DOWN },
{ COLOR_TRAYBUTTON_ACTIVE_BG1,
COLOR_TRAYBUTTON_ACTIVE_UP, COLOR_TRAYBUTTON_ACTIVE_DOWN },
Expand Down
85 changes: 45 additions & 40 deletions src/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,51 @@ typedef unsigned char ColorType;
#define COLOR_TASKLIST_ACTIVE_FG 19
#define COLOR_TASKLIST_ACTIVE_BG1 20
#define COLOR_TASKLIST_ACTIVE_BG2 21
#define COLOR_TASKLIST_UP 22
#define COLOR_TASKLIST_DOWN 23
#define COLOR_TASKLIST_ACTIVE_UP 24
#define COLOR_TASKLIST_ACTIVE_DOWN 25
#define COLOR_TRAYBUTTON_FG 26
#define COLOR_TRAYBUTTON_BG1 27
#define COLOR_TRAYBUTTON_BG2 28
#define COLOR_TRAYBUTTON_ACTIVE_FG 29
#define COLOR_TRAYBUTTON_ACTIVE_BG1 30
#define COLOR_TRAYBUTTON_ACTIVE_BG2 31
#define COLOR_TRAYBUTTON_UP 32
#define COLOR_TRAYBUTTON_DOWN 33
#define COLOR_TRAYBUTTON_ACTIVE_UP 34
#define COLOR_TRAYBUTTON_ACTIVE_DOWN 35
#define COLOR_PAGER_BG 36
#define COLOR_PAGER_FG 37
#define COLOR_PAGER_ACTIVE_BG 38
#define COLOR_PAGER_ACTIVE_FG 39
#define COLOR_PAGER_OUTLINE 40
#define COLOR_PAGER_TEXT 41
#define COLOR_MENU_BG 42
#define COLOR_MENU_FG 43
#define COLOR_MENU_UP 44
#define COLOR_MENU_DOWN 45
#define COLOR_MENU_ACTIVE_BG1 46
#define COLOR_MENU_ACTIVE_BG2 47
#define COLOR_MENU_ACTIVE_FG 48
#define COLOR_MENU_ACTIVE_UP 49
#define COLOR_MENU_ACTIVE_DOWN 50
#define COLOR_POPUP_BG 51
#define COLOR_POPUP_FG 52
#define COLOR_POPUP_OUTLINE 53
#define COLOR_TITLE_UP 54
#define COLOR_TITLE_DOWN 55
#define COLOR_TITLE_ACTIVE_UP 56
#define COLOR_TITLE_ACTIVE_DOWN 57
#define COLOR_CLOCK_FG 58
#define COLOR_CLOCK_BG1 59
#define COLOR_CLOCK_BG2 60
#define COLOR_COUNT 61
#define COLOR_TASKLIST_MINIMIZED_FG 22
#define COLOR_TASKLIST_MINIMIZED_BG1 23
#define COLOR_TASKLIST_MINIMIZED_BG2 24
#define COLOR_TASKLIST_UP 25
#define COLOR_TASKLIST_DOWN 26
#define COLOR_TASKLIST_ACTIVE_UP 27
#define COLOR_TASKLIST_ACTIVE_DOWN 28
#define COLOR_TASKLIST_MINIMIZED_UP 29
#define COLOR_TASKLIST_MINIMIZED_DOWN 30
#define COLOR_TRAYBUTTON_FG 31
#define COLOR_TRAYBUTTON_BG1 32
#define COLOR_TRAYBUTTON_BG2 33
#define COLOR_TRAYBUTTON_ACTIVE_FG 34
#define COLOR_TRAYBUTTON_ACTIVE_BG1 35
#define COLOR_TRAYBUTTON_ACTIVE_BG2 36
#define COLOR_TRAYBUTTON_UP 37
#define COLOR_TRAYBUTTON_DOWN 38
#define COLOR_TRAYBUTTON_ACTIVE_UP 39
#define COLOR_TRAYBUTTON_ACTIVE_DOWN 40
#define COLOR_PAGER_BG 41
#define COLOR_PAGER_FG 42
#define COLOR_PAGER_ACTIVE_BG 43
#define COLOR_PAGER_ACTIVE_FG 44
#define COLOR_PAGER_OUTLINE 45
#define COLOR_PAGER_TEXT 46
#define COLOR_MENU_BG 47
#define COLOR_MENU_FG 48
#define COLOR_MENU_UP 49
#define COLOR_MENU_DOWN 50
#define COLOR_MENU_ACTIVE_BG1 51
#define COLOR_MENU_ACTIVE_BG2 52
#define COLOR_MENU_ACTIVE_FG 53
#define COLOR_MENU_ACTIVE_UP 54
#define COLOR_MENU_ACTIVE_DOWN 55
#define COLOR_POPUP_BG 56
#define COLOR_POPUP_FG 57
#define COLOR_POPUP_OUTLINE 58
#define COLOR_TITLE_UP 59
#define COLOR_TITLE_DOWN 60
#define COLOR_TITLE_ACTIVE_UP 61
#define COLOR_TITLE_ACTIVE_DOWN 62
#define COLOR_CLOCK_FG 63
#define COLOR_CLOCK_BG1 64
#define COLOR_CLOCK_BG2 65
#define COLOR_COUNT 66

extern unsigned long colors[COLOR_COUNT];

Expand Down
1 change: 1 addition & 0 deletions src/lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static const StringMappingType TOKEN_MAP[] = {
{ "Menu", TOK_MENU },
{ "MenuStyle", TOK_MENUSTYLE },
{ "Minimize", TOK_MINIMIZE },
{ "Minimized", TOK_MINIMIZED },
{ "Mouse", TOK_MOUSE },
{ "Move", TOK_MOVE },
{ "MoveMode", TOK_MOVEMODE },
Expand Down
1 change: 1 addition & 0 deletions src/lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef enum {
TOK_MENU,
TOK_MENUSTYLE,
TOK_MINIMIZE,
TOK_MINIMIZED,
TOK_MOUSE,
TOK_MOVE,
TOK_MOVEMODE,
Expand Down
43 changes: 43 additions & 0 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ static void ParseTrayStyle(const TokenNode *tp,
static void ParseActive(const TokenNode *tp, ColorType fg,
ColorType bg1, ColorType bg2,
ColorType up, ColorType down);
static void ParseMinimized(const TokenNode *tp, ColorType fg,
ColorType bg1, ColorType bg2,
ColorType up, ColorType down);
static void ParsePagerStyle(const TokenNode *tp);
static void ParseClockStyle(const TokenNode *tp);
static void ParseMenuStyle(const TokenNode *tp);
Expand Down Expand Up @@ -1206,10 +1209,15 @@ void ParseTrayStyle(const TokenNode *tp, FontType font, ColorType fg)
const ColorType activeFg = fg + COLOR_TRAY_ACTIVE_FG - COLOR_TRAY_FG;
const ColorType activeBg1 = fg + COLOR_TRAY_ACTIVE_BG1 - COLOR_TRAY_FG;
const ColorType activeBg2 = fg + COLOR_TRAY_ACTIVE_BG2 - COLOR_TRAY_FG;
const ColorType minimizedFg = fg + COLOR_TASKLIST_MINIMIZED_FG - COLOR_TASKLIST_FG;
const ColorType minimizedBg1 = fg + COLOR_TASKLIST_MINIMIZED_BG1 - COLOR_TASKLIST_FG;
const ColorType minimizedBg2 = fg + COLOR_TASKLIST_MINIMIZED_BG2 - COLOR_TASKLIST_FG;
const ColorType up = fg + COLOR_TRAY_UP - COLOR_TRAY_FG;
const ColorType down = fg + COLOR_TRAY_DOWN - COLOR_TRAY_FG;
const ColorType activeUp = fg + COLOR_TRAY_ACTIVE_UP - COLOR_TRAY_FG;
const ColorType activeDown = fg + COLOR_TRAY_ACTIVE_DOWN - COLOR_TRAY_FG;
const ColorType minimizedUp = fg + COLOR_TASKLIST_MINIMIZED_UP - COLOR_TASKLIST_FG;
const ColorType minimizedDown = fg + COLOR_TASKLIST_MINIMIZED_DOWN - COLOR_TASKLIST_FG;

/* TaskListStyle has extra attributes. */
if(tp->type == TOK_TASKLISTSTYLE) {
Expand Down Expand Up @@ -1242,6 +1250,9 @@ void ParseTrayStyle(const TokenNode *tp, FontType font, ColorType fg)
case TOK_ACTIVE:
ParseActive(np, activeFg, activeBg1, activeBg2, activeUp, activeDown);
break;
case TOK_MINIMIZED:
ParseMinimized(np, minimizedFg, minimizedBg1, minimizedBg2, minimizedUp, minimizedDown);
break;
case TOK_BACKGROUND:
ParseGradient(np->value, bg1, bg2);
break;
Expand Down Expand Up @@ -1297,6 +1308,38 @@ void ParseActive(const TokenNode *tp, ColorType fg,
}
}

/** Parse minimized tray style. */
void ParseMinimized(const TokenNode *tp, ColorType fg,
ColorType bg1, ColorType bg2,
ColorType up, ColorType down)
{
const TokenNode *np;

for(np = tp->subnodeHead; np; np = np->next) {
switch(np->type) {
case TOK_BACKGROUND:
if(bg1 == bg2) {
SetColor(bg1, np->value);
} else {
ParseGradient(np->value, bg1, bg2);
}
break;
case TOK_FOREGROUND:
SetColor(fg, np->value);
break;
case TOK_OUTLINE:
if(up != COLOR_COUNT) {
ParseGradient(np->value, down, up);
break;
}
/* fall through */
default:
InvalidTag(np, TOK_MINIMIZED);
break;
}
}
}

/** Parse tray. */
void ParseTray(const TokenNode *tp)
{
Expand Down
7 changes: 6 additions & 1 deletion src/taskbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,17 @@ void Render(const TaskBarType *bp)
const char flash = (cp->client->state.status & STAT_FLASH) != 0;
const char active = (cp->client->state.status & STAT_ACTIVE)
&& IsClientOnCurrentDesktop(cp->client);
const char minimized = (cp->client->state.status & STAT_MINIMIZED);
if(flash || active) {
if(button.type == BUTTON_TASK) {
if(button.type != BUTTON_TASK_ACTIVE) {
button.type = BUTTON_TASK_ACTIVE;
} else if(minimized) {
button.type = BUTTON_TASK_MINIMIZED;
} else {
button.type = BUTTON_TASK;
}
} else if(minimized) {
button.type = BUTTON_TASK_MINIMIZED;
}
clientCount += 1;
}
Expand Down

0 comments on commit 63b2ff5

Please sign in to comment.