Commit graph

2683 commits

Author SHA1 Message Date
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
Ryan Dwyer 7f22fab389
Merge branch 'master' into commands 2018-08-19 16:07:11 +10:00
Drew DeVault d0a24465d7
Merge pull request #2466 from RyanDwyer/geometry
Fix geometry
2018-08-18 19:26:36 -04:00
Ian Fan 37e37627ca commands: move newly-stickied containers to focused workspace 2018-08-18 18:29:18 +01:00
Ian Fan 1be75fe740 Fix double iterating in container_for_each_child 2018-08-18 18:10:41 +01:00
Ian Fan b3f7801fca commands: prevent focusing mode with no containers
Explicitly fail when trying to focus tiling/floating when there are no tiling/floating containers.
2018-08-18 17:25:06 +01:00
Ian Fan 23601a8771 commands: complete assign command 2018-08-18 17:25:06 +01:00
Ian Fan e81cc8a575 commands: saner workspace number handling 2018-08-18 17:25:06 +01:00
Ian Fan 69e00151bb commands: handle quoted exec command 2018-08-18 15:50:26 +01:00
Ian Fan 453646b887 commands: fix documentation formatting mistakes for move command 2018-08-18 15:50:26 +01:00
Ian Fan 7717c2231a commands: require set variable to start with $ 2018-08-18 15:50:26 +01:00
Ian Fan c1af79532f commands: add nop 2018-08-18 15:50:26 +01: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
Drew DeVault d4a32800d5
Merge pull request #2460 from RyanDwyer/implement-mousedown
Implement mousedown operation
2018-08-18 09:32:04 -04:00
Ryan Dwyer 16c663ed49 Rename container_sort_workspaces and container_wrap_children
This commit renames container_sort_workspaces to output_sort_workspaces
and moves it to output.c.

This also renames container_wrap_children to workspace_wrap_children and
moves it to workspace.c. This function is only called with workspaces.
2018-08-18 22:02:03 +10:00
Ryan Dwyer d22420689d Fix mod+resize
Fixes #2479.

It was missing a mod_pressed check.

This also moves the parent traversal into the `if` block.
2018-08-18 17:50:37 +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 07a897b3b7 Don't send motion if the cursor hasn't moved
Prevents GTK+ comboboxes from immediately closing.
2018-08-18 09:29:18 +10:00
Ryan Dwyer b637b61a7a Rename mousedown to down and make seat operation a named enum 2018-08-18 09:18:32 +10:00
Ryan Dwyer a36625a482 Implement mousedown operation
This allows you to move the cursor off the surface while dragging its
scrollbar.
2018-08-18 09:18:32 +10:00
Drew DeVault db4b4935b3
Merge pull request #2472 from RyanDwyer/refactor-seat-get-focus
Refactor seat_get_focus functions
2018-08-17 09:53:28 -04:00
emersion 754bbd03c0
Merge pull request #2471 from RyanDwyer/reap-when-floating
Attempt to reap old tiling parent when floating a container
2018-08-17 13:37:39 +01: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 3a888163a0 Refactor seat_get_focus functions
Fixes #2467.

This commit introduces seat_get_focus_inactive_floating to supplement
seat_get_focus_inactive_tiling, and uses it during `focus mode_toggle`
which fixes a focus bug.

This also refactors the seat_get_focus_inactive functions so that they
do their selection logic themselves rather than offloading it to
seat_get_focus_by_type which was getting bloated. seat_get_focus_by_type
is now removed.

Lastly, this commit changes seat_get_focus to just return the first
container in the focus stack rather than looping and calling
seat_get_focus_by_type.
2018-08-17 17:32:53 +10:00
Ryan Dwyer 6a26b499a4 Attempt to reap old tiling parent when floating a container 2018-08-17 16:23:37 +10:00
Donnie West a9433cbded
When the workspace is focused, return it instead of checking parent 2018-08-16 18:52:40 -05:00
Drew DeVault 98ed05225e
Merge pull request #2458 from RyanDwyer/cleanup-transactions
Simplify transactions
2018-08-15 17:16:32 -04:00
Ryan Dwyer 701fcafc70 Use list_find in more places and refactor/fix workspace prev_next functions
The original purpose of this commit is to replace some for loops with
list_find. But while doing this I found the workspace_prev_next_impl
functions to be difficult to read and also contained a bug, so I
refactored them and fixed the bug.

To reproduce the bug:

* Have two outputs, where the left output has workspaces 1, 2, 3 and the
right output has workspaces 4, 5, 6. Make workspace 2 focused_inactive
and workspace 4 focused.
* Run `workspace prev`.
* Previously it would visit the left output, then apply `workspace prev`
to workspace 2, which focuses workspace 1.
* Now it will focus the rightmost workspace on the left output
(workspace 3).

The refactoring I made to the workspace functions are:

* Added the static keyword.
* They now accept an int dir rather than bool, to avoid an unnecessary
conversion.
* Rather than preparing start and end variables for the purpose of
iterating, just iterate everything.
* Replace for loops with list_find.
* Don't call workspace_output_prev_next_impl (this fixes the bug).
2018-08-15 15:14:35 +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
Drew DeVault b4887ba154
Merge pull request #2445 from RyanDwyer/resize-tiling-via-cursor
Implement resizing tiled containers via cursor
2018-08-14 09:07:59 -04:00
minus 18e425eda6 Use assigned workspace name for output
Instead of relying on bindings being configured, primarily source
new workspace names from workspace-output assignments.

Fixes #2435
2018-08-12 14:41:41 +02: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 4d023c0390 Make mod+resize a floating container resize the container itself
Rather than resizing the split within the container.
2018-08-12 10:45:54 +10:00
Ryan Dwyer e9d46ccbdd Use col-resize and row-resize cursor images 2018-08-12 10:45:54 +10:00
Ryan Dwyer 1893515d3a Fix right-click/popups and add state checks 2018-08-12 10:45:54 +10:00
Ryan Dwyer 2dceae6224 Allow resizing tiled views via mod key 2018-08-12 10:45:54 +10:00
Ryan Dwyer f4280e506b Refactor dispatch_cursor_button
There was a separate function dispatch_cursor_button_floating which
dealt with the resize and move operations, but as resize is not really
limited to floating views, it doesn't make as much sense to have this
separate. So both functions are now combined into one.

Additionally, dispatch_cursor_button now uses a pattern of returning
early instead of using else-ifs.
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
Josip Janzic 5aca2b42e6
man: Correct format for output position config 2018-08-11 18:41:31 +02:00
Ryan Dwyer 5f3757c927 Fix container_has_ancestor crash
Fixes #2450
2018-08-12 00:14:52 +10:00
Drew DeVault 2aa6d98c5a
Merge pull request #2449 from RyanDwyer/remove-bfs
Remove container_for_each_descendant_bfs
2018-08-11 08:29:34 -04:00
Ryan Dwyer 4ad1ccc9dc Remove container_for_each_descendant_bfs
The function was not used.

Also renames container_for_each_descendant_dfs to just
container_for_each_descendant.
2018-08-11 15:57:09 +10:00
Ryan Dwyer 31844bf42b Remove container_has_child
In all cases you can use container_has_ancestor with the arguments
swapped, which is faster than container_has_child.
2018-08-11 15:36:19 +10:00
emersion d1433c637a xwayland: fix unmanaged surfaces order 2018-08-10 12:47:24 +01:00
Ryan Dwyer af693cba26 Update resize documentation 2018-08-10 08:50:38 +10:00
Ryan Dwyer 6c730a2cb2 Implement resize set <width> <height> for tiled containers
Unlike i3, this implementation allows px measurements.

Also fixes a sane size check.
2018-08-10 08:50:15 +10:00
Ryan Dwyer 9395d3c93c Implement resize grow|shrink <direction> <amount> for tiled containers 2018-08-10 08:50:15 +10:00
Drew DeVault db0fa066e5 Remove obsolete security sanity check 2018-08-09 08:45:32 -04:00
Brian Ashworth b6f4623551 Don't call swaynag_log for bg when not reading 2018-08-08 17:04:12 -04:00
Brian Ashworth 43d1ffc9dd Allow a fallback color to be specified for swaybg
This allows for a color to be set when the wallpaper does not fill the
entire output. If specified, the fallback color is also used when the
image path is inaccessible.
2018-08-08 15:37:06 -04:00
Brian Ashworth 3c26536267
Merge branch 'master' into master 2018-08-08 15:26:44 -04:00
Ryan Dwyer f5dc3ac09d Don't call send_pointer_notify_button when doing move or resize 2018-08-08 22:32:59 +10:00
Ryan Dwyer 4c5dc6f135 Focus floating views when beginning move/resize operations 2018-08-08 22:28:13 +10:00
Ryan Dwyer a0ece6f956 Rename container_at_view to surface_at_view and make it return void 2018-08-08 22:28:13 +10:00
Ryan Dwyer 1e984fec05 Fix focus when clicking floating decorations
It's not right for container_at_view to only return the swayc if a
surface was clicked.
2018-08-08 22:28:13 +10:00
Ryan Dwyer 5653fc754b Deny moving a sticky container to workspace if it's the same output
Rationale: Sticky containers are always assigned to the visible
workspace.

The basic idea here is to check the destination's output (move.c:190).
But if the command was `move container to workspace x` then a workspace
might have been created for it. We could destroy the workspace in this
case, but that results in unnecessary IPC events.

To avoid this, the logic for `move container to workspace x` has been
adjusted. It now delays creating the workspace until the end, and uses
`workspace_get_initial_output` to determine and check the output before
creating it.
2018-08-08 12:50:42 +10:00
Ryan Dwyer a0649190de Fix edge cases when moving floating container to new workspace
* Removes container_floating_move_to_container, instead opting to put
that logic in container_move_to
* In the seat code, focusing a floating view now updates the pending
state only and lets the next transaction carry it over to the current
state. This is required, otherwise it would crash.
* When unfullscreening a floating container, an output check is now done
to see if it should center it.
2018-08-08 08:48:20 +10:00
Ryan Dwyer 36281609ea Implement move to workspace on a floating container
Also adjusts container_floating_translate to not change the current
properties directly.
2018-08-08 08:48:20 +10:00
Drew DeVault 6f0bc469e9
Merge pull request #2432 from RyanDwyer/fix-move-crash
Fix crash when running `move container to workspace back_and_forth`
2018-08-07 10:27:45 -04:00
Ryan Dwyer 50f3a7ff5c Fix infinite loop when focusing sticky containers via workspace command
In a multi-output setup, if a sticky container is on one output and
focus is on the other output, and you run (eg) `workspace 1` to focus
the workspace containing the sticky container, an infinite loop would
occur. It would loop infinitely because it would remove the sticky
container from the workspace, add it back to the same workspace, and
then decrement the iterator variable.

The fix just wraps the loop in a workspace comparison.
2018-08-07 23:32:25 +10:00
Ryan Dwyer 5ac6f2f429 Fix crash when running move container to workspace back_and_forth
The back_and_forth condition is intended to be handled in the else-if
block, but this was never reached because it remained in the first
block's conditions.
2018-08-07 23:04:21 +10:00
Brian Ashworth 639f3368e1
Merge branch 'master' into workspace-move-to-output 2018-08-06 11:47:00 -04:00
Drew DeVault d8b65193c4
Merge pull request #2268 from emersion/server-decoration-borders
Enable borders on floating SSD xdg-shell views
2018-08-06 11:32:17 -04: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
emersion 700941dde8 Listen to server-decoration mode changes 2018-08-06 15:20:30 +01:00
Ryan Dwyer f57a3919cf Move workspace moving code out of container_move_to
container_move_to handled moving containers to new parents, as well as
moving workspaces to new outputs.

This commit removes the workspace-moving code from this function and
introduces workspace_move_to_output. Moving workspaces using
container_move_to only happened from the move command, so it's been
implemented as a static function in that file.

Simplifying container_move_to makes it easier for me to fix some issues
in #2420.
2018-08-07 00:03:01 +10:00
Ian Fan f7c21451df commands: fix workspace edge cases 2018-08-06 14:17:58 +01:00
Ian Fan 667b8dcb67 commands: check for special workspaces in workspace & move commands 2018-08-06 14:17:58 +01:00
Ian Fan 3b1f58e135 commands: document <criteria> focus 2018-08-06 14:17:58 +01:00
Ian Fan dd48c8a579 commands: add optional flags to move 2018-08-06 14:17:58 +01:00
Ian Fan 85ae121caa commands: complete workspace implementation
Allow optional --no-auto-back-and-forth flag, as well as refactoring some logic
2018-08-06 14:17:58 +01:00
Ian Fan 356063b6c0 commands: fix layout implementation (also better name for previous split layout) 2018-08-06 14:17:58 +01:00
Ian Fan 3a980857cb commands: better type for con_id string length 2018-08-06 14:17:58 +01:00
Ian Fan 69e1a421fc commands: complete move implementation 2018-08-06 14:17:58 +01:00
Ian Fan be64c46624 commands: complete layout implementation 2018-08-06 14:17:58 +01:00
Ian Fan 11ac66d6fe commands: allow __focused__ for con_id criterion 2018-08-06 14:17:58 +01:00
Ian Fan 710f27d0d2 commands: allow "first", "last", "newest" and "recent" as values for urgent criteria 2018-08-06 14:17:45 +01:00
Mariusz Bialonczyk 776b9b7e1f Fix segv when sway is terminating
I've got the following SIGSEGV when terminating sway:
```
Program terminated with signal SIGSEGV, Segmentation fault.
0x00005607dc603af5 in view_unmap (view=0x5607dcb3d350) at ../sway/tree/view.c:599
599		if (surviving_ancestor->type >= C_WORKSPACE) {
```
surviving_ancestor was NULL at that time

This commit is trying to fix this problem.
2018-08-05 17:04:20 +02:00
Geoff Greer 208831aec6 Fix compiler errors.
- Some platforms don't expose kill() unless _POSIX_C_SOURCE is defined.
- fork(), execl(), and setsid() need unistd.h on some platforms.

Basically, this fixes some platform-specific build errors.
2018-08-05 00:24:44 -07:00
Ryan Dwyer 30e7e0f7c7 Move workspace pid code to root.c 2018-08-04 14:01:49 +10:00
Ryan Dwyer 04489ff420 Separate root-related code
This creates a root.c and moves bits and pieces from elsewhere into it.

* layout_init has been renamed to root_create and moved into root.c
* root_destroy has been created and is called on shutdown
* scratchpad code has been moved into root.c, because hidden scratchpad
containers are stored in the root struct
2018-08-04 14:01:20 +10:00
Ryan Dwyer e24fc3df18
Merge branch 'master' into fix-2416 2018-08-04 10:15:29 +10:00
Brian Ashworth ad2a7c2618 Check correct ws for sticky and fix floating iter 2018-08-03 11:36:18 -04:00
Brian Ashworth 36fd84cc42 Remove swaynag_clone and use memcpy 2018-08-03 10:40:09 -04:00
Brian Ashworth a7f7d4a488 Write to swaynag pipe fd directly on config errors 2018-08-03 10:37:35 -04:00
Brian Ashworth f9a6407111 Show swaynag on config errors 2018-08-03 10:37:35 -04:00
emersion b49904dd7e
Merge pull request #2414 from RyanDwyer/fix-inactive-fullscreen-crash
Fix crash when fullscreen view closes on inactive workspace
2018-08-03 09:56:46 +01:00
emersion 16c1e21f26
Merge pull request #2415 from RyanDwyer/fix-fullscreen-container-crash
Fix crash when moving cursor over a fullscreen split container
2018-08-03 09:47:54 +01:00
Ryan Dwyer c17f0870ef Fix crash when moving cursor over a fullscreen split container
Calling container_at_view fails an assertion if the container isn't a
view. Calling tiling_container_at works correctly, as that function
checks if the container is a view and calls container_at_view if so.
2018-08-03 18:08:20 +10:00
Ryan Dwyer 854c5fbec8 Fix crash when fullscreen view closes on inactive workspace
When a view unmaps, normally the surviving ancestor (ie. after reaping)
needs to be arranged. When a fullscreen view unmaps, it arranges the
workspace rather than the surviving ancestor, but didn't handle cases
where the workspace itself was reaped. This happens if the workspace is
not currently shown and the fullscreen view was the last container on
that workspace.

This commit rewrites this part of view_unmap so it's more readable, and
fixes the crash by not arranging the workspace if it's been reaped. Note
that it no longer arranges the output under any circumstance - this
wasn't required anyway.
2018-08-03 17:55:58 +10:00
Ryan Dwyer 9e8d628a17 Deny "move container" when an empty workspace is focused 2018-08-03 17:13:37 +10:00