diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/output.c | 13 | ||||
-rw-r--r-- | sway/input/input-manager.c | 1 | ||||
-rw-r--r-- | sway/input/seat.c | 2 | ||||
-rw-r--r-- | sway/ipc-json.c | 23 | ||||
-rw-r--r-- | sway/tree/output.c | 15 | ||||
-rw-r--r-- | sway/tree/workspace.c | 10 |
6 files changed, 42 insertions, 22 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index ed9300bb..4d6c0336 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -39,6 +39,19 @@ struct sway_output *output_by_name(const char *name) { return NULL; } +struct sway_output *output_by_identifier(const char *identifier) { + for (int i = 0; i < root->outputs->length; ++i) { + struct sway_output *output = root->outputs->items[i]; + char output_identifier[128]; + snprintf(output_identifier, sizeof(output_identifier), "%s %s %s", output->wlr_output->make, + output->wlr_output->model, output->wlr_output->serial); + if (strcasecmp(output_identifier, identifier) == 0) { + return output; + } + } + return NULL; +} + /** * Rotate a child's position relative to a parent. The parent size is (pw, ph), * the child position is (*sx, *sy) and its size is (sw, sh). diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 91c45dd1..68445d68 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -431,6 +431,7 @@ void input_manager_set_focus(struct sway_node *node) { struct sway_seat *seat; wl_list_for_each(seat, &server.input->seats, link) { seat_set_focus(seat, node); + seat_consider_warp_to_focus(seat); } } diff --git a/sway/input/seat.c b/sway/input/seat.c index 9d4dc7af..64419afa 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -948,7 +948,7 @@ struct sway_node *seat_get_focus(struct sway_seat *seat) { if (!seat->has_focus) { return NULL; } - if (wl_list_length(&seat->focus_stack) == 0) { + if (wl_list_empty(&seat->focus_stack)) { return NULL; } struct sway_seat_node *current = diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 2cd0cb2d..5c9b3e5a 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -229,10 +229,6 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object_object_add(object, "app_id", app_id ? json_object_new_string(app_id) : NULL); - const char *class = view_get_class(c->view); - json_object_object_add(object, "class", - class ? json_object_new_string(class) : NULL); - json_object *marks = json_object_new_array(); list_t *view_marks = c->view->marks; for (int i = 0; i < view_marks->length; ++i) { @@ -269,13 +265,17 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object *window_props = json_object_new_object(); - json_object_object_add(window_props, "class", - class ? json_object_new_string(class) : NULL); + const char *class = view_get_class(c->view); + if (class) { + json_object_object_add(window_props, "class", json_object_new_string(class)); + } const char *instance = view_get_instance(c->view); - json_object_object_add(window_props, "instance", - instance ? json_object_new_string(instance) : NULL); - json_object_object_add(window_props, "title", - c->title ? json_object_new_string(c->title) : NULL); + if (instance) { + json_object_object_add(window_props, "instance", json_object_new_string(instance)); + } + if (c->title) { + json_object_object_add(window_props, "title", json_object_new_string(c->title)); + } // the transient_for key is always present in i3's output uint32_t parent_id = view_get_x11_parent_id(c->view); @@ -284,8 +284,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object const char *role = view_get_window_role(c->view); if (role) { - json_object_object_add(window_props, "window_role", - json_object_new_string(role)); + json_object_object_add(window_props, "window_role", json_object_new_string(role)); } json_object_object_add(object, "window_properties", window_props); diff --git a/sway/tree/output.c b/sway/tree/output.c index 9d523997..632501e1 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -65,7 +65,14 @@ void output_enable(struct sway_output *output, struct output_config *oc) { return; } struct wlr_output *wlr_output = output->wlr_output; + size_t len = sizeof(output->layers) / sizeof(output->layers[0]); + for (size_t i = 0; i < len; ++i) { + wl_list_init(&output->layers[i]); + } + wl_signal_init(&output->events.destroy); + output->enabled = true; + apply_output_config(oc, output); list_add(root->outputs, output); output->lx = wlr_output->lx; @@ -91,14 +98,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) { ipc_event_workspace(NULL, ws, "init"); } - size_t len = sizeof(output->layers) / sizeof(output->layers[0]); - for (size_t i = 0; i < len; ++i) { - wl_list_init(&output->layers[i]); - } - wl_signal_init(&output->events.destroy); - - apply_output_config(oc, output); - input_manager_configure_xcursor(); wl_signal_add(&wlr_output->events.mode, &output->mode); diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 27e9ac7a..05cda5c0 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -35,6 +35,10 @@ struct sway_output *workspace_get_initial_output(const char *name) { struct workspace_config *wsc = workspace_find_config(name); if (wsc && wsc->output) { struct sway_output *output = output_by_name(wsc->output); + if (!output) { + output = output_by_identifier(wsc->output); + } + if (output) { return output; } @@ -143,7 +147,11 @@ void workspace_consider_destroy(struct sway_workspace *ws) { static bool workspace_valid_on_output(const char *output_name, const char *ws_name) { struct workspace_config *wsc = workspace_find_config(ws_name); - return !wsc || !wsc->output || strcmp(wsc->output, output_name) == 0; + char identifier[128]; + struct sway_output *output = output_by_name(output_name); + output_get_identifier(identifier, sizeof(identifier), output); + + return !wsc || !wsc->output || strcmp(wsc->output, output_name) == 0 || strcasecmp(identifier, output_name) == 0; } static void workspace_name_from_binding(const struct sway_binding * binding, |