Commit graph

3872 commits

Author SHA1 Message Date
Simon Ser 46561fc914 Fix seat_set_focus_layer crash when disabling output
This fixes the following crash:

    #0  0x00007f7daac3af25 in raise () at /usr/lib/libc.so.6
    #1  0x00007f7daac24897 in abort () at /usr/lib/libc.so.6
    #2  0x00007f7daac24767 in _nl_load_domain.cold () at /usr/lib/libc.so.6
    #3  0x00007f7daac33526 in  () at /usr/lib/libc.so.6
    #4  0x0000555bfbc35029 in seat_set_focus_layer (seat=0x555bfd76d860, layer=0x555bfdda2ff0)
        at ../sway/input/seat.c:1164
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
    #5  0x0000555bfbc35029 in seat_set_focus_layer (seat=seat@entry=0x555bfd76d860, layer=0x555bfdda2ff0)
        at ../sway/input/seat.c:1164
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
    #6  0x0000555bfbc25899 in handle_output_destroy (listener=0x555bfdb90688, data=<optimized out>)
        at ../sway/desktop/layer_shell.c:263
            layer = 0x555bfdd6b040
            sway_layer = 0x555bfdb90610
            seat = 0x555bfd76d860
            client = 0x555bfdb76d70
            set_focus = <optimized out>
    #7  0x0000555bfbc5b669 in wl_signal_emit (data=0x555bfd795930, signal=0x555bfd795ae0)
        at /usr/include/wayland-server-core.h:472
            l = <optimized out>
            next = 0x555bfdb6a3e8
            __PRETTY_FUNCTION__ = "output_disable"
            index = <optimized out>
    #8  0x0000555bfbc5b669 in output_disable (output=output@entry=0x555bfd795930)
        at ../sway/tree/output.c:263
            __PRETTY_FUNCTION__ = "output_disable"
            index = <optimized out>
    #9  0x0000555bfbc3b890 in apply_output_config (oc=0x555bfd7d73d0, output=output@entry=0x555bfd795930)
        at ../sway/config/output.c:321
            wlr_output = 0x555bfd7afaf0
            scale = <optimized out>
            output_box = <optimized out>
    #10 0x0000555bfbc28309 in handle_output_manager_apply
        (listener=0x555bfbc7f148 <server+488>, data=0x555bfdca6eb0) at ../sway/desktop/output.c:936
            wlr_output = <optimized out>
            output = 0x555bfd795930
            oc = <optimized out>
            server = 0x555bfbc7ef60 <server>
            config = 0x555bfdca6eb0
            config_head = 0x555bfdb79350
            ok = true
    #11 0x00007f7dab4fbf7c in wlr_signal_emit_safe (signal=<optimized out>, data=0x555bfdca6eb0)
        at ../subprojects/wlroots/util/signal.c:29
            pos = 0x555bfbc7f148 <server+488>
            l = 0x555bfbc7f148 <server+488>
            cursor =
              {link = {prev = 0x555bfbc7f148 <server+488>, next = 0x7fff238a8390}, notify = 0x7f7dab4fbef0 <handle_noop>}
            end =
              {link = {prev = 0x7fff238a8370, next = 0x555bfd7419f8}, notify = 0x7f7dab4fbef0 <handle_noop>}
    #12 0x00007f7daa45469a in ffi_call_unix64 () at /usr/lib/libffi.so.6
    #13 0x00007f7daa453fb6 in ffi_call () at /usr/lib/libffi.so.6
    #14 0x00007f7daae6f82f in  () at /usr/lib/libwayland-server.so.0
    #15 0x00007f7daae6c193 in  () at /usr/lib/libwayland-server.so.0
    #16 0x00007f7daae6d7f2 in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
    #17 0x00007f7daae6c39c in wl_display_run () at /usr/lib/libwayland-server.so.0

This crash happens because focus can only be set on mapped surfaces.
2020-02-06 17:19:58 +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
Nathan Rossi ffbf10d07b ipc: Handle unsupported binding event types
Handle binding event types that cannot be encoded gracefully by dropping
the event. This prevents issues for binding types like BINDING_SWITCH,
where the event would cause a crash.
2020-01-30 15:03:54 +01:00
Jason Nader 5568f14e71 Docs: Add marks field to get_tree response 2020-01-24 10:37:21 +01:00
thermitegod 29a5ce5f65 Fix compiling with -fno-common 2020-01-24 10:16:59 +01:00
Alex Maese 8faaf52f7f Add documentation for floating_modifier 2020-01-20 09:19:04 -07:00
Alex Maese 86ee240a4a Add ability to remove the floating modifier 2020-01-20 09:19:04 -07:00
Jason Nader a576bc27bf Check argc>0 before strcasecmp. Should shortcircuit 2020-01-18 10:36:03 +01:00
Jason Nader 450b40c635 commands/move: Fix crash when required args not provided
Fixes #4919.
2020-01-18 10:36:03 +01:00
Brian Ashworth 9d827ef493 output: apply oc to outputs using wl_for_each_safe
If applying an output config to an output fails, the output may be
destroyed. To be able to handle this situation correctly,
apply_output_config_to_outputs needs to use wl_list_for_each_safe.
2020-01-16 19:55:24 -07:00
Ronan Pigott 5501d14a2e cmd_split: Refuse to split scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott 72ad35ba16 cmd_move: Fix crash when moving to scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott d88d4bbd9d Fix crash when showing scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Brian Ashworth 18507e62fd desktop/output: fix mem leak in handle_new_output
This fixes a memory leak of oc (the output config) in handle_new_output.
Output configs returned from find_output_config are not stored and need
to be freed after use.
2020-01-16 18:14:49 -07:00
Ronan Pigott 1bd51d9377 sway.5: Document missing bindsym flags for unbindsym
sway.5: Remove indents within long command descriptions
2020-01-16 16:15:50 +01:00
Ronan Pigott 5215cdfa92 sway-input.5: Document repeat_delay and repeat_rate only once 2020-01-16 16:15:50 +01:00
Ronan Pigott 33fc9c5f1f ipc-json: Remove unnecessary dereference 2020-01-16 16:15:50 +01:00
Ronan Pigott f68961fbe6 commands/split: Fix error message typos 2020-01-16 16:15:50 +01:00
Brian Ashworth a4e4e21edf container: add inactive fullscreen to focus stack
When a container was being made fullscreen and it is on the focused
workspace for a seat, focus was being set to the container. However,
when the container was on a non-focused workspace, the focus stack
wasn't being touched. When assigning a fullscreen container to a
workspace or moving a fullscreen container to a different workspace,
this would make it so the fullscreen container was never added to the
focus stack for the workspace thus preventing access to the workspace.
This adds the container to the top of the focus stack, behind the
container on the focused workspace.
2020-01-14 07:38:57 -07:00
Simon Ser 679aa6032d Fix unreliable scaling filter
Two changes were made:

- Bind the texture before glTexParameteri
- Set the scaling filter before each wlr_render_texture_with_matrix call

Logging in wlroots allows to check that the scaling filter is properly
set prior to rendering.

Fixes: 6968fb3123 ("add scale_filter output config option")
Closes: https://github.com/swaywm/sway/issues/4798
2020-01-13 12:36:14 -07:00
Cassandra McCarthy 8b251f068f integer scaling, not integral 2020-01-10 07:03:24 -07: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 1e2a2b0778 input/cursor: handle setting a NULL image surface
This fixes a crash when attempting to listen to a signal on a NULL
cursor image surface. If the surface is NULL, the listener is just
reinitialized using wl_list_init.
2020-01-06 10:12:28 +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
Brian Ashworth b977c02e35 render: do not render indicator on floating views
This adds a check to make it so the indicator is only rendered on views
with a parent, which floating views do not. Since floating views do not
have a parent, the workspace layout was being incorrectly used to
determine whether to show the split indicator previously. This has no
impact on floating containers and a view within a floating container
will still have indicators rendered appropriately.
2020-01-05 22:16:44 +01:00
Ross Schulman b758b43085 Fix small typo in sway-input(5) 2020-01-05 11:16:15 -05:00
Thayne McCombs 218950c88d Add missing items to documentation for GET_TREE response in ipc.
A few items in the response for the get_tree ipc call were missing from
the documentation. This adds some documentation for them.
2020-01-05 10:53:16 +01:00
Rouven Czerwinski 1e44247baa xwayland: handle size_hints == NULL
In case xcb-iccm is not installed on the system, size_hints will be
null. Handle this as if the get_constraints functions was not
implemented and return the defaults.

Fixes #4870
2020-01-03 14:02:19 +01:00
Andri Yngvason d510684c47 input: Assign virtual input devices to their selected seats 2020-01-01 10:21:04 -07:00
Pedro Côrte-Real bd1fb76e0f Make sure we don't calculate fractional pixel gaps
When gaps are resized for lack of space the calculation could result in
a gap size of non-integer pixels. This would result in containers
located at non-integer pixels which would be subtly broken.
2020-01-01 10:14:29 -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
Paul Riou 2b5e75032b Fix sway_log using non initialised output_config pointer
This fixes a crash where the `oc->name` would be accessed by sway_log()
even when `oc` was NULL.
2019-12-31 15:56:32 +01:00
Simon Ser ef2332f7a6 Re-add support for wlr_output's atomic API
This reverts commit 724926ea6a and
re-applies commit 6e0565e9de.

Outputs now need to be explicitly enabled when performing a modeset.
We need to roll back wlr_output_attach_render when we decide not to
render.

See also: https://github.com/swaywm/wlroots/pull/1797 (wlroots PR)
See also: https://github.com/swaywm/sway/pull/4355 (Original sway PR)
See also: https://github.com/swaywm/sway/pull/4434 (Revert sway PR)
2019-12-30 11:24:11 -07:00
Brian Ashworth de43f7c1db cmd_client_*: support optional args for i3 compat
For i3 compatibility, allow the indicator and child_border colors values
to be optional. The indicator will fallback to sane defaults and
child_border will fallback to the background color for the class.
2019-12-29 10:40:06 +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 088b374b1a layer-shell: refocus if keyboard interactive lost
When arranging layer-shell layers, verify that the currently focused
layer, if any, for each seat is still keyboard interactive. If the layer
is no longer keyboard interactive and there is not a keyboard
interactive overlay or top layer to change the focus to, refocus the
focus inactive node for the seat.
2019-12-27 11:38:56 +01:00
Ronan Pigott bd42415b5d config/output: apply scale_filter even when scale has not changed 2019-12-27 11:38:05 +01:00
Manuel Stoeckl 1d483c340d desktop/surface: Fix crash when timer is NULL
When many surfaces are created, sway can run out of file descriptors,
making wl_event_loop_add_timer (which creates a timerfd) fail and
return NULL. This patch posts a "no memory" error when that is the case,
and only removes the timer if it was created.

(Why "no memory"? It is not easy to distinguish between failures due to
running out of memory and failures due to running out of file
descriptors. Also, using the newer `wl_client_post_implementation_error`
function would lead to an increased version requirement for the
libwayland-server dependency.)
2019-12-24 13:03:50 +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
Brian Ashworth 2b51c5b294 input/seatop_default: fix focusing floating titles
When clicking on the titlebar of a floating container (or descendant of
a floating container), the top-level floating container was being
focused and then allowing you to move the top-level floating container.
This made it so you couldn't switch to a different tab/stack within the
floating container. With this patch, the focus inactive view for the
container that the titlebar is associated with is focused, then the
traversal to the top-level floating container is performed to use with
the move floating operation.
2019-12-16 12:02:05 -05:00
Brian Ashworth 0278c4db6f root_scratchpad_hide: disable fullscreen descendants
Any descendant of a scratchpad container may be fullscreen so checking
to see if the top-level scratchpad container is fullscreen in
root_scratchpad_hide is not sufficient. This iterates through all
descendants of the scratchpad container
2019-12-16 12:01:42 -05:00
Brian Ashworth 218b5b9dc0 config/input: set type for new identifier configs
When an input becomes available, the input type config for that device
type will be merged underneath the input identifier config, provided
they both exist. If an input type config gets added or modified at a
later point, then those changes get merged onto the input identifier
configs for that type. However there was a missing case of the input
identifier config being added after the device is already available and
the input type config existing. This makes it so that the first time an
input identifier config gets stored, there will be a check to see if it
matched any of the available devices. If it does, then there will be a
search for the associated input type config, which will be merged
underneath the input identifier config if found.
2019-12-14 09:31:42 -05:00
Brian Ashworth f9ce8749dc input/keyboard: defer wlr_keyboard_group destroy
This defers the destruction of wlr_keyboard_groups until idle. This is
to prevent the keyboard group's keyboard from being destroyed in the
middle of handling a keyboard event. This would occur when changing the
keymap of the last keyboard in a group with a keyboard binding. The
prevents crashing when attempting to update the xkb state of the
keyboard group's keyboard. The sway_keyboard_group is still immediately
destroyed so that the group is no longer used
2019-12-13 09:53:51 +01:00
Brian Ashworth f365ffef34 input/keyboard: remove group listeners on destroy
This adds two missing calls to wl_list_remove to remove the key and
modifier listeners for the keyboard group's keyboard when destroying
the keyboard group. This fixes some crashes when changing the keymap of
the last keyboard in a group with a keyboard binding.
2019-12-13 09:53:51 +01:00
Simon Ser 2f84d6e349 Auto-detect output scale
If the screen DPI is high enough, auto-enable scale=2 (if the user
hasn't set the scale).

Uses heuristics based on [1].

[1]: 0521706617/src/backends/meta-monitor.c (L1590)

Closes: https://github.com/swaywm/sway/issues/1800
2019-12-12 19:00:24 -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
Ronan Pigott f645f8efd6 Fix lingering workspace with scratchpad show
Showing a window in the scratchpad can move a visible scratchpad window
from another workspace to the current one. If the scratchpad window was
the last visible container in that workspace, the old workspace should
be destroyed.
2019-12-12 06:51:13 -05:00
Brian Ashworth b7f0656fab layer-shell: unfocus output-less layer on unmap
If a layer is focused by any seat, it needs to be unfocused on unmap. If
the unmap was due to an output being disabled, there would not be a
sway_output and unmap would do an early return. This results in a
use-after-free if the layer was focused by any seat prior to being
unmapped. This change just moves the refocusing code above the early
returns.
2019-12-10 21:09:48 -05:00
Benjamin Cheng 2d0f15debb input/cursor: remove gesture listeners in destroy
Part of #4794. Forgot to remove gesture listeners when the
cursor is destroyed.
2019-12-07 12:55:37 -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
Brian Ashworth fe7ec8024c config: apply input type configs on reload
When making the reload validation improvements, I forgot that input type
configs are stored in a separate list. This makes it so input type
configs are correctly applied on reload.
2019-12-04 02:11:22 +01:00
Jayce Fayne ad189d27f9 Revert "fix bar_state_update/input event"
This reverts commit a3da7fec32.
2019-12-02 19:57:06 +01:00
Rex Hackbro a3da7fec32 fix bar_state_update/input event 2019-12-01 16:40:26 -05:00
Kenny Levinsen 275af2ad62 output: Restore previous max_render_time behavior 2019-12-01 12:44:07 +01: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
Kenny Levinsen 57f615e122 output: Replace block_idle_frame with frame_pending 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
Kenny Levinsen 4b57953628 output: Ensure that frame_done is delayed on max_render_time
max_render_time can be set on output, view, or both. However, if only
applied to the output, send_frame_done_iterator would erroneously send
frame_done immediately, ignoring the output max_render_time. As
damage_handle_frame processed max_render_time correctly, idle frames
would be blocked in anticipation of the delay that was meant to happen.

Without the delay, frame events would be dispatched during the idle
frame block, and some clients would never receive the frame done events
they had requested, at least not until something else actively drove
another render.

Respecting both view and output max_render_time in
send_frame_done_iterator ensures that the frame events are always
correctly delayed.

Fixes #4756
2019-11-28 23:40:36 +01:00
Rex Hackbro 9979382d56 Rename 'node' to 'nodes' in swayipc doc 2019-11-28 23:29:17 +01:00
Brian Ashworth 0cdad33f1a input/keyboard: reset seat keyboard on destroy
If a sway keyboard is being destroyed, then the keyboard is being
removed from a seat. If the associated wlr_keyboard is the currently
set keyboard for the wlr_seat, then we need to reset the wlr_seat's
keyboard to NULL so it doesn't reference an invalid device for the seat.
The next configured keyboard from the seat or the next keyboard from
that seat that has an event will then become the seat keyboard.
Similarly, this needs to be done for a wlr_keyboard_group's keyboard
when the wlr_keyboard_group is being destroyed.
2019-11-28 10:34:49 +01:00
Brian Ashworth 1a5797803a config: improvements to the reload validation
For the validation pass of reloading, there is no need to touch swaybg,
swaynag, inputs, outputs, or seats. This drastically improves the speed
of a reload by skipping over the expensive I/O configuration and
handling of wayland clients. As long as the syntax is valid, the
CMD_FAILURE's can be relayed during the actual reload.
2019-11-27 02:04:13 +01:00
Brian Ashworth 90e3d25009 input/keyboard: check keyboard group before remove
In sway_keyboard_destroy, only remove the keyboard from a keyboard
group, if it is part of a keyboard group. If the keyboard is not part of
a keyboard group, then there is nothing to remove it from
2019-11-26 11:31:55 +01:00
Paul Riou 3334d11adc input: seat: Fix seat device list not initialised before use
When being created, non first seats would get through the list of devices
without the list being first initialised -> segfault.
Issue introduced with ab0248a545

Fixes #4750: Crash when reloading Sway with multiple seats configured
2019-11-24 21:51:06 +01:00
Jason 939c7b2d52 Amend typos 2019-11-23 11:48:31 +01:00
Simon Ser 1d3cbe9f27 Use new presentation-time helper
This has the advantage to (1) reduce boilerplate and (2) make us
correctly handle wlr_output_event_present.commit_seq.
2019-11-21 11:19:00 -05: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
Brian Ashworth 66725f2e27 input/keyboard: cleanup xkb_file error handing
This fixes an inverted fclose return value check and simplifies the
error handling and logging for xkb_file in sway_keyboard_compile_keymap
2019-11-21 09:49:25 -05:00
Ivan Molodetskikh ba8586e282 Add note about backends to output max_render_time 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 76210c141d output: check wlr_output in repaint handler
It's possible for the output to be disconnected in just the right moment
for wlr_output to be NULL in the repaint handler, causing a crash. This
check fixes that crash.
2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 7f8a47855c Add max_render_time to view JSON 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh fe84ec2f24 Add max_render_time to output JSON 2019-11-17 20:18:42 +01: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
Rouven Czerwinski df1a046875 xwayland: get_constraints using size hints
Previously, Xwayland windows did not have size_constraints implemented,
resulting in the window being resizable. This implements the constraints
through the X11 size hints supplied by the window itself.
2019-11-16 10:18:26 +01:00
Ronan Pigott 37afbc4dbc seatop_default: handle focus for unmanaged xwayland windows last
Fixes #4707
2019-11-08 19:06:00 -05:00
Simon Ser f576bcdb8c Use wlr_output_preferred_mode instead of the last mode
Instead of relying on the order of modes, use wlr_output_preferred_mode
to get the preferred mode.
2019-11-05 14:00:23 -05:00
Simon Ser 01b5350bdc Fix segfault in set_mode
best is NULL prior to being assigned to a mode.

Closes: https://github.com/swaywm/sway/issues/4705
Fixes: f33dcd4c60 ("Prefer higher refresh rate default modes")
2019-11-05 13:35:56 -05:00
Ronan Pigott f33dcd4c60 Prefer higher refresh rate default modes 2019-11-05 10:34:44 +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
Ronan Pigott eaee087c17 seatop_default: handle focus for xwayland_unmanaged views 2019-11-04 23:56:27 +01:00
Ronan Pigott d159b98744 seatop_move_floating: make container respect pointer constraint 2019-11-04 23:53:30 +01:00
Ronan Pigott 1f469e1692 focus: do nothing on focus prev|next for workspaces 2019-11-04 23:48:39 +01: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
lbonn cf95de9cae focus: add a NULL check in focus <direction>
container is checked for NULL in other conditions earlier, it's not
obvious that it can't be undefined here.
2019-11-01 12:18:09 -04:00
lbonn 30fa7d191e Fix potential NULL reference on cleanup
If allocation of bindings failed.

Found with clang-tidy
2019-11-01 12:18:09 -04:00
lbonn a6307aed00 Fix various memory leaks
Found with clang-tidy
2019-11-01 12:18:09 -04:00
lbonn 32caabc7a1 seat: simplify a strdup 2019-11-01 12:18:09 -04:00
Robert Günzler 354e705a7b Skip line continuation when it is a comment
Currently commented lines ending in the backslash character will be
concatenated with the following line.

```
 # with this comment \
exec swaynag -m 'will not run'
```

This change modifies `getline_with_cont` to stop reading when the
initial character is a '#'.
2019-10-31 23:05:06 +01:00
Simon Ser 1a253ca7ab Fix presentation feedback when scanning out fullscreen view
Closes: https://github.com/swaywm/sway/issues/4663
2019-10-27 11:07:48 -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
Ronan Pigott f5f12a69f6 focus: support focus prev|next [sibling] 2019-10-27 11:02:57 -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
Kirill Chibisov 43bd8dc437 Fix tiled containers resize with mouse
Fixes regression introduced in 2c1a11016c
2019-10-23 17:21:09 +02:00
Danilo Spinella a5b6f40937 Fix refresh rate scale of output
When applying config, value mode->refresh is mHz; convert it to Hz before
assigning it to the temporary output config. oc->refresh_rate will
be converted back to mHz in set_mode function.

Fix debug log printing GHz instead of Hz.
2019-10-21 14:22:20 +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
A. M. Joseph 74c0e7921a xwayland.c handle_map(): NULL out xsurface->data() to prevent crashing.
When changing a surface from managed to unmanaged in handle_map(), the
call to handle_destroy(.., view) causes the sway_xwayland_view pointed
to by the untyped wlr_xwayland_surface.data field to become invalid
garbage, yet the untyped wlr_xwayland_surface.data continues to point
at it.  In particular: view_get_*(view_from_wlr_surface(..)), even
with appropriate NULL checking, will crash sway when this codepath is
exercised (reliable test case: drop-down menus in Google Earth).
2019-10-17 11:40:16 +03:00
Drew DeVault d19f4f7bf8 Updates per wlroots layer shell changes 2019-10-16 10:24:15 -04:00
Rouven Czerwinski 344c259ec0 sway(5): move workspace_layout to config only
According to the source files, workspace_layout is a configuration only
command, move it to the correct section within the man page.
2019-10-16 14:21:45 +03:00
Wieland Hoffmann f79f00dbfb sway(5): Highlight valid values in the description of tiling_drag 2019-10-09 23:32:08 +03:00
Wieland Hoffmann 42db4468a0 sway(5): Add a missing verb 2019-10-09 23:32:08 +03:00
Arkadiusz Hiler cf18bd8879 Fix syntax in examples in sway-output(5)
Some examples use comma to separate x and y for setting the output
position which is wrong.

Let's change it to spaces, as correctly demonstrated in the
`output <name> position|pos <X> <Y>` section.
2019-10-02 17:37:54 -04:00
Sebastian Krzyszkowiak edcd353a00 layer-shell: Fix damage tracking of nested popups
Popups are positioned relative to local surface coordinates of the
parent surface. There's no need to consider values set with
xdg_surface.set_window_geometry for parent surfaces.
2019-09-29 19:50:58 +03:00
Simon Ser 00c4c7e8cc Fix direct scan-out flickering
Sometimes when using direct scan-out, some flickering between the
fullscreen app and the regular desktop could be seen.

This happened because we called wlr_output_attach_render and then
wlr_output_attach_buffer for direct scan-out. wlr_output_attach_render
makes the OpenGL context current but also attaches the OpenGL buffer to
the primary plane apparently (all of this happens inside
eglMakeCurrent).

This patch moves the scan-out logic outside of output_render, before
wlr_output_attach_render. This lines it up with rootston's
implementation. This also makes more sense since no rendering is
involved when using direct scan-out.

Sorry about that, I should've tested this with more clients. The new
code has been tested with mpv and a GLFW demo.
2019-09-26 10:36:18 -04:00
John Chadwick 7e420cb6e4 input: Add support for tablet protocol.
Sway has basic support for drawing tablets, but does not expose
properties such as pressure sensitivity. This implements the wlr tablet
v2 protocol, providing tablet events to Wayland clients.
2019-09-25 23:10:33 -04:00
Simon Ser 875edc9c2f Add support for fullscreen view direct scan-out 2019-09-25 23:00:08 -04:00
Ronan Pigott ec66bb987a view: create container before selecting workspace 2019-09-22 15:18:51 -04:00
Simon Ser c41c24d684 Error out on unknown debug flag
Otehrwise it's pretty easy to misremember a flag and think damage=rerender is
enabled when it's not.
2019-09-22 15:17:59 -04:00
Brian Ashworth da0ad4c39e view: always populate pid
If the view was mapped as fullscreen or the view was assigned either a
workspace or output, the pid was not being populated since it was
occurring as part of the pid mapping check in select_workspace. This
extracts the pid population and makes it so it is always executed
2019-09-20 20:47:59 +03:00
Ivan Molodetskikh fba248ed5e render: set surface as sampled for presentation 2019-09-19 19:47:24 +03:00
Martin Michlmayr c11c8a583f sway-output.5: fix variable name
__foo__ is verbatim in scdoc, but we want the variable foo in italic,
i.e. _foo_.
2019-09-11 15:34:11 +03:00
Brian Ashworth aa8ea2fa82 sway.5: clarify that a marks are unqiue
This just clarifies that a mark can only be set for a single window
since they are used as unique identifiers
2019-09-05 22:04:02 +03:00
Nils ANDRÉ-CHANG 21717d2ed2 Fix type (an -> and) 2019-09-05 22:02:33 +03:00
Versus Void 2c1a11016c Do not search for edges on subsurfaces, fix #4381
Subsurfaces (in most cases popups) aren't decorated by sway
and will never have any borders, but may be drawn beyond container
boundaries producing false positive when searching for edge.
So we want to skip edge search when handling mouse event on subsurface.
2019-09-05 17:41:23 +03:00
Brian Ashworth 1fd2c6ba49 swaybar: complete barconfig_update event handling
This adds complete support for the barconfig_update ipc event. This also
changes the bar command and subcommand handlers to correctly emit the
event. This makes it so all bar subcommands other than id and
swaybar_command are dynamically changeable at runtime. sway-bar.5 has
been updated accordingly
2019-09-04 16:48:50 -10:00
Brian Ashworth 187306640b seatop_default: only focus container on press
This matches i3's behavior of only focusing a container when pressed.
This allows for `bindsym button1 nop`, `bindsym BTN_LEFT nop`, or
`bindcode 272 nop` to be used to disable focusing when clicking on the
title (or with additional flags to bind{code,sym} other portions of
the container).

Without this additional condition, the user would need both
`bindsym button1 nop` and `bindsym --release button1 nop` to override
both the pressed and released behavior.
2019-09-04 16:48:34 -10:00
xPMo 42a7860dcf Fix bar_state_update docs 2019-09-03 22:22:25 -04:00
Ben Brown b46c53957f Fix typo for the force/immediate option in xwayland_mode enum 2019-09-02 17:06:38 +03:00
Simon Ser 1b396273bb man: document how to specify multiple xkb layouts and options
This isn't described in xkeyboard-config(7).
2019-09-02 08:39:25 +09:00
Simon Ser 53e01bf5c7 layer-shell: don't give focus to unmapped layer surfaces
Focused layers are not cleared when destroyed, they are cleared on unmap.
Giving focus to an unmapped layer surface is (1) incorrect and (2) triggers a
use-after-free.

Closes: https://github.com/swaywm/sway/issues/4517
2019-09-01 09:58:03 +09:00
Kenny Levinsen b2ee5bc05d Ensure that seat->focused_layer is cleared on unmap
The current seat may have changed between the last focus change and
this unmap, so we need to scan through all seats to find our layer.
2019-09-01 00:03:18 +03:00
xdavidwu 07d7af593d seat: set cursor image only if no pointer cap previously
This make seat_update_capabilities set cursor image only if
there was no pointer cap before update. This avoid resetting
cursor to left_ptr if an input device is removed.
2019-08-31 23:13:12 +09:00
xdavidwu afde6369b8 seat: avoid unneeded reloading xcursor theme
Load xcursor theme on configuring pointer or tablet tool only if
there was no pointer cap before.
2019-08-31 23:12:33 +09:00
Martin Michlmayr 3dcfa2ee90 Fix markup syntax in man pages 2019-08-31 22:50:39 +09:00
Brian Ashworth 1a8b9fda8a cmd_mode: don't reset to default after subcommand
In cmd_mode, the mode is currently being reset to the default mode after
a mode subcommand handler is executed. This stores and restores the mode
instead
2019-08-27 13:45:04 +09:00
asdfjkluiop f07b9afee5 A layer-shell will only be focused if it is non-null 2019-08-27 10:09:41 +09:00
Michael Aquilina a298cad05c Fix formatting for title_format in man 5 sway
Use explicit linebreaks to make scdoc use a separate line for each entry
listed
2019-08-25 09:19:05 +09:00
Dark c3fbb01e07 Update titlebar borders to match i3's current behavior. 2019-08-24 00:41:19 -04:00
Brian Ashworth 90bef0364b cmd_move: fix move to scratchpad hidden container
When moving to a scratchpad hidden container (using `move
[window|container] [to] mark <mark>`), this moves the container to the
scratchpad (equivalent to `move [window|container] [to] scratchpad`).

Previously, this would crash since the destination did not have a
workspace.
2019-08-23 09:12:06 +09:00
Laurent Bonnans a074e0f504 ipc: collapse multi-container command results
Match i3's behavior and only return one status response per command,
even if it applies to several nodes.

Also returns an error if the criteria returns an empty match.

Closes #4483
2019-08-22 13:09:38 -04:00
Brian Ashworth aa9ba58169 sway.5: remove mention of floating_scroll
It looks like floating_scroll was still in the sway(5) man page as a
remnant of the 0.x era. This just removes it from the man page since it
is no longer a valid command. Mouse bindings with Button4-7 can be used
instead
2019-08-22 10:40:13 +09:00
lbonn 7baa3ffece Allow moving a container hidden in scratchpad
(as i3 allows it)

Just update the container's coordinates so that they will be applied at
the next show.
2019-08-20 13:09:52 -04:00
Brian Ashworth ff7d979d99 cmd_xwayland: add force for immediate launch
This just adds a force option to cmd_xwayland that allows for xwayland
to be immediately launched instead of lazily launched. This is useful
for slower machines so it can be part of the startup time instead of
when the user is actively trying to use it
2019-08-20 11:34:34 +09:00
Brian Ashworth 384afc5cb5 input/keyboard: send released only if pressed sent
This keeps track of whether surfaces received a key press event and
will only send a key release event if the pressed event was sent. This
also requires changing the keycodes that are sent via wl_keyboard_enter
to only include those that were previously sent. This makes it so
surfaces do not receive key release events for keys that they never
received a key press for and makes it so switching focus doesn't leak
keycodes that were consumed by bindings.
2019-08-20 11:14:56 +09:00
Simon Ser 7488d33d42 Remove xdg-shell v6 support
All major toolkits and apps have gained xdg-shell stable support.

Closes: https://github.com/swaywm/sway/issues/3690
2019-08-20 10:57:20 +09:00
Ilia Bozhinov 06c36f8435 properly check pixman_region32_contains_rectangle return
pixman_region32_contains_rectangle() returns
pixman_region_intersection_t not a bool.
2019-08-19 12:28:40 +03:00
Brian Ashworth 8441711990 input/seatop_down: add axis handler
This adds an axis handler to seatop_down so that it is possible to
manually scroll while having a mouse button down. This is mainly useful
for selecting text. Some applications may not automatically scroll when
the cursor is near the edge of the application or the user may just
prefer manually scrolling for more control over the scrolling speed.
2019-08-16 08:57:17 +03:00
Brian Ashworth 6061d083ca sway{,-bar}.5: add link to pango font description
This just specifies that both cmd_font and bar_cmd_font should be
specified using the pango font description and adds a link to the pango
documentation regarding the font description
2019-08-16 08:53:55 +03:00
Drew DeVault cb8f68d74b layer-shell: add support for popups 2019-08-14 22:10:05 +03:00
Brian Ashworth f36240208c workspace_split: focus middle if workspace focused
In workspace_split, the middle container that wraps the workspace's
children should be focused for any seat that is focusing the workspace
2019-08-14 13:19:16 +09:00
Brian Ashworth 75a7b02529 container_replace: copy {width,height}_fraction
This copies the width and height fractions from the container to the
container replacing it. Without setting these values, the container
is treated as a new container and throws off the existing sizing. Since
one container is replacing the other, it makes sense for the sizing to
remain the same.
2019-08-14 13:18:57 +09:00
Brian Ashworth acd3db4fe1 workspace: do not destroy if any seat is focusing
Since each seat has its own focus, do not destroy a workspace until it
is no longer focused by any seat. This prevents seats from being forced
to evacuate the workspace just because another seat switched focus away
from it
2019-08-13 11:30:28 +09:00