Commit graph

495 commits

Author SHA1 Message Date
Drew DeVault 47cca240e2
Merge pull request #3102 from emersion/render-software-cursors
Render software cursors with wlr_output_render_software_cursors
2018-11-13 14:59:48 -05:00
emersion 2afd930914
Use #if instead of #ifdef for WLR_HAS_* 2018-11-12 22:23:06 +01:00
emersion 528f129c98
Render software cursors with wlr_output_render_software_cursors 2018-11-10 19:22:32 +01:00
emersion 0e85b92250
Use wlr_surface_get_effective_damage 2018-11-04 23:21:37 +01:00
Ryan Dwyer 9fc736f4e1 Move view marks properties to container struct
Like border properties, this will be needed to implement layout saving
and restoring.
2018-11-01 18:09:51 +10:00
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