osd: update the default window switcher layout

The default window switcher layout is updated from:

  <windowSwitcher>
    <fields>
      <field content="type" width="25%" />
      <field content="trimmed_identifier" width="25%" />
      <field content="title" width="50%" />
    </fields>
  </windowSwitcher>

to:

  <windowSwitcher>
    <fields>
      <field content="icon" width="5%" />
      <field content="desktop_entry_name" width="30%" />
      <field content="title" width="65%" />
    </fields>
  </windowSwitcher>

Only desktop entry name and title are shown when libsfdo is not linked.
This commit is contained in:
tokyo4j 2025-03-31 12:20:30 +09:00 committed by Johan Malm
parent fdc8537eee
commit 44146487b2
3 changed files with 34 additions and 30 deletions

View file

@ -269,9 +269,9 @@ this is for compatibility with Openbox.
```
<windowSwitcher show="yes" preview="yes" outlines="yes" allWorkspaces="no">
<fields>
<field content="type" width="25%"/>
<field content="trimmed_identifier" width="25%"/>
<field content="title" width="50%"/>
<field content="icon" width="5%" />
<field content="desktop_entry_name" width="30%" />
<field content="title" width="65%" />
</fields>
</windowSwitcher>
```

View file

@ -70,24 +70,25 @@
</font>
</theme>
<!--
Just as for window-rules, 'identifier' relates to app_id for native Wayland
windows and WM_CLASS for XWayland clients.
-->
<windowSwitcher show="yes" preview="yes" outlines="yes" allWorkspaces="no">
<fields>
<field content="type" width="25%" />
<field content="trimmed_identifier" width="25%" />
<!-- <field content="identifier" width="25%" /> -->
<field content="title" width="50%" />
<field content="icon" width="5%" />
<field content="desktop_entry_name" width="30%" />
<field content="title" width="65%" />
<!--
Just as for window-rules, you can use 'identifier' or
'trimmed_identifier' to show the app_id for native wayland clients or
WM_CLASS for XWayland clients.
<field content="trimmed_identifier" width="65%" />
-->
</fields>
</windowSwitcher>
<!--
When using all workspaces option of window switcher, there are extra fields
that can be used, workspace (variable length), state (single space),
type_short (3 spaces), output (variable length), and can be set up
like this. Note: output only shows if more than one output available.
We support many other kinds of contents in the window switcher like below.
Some contents are fixed-length and others are variable-length.
See "man 5 labwc" for details.
<windowSwitcher show="yes" preview="no" outlines="no" allWorkspaces="yes">
<fields>
@ -102,12 +103,12 @@
custom format - (introduced in 0.7.2)
It allows one to replace all the above "fields" with one line, using a
printf style format. For field explanations, "man 5 labwc-config".
printf style format. For field explanations, see "man 5 labwc-config".
The example below would print "foobar",then type of window (wayland, X),
The example below would print "foobar", then type of window (wayland, X),
then state of window (M/m/F), then output (shows if more than 1 active),
then workspace name, then identifier/app-id, then the window title.
Uses 100% of OSD window width.
It uses 100% of OSD window width.
<windowSwitcher show="yes" preview="no" outlines="no" allWorkspaces="yes">
<fields>

View file

@ -1673,22 +1673,25 @@ deduplicate_key_bindings(void)
}
}
static struct {
enum window_switcher_field_content content;
int width;
} fields[] = {
{ LAB_FIELD_TYPE, 25 },
{ LAB_FIELD_TRIMMED_IDENTIFIER, 25 },
{ LAB_FIELD_TITLE, 50 },
{ LAB_FIELD_NONE, 0 },
};
static void
load_default_window_switcher_fields(void)
{
struct window_switcher_field *field;
static const struct {
enum window_switcher_field_content content;
int width;
} fields[] = {
#if HAVE_LIBSFDO
{ LAB_FIELD_ICON, 5 },
{ LAB_FIELD_DESKTOP_ENTRY_NAME, 30 },
{ LAB_FIELD_TITLE, 65 },
#else
{ LAB_FIELD_DESKTOP_ENTRY_NAME, 30 },
{ LAB_FIELD_TITLE, 70 },
#endif
};
for (int i = 0; fields[i].content != LAB_FIELD_NONE; i++) {
struct window_switcher_field *field;
for (size_t i = 0; i < ARRAY_SIZE(fields); i++) {
field = znew(*field);
field->content = fields[i].content;
field->width = fields[i].width;