This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.
wlr_log_init is still invoked in sway/main.c
This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
This add errors from calls to `libinput_device_config_*_set` to the
debug log. This may be useful when looking at issues related to input
devices and config settings not working.
This extends `input <identifier> events toggle` to allow for an optional
list of modes to toggle through. If no event modes are listed, all
supported modes are cycled through (current behavior). If event modes
are listed, they will be cycled through, defaulting to the first mode
listed when the current mode is not in the list. This modes listed will
also not be checked to see if the device supports them and may fail.
Previously, the success of `getline` was tested by checking if the
buffer it allocates is nonempty and has a nonzero first byte. As
`getline` does not explicitly zero out its memory buffer, this may
fail (e.g., with AddressSanitizer). Instead, we check that at least one
character was returned on standard output.
Also, trailing newlines (if present) are now removed.
If output->configured is true, then the output has been modeset correctly and
we don't need to try again. If output->enabled is true, then we are in the
process of configuring the output and we shouldn't do anything.
Designing the output configuration sequence without invalid state is tricky.
We have one function, apply_output_config, that takes an output and (besides
other things) performs a modeset and inserts the output in the output layout.
The modeset can fail, in which case we don't want the output to be enabled.
We also have an output_enable function, which calls output_apply_config and
also configures the output's workspace and inserts it in the root container.
Now, we have two choices.
Either we configure the output before it's been inserted in the root container
and then, if the modeset was successful, we insert it and create the workspace.
The main issue with this approach is that configuring the output triggers a
handful of signals, namely wlr_output.mode and wlr_output_layout.change. In
those event handlers, we need to make sure to ignore these outputs in the
process of being configured.
Either we first insert the output, create the workspace and then try to
configure it. It means we need to undo everything if the modeset fails. The
main issue with this solution is that it enables and disables the output very
quickly, creates a workspace and immediately destroys it, and maybe moves
views back and forth (see output_evacuate).
I've tried to make it so an output isn't enabled then immediately disabled. We
already have code for ignoring outputs when the output is being destructed.
Fixes https://github.com/swaywm/sway/issues/3462
This happens if you plug in more outputs than supported by your GPU.
This patch makes it so outputs without CRTCs appear as disabled. As soon as
they get a CRTC (signalled via the mode event), we can enable them.
This modifies `bar_cmd_tray_bindsym` to use `get_mouse_bindsym` for
parsing mouse buttons. This also introduces `bar_cmd_tray_bindcode`,
which will use `get_mouse_bindcode` for parsing mouse buttons. Like with
sway bindings, the two commands are encapsulated in a single file to
maximize shared code.
This also modifies tray bindings to work off of events codes rather than
x11 buttons, which allows for any mouse buttons to be used.
For `get_bar_config`, `event_code` has been added to the `tray_bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
In `sway_terminate`, `ipc_event_shutdown` was being sent regardless
which mode sway was running in. When running as an ipc client,
`sway_terminate` should just exit
Clear the focus when we hide the cursor and show it again during the unhide
action. The unhide function will rebase the cursor after the unhide.
Tested by looking at the WAYLAND_DEBUG=1 output of termite.
Also call cursor_handle_activity before sending pointer events to send the enter
events to the surface if the cursor was hidden before.
Fixes#3431