mirror of
https://github.com/labwc/labwc.git
synced 2026-04-11 08:21:13 -04:00
query: added "decoration" option
This commit is contained in:
parent
e0fa623d42
commit
9181ea1e6f
6 changed files with 38 additions and 9 deletions
|
|
@ -62,9 +62,10 @@ enum ssd_part_type {
|
|||
};
|
||||
|
||||
enum ssd_mode {
|
||||
LAB_SSD_MODE_INVALID,
|
||||
LAB_SSD_MODE_NONE,
|
||||
LAB_SSD_MODE_BORDER,
|
||||
LAB_SSD_MODE_FULL
|
||||
LAB_SSD_MODE_FULL,
|
||||
};
|
||||
|
||||
/* Forward declare arguments */
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ struct view_query {
|
|||
enum view_edge tiled;
|
||||
char *tiled_region;
|
||||
char *desktop;
|
||||
enum ssd_mode decoration;
|
||||
};
|
||||
|
||||
struct xdg_toplevel_view {
|
||||
|
|
|
|||
|
|
@ -378,7 +378,12 @@ action_arg_from_xml_node(struct action *action, const char *nodename, const char
|
|||
case ACTION_TYPE_SET_DECORATIONS:
|
||||
if (!strcmp(argument, "decorations")) {
|
||||
enum ssd_mode mode = ssd_mode_parse(content);
|
||||
action_arg_add_int(action, argument, mode);
|
||||
if (mode != LAB_SSD_MODE_INVALID) {
|
||||
action_arg_add_int(action, argument, mode);
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Invalid argument for action %s: '%s' (%s)",
|
||||
action_names[action->type], argument, content);
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
if (!strcasecmp(argument, "forceSSD")) {
|
||||
|
|
|
|||
|
|
@ -493,6 +493,8 @@ fill_action_query(char *nodename, char *content, struct action *action)
|
|||
current_view_query->tiled_region = xstrdup(content);
|
||||
} else if (!strcasecmp(nodename, "desktop")) {
|
||||
current_view_query->desktop = xstrdup(content);
|
||||
} else if (!strcasecmp(nodename, "decoration")) {
|
||||
current_view_query->decoration = ssd_mode_parse(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -350,14 +350,16 @@ enum ssd_mode
|
|||
ssd_mode_parse(const char *mode)
|
||||
{
|
||||
if (!mode) {
|
||||
return LAB_SSD_MODE_FULL;
|
||||
return LAB_SSD_MODE_INVALID;
|
||||
}
|
||||
if (!strcasecmp(mode, "none")) {
|
||||
return LAB_SSD_MODE_NONE;
|
||||
} else if (!strcasecmp(mode, "border")) {
|
||||
return LAB_SSD_MODE_BORDER;
|
||||
} else {
|
||||
} else if (!strcasecmp(mode, "full")) {
|
||||
return LAB_SSD_MODE_FULL;
|
||||
} else {
|
||||
return LAB_SSD_MODE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
28
src/view.c
28
src/view.c
|
|
@ -89,14 +89,20 @@ view_query_free(struct view_query *query)
|
|||
zfree(query);
|
||||
}
|
||||
|
||||
static enum three_state
|
||||
bool_to_tristate(bool b)
|
||||
{
|
||||
return b ? LAB_STATE_ENABLED : LAB_STATE_DISABLED;
|
||||
}
|
||||
|
||||
static enum three_state
|
||||
match_tristate(enum three_state desired, bool actual, enum three_state old_match)
|
||||
{
|
||||
switch (desired) {
|
||||
case LAB_STATE_ENABLED:
|
||||
return actual ? LAB_STATE_ENABLED : LAB_STATE_DISABLED;
|
||||
return bool_to_tristate(actual);
|
||||
case LAB_STATE_DISABLED:
|
||||
return actual ? LAB_STATE_DISABLED : LAB_STATE_ENABLED;
|
||||
return bool_to_tristate(!actual);
|
||||
default:
|
||||
return old_match;
|
||||
}
|
||||
|
|
@ -209,14 +215,26 @@ view_matches_query(struct view *view, struct view_query *query)
|
|||
|
||||
if (query->desktop) {
|
||||
if (!strcasecmp(query->desktop, "other")) {
|
||||
return strcasecmp(view->workspace->name,
|
||||
view->server->workspaces.current->name);
|
||||
struct workspace *current = view->server->workspaces.current;
|
||||
match = bool_to_tristate(strcasecmp(view->workspace->name, current->name));
|
||||
} else {
|
||||
// TODO: perhaps allow wrapping for "left" and "right" workspaces
|
||||
struct workspace *target =
|
||||
workspaces_find(view->server->workspaces.current,
|
||||
query->desktop, false);
|
||||
return target && !strcasecmp(view->workspace->name, target->name);
|
||||
match = bool_to_tristate(target &&
|
||||
!strcasecmp(view->workspace->name, target->name));
|
||||
}
|
||||
if (match == LAB_STATE_DISABLED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
enum ssd_mode decoration = view_get_ssd_mode(view);
|
||||
if (query->decoration != LAB_SSD_MODE_INVALID) {
|
||||
match = bool_to_tristate(query->decoration == decoration);
|
||||
if (match == LAB_STATE_DISABLED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue