Implement window_role criteria token
Depends on https://github.com/swaywm/wlroots/pull/1226
This commit is contained in:
parent
0b61bae8fb
commit
29f5cc7508
|
@ -170,6 +170,7 @@ struct sway_xwayland_view {
|
||||||
struct wl_listener request_activate;
|
struct wl_listener request_activate;
|
||||||
struct wl_listener set_title;
|
struct wl_listener set_title;
|
||||||
struct wl_listener set_class;
|
struct wl_listener set_class;
|
||||||
|
struct wl_listener set_role;
|
||||||
struct wl_listener set_window_type;
|
struct wl_listener set_window_type;
|
||||||
struct wl_listener set_hints;
|
struct wl_listener set_hints;
|
||||||
struct wl_listener map;
|
struct wl_listener map;
|
||||||
|
|
|
@ -160,7 +160,10 @@ static bool criteria_matches_view(struct criteria *criteria,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria->window_role) {
|
if (criteria->window_role) {
|
||||||
// TODO
|
const char *role = view_get_window_role(view);
|
||||||
|
if (!role || regex_cmp(role, criteria->window_role) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria->window_type != ATOM_LAST) {
|
if (criteria->window_type != ATOM_LAST) {
|
||||||
|
@ -368,7 +371,7 @@ static char *get_focused_prop(enum criteria_token token) {
|
||||||
value = view_get_shell(view);
|
value = view_get_shell(view);
|
||||||
break;
|
break;
|
||||||
case T_TITLE:
|
case T_TITLE:
|
||||||
value = view_get_class(view);
|
value = view_get_title(view);
|
||||||
break;
|
break;
|
||||||
case T_WORKSPACE:
|
case T_WORKSPACE:
|
||||||
{
|
{
|
||||||
|
@ -388,21 +391,21 @@ static char *get_focused_prop(enum criteria_token token) {
|
||||||
snprintf(id_str, id_size, "%zu", id);
|
snprintf(id_str, id_size, "%zu", id);
|
||||||
value = id_str;
|
value = id_str;
|
||||||
break;
|
break;
|
||||||
case T_CON_MARK: // These do not support __focused__
|
|
||||||
case T_FLOATING:
|
|
||||||
#ifdef HAVE_XWAYLAND
|
#ifdef HAVE_XWAYLAND
|
||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
value = view_get_class(view);
|
value = view_get_class(view);
|
||||||
break;
|
break;
|
||||||
case T_ID:
|
|
||||||
case T_INSTANCE:
|
case T_INSTANCE:
|
||||||
value = view_get_instance(view);
|
value = view_get_instance(view);
|
||||||
break;
|
break;
|
||||||
case T_WINDOW_ROLE:
|
case T_WINDOW_ROLE:
|
||||||
value = view_get_class(view);
|
value = view_get_window_role(view);
|
||||||
break;
|
break;
|
||||||
case T_WINDOW_TYPE:
|
case T_WINDOW_TYPE: // These do not support __focused__
|
||||||
|
case T_ID:
|
||||||
#endif
|
#endif
|
||||||
|
case T_CON_MARK:
|
||||||
|
case T_FLOATING:
|
||||||
case T_TILING:
|
case T_TILING:
|
||||||
case T_URGENT:
|
case T_URGENT:
|
||||||
case T_INVALID:
|
case T_INVALID:
|
||||||
|
|
|
@ -154,6 +154,8 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
|
||||||
return view->wlr_xwayland_surface->class;
|
return view->wlr_xwayland_surface->class;
|
||||||
case VIEW_PROP_INSTANCE:
|
case VIEW_PROP_INSTANCE:
|
||||||
return view->wlr_xwayland_surface->instance;
|
return view->wlr_xwayland_surface->instance;
|
||||||
|
case VIEW_PROP_WINDOW_ROLE:
|
||||||
|
return view->wlr_xwayland_surface->role;
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -340,6 +342,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&xwayland_view->request_activate.link);
|
wl_list_remove(&xwayland_view->request_activate.link);
|
||||||
wl_list_remove(&xwayland_view->set_title.link);
|
wl_list_remove(&xwayland_view->set_title.link);
|
||||||
wl_list_remove(&xwayland_view->set_class.link);
|
wl_list_remove(&xwayland_view->set_class.link);
|
||||||
|
wl_list_remove(&xwayland_view->set_role.link);
|
||||||
wl_list_remove(&xwayland_view->set_window_type.link);
|
wl_list_remove(&xwayland_view->set_window_type.link);
|
||||||
wl_list_remove(&xwayland_view->set_hints.link);
|
wl_list_remove(&xwayland_view->set_hints.link);
|
||||||
wl_list_remove(&xwayland_view->map.link);
|
wl_list_remove(&xwayland_view->map.link);
|
||||||
|
@ -500,6 +503,17 @@ static void handle_set_class(struct wl_listener *listener, void *data) {
|
||||||
view_execute_criteria(view);
|
view_execute_criteria(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_set_role(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_xwayland_view *xwayland_view =
|
||||||
|
wl_container_of(listener, xwayland_view, set_role);
|
||||||
|
struct sway_view *view = &xwayland_view->view;
|
||||||
|
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
|
||||||
|
if (!xsurface->mapped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
view_execute_criteria(view);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_set_window_type(struct wl_listener *listener, void *data) {
|
static void handle_set_window_type(struct wl_listener *listener, void *data) {
|
||||||
struct sway_xwayland_view *xwayland_view =
|
struct sway_xwayland_view *xwayland_view =
|
||||||
wl_container_of(listener, xwayland_view, set_window_type);
|
wl_container_of(listener, xwayland_view, set_window_type);
|
||||||
|
@ -587,6 +601,9 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_class);
|
wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_class);
|
||||||
xwayland_view->set_class.notify = handle_set_class;
|
xwayland_view->set_class.notify = handle_set_class;
|
||||||
|
|
||||||
|
wl_signal_add(&xsurface->events.set_role, &xwayland_view->set_role);
|
||||||
|
xwayland_view->set_role.notify = handle_set_role;
|
||||||
|
|
||||||
wl_signal_add(&xsurface->events.set_window_type,
|
wl_signal_add(&xsurface->events.set_window_type,
|
||||||
&xwayland_view->set_window_type);
|
&xwayland_view->set_window_type);
|
||||||
xwayland_view->set_window_type.notify = handle_set_window_type;
|
xwayland_view->set_window_type.notify = handle_set_window_type;
|
||||||
|
|
Loading…
Reference in a new issue