Skip to content

Commit

Permalink
style: add window-property matching
Browse files Browse the repository at this point in the history
Historically, window style matching relied on fvwm matching a windows
name or resource or class, etc., in a hard-coded order, with very little
means of being able to specify those properties.

With this change, it's now possible to specify the following attributes
a window should match against, either individually or in combination:

 - Resource
 - Class
 - Name
 - Icon
 - WindowID

For example:

  Style (Name foo, Class XTerm) Sticky

Would only make the window sticky if its name matched "foo", and its
class is "XTerm".

Existing style lines such as:

  Style foo Sticky

Still work as expected.

In addition, this change also removes the "PrintInfo style" command as
it is no longer useful with this change to styles.
  • Loading branch information
ThomasAdam committed Feb 6, 2025
1 parent ffce52d commit 05de703
Show file tree
Hide file tree
Showing 6 changed files with 566 additions and 311 deletions.
51 changes: 49 additions & 2 deletions doc/fvwm3_manpage_source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3451,8 +3451,6 @@ fvwm used. _verbose_ can be 1 or 2.
+
_nls_ which prints information on the locale catalogs that fvwm used
+
_style_ which prints information on fvwm styles. _verbose_ can be 1.
+
_bindings_ which prints information on all the bindings fvwm has: key
and mouse bindings. _verbose_ has no effect with this option.
+
Expand Down Expand Up @@ -4942,6 +4940,55 @@ For readability, the commands in this section are not sorted
alphabetically. The description of the *Style* command can be found at
the end of this section.

The commands: *FocusStyle*, *Style*, and *WindowStyle* can accept optional
conditional components to match some properties of a window.

For example:

....
Style (Name mc) Sticky
....

Will make a window whose name matched 'mc' _Sticky_.

....
Style (Name mc, Class XTerm) StartIconic
....

This example will start an xterm(1) window whose WM_CLASS matches 'XTerm' and
name is 'mc'.

A valid list of properties to test against are:

* Resource
* Class
* Name
* Icon
* WindowID

The matching of the properties specified for any *Style* line are ANDed
together, and for styles to be applied, *all* properties must match.

**NOTE**: To destroy a style line with window properties, *DestroyStyle*
should be used. For example:

....
DestroyStyle (Name mc, Class XTerm)
....

It is not required to specify the style arguments when destroying a style,
only the property components are required.

Existing *Style* lines in the form:

....
Style Application* Sticky, StartIconic
....

are still supported, and their behaviour remains unchanged.

'''

*FocusStyle* _stylename_ _options_::
works exactly like the *Style* command, but accepts only the focus
policy related styles beginning with "FP". The prefix can be removed,
Expand Down
4 changes: 0 additions & 4 deletions fvwm/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -2651,10 +2651,6 @@ void CMD_PrintInfo(F_CMD_ARGS)
{
FGettextPrintLocalePath(verbose);
}
else if (StrEquals(subject, "style"))
{
print_styles(verbose);
}
else if (StrEquals(subject, "ImageCache"))
{
PicturePrintImageCache(verbose);
Expand Down
29 changes: 23 additions & 6 deletions fvwm/fvwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,24 @@ typedef struct style_flags
unsigned initial_placement_done : 1;
} style_flags;

typedef struct style_id_flags
{
unsigned has_name:1;
unsigned has_window_id:1;
unsigned has_class:1;
unsigned has_resource:1;
unsigned has_icon:1;
unsigned is_compatibility_mode:1;
} style_id_flags;

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

typedef struct snap_attraction_t
Expand Down Expand Up @@ -679,6 +688,14 @@ typedef struct window_style
unsigned has_icon_title_format_string : 1;
} window_style;

typedef struct window_style_list
{
struct window_style_list *next;
style_id_t flags;
window_style *first_style;
window_style *last_style;
} window_style_list;

typedef struct window_g
{
rectangle frame;
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
Loading

0 comments on commit 05de703

Please sign in to comment.