diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-08-14 09:07:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 09:07:59 -0400 |
commit | b4887ba154ab0d659c560a21194c8ca43b953632 (patch) | |
tree | d1d693231ab91f1ef2fe98a437cc260daf755142 /sway/desktop | |
parent | d0fb2d9a53662c8629f1a0f0a57e83e6f36285c4 (diff) | |
parent | 4b8e3a885be74c588291c51f798de80bd81a92db (diff) | |
download | sway-b4887ba154ab0d659c560a21194c8ca43b953632.tar.xz |
Merge pull request #2445 from RyanDwyer/resize-tiling-via-cursor
Implement resizing tiled containers via cursor
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/transaction.c | 70 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 3 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 3 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 |
4 files changed, 55 insertions, 23 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 4e6af86a..a449ffaa 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -33,6 +33,7 @@ struct sway_transaction { list_t *instructions; // struct sway_transaction_instruction * size_t num_waiting; size_t num_configures; + uint32_t con_ids; // Bitwise XOR of view container IDs struct timespec create_time; struct timespec commit_time; }; @@ -212,17 +213,43 @@ static void transaction_apply(struct sway_transaction *transaction) { } } +static void transaction_commit(struct sway_transaction *transaction); + static void transaction_progress_queue() { - while (server.transactions->length) { - struct sway_transaction *transaction = server.transactions->items[0]; - if (transaction->num_waiting) { - return; + if (!server.transactions->length) { + return; + } + // There's only ever one committed transaction, + // and it's the first one in the queue. + struct sway_transaction *transaction = server.transactions->items[0]; + if (transaction->num_waiting) { + return; + } + transaction_apply(transaction); + transaction_destroy(transaction); + list_del(server.transactions, 0); + + if (!server.transactions->length) { + idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1); + return; + } + + // If there's a bunch of consecutive transactions which all apply to the + // same views, skip all except the last one. + while (server.transactions->length >= 2) { + struct sway_transaction *a = server.transactions->items[0]; + struct sway_transaction *b = server.transactions->items[1]; + if (a->con_ids == b->con_ids) { + list_del(server.transactions, 0); + transaction_destroy(a); + } else { + break; } - transaction_apply(transaction); - transaction_destroy(transaction); - list_del(server.transactions, 0); } - idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1); + + transaction = server.transactions->items[0]; + transaction_commit(transaction); + transaction_progress_queue(); } static int handle_timeout(void *data) { @@ -276,6 +303,7 @@ static void transaction_commit(struct sway_transaction *transaction) { instruction->state.view_width, instruction->state.view_height); ++transaction->num_waiting; + transaction->con_ids ^= con->id; // From here on we are rendering a saved buffer of the view, which // means we can send a frame done event to make the client redraw it @@ -293,17 +321,6 @@ static void transaction_commit(struct sway_transaction *transaction) { if (server.debug_txn_timings) { clock_gettime(CLOCK_MONOTONIC, &transaction->commit_time); } - if (server.transactions->length || transaction->num_waiting) { - list_add(server.transactions, transaction); - } else { - // There are no other transactions in progress, and this one has nothing - // to wait for, so we can skip the queue. - wlr_log(WLR_DEBUG, "Transaction %p has nothing to wait for", transaction); - transaction_apply(transaction); - transaction_destroy(transaction); - idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1); - return; - } if (transaction->num_waiting) { // Set up a timer which the views must respond within @@ -317,6 +334,9 @@ static void transaction_commit(struct sway_transaction *transaction) { strerror(errno)); handle_timeout(transaction); } + } else { + wlr_log(WLR_DEBUG, + "Transaction %p has nothing to wait for", transaction); } // The debug tree shows the pending/live tree. Here is a good place to @@ -403,5 +423,15 @@ void transaction_commit_dirty(void) { container->dirty = false; } server.dirty_containers->length = 0; - transaction_commit(transaction); + + list_add(server.transactions, transaction); + + // There's only ever one committed transaction, + // and it's the first one in the queue. + if (server.transactions->length == 1) { + transaction_commit(transaction); + // Attempting to progress the queue here is useful + // if the transaction has nothing to wait for. + transaction_progress_queue(); + } } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 3b73f99c..af9d49b8 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -331,7 +331,8 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { struct wlr_xdg_toplevel_resize_event *e = data; struct sway_seat *seat = e->seat->seat->data; if (e->serial == seat->last_button_serial) { - seat_begin_resize(seat, view->swayc, seat->last_button, e->edges); + seat_begin_resize_floating(seat, view->swayc, + seat->last_button, e->edges); } } diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index a947fb35..c6ac0f4e 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -327,7 +327,8 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { struct wlr_xdg_toplevel_v6_resize_event *e = data; struct sway_seat *seat = e->seat->seat->data; if (e->serial == seat->last_button_serial) { - seat_begin_resize(seat, view->swayc, seat->last_button, e->edges); + seat_begin_resize_floating(seat, view->swayc, + seat->last_button, e->edges); } } diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 393185bd..5e8afa65 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -432,7 +432,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { } struct wlr_xwayland_resize_event *e = data; struct sway_seat *seat = input_manager_current_seat(input_manager); - seat_begin_resize(seat, view->swayc, seat->last_button, e->edges); + seat_begin_resize_floating(seat, view->swayc, seat->last_button, e->edges); } static void handle_set_title(struct wl_listener *listener, void *data) { |