Commit graph

463 commits

Author SHA1 Message Date
Drew DeVault 9f913614ca
Merge pull request #2478 from RyanDwyer/standardise-debug
Standardise debug variables
2018-08-19 10:29:29 -04:00
Ryan Dwyer 76bdb21ca9 Fix popup position when parent uses geometry
Fixes #2489.
2018-08-19 21:09:39 +10:00
Ryan Dwyer 2b5a404ac9 Replace hacky L_FLOATING container with a list
Workspaces previously had a magical `workspace->floating` container,
which had a layout of L_FLOATING and whose children were actual floating
views. This allowed some conveniences, but was a hacky solution because
the container has to be exempt from focus, coordinate transactions with
the workspace, and omit emitting IPC events (which we didn't do).

This commit changes it to be a list directly in the sway_workspace. The
L_FLOATING layout is no longer used so this has been removed as well.

* Fixes incorrect check in the swap command (it checked if the
containers had the L_FLOATING layout, but this layout applied to the
magical container).
* Introduces workspace_add_floating
2018-08-19 16:18:33 +10:00
Ryan Dwyer f9563d88f3 Use enum for damage debug options 2018-08-19 16:17:24 +10:00
Ryan Dwyer 8d1dd03823 Standardise debug variables
This makes all debug options stored in a single struct rather than in
various places, changes/fixes the behaviour of existing options, and
introduces some new options.

* Fixes damage issues with `-Drender-tree` texture (by removing scissor)
* Offsets the render tree overlay's `y` position for those who have
swaybar at the top
* Replaces `-Ddamage=rerender` with `-Dnodamage`
* Replaces `-Ddamage=highlight` with `-Dhighlight-damage`
* Replaces `-Dtxn-debug` with `-Dtxn-wait`
* Introduces `-Dnoatomic`
* Removes the `create_time` and `ms_arranging` figures from transactions
and the log message. Transactions are created after arranging and the
create time is of no significance.
* Fixes `-Dtxn-debug` (now `-Dtxn-wait`) not working.
2018-08-19 16:17:24 +10:00
Drew DeVault d0a24465d7
Merge pull request #2466 from RyanDwyer/geometry
Fix geometry
2018-08-18 19:26:36 -04:00
Ryan Dwyer d6cd79c342 Implement iterators per container type
This introduces the following `for_each` functions:

* root_for_each_workspace
* root_for_each_container
* output_for_each_workspace
* output_for_each_container
* workspace_for_each_container

And introduces the following `find` functions:

* root_find_output
* root_find_workspace
* root_find_container
* output_find_workspace
* output_find_container
* workspace_find_container
* container_find_child

And removes the following functions:

* container_descendants
* container_for_each_descendant
* container_find

This change is preparing the way for demoting sway_container. Eventually
these functions will accept and return sway_outputs, sway_workspaces and
sway_containers (meaning a C_CONTAINER or C_VIEW).

This change also makes it easy to handle abnormalities like the
workspace floating list, root's scratchpad list and (once implemented)
root's saved workspaces list for when there's no connected outputs.
2018-08-18 23:38:54 +10:00
Ryan Dwyer ce78f6770e Fix nitpick 2018-08-18 15:11:46 +10:00
Ryan Dwyer b0a5f3a25f Store geometry in the view and handle any floating view resizing 2018-08-18 15:10:06 +10:00
Ryan Dwyer 4e755c4b12 Set current size when a floating xwayland view resizes
This avoids sending an unnecessary configure.
2018-08-18 10:39:38 +10:00
Ryan Dwyer 8af4e2e3e6 Handle xwayland views sending new sizes in their commits 2018-08-18 10:39:38 +10:00
Ryan Dwyer 9ee89f11c4 Add get_geometry for xdg_shell_v6 2018-08-18 10:39:38 +10:00
Ryan Dwyer 8034c25426 Render saved buffer using saved geometry 2018-08-18 10:39:38 +10:00
Ryan Dwyer 982a2d0c99 Fix geometry 2018-08-18 10:39:38 +10:00
emersion b3ee9af0c8 Add view_get_geometry 2018-08-18 10:39:38 +10:00
Ryan Dwyer 1801b725e2 Add using_csd variable to transaction state
This fixes a race condition flicker when unfloating a view which uses
client side decorations.

When the view is floated it has using_csd = true, so the decorations are
not drawn. When unfloating it it changes to false, but this change
wasn't part of transactions so it could potentially render the
decorations around the view while it's waiting for the transaction to
apply.
2018-08-17 20:25:33 +10:00
Ryan Dwyer c3ef36d6b5 Simplify transactions
Commit 4b8e3a885b makes it so only one
transaction is committed (ie. configures sent) at a time. This commit
removes the now-unnecessary code which was used to support concurrent
committed transactions.

* Instead of containers storing a list of instructions which they've
been sent, it now stores a single instruction.
* Containers now have an ntxnrefs property. Previously we knew how many
references there were by the length of the instruction list.
* Instructions no longer need a ready property. It was used to avoid
marking an instruction ready twice when they were in a list, but this is
now avoided because there is only one instruction and we nullify the
container->instruction pointer when it's ready.
* When a transaction applies, we no longer need to consider releasing
and resaving the surface, as we know there are no other committed
transactions.
* transaction_notify_view_ready has been renamed to
view_notify_view_ready_by_serial to make it consistent with
transaction_notify_view_ready_by_size.
* Out-of-memory checks have been added when creating transactions and
instructions.
2018-08-15 10:03:55 +10:00
Ryan Dwyer 4b8e3a885b Don't commit multiple transactions at the same time 2018-08-12 10:45:54 +10:00
Ryan Dwyer e7a7306063 Don't progress transaction queue if any are partially complete
This fixes an issue where views might commit to a transaction ahead of
the first one, and applying the first transaction causes us to save a
buffer of the wrong size.
2018-08-12 10:45:54 +10:00
Ryan Dwyer b4a0363d17 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.
2018-08-12 10:45:54 +10:00
emersion d1433c637a xwayland: fix unmanaged surfaces order 2018-08-10 12:47:24 +01:00
emersion d2ac48f920 Handle views created after decoration mode is sent for xdg-shell-v6 2018-08-06 15:28:33 +01:00
emersion 9d578e0a0f Handle views created after decoration mode is sent for xdg-shell 2018-08-06 15:20:30 +01:00
Ryan Dwyer 787f08da7f Convert toplevel coordinates to output-local 2018-08-02 23:36:36 +10:00
Ryan Dwyer 8392eae40f Revert "Revert "Fix popups""
This reverts commit 9aa258d33a.

Reverting the revert, so that popups can be fixed.
2018-08-02 23:36:36 +10:00
Drew DeVault ea14ef4095
Merge pull request #2366 from RedSoxFan/nagbar
Implement swaynag
2018-08-02 09:28:13 -04:00
Ryan Dwyer 706c0fbe23
Merge branch 'master' into nagbar 2018-08-02 23:05:49 +10:00
Drew DeVault 9aa258d33a Revert "Fix popups"
This reverts commit de86d65627.
2018-08-02 09:05:46 -04:00
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
emersion 47bf4ed0cb
Merge branch 'master' into fix-resize-wiggle 2018-08-02 08:11:10 +01:00
Brian Ashworth a4f7bf23b2 Address first round review for swaynag 2018-08-01 22:47:54 -04:00
Brian Ashworth abf33468c1 Arrange output in arrange_layers and commit dirty 2018-08-01 22:47:54 -04: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 7a59508da4 Close popups when changing focus
Also reverts the send frame done changes from the previous commit.
2018-07-31 19:58:34 +10:00
Ryan Dwyer de86d65627 Fix popups
Fixes the render and container_at order for popups.

Fixes #2210

For rendering:

* render_view_surfaces has been renamed to render_view_toplevels
* render_view_toplevels now uses output_surface_for_each_surface (which
is now public), as that function uses wlr_surface_for_each_surface which
doesn't descend into popups
* Views now have a for_each_popup iterator, which is used by the
renderer to render the focused view's popups
* When rendering a popup, toplevels (xdg subsurfaces) of that popup are
also rendered

For sending frame done, the logic has been updated to match the
rendering logic:

* send_frame_done_container no longer descends into popups
* for_each_popup is used to send frame done to the focused view's popups
and their child toplevels

For container_at:

* floating_container_at is now static, which means it had to be moved
higher in the file.
* container_at now considers popups for the focused view before checking
containers.
* tiling_container_at has been introduced, so that it doesn't call
container_at recursively (it would check popups recursively if it did)
2018-07-31 18:41:30 +10:00
emersion 15c19572cf Fix segfault with fullscreen 2018-07-30 19:44:07 +01:00
Drew DeVault cbd0c3ec40
Merge pull request #2367 from emersion/iterator-redesign
Refactor surface iterators
2018-07-30 13:12:22 -04:00
Brian Ashworth b8efdeae29 Fix title textures on scale change 2018-07-30 01:59:20 -04:00
emersion 9a7e436fad Don't give focus if xwayland window has a type hint 2018-07-29 17:28:21 +01:00
emersion 0ad865f0b7 Make output_surface_for_each_surface_iterator static 2018-07-29 14:34:48 +01:00
emersion 9951b2ec33 Remove unused output_from_wlr_output 2018-07-29 14:33:26 +01:00
emersion fe0750fec1 Remove output_surface_for_each_surface from header 2018-07-29 14:33:26 +01:00
emersion 8d5cc8625c Completely switch over to new iterators 2018-07-29 14:33:26 +01:00
emersion e9d674cfd2 wip: redesign output_view_for_each_surface iterator 2018-07-29 14:33:26 +01:00
emersion a0dd977617 wip: redesign output_layer_for_each_surface iterator 2018-07-29 14:33:26 +01:00
emersion dbf6dd0dae wip: redesign output_drag_icons_for_each_surface iterator 2018-07-29 14:33:26 +01:00
emersion d2172bd331 wip: redesign output_unmanaged_for_each_surface iterator 2018-07-29 14:33:26 +01:00
Drew DeVault 53069f1403
Merge pull request #2360 from RyanDwyer/floating-containers
Allow containers to float
2018-07-28 09:30:12 -04:00
Ryan Dwyer 08cfba2192 Allow containers to float
Things worth noting:

* When a fullscreen view unmaps, the check to unset fullscreen on the
workspace has been moved out of view_unmap and into container_destroy,
because containers can be fullscreen too
* The calls to `container_reap_empty_recursive(workspace)` have been
removed from `container_set_floating`. That function reaps upwards so it
wouldn't do anything. I'm probably the one who originally added it...
* My fix (b14bd1b0b1) for the tabbed child
crash has a side effect where when you close a floating container, focus
is not given to the tiled container again. I've removed my fix and
removed the call to `send_cursor_motion` from `seat_set_focus_warp`. We
should consider calling it from somewhere earlier in the call stack.
2018-07-28 22:41:04 +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 868dcde14e Fix indent 2018-07-26 08:28:05 +10:00
Ryan Dwyer 27a20a4884 Allow containers to be fullscreen 2018-07-26 08:27:07 +10:00
Drew DeVault 53dbe2da4b
Merge pull request #2353 from emersion/render-opaque-overlay
Improve rendering with a fullscreen opaque overlay surface
2018-07-25 08:32:32 -04:00
Pascal Pascher f95cb9a7c1 reverted includes of "sway/config.h" and replaced with "config.h" from meson build 2018-07-25 13:32:20 +02:00
emersion 0e79b2114c Improve rendering with a fullscreen opaque overlay surface
The rendering code doesn't use the exclusive input surface at all
anymore to decide to skip rendering of shell surfaces. This fixes
a weird situation in which a client requests exclusive input but
isn't an overlay layer surface.

The renderer also renders all overlay surfaces in this situation,
not just one. This simplifies the code and fixes rendering when
there are more than one overlay surfaces (e.g. for a virtual
keyboard to type the lockscreen password).
2018-07-25 08:55:41 +01:00
Pascal Pascher 2bf893248a style fixes, exclude sway/desctop/xwayland.c when enable_xwayland: false 2018-07-24 23:37:41 +02:00
Pascal Pascher 24ad1c3983 Added meson option "enable_xwayland" (default: true) to enable/disable xwayland support 2018-07-24 22:16:06 +02:00
Drew DeVault f4b882475e Merge branch 'master' into pid-workspaces 2018-07-23 20:31:11 -04:00
somdoron 7ead2e85a7 fix crash on new output while swaylock is running 2018-07-23 19:35:40 +03:00
emersion 238c8afc74 Handle set_{title,app_id} for xdg-shell and zxdg-shell-v6
This allows to update the title even if the view doesn't commit.
This is useful e.g. when a terminal sets its toplevel title to
the currently running command and when the view isn't visible.
2018-07-22 22:20:07 +01:00
Ryan Dwyer 5ba2ae9c6a Implement request_move and request_resize for xwayland views
I discovered we have to send a click event when ending the move or
resize operation to make xwayland's requests work correctly.
2018-07-22 23:10:19 +10:00
Ryan Dwyer cf5f5eaf8c Deny move/resize events for tiled xdg shell views 2018-07-22 23:10:19 +10:00
Ryan Dwyer 011d1ebfa4 Consider view's min/max sizes when resizing 2018-07-22 23:10:19 +10:00
Ryan Dwyer 9df660ee31 Store last button and use it when views request to move or resize 2018-07-22 23:10:19 +10:00
Ryan Dwyer ff445cc855 Implement xdg shell request_move and request_resize events
Also does a few other related things:

* Now uses enum wlr_edges instead of our own enum resize_edge
* Now uses wlr_xcursor_get_resize_name and removes our own
find_resize_edge_name
* Renames drag to move for consistency
2018-07-22 23:10:19 +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
Ryan Dwyer f9491c9584 Fix damage issue when moving and resizing 2018-07-22 23:10:19 +10:00
Ryan Dwyer c2ed3d8bd6 Implement force_display_urgency_hint
The directive sets the timeout before an urgent view becomes normal
again after switching to it from another workspace.

Also:

* When an xwayland surface removes the urgent hint while the timer is
active, we now ignore the request. This happens as soon as the view
receives focus, so it was effectively making the timer pointless.
* The timeout is now only applied when switching to it from another
workspace.
2018-07-21 10:28:07 +10:00
emersion 4154234eee Update for swaywm/wlroots#1148 2018-07-19 21:54:46 +01:00
Ryan Dwyer 63d6233fcb Allow xwayland views to become urgent when on a non-visible workspace
This removes the urgency stuff from the commit handler and puts it in a
new set_hints handler instead. This allows the xwayland surface to
become urgent without having to commit (which doesn't happen if it's on
an non-visible workspace).
2018-07-19 21:08:51 +10:00
emersion 747725b8bb Don't unfocus when an override redirect window is mapped 2018-07-18 20:00:48 +01:00
emersion fb4eca5d56 Handle xwayland override_redirect flag change
This fixes syncplay menus.
2018-07-18 19:10:08 +01:00
frsfnrrg 3931cb85b2 Fix memory leak in sway/desktop/idle_inhibit_v1.c 2018-07-17 11:35:24 -04:00
frsfnrrg 37471ac649 Fix memory leak in handle_layer_shell_surface 2018-07-17 11:35:24 -04:00
Ryan Dwyer 75c699db62 Implement default_floating_border command and adjust CSD behaviour 2018-07-17 10:14:33 +10:00
Ryan Dwyer af5f736277 Render containers as urgent if they have an urgent child 2018-07-16 18:22:27 +10:00
Ryan Dwyer e3f90f00fe Implement xwayland urgency hint 2018-07-16 08:42:34 +10:00
Ryan Dwyer 315d5311b2 Implement urgency base functionality
Introduces a command to manually set urgency, as well as rendering of
urgent views, sending the IPC event, removing urgency after focused for
one second, and matching urgent views via criteria.
2018-07-16 08:19:25 +10: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 efda33b285 Simplify popup_unconstrain
Just use the parent output.
2018-07-13 21:17:31 +01:00
emersion d88f1d2196 Fix output_has_opaque_lockscreen 2018-07-13 12:26:20 +01:00
Ryan Dwyer 53133fdefb
Merge branch 'master' into xwayland-floating-borders 2018-07-13 08:17:45 +10:00
emersion a96f1c22fe Add xdg-positioner support 2018-07-12 20:31:55 +01:00
emersion 9b16227ec3 Don't disable borders for xwayland floating views 2018-07-12 20:01:33 +01:00
Ryan Dwyer 3b50a2a3af Use saved buffer when fullscreen view is in a transaction
Fixes #2237.
2018-07-11 20:33:36 +10:00
russ morris 6ae1004cd1 removed unnecessary parens 2018-07-10 20:57:05 -07:00
russ morris c06266e12d fix line lengths 2018-07-10 20:34:51 -07:00
russ morris b9d8ecc548 tabs instead of spaces 2018-07-10 20:24:57 -07:00
russ morris 89c25dd149 fix tabbed titlebar widths 2018-07-10 17:59:00 -07:00
Ryan Dwyer 56ad148403
Merge branch 'master' into fix-stacked-layout 2018-07-10 20:41:02 +10:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Konstantin Pospelov 9dd54f934e Fix titlebar rendering for nested stacked containers 2018-07-10 00:33:13 +03:00