1
1
Fork 0
mirror of https://github.com/swaywm/sway synced 2024-06-02 10:46:29 +02:00

Implement window_role criteria token

Depends on https://github.com/swaywm/wlroots/pull/1226
This commit is contained in:
Ryan Dwyer 2018-09-02 20:06:25 +10:00
parent 0b61bae8fb
commit 29f5cc7508
3 changed files with 28 additions and 7 deletions

View File

@ -170,6 +170,7 @@ struct sway_xwayland_view {
struct wl_listener request_activate;
struct wl_listener set_title;
struct wl_listener set_class;
struct wl_listener set_role;
struct wl_listener set_window_type;
struct wl_listener set_hints;
struct wl_listener map;

View File

@ -160,7 +160,10 @@ static bool criteria_matches_view(struct criteria *criteria,
}
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) {
@ -368,7 +371,7 @@ static char *get_focused_prop(enum criteria_token token) {
value = view_get_shell(view);
break;
case T_TITLE:
value = view_get_class(view);
value = view_get_title(view);
break;
case T_WORKSPACE:
{
@ -388,21 +391,21 @@ static char *get_focused_prop(enum criteria_token token) {
snprintf(id_str, id_size, "%zu", id);
value = id_str;
break;
case T_CON_MARK: // These do not support __focused__
case T_FLOATING:
#ifdef HAVE_XWAYLAND
case T_CLASS:
value = view_get_class(view);
break;
case T_ID:
case T_INSTANCE:
value = view_get_instance(view);
break;
case T_WINDOW_ROLE:
value = view_get_class(view);
value = view_get_window_role(view);
break;
case T_WINDOW_TYPE:
case T_WINDOW_TYPE: // These do not support __focused__
case T_ID:
#endif
case T_CON_MARK:
case T_FLOATING:
case T_TILING:
case T_URGENT:
case T_INVALID:

View File

@ -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;
case VIEW_PROP_INSTANCE:
return view->wlr_xwayland_surface->instance;
case VIEW_PROP_WINDOW_ROLE:
return view->wlr_xwayland_surface->role;
default:
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->set_title.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_hints.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);
}
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) {
struct sway_xwayland_view *xwayland_view =
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);
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,
&xwayland_view->set_window_type);
xwayland_view->set_window_type.notify = handle_set_window_type;