Skip to content
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

Merged
merged 2 commits into from
Sep 15, 2022

Conversation

mikefhewitt
Copy link

Please see comments in issue #585

Copy link
Owner

@joewing joewing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
I think I'd want to change the way the allocation is done for the title bar and maybe the names (though I don't really have a strong opinion on those).

src/border.c Outdated
@@ -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));
Copy link
Owner

@joewing joewing Sep 15, 2022

Choose a reason for hiding this comment

The 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 sprintfs should probably be switched to snprintfs. I think I'd be more comfortable just allocating the right amount though, which is maybe a little error prone, but I think this would work:

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.

Copy link
Author

Choose a reason for hiding this comment

The 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

@@ -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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing all these typos!

jwm.1.in Outdated
.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
Copy link
Owner

@joewing joewing Sep 15, 2022

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?

Copy link
Author

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

Copy link
Author

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.

jwm.1.in Outdated
@@ -1279,6 +1291,13 @@ Possible values are \fBdesktop\fP and \fBall\fP. The default
is \fBdesktop\fP.
.RE
.P
.B killmenu
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be showkill?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change this also...

src/parse.c Outdated
temp = FindAttribute(tp->attributes, MN_DELIMITERS_ATTRIBUTE);
if(temp && strlen(temp)>=2) {
char *delims = calloc(strlen(temp)+1,sizeof(char));
sprintf(delims,"%s",temp);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would actually just declare settings.machineNameDelimiters as char machineNameDelimiters[2]; and just memcpy two characters here

@joewing
Copy link
Owner

joewing commented Sep 15, 2022

Looks great! Thanks!

@joewing joewing merged commit 8e80d21 into joewing:master Sep 15, 2022
@mikefhewitt
Copy link
Author

Thank you for adding these changes. Now I (hopefully) won't have to work with Openbox or Fluxbox any more...

@i2
Copy link

i2 commented Oct 20, 2022

@joewing Can you make a new release with this commit? It's been a while since previous one :) Thanks!

@joewing
Copy link
Owner

joewing commented Oct 22, 2022

Sure! I'll try to push out a release today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants