mlvwm icon indicating copy to clipboard operation
mlvwm copied to clipboard

`Style` commands don't search `WM_WINDOW_ROLE` X window properties

Open morgant opened this issue 1 year ago • 1 comments

It doesn't appear that the built-in Style command appname string (which accepts '*' & '?' wildcards; see mlvwm(1) manual page) can match against the WM_WINDOW_ROLE X window property. I believe it currently only matches against WM_CLASS or WM_NAME.

There are many X11 applications that have different types of windows which should have different styles, including the menu bar itself as well as various window features. For example, Claws Mail has WM_CLASS(STRING) = "claws-mail", "Claws-mail" set on all windows, but the WM_WINDOW_ROLE differs by the various window types:

  • The main account/mailbox view has WM_WINDOW_ROLE(STRING) = "mainwindow"
  • A new message has WM_WINDOW_ROLE(STRING) = "compose"
  • Opening an existing message has WM_WINDOW_ROLE(STRING) = "messageview"

A window with a mainwindow role should have different menu bar options than messageview or compose. So, it'd be very helpful to be able to define multiple Style commands for the same WM_CLASS, but differing WM_WINDOW_ROLE.


It appears that WM_WINDOW_ROLE is part of the ICCCM specification, see section 5. Session Management.

morgant avatar Mar 04 '24 20:03 morgant

Looking at this again for another mlvwmrc issue and wanted to note the following for future me:

  • Parsing of Style ... END configuration blocks is implemented in config.c's SetStyles(). Each line's parsing includes:
    • The first quoted portion of the line is used as the Style name (including * & ? wildcard characters) and either:
      • Scr.style_list is searched for an existing style with name and the matching style is used
      • If one isn't found, a new style is created with the name and appended to the Scr.style_list linked list
    • The rest of the comma-separated options are parsed and the appropriate function will be executed for the style
  • Styles are destroyed in config.c's FreeStyles()
  • add_window.c's lookupstyles() searches Scr.style_list for matching name (using matchWildcards() to support * & ? wildcard characters), returning the style where any of the following match:
    1. Matches against the window name
    2. If the window has a class (an XClassHint), it then matches: a. class->res_name b. class->res_class
  • add_window.c's AddWindow() uses lookupstyles() to find the matching style, then applies the Style's configuration to the window

morgant avatar Sep 30 '24 20:09 morgant