Commit graph

640 commits

Author SHA1 Message Date
Ryan Dwyer 528c7495bb Move view border properties to container struct
This will be needed to implement layout saving and restoring, as we need
to be able to configure borders on a placeholder container which has no
view.
2018-10-31 23:56:20 +10:00
Rostislav Pehlivanov b0fb2846fe Revert "Respect border settings when rendering lone tabbed/stacked child"
This reverts commit 65328ef60c.
2018-10-30 11:42:44 +00:00
Robinhuett 0a4cf4748d Use output identifier for workspace config 2018-10-27 15:56:06 +02:00
Ryan Dwyer d0dca7f35e Don't reset cursor during mouse operations 2018-10-27 19:12:55 +10:00
Ryan Dwyer 65328ef60c Respect border settings when rendering lone tabbed/stacked child
In i3, when a child of a tabbed or stacked container has no siblings,
its border settings are respected.

This patch achieves the same effect by rendering a lone tabbed/stacked
child as if it's a linear container. This makes the border settings be
respected.

Over in view_autoconfigure, we compensate for this by only adjusting
`y_offset` if there's multiple children.
2018-10-27 11:23:02 +10:00
Ryan Dwyer 60a1d79de7 Rebase the cursor after applying transactions
This approaches cursor rebasing from a different angle. Rather than
littering the codebase with cursor_rebase calls and using transaction
callbacks, this just runs cursor_rebase after applying every transaction
- but only if there's outputs connected, because otherwise it causes a
crash during shutdown.

There is one known case where we still need to call cursor_rebase
directly, and that's when running `seat seat0 cursor move ...`. This
command doesn't set anything as dirty so no transaction occurs.
2018-10-25 23:37:40 +10:00
Drew DeVault ea2497d35c
Merge pull request #2950 from emersion/presentation-time
Implement the presentation-time protocol
2018-10-25 15:31:47 +02:00
Ryan Dwyer bdae625cb3 Rebase the cursor after mapping a view
I originally put the rebase at the end of view_map, but at this point
the view is still at its native size and will ignore the motion event if
it falls outside of its native size. The only way to do this properly is
to rebase the cursor later - either after sending the configure, after
the view commits with the new size, or after applying the transaction. I
chose to do it after applying the transaction for simplicity.

I then attempted to just call cursor_rebase after applying every
transaction, but this causes crashes when exiting sway (and possibly
other places) because cursor_rebase assumes the tree is in a valid
state.

So my chosen solution introduces transaction_commit_dirty_with_callback
which allows handle_map to register a callback which will run when the
transaction is applied.
2018-10-24 19:38:52 +10:00
Drew DeVault bdb176863c
Merge pull request #2933 from Snaipe/xwayland-window-properties
xwayland: populate window_properties in json for views
2018-10-24 01:13:15 +02:00
emersion a654ac1bd6
Implement the presentation-time protocol 2018-10-23 23:38:57 +02:00
Franklin "Snaipe" Mathieu 8fc9328334 xwayland: populate window_properties in json for views
window_properties is documented to contain a subset of the X11 properties
of a window (its title, class, instance, role, and transient ID). This
commit adds the missing json object from the get_tree output for
xwayland windows only.

This is a follow-up of #2911.

Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
2018-10-23 19:10:50 +01:00
Ryan Dwyer 16ef702645 Fix xwayland wants_floating logic 2018-10-22 21:51:10 +10:00
Christian 989bddc765 Parse missing i3 window types
fixes the parsing part of #2906
2018-10-21 15:59:04 +02:00
Ryan Dwyer 93ec1af4d9 Fix popup damage issues when toplevel and/or popup uses geometry
The wlr_xdg_popup_get_toplevel_coords function has the following quirks:

* It does not do anything with the coordinates of the passed popup.
Instead, we are required to add them ourselves, which we do by passing
them to the function as the surface local values.
* It adds the geometry (shadows etc) of the toplevel itself, so the
coordinates are surface local rather than content local. For this
reason, we have to negate the toplevel's geometry
(child->view->geometry).
* I may be wrong, but the popup positions appear to be stored in surface
local coordinates rather than content local coordinates. The geometry
(shadows etc) of the popup itself must be negated (surface->geometry).
2018-10-20 23:18:56 +10:00
Ryan Dwyer c006717910 Minor refactor of input manager
The input manager is a singleton object. Passing the sway_input_manager
argument to each of its functions is unnecessary, while removing the
argument makes it obvious to the caller that it's a singleton. This
patch removes the argument and makes the input manager use server.input
instead.

On a similar note:

* sway_input_manager.server is removed in favour of using the server
global.
* seat.input is removed because it can get it from server.input.

Due to a circular dependency, creating seat0 is now done directly in
server_init rather than in input_manager_create. This is because
creating seats must be done after server.input is set.

Lastly, it now stores the default seat name using a constant and removes
a second reference to seat0 (in input_manager_get_default_seat).
2018-10-20 13:11:43 +10:00
Drew DeVault 765c80e5f7
Merge pull request #2820 from Emantor/fix-mouse-warping-container
Fix mouse warping container
2018-10-17 15:57:13 +02:00
Rouven Czerwinski 892446a0b6 view: move arrange_workspace into view_map
For mouse_warping cursor to correctly work on newly spawned containers,
the workspace needs to be arranged before the cursor is warped.

The shell functions each implement their own fullscreen and arrange checks,
move them into the view_map function and pass their states via boolean arguments.

Fixes #2819
2018-10-16 15:47:02 +02:00
Ryan Dwyer c699a86e47 Fix pixel leaks when using fractional scaling
The basic idea here is to apply rounding after scaling. It's not as
simple as this, though, and I've detailed it in the comments for a
function.

In order to fix some pixel leaks in the title bar, I found it easier to
change how we place rectangles to fill the area. Instead of placing two
rectangles across the full width above and below the title and having
shorter rectangles in the inner area, it's now pieced together in
vertical chunks. This method involves drawing two less rectangles per
container.
2018-10-12 22:36:11 +10:00
Drew DeVault 4bebee620f
Merge pull request #2772 from RyanDwyer/improve-popup-damage
Only damage popups when popups have damage
2018-10-09 00:02:36 +02:00
Ryan Dwyer d21d2c8665 Remove duplicate code 2018-10-08 23:50:43 +10:00
Ryan Dwyer b8002fc0c4 Look for any ancestor when checking for fullscreen exit 2018-10-08 23:39:35 +10:00
Ryan Dwyer 88317b59ce Use current state when rendering transient containers 2018-10-08 23:27:19 +10:00
Ryan Dwyer f23588de3c Introduce container_is_transient_for 2018-10-08 23:00:36 +10:00
Ryan Dwyer 832ebc8966 Implement popup_during_fullscreen
This introduces a new view_impl function: is_transient_for. Similar to
container_has_ancestor but works using the surface parents rather than
the tree.

This patch modifies view_is_visible, container_at and so on to allow
transient views to function normally when they're in front of a
fullscreen view.
2018-10-08 22:49:59 +10:00
Ryan Dwyer 59ba528bd9 Use wlr_xdg_popup_get_toplevel_coords 2018-10-07 11:07:29 +10:00
Ryan Dwyer 1059e173f4 Only damage popups when popups have damage
The previous behaviour was to damage the entire view, which would
recurse into each popup. This patch makes it damage only the popup's
surface, and respect the surface damage given by the client.

This adds listeners to the popup's map and unmap events rather than
doing the damage in the create and destroy functions. To get the popup's
position relative to the view, a new child_impl function get_root_coords
has been introduced, which traverses up the parents.
2018-10-07 11:07:29 +10:00
Ryan Dwyer 32cb631143 Give focus to another swaylock surface when output is disconnected
* Have multiple outputs
* Launch swaylock
* Unplug an output (possibly has to be the last "connected" one)
* The swaylock surface on the remaining output would not respond to key
events

This was happening because when the output destroys, focus was not given
to the other swaylock surface.

This patch makes focus be transferred to another surface owned by the
same Wayland client, but only if input was inhibited by the surface
being destroyed, and only if it's in the overlay layer. I figure it's
best to be overly specific and relax the requirements later if needed.

This patch removes a check in seat_set_focus_surface which was
preventing focus from being passed from a layer surface to any other
surface. I don't know of a use case for this check, but it's possible
that this change could produce issues.
2018-10-04 19:36:19 +10:00
Drew DeVault 06c214a800
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
2018-10-03 13:03:06 +02:00
Ian Fan 0dfcadc1cf transaction: do not use pointers for state 2018-09-28 09:18:24 +01:00
Ryan Dwyer f16529e258 Remove server-decoration assumption if view supports xdg-decoration 2018-09-27 23:00:10 +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 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
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
Ryan Dwyer ae2f53a477 Reconfigure xwayland views when repositioned
Fixes #2673.
2018-09-21 23:02:48 +10:00
emersion 4289343e17 Fix segfault in output_render 2018-09-19 11:03:25 +02: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
emersion 7699c5444c Update for swaywm/wlroots#1243 2018-09-14 19:21:44 +02: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 d4e80cf301 Rename OP_MOVE to OP_MOVE_FLOATING
In preparation for introducing OP_MOVE_TILING.
2018-09-11 16:56:05 +10: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
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 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 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 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
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 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 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 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 29f5cc7508 Implement window_role criteria token
Depends on https://github.com/swaywm/wlroots/pull/1226
2018-09-04 08:23:50 +10:00
Ian Fan e6fde0739a Fix crash when a splash screen opens on an empty workspace 2018-09-03 14:03:49 +01:00
Brian Ashworth afb6968874
Merge branch 'master' into disabled-no-modeset 2018-09-03 00:24:28 -04: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 349d1f3be8 Do not modeset disabled outputs 2018-09-01 18:56:53 +02:00
Ryan Dwyer f4ec308376 Implement window_type criteria token 2018-09-01 23:04:49 +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
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
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 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
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 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 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
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
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 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 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
Ryan Dwyer ab8a86369c Implement some floating move commands
This implements the following for floating containers:

* move <direction> <amount>
* move [absolute] position <x> <y>
* move [absolute] position mouse
2018-07-09 23:38:29 +10:00
emersion f9625d1d56
Split renderer 2018-07-07 10:30:52 +01:00
Ryan Dwyer 0046eed969 Fix titles when container titles contain UTF-8 characters
The title and marks textures would have their height set from the
config's computed max font height, but the textures were not regenerated
when the config's max font height changed which made a gap appear.
Rather than making it regenerate the title textures every time the
config font height was changed, I've changed it to just make the
textures the height of the title itself and fill any gap when rendering.

Also, the title_width and marks_width variables have been renamed to
make it more obvious that they are in output-buffer-local coordinates.

Fixes #1936.
2018-07-07 15:49:51 +10:00
emersion 9a9d9116be
Make view_update_* update live props as well 2018-07-06 19:33:10 +01:00
emersion 47d56306c3
Fix xwayland floating views unclickable
Some xwayland views are first configured with a 1x1 size, and then
resized. Since the view size isn't updated, they are unclickable.

Fixes #2195
2018-07-06 19:31:44 +01:00
Ryan Dwyer 464d4d5889 Translate surface by its geo when doing opaque box check 2018-07-07 01:18:54 +10:00
Ryan Dwyer 9480781229 Don't clear when using opaque lockscreen 2018-07-07 00:21:39 +10:00
Ryan Dwyer 3b842f4eed Detect opaque lockscreen when using a solid color 2018-07-07 00:17:08 +10:00
Ryan Dwyer f1fadef923 Use pixman_region32_contains_rectangle 2018-07-07 00:03:49 +10:00
Ryan Dwyer 839c3a5500 Use opaque region to determine if frame done should be sent 2018-07-07 00:03:49 +10:00
Ryan Dwyer 58befcf2cd Don't send frame done to surfaces behind lockscreen
Also, when rendering, don't descend into the tree if the lockscreen is
active. Just render the lockscreen's surfaces.
2018-07-07 00:03:49 +10:00
emersion 51b215ad5c
Use wlr_surface.buffer_damage 2018-07-05 00:26:39 +01:00
Drew DeVault d43500831a
Updates per wlroots#1076 2018-07-05 00:26:35 +01:00
Ryan Dwyer 50b401677b Fix use after free in transaction code
If we set an instruction as ready twice, it decreases the transaction's
num_waiting a second time and applies the transaction earlier than it
should. This no doubt has undesired effects, probably resulting in a use
after free.

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

Found through static analysis
2018-07-02 08:03:41 +09:00
Drew DeVault acd79e1505 Implement pid->workspace tracking
When you spawn a process with the exec command, sway now notes the
workspace you had focused and the pid of the child process, then assigns
that workspace to the child when its window appears.

Some of this is carried over from sway 0.15, but with some major
refactoring and centralization of state.
2018-07-01 09:58:18 -04:00
Dominique Martinet bc1e99305a xdg_shell: listen to fullscreen request on map
That event comes from the toplevel and not the surface, so would cause
a use-after-free on destroy if the toplevel got destroyed first:

==5454==ERROR: AddressSanitizer: heap-use-after-free on address 0x6110001ed198 at pc 0x000000472d10 bp 0x7ffc19070a80 sp 0x7ffc19070a70
WRITE of size 8 at 0x6110001ed198 thread T0
    #0 0x472d0f in wl_list_remove ../common/list.c:157
    #1 0x42e159 in handle_destroy ../sway/desktop/xdg_shell_v6.c:243
    #2 0x7fa9e5b28ce8 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7fa9e5afd6b1 in destroy_xdg_surface_v6 ../types/xdg_shell_v6/wlr_xdg_surface_v6.c:101
    #4 0x7fa9e5d98025 in destroy_resource src/wayland-server.c:688
    #5 0x7fa9e5d98091 in wl_resource_destroy src/wayland-server.c:705
    #6 0x7fa9e27f103d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)
    #7 0x7fa9e27f09fe in ffi_call (/lib64/libffi.so.6+0x59fe)
    #8 0x7fa9e5d9bf2c  (/lib64/libwayland-server.so.0+0xbf2c)
    #9 0x7fa9e5d983de in wl_client_connection_data src/wayland-server.c:420
    #10 0x7fa9e5d99f01 in wl_event_loop_dispatch src/event-loop.c:641
    #11 0x7fa9e5d98601 in wl_display_run src/wayland-server.c:1260
    #12 0x40a2f4 in main ../sway/main.c:433
    #13 0x7fa9e527318a in __libc_start_main ../csu/libc-start.c:308
    #14 0x40b749 in _start (/opt/wayland/bin/sway+0x40b749)

0x6110001ed198 is located 152 bytes inside of 240-byte region [0x6110001ed100,0x6110001ed1f0)
freed by thread T0 here:
    #0 0x7fa9e7c89880 in __interceptor_free (/lib64/libasan.so.5+0xee880)
    #1 0x7fa9e5affce9 in destroy_xdg_toplevel_v6 ../types/xdg_shell_v6/wlr_xdg_toplevel_v6.c:23
    #2 0x7fa9e5d98025 in destroy_resource src/wayland-server.c:688

previously allocated by thread T0 here:
    #0 0x7fa9e7c89e50 in calloc (/lib64/libasan.so.5+0xeee50)
    #1 0x7fa9e5b00eea in create_xdg_toplevel_v6 ../types/xdg_shell_v6/wlr_xdg_toplevel_v6.c:427
    #2 0x7fa9e27f103d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)

The toplevel only notifies the compositor on destroy if it was mapped,
so only listen to events at map time.
2018-06-30 22:42:24 +09:00
Dominique Martinet 9ea4cc13a0 sway views: add helpers to get view and layer from wlr_surface 2018-06-30 22:31:14 +09:00