Commit graph

1490 commits

Author SHA1 Message Date
David Rosca d0fe721fbb seatop_down: Change type of sx, sy to double in begin_seatop_down
Losing the precision resulted in wlr_cursor and wlr_seat::pointer_state
getting out of sync during pointer motion in seatop_down.
Since the difference was always under 1 px, it was practically
impossible to notice in normal use.

But because of being out of sync, cursor_rebase would always end up
incorrectly calling wlr_seat_pointer_notify_motion from
seatop_default_begin (on releasing mouse button) which broke cursor
locking.

See #5405
Closes #4632
2021-08-05 09:26:11 -04:00
Simon Zeni 6ffa4b1f70 view: remove reference to wlr_wl_shell_surface 2021-07-27 17:31:29 +02:00
Simon Ser 2e03a61262 Fix wl_pointer.frame not sent on touch emulation
When emulating touch, the simulating_pointer_from_touch field is
set to true. It's switched back to false when a touch_up event is
received. However we need to ensure we always send a wl_pointer.frame
event following a group of other wl_pointer events.

Since a touch_frame event is always guaranteed to come after a group
of touch events, unset simulating_pointer_from_touch in the touch_frame
handler instead of the touch_up handler. Add a new field to know whether
the touch_frame handler should stop emulation.
2021-07-26 16:58:11 +02:00
Simon Ser 7114030159 Add support for touch frame events
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3001
2021-07-08 09:18:20 +02:00
Simon Ser 4832fc937f Update wlr_box includes
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3011
2021-07-07 11:29:14 +02:00
Kenny Levinsen 80315217f7 input: Move get_current_time_msec in from util
get_current_time_msec is only used in cursor.c, so we can move it in and
make it static. This is primarily intended to avoid a symbol collision
with wlroots, which we unfortunately do not have a good solution for
yet.
2021-06-23 09:55:36 +02:00
Ragnar Groot Koerkamp c0c4e260c4 Revert "Add workspace {prev,next}_on_output --create"
This reverts commit 487c83f0de.

The --create flag is undocumented, not in i3, and at least partially
broken (#5913), so this removes the feature.
2021-06-22 19:00:31 +02:00
Ragnar Groot Koerkamp 3080f1b9ce Move auto_back_and_forth logic out of workspace_switch
This extracts the code to a separate workspace_auto_back_and_forth
function.
It also removes the bool argument by adding an extra if statement at the call
site, and repurposes the no_auto_back_and_forth variable to
auto_back_and_forth for simpler understanding.
2021-06-18 16:15:02 +02:00
James Edwards-Jones d13090be54 swaynag: adds option to set wayland shell layer
Uses --layer/-y set to overlay|top|bottom|background
2021-06-17 11:47:49 +02:00
Daniel Otero b997147284 config: Fix swaybar pango_markup inconsistency
Until now, swaybar did not have pango markup enabled by default, even if
the sway config had it on. This patch aims to mimic the i3 behavior, but
maintaining the functionality of the "pango_markup" sway config command.
2021-06-03 14:18:23 +02:00
Simon Ser 9755684fb0 Implement xdg-activation-v1
See https://github.com/swaywm/wlroots/pull/2718.
2021-06-02 19:39:40 +02:00
Issam E. Maghni d45623c2db cairo: Replace <cairo/cairo.h> by <cairo.h>
For full context, read
https://gitlab.freedesktop.org/cairo/cairo/-/issues/479
TL;DR, cairo’s pc file adds `/cairo` to CFLAGS.
So namespace cairo shouldn’t be used.
2021-05-10 10:28:32 +02:00
Simon Ser fd36289faa Remove support for arbitrary rotations
There was some unused code-paths for rendering surfaces with an
arbitrary rotation applied. This was imported from rootston.

Since we don't have plans to make use of this, remove it.
2021-04-26 10:36:25 +02:00
Kenny Levinsen 152a559e30 idle_inhibit: Store wlr inhibitor instead of view
When an application inhibited idle, a view pointer was stored and a
destroy listener was registered to the wlr inhibitor. As the wlr
inhibitor lives longer than the view, this lead to a dangling view
pointer between view unmap and inhibitor destroy.

Store a pointer to the wlr inhibitor instead of to the view, and look up
the view when needed, which may at any point be NULL. This also allows
for an inhibitor to remain functional if a surface is re-mapped.
2021-03-21 12:27:29 +01:00
xdavidwu e5913f8106
Implement input method keyboard grab 2021-03-12 12:18:08 +01:00
ftilde 1afedcb94c Fix for_window criteria and mouse button bindings
Previously, the special case handling of scratchpad and unmark commands
was (probably accidentally) limited to criteria directly handled in the
execute_command function. This would exclude: 1. for_window criteria, as
these are handled externally for views and 2. and mouse bindings which
select target the node currently under the mouse cursor.

As a concrete example `for_window [app_id="foobar"] move scratchpad,
scratchpad show` would show (or hide due to the toggling functionality)
another window from the scratchpad, instead of showing the window with
app_id "foobar".

This commit replaces the "using_criteria" flag with "node_overridden"
with the more general notion of signifying that the node (and
container/workspace) in the current command handler context of the sway
config is not defined by the currently focused node, but instead
overridden by other means, i.e., criteria or mouse position.
2021-02-25 09:48:39 -05:00
lbonn c6e7cf1ae5 focus: beyond fullscreen when focused explicitly
When issuing a focus command on a specific container, users expect to
proceed it even if is hidden by a fullscreen window.

This matches the behavior of i3.
2021-02-25 09:40:20 -05:00
Simon Ser eea9c6331f Automatically map built-in touchscreens/tablets to built-in panels
Detect whether an output is built-in via its type. Detect whether
a touchscreen or tablet tool is built-in via its ID_PATH property.
2021-02-25 09:38:00 -05:00
Quantum e01a3c85f6 render: handle containers without output when rendering titles
In e0a94bee8d, it was believed that if the
container is being rendered, it must have an output.

This turned out not to be the case. When rendering a container, all its
children are rendered, even if the children is positioned off screen and
thus not having any output. This is the cause of the crash in #6061.

This commit introduces a null-check, which fixes #6061.
2021-02-25 00:43:02 -05:00
Kenny Levinsen 1989b18ff2 transaction: Remove unused ready_immediately 2021-02-23 19:38:05 +01:00
Kenny Levinsen 35b9a41720 transaction: Note if instructions are server requests
On server request, we need to send configure events to inform the client
of the new intended size. If the client changes size itself, sending a
configure event will only cause problems.

Use transaction_commit_dirty_client to distinguish between the two
transaction causes.
2021-02-23 19:38:05 +01:00
Kenny Levinsen 2c917a8c34 container: Add container_is_current_floating
Needed to check if containers are currently floating from render code,
as container_is_floating checks pending state.
2021-02-22 23:55:22 +01:00
Kenny Levinsen a047b5ee4a container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.

Instead, use the state struct for both current and pending.
2021-02-16 22:05:00 -05:00
Kenny Levinsen c8bf84c82d transactions: Amend pending transactions
The transaction system contains a necessary optimization where a popped
transaction is combined with later, similar transactions. This breaks
the chronological order of states, and can lead to desynchronized
geometries.

To fix this, we replace the queue with only 2 transactions: current and
pending. If a pending transaction exists, it is updated with new state
instead of creating additional transactions.

As we never have more than a single waiting transaction, we no longer
need the queue optimization that is causing problems.

Closes: https://github.com/swaywm/sway/issues/6012
2021-02-16 00:18:26 +01:00
Kenny Levinsen 63a6635163 view: Read geometry directly in view_update_size 2021-02-09 09:37:10 +01:00
Kenny Levinsen 50205ade9d transaction: Move centering to view_center_surface
This will allow us to reuse it for centering elsewhere.
2021-02-09 09:37:10 +01:00
Manuel Stoeckl cb3c727632 Declare all struct cmd_handler arrays const
And make the functions handling these arrays use const types.
2021-02-04 09:49:06 +01:00
Simon Ser 1c3cfd3bac Rename output_layer_for_each_surface_{toplevel,popup}
Swap the "surface" part for consistency with wlroots' naming.
2021-01-12 11:25:34 +01:00
Simon Ser 5438cc158a Switch to wlr_xdg_surface_for_each_popup_surface
Instead of calling wlr_xdg_surface_for_each_popup and then
wlr_surface_for_each_surface, use the new for_each_popup_surface helper
introduced in [1] that does it in one go.

[1]: https://github.com/swaywm/wlroots/pull/2609
2021-01-12 11:25:34 +01:00
Andri Yngvason 98eece53ad input: Clean up input_method_relay in seat_destoy()
This fixes a crash that happens when input_method_new or text_method_new
events are emitted after the seat has been freed.
2021-01-01 19:02:56 +01:00
Ronan Pigott 8eb0c54693 introduce workspace_squash
workspace_squash is container_flatten in the reverse
direction. Instead of eliminating redundant splits that are
parents of the target container, it eliminates pairs of
redundant H/V splits that are children of the workspace.

Splits are redundant if a con and its grandchild have the
same layout, and the immediate child has the opposite split.

For example, layouts are transformed like:

    H[V[H[app1 app2]] app3] -> H[app1 app2 app3]

i3 uses this operation to simplify the tree after moving
heavily nested containers to a higher level in the tree via
an orthogonal move.
2020-12-20 00:58:42 -05:00
Ronan Pigott ece6a1d408 Change workspace_layout to match i3 behavior
In i3, the workspace_layout command does not affect the
workspace layout. Instead, new workspace level containers
are wrapped in the desired layout and the workspace layout
always defaults to the output orientation.
2020-12-20 00:58:42 -05:00
Arav K c9fe0626ca Fix swaybar tray for non-systemd
Meson's generated config.h header defines false macros as 0, not
undefined.  This means that the header line, which was checking for the
definition existing, not a non-zero value, was incorrect.  Now the
swaybar tray can be used with systemd, elogind, or basu.
2020-12-16 21:19:20 +01:00
Simon Ser a52176f830 build: add basu as sd-bus provider 2020-12-09 17:39:20 -05:00
Simon Ser fdbe98512a build: introduce sd-bus-provider option
This allows to select a specific provider for the sd-bus library.
2020-12-09 17:39:20 -05:00
Vlad Pănăzan 71725a8eae Add layer shell subsurfaces
Damage subsurfaces created by layer surfaces on map, unmap and
commit. This fixes the flicker of Gtk Popovers.

Fixes #5617
2020-12-07 12:30:13 +01:00
Tudor Brindus cc2c0d5966 input/cursor: unhide cursor on synthetic input
Fixes #5847.
2020-12-06 09:38:49 +01:00
Paul Riou 4583feee59 common: make 'lenient_strcmp' arguments const
Prevents build failures when calling the function with 'const char *'
arguments.
This is also more accurate since the function is not expected to modify
the args.
2020-12-04 10:49:49 +01:00
Tudor Brindus 07042486c3 tree/container: introduce container_is_sticky[_or_child] functions
To query whether a container is sticky, checking `con->is_sticky` is
insufficient. `container_is_floating_or_child` must also return true;
this led to a lot of repetition.

This commit introduces `container_is_sticky[_or_child]` functions, and
switches all stickiness checks to use them. (Including ones where the
container is already known to be floating, for consistency.)
2020-11-11 20:43:58 -05:00
Tudor Brindus 60d95414d4 commands/focus: force container warp when fulfilling focus mode_toggle
This commit switches focusing behavior to force a warp when executing
`focus mode_toggle`.

Fixes #5772.
2020-11-01 03:43:00 -05:00
Tudor Brindus 8c12e71a66 input: remove motion deltas from seatop callbacks
Straightforward cleanup, they haven't been used for a while.
2020-10-31 23:15:32 +01:00
Tamir Zahavi-Brunner 96578aa91e hide_cursor: Add an option to hide when typing
Add an option for the `hide_cursor` command to hide the cursor when
typing, i.e. whenever a key is pressed.
2020-10-30 09:59:54 +01:00
mwenzkowski 32788a93f2 output: evacuate sticky containers only if new output has a workspace
Sticky floating containers on an otherwise empty workspace can only be
evacuated if the new output has an active workspace. The noop output may
not have one and in that case we have to move the whole workspace to the
new output.
2020-10-27 19:26:26 -04:00
Tudor Brindus 8355884fbd transaction: validate X transaction completions by geometry, not size
Xwayland views are aware of their coordinates, so validating transaction
completions should take into account the reported coordinates of the
view. Prior to this commit they didn't, and matching dimensions would
suffice to validate the transaction.

Also introduced `transaction_notify_view_ready_immediately` to support
the fix from d0f7e0f without jumping through hoops to figure out the
geometry of an `xdg_shell` view.
2020-10-18 22:37:42 +02:00
Tudor Brindus 181798c2fe xwayland: listen to set_geometry event
Closes #5735, refs #3007.

This makes the "Search everywhere" dialog in JetBrains IDEs movable.
2020-10-18 15:18:53 +02:00
Tudor Brindus ed247c031c input/tablet: add tool_mode option to set tablet tools as relative input
Closes #4139.
2020-10-12 15:01:37 +02:00
Tarmack 989123a2a5 Add support for workspace_min_width bar option. 2020-10-11 19:12:42 +02:00
Tobias Langendorf 657587964e xwayland: support views that change override-redirect status 2020-10-10 09:53:41 +02:00
Mustafa Abdul-Kader eb1c09030e swaynag: add details background option
Adds a new config option for details background for swaynag

issue/#5673
2020-09-14 22:13:01 -04:00
oliver-giersch a543fa35ff swaynag: adds option to separately specify the text color for buttons 2020-09-04 18:17:42 +02:00
Simon Ser 2c76923282 Use wlr_output_event_commit
Instead of listening to both transform and scale events, we can listen
to the commit event and use the new wlr_output_event_commit struct to
decide what to do.

This de-duplicates some of the work we were doing twice when an output
was re-configured.

Depends on [1].

[1]: https://github.com/swaywm/wlroots/pull/2315
2020-08-27 13:57:10 -06:00
Konstantin Pospelov fd216b3a81 exec: fix validation during config reload
Split cmd_exec_always into separate methods for general validation and
process creation. This fixes a potential call of join_args with 0 arguments.
2020-08-24 09:41:54 +02:00
Ronan Pigott b7f28cd6b7 view: remove foreign toplevel listeners on destroy 2020-08-05 11:05:49 +02:00
Ronan Pigott f478f4cc66 view: implement foreign toplevel fullscreen request 2020-08-05 11:05:49 +02:00
Tobias Langendorf 4f718e6c75 Fix X11 clients getting stuck minimized
Usually it should be enough to simply not grant a client's
minimize request, however some applications (Steam, fullscreen
games in Wine) don't wait for the compositor and minimize anyway,
getting them stuck in an unrecoverable state.
Restoring them immediately lead to heavy flickering when unfocused
on my test application (Earth Defense Force 5 via Steam), so it's
preferable to grant their request without actually minimizing and
then restoring them once they are in focus again.
2020-07-22 18:50:57 -04:00
Nils Schulte 6898d1963f moved and renamed movement-unit parsing to common 2020-07-21 10:07:01 +02:00
Ronan Pigott 39d677af15 input: implement xdg_toplevel interactive resize hints 2020-07-13 00:21:52 -04:00
Simon Ser 5432f00adf config/output: don't change output state before commit
Previously, we called output_disable prior to wlr_output_commit. This
mutates Sway's output state before the output commit actually succeeds.
This results in Sway's state getting out-of-sync with wlroots'.

An alternative fix [1] was to revert the changes made by output_disable
in case of failure. This is a little complicated. Instead, this patch
makes it so Sway's internal state is never changed before a successful
wlr_output commit.

We had two output flags: enabled and configured. However enabled was set
prior to the output becoming enabled, and was used to prevent the output
event handlers (specifically, the mode handler) from calling
apply_output_config again (infinite loop).

Rename enabled to enabling and use it exclusively for this purpose.
Rename configure to enabled, because that's what it really means.

[1]: https://github.com/swaywm/sway/pull/5521

Closes: https://github.com/swaywm/sway/issues/5483
2020-07-10 18:18:27 -04:00
Geoffrey Casper ea3ba203cc Reload command now matches i3's implementation 2020-07-07 17:15:57 -04:00
Tudor Brindus 92891fb1ed commands/move: unwrap workspace container on move to new workspace
If moving e.g. `T[app app]` into a new workspace with `workspace_layout
tabbed`, then post-move the tree in that workspace will be `T[T[app
app]]`. This still happens with horizontal or vertical workspace layout,
but is less visible since those containers have no decorations.

Fixes #5426.
2020-07-01 18:43:20 -04:00
Kenny Levinsen 492267a5d6 seat: Refocus seat when wlr_drag is destroyed
wlr_drag installs grabs for the full duration of the drag, leading to
the drag target not being focused when the drag ends. This leads to
unexpected focus behavior, especially for the keyboard which requires
toggling focus away and back to set.

We can only fix the focus once the grabs are released, so refocus the
seat when the wlr_drag destroy event is received.

Closes: https://github.com/swaywm/sway/issues/5116
2020-06-30 13:27:51 +02:00
Drew DeVault 8d5e627bc9 Implement wlr-foreign-toplevel-management-v1 2020-06-23 22:26:00 +02:00
Tudor Brindus b3f08597cd input: disable events for map_to_output devices when output not present
Fixes #3449.
2020-06-19 10:02:22 +02:00
Tudor Brindus d328c2439c input/pointer: don't trigger pointer bindings for emulated input
Prior to this commit, a tablet device could trigger mouse button down
bindings if the pen was pressed on a surface that didn't bind tablet
handlers -- but it wouldn't if the surface did bind tablet handlers.

We should expose consistent behavior to users so that they don't have to
care about emulated vs. non-emulated input, so stop triggering bindings
for any non-pointer devices.
2020-06-18 22:35:01 +02:00
Tudor Brindus 82c439c4f1 input/cursor: send idle events based off device type, not input type
Previously, a tablet or touch device could report activity as a pointer
device if it went through pointer emulation. This commit refactors idle
sources to be consistently reported based on the type of the device that
generated an input event, and now how that input event is being
processed.
2020-06-18 22:35:01 +02:00
Simon Ser e19bd1e474 Add support for viewporter
Depends on [1].

[1]: https://github.com/swaywm/wlroots/pull/2092
2020-06-17 10:18:58 -06:00
Brian Ashworth 33aa59d4c6 input/keyboard: wlr_keyboard_group enter and leave
This adds support for wlr_keyboard_group's enter and leave events. The
enter event just updates the keyboard's state. The leave event updates
the keyboard's state and if the surface was notified of a press event
for any of the keycodes, it is refocused so that it can pick up the
current keyboard state without triggering any keybinds.
2020-06-16 17:53:23 +02:00
Jason Nader 45859be03f i3-compat: add GET_BINDING_STATE IPC command 2020-06-14 00:55:14 -04:00
Tudor Brindus ed08f2f20c tree/view: fix smart gaps when ancestor container is tabbed or stacked
Fixes #5406.
2020-06-08 19:01:45 -04:00
Graham Christensen a974300652 swaynag: allow specifying more buttons which execute and dismiss
I don't love -z / -Z, but I figure this patch is far from being
accepted for other reasons too.
2020-06-09 00:00:14 +02:00
Tudor Brindus 53dc83fb68 tree/container: introduce container_toplevel_ancestor helper
This allows us to not have to explicitly write the same while loop
everywhere.
2020-06-07 10:46:14 +02:00
Tudor Brindus d7900c6e5e common/util: fix get_current_time_msec returning microseconds
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util.c` so that it can be reused elsewhere
without having to consider these pitfalls.
2020-06-06 13:38:41 +02:00
Kalyan Sriram e3e548a648
Save transform during transaction
Closes: https://github.com/swaywm/sway/issues/5412
2020-06-05 14:13:18 +02:00
Kenny Levinsen 5a4a7bc0da container: Remove useless surface dimensions
The adjustments to resize logic left them unnecessary.
2020-06-03 16:41:17 +02:00
Kenny Levinsen fcd0ab8f33 view: Save all buffers associated with view
During the execution of a resize transaction, the buffer associated
with a view's surface is saved and reused until the client acknowledges
the resulting configure event.

However, only one the main buffer of the main surface was stored and
rendered, meaning that subsurfaces disappear during resize.

Iterate over all, store and render buffers from all surfaces in the view
to ensure that correct rendering is preserved.
2020-06-03 16:41:17 +02:00
Damien Tardy-Panis 0cbd26f0da Add views idle inhibition status in get_tree output
Fixes #5286
2020-05-29 17:29:41 -04:00
Tudor Brindus 6da1631090 input/cursor: rename simulated_tool_tip_down to be more accurate
This is a tiny cleanup commit that renames `simulated_tool_tip_down` to
`simulating_pointer_from_tool_tip`, making it match
`simulating_pointer_from_touch`.

This is a better name since it makes it clear that it's the *pointer*
that's being simulated, not the tool tip.
2020-05-29 08:44:56 +02:00
Tudor Brindus d71fed95da input/cursor: keep reference to cursor in constraint
set_region accepts a NULL *data, so we can't use it to reference the
constraint and find the cursor through its seat.

Fixes #5386.
2020-05-26 16:24:52 +02:00
Tudor Brindus 5d13f647f9 input/tablet: add seatop_down entry for tablet input
Currently, when tablet input exits a window during an implicit grab, it
passes focus to another window.

For instance, this is problematic when trying to drag a scrollbar, and
exiting the window &mdash; the scrollbar motion stops. Additionally,
without `focus_follows_mouse no`, the tablet passes focus to whatever
surface it goes over regardless of if there is an active implicit.

If the tablet is over a surface that does not bind tablet handlers, sway
will fall back to pointer emulation, and all of this works fine. It
probably should have consistent behavior between emulated and
not-emulated input, though.

This commit adds a condition for entering seatop_down when a tablet's
tool tip goes down, and exiting when it goes up. Since events won't be
routed through seatop_default, this prevents windows losing focus during
implicit grabs.

Closes #5302.
2020-05-25 10:01:00 +02:00
Érico Rolim 1d3681f521 Remove code related to the security features
- Remove struct definitions
- Remove struct members
- Remove initializations and frees
2020-05-21 10:57:00 +02:00
Martin Michlmayr 06fc42359b Fix typos in comments 2020-05-21 10:52:59 +02:00
Tudor Brindus 6f0a0bd385 input/pointer: only warp cursor when the confine region has changed
Refs #5268.
2020-05-21 10:45:08 +02:00
Michael Weiser 0f11aa037a commands: Add per-view shortcuts_inhibitor command
Add a separate per-view shortcuts_inhibitor command that can be used
with criteria to override the per-seat defaults. This allows to e.g.
disable shortcuts inhibiting globally but enable it for specific,
known-good virtualization and remote desktop software or, alternatively,
to blacklist that one slightly broken piece of software that just
doesn't seem to get it right but insists on trying.

Add a flag to sway_view and handling logic in the input manager that
respects that flag if configured but falls back to per-seat config
otherwise. Add the actual command but with just enable and disable
subcommands since there's no value in duplicating the per-seat
activate/deactivate/toggle logic here. Split the inhibitor retrieval
helper in two so we can use the backend half in the command to retrieve
inhibitors for a specific surface and not just the currently focused
one. Extend the manual page with documentation of the command and
references to its per-seat sibling and usefulness with criteria.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-05-13 21:22:16 -04:00
David96 2473cac32c Implement pointer simulation if client hasn't bound to touch 2020-05-13 14:29:15 -04:00
Tudor Brindus 726d187d3c input/tablet: simplify parameter plumbing for tablet references
This is a small cleanup commit for removing `sway_tablet` parameters
from functions that already accept `sway_tablet_tool`, since the tablet
reference can be accessed through `tool->tablet`.
2020-05-10 16:49:35 +02:00
Tudor Brindus e262f93d0a input: rename pointer handlers to be unambiguous
This commit renames `motion` and `axis` handlers to `pointer_motion` and
`pointer_axis`, respectively, to disambiguate them from their tablet
(and future touch) handlers. `button` is left as-is, as it is generic
across input devices.
2020-05-02 18:28:06 +02:00
Tudor Brindus ae3ec745f8 input: refactor tablet motion into seatop handler
This commit moves tablet motion logic into a seatop handler.

As a side-effect of seatop implementations being able to receive
tablet motion events, fixes #5232.
2020-05-02 13:32:28 +02:00
Tudor Brindus 0dc1863dce input/cursor: make cursor rebasing cursor type-agnostic
This commit refactors `cursor_rebase` into `cursor_update_image`, and
moves sending pointer events to the two existing call sites. This will
enable this code to be reused for tablets.

Refs #5232
2020-05-02 13:32:28 +02:00
Simon Ser 5e5e5f2ee5 Add a secondary headless backend
This allows the create_output command to work on DRM too.
2020-05-01 17:00:14 +02:00
Tudor Brindus 2913f39dcb input/cursor: release simulated tool tip button when over v2 surface
d88460f addressed sending v2 tool tip up when over a non-v2 surface.
This commit addresses the other direction.

Fixes #5230.
2020-05-01 11:00:49 +02:00
Martin Dørum 4492e493e6 swaybar: Fix scrolling with precise trackpads 2020-04-28 21:46:37 +02:00
Tudor Brindus 44b2d3ad81 input/cursor: fix hide cursor timeouts on tablets and touchscreens
This commit refactors `cursor_handle_activity` to also take the idle
source, so that it can be reused for tablet and touch activity.
Previously, the timeouts would be tracked, but the cursor would never be
un-hidden for anything but pointers.

Fixes #5169.
2020-04-22 17:30:08 +02:00
Andri Yngvason 46599df0a2 input: Mark virtual devices as such
This is for internal configuration purposes
2020-04-14 12:07:24 +02:00
Simon Ser 4d13cee59a Use bitshifts for bitfields
Instead of hardcoded power of 2 values, use bitshifts. This makes the
enums more readable, avoids mistakes, and makes it clear how much of the
int32_t bit space we have left.

While at it, fix other minor style issues.
2020-04-10 18:08:46 -04:00
David96 8c62278207 Render layer shell popups over the top layer 2020-04-10 10:45:47 +02:00
Simon Ser 0cdcf66bbc Introduce test_output_config
This function checks whether the backend would accept an output
configuration, without applying the changes.
2020-04-08 16:36:40 +02:00
xdavidwu 4e1e5e4e33 im: make text-input listeners per text-input 2020-04-04 11:42:04 +02:00
xdavidwu 5886187c6e Port input method and text input from rootston
This ports swaywm/wlroots#1203, swaywm/wlroots#1303,
swaywm/wlroots#1308, swaywm/wlroots#1759 rootston part to sway.

Co-Authored-By: Leo Chen <leo881003@gmail.com>
2020-04-04 11:42:04 +02:00
Ian Fan 65501f0e46 tray: track SNI callbacks
This removes any pending messages once the item is destroyed.
Furthermore, this installs SNI event calbacks asynchronously
in order to prevent sd-bus from bypassing pending messages.
2020-03-30 17:31:00 +02:00
Ian Fan 68f53cd509 tray: tidy code
This includes some refactoring and fixing a small memory leak.
2020-03-30 17:31:00 +02:00
Ian Fan 3b894c387d tray: allow themes to inherit from multiple themes 2020-03-30 17:31:00 +02:00
Linus Heckemann df48c48123 add --no-repeat option for bindings
This allows e.g. triggering one command while a key is held, then
triggering another to undo the change performed by it afterwards. One
use case for this is triggering push-to-talk functionality for VoIP
tools without granting them full access to all input events.

Fixes #3151
2020-03-30 14:18:27 +02:00
Michael Weiser 3ee5aace33 commands: Add shortcuts_inhibitor command
Add a command to influence keyboard shortcuts inhibitors. In its current
form it can be used to activate, deactivate or toggle an existing
inhibitor on the surface currently receiving input. This can be used to
define an escape shortcut such as:

bindsym --inhibited $mod+Escape seat - shortcuts_inhibitor deactivate

It also allows the user to configure a per-seat default of whether
keyboard inhibitors are honoured by default (the default) or not. Using
the activate/toggle command they can then enable the lingering inhibitor
at a later time of their choosing.

As a side effect this allows to specifically address a named seat for
actions as well, whatever use-case that might serve.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser eeac0aa170 input: Add support for keyboard shortcuts inhibit
Adding support for the keyboard shortcuts inhibit protocol allows remote
desktop and virtualisation software to receive all keyboard input in
order to pass it through to their clients so users can fully interact
the their remote/virtual session. The software usually provides its own
key combination to release its "grab" to all keyboard input. The
inhibitor can be deactivated by the user by removing focus from the
surface using another input device such as the pointer.

Use support for the procotol in wlroots to add support to sway. Extend
the input manager with handlers for inhibitor creation and destruction
and appropriate bookkeeping. Attach the inhibitors to the seats they
apply to to avoid having to search the list of all currently existing
inhibitors on every keystroke and passing the inhibitor manager around.
Add a helper function to retrieve the inhibitor applying to the
currently focused surface of a seat, if one exists.

Extend bindsym with a flag for bindings that should be processed even if
an inhibitor is active. Conversely this disables all normal shortcuts if
an inhibitor is found for the currently focused surface in
keyboard::handle_key_event() since they don't have that flag set. Use
above helper function to determine if an inhibitor exists for the
surface that would eventually receive input.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser ef9c597fcb config: Fix typo in reload bindsym flag bitmask
Fix a typo in the bit mask value of the BINDING_RELOAD flag introduced
in commit 152e30c37 so it can work as intended.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Simon Ser 5d692b0581 Add an adaptive_sync output command
This enables/disables adaptive synchronization on the output.

For now, the default is disabled because it might cause flickering on
some hardware if clients don't submit frames at regular enough
intervals. In the future an "auto" option will only enable adaptive sync
if a fullscreen client opts-in via a Wayland protocol.
2020-03-07 00:32:04 +01:00
Simon Ser 9d0aa0cb83 Use wlr_client_buffer
Update for breaking changes in [1].

[1]: https://github.com/swaywm/wlroots/pull/2043
2020-03-06 23:57:43 +01:00
Simon Ser 241684eb1d Drop sway_output.surface_needs_frame
wlr_output_schedule_frame now sets output->needs_frame [1], so this
isn't needed anymore.

[1]: https://github.com/swaywm/wlroots/pull/2053
2020-03-06 21:37:53 +01:00
Simon Ser c0811fcf87 Make handle_destroy and output_repaint_timer_handler static 2020-03-04 03:09:43 +01:00
Ryan Dwyer 2045ac3472 Introduce pid criteria token
This can be used as a workaround to flag terminal windows as urgent when
commands are completed, until urgency is introduced in the Wayland
protocol.

Configure your shell to run `swaymsg "[pid=$PPID] urgent enable"` when
commands are completed, and use a terminal which uses one process per
window.
2020-02-27 14:03:22 +01:00
Simon Ser 5ed01c861a Add support for wlr-output-power-management-unstable-v1 2020-02-26 16:26:13 +01:00
Torstein Husebø af294289b1 treewide: fix typos 2020-02-18 21:53:57 +01:00
Brian Ashworth 8b593677d2 output: fix updating output manager config
The output manager config is created when the output is created. It is
updated when the mode, transform, scale, or layout for the output
changes, as well as, when the output is destroyed.

Since the output->enabled property was not being set before calling
apply_output_config, the output event handlers were early returning and
never updating the output manager config when the output state was
committed.

This fixes the issue by setting output->enabled in apply_output_config
below the output disabling section. There are also a few other minor
changes that are required to function.

Additionally, this renames output_enable to output_configure to better
describe the recent changes.
2020-02-16 09:42:22 +01:00
Simon Ser f5fa0c7124 Stop calling apply_output_config from output_enable
The only output_enable caller is now apply_output_config. Stop calling
apply_output_config from output_enable to simplify the code and avoid
the back-and-forth between these two functions.

output_enable is now the symmetric of output_disable: it just marks the
output as enabled and performs bookkeeping (e.g. creating teh default
workspace). It is called from apply_output_config after the output
commit, so that it can read the current output state and act
accordingly.

This change also allows us to avoid an extraneous wlr_output_commit.

References: https://github.com/swaywm/sway/issues/4921
2020-02-11 20:52:02 -05:00
Hristo Venev 7affe5c1bd swaybar: fix i3bar relative coordinates when scaling is used
24e8ba048a did not take scaling into account.
The hotspot size used pixel coordinates, the absolute coordinates were logical,
and the relative coordinates were completely wrong.

This commit makes all coordinates use logical values. If
`"float_event_coords":true` is sent in the handshake message, coordinates are
sent as floating-point values.

The "scale" field is an integer containing the scale value.
2020-02-10 18:58:09 +01:00
Hristo Venev fca32b6334 Do not truncate pointer coordinates to int.
This increases the precision of the clicks when using i3bar.
2020-02-10 18:58:09 +01:00
Anders 4e46bdf73d criteria: match containers without view
Closes #4929

Replaces criteria_get_views with criteria_get_containers which can
return containers without views when the criteria only contains
container properties.
2020-02-04 19:52:21 -05:00
thermitegod 29a5ce5f65 Fix compiling with -fno-common 2020-01-24 10:16:59 +01:00
Ronan Pigott d88d4bbd9d Fix crash when showing scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Simon Ser 0d2a3fa835 Revert "Make all the container dimensions integers"
This reverts commit 79c5f5ba12.

Fixes: https://github.com/swaywm/sway/issues/4908
2020-01-15 17:56:14 +01:00
Brian Ashworth c99d423ad9 view: remove workspace pid mapping for assigns
If a view is mapped to a workspace using an assign, the pid should still
be removed from the pid mapping list. This prevents child processes from
matching against it and mapping a view to a likely undesired workspace.
2020-01-09 09:52:37 +01:00
Brian Ashworth 897c36b12c input/cursor: handle image surface destroy
This adds a listener for the destroy event of the cursor image surface.
This prevents a use-after-free when the last visible image surface is
freed, there has not been a new cursor set, and the cursor is reshown.
2020-01-05 23:03:34 +01:00
Andri Yngvason 4c29a53386 swaynag: Add multi-seat support
This also adds cleanup for all seat resources
2020-01-05 19:57:05 +01:00
Pedro Côrte-Real 79c5f5ba12 Make all the container dimensions integers
Containers are always fixed to the pixel grid so position and size them
with integers instead of doubles.

Functionally this should be no different since rounding down is already
being done on things like layout. But it makes it clear what the
intention is and avoids bugs where fractional pixels are used. The
translating and moving code is still using doubles because the cursors
can have fractional pixels and thus the code is plumbed that way. But
that could also probably be changed easily by doing the integer
conversions earlier and plumbing with int.
2020-01-01 10:14:40 -07:00
Pedro Côrte-Real 8008344762 Avoid numerical instability in resize
Because the layout code rounds down the dimensions of the windows
resizing would often be off by one pixel. The width/height fraction
would not exactly reflect the final computed width and so the resize
code would end up calculating things wrong.

To fix this first snap the container size fractions to the pixel grid
and only then do the resize. Also use round() instead of floor() during
layout to avoid a slightly too small width. This applies in two cases:

1. For the container we are actually resizing using floor() might result
   in being 1px too small.
2. For the other containers it might result in resizing them down by 1px
   and then if the container being resized is the last all those extra
   pixels would make the resize too large.

Fixes #4391
2020-01-01 10:14:29 -07:00
Josef Gajdusek f501a60c14 Add virtual pointer protocol 2019-12-31 16:04:50 +01:00
Brian Ashworth f898ca9a83 bar_cmd_colors: remove add_color
This is the third commit in a series of commits to refactor color
handling in sway. This removes add_color from commands.c. It was only
being used by bar_cmd_colors. This also changes the functions to use
parse_color which is used to validate rgb(a) colors throughout the code
base and is also what i3bar is using to parse the colors after they are
passed over ipc. After parsing the color and ensuring it is valid, the
rgba hex string is then generated using snprintf. This refactor also
ensures that all the colors for the command are valid before applying
any of them.
2019-12-28 10:07:25 +01:00
Brian Ashworth 66dc33296c cmd_client_*: refactor duplicated code
This is the second in a series of commits to refactor the color handling
in sway. This removes the duplicated color parsing code in
sway/commands/client.c. Additionally, this combines the parsing of
colors to float arrays with that in sway/config.c and introduces a
color_to_rgba function in commom/util.c.

As an added bonus, this also makes it so non of the colors in a border
color class will be changed unless all of the colors specified are
valid. This ensures that an invalid command does not get partially
applied.
2019-12-28 10:07:25 +01:00
Brian Ashworth 97f9f0b699 parse_color: return success + drop fallback color
This is the first in a series of commits to refactor the color handling
in sway. This changes parse_color to return whether it was success and
no longer uses 0xFFFFFFFF as the fallback color. This also verifies that
the string actually contains a valid hexadecimal number along with
the length checks.

In the process of altering the calls to parse_color, I also took the
opportunity to heavily refactor swaybar's ipc_parse_colors function.
This allowed for several lines of duplicated code to be removed.
2019-12-28 10:07:25 +01:00
Brian Ashworth 452a615bb8 seat_cmd_keyboard_grouping: change keymap to smart
This removes `seat <seat> keyboard_grouping keymap` and replaces it with
`seat <seat> keyboard_grouping smart`. The smart keyboard grouping will
group based on both the keymap and repeat info. The reasoning for this
is that deciding what the repeat info should be for a group is either
arbitrary or non-deterministic when multiple keyboards in the group have
repeat info configured (unless somehow exposed to the user in a
reproducible uniquely identifiable fashion).
2019-12-16 12:03:11 -05:00
Drew DeVault 2f3c6cccf5 Add seat <seat> idle_{inhibit,wake} <sources...>
This adds seat configuration options which can be used to configure what
events affect the idle behavior of sway.

An example use-case is mobile devices: you would remove touch from the
list of idle_wake events. This allows the phone to stay on while you're
actively using it, but doesn't wake from idle on touch events while it's
sleeping in your pocket.
2019-12-12 10:37:30 -05:00
Benjamin Cheng 9ef026e804 input/cursor: pass gesture events to clients
Some wayland clients (mostly GTK3 apps) like eog or evince support
gestures like pinch-to-zoom. These gestures are given to clients
via the pointer_gestures_v1 protocol. This is already supported in
wlroots, so we just need to hook up the events here in sway.

Fixes #4724
2019-12-07 12:26:21 -05:00
Kenny Levinsen d1eab10266 output: Schedule idle frames if we do not render
Repaint scheduling delays output render and frame done events from
output frame events, and block idle frame events from being scheduled in
between output frame done and output render in this period of time.

If a surface is committed after its frame done event, but before output
render, idle frame requests will be blocked, and the surface relies on
the upcoming render to schedule a frame.

If when the repaint timer expires, output render is deemed unnecessary,
no frame will be scheduled. This can lead to surfaces never having their
frame callbacks fire.

To fix this, we store that a surface has requested a frame in
surface_needs_frame. When the repaint expires, if no render is deemed
necessary, we check this flag and schedule an idle frame.

Fixes #4768
2019-12-01 12:44:07 +01:00
Ronan Pigott 6968fb3123 add scale_filter output config option 2019-11-29 18:13:37 +01:00
Brian Ashworth 5d882cb5fc Add support for wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. This is useful for keyboards that
are split into multiple input devices despite appearing as one physical
keyboard in the user's mind.

This adds support for wlr_keyboard_groups to sway. There are two
keyboard groupings currently supported, which can be set on a per-seat
basis. The first keyboard grouping is none, which disables all grouping
and provides no functional change. The second is keymap, which groups
the keyboard devices in the seat by their keymap. With this grouping,
the effective layout and repeat info is also synced across keyboard
devices in the seat. Device specific bindings will still be executed as
normal, but everything else related to key and modifier events will be
handled by the keyboard group's keyboard.
2019-11-21 10:42:10 -05:00
Brian Ashworth 2f858a1ada input_cmd_xkb_file: allow shell path expansion
This allows for shell path expansion for input_cmd_xkb_file. The logic
has been extracted from output_cmd_background
2019-11-21 10:36:15 -05:00
Ivan Molodetskikh bd9a53f1a3 view: add max_render_time 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 5421198489 Add sway_surface
For extending wlr_surface with additional things.
2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 022df2542b output: add max_render_time 2019-11-17 20:18:42 +01:00
Tadeo Kondrak 7f54495b5e Use an enum instead of a marker string for map_to_ 2019-11-17 13:34:24 +01:00
Tadeo Kondrak 4829f1c26a Implement input map_to_region command 2019-11-17 13:34:24 +01:00
Ronan Pigott 3975ca28c2 smart_borders: separate smartness from edge types 2019-11-04 21:16:27 -05:00
Simon Ser 38b37247ff Add --custom to output mode command
This forces to set the mode as a custom mode.
2019-11-04 19:40:47 -05:00
Sheena Artrip 7efb5d4673 Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.
set_cloexec is defined by both sway and wlroots (and who-knows-else),
so rename the sway one for supporting static linkage. We also remove
the duplicate version of this in client/.

Fixes: https://github.com/swaywm/sway/issues/4677
2019-11-01 12:41:08 -04:00
Simon Ser ad07886543 Handle layer changes for layer shell surfaces
Closes: https://github.com/swaywm/sway/issues/4644
References: 1982106c9b
2019-10-27 11:07:18 -04:00
Ronan Pigott 7c9b71f5c6 criteria: make literal comparison for __focused__ values 2019-10-27 11:06:05 -04:00
Simon Ser ec14a00e8c Fix segfault in wlr_output_manager_v1_set_configuration
Calling wlr_output_manager_v1_set_configuration with an enabled output
and a NULL mode is incorrect if the output doesn't support modes.

When DPMS'ing an output, wlr_output_enable(output, false) is called.
This de-allocates the CRTC and sets wlr_output.current_mode to NULL.

Because we mark DPMS'ed outputs as enabled, we also need to provide a
correct output mode. Add a field to sway_output to hold the current
mode.

Closes: https://github.com/swaywm/wlroots/issues/1867
2019-10-27 10:51:02 -04:00
Simon Ser 58a40ce07b Fix apply_output_config return value when enabling output
apply_output_config would call output_enable and always return true,
even if the output couldn't be enabled.
2019-10-27 10:51:02 -04:00
Konstantin Pospelov fa0abaf7cf swaybar: do not retry search for tray icons
In case a tray icon cannot be found or does not have a desirable size,
swaybar retries the search again and again, which increases load on disk
and CPU. This commit solves it by storing target_size for each icon, so
that swaybar does not search for an icon of some size if it already tried to.

Fixes #3789.
2019-10-21 17:22:25 +02:00
lbonn 3ee3a9ef60 focus: support focus_wrapping workspace
Following i3 support: https://github.com/i3/i3/pull/3407
2019-10-17 13:48:52 +03:00