Commit graph

90 commits

Author SHA1 Message Date
Ryan Dwyer 8314019f66 Fix race condition crashes when unmapping views
This fixes two issues which were both introduced in #2396.

First issue:
The PR changes the location of the buffer save to transaction_apply, but
puts it inside the should_configure block. For unmapping (destroying)
views, should_configure returns false so it wasn't saving the buffer. If
a frame was rendered between the unmap and the transaction applying then
it would result in a crash.

Second issue:
If a destroying view is involved in two transactions, we must not
release the buffer between the transactions because there is no live
buffer to grab any more.
2018-08-02 20:54:03 +10:00
Ryan Dwyer d10ccc1eb1 Correctly track saved surfaces during multiple transactions
Fixes #2364.

Suppose a view is 600px wide, and we tell it to resize to 601px during a
resize operation. We create a transaction, save the 600px buffer and
send the configure. This buffer is saved into the associated
instruction, and is rendered while we wait for the view to commit a
601px buffer.

Before the view commits the 601px buffer, suppose we tell it to resize
to 602px. The new transaction will also save the buffer, but it's still
the 600px buffer because we haven't received a new one yet.

Then suppose the view commits its original 601px buffer. This completes
the first transaction, so we apply the 601px width to the container.
There's still the second (now only) transaction remaining, so we render
the saved buffer from that. But this is still the 600px buffer, and we
believe it's 601px. Whoops.

The problem here is we can't stack buffers like this. So this commit
removes the saved buffer from the instructions, places it in the view
instead, and re-saves the latest buffer every time the view completes a
transaction and still has further pending transactions.

As saved buffers are now specific to views rather than instructions, the
functions for saving and removing the saved buffer have been moved to
view.c.

The calls to save and restore the buffer have been relocated to more
appropriate functions too, favouring transaction_commit and
transaction_apply rather than transaction_add_container and
transaction_destroy.
2018-08-01 16:24:15 +10:00
Ryan Dwyer a4bcddcfdc Include errno.h 2018-07-28 22:40:43 +10:00
Ryan Dwyer d6daf10cad Show errno description in log 2018-07-28 22:40:43 +10:00
Ryan Dwyer 32663b7b01 Handle out-of-fd situations gracefully for transaction and urgent timers 2018-07-28 22:40:43 +10:00
Ryan Dwyer 52cf410d3c Second attempt at fixing transaction use-after-free
The solution used in 073ac425d5 doesn't
work in all cases because the freed instruction might be ahead in the
list, not necessarily behind.

The new solution delays running the queue until after the loop has
finished iterating, thus avoiding the problem completely.
2018-07-28 17:43:18 +10:00
Ryan Dwyer 073ac425d5 Fix use after free in transactions
In set_instructions_ready, calling set_instruction_ready may cause any
number of transactions to get applied, which removes them from the list
being iterated.  The iteration variables need to be adjusted
accordingly.
2018-07-28 15:21:39 +10:00
Ryan Dwyer 27a20a4884 Allow containers to be fullscreen 2018-07-26 08:27:07 +10:00
Ryan Dwyer 31f91bd483 Improve resize performance by partially flushing the transaction queue
When interactively resizing some views (eg. Nautilus), new transactions
are added to the queue faster than the client can process them.
Previously, we would wait for the entire queue to be ready before
applying any of them, but in this case the transactions would time out,
giving the client choppy performance.

This changes the queue handling so it applies the transactions up to the
first waiting transaction, without waiting for the entire queue to be
ready.
2018-07-22 23:10:19 +10:00
emersion 4154234eee Update for swaywm/wlroots#1148 2018-07-19 21:54:46 +01:00
Ryan Dwyer a120d4c79f Make focus part of transactions
Rather than maintain copies of the entire focus stack, this PR
transactionises the focus by introducing two new properties to the
container state and using those when rendering.

* `bool focused` means this container has actual focus. Only one
container should have this equalling true in its current state.
* `struct sway_container *focus_inactive_child` points to the immediate
child that was most recently focused (eg. for tabbed and stacked
containers).
2018-07-15 22:08:26 +10:00
Drew DeVault 53e3f35ba3
Merge pull request #2272 from RyanDwyer/simplify-transactions
Simplify transactions by using a dirty flag on containers
2018-07-15 05:01:25 -07:00
Drew DeVault b1afcc69fa Add extended debugging flags
We currently have several ways of setting debug flags, including command
line arguments, environment variables, and compile-time macros. This
replaces the lot with command line flags.
2018-07-14 20:44:32 -04:00
Ryan Dwyer 6b2dc7e63b Set signature to void 2018-07-15 10:41:10 +10:00
Ryan Dwyer 2032f85d94 Simplify transactions by utilising a dirty flag on containers
This PR changes the way we handle transactions to a more simple method.
The new method is to mark containers as dirty from low level code
(eg. arranging, or container_destroy, and eventually seat_set_focus),
then call transaction_commit_dirty which picks up those containers and
runs them through a transaction. The old methods of using transactions
(arrange_and_commit, or creating one manually) are now no longer
possible.

The highest-level code (execute_command and view implementation
handlers) will call transaction_commit_dirty, so most other code just
needs to set containers as dirty. This is done by arranging, but can
also be done by calling container_set_dirty.
2018-07-14 23:14:55 +10:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Drew DeVault d43500831a
Updates per wlroots#1076 2018-07-05 00:26:35 +01:00
Ryan Dwyer 50b401677b Fix use after free in transaction code
If we set an instruction as ready twice, it decreases the transaction's
num_waiting a second time and applies the transaction earlier than it
should. This no doubt has undesired effects, probably resulting in a use
after free.

Hopefully fixes the first part of #2207.
2018-07-04 22:58:17 +10:00
emersion f611a4f9b1
Merge pull request #2187 from martinetd/idle-inhibit
Idle inhibit
2018-07-02 09:06:23 +01:00
Dominique Martinet 71224781c4 idle_inhibit: move server data to its own struct 2018-07-02 09:29:16 +09:00
Dominique Martinet 072b334abc idle_inhibit: stop inhibitor when views become invisible 2018-07-02 09:29:16 +09:00
Dominique Martinet df494a7e51 transaction_apply: use float for quotient
Pre-dividing 1000/60 would lose 2/3 due to round-up

Found through static analysis
2018-07-02 08:03:41 +09:00
Ryan Dwyer 96c8c02483 Fix flash of background when xwayland views are mapped
A flash of background was happening for two reasons:

1) We were using the xsurface's dimensions to check if the surface is
ready, but these are pending dimensions.
2) In my particular setup, the default geometry of the xsurface does not
intersect any output, which prevented it from receiving a frame done
event. This made the transaction time out and the client would only
redraw once it's been rendered.
2018-06-30 14:30:14 +10:00
Ryan Dwyer 3a6ed5110c Render saved buffers with the surface's dimensions 2018-06-29 21:13:22 +10:00
Ryan Dwyer d7169ee7ff Replace list_empty with a simple alternative 2018-06-29 19:44:54 +10:00
Ryan Dwyer 9652529cc1 Allow views to skip configures
To do this properly, the transaction queue will only be processed if it
can be completely processed.
2018-06-27 19:07:48 +10:00
Ryan Dwyer be86d3aba6 Remove transaction_add_damage
Instead, damage each container when applying the transaction.
2018-06-27 17:46:03 +10:00
Ryan Dwyer 61c1187685 Fix nitpicks 2018-06-27 17:23:44 +10:00
Ryan Dwyer 0085f64ac0 Remove timer when transaction destroys 2018-06-26 18:51:37 +10:00
Ryan Dwyer beacd4d9f9 Rename progress_queue to transaction_progress_queue 2018-06-25 16:50:01 +10:00
Ryan Dwyer c371ff3de8 Implement per-configure debug timings 2018-06-25 09:25:51 +10:00
Ryan Dwyer 289d696adc Implement transaction timings debug
Launch sway with SWAY_DEBUG=txn_timings to enable it.
2018-06-25 09:09:43 +10:00
Ryan Dwyer 1549fb719a Implement atomic layout updates for xwayland views 2018-06-24 23:01:09 +10:00
Ryan Dwyer f08a30d6d0 Force transactions to complete in order
This forces transactions to complete in order by using a singly linked
list stored in the sway server.
2018-06-24 12:33:23 +10:00
Ryan Dwyer 38398e2d77 Implement atomic layout updates for tree operations
This implements atomic layout updates for when views map, reparent or
unmap.
2018-06-23 16:24:11 +10:00
Ryan Dwyer 1c89f32533 Preserve buffers during transactions
* Also fix parts of the rendering where it was rendering the pending
state instead of current.
2018-06-18 20:42:12 +10:00
Ryan Dwyer 9e96cfd310 Merge remote-tracking branch 'upstream/master' into atomic 2018-06-11 11:03:43 +10:00
Ryan Dwyer bb66e6d578 Refactor everything that needs to arrange windows
* The arrange_foo functions are now replaced with arrange_and_commit, or
with manually created transactions and arrange_windows x2.
* The arrange functions are now only called from the highest level
functions rather than from both high level and low level functions.
* Due to the previous point, view_set_fullscreen_raw and
view_set_fullscreen are both merged into one function again.
* Floating and fullscreen are now working with transactions.
2018-06-09 10:11:25 +10:00
Ryan Dwyer f9e6d703d2 Make main properties be the pending state 2018-06-09 10:08:43 +10:00
Ryan Dwyer 59c9488701 WIP: Atomic layout updates ground work 2018-06-09 10:08:43 +10:00