mirror of
https://github.com/labwc/labwc.git
synced 2026-03-17 05:33:47 -04:00
osd: add window-switcher field content types (#1623)
...`workspace`, `state`, `type_short` and `output`.
Example usage:
<windowSwitcher allWorkspaces="yes">
<fields>
<field content="workspace" width="5%" />
<field content="state" width="3%" />
<field content="type_short" width="3%" />
<field content="output" width="9%" />
<field content="identifier" width="30%" />
<field content="title" width="50%" />
</fields>
</windowSwitcher>
This commit is contained in:
parent
901240b321
commit
b0c2ac1a6d
5 changed files with 77 additions and 0 deletions
|
|
@ -216,6 +216,14 @@ this is for compatibility with Openbox.
|
||||||
|
|
||||||
- *title* Show window title if different to app_id
|
- *title* Show window title if different to app_id
|
||||||
|
|
||||||
|
- *workspace* Show workspace name
|
||||||
|
|
||||||
|
- *state* Show window state, M/m/F (max/min/full)
|
||||||
|
|
||||||
|
- *type_short* Show view type ("W" or "X")
|
||||||
|
|
||||||
|
- *output* Show output id, if more than one output detected
|
||||||
|
|
||||||
*width* defines the width of the field expressed as a percentage of
|
*width* defines the width of the field expressed as a percentage of
|
||||||
the overall window switcher width. The "%" character is required.
|
the overall window switcher width. The "%" character is required.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,24 @@
|
||||||
</fields>
|
</fields>
|
||||||
</windowSwitcher>
|
</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.
|
||||||
|
|
||||||
|
<windowSwitcher show="yes" preview="no" outlines="no" allWorkspaces="yes">
|
||||||
|
<fields>
|
||||||
|
<field content="workspace" width="5%" />
|
||||||
|
<field content="state" width="3%" />
|
||||||
|
<field content="type_short" width="3%" />
|
||||||
|
<field content="output" width="9%" />
|
||||||
|
<field content="identifier" width="30%" />
|
||||||
|
<field content="title" width="50%" />
|
||||||
|
</fields>
|
||||||
|
</windowSwitcher>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- edge strength is in pixels -->
|
<!-- edge strength is in pixels -->
|
||||||
<resistance>
|
<resistance>
|
||||||
<screenEdgeStrength>20</screenEdgeStrength>
|
<screenEdgeStrength>20</screenEdgeStrength>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ enum window_switcher_field_content {
|
||||||
LAB_FIELD_IDENTIFIER,
|
LAB_FIELD_IDENTIFIER,
|
||||||
LAB_FIELD_TRIMMED_IDENTIFIER,
|
LAB_FIELD_TRIMMED_IDENTIFIER,
|
||||||
LAB_FIELD_TITLE,
|
LAB_FIELD_TITLE,
|
||||||
|
LAB_FIELD_WORKSPACE,
|
||||||
|
LAB_FIELD_WIN_STATE,
|
||||||
|
LAB_FIELD_TYPE_SHORT,
|
||||||
|
LAB_FIELD_OUTPUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum view_placement_policy {
|
enum view_placement_policy {
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,14 @@ fill_window_switcher_field(char *nodename, char *content)
|
||||||
current_field->content = LAB_FIELD_TRIMMED_IDENTIFIER;
|
current_field->content = LAB_FIELD_TRIMMED_IDENTIFIER;
|
||||||
} else if (!strcmp(content, "title")) {
|
} else if (!strcmp(content, "title")) {
|
||||||
current_field->content = LAB_FIELD_TITLE;
|
current_field->content = LAB_FIELD_TITLE;
|
||||||
|
} else if (!strcmp(content, "workspace")) {
|
||||||
|
current_field->content = LAB_FIELD_WORKSPACE;
|
||||||
|
} else if (!strcmp(content, "state")) {
|
||||||
|
current_field->content = LAB_FIELD_WIN_STATE;
|
||||||
|
} else if (!strcmp(content, "type_short")) {
|
||||||
|
current_field->content = LAB_FIELD_TYPE_SHORT;
|
||||||
|
} else if (!strcmp(content, "output")) {
|
||||||
|
current_field->content = LAB_FIELD_OUTPUT;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(WLR_ERROR, "bad windowSwitcher field '%s'", content);
|
wlr_log(WLR_ERROR, "bad windowSwitcher field '%s'", content);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
39
src/osd.c
39
src/osd.c
|
|
@ -239,6 +239,20 @@ get_type(struct view *view)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_type_short(struct view *view)
|
||||||
|
{
|
||||||
|
switch (view->type) {
|
||||||
|
case LAB_XDG_SHELL_VIEW:
|
||||||
|
return "[W]";
|
||||||
|
#if HAVE_XWAYLAND
|
||||||
|
case LAB_XWAYLAND_VIEW:
|
||||||
|
return "[X]";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
get_app_id(struct view *view)
|
get_app_id(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -364,6 +378,31 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
|
||||||
case LAB_FIELD_TYPE:
|
case LAB_FIELD_TYPE:
|
||||||
buf_add(&buf, get_type(*view));
|
buf_add(&buf, get_type(*view));
|
||||||
break;
|
break;
|
||||||
|
case LAB_FIELD_TYPE_SHORT:
|
||||||
|
buf_add(&buf, get_type_short(*view));
|
||||||
|
break;
|
||||||
|
case LAB_FIELD_WORKSPACE:
|
||||||
|
buf_add(&buf, (*view)->workspace->name);
|
||||||
|
break;
|
||||||
|
case LAB_FIELD_WIN_STATE:
|
||||||
|
if ((*view)->maximized) {
|
||||||
|
buf_add(&buf, "M");
|
||||||
|
} else if ((*view)->minimized) {
|
||||||
|
buf_add(&buf, "m");
|
||||||
|
} else if ((*view)->fullscreen) {
|
||||||
|
buf_add(&buf, "F");
|
||||||
|
} else {
|
||||||
|
buf_add(&buf, " ");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LAB_FIELD_OUTPUT:
|
||||||
|
if (wl_list_length(&server->outputs) > 1 &&
|
||||||
|
output_is_usable((*view)->output)) {
|
||||||
|
buf_add(&buf, (*view)->output->wlr_output->name);
|
||||||
|
} else {
|
||||||
|
buf_add(&buf, " ");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case LAB_FIELD_IDENTIFIER:
|
case LAB_FIELD_IDENTIFIER:
|
||||||
buf_add(&buf, get_app_id(*view));
|
buf_add(&buf, get_app_id(*view));
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue