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

New Style syntax for finer-grained matching #1028

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/fvwm3_manpage_source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,16 @@ the newcomer.

=== Miscellaneous Commands

*Capabilities* [_option_ [_bool_]], ...::
This command enables features which are still experimental.
+
_FvwmStyleV3_ activates enhanced style matching whereby different aspects of
styles can be matched, for example:
+
....
Style (Class=XTerm, Name=mc) Sticky
....

*BugOpts* [_option_ [_bool_]], ...::
This command controls several workarounds for bugs in third party
programs. The individual options are separated by commas. The optional
Expand Down
46 changes: 46 additions & 0 deletions fvwm/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -3361,6 +3361,52 @@ void CMD_UnsetEnv(F_CMD_ARGS)
return;
}

void CMD_Capabilities(F_CMD_ARGS)
{
char *opt;
int toggle;
char *optstring;

while (action && *action && *action != '\n')
{
action = GetNextFullOption(action, &optstring);
if (!optstring)
{
/* no more options */
return;
}
toggle = ParseToggleArgument(
SkipNTokens(optstring,1), NULL, 2, False);
opt = PeekToken(optstring, NULL);
free(optstring);

if (!opt)
{
return;
}

if (StrEquals(opt, "FvwmStyleV3"))
{
switch (toggle)
{
case -1:
Scr.cap.fvwm_style_v3 ^= 1;
break;
case 0:
case 1:
Scr.cap.fvwm_style_v3 = toggle;
break;
default:
Scr.cap.fvwm_style_v3 = 0;
break;
}
} else {
fvwm_debug(__func__,
"Unknown capability '%s'", opt);
}
}
}

void CMD_BugOpts(F_CMD_ARGS)
{
char *opt;
Expand Down
2 changes: 2 additions & 0 deletions fvwm/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum
F_BUSY_CURSOR,
F_BUTTON_STATE,
F_BUTTON_STYLE,
F_CAPABILITIES,
F_CHANGE_MENUSTYLE,
F_CIRCULATE_DOWN,
F_CIRCULATE_UP,
Expand Down Expand Up @@ -216,6 +217,7 @@ void CMD_BugOpts(F_CMD_ARGS);
void CMD_BusyCursor(F_CMD_ARGS);
void CMD_ButtonState(F_CMD_ARGS);
void CMD_ButtonStyle(F_CMD_ARGS);
void CMD_Capabilities(F_CMD_ARGS);
void CMD_ChangeDecor(F_CMD_ARGS);
void CMD_ChangeMenuStyle(F_CMD_ARGS);
void CMD_CleanupColorsets(F_CMD_ARGS);
Expand Down
3 changes: 3 additions & 0 deletions fvwm/functable.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ const func_t func_table[] =
FUNC_DECOR, 0),
/* - Define a window button look (will be reworked) */

CMD_ENT("capabilities", CMD_Capabilities, F_CAPABILITIES, 0, 0),
/* - Define capabilities which can be changed at runtime */

CMD_ENT("changedecor", CMD_ChangeDecor, F_CHANGE_DECOR,
FUNC_NEEDS_WINDOW, CRS_SELECT),
/* - Attach decor to a window (will be obsolete) */
Expand Down
8 changes: 7 additions & 1 deletion fvwm/fvwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,18 @@ typedef struct style_flags

typedef struct style_id_t
{
char *name;
XID window_id;
char *name;
char *class;
char *resource;
char *icon;
struct
{
unsigned has_name:1;
unsigned has_window_id:1;
unsigned has_class:1;
unsigned has_resource:1;
unsigned has_icon:1;
} flags;
} style_id_t;

Expand Down
4 changes: 4 additions & 0 deletions fvwm/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ typedef struct ScreenInfo
unsigned do_debug_randr : 1;
} bo; /* bug workaround control options */
struct
{
unsigned fvwm_style_v3 : 1;
} cap; /* Capabilities. */
struct
{
unsigned do_emulate_mwm : 1;
unsigned do_emulate_win : 1;
Expand Down
16 changes: 10 additions & 6 deletions fvwm/style.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
/* ---------------------------- forward declarations ----------------------- */

static int style_set_border_colorset(window_style *, char *, int);
static char *parse_v3_style_id(char *, style_id_t *);

/* ---------------------------- local variables ---------------------------- */

Expand Down Expand Up @@ -4524,15 +4525,13 @@ static void _style_command(F_CMD_ARGS, char *prefix, Bool is_window_style)

if (!is_window_style)
{
/* parse style name */
action = GetNextToken(action, &SGET_NAME(*ps));
/* in case there was no argument! */
if (SGET_NAME(*ps) == NULL)
{
/* FIXME: capability check. */
action = parse_v3_style_id(action, &SGET_ID(*ps));
if (action == NULL) {
free(ps);
return;
}
SSET_ID_HAS_NAME(*ps, True);

}
else
{
Expand Down Expand Up @@ -4583,6 +4582,11 @@ static void _style_command(F_CMD_ARGS, char *prefix, Bool is_window_style)
return;
}

static char *parse_v3_style_id(char *action, style_id_t *r)
{
return action;
}

/* ---------------------------- interface functions ------------------------ */

/* Compare two flag structures passed as byte arrays. Only compare bits set in
Expand Down
14 changes: 13 additions & 1 deletion fvwm/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,18 @@
((id).flags.has_window_id = !!(x))
#define SID_GET_HAS_WINDOW_ID(id) \
((id).flags.has_window_id)
#define SID_GET_HAS_RESOURCE(id) \
((id).flags.has_resource)
#define SID_SET_HAS_RESOURCE(id,x) \
((id).flags.has_resource = (x))
#define SID_GET_HAS_CLASS(id) \
((id).flags.has_class)
#define SID_SET_HAS_CLASS(id,x) \
((id).flags.has_class = (x))
#define SID_GET_HAS_ICON(id) \
((id).flags.has_icon)
#define SID_SET_HAS_ICON(id,x) \
((id).flags.has_icon = (x))

/* access to other parts of a style (call with the style itself) */
#define SGET_NEXT_STYLE(s) \
Expand Down Expand Up @@ -679,4 +691,4 @@ void free_icon_boxes(icon_boxes *ib);
void style_destroy_style(style_id_t s_id);
void print_styles(int verbose);

#endif /* FVWM_STYLE_H */
#endif /* FVWM_STYLE_H */
Loading