Skip to content

Commit

Permalink
Add WindowName option to FvwmButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
NsCDE authored and ThomasAdam committed Sep 9, 2020
1 parent 297e1e4 commit 67bb1da
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/FvwmButtons/FvwmButtons.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ double quotes) for a transparent background.
Specifies the number of rows of buttons to be created. The default
is 2 rows.

.IP "*FvwmButtons: WindowName \fIname\fP"
If FvwmButtons has a titlebar enabled with Title style, (for example,
some transient subpanel), this option can set it's Window name and
Icon name to a string provided with this parameter. If omitted, default
for Window and Icon name is the window resource name which itself is
simply "FvwmButtons", or is derived from the alias by which FvwmButtons
configuration is referenced. This enables setting a title with spaces
and larger number of non-ASCII characters which is not allowed as an
alias for FvwmButtons module instance otherwise.

.IP "*FvwmButtons: (\fIoptions\fP) [\fItitle icon command\fP]"
Specifies the contents of a button in the buttonbox. The following
\fIoptions\fP, separated by commas or whitespace, can be given a
Expand Down
25 changes: 25 additions & 0 deletions modules/FvwmButtons/FvwmButtons.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Bool do_allow_bad_access = False;
Bool was_bad_access = False;
Bool swallowed = False;
Window swallower_win = 0;
char windowname[128];

/* ------------------------------ Misc functions ----------------------------*/

Expand Down Expand Up @@ -847,6 +848,11 @@ int main(int argc, char **argv)
* indent buttons correctly */
SendText(fd, "Send_WindowList", 0);

if (UberButton->c->flags.b_WindowName == 1)
{
change_window_name(windowname);
}

#ifdef DEBUG_INIT
fvwm_debug(__func__, "OK\n%s: Startup complete\n", MyName);
#endif
Expand Down Expand Up @@ -3420,3 +3426,22 @@ void exec_swallow(char *action, button_info *b)
SendText(fd, cmd, 0);
free(cmd);
}

/*
* Change the window name displayed in the title bar.
* Helper function borrowed from FvwmIdent for
* WindowName FvwmButtons functionality
*/
void change_window_name(char *str)
{
XTextProperty name;

if (XStringListToTextProperty(&str, 1, &name) == 0)
{
fprintf(stderr,"FvwmButtons: cannot allocate window name");
return;
}
XSetWMName(Dpy, MyWindow, &name);
XSetWMIconName(Dpy, MyWindow, &name);
XFree(name.value);
}
3 changes: 3 additions & 0 deletions modules/FvwmButtons/FvwmButtons.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef struct
unsigned b_PressIcon : 1; /* Use alternate Icon on press */
unsigned b_PressColorset : 1; /* Use alternate Colorset on press */
unsigned b_PressTitle : 1; /* Use alternate Title text on press */
unsigned b_WindowName : 1; /* Use alternate Window and Icon name */
} flags_type;

/* Flags for b->swallow */
Expand Down Expand Up @@ -240,6 +241,7 @@ void exec_swallow(char *action, button_info *b);

char *GetButtonAction(button_info*,int);
void ButtonPressProcess(button_info *b, char **act);
void change_window_name(char *str);

/* ----------------------------- global variables -------------------------- */

Expand All @@ -257,6 +259,7 @@ extern int new_desk;
extern GC NormalGC;
extern GC ShadowGC;
extern FlocaleWinString *FwinString;
extern char windowname[128];

/* ---------------------------------- misc --------------------------------- */

21 changes: 21 additions & 0 deletions modules/FvwmButtons/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,7 @@ static void ParseConfigLine(button_info **ubb, char *s)
"colorset",
"activecolorset",
"presscolorset",
"windowname",
NULL
};
int i, j, k;
Expand Down Expand Up @@ -1933,6 +1934,26 @@ static void ParseConfigLine(button_info **ubb, char *s)
}
break;

case 15: /* WindowName */
{
i = sscanf(s, "%126[^\n]", windowname);
if (i > 0)
{
ub->c->flags.b_WindowName = 1;
}
else
{
ub->c->flags.b_WindowName = 0;
}
#ifdef DEBUG_PARSER
if (windowname == 0)
{
fprintf(stderr, "%s\n", windowname);
}
#endif
break;
}

default:
s = trimleft(s);
ParseButton(ubb, s);
Expand Down

0 comments on commit 67bb1da

Please sign in to comment.