Commit graph

3058 commits

Author SHA1 Message Date
Brian Ashworth af45ee2d8b Handle shell special characters in bg file path
This changes it back so the path given to swaybg is enclosed in quotes.

Additionally, the only character that is escaped in the path stored is
double quotes now. This makes it so we don't need to keep an exhaustive
list of characters that need to be escaped.

The end user will still need to escape these characters in their config
or when passed to swaybg.
2018-09-28 23:12:24 -04:00
Ryan Dwyer 7661c71b33 Update gaps documentation 2018-09-29 12:59:02 +10:00
Ryan Dwyer bb708d0f82 Don't allow negative gaps 2018-09-29 12:58:54 +10:00
Ryan Dwyer 415a48ac63 Make gaps implementation consistent with i3-gaps
This changes our gaps implementation to behave like i3-gaps.

Our previous implementation allowed you to set gaps on a per container
basis. This isn't supported by i3-gaps and doesn't seem to have a
practical use case. The gaps_outer and gaps_inner properties on
containers are now removed as they just read the gaps_inner from the
workspace.

`gaps inner|outer <px>` no longer changes the gaps for all workspaces.
It only sets defaults for new workspaces.

`gaps inner|outer current|workspace|all set|plus|minus <px>` is now
runtime only, and the workspace option is now removed. `current` now
sets gaps for the current workspace as opposed to the current container.

`workspace <ws> gaps inner|outer <px>` is now implemented. This sets
defaults for a workspace.

This also fixes a bug where changing the layout of a split container
from linear to tabbed would cause gaps to not be applied to it until you
switch to another workspace and back.
2018-09-29 11:08:19 +10:00
Brian Ashworth a9d9944e76 sway{,bar,input}.5: changes for generic blocks 2018-09-28 13:30:54 -04:00
Brian Ashworth cc6544c538 sway.5: update set command information 2018-09-28 13:30:54 -04:00
Ian Fan 98576b9dda swaybar: fix setting binding mode indicator 2018-09-28 13:48:59 +01:00
Ryan Dwyer 56e9f31b2f Check for NULL output in workspace_valid_on_output 2018-09-28 22:35:38 +10:00
Ryan Dwyer 138d10d5d6 Rename workspace_outputs to workspace_configs and fix memory leak
When we eventually implement `workspace <ws> gaps inner|outer <px>`,
we'll need to store the gaps settings for workspaces before they're
created. Rather than create a workspace_gaps struct, the approach I'm
taking is to rename workspace_outputs to workspace_configs and then add
gaps settings to that.

I've added a lookup function workspace_find_config. Note that we have a
similar thing for outputs (output_config struct and output_find_config).

Lastly, when freeing config it would create a memory leak by freeing the
list items but not the workspace or output names inside them. This has
been rectified using a free_workspace_config function.
2018-09-28 22:35:38 +10:00
Ian Fan 0dfcadc1cf transaction: do not use pointers for state 2018-09-28 09:18:24 +01:00
Ryan Dwyer 22412f57b0 Fix floating views in tabbed/stacked workspaces not getting frame events
view_is_visible would return false, which meant the view wouldn't
receive a frame done event. view_is_visible needs to make an exception
for floating containers.

This also moves the workspace_is_visible check to an earlier location
for performance reasons.
2018-09-28 17:02:35 +10:00
Ryan Dwyer f16529e258 Remove server-decoration assumption if view supports xdg-decoration 2018-09-27 23:00:10 +10:00
Ryan Dwyer 21ff87d72b Improve CSD logic
This does the following:

* Removes the xdg-decoration surface_commit listener. I was under the
impression the client could ignore the server's preference and set
whatever decoration they like using this protocol, but I don't think
that's right.
* Adds a listener for the xdg-decoration request_mode signal. The
protocol states that the server should respond to this with its
preference. We'll always respond with SSD here.
* Makes it so tiled views which use CSD will still have sway decorations
rendered. To do this, using_csd had to be added back to the view struct,
and the border is changed when floating or unfloating a view.
2018-09-27 22:51:37 +10:00
Ryan Dwyer 6d0442c0c2 Rename view_set_csd_from_client to view_update_csd_from_client 2018-09-27 22:51:37 +10:00
Ryan Dwyer efcfe57b10 Remove CSD from toggle list if client doesn't support it 2018-09-27 22:51:37 +10:00
Ryan Dwyer 7b138e5ef0 Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also
removes sway_xdg_shell{_v6}_view.deco_mode and
view->has_client_side_decorations as we can now get these from the
border.

You can use `border toggle` to cycle through the modes including CSD, or
use `border csd` to set it directly. The client must support the
xdg-decoration protocol, and the only client I know of that does is the
example in wlroots.

If the client switches from SSD to CSD without us expecting it (via the
server-decoration protocol), we stash the previous border type into
view.saved_border so we can restore it if the client returns to SSD. I
haven't found a way to test this though.
2018-09-27 22:51:37 +10:00
Ian Fan a6c5628fa7 input config: merge left_handed option 2018-09-27 09:25:43 +01:00
Drew DeVault 5912be46c3
Merge pull request #2704 from ianyfan/tablet-config
input: enable configuring tablets with libinput
2018-09-27 02:07:15 -05:00
sghctoma 2f258eff6f Make sway/ipc-server.c POSIX 2001 compliant
This commit replaces the non-standard SOCK_NONBLOCK and SOCK_CLOEXEC
flags with two fcntl calls. This makes the file POSIX 2001 compliant,
thus it is no longer necessary to conditionally define, or use internal
(__BSD_VISIBLE) feature test macros.
2018-09-26 20:10:53 +02:00
Ryan Dwyer 4e4898e90f Fix race condition crash when view unmaps + maps quickly
When a view unmaps, we start a transaction to destroy the container,
then when the transaction completes we destroy the container and unset
the view's container pointer. But if the view has remapped in the
meantime, the view's container pointer will be pointing to a different
container which should not be cleared.

This adds a check to make sure the view is still pointing to the
container being destroyed before clearing the pointer. The freeing of
the title format is also removed as it is already freed when the view
destroys in view_destroy.
2018-09-26 21:33:54 +10:00
Alexander Bakker d129108cdd Add a missing null check for moving tiling containers 2018-09-25 22:19:46 +02:00
Ryan Dwyer b1a0e95e8e Fix crash when disconnecting output
If the output being disconnected contains views, and the views are being
relocated to another output of a different size, a transaction must
occur to reconfigure them. This means by the time
container_discover_outputs is called, the output is already disabled and
wlr_output is NULL.

I considered making it check output->wlr_output, but output->enabled
should work just as well and is more descriptive.
2018-09-25 08:21:22 +10:00
Ian Fan 6194a445d3 input: enable configuring tablets with libinput 2018-09-24 12:49:20 +01:00
Ian Fan a10fef9ae8 cursor: allow cursor_set_image to accept a NULL image to hide cursor 2018-09-24 12:34:09 +01:00
Ian Fan dafb0526d7 seat: only show cursor if pointer configured 2018-09-24 10:55:42 +01:00
Brian Ashworth baeb28ea62 Implement support for input wildcard 2018-09-23 19:56:52 -04:00
Ryan Dwyer 271b24ddfb Fix GtkMenuBar always opening first item
It seems like advertising that we support touch when we don't, while
using SSD, makes GtkMenuBar misbehave. Please don't ask me why...
2018-09-23 22:00:18 +10:00
Drew DeVault c2c257b884
Merge pull request #2695 from RyanDwyer/remove-moveoutoftabsstacks
Remove move_out_of_tabs_stacks
2018-09-23 06:19:12 -05:00
emersion 4bc327a021
Merge pull request #2694 from RyanDwyer/fix-sticky-jumping-on-switch
Prevent sticky containers from jumping on workspace switch
2018-09-23 09:42:07 +02:00
emersion 1af4d314d1
Merge pull request #2686 from RyanDwyer/tab-scrolling
Implement tab cycling using mouse wheel
2018-09-23 09:39:53 +02:00
Ryan Dwyer 9753e52d6b Flatten container in workspace_rejigger 2018-09-23 14:32:26 +10:00
Ryan Dwyer 0b7fb6943e Fix some bugs as a result of removing move_out_of_tabs_stacks 2018-09-23 13:55:06 +10:00
Ryan Dwyer 93624599b3 Remove move_out_of_tabs_stacks
This fixes the following. Create these layouts and run move right:

(Initial layout -> expected result -> actual result)

* `H[S[unfocused focused] unfocused]` ->
`H[S[unfocused] focused unfocused]` ->
`H[H[S[unfocused] focused] unfocused]`
* `H[S[unfocused focused] V[unfocused]]` ->
`H[S[unfocused] V[unfocused focused]]` ->
`H[H[S[unfocused] focused] V[unfocused]]`

move_out_of_tabs_stacks was originally made to allow views to move out
of the tabbed/stacked container in the parallel direction, but at some
point this has started working using the regular logic.
2018-09-23 13:10:36 +10:00
Ryan Dwyer 64445f4214 Prevent sticky containers from jumping on workspace switch
If you have swaybar docked to the top, and you create a floating sticky
container and switch workspaces on the same output, the sticky container
would move down by the height of swaybar on each switch.

This happens because when creating the workspace we set the dimensions
to the same as the output, then the subsequent arrange corrects it.
During this arrange, floating containers are translated so they stay
relative to the workspace. This translation needs to not occur for the
initial arrange.

This patch makes workspaces have a zero width and height when first
created, so we can detect whether this is the initial arrange and avoid
translating the floating containers if so.
2018-09-23 11:36:16 +10:00
Drew DeVault 68395f34f6
Merge pull request #2688 from RyanDwyer/exec-commands-without-focus
Allow running commands on containers without focusing them
2018-09-22 19:51:02 -05:00
Ryan Dwyer cb66bbea42 Allow running commands on containers without focusing them
This adds a `con` argument to `execute_command` which allows you to
specify the container to execute the command on. In most cases it leaves
it as `NULL` which makes it use the focused node. We only set it when
executing `for_window` criteria such as when a view maps. This means we
don't send unnecessary IPC focus events, and fixes a crash when the
criteria command is `move scratchpad` (because we can't give focus to a
hidden scratchpad container).

Each of the shell map handlers now check to see if the view has a
workspace. It won't have a workspace if criteria has moved it to the
scratchpad.
2018-09-23 08:39:11 +10:00
Ian Fan d101f3d357 commands: remove obselete code for sticky windows when switching workspace 2018-09-22 23:27:53 +01:00
Geoff Greer c495164f60 swaybar, swaylock, & tree/container: Set cairo font options to render text and lines with subpixel hinting (if available). 2018-09-22 11:34:21 -07:00
emersion eae42606e2
Merge pull request #2660 from RyanDwyer/fix-scratchpad-iteration
Fix double iteration of scratchpad containers
2018-09-22 13:40:01 +02:00
Ryan Dwyer 10ef118e09 Fix pango escaping and refactor escape_markup_text
Fixes #2674.

The cause of the issue was in get_pango_layout. When we call
pango_parse_markup, `text` is the escaped string, and the unescaped
string is then computed and written to `buf`. We were then passing the
unescaped string to pango_layout_set_markup, but this function needs the
escaped string. `buf` is not needed and has been removed.

The other part of this PR refactors escape_markup_text to remove the
dest_length argument and removes the -1 return value on error. It now
assumes that you've allocated dest to the correct length.
2018-09-22 18:33:28 +10:00
emersion fe7e66407c
Merge pull request #2678 from RyanDwyer/reconfigure-on-reposition
Reconfigure xwayland views when repositioned
2018-09-22 10:09:55 +02:00
Ryan Dwyer bf5933c501 Implement tab cycling using mouse wheel
Firstly, a change had to be made to the container_at functions. If you
create layout `T[view H[view view]]` and hover the second tab, the
container_at functions would return the focus_inactive child. They now
return the split container itself. To compensate for this,
dispatch_cursor_button has been adjusted to find the focus_inactive
child before focusing it.

The actual implementation of wheel scrolling is pretty straightforward.
This uses handle_cursor_axis, so I took a similar approach to
handle_cursor_button (ie. creating a dispatch_cursor_axis function).
2018-09-22 10:42:59 +10:00
Brian Ashworth 04862e2121
Merge branch 'master' into swaybar-hotplug 2018-09-21 15:28:53 -04:00
Ryan Dwyer ae2f53a477 Reconfigure xwayland views when repositioned
Fixes #2673.
2018-09-21 23:02:48 +10:00
Marien Zwart 37e51a20cc Fix compilation against wlroots without X11 backend 2018-09-21 21:25:03 +10:00
Ryan Dwyer 0798fadff2
Merge branch 'master' into render-output-segfault 2018-09-21 20:05:39 +10:00
emersion 82f1393cbb swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
2018-09-20 18:37:51 +02:00
emersion fa4308c5ab
Merge pull request #2671 from emersion/output-execute-no-focus
Fix segfault when executing command without focus
2018-09-20 18:36:47 +02:00
Drew DeVault 6ec3626228
Merge pull request #2676 from ianyfan/ipc
ipc: add pid information for views in layout tree
2018-09-19 17:37:58 -04:00
Ian Fan 81f3fda6fa ipc: add pid information for views in layout tree 2018-09-19 22:21:09 +01:00
emersion efc08ec888 Fix segfault when executing command without focus 2018-09-19 15:50:42 +02:00
emersion a2090d4222
Merge branch 'master' into create-output-command 2018-09-19 14:19:22 +02:00
Ian Fan 8e8a5ca217 config: free strings fields when freeing input config 2018-09-19 12:55:49 +01:00
Ryan Dwyer db28459634 Introduce create_output command (for developer use)
Should help with testing hotplugging.
2018-09-19 21:54:27 +10:00
emersion 4289343e17 Fix segfault in output_render 2018-09-19 11:03:25 +02:00
Ryan Dwyer c6ff1f67f1 Fix double iteration of scratchpad containers
root_for_each_container and root_find_container were using incorrect
logic to determine if a container was hidden in the scratchpad.
Containers will have a NULL parent if they are a direct child of a
workspace. Containers will have a NULL workspace if they are hidden in
the scratchpad.

The incorrect check meant that root_for_each_container would run the
callback on scratchpad containers twice. This meant that executing a
command such as `[class="$something"] scratchpad show` would cause the
command to run twice, resulting in the container being shown and hidden
again which is effectively a no op.

Fixes #2655.
2018-09-18 21:53:02 +10:00
William Wold f48999dd24 Fix crash moving out of tab container 2018-09-17 01:20:45 -07:00
Drew DeVault 456b91600d
Merge pull request #2637 from RyanDwyer/fix-tabbed-workspace-shenanigans
Make seat_get_active_child ignore floating children
2018-09-16 10:22:01 -04:00
Marien Zwart ffd1308bbc Fix crash when destroying an idle-inhibiting client
When destroying an idle-inhibiting client, idle_inhibit_v1_check_active can get
called from transaction_progress_queue on a view with a null container.
view_is_visible does not handle a view in this state.
2018-09-16 23:20:58 +10:00
Ryan Dwyer f6e218a643 Rename seat_get_active_child to seat_get_active_tiling_child
Also renames container to con in one function to prevent ugly line
wrapping.
2018-09-16 22:01:54 +10:00
Ryan Dwyer 48bc15e758 Make seat_get_active_child ignore floating children
seat_get_active_child is used to get the active tiling child in a few
places, such as outputs getting their active workspace and
tabbed/stacked containers getting their visible child. When a workspace
uses a tabbed or stacked layout and contains a focused floating view,
calling seat_get_active_child on the workspace would incorrectly return
the floating view. This changes it so it will return the tiling child.

This fixes the following bug:

* Create layout T[view view] then float one of the views
* Attempt to click the tiling view to give it focus - it wouldn't work
because seat_get_active_child would return the floating view
2018-09-16 21:57:19 +10:00
Ryan Dwyer 09733e233f Fix crash when unmapping last child of a tabbed workspace
* Create layout T[view view]
* Move the cursor into the title bar area
* Close both views

Sway would crash because container_at_tabbed would attempt to divide by
zero when there are no children.

The children check isn't needed for the stacked function because it
doesn't divide anything by the number of children.

Fixes #2636.
2018-09-16 14:18:13 +10:00
Ian Fan 34dbbb1314 ipc: handle NULL cases for node_get_output 2018-09-15 09:42:49 +01:00
Ian Fan 1c292fd43a ipc: add focus information to root node 2018-09-15 09:42:49 +01:00
Drew DeVault 64d567be9b
Merge branch 'master' into wlroots-1243 2018-09-14 21:03:59 -04:00
Drew DeVault 3b92d5bb6d Additional fix for xdg-output 2018-09-14 21:03:35 -04:00
Drew DeVault b4d60da856
Merge branch 'master' into wlroots-1243 2018-09-14 20:56:50 -04:00
Drew DeVault 73aab86b6d Postfix xdg-output headers
"Doesn't need an update" my ass...
2018-09-14 20:55:05 -04:00
Ian Fan 25ba80057d Remove redundant container creation in view initialization 2018-09-15 01:24:10 +01:00
emersion 7699c5444c Update for swaywm/wlroots#1243 2018-09-14 19:21:44 +02:00
Brian Ashworth 17fe8924f2 Address ianyfan's comments
wordexp p is now initialized to {0} to prevent a segfault on wordfree
in the failure case.

File paths with single quotes and double quotes are now supported. The
quote can either be wrapped in the other quote or escaped with three
backslashes.

Additionally to make passing file paths with double quotes to swaybg
easier, instead of enclosing the path given to swaybg in quotes, all
spaces, single quotes, and double quotes in the resulting path are now
escaped with a single backslash.
2018-09-14 08:51:01 -04:00
Brian Ashworth 1cf737489d Escape spaces in background file path 2018-09-13 22:21:10 -04:00
Brian Ashworth 0b64cce733 Allow spaces in background file paths 2018-09-13 22:21:10 -04:00
Ryan Dwyer 2f6935e00f Remove bad assertion in workspace_rejigger
The assertion can be (rightfully) triggered by creating layout
V[H[view view] view] and moving the top right view to the right.

After removing the assertion I found the container being moved needs its
size reset to prevent it from being sized wrongly after arranging.
2018-09-13 17:02:10 +10:00
emersion af9e8f94cc
Merge pull request #2620 from ianyfan/commands
commands: when moving a container, restore focus properly
2018-09-12 09:20:47 +02:00
Drew DeVault 7a295e8932
Merge pull request #2624 from RedSoxFan/update-tex-in-cmd-client
Update textures for cmd_client_* commands
2018-09-11 19:55:23 -04:00
Drew DeVault d8a96c9e4d
Merge pull request #2621 from emersion/fix-unmap-segfault
Don't use handler_context in view_unmap
2018-09-11 19:50:00 -04:00
Brian Ashworth 0b7fe54f9e Update textures for cmd_client_* commands
Since the `client.{focused,focused_inactive,unfocused,urgent}` commands
change colors, the textures need to be updated otherwise the textures
and the rest of the title bar may utilize different colors.
2018-09-11 19:34:57 -04:00
Ryan Dwyer 679c7eb08c Minor fixes to tiling drag implementation
* Make container_add_sibling's `after` argument a boolean.
* Use a constant for drop layout border
* Make thickness an int
* Add button state check
* Move comments in seat_end_move_tiling
2018-09-12 08:46:46 +10:00
emersion 8b263429cf Don't use handler_context in view_unmap 2018-09-11 19:34:58 +02:00
Ian Fan ae535396b0 commands: when moving container, remove its gaps 2018-09-11 16:46:11 +01:00
Ian Fan c770949a9f commands: when moving container, restore focus properly 2018-09-11 16:46:07 +01:00
Ryan Dwyer df95c61044 Fix crash in workspace_wrap_children
When workspace_wrap_children is called on a workspace which has a
fullscreen child and the fullscreen child is a direct child of the
workspace, sway would crash.

The workspace's fullscreen pointer is unset when the fullscreen
container is detached and applied again when added to a parent, but in
this case the parent hadn't yet been added to the workspace which meant
con->workspace was NULL.

The fix makes container_handle_fullscreen_reparent return if there's no
workspace, and the fullscreen pointer is reapplied in
workspace_wrap_children.
2018-09-11 23:38:17 +10:00
Ryan Dwyer 403905c11b Fix line length 2018-09-11 23:24:57 +10:00
Ryan Dwyer eb74317c2d Fix dropzone box on scaled outputs 2018-09-11 22:26:39 +10:00
Ryan Dwyer 8bb40c24c7 Implement tiling drag
Hold floating_modifier and drag a tiling view to a new location.
2018-09-11 21:34:21 +10:00
Ryan Dwyer ec9c4de564 Introduce tiling_drag directive 2018-09-11 17:17:19 +10:00
Ryan Dwyer d4e80cf301 Rename OP_MOVE to OP_MOVE_FLOATING
In preparation for introducing OP_MOVE_TILING.
2018-09-11 16:56:05 +10:00
William Wold 097ed03647 Minor fix 2018-09-10 17:52:42 -07:00
William Wold 22c5dd8a02 Minor fix 2018-09-10 10:18:12 -07:00
William Wold 9a08019267 Prevent stacked layout from crashing 2018-09-10 10:18:12 -07:00
William Wold e787a1581c Give windows pointer focus immediately when they are switched to
Fixes #2401 (aka #2558)

Previously, when switching windows, pointer focus was not changed until the pointer was moved. This makes the pointer enter happen immediately, without the side effects of other attempted fixes.
2018-09-10 10:18:12 -07:00
emersion 024b9d85ea
Merge pull request #2613 from apreiml/fix_no_last_focus_fail
handle_layer_shell_surface: Do not crash if seat doesn't have focus
2018-09-10 13:56:02 +02:00
Armin Preiml 47b6fea3fe handle_layer_shell_surface: Do not crash if seat doesn't have focus 2018-09-10 11:23:08 +02:00
Ian Fan 6cd92b193c commands: prevent running empty seat command 2018-09-08 19:53:27 +01:00
Drew DeVault 1376d36104
Merge pull request #2530 from apreiml/ipc_missing_get_tree
start adding missing ipc properties
2018-09-08 09:20:36 -04:00
Armin Preiml 7919ae5e44 code style fixes 2018-09-08 13:24:01 +02:00
Armin Preiml 2dec0d894b get_tree: percent cast to double on division 2018-09-08 13:24:01 +02:00
Armin Preiml 79eaa26b3e get_tree: default values
Added default values for all nodes, because the i3 get_tree always returns
all fields inside the json objects.

Add geometry and window for views. Window is only availabel on
x11 windows otherwise it's NULL.

Calculate percent only if parent is not empty to avoid division by 0.
2018-09-08 13:24:01 +02:00
Armin Preiml 3d8c3e560b missing ipc stuff: rebase to typesafety 2018-09-08 13:24:01 +02:00
Ryan Dwyer 9215ca0f01 Align titles to baseline
This does the following:

* Adds a baseline argument to get_text_size (the baseline is the
distance from the top of the texture to the baseline).
* Stores the baseline in the container when calculating the title
height.
* Takes the baseline into account when calculating the config's max font
height.
* When rendering, pads the textures according to the baseline so they
line up.
2018-09-08 16:25:07 +10:00
Ryan Dwyer 9226aad58c Fix gaps in title textures and vertically center them
There was code that attempted to fill in the gap below the title texture
when the texture isn't tall enough, but this only worked when the output
was positioned at 0,0. The reason is that render_rect expects a box
passed in a hybrid layout-local/output-buffer-local system, and we were
passing purely output-buffer-local. I've added a comment documenting
this.

By the way, we can't use layout-local coordinates for the rectangle box
because in some cases we set the box based on a texture size. Texture
sizes are buffer-local, and we'd have to divide them to bring it back to
layout-local which means losing precision. We could use
output-buffer-local coordinates for the box, but this would require
translating the coordinates from layout-local to output-buffer-local in
many places during rendering.

This patch also vertically centers the text inside the title bar.
2018-09-08 16:25:07 +10:00
Drew DeVault 030b5bc024
Merge pull request #2603 from emersion/fix-dnd
Fix drag-and-drop
2018-09-07 11:09:02 -04:00
emersion 251a7ebc4b Fix drag-and-drop 2018-09-07 15:43:15 +02:00
Ryan Dwyer 763554e1be Fix workspace switching
The output also needs to be made dirty when focusing a new output.
2018-09-07 08:08:40 +10:00
emersion f3b96d4050
Merge pull request #2594 from RyanDwyer/fix-pinentry
Float views when min == max on either dimension
2018-09-06 21:28:51 +02:00
Ryan Dwyer cf32d5d776 Float views when min == max on either dimension
This fixes pinentry-gtk-2, but might make other views floating which
would otherwise be tiled. This patch is more of a trial which could end
up becoming a permanent fix.
2018-09-06 23:57:57 +10:00
Ryan Dwyer f30527e0cd Don't dirty outputs unnecessarily 2018-09-06 23:25:10 +10:00
Ryan Dwyer 635ae9557c Second attempt at restoring focus when closing a fullscreen view
To reproduce the problem this is fixing, create H[view view view],
fullscreen one of the views and close it. The entire workspace will be
given focus rather than one of the siblings.

This happens because we emit the destroy event, so the seat code tries
to find a new focus, but the view it finds is still believed to be
hidden by the fullscreen view so it's discarded and the workspace is
used instead.

This clears the workspace's fullscreen pointer prior to emitting the
destroy event so that the seat code finds an appropriate new focus.
2018-09-06 22:34:09 +10:00
Ryan Dwyer 5896781df4 Make outputs dirty when changing focus
Fixes a workspace switch bug introduced by
5967ee1fbc.
2018-09-06 21:15:24 +10:00
emersion 8e2a2e5ca4
Merge pull request #2589 from RyanDwyer/seat-set-focus-type
Introduce seat_set_focus_container and seat_set_focus_workspace
2018-09-06 12:56:21 +02:00
Ryan Dwyer 5967ee1fbc Fix crash when switching to new workspace during transaction
When rendering, the workspace for the output needs to be retrieved from
the output's `current` state. output_get_active_workspace returns the
pending workspace, which crashes if the pending workspace is new and
hasn't completed a transaction yet.
2018-09-06 20:20:29 +10:00
Ryan Dwyer 908095ef9a Introduce seat_set_focus_container and seat_set_focus_workspace
These are the same as seat_set_focus, but accept a specific type rather
than using nodes. Doing this adds more typesafety and lets us avoid
using &con->node which looks a little ugly.

This fixes a crash that pretty much nobody would ever come across. If
you have a bindsym for "focus" with no arguments and run it from an
empty workspace, sway would crash because it assumes `container` is not
NULL.
2018-09-06 19:26:56 +10:00
emersion bea9f9c63f
Merge pull request #2578 from RyanDwyer/fix-binding-reload
Fix management of bindings during reload
2018-09-06 10:41:49 +02:00
Ryan Dwyer 1f941163d3 Fix crash when running "layout toggle"
The argc and argv used in this function are the same ones used by the
layout command itself.
2018-09-06 14:29:26 +10:00
Drew DeVault c6a74cb4df
Merge pull request #2586 from RyanDwyer/fix-fullscreen-focus-crash
Fix crash when focusing from fullscreen in an invalid direction
2018-09-05 22:12:54 -04:00
Drew DeVault 2eec9740bd
Merge pull request #2585 from RyanDwyer/fix-move-across-outputs
Fix crash when moving view across outputs
2018-09-05 22:04:38 -04:00
Ryan Dwyer 8859da1dc3 Fix crash when focusing from fullscreen in an invalid direction
* Fullscreen a view
* Run `focus <direction>` where there is no output in that direction

The output returned was rightfully NULL, which needs to be handled.
2018-09-06 12:03:13 +10:00
Drew DeVault 7b79ab2577
Merge pull request #2583 from RyanDwyer/fix-null-surface-crash
Fix crash when views rapidly map and unmap
2018-09-05 21:59:13 -04:00
Ryan Dwyer 01117db6d9 Fix crash when moving view across outputs
It was incorrectly determining that the container being moved and the
destination had the same parent, which resulted in tree corruption. Both
parents can be NULL but the containers may belong to different
workspaces.

To reproduce, create layout H[V[view] view] in one workspace then move a
view left or right from another output into that workspace.
2018-09-06 11:53:55 +10:00
Ryan Dwyer 9642b87b9e Fix crash when views rapidly map and unmap
Suppose the following:

* Transactions are already in progress - say transaction A.
* View A maps, which creates transaction B and appends it to the
transaction queue.
* View B maps, which creates transaction C and appends it to the queue.
* View A unmaps, which creates transaction D and appends it to the
queue.
* Transaction A completes, so transaction B attempts to save View A's
buffer, but this doesn't exist so it saves nothing.
* Rendering code attempts to render View A, but there is no saved buffer
nor live buffer that it can use.

Rather than implement an elaborate solution for a rare circumstance,
I've take the safe option of just not rendering anything for that view.
It means that if you reproduce the scenario above, you might get the
title and borders rendered but no surface.
2018-09-06 11:39:52 +10:00
Drew DeVault f255881134
Merge pull request #2579 from RyanDwyer/adjust-container-box
Adjust container box
2018-09-05 21:14:19 -04:00
Ryan Dwyer 5cc70d1dfd Restore focus correctly when closing a fullscreen view
We weren't calling seat_send_focus. I think this was previously called
by seat_set_focus_warp.
2018-09-06 09:33:37 +10:00
Ryan Dwyer c6368febc8 Adjust container box
Prior to f5b9815128, children of tabbed
and stacked containers would have their container size and position set
to the same as the tabbed/stacked container. Normally this would be a
problem for a layout such as T[V[view]], but there was some code in the
arrange functions which would check if the grandparent of the view was a
tabbed or stacked container and would offset the view's Y accordingly.

Commit f5b9815128 changed the box to
exclude the titlebar for all tabbed/stacked children so that the
grandparent check could be removed. But this meant the title was not
covered in the container and wasn't damaged when the child changed its
title.

This patch changes it so that a child of a tabbed/stacked container will
have its box include the title bar if the child is a view, but not if
it's a layout container. This fixes the title damage issue while
avoiding the grandparent check in the arrange functions, and matches
what we see visually.
2018-09-06 09:13:36 +10:00
Ryan Dwyer 32c7386b0f Fix management of bindings during reload
seat_execute_command needs to check the flags on `binding_copy`, as
`binding` will be a dangling pointer after a reload command.

handle_keyboard_key needs to set the next_repeat_binding for
non-reloads prior to executing the command in case the binding is
freed by the reload command.
2018-09-06 08:33:00 +10:00
Brian Ashworth c246cf84c8 Call wlr_output_enable on enable/disable if needed 2018-09-05 14:00:00 -04:00
Ryan Dwyer dbf4aa3e33 Allow marked containers to be moved out of the scratchpad via move command 2018-09-05 18:01:43 +10:00
Ryan Dwyer 1f2e0ff54b Fix inversed condition in criteria 2018-09-05 18:01:43 +10:00
Ryan Dwyer 6f71749398 Fix clicking workspace buttons
Because node_at_coords was returning the workspace's node, it
interpreted this as clicking the focused workspace which was a no op.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 3cc7de3fb4 Fix crash when view in scratchpad becomes urgent 2018-09-05 18:01:43 +10:00
Ryan Dwyer e5c9204b49 Focus empty workspace when clicking it
Also removes container_at_coords as this function is no longer
necessary.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 27d2d37d6e Fix crash when running layout toggle split 2018-09-05 18:01:43 +10:00
Ryan Dwyer c0da364865 Fix floating view moving to 0,0 when splitting 2018-09-05 18:01:43 +10:00
Ryan Dwyer 7263e39f64 Fix crash when using focus parent/child from an empty workspace 2018-09-05 18:01:43 +10:00
Ryan Dwyer 4e0452fce3 Fix scratchpad related crashes
* Was crashing when a view was moved to the scratchpad (prev focus had
no parent).
* Was crashing when a hidden scratchpad view unmaps because it has no
workspace.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 93ff7879f1 Fix output position issue
Looks like the output dimensions need to be set when arranging rather
than when a mode is set.

Fixes an issue with position of fullscreen views.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 7f40b928c7 Fix another focus bug when moving into output
Find the focused_inactive view rather than possibly selecting a parent.
2018-09-05 18:01:43 +10:00
Ryan Dwyer fb9b0f7a08 Fix focus bug
When changing focus from a view in one workspace to an empty workspace
using `focus <direction>`, the view in the previous workspace would keep
focused styling. This is because the check to unfocus it was only done
in the container case and not workspace case, so it's been moved out of
both.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 3133d0c03c Fix swaybars with no defined output 2018-09-05 18:01:43 +10:00
Ryan Dwyer eccfcde2eb Fix crash when moving mouse over a fullscreen split container 2018-09-05 18:01:43 +10:00
Ryan Dwyer 9d168a693d Fix moving workspace to output 2018-09-05 18:01:43 +10:00
Ryan Dwyer 0b23423c14 Update output propertes on mode change
This was previously done when arranging the output, but only needs to be
done on mode change.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 2aa6afae54 Fix mouse_warping 2018-09-05 18:01:43 +10:00
Ryan Dwyer 26204441b4 Apply default config to output
When starting without any output config, the default config was not
applying.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 06d9693829 Remove offset argument to container_add_sibling
I added this thinking that it might come in useful. Turns out it didn't.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 0df04e27b6 Fix crash when focus hits edge of root 2018-09-05 18:01:43 +10:00
Ryan Dwyer acc2628c79 Don't use wlr_output properties
These properties are before rotation.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 7586f150c0 Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.

In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.

If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.

There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.

In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.

The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.

The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.

Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.

Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.

In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.

container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.

`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.

container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.

There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.

The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 7797490e9e Deny repeating reload by holding key
Fixes #2568

The binding that gets stored in the keyboard's `repeat_binding` would
get freed on reload, leaving a dangling pointer.

Rather than attempt to unset the keyboard's `repeat_binding` along with
the other bindings, I opted to just not set it for the reload command
because there's no point in reloading repeatedly by holding the binding.
This disables repeat bindings for the reload command.

As we now need to detect whether it's a reload command in two places,
I've added a binding flag to track whether it's a reload or not.
2018-09-04 20:00:04 +10:00
Ryan Dwyer 29f5cc7508 Implement window_role criteria token
Depends on https://github.com/swaywm/wlroots/pull/1226
2018-09-04 08:23:50 +10:00
Drew DeVault 0b61bae8fb
Merge pull request #2564 from ppascher/master
Fix window_type with disabled xwayland support
2018-09-03 11:04:03 -04:00
Drew DeVault e4afd33d47
Merge pull request #2542 from sghctoma/fix-freebsd-build
FreeBSD fixes
2018-09-03 10:59:18 -04:00
Drew DeVault 7d353813d5
Merge pull request #2563 from taiyu-len/fix/misaligned-pointer-access
fix misaligned integer stores/loads
2018-09-03 10:57:21 -04:00
Ian Fan e6fde0739a Fix crash when a splash screen opens on an empty workspace 2018-09-03 14:03:49 +01:00
Pascal Pascher 93673095f0 move criteria "instance", "class" and "window_role" inside HAVE_XWAYLAND ifdefs" 2018-09-03 14:25:48 +02:00
Pascal Pascher 587e320cd8 Fixed window_type with disabled xwayland support. 2018-09-03 11:13:50 +02:00
sghctoma 073dcb3a86 Change _XOPEN_SOURCE defines to _POSIX_C_SOURCE 2018-09-03 09:08:49 +02:00
sghctoma df730a8891 Merge remote-tracking branch 'upstream/master' into fix-freebsd-build 2018-09-03 08:57:17 +02:00
Brian Ashworth afb6968874
Merge branch 'master' into disabled-no-modeset 2018-09-03 00:24:28 -04:00
taiyu d625d68d4a
prevent ub caused by misaligned stores/loads 2018-09-02 17:07:12 -07:00
Ryan Dwyer 6fb03817c9 Rename fowa enum and use switch in view_request_activate 2018-09-02 18:25:45 +10:00
Ryan Dwyer f057a0195e Implement focus_on_window_activation
Depends on https://github.com/swaywm/wlroots/pull/1223
2018-09-02 18:20:34 +10:00
Ryan Dwyer 69cd1dfaca Check modal state when determining whether an xwayland view should float
Depends on https://github.com/swaywm/wlroots/pull/1222.

I don't know of a program that sets the state to modal without setting
the window type, but I know the modal property works because logging the
property shows it's true for the Firefox Open File dialog.
2018-09-02 17:14:12 +10:00
emersion ca3be93757
Merge pull request #2554 from emersion/init-dmabuf-global-in-renderer
Update for swaywm/wlroots#1216
2018-09-02 08:51:07 +02:00
emersion 407c12fddd Update for swaywm/wlroots#1216 2018-09-01 19:33:24 +02:00
Drew DeVault 80270ba086
Merge pull request #2544 from RyanDwyer/fix-deferred-cmd-crash
Fix crash when running deferred commands
2018-09-01 13:00:26 -04:00
emersion 349d1f3be8 Do not modeset disabled outputs 2018-09-01 18:56:53 +02:00
Drew DeVault 89a045835f
Merge pull request #2547 from RyanDwyer/fix-reload-crash
Fix crash on reload
2018-09-01 10:39:36 -04:00
Drew DeVault 692dc55eca
Merge pull request #2549 from RyanDwyer/border-improvements
Implement deprecated new_window and new_float commands
2018-09-01 10:38:02 -04:00
Ryan Dwyer f4ec308376 Implement window_type criteria token 2018-09-01 23:04:49 +10:00
Ryan Dwyer 016d0455f8 Implement deprecated new_window and new_float commands
May as well make it as easy as possible for users who are coming from
i3.

This also changes the `border` command to accept a thickness when
setting the border to normal. This makes it work the same way as the
`default_border` command. Eg. `border normal 5`
2018-09-01 21:28:13 +10:00
Ryan Dwyer 7e81e58e7d Allow reload command to exist anywhere in the command string
This fixes a crash if you have commands where reload appears in the
middle or at the end, such as `bindsym r mode default, reload`.
2018-09-01 11:45:48 +10:00
Ryan Dwyer ebe65a4d48 Fix crash on reload
If sway is reloaded using a bindsym which has multiple commands, it
failed to detect the reload command, didn't create a duplicate of the
binding and would crash because the reload command frees the bindings.

For example:

    mode system {
        bindsym r reload, mode default
    }

In this example, the binding->command is "reload, mode default".

Fixes #2545
2018-09-01 11:17:15 +10:00
Ryan Dwyer dce549c537 Don't send never-ending transactions when a focused layer surface commits
This moves the arrange_windows call into the arrange_layers function,
where we know the output actually needs to be arranged.

Additionally, we shouldn't set focus to the parent of an unknown
container type, because the parent may be an output and this causes a
crash because outputs can't have direct focus.

Fixes #2543
2018-08-31 21:39:28 +10:00
Ryan Dwyer 1e0459f7f7 Fix crash when running deferred commands
Fixes #2541
2018-08-31 19:49:12 +10:00
sghctoma 67188b7cba Enable privilege dropping of FreeBSD
Privilege dropping works on FreeBSD too, so only the caps parts need to
be Linux-only.
2018-08-30 10:33:48 +02:00
sghctoma ac7a0aa038 Add missing destroy calls to server_fini
Rootston calls "wlr_xwayland_destroy" and "wl_display_destroy_clients"
on shutdown, but these were not called by Sway. Without them, Sway
crashes on exit before the display destroy event handler could be
called. This causes two problems:

 - The TTY is not reset, and it locks up after exiting Sway.
 - drmDropMaster is not called, and the implicit drop (that should
   occur when the DRM fd is closed) seems not to be working in some
   scenarios (e.g. if you have a tmux session running - maybe the fd
   is retained somehow by tmux?). In other words, it you exit Sway,
   you can't start it (or any other program that wants to be DRM
   master) again until you close all your tmux sessions.
2018-08-30 10:05:04 +02:00
sghctoma cc16948c85 Fix feature macros for FreeBSD
On FreeBSD, snprintf and vsnprintf are visible only if
_XOPEN_SOURCE >= 600.
2018-08-30 09:34:26 +02:00
Drew DeVault de9e80459a
Merge pull request #2537 from ianyfan/commands
commands: fix exec quoting
2018-08-29 08:42:03 -04:00
Drew DeVault 3686724c9e
Merge pull request #2531 from RyanDwyer/maybe-fix-transaction-crash
Don't use bitfield to test for similar transactions
2018-08-29 08:40:13 -04:00
Ian Fan 79899064b6 commands: fix exec quoting 2018-08-29 10:55:12 +01:00
Ryan Dwyer 3c4196b986 Fix rendering of nested tabs
The C_CONTAINER check needs to apply to C_VIEW as well.
2018-08-29 14:38:51 +10:00
Ryan Dwyer 2438f5f050 Fix crash when reaping a workspace
It wasn't returning the surviving container.
2018-08-29 10:51:54 +10:00
Ryan Dwyer 53fe7b02e9 Fix workspace tabs
When collecting focus to save into the transaction state, the workspace
needs to look in the tiling list only.

As seat_get_focus_inactive_tiling returns any descendant, the list also
needs to be traversed back up to the direct child of the workspace.

Fixes #2532
2018-08-29 10:38:46 +10:00
Ryan Dwyer b12f7be907 Don't use bitfield to test for similar transactions
When there's multiple transactions in the queue, sway can take a
shortcut by checking if they all operate on the same set of containers.
If they do, it can skip all but the last transaction. The way we tested
for transactions which used the same containers was to exclusive-or
their con IDs together, but this has proved not only to be ineffective
but also has the potential to make sway crash.

This patch replaces the exclusive-or with a loop and container
comparison.
2018-08-29 08:29:11 +10:00
Ian Fan bc30f2d528 commands: fix moving container to different output
When moving a container to an inactive workspace on a different output, this will change the focus on the destination output back to its last active workspace
2018-08-28 15:08:46 +01:00
Ryan Dwyer 126a82f14f Fix gaps issues
* In layout command, arrange parent of parent - not sure why this is
needed but it is
* Remove gap adjustment when rendering
* Workspace should use outer gaps, not inner
* Add exceptions for tabbed and stacked containers
* Don't mess with gap state when splitting a container
2018-08-28 23:53:51 +10:00
Ryan Dwyer f5b9815128 Prepare arrange code for type safe arguments
This commit changes the arrange code in a way that will support type
safe arguments.

The arrange_output et al functions are now public, however I opted not
to use them directly yet. I've kept the generic arrange_windows there
for convenience until type safety is fully implemented. This means this
patch has much less risk of breaking things as it would otherwise.

To be type safe, arrange_children_of cannot exist in its previous form
because the thing passed to it could be either a workspace or a
container. So it's now renamed to arrange_children and accepts a list_t,
as well as the parent layout and parent's box.

There was some code which checked the grandparent's layout to see if it
was tabbed or stacked and adjusted the Y offset of the grandchild
accordingly. Accessing the grandparent layout isn't easy when using type
safe arguments, and it seemed odd to even need to do this. I determined
that this was needed because a child of a tabbed container would have a
swayc Y matching the top of the tab bar. I've changed this so a child of
a tabbed container will have a swayc Y matching the bottom of the tab
bar, which means we don't need to access the grandparent layout.  Some
tweaks to the rendering and autoconfigure code have been made to
implement this, and the container_at code appears to work without
needing any changes.

arrange_children_of (now arrange_children) would check if the parent had
gaps and would copy them to the child, effectively making the
workspace's gaps recurse into all children. We can't do this any more
without passing has_gaps, gaps_inner and gaps_outer as arguments to
arrange_children, so I've changed the add_gaps function to retrieve it
from the workspace directly.

apply_tabbed_or_stacked_layout has been split into two functions, as it
had different logic depending on the layout.

Lastly, arrange.h had an unnecessary include of transaction.h. I've
removed it, which means I've had to add it to several other files.
2018-08-28 23:50:41 +10:00
Drew DeVault 98ef29c228
Merge pull request #2523 from RedSoxFan/fix-floating-drag-outputs
Stop floaters from snapping on move to new output
2018-08-27 13:44:08 -04:00
Drew DeVault 82423b88b8
Merge pull request #2494 from RyanDwyer/fix-overflowing-subsurfaces
Allow subsurfaces which overflow the container to be interacted with
2018-08-27 12:41:39 -04:00
Drew DeVault 9d9de97c4c
Merge pull request #2520 from RedSoxFan/destroy-empty-ws-on-evac
Destroy empty workspaces in output_evacuate
2018-08-27 12:32:29 -04:00
Ian Fan 3bf849d993 seat.c: clean-up seat_set_focus_warp function 2018-08-27 13:25:01 +01:00
Brian Ashworth 11c1619f30 Stop floaters from snapping on move to new output 2018-08-27 03:06:37 -04:00
Scott Anderson 31c3c8a365 Initialise variable properly 2018-08-27 18:01:17 +12:00
Brian Ashworth 148b113b8d Destroy empty workspaces in output_evacuate 2018-08-27 00:18:20 -04:00
Ian Fan 6ae2e3a4a8 ipc: clean-up container_create_notify function 2018-08-26 19:01:09 +01:00
Ian Fan e7c94708f2 ipc: emit window close event earlier, before destroying 2018-08-26 19:01:09 +01:00
Drew DeVault 10c2c09cf6
Merge pull request #2513 from RyanDwyer/rename-root-outputs
Rename sway_root.outputs to sway_root.all_outputs
2018-08-26 10:50:02 -04:00
Ryan Dwyer 5dbbab7bdc Remove layout.c
When we have type safety we'll need to have functions for
workspace_add_tiling and so on. This means the existing container
functions will be just for containers, so they are being moved to
container.c. At this point layout.c doesn't contain much else, so I've
relocated everything and removed the file.

* container_swap and its static functions have been moved to the swap
command and made static.
* container_recursive_resize has been moved to the resize command and
made static.
* The following have been moved to container.c:
    * container_handle_fullscreen_reparent
    * container_insert_child
    * container_add_sibling
    * container_add_child
    * container_remove_child
    * container_replace_child
    * container_split
* enum movement_direction and sway_dir_to_wlr have been moved to util.c.

Side note: Several commands included layout.h which then included
root.h. With layout.h gone, root.h has to be included by those commands.
2018-08-26 12:05:16 +10:00
Ryan Dwyer 8bed4be1f3 Make separate gaps functions per container type
In preparation for using type safety.
2018-08-26 09:52:12 +10:00
Armin Preiml 1a72149d88 Workspace move cycle
On move workspace to direction: Try the farthest on the opposite
direction if no workspace is found at given direction.
2018-08-25 17:10:41 +02:00
Ryan Dwyer 2e7401772e Rename sway_root.outputs to sway_root.all_outputs
This list includes disabled outputs.

When sway_container is demoted, we'll need to store the root's children
(ie. enabled outputs) in the sway_root. It makes sense to put these in a
list called `outputs`, so I'm renaming the existing list in advance.
2018-08-25 23:41:11 +10:00
Drew DeVault b945957b9b
Merge pull request #2510 from RyanDwyer/relocate-layout-functions
Relocate container_move, container_move_to and container_get_in_direction
2018-08-25 09:38:33 -04:00
Ryan Dwyer 4b9ad9c238
Merge branch 'master' into commands 2018-08-25 13:06:04 +10:00
Ryan Dwyer f4bc25bcc6 Relocate container_move, container_move_to and container_get_in_direction
* container_move is only called from the move command
* container_move_to was called from both the move command and the sticky
command, but the sticky command can easily not call it
* container_get_in_direction is only called from the focus command

Moving these functions to their respective commands gives better
separation of code and removes bloat from layout.c. These functions will
need to be refactored to take advantage of type safety, so separating
them will make this easier to refactor.

The following static functions have also been moved:

* is_parellel
* invert_movement
* move_offs
* container_limit
* workspace_rejigger
* move_out_of_tabs_stacks
* get_swayc_in_output_direction

They were all used by the move functions, except for the last one which
is used by focus.

Other changes:

* index_child has been renamed to container_sibling_index, moved to
container.c and made public
* sway_output_from_wlr has been renamed to output_from_wlr_output, moved
to output.c and made public
* container_handle_fullscreen_reparent has been made public
* sway_dir_to_wlr has been made public

No changes have been made to any of the moved functions, other than
updating calls to functions that have been renamed.
2018-08-25 12:09:42 +10:00
Ryan Dwyer b6058703fa Refactor destroy functions and save workspaces when there's no outputs
This changes the destroy functions to the following:

* output_begin_destroy
* output_destroy
* workspace_begin_destroy
* workspace_destroy
* container_begin_destroy
* container_destroy
* view_begin_destroy
* view_destroy

The terminology was `destroy` and `free`, and it has been changed to
`begin_destroy` and `destroy` respectively.

When the last output is disconnected, its workspaces will now be stashed
in the root. Upon connection of a new output they will be restored.

There is a new function `workspace_consider_destroy` which decides
whether the given workspace should be destroyed or not (ie. empty and
not visible).

Calling container_begin_destroy will no longer automatically reap the
parents. In some places we want to reap the parents and in some we
don't, so this is left to the caller.

container_reap_empty_recursive and container_reap_empty have been
combined into one function and it will recurse up the tree.
2018-08-24 22:17:28 +10:00
emersion a81c148e25
Merge pull request #2507 from RyanDwyer/move-workspace-translate-floating
Translate floating containers when a workspace is moved
2018-08-22 09:34:27 +01:00
Ryan Dwyer e1d5dc0804 Translate floating containers when a workspace is moved
When a workspace is moved to another output, or the output it's on
changes its global layout position, the floating containers on that
workspace should be translated by the same amount as the workspace. This
keeps the floating containers in the same position relative to the
workspace.

A check is done to make sure the floating container's center point isn't
being moved off screen. If it is, it is centered within the workspace.

Fixes part of #2500.
2018-08-22 17:46:12 +10:00
vilhalmer 03718aaebb
Add app_id and class to get_tree output 2018-08-21 20:51:01 -04:00
Ryan Dwyer e81c26fab9 Fix sending fullscreen event to view
Fixes #2504
2018-08-22 08:23:29 +10:00
Ryan Dwyer f129b1b89f Replace enum resize_edge with wlr_edges 2018-08-21 12:41:57 +10:00
minus 471533be0a Improve new workspace name selection
Improves upon 18e425ed by using the first assigned workspace instead of
the last one. The order isn't explicitly guaranteed to be the same as in
the config, but in general works.
2018-08-20 23:17:07 +02:00
Ian Fan f51b9478f2 commands: implement move absolute 2018-08-20 10:17:32 +01:00
Ryan Dwyer 771ad7bffa Fix jumping views
Fixes #2490.

To be honest I'm not sure why this fixes the issue.

I observed that I could only make the view jump if I resized it to the
smallest possible size first. Then I had a suspicion that we were
accidentally factoring in the title and border sizes into the view size
when it uses CSD. So I changed that and it appears to have fixed the
jumping issue.

I guess when we factor the title and borders in, we send a configure to
the surface with a size smaller than the minimum, and it comes back with
a surface at the minimum size. We interpret this as an unexpected
resize, and this somehow makes it jump.
2018-08-20 13:24:57 +10:00
Drew DeVault 08a69f267a
Merge pull request #2483 from RyanDwyer/floating-emit-reparent
Send enter/leave events for floating views
2018-08-19 22:06:09 -04:00
Ryan Dwyer e1955c5c08 Fix crash when adding output 2018-08-20 10:37:52 +10:00
Ryan Dwyer a49e4b13bf Clean up tracked outputs when an output is destroyed 2018-08-20 09:23:34 +10:00
Ryan Dwyer 0f6d212629 Send output enter/leave events correctly
Previously we used a reparent event to detect when a view changes
parent, then sent an output enter/leave to the surfaces if needed. This
worked for tiling views but not floating views, as floating views can
intersect another output without changing parent.

The solution implemented for floating views also applies cleanly to
tiling views, so the previous method has been completely replaced and
the reparent event has been removed.

This introduces a new function container_discover_outputs. This function
compares the container's `current` position to the outputs, sends enter
and leave events as needed, and keeps track of which outputs it's
intersecting in a new `container->outputs` list. If it has entered a new
output with a different scale then the title and marks textures will
also be recreated at the new scale.

The function is called when a transaction applies. This is convenient as
it means we don't have to call it from various places.

There is imperfect rendering when a floating view overlaps two outputs
with different scales. It renders correctly for the most recently
entered output, but there is only one title texture so it renders
incorrectly on the old output.

Fixes #2482
2018-08-20 09:23:24 +10:00
Ryan Dwyer b3e2c49774 Fix crash when a view destroys with pending transactions
We were removing the saved buffer when one transaction applies, then
didn't have a new buffer to save when the next transaction ran. This
made the rendering code crash as it had no surface to use.

This commit makes it continue to hold the buffer if the view is
destroying and has more transactions. Additionally, a check is added
when saving the buffer to make sure there's no one already there.
2018-08-20 09:04:04 +10:00
emersion 8db6c68db6
Merge pull request #2493 from RyanDwyer/fix-popup-position
Fix popup position when parent uses geometry
2018-08-19 21:51:53 +01:00
Drew DeVault 9f913614ca
Merge pull request #2478 from RyanDwyer/standardise-debug
Standardise debug variables
2018-08-19 10:29:29 -04:00
Ryan Dwyer 4afb2e3f24 Allow subsurfaces which overflow the container to be interacted with
Fixes #2492.
2018-08-19 21:50:33 +10: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
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