-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added configuration options for issue #585 (kill menu, client name in title) #587
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1074,14 +1074,26 @@ that the value is relative to the bottom of the screen. | |
.B "WINDOW STYLE" | ||
.RS | ||
The \fBWindowStyle\fP tag controls the look of window borders. | ||
This tag supports the following attribute: | ||
This tag supports the following attributes: | ||
.P | ||
.B decorations | ||
.RS | ||
The window decorations to use. Valid options are \fBflat\fP and | ||
\fBmotif\fP. \fBflat\fP is the default. | ||
.RE | ||
.P | ||
.B machinename | ||
.RS | ||
Include the X client machine name (WM_CLIENT_MACHINE) in the window title. | ||
Valid options are \fBtrue\fP and \fBfalse\fP. \fBfalse\fP is the default. | ||
.RE | ||
.P | ||
.B delimiters | ||
.RS | ||
The two characters used to wrap the X client machine name in the window title. | ||
The default characters are \fB()\fP. | ||
.RE | ||
.P | ||
Within this tag, the following tags are supported: | ||
.P | ||
.B Font | ||
|
@@ -1257,7 +1269,7 @@ respectively. | |
.B "TASK LIST STYLE" | ||
.RS | ||
The \fBTaskListStyle\fP tag controls the look of task lists. | ||
The following attributea are supported: | ||
The following attributes are supported: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing all these typos! |
||
.P | ||
.B decorations | ||
.RS | ||
|
@@ -1279,6 +1291,13 @@ Possible values are \fBdesktop\fP and \fBall\fP. The default | |
is \fBdesktop\fP. | ||
.RE | ||
.P | ||
.B killmenu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will change this also... |
||
.RS | ||
Determines if the \fBKill\fP popup menu item is shown on task bars and | ||
window title bars. Possible values are \fBtrue\fP and \fBfalse\fP. The default | ||
is \fBtrue\fP. | ||
.RE | ||
.P | ||
Within this tag the following tags are supported: | ||
.P | ||
.B Font | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,7 +451,17 @@ void DrawBorderHelper(const ClientNode *np) | |
if(np->name && np->name[0] && point.x < point.y) { | ||
unsigned titleWidth = point.y - point.x; | ||
const int sheight = GetStringHeight(FONT_BORDER); | ||
const int textWidth = GetStringWidth(FONT_BORDER, np->name); | ||
const int buffSize = (MAX_TITLE_LENGTH+1)*sizeof(char); | ||
char *titleBuffer = calloc(MAX_TITLE_LENGTH+1,sizeof(char)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason behind a fixed length allocation? I suspect 512 is probably enough for most reasonable use-cases, but then the char *titleBuffer;
if(settings.showMachineName) {
/* Space for 2 delimiters, space, terminator, and strings */
const size_t bufSize = strlen(np->name) + strlen(np->machineName) + 4;
titleBuffer = Allocate(bufSize);
sprintf(titleBuffer, "%s %c%s%c", np->name,
settings.machineNameDelimiters[0], np->machineName,
settings.machineNameDelimiters[1]);
} else {
titleBuffer = CopyString(np->name);
}
...
Release(titleBuffer); Also, JWM has macros to wrap malloc/realloc/free (Allocate/Reallocate/Release), which I try to use to make it easy to check for memory leaks and buffer overruns. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will make the suggested changes and remove the MAX_TITLE_LENGTH define |
||
titleBuffer = memset(titleBuffer,'\0',buffSize); | ||
if (settings.showMachineName){ | ||
sprintf(titleBuffer,"%s %c%s%c",np->name, | ||
settings.machineNameDelimiters[0],np->machineName, | ||
settings.machineNameDelimiters[1]); | ||
} else { | ||
sprintf(titleBuffer,"%s",np->name); | ||
} | ||
const int textWidth = GetStringWidth(FONT_BORDER,titleBuffer); | ||
unsigned titlex, titley; | ||
int xoffset = 0; | ||
|
||
|
@@ -474,7 +484,8 @@ void DrawBorderHelper(const ClientNode *np) | |
titley += south - 1; | ||
} | ||
RenderString(canvas, FONT_BORDER, borderTextColor, | ||
titlex, titley, titleWidth, np->name); | ||
titlex, titley, titleWidth, titleBuffer); | ||
free(titleBuffer); | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,9 @@ static const char *DYNAMIC_ATTRIBUTE = "dynamic"; | |
static const char *SPACING_ATTRIBUTE = "spacing"; | ||
static const char *TIMEOUT_ATTRIBUTE = "timeout"; | ||
static const char *POPUP_ATTRIBUTE = "popup"; | ||
static const char *MACHINENAME_ATTRIBUTE = "machinename"; | ||
static const char *MN_DELIMITERS_ATTRIBUTE = "delimiters"; | ||
static const char *KILL_MENU_ATTRIBUTE = "killmenu"; | ||
|
||
static const char *FALSE_VALUE = "false"; | ||
static const char *TRUE_VALUE = "true"; | ||
|
@@ -998,6 +1001,19 @@ void ParseWindowStyle(const TokenNode *tp) | |
{ | ||
const TokenNode *np; | ||
|
||
const char *temp; | ||
temp = FindAttribute(tp->attributes, MACHINENAME_ATTRIBUTE); | ||
if(temp){ | ||
settings.showMachineName = !strcmp(temp,TRUE_VALUE); | ||
} | ||
|
||
temp = FindAttribute(tp->attributes, MN_DELIMITERS_ATTRIBUTE); | ||
if(temp && strlen(temp)>=2) { | ||
char *delims = calloc(strlen(temp)+1,sizeof(char)); | ||
sprintf(delims,"%s",temp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I would actually just declare |
||
settings.machineNameDelimiters = delims; | ||
} | ||
|
||
ParseDecorations(tp, &settings.windowDecorations); | ||
for(np = tp->subnodeHead; np; np = np->next) { | ||
switch(np->type) { | ||
|
@@ -1203,6 +1219,12 @@ void ParseTrayStyle(const TokenNode *tp, FontType font, ColorType fg) | |
if(temp) { | ||
settings.listAllTasks = !strcmp(temp, "all"); | ||
} | ||
|
||
temp = FindAttribute(tp->attributes, KILL_MENU_ATTRIBUTE); | ||
if(temp) { | ||
settings.showKillMenuItem = !strcmp(temp, TRUE_VALUE); | ||
} | ||
|
||
} else if(tp->type == TOK_TRAYSTYLE) { | ||
ParseDecorations(tp, &settings.trayDecorations); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of conflicted on the name. As is it sounds like you're setting the machine name. Even the code has showMachineName, but that's a little on the long side. Should it be named
showmachine
instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like showmachine better - will make the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I think the attribute should be showclient since it is based on the WM_CLIENT_MACHINE property.