mirror of
https://github.com/swaywm/sway.git
synced 2026-04-18 06:46:56 -04:00
chore: tidy up code
This commit is contained in:
parent
6ce09d0fa9
commit
5725d3a170
1 changed files with 33 additions and 22 deletions
|
|
@ -267,31 +267,36 @@ static void relay_handle_text_input(struct wl_listener *listener,
|
|||
sway_text_input_create(relay, wlr_text_input);
|
||||
}
|
||||
|
||||
static struct sway_layer_surface *loop_layer_surface(struct wl_list children,
|
||||
struct wlr_layer_surface_v1 *layer)
|
||||
{
|
||||
struct wlr_scene_node *node;
|
||||
wl_list_for_each (node, &children, link) {
|
||||
struct sway_layer_surface *surface = scene_descriptor_try_get(node,
|
||||
SWAY_SCENE_DESC_LAYER_SHELL);
|
||||
if (!surface) {
|
||||
continue;
|
||||
}
|
||||
if (surface->layer_surface == layer) {
|
||||
return surface;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sway_layer_surface *find_layer_by_surface(
|
||||
struct wlr_layer_surface_v1 *layer) {
|
||||
for (int i = 0; i < root->outputs->length; ++i) {
|
||||
struct sway_output *output = root->outputs->items[i];
|
||||
// For now we'll only check the overlay and top layer
|
||||
struct wlr_scene_node *node;
|
||||
wl_list_for_each (node, &output->layers.shell_top->children, link) {
|
||||
struct sway_layer_surface *surface = scene_descriptor_try_get(node,
|
||||
SWAY_SCENE_DESC_LAYER_SHELL);
|
||||
if (!surface) {
|
||||
continue;
|
||||
}
|
||||
if (surface->layer_surface == layer) {
|
||||
return surface;
|
||||
}
|
||||
struct sway_layer_surface *surface;
|
||||
surface = loop_layer_surface(output->layers.shell_top->children, layer);
|
||||
if (surface != NULL) {
|
||||
return surface;
|
||||
}
|
||||
wl_list_for_each (node, &output->layers.shell_overlay->children, link) {
|
||||
struct sway_layer_surface *surface = scene_descriptor_try_get(node,
|
||||
SWAY_SCENE_DESC_LAYER_SHELL);
|
||||
if (!surface) {
|
||||
continue;
|
||||
}
|
||||
if (surface->layer_surface == layer) {
|
||||
return surface;
|
||||
}
|
||||
surface = loop_layer_surface(output->layers.shell_overlay->children, layer);
|
||||
if (surface != NULL) {
|
||||
return surface;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -315,7 +320,6 @@ static void input_popup_update(struct sway_input_popup *popup) {
|
|||
if (popup->desc.relative != NULL) {
|
||||
wlr_scene_node_destroy(popup->desc.relative);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool cursor_rect = text_input->input->current.features
|
||||
|
|
@ -335,6 +339,10 @@ static void input_popup_update(struct sway_input_popup *popup) {
|
|||
return;
|
||||
}
|
||||
|
||||
relative = wlr_scene_tree_create(layer->scene->tree);
|
||||
if (relative == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wlr_output* output = layer->layer_surface->output;
|
||||
wlr_output_layout_get_box(root->output_layout, output, &output_box);
|
||||
int lx, ly;
|
||||
|
|
@ -343,9 +351,13 @@ static void input_popup_update(struct sway_input_popup *popup) {
|
|||
parent.y = ly;
|
||||
popup->scene_tree = wlr_scene_subsurface_tree_create(root->layers.popup, popup->popup_surface->surface);
|
||||
popup->desc.view = NULL;
|
||||
relative = wlr_scene_tree_create(layer->scene->tree);
|
||||
|
||||
} else {
|
||||
struct sway_view *view = view_from_wlr_surface(focused_surface);
|
||||
relative = wlr_scene_tree_create(view->scene_tree);
|
||||
if (relative == NULL) {
|
||||
return;
|
||||
}
|
||||
int lx, ly;
|
||||
wlr_scene_node_coords(&view->scene_tree->node, &lx, &ly);
|
||||
struct wlr_output *output = wlr_output_layout_output_at(root->output_layout,
|
||||
|
|
@ -359,7 +371,6 @@ static void input_popup_update(struct sway_input_popup *popup) {
|
|||
parent.height = view->geometry.height;
|
||||
popup->scene_tree = wlr_scene_subsurface_tree_create(root->layers.popup, popup->popup_surface->surface);
|
||||
popup->desc.view = view;
|
||||
relative = wlr_scene_tree_create(view->scene_tree);
|
||||
}
|
||||
|
||||
popup->desc.relative = &relative->node;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue