Refactor seat operations to use an interface

This splits each seat operation (drag/move tiling/floating etc) into a
separate file and introduces a struct sway_seatop_impl to abstract the
operation.

The move_tiling_threshold operation has been merged into move_tiling.

The main logic for each operation is untouched aside from variable
renames.

The following previously-static functions have been made public:
* node_at_coords
* container_raise_floating
* render_rect
* premultiply_alpha
* scale_box
This commit is contained in:
Ryan Dwyer 2019-01-10 22:04:42 +10:00
parent 15ac580b28
commit ed5aafd90b
19 changed files with 924 additions and 646 deletions

View file

@ -864,15 +864,7 @@ bool container_has_urgent_child(struct sway_container *container) {
void container_end_mouse_operation(struct sway_container *container) {
struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) {
if (seat->op_container == container) {
seat->op_target_node = NULL; // ensure tiling move doesn't apply
seat_end_mouse_operation(seat);
}
// If the user is doing a tiling drag over this container,
// keep the operation active but unset the target container.
if (seat->op_target_node == &container->node) {
seat->op_target_node = NULL;
}
seatop_unref(seat, container);
}
}
@ -1384,3 +1376,16 @@ void container_update_marks_textures(struct sway_container *con) {
&config->border_colors.urgent);
container_damage_whole(con);
}
void container_raise_floating(struct sway_container *con) {
// Bring container to front by putting it at the end of the floating list.
struct sway_container *floater = con;
while (floater->parent) {
floater = floater->parent;
}
if (container_is_floating(floater)) {
list_move_to_end(floater->workspace->floating, floater);
node_set_dirty(&floater->workspace->node);
}
}