Implement floating_modifier and mouse operations for floating views

This implements the following:

* `floating_modifier` configuration directive
* Drag a floating window by its title bar
* Hold mod + drag a floating window from anywhere
* Resize a floating view by dragging the border
* Resize a floating view by holding mod and right clicking anywhere on
the view
* Resize a floating view and keep aspect ratio by holding shift while
resizing using either method
* Mouse cursor turns into resize when hovering floating border or corner
This commit is contained in:
Ryan Dwyer 2018-07-18 16:13:28 +10:00
parent 27f65b94ae
commit 9fbe13b9be
11 changed files with 395 additions and 17 deletions

View file

@ -323,6 +323,8 @@ static struct sway_container *container_destroy_noreaping(
}
}
container_end_mouse_operation(con);
con->destroying = true;
container_set_dirty(con);
@ -964,6 +966,8 @@ void container_set_floating(struct sway_container *container, bool enable) {
container_reap_empty_recursive(workspace->sway_workspace->floating);
}
container_end_mouse_operation(container);
ipc_event_window(container, "floating");
}
@ -1009,7 +1013,7 @@ void container_get_box(struct sway_container *container, struct wlr_box *box) {
/**
* Translate the container's position as well as all children.
*/
static void container_floating_translate(struct sway_container *con,
void container_floating_translate(struct sway_container *con,
double x_amount, double y_amount) {
con->x += x_amount;
con->y += y_amount;
@ -1105,3 +1109,13 @@ static bool find_urgent_iterator(struct sway_container *con,
bool container_has_urgent_child(struct sway_container *container) {
return container_find(container, find_urgent_iterator, NULL);
}
void container_end_mouse_operation(struct sway_container *container) {
struct sway_seat *seat;
wl_list_for_each(seat, &input_manager->seats, link) {
if (seat->op_container == container) {
seat->op_container = NULL;
seat->operation = OP_NONE;
}
}
}