mirror of
https://github.com/swaywm/sway.git
synced 2026-04-02 07:15:50 -04:00
Implement resizing tiled containers via cursor
* The OP_RESIZE seat operation has been renamed to OP_RESIZE_FLOATING, and OP_RESIZE_TILING has been introduced. * Similar to the above, seat_begin_resize and handle_resize_motion have been renamed and tiling variants introduced. * resize.c's resize_tiled has to be used, so container_resize_tiled has been introduced in resize.c to allow external code to call it.
This commit is contained in:
parent
146cc0a441
commit
b4a0363d17
10 changed files with 173 additions and 34 deletions
|
|
@ -942,14 +942,14 @@ void seat_begin_move(struct sway_seat *seat, struct sway_container *con,
|
|||
cursor_set_image(seat->cursor, "grab", NULL);
|
||||
}
|
||||
|
||||
void seat_begin_resize(struct sway_seat *seat, struct sway_container *con,
|
||||
uint32_t button, enum wlr_edges edge) {
|
||||
void seat_begin_resize_floating(struct sway_seat *seat,
|
||||
struct sway_container *con, uint32_t button, enum wlr_edges edge) {
|
||||
if (!seat->cursor) {
|
||||
wlr_log(WLR_DEBUG, "Ignoring resize request due to no cursor device");
|
||||
return;
|
||||
}
|
||||
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
|
||||
seat->operation = OP_RESIZE;
|
||||
seat->operation = OP_RESIZE_FLOATING;
|
||||
seat->op_container = con;
|
||||
seat->op_resize_preserve_ratio = keyboard &&
|
||||
(wlr_keyboard_get_modifiers(keyboard) & WLR_MODIFIER_SHIFT);
|
||||
|
|
@ -968,20 +968,29 @@ void seat_begin_resize(struct sway_seat *seat, struct sway_container *con,
|
|||
cursor_set_image(seat->cursor, image, NULL);
|
||||
}
|
||||
|
||||
void seat_begin_resize_tiling(struct sway_seat *seat,
|
||||
struct sway_container *con, uint32_t button, enum wlr_edges edge) {
|
||||
seat->operation = OP_RESIZE_TILING;
|
||||
seat->op_container = con;
|
||||
seat->op_resize_edge = edge;
|
||||
seat->op_button = button;
|
||||
seat->op_ref_lx = seat->cursor->cursor->x;
|
||||
seat->op_ref_ly = seat->cursor->cursor->y;
|
||||
seat->op_ref_con_lx = con->x;
|
||||
seat->op_ref_con_ly = con->y;
|
||||
seat->op_ref_width = con->width;
|
||||
seat->op_ref_height = con->height;
|
||||
|
||||
const char *image = wlr_xcursor_get_resize_name(edge);
|
||||
cursor_set_image(seat->cursor, image, NULL);
|
||||
}
|
||||
|
||||
void seat_end_mouse_operation(struct sway_seat *seat) {
|
||||
switch (seat->operation) {
|
||||
case OP_MOVE:
|
||||
{
|
||||
// We "move" the container to its own location so it discovers its
|
||||
// output again.
|
||||
struct sway_container *con = seat->op_container;
|
||||
container_floating_move_to(con, con->x, con->y);
|
||||
}
|
||||
case OP_RESIZE:
|
||||
// Don't need to do anything here.
|
||||
break;
|
||||
case OP_NONE:
|
||||
break;
|
||||
if (seat->operation == OP_MOVE) {
|
||||
// We "move" the container to its own location so it discovers its
|
||||
// output again.
|
||||
struct sway_container *con = seat->op_container;
|
||||
container_floating_move_to(con, con->x, con->y);
|
||||
}
|
||||
seat->operation = OP_NONE;
|
||||
seat->op_container = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue