Commit graph

3571 commits

Author SHA1 Message Date
Carlo Abelli b00b0fb9d3 fix smart_borders description in manual
The wording for smart_borders was opposite the actual behavior.
2019-02-25 14:52:29 -05:00
Connor E 9032be4f08 Allow 0 degree transform (normal transform). 2019-02-25 11:28:29 +01:00
Milkey Mouse 2f7247e08a swaybar: add overlay mode (fix #1620)
Overlay mode puts the bar above normal windows and passes through/ignores any
touch/mouse/keyboard events that would be sent to it.
2019-02-24 20:05:47 -05:00
db 2510e3df38 add --i3 flag to hide_edge_borders
Enables i3-compatible behavior regarding hiding the title bar on tabbed and
stacked containers with one child.

Related issues and merge requests: #3031, #3002, #2912, #2987.
2019-02-24 15:26:37 -05:00
Connor E d4b1e71b91 Make load_include_configs void. Fix some cases where WD would not be restored. 2019-02-24 00:01:35 -05:00
minus 713883f04c Fix crash exiting fullscreened floating container
container_floating_move_to_center and container_fullscreen_disable were
calling recursively when the container spawned as a fullscreen floating
container (via for_window). Such a window now doesn't crash sway anymore
but is still configured with a wrong, zero size, making it not directly
usable.
2019-02-23 21:40:03 -05:00
Caleb Bassi f84ac3f114 ipc: add missing fields to disabled outputs
i3 requires all outputs to have certain fields, including 'primary', 'current_workspace', and 'rect' which were missing on disabled outputs.

https://i3wm.org/docs/ipc.html#_outputs_reply
2019-02-23 20:27:59 +01:00
emersion 656541bcc4
Update for swaywm/wlroots#1517 2019-02-23 19:04:10 +01:00
Brian Ashworth 9350a52c0e handle_seat_node_destroy: update seat->workspace
If an unmanaged or layer surface is focused when an output gets
disabled and an empty workspace on the output was focused by the seat,
the seat needs to refocus it's focus inactive to update the value of
`seat->workspace`.
2019-02-23 09:21:19 +01:00
Brian Ashworth bcec866c6b handle_layer_shell_surface: do not use noop output
If the noop output is focused (all other outputs disabled/disconnected),
do not auto assign a layer surface to it. The noop output is not enabled
and does not have the `output->layers` list initialized. It also does
not make sense to map the layer surfaces to something that is not
visible.
2019-02-23 09:15:35 +01:00
Rouven Czerwinski 3ead287064 view: set xdg_decoration->view to NULL, check decoration destroy
Fixes heap-use-after-free:

==32046==ERROR: AddressSanitizer: heap-use-after-free on address 0x615000064d20 at pc 0x55571ce4d303 bp 0x7fff545c64c0 sp 0x7fff545c64b0
WRITE of size 8 at 0x615000064d20 thread T0
    #0 0x55571ce4d302 in xdg_decoration_handle_destroy ../sway/xdg_decoration.c:13
    #1 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #2 0x7f64009d3c46 in toplevel_decoration_handle_resource_destroy ../types/wlr_xdg_decoration_v1.c:65
    #3 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)
    #4 0x7f6400a19fed in wl_resource_destroy (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7fed)
    #5 0x7f64009d3d1f in toplevel_decoration_handle_surface_destroy ../types/wlr_xdg_decoration_v1.c:82
    #6 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #7 0x7f64009b059c in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:453
    #8 0x7f64009b0688 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:483
    #9 0x7f64009af08c in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #10 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)
    #11 0x7f6400a1e211  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0xc211)
    #12 0x7f6400a1e6fe  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0xc6fe)
    #13 0x7f6400a1a0ec in wl_client_destroy (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x80ec)
    #14 0x7f6400a1a1c4  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x81c4)
    #15 0x7f6400a1b941 in wl_event_loop_dispatch (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x9941)
    #16 0x7f6400a1a569 in wl_display_run (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x8569)
    #17 0x55571ce4c7fd in server_run ../sway/server.c:214
    #18 0x55571ce4ad59 in main ../sway/main.c:405
    #19 0x7f640071109a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #20 0x55571ce2cfa9 in _start (/usr/local/bin/sway+0x35fa9)

0x615000064d20 is located 32 bytes inside of 504-byte region [0x615000064d00,0x615000064ef8)
freed by thread T0 here:
    #0 0x7f6401531b70 in free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedb70)
    #1 0x55571ce6c72b in destroy ../sway/desktop/xdg_shell.c:252
    #2 0x55571cee3f7b in view_destroy ../sway/tree/view.c:60
    #3 0x55571cee4090 in view_begin_destroy ../sway/tree/view.c:73
    #4 0x55571ce6dd95 in handle_destroy ../sway/desktop/xdg_shell.c:464
    #5 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #6 0x7f64009b059c in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:453
    #7 0x7f64009b0688 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:483
    #8 0x7f64009af08c in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #9 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)

previously allocated by thread T0 here:
    #0 0x7f6401532138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
    #1 0x55571ce6df39 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:485
    #2 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7f64009b0167 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:350
    #4 0x7f64009ce2a5 in surface_commit_pending ../types/wlr_surface.c:372
    #5 0x7f64009ce523 in surface_commit ../types/wlr_surface.c:444
    #6 0x7f63ff63ddad in ffi_call_unix64 (/usr/lib/x86_64-linux-gnu/libffi.so.6+0x5dad)

Fixes #3759
2019-02-23 03:03:03 -05:00
Brian Ashworth f078a1ccb8 input/cursor: allow whole-window bindings on ws
To match i3's behavior, this allows mouse bindings to be triggered over
a workspace when `--whole-window` is given.
2019-02-22 13:32:34 +01:00
Ian Fan 923cd865f5
Merge pull request #3740 from Emantor/fix/ipc_allocs
Fix small memory leaks reported in #3658
2019-02-22 08:20:26 +00:00
Brian Ashworth 7252ca09a7 move scratchpad: hide visible scratchpad container
This makes it so running `move [to] scratchpad` on a container already
in the scratchpad does not return an error. To match i3's behavior, a
visible scratchpad container will be hidden and a hidden scratchpad
container will be treated as a noop.
2019-02-22 08:13:51 +01:00
Rouven Czerwinski 16ddd00102 commands/move: reintroduce wrongly removed NULL check
Commit d3d7956576 removed this NULL check, which
leads to the following backtrace:

  #0  0x0000557bd201df46 in node_is_view (node=0x0) at ../sway/sway/tree/node.c:41
  #1  0x0000557bd1ff5d4e in seat_get_focus_inactive (seat=0x557bd3fc7580, node=0x0) at ../sway/sway/input/seat.c:968
          current = 0x557bd2033485
  #2  0x0000557bd2009f24 in cmd_move_container (argc=3, argv=0x557bd46b19c0) at ../sway/sway/commands/move.c:557
          new_output_last_focus = 0x0
          error = 0x0
          node = 0x557bd469f360
          workspace = 0x557bd4572ee0
          container = 0x557bd469f360
          no_auto_back_and_forth = false
          seat = 0x557bd3fc7580
          old_parent = 0x0
          old_ws = 0x557bd4572ee0
          old_output = 0x557bd411f740
          destination = 0x557bd46a0cc0
          new_output = 0x557bd411f740
          new_output_last_ws = 0x0
          focus = 0x557bd469f360
          __PRETTY_FUNCTION__ = "cmd_move_container"
          new_workspace = 0x557bd4572ee0
  […]

Reintroduce the NULL check to fix the bug.

Fixes #3746
2019-02-22 00:52:57 -05:00
Brian Ashworth d3d7956576 Handle NULL from output_get_active_workspace
This modifies the places where output_get_active_workspace is called to
handle a NULL result. Some places already handled it and did not need a
change, some just have guard off code blocks, others return errors, and
some have sway_asserts since the case should never happen. A lot of this
is probably just safety precautions since they probably will never be
called when `output_get_active_workspace` is not fully configured with a
workspace.
2019-02-21 21:18:03 +01:00
Brian Ashworth 03dfdb1edb output_get_active_workspace: check workspaces length
If an output's node was dirty and the transaction was committed before a
workspace was moved to or created for the output, the instruction would
have a bad value for `state->active_workspace` due to a missing
length check in `output_get_active_workspace`. If there was no focus on
the output, the first workspace was being returned. If the workspace
list was currently empty, the value was either garbage, or in the case of
an output being disabled and re-enabled, a workspace that may have been
previously freed. This just adds the length check to avoid returning out
of bounds value.
2019-02-21 08:06:35 -05:00
Rouven Czerwinski aa4ccd845c run_as_ipc_client: free response after running the IPC command
Fixes memory leaks in the form of:

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c799569f2 in ipc_recv_response ../common/ipc-client.c:94
    #2 0x563c79957062 in ipc_single_command ../common/ipc-client.c:138
    #3 0x563c798a56cc in run_as_ipc_client ../sway/main.c:127
    #4 0x563c798a6a3a in main ../sway/main.c:349
    #5 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:32:55 +01:00
Rouven Czerwinski a968a650e2 ipc-client: free payload after sending it over the socket
Fixes memory leaks in the form of:

Direct leak of 20 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c7995b36a in join_args ../common/stringop.c:268
    #2 0x563c798a6a1a in main ../sway/main.c:348
    #3 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:31:05 +01:00
Brian Ashworth 546b976baa output_evacuate: call workspace_consider_destroy
This calls `workspace_consider_destroy` on the workspace that was
visible on an output that a workspace was just evacuated to. This
prevents having hidden empty workspaces.
2019-02-20 20:17:45 +01:00
emersion 444e00662c
Add wp-primary-selection-unstable-v1 2019-02-20 11:16:05 +01:00
Eric Drechsel 9bbf10bdfc layout cmd: always operate on parent container, like i3Fixes #3724 2019-02-19 10:50:49 -05:00
emersion b799a30962 Don't use SOCK_CLOEXEC
Manually set the CLOEXEC flag instead, since SOCK_CLOEXEC isn't POSIX.
2019-02-19 16:34:07 +01:00
Drew DeVault c939453bea
Merge pull request #3714 from emersion/fix-drag-icon-map-listener
Fix drag icon map listener not removed
2019-02-18 15:29:07 -05:00
Yorick van Pelt fc397f52bb
Add 'visible' key to view json response 2019-02-18 13:57:16 +01:00
emersion 59f2056022
Fix drag icon map listener not removed 2019-02-18 13:19:58 +01:00
Drew DeVault a1e171080d
Merge pull request #3712 from RedSoxFan/fix-typo-seat-cursor
seat_cmd_cursor: fix typo in expected syntax
2019-02-18 05:18:46 +01:00
Brian Ashworth 041594d2ab Use container under cursor for mouse bindings
This matches i3's behavior of executing mouse bindings in regards to the
container under the cursor instead of what is focused.
2019-02-17 20:33:37 -05:00
Brian Ashworth 73c8e63438 seat_cmd_cursor: fix typo in expected syntax
This just fixes a typo in the expected syntax for seat_cmd_cursor
2019-02-17 20:16:23 -05:00
Brian Ashworth faf15ee733 workspace_next_name: fallback to next available number
This changes `workspace_next_name` to use the next available number as
the workspace name instead of the number of outputs. This fixes the case
where a number that is already in use could be returned. The workspace
numbers in use have no relation to the number of outputs so it makes
more sense to use the lowest available number
2019-02-17 19:15:19 +01:00
Drew DeVault 487c83f0de Add workspace {prev,next}_on_output --create
This creates the next workspace if you hit the end.
2019-02-17 11:50:07 -05:00
Drew DeVault cd10e755c1 Remove refs to unimplemented debuglog command
Closes #3695
2019-02-17 09:52:19 -05:00
emersion 7baaa3a0f8 Disconnect swaybg instead of killing it
This is much more reliable. This also fixes race conditions when killing swaybg
while it's doing a wl_display_roundtrip.
2019-02-16 19:11:22 -05:00
Brian Ashworth f7f5b172a0 sway-input.5: document wildcard and identifier troubleshooting
This documents the wildcard character for both inputs and seats. There
is also a tip added on trying the wildcard to verify a setting if the
identifier does not appear to be working.
2019-02-16 23:50:37 +01:00
emersion 8ab64d3fcc Remove unused header include/sway/tree/output.h 2019-02-16 17:40:56 -05:00
Brian Ashworth 272ca06171 Fix reload freeze when not modsetting current mode
This fixes the issue of the display freezing on reload with
wlroots#1545.

On master, all output configs are applied on reload. This may cause an
output to have its config applied up to three times, instead of just
once. The three cases are: output name, output identifier, and wildcard.
Not only is this inefficient, but it can cause swaybg to be spawned and
immediately killed.

However, swaybg requires two roundtrips of wl_display (to obtain needed
globals) before it enters its normal event loop. Modesetting will
roundtrip the wl_display. Without modesetting, waitpid for killing
swaybg could block infinitely due to swaybg being blocked by
wl_display_roundtrip.

This only configured an output once. It either uses the wildcard config
or creates an empty wildcard config and applies that. This also fixes a
bug where an output would not be reset when there is no output config to
apply to it.
2019-02-16 23:37:36 +01:00
Vincent Vanlaer cfacf85755 Check layout before getting pointer surface coords
This fixes issues of clients at the edge of the screen, like swaybar,
ignoring buttons.
2019-02-16 21:46:19 +01:00
Brian Ashworth 96de2b539c apply_output_config: dpms on before modeset
On the DRM backend, if an output is dpms'd off and a different output is
hotplugged, the CRTC for the output is reclaimed. When modesetting an
output without a CRTC, a CRTC will not be given to an output that is not
desired to be enabled. This splits setting the dpms state in
apply_output_config. If the output should be dpms on, the it is enabled
before attempting to modeset. Otherwise, it is dpms'd off after setting
everything else.

This also adds DPMS_ON to the default output configs.
2019-02-15 09:43:48 +01:00
Brian Ashworth e8c472aee9 seatop_move_tiling: do not move to descendant
In seatop_move_tiling, it is possible to cause a stack overflow by
dragging a container into one of its descendants. This disables the
ability to move into a descendant.
2019-02-14 14:07:13 +01:00
Brian Ashworth ab42874f71 seat: allow tree focus changes while layer focused
This allows the focused inactive tree node and visible workspaces to be
changed while a surface layer has focus. The layer temporarily loses
focus, the tree focus changes, and the layer gets refocused.
2019-02-14 11:01:08 +01:00
Brian Ashworth 9b8249c350 seatop_move_tiling: use tab/stack parent not self
When moving a descendant of a tabbed or stacked container, it is possible
for the target node to be the node being moved. This causes a segfault in
`handle_finish` since the node will be detached and then attempted to be
attached to it own parent, which is NULL due to the detach. In this
case, the target node should not be set to the node being moved, but the
parent of the node. This also allows for a descendant of a tabbed or
stacked container to be dragged out of the tabs/stacks and to be a
sibling of the tabbbed/stacked container, which was not previously
possible.
2019-02-13 14:32:47 -05:00
Brian Ashworth d168d65f2c subsurface_get_root_coords: break on NULL
It is possible for `wlr_surface_is_subsurface` to return true, but
`wlr_surface_from_wlr_surface` to be NULL. This adds a NULL check to the
value returned by `wlr_surface_from_wlr_surface` and breaks out of the
while loop in `subsurface_get_root_coords`.
2019-02-13 09:51:40 +01:00
Brian Ashworth 1bccde68a4 cursor: relative-pointer-v1 time is usec
In handle_cursor_motion, the timestamp passed to
`wlr_relative_pointer_manager_v1_send_relative_motion` should be
microseconds (not milliseconds) according to relative-pointer-v1 spec.
2019-02-13 09:49:34 +01:00
athrungithub 98b40d31c1 Don't remove from scratchpad on move to workspace
on move container window to another workspace,
not remove from scratchpad.
2019-02-12 23:47:10 -05:00
emersion 97c89b24b8
Rebase cursor when a layer surface maps
Also removes an extraneous arrange_outputs call, it's already called if
necessary in arrange_layers.

Updates https://github.com/swaywm/sway/issues/3080
2019-02-12 22:57:23 +01:00
Brian Ashworth fb4f29289f workspace_get_initial_output: handle focused layer
When a layer surface is focused, `seat_get_focused_workspace` will be
NULL. This changes `workspace_get_initial_output` to use output of the
focus inactive. If the focus inactive is also NULL, then either the
first output or the noop output will be used as fallbacks.
2019-02-11 10:13:16 +01:00
Brian Ashworth 2540e8ea79 Abort early when XDG_RUNTIME_DIR is not set
This aborts sway and displays an error message about XDG_RUNTIME_DIR
not being set without initializing the wl_display or logging any other
information.
2019-02-11 10:11:41 +01:00
Brian Ashworth d2c896ed84 fix misc memory leaks
This fixes a few misc memory leaks reported by asan:
- Items of `config->config_chain` are now freed instead of just the list
itself
- `bar->swaybar_command` is now freed
- The result returned by a seat subcommand is now returned instead of
leaked
2019-02-11 10:10:48 +01:00
Brian Ashworth a64a3ee6bb ipc: handle unnamed xkb_active_layout_name
If the active xkb_layout does not have a name, use `NULL` instead of
`json_object_new_string(NULL)`. This also makes it so swaymsg will pretty
print this as `(unnamed)`.
2019-02-11 01:07:11 +01:00
Brian Ashworth 418c19fe52 view: remove pointer constraints on unmap
If the view has any pointer constraints, ensure they are removed
before the view is unmapped and the surface is no longer tied to the
view.
2019-02-10 21:29:45 +01:00
Brian Ashworth 3952d4f4f3 input/keyboard: respect solo repeat_{rate,delay}
If `repeat_rate` or `repeat_delay` is set without the other being set,
the default was being used for both. This changes the logic to respect
the value given and use the default for the other when only one is set.
2019-02-10 18:45:02 +01:00
Rouven Czerwinski 605e515a93 fix double free for mode toggle if bar was invisible
If the bar was set to "invisible" and subsequently "toggle" was send twice, the
new mode was never set and the bar->mode was double freed.
Fix this by not requiring the bar->mode to be "hide" and instead show it
unconditionally, because it was either hidden or invisible.

Fixes #3637
2019-02-10 17:13:11 +01:00
Brian Ashworth 995b6edab6 container_at_stacked: skip titles when zero pixels
It is possible to make the title bars have a zero pixel height while
stacked, by using a blank font and no padding. This causes a division by
zero when attempting to calculate the child index in
container_at_stacked, which then results in a segfault when attempting
to access the child at that bad index (INT_MIN). This just skips the
check to see if the cursor is over a title bar of a child of a stacked
container when the title bar height is zero since there will be no title
bars.
2019-02-09 09:24:43 +01:00
Brian Ashworth f5190d1f79 bar_cmd_modifier: add support for none
sway-bar(5) documents `modifier none`, which comes from i3. This
implements the functionality for `modifier none` since it was not
previously implemented. The bar modifier toggles visibility of the bar
when the bar mode is set to hide. When the bar modifier is set to
`none`, the ability to toggle visibility of the bar will be disabled.
2019-02-08 16:02:45 +01:00
Drew DeVault 82d7a70b03 Revert "Return false if config could not be loaded."
This reverts commit 855368b67e.
2019-02-07 21:22:53 -05:00
Drew DeVault 385cf330ae Revert "Restore CWD if returning early."
This reverts commit 921e42c6c0.
2019-02-07 21:22:53 -05:00
Brian Ashworth ec5da0ca5b seat_configure_tablet_tool: configure xcursor
Since a tablet tool provides the WL_SEAT_CAPABILITY_POINTER capability,
sway will attempt to use the xcursor manager to set a cursor image. If
the tablet tool was the first (and possibly only) device to provide the
capability for the seat, the xcursor manager was not being configured
before attempting to set a cursor image. This was due to
`seat_configure_xcursor` only being called in `seat_configure_pointer`.
Since the xcursor manager was NULL in this case, it would cause a
segfault when attempting to set a cursor image. This adds a call to
`seat_configure_xcursor` in `seat_configure_tablet_tool` to ensure that
the seat has a xcursor manager.
2019-02-07 09:41:58 +01:00
Brian Ashworth 5a32a74b2d load_main_config: use given path, store realpath
Since `load_include_config` compares against the realpath of a config
file when checking if a config has already been added, the main config's
realpath has to be added to the config_chain.

However, includes from the main config should be processed relative to
the path given to allow for symbolic links. This stores the realpath in
`config->config_chain`, but uses the given path for all other
operations.
2019-02-07 09:41:05 +01:00
Brian Ashworth ee56428b64 Clarify error for options and positional args
When both options and positional arguments are given, sway would print
the error `Don't use options with the IPC client`. Over the past
several months, it seems like users are including this error message in
issues instead of a debug log due to not understanding that the error
message means there is an issue with their command.

This makes the error message more verbose and will hopefully make it so
more users understand that the message is not a bug in sway, but with
the command used.
2019-02-06 19:38:25 +01:00
Connor E 921e42c6c0 Restore CWD if returning early. 2019-02-06 18:23:20 +01:00
Connor E 855368b67e Return false if config could not be loaded. 2019-02-06 18:23:20 +01:00
Daniel Eklöf d3b3eb019a ipc_has_event_listeners: fix inverted check of subscribed_events
subscribed_events is a bit mask, with each *set* bit representing an
event the client has subscribed to.
2019-02-06 15:16:48 +01:00
Brian Ashworth c65057ef8b load_main_config: add realpath to config_chain
Since `load_include_config` compares against the realpath of a config
file when checking if a config has already been added, the main config's
realpath has to be added to the config_chain.
2019-02-06 09:36:33 +01:00
emersion 9b1905acf9 Fix close_popups for xdg-shell
wlr_xdg_popup_destroy will destroy popups, so we need to walk the tree
carefully. It's enough to just destroy all direct children, since destroying
the parent will also destroy all children.
2019-02-05 22:31:05 -05:00
Brian Ashworth 89afb761ba output_cmd_background: fix no file + valid mode
If output_cmd_background is given a valid mode as the first argument,
then there is no file given and an error should be returned.

join_args should not be called with an argc of zero since it sets the
last character to the null terminator. With an argc of zero, the length
is zero causing a heap buffer overflow when setting the byte before the
start of argv to '\0'. This probably will not ever generate a segfault,
but may cause data corruption to whatever is directly before it in
memory. To make other such cases easier to detect, this also adds a
sway_assert in join_args when argc is zero.
2019-02-05 14:13:27 -05:00
Connor E e1b8190d2c Initialize server so input manager is available. 2019-02-05 15:39:22 +00:00
Connor E 886789c197 If validating the config, do it as early as possible. 2019-02-05 14:37:22 +00:00
Drew DeVault fb73f84d0e
Merge pull request #3579 from RedSoxFan/fix-workspace-gaps-double-free
cmd_workspace_gaps: fix double free on bad amount
2019-02-05 14:41:52 +01:00
Brian Ashworth f2abe0570f cmd_workspace_gaps: fix double free on bad amount
This fixes a double free in cmd_workspace_gaps when the amount given is
invalid. The end pointer from strtol is part of the argument and should
not be freed. Freeing the end pointer could result in a double free or
bad free depending on whether or not the end pointer was at the start of
the argument
2019-02-05 08:35:00 -05:00
Brian Ashworth 288e35f99e IPC_COMMAND: split on newline
This splits commands given in IPC_COMMAND on newline to match i3's
behavior.
2019-02-05 07:39:21 -05:00
emersion 478b128c26 Fix quote stripping
Let's not use !strcmp(…) anymore.
2019-02-05 07:15:25 -05:00
Brian Ashworth 1e65cc1ea6 execute_command: dont strip quotes for exec_always
This removes quote stripping for `exec_always` in `execute_command`.
Since `exec_always` commands will be deferred in the config and
processed by `execute_command`, the quotes need to be left intact
like they are for `exec`.
2019-02-05 09:37:31 +01:00
Brian Ashworth 920c64f569 load_include_configs: fix wordexp fail condition
This fixes the failure condition for the wordexp call in
load_include_configs. The only success value is zero. Since the error
codes are positive, having the check be less than zero was causing
segfaults on failure when accessing the words.
2019-02-05 09:33:45 +01:00
Drew DeVault a1a99421a1
Merge pull request #3562 from vilhalmer/focus_follows_mouse-workspace-last-inactive
Focus workspace inactive node with focus_follows_mouse
2019-02-03 20:15:21 +01:00
Brian Ashworth 7299b9a6ca seat_cmd_cursor: do not create non-existing seat
If a seat does not exist in seat_cmd_cursor, do not create it. A seat
without any attachments is useless since it will have no capabilities.

This changes `input_manager_get_seat` to have an additional argument
that dictates whether or not to create the seat if it does not exist.
2019-02-03 14:01:29 -05:00
vilhalmer f8a9117149
Fall back to wildcard in sway_cursor_constrain 2019-02-03 13:46:44 -05:00
vilhalmer 907595b10d
Skip constraining cursor if no seat config 2019-02-03 13:44:37 -05:00
vilhalmer da59ffa8a0
Skip wildcard seat config in destroy_removed_seats 2019-02-03 13:41:35 -05:00
vilhalmer a3332c70bf
Focus ws inactive node with focus_follows_mouse 2019-02-03 12:12:40 -05:00
Drew DeVault bbfe13a248
Merge pull request #3551 from c-edw/RevertDoubleFrees
Revert double frees.
2019-02-03 09:55:54 +01:00
Brian Ashworth f425e81fbe cmd_seat: allow - to be used as alias for current
This allows for `-` (hyphen) to be used as an alias for the current seat
while sway is running. This alias was chosen since it is unlikely to
interfere with any desirable seat identifier
2019-02-02 22:02:28 -05:00
Brian Ashworth 1bd7400c4d seat_cmd_attach: defer while reading
Since the seats and inputs are not yet available while the config is
being read, defer seat attachment requests
2019-02-03 00:23:28 +01:00
Connor E 2f2a887377 Revert "More frees."
This reverts commit eda1bf769f.
2019-02-01 11:52:37 +00:00
Connor E 49b667272b Revert "Add some missing frees."
This reverts commit b5d95f264d.
2019-02-01 11:51:03 +00:00
Drew DeVault de76c4e071
Merge pull request #3543 from emersion/relative-pointer-usec
relative-pointer-v1: time is in usec, not msec
2019-02-01 09:27:00 +01:00
Brian Ashworth ebe5399ed6 pointer_constraint: change to a seat subcommand
This changes the `pointer_constraint` command to be a subcommand of seat
to allow for per-seat settings. The current implementation that is not a
seat subcommand will only operate on the current seat and will segfault
in the config due to `config->handler_context.seat` only being set at
runtime.

This also allows for the wildcard identifier to be used to alter the
pointer constraint settings on all seats and allows for the setting to
be merged with the rest of the seat config.
2019-01-31 22:58:52 -05:00
Drew DeVault 82461c4165 Updates for scdoc 1.8.1 2019-01-31 08:42:29 -05:00
Ashkan Kiani aee9942145 Add details on --whole-window for bindsym
Updates sway.5 to include information on the usage of the `--whole-window` option in the context of the `bindsym` command, which modifies mouse bindings to allow them to operate over the whole window instead of just the titlebar. Also includes the disclaimer about mouse bindings only working over the title bar.

Also fixes the escaping of the `BTN_LEFT` and `BTN_RIGHT` key mention.
Add notes on --border and --exclude-titlebar

Update the flags for bindcode command.
2019-01-30 22:55:22 +01:00
emersion dde9fc19de
relative-pointer-v1: time is in usec, not msec 2019-01-30 21:30:44 +01:00
Drew DeVault 0c975af1fb Send pointer frames on tool events 2019-01-30 14:09:50 -05:00
Drew DeVault 4b87edeba4 Missed a spot in pointer constraints 2019-01-30 14:06:44 -05:00
Drew DeVault a6d41254c9 Add pointer_constraint command 2019-01-30 19:53:59 +01:00
absrd ee4b8a3938 Add relative pointer 2019-01-30 19:53:59 +01:00
Las cedde21c96 Implement pointer-constraints-unstable-v1 2019-01-30 19:53:59 +01:00
athrungithub 5cb3d4769c criteria & scratchpad verify if show in another workspace (#3522)
check if scratchpad is show in another workspace
2019-01-30 09:05:46 -05:00
Brian Ashworth f0fd6119cf Cleanup config reading failure error logs
This cleans up the log when sway fails to read a config file. The
following changes have been made:
- A missing error message has been added to the log when the config file
is a directory instead of a regular file
- In main, `goto` statements have been added after the `sway_terminate`
calls instead of wrapping every block in `if (!terminate_request)`
- Unnecessary NULL-checks around calls to free in `main` have been
removed
- Deferred command execution has been extracted to a separate function
and the `Running deferred commands` log message will not be shown when
there are no deferred commands.
2019-01-29 13:18:53 -05:00
Peter Grayson f49ad5977e Document cursor moving between adjacent outputs
Add a sentence to sway-output.5.scd to highlight that the cursor can
only be moved between immediately adjacent outputs.

References issue #3529

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2019-01-28 21:36:48 -05:00
Ryan Dwyer 8995694a2f Remove bad assertion in container_handle_fullscreen_reparent
The assertion could trigger when called from workspace_wrap_children.
2019-01-29 08:05:55 +10:00
emersion 7c72327ab5
Cleanup log_env
SWAY_CURSOR_* are not used anymore. LD_PRELOAD_PATH doesn't exist and has been
replaced with LD_PRELOAD.
2019-01-28 21:59:10 +01:00
mwenzkowski 7c27d73b02 Check xdg_surface's role before using its toplevel
Don't access xdg_surface->toplevel if xdg_surface->role is equal to
WLR_XDG_SURFACE_ROLE_NONE, since this could lead to crash. The same
checks are added for xdg_surface_v6.

Fixes #3311
2019-01-28 16:14:35 +01:00
Ryan Dwyer 6b8bf10941 Introduce container_is_scratchpad_hidden
Just a convenience function that improves readability of the code.

Other things worth noting:

* container_get_siblings and container_sibling_index no longer use the
const keyword
* container_handle_fullscreen_reparent is only ever called after
attaching the container to a workspace, so its con->workspace check has
been changed to an assertion
2019-01-28 10:35:40 +01:00
Ryan Dwyer 0a9ff774ad Center surface inside container when it's too small
The goal here is to center fullscreen views when they are both too small
for the output and refuse to resize to the output's dimensions. It has
the side effect of also centering the view when it's too small for its
container.

Example clients that have this behaviour are emersion's hello-wayland
and weston.

It works by introducing surface_{x,y,width,height} properties to the
container struct. The x and y represent layout-local coordinates where
the surface will be rendered. The width and height are only used to
track the surface's previous dimensions so we can detect when the client
has resized it and recenter and apply damage accordingly.

The new surface properties are calculated when a transaction is applied,
as well as when a view resizes itself unexpectedly. The latter is done
in view_update_size. This function was previously restricted to views
which are floating, but can now be called for any views.

For views which refuse to resize *smaller* than a particular size, such
as gnome-calculator, the surface is still anchored to the top left as
per the current behaviour.
2019-01-28 01:17:21 -05:00
Drew DeVault 783fadab28
Merge pull request #3423 from RyanDwyer/fullscreen-global
Implement fullscreen global
2019-01-27 18:06:50 -05:00
Drew DeVault 897250c65f
Merge pull request #3519 from emersion/pointer-frame
Update for swaywm/wlroots#1503
2019-01-27 11:44:09 -05:00
Drew DeVault cd22d555e8 Remove unnecessary underscores in man pages 2019-01-27 11:27:48 -05:00
emersion a452f8f822
Update for swaywm/wlroots#1503 2019-01-27 12:59:46 +01:00
Ryan Dwyer 20aa8ee67d Implement fullscreen global 2019-01-25 08:29:21 +10:00
Ian Fan 5d6f906bd7 Use sway_log_errno instead of strerror 2019-01-24 11:33:54 +00:00
emersion 75406bb93b Update for swaywm/wlroots#1402 2019-01-24 11:48:19 +01:00
Jan Beich ba96983bf0 Make json-c include respect pkg-config --cflags
json-c.pc contains `Cflags: -I${includedir}/json-c`, so `<json-c/json.h>`
won't be found unless the parent directory is searched by default.
2019-01-23 21:50:06 -05:00
M Stoeckl 0af5b26e41 Fix dead stores found by scan-build
In addition to removing unused code, two minor problems are fixed:
 (1) `resize set` and `resize adjust` did not error when given
too many arguments.
 (2) `orientation` was incorrectly overridden to be 'U' for
scroll events in the swaybar tray `handle_click` function.
2019-01-22 10:12:04 -05:00
Drew DeVault 71a37ad186
Merge pull request #3494 from ianyfan/commands
i3 command behaviour compatibility fixes
2019-01-22 07:55:31 -05:00
Brian Ashworth 8ce57f0a77 root_scratchpad_remove_container: do not show
This removes the call to `root_scratchpad_show` from
`root_scratchpad_remove_container` and places it in the
`cmd_move_container`. This also moved the IPC `window::move` event to
`cmd_scratchpad`.
2019-01-22 13:13:34 +01:00
Ian Fan de9a357de8 util.c: remove numlen function
Its uses have been replaced by snprintf, which is more in line with its usage.
2019-01-22 13:10:25 +01:00
Ian Fan ec0013b9f5 commands: allow setting floating on scratchpad containers 2019-01-22 11:47:48 +00:00
Ian Fan 34dea3d9d2 commands: allow tiled containers to be stickied
This also stops stickied containers from losing its sticky status when
it is tiled, allowing it to be immediately stickied when floated again.
2019-01-22 11:47:48 +00:00
Ryan Dwyer 42f8a038c9 Remove assumption that noop output will be called NOOP-1 2019-01-22 09:55:13 +01:00
Ryan Dwyer 7f8ea60e71 Don't allow noop output to be configured 2019-01-22 09:55:13 +01:00
Ryan Dwyer e815e48cee Hide noop output in IPC 2019-01-22 09:55:13 +01:00
Ryan Dwyer 75e7ce82f5 Prevent noop output from being enabled 2019-01-22 09:55:13 +01:00
Ryan Dwyer 2301349ad5 Use noop output when there's no outputs connected
Instead of having NULL workspace->output pointers, use a noop output.
This should be safer.
2019-01-22 09:55:13 +01:00
Brian Ashworth ab0248a545 seat_create: set initial focus for added seats
This sets the initial focus for all seats other than the first seat,
which gets it focus on launch. The ensures that all seats have something
focused.
2019-01-22 09:33:58 +01:00
M Stoeckl d7ff776552 Move sway-specific functions in common/util.c into sway/
Modifier handling functions were moved into sway/input/keyboard.c;
opposite_direction for enum wlr_direction into sway/tree/output.c;
and get_parent_pid into sway/tree/root.c .
2019-01-21 12:39:16 -05:00
Drew DeVault cddb057343
Merge pull request #3480 from RedSoxFan/input-modes-improved-toggle
input_cmd_events: allow toggle modes to be listed
2019-01-21 09:28:47 -05:00
emersion e134da3023
Fix one remaining wlr_log call 2019-01-21 13:02:03 +01:00
M Stoeckl 1211a81aad Replace wlr_log with sway_log
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.
2019-01-21 12:59:42 +01:00
Brian Ashworth 5c834d36e1 Log libinput_config_status errors
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.
2019-01-21 08:46:36 +01:00
Brian Ashworth 91c1f44956 input_cmd_events: allow toggle modes to be listed
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.
2019-01-21 02:13:01 -05:00
Drew DeVault a3d3504072
Merge pull request #3468 from emersion/fix-output-gain-crtc
Fix re-enabling outputs gaining a CRTC
2019-01-20 09:01:33 -05:00
Brian Ashworth afac6ced6e apply_output_config: remove output_i
output_i was used in apply_output_config when swaybar used wl_output
index numbers instead of xdg-output names. This is no longer needed.
2019-01-19 17:28:26 +01:00
emersion 0bf3252d8b
Fix re-enabling outputs gaining a CRTC
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.
2019-01-19 10:19:59 +01:00
emersion 2ae2d09c4c Prevent crashes in handle_transform and handle_scale too 2019-01-19 08:29:46 +01:00
emersion 3b7a7462a2 Fix crash in cursor_rebase with multiple screens
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
2019-01-19 08:29:46 +01:00
Drew DeVault 639b66b676
Merge pull request #3452 from emersion/meson-features
Use Meson feature options
2019-01-18 15:39:07 -05:00
emersion 6ff54d0640
Fix segfault in output_enable 2019-01-18 14:52:40 +01:00
Drew DeVault dd4a6586b2
Merge pull request #3457 from emersion/swaybg-no-escape
Don't escape swaybg arguments anymore
2019-01-18 08:23:48 -05:00
emersion a737d7ecc4
Better handle outputs without CRTC
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.
2019-01-18 10:09:10 +01:00
emersion dc1eac0cf1 output: remove output_add_listeners
Simplify the code by registering signals when outputs are created and removing
signals when they are destroyed.
2019-01-18 10:08:34 +01:00
emersion d803861504
Don't escape swaybg arguments anymore
swaybg used to be invoked with sh, which made escaping necessary. This is no
longer necessary.

Fixes https://github.com/swaywm/sway/issues/3456
2019-01-18 09:22:33 +01:00
emersion bb2f007ad3
meson: remove rpath options 2019-01-18 08:26:44 +01:00
emersion 08a5b304e4
Use Meson feature options 2019-01-17 18:26:24 +01:00
emersion fe3f4882ed
Don't use sh when spawning swaybg 2019-01-17 11:20:08 +01:00
emersion 000b313985
swaybg: use output names instead of output indexes 2019-01-17 11:13:10 +01:00
Connor E de6f5b3453 Use static arrays where possible. 2019-01-16 13:02:26 +01:00
Connor E aa9d7d8ca1 Remove usage of VLAs. 2019-01-16 13:02:26 +01:00
Brian Ashworth 02bbefda20 bar_cmd_tray_bind: Use mouse button helpers
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`.
2019-01-16 11:12:45 +01:00
Brian Ashworth 247817f68c layer_shell: do not SIGABRT sway on zero outputs
If there are no outputs, do not SIGABRT when a layer surface is created,
just close the layer surface.
2019-01-16 10:55:25 +01:00
Brian Ashworth 81e595e6e8 cmd_resize: allow resizing hidden scratchpad by px
Allow resizing a hidden scratchpad container by px. Resizing a hidden
scratchpad container by ppt is still not allowed since there is no
workspace
2019-01-16 09:30:43 +01:00
Brian Ashworth 638b04b3e0 seatop_begin_down: raise floating
In `seatop_begin_down`, raise the floating container. This appears to
have been dropped in the transition to seatops.
2019-01-15 22:45:01 +01:00
Brian Ashworth 686b853047 Do not send ipc_event_shutdown from ipc client
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
2019-01-15 22:41:54 +01:00
Rouven Czerwinski f7309778a7 cursor: send clear_focus on hide and enter event on unhide
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
2019-01-15 14:06:48 -05:00
Connor E 023c92423e Remove wlr_xdg_surface_send_close. 2019-01-15 09:13:27 +01:00
Brian Ashworth a68bc5f449 Do not damage view child when container is NULL
In `view_child_damage`, do not damage the surface if it has been
unmapped or if the container is NULL.
2019-01-15 09:06:42 +01:00
Brian Ashworth 3087942c35 Handle hidden scratchpad containers in commands
This fixes the handling of hidden scratchpad containers for some
commands. For the most part, this just prevents running the commands on
hidden scratchpad containers, but there are some commands that have some
special handling for them.
2019-01-15 09:05:27 +01:00
Ryan Dwyer 289130430f Fix invalid pointers when using resize grow width on first/last siblings 2019-01-15 08:17:41 +10:00
Ryan Dwyer 2024f1da72 Resize only current and immediate siblings rather than all siblings
For example, create layout V[view view view] and resize the leftmost
view using mod+rightclick. Previously, the edge between view 2 and 3
would be adjusted as well. Now this edge will remain constant, which
matches the behaviour of i3.

To do this operation correctly, the resize tiling seatop now keeps track
of two containers, as the container that resizes horizontally will be a
different container to the one which resizes vertically (one will be an
ancestor). The tiling resize seatop now figures out these containers
during the start of the operation and keeps references to them in the
event. A new function container_find_resize_parent has been introduced
to do this. This function is also used by the resize command.

During cursor motion, the seatop logic is similar to before, but now has
to choose the correct container to resize.

In resize.c, container_resize_tiled and resize_tiled have been merged
into one. One of them originally did nothing except pass the values
through to the other.

container_resize_tiled now takes a simplified approach where it just
finds the immediate siblings on either side and resizes them without
worrying about the others. The parellel_coord and parallel_size
functions are no longer needed and have been removed.
2019-01-15 08:01:21 +10:00
Brian Ashworth 2573606b60 Disarm key repeat on reload
When resetting the keyboard during reload, disarm the key repeat on all
keyboards since the bindings (and possibly keyboard) will be freed before
the key repeat can go off.
2019-01-14 20:15:23 +01:00
M Stoeckl 2a684cad5f Remove now-unused "input" argument of cmd_results_new
Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))`
applied to `cmd_results_new`.

String usage constants have been converted from pointers to arrays when
encountered. General handler format strings were sometimes modified to
include the old input string, especially for unknown command errors.
2019-01-14 08:05:29 -05:00
M Stoeckl 6d392150a7 Remove 'input' field of IPC command return json
This field is not in i3 and provides imprecise and redundant information.
(Specifically, when swaymsg is given a list of commands, the IPC return
array already indicates precisely which number command failed; knowing
the name of the command is not useful when multiple commands of the
same type are provided.)
2019-01-14 07:58:02 -05:00
Ryan Dwyer b322432eff Use uint32_t where resize axis might contain a bitfield 2019-01-14 20:10:49 +10:00
Ryan Dwyer 22ac1c121a Replace resize_axis with wlr_edges
This patch removes the resize_axis enum in favour of wlr_edges. As
wlr_edges has no `horizontal` or `vertical` value, it denotes these by
bitwise `or`ing the left/right and up/down values. Two constants are
defined to make it easier to refer to these.

This will allow the tiling resize seatop to utilise the functions in
this file. resize_axis was local to the resize command and couldn't be
exposed in function arguments.
2019-01-14 19:05:48 +10:00
Drew DeVault 4879d40695
Merge pull request #3144 from emersion/cmd-xwayland
Add xwayland command
2019-01-13 20:42:39 -05:00
Drew DeVault 81bb675274
Merge pull request #3344 from RedSoxFan/bar-mouse-bindings-improved
Improve mouse button parsing: bar mouse bindings
2019-01-13 20:41:05 -05:00
Drew DeVault 9f9ef76175
Merge pull request #3343 from RedSoxFan/seat-cursor-buttons-improved
Improve mouse button parsing: seat cursor buttons
2019-01-13 20:40:42 -05:00
Drew DeVault db1631b67d
Merge pull request #3342 from RedSoxFan/scroll-buttons-improved
Improve mouse button parsing: input scroll_button
2019-01-13 20:40:00 -05:00
Drew DeVault 23ab56bbf7
Merge pull request #3402 from RyanDwyer/refactor-seatops
Refactor seat operations to use an interface
2019-01-13 20:38:34 -05:00
Drew DeVault 08569aab36
Merge pull request #3388 from RedSoxFan/reset-inputs-on-reload
reload: reset input configs
2019-01-13 20:37:05 -05:00
Drew DeVault fc93cd20dc
Merge pull request #3397 from RedSoxFan/fix-swaybar-height
swaybar: obey height if given
2019-01-13 20:36:08 -05:00
Drew DeVault 4eb0767414
Merge pull request #3398 from RedSoxFan/toggle-input-events
input events: toggle and ipc get_inputs
2019-01-13 20:35:45 -05:00
Drew DeVault 9ce4d53e78
Merge pull request #3408 from RedSoxFan/bar-padding
swaybar: adjustable status padding
2019-01-13 20:34:13 -05:00
Brian Ashworth b43345a1a3 config: fix line number with continued lines
When the config has continued lines, `get_line_with_cont` may read more
than one line of the actual file. When displaying line numbers for error
messages, they should be the line number in the file to make it easy to
find and fix the issue.
2019-01-11 20:41:38 -05:00
Brian Ashworth 39975ccfb5 config: do not reset pos when braces found
When a brace is found, the config file should not seek back to before
the brace, otherwise the brace will be read multiple times.
2019-01-11 20:02:20 -05:00
Brian Ashworth ca0a75d540 swaybar: add status_edge_padding command
This adds the bar subcommand `status_edge_padding <padding>` to set the
padding used when the status line is on the right edge of the bar.
2019-01-11 00:12:24 -05:00
Brian Ashworth c0f92cb2fb swaybar: add status_padding command
Adds the bar subcommand `status_padding <padding>` which allows setting
the padding used for swaybar. If `status_padding` is set to `0`, blocks
will be able to take up the full height of the bar.
2019-01-11 00:07:58 -05:00
Brian Ashworth 4e6bd53abf input_cmd_scroll_button: utilize mouse btn helpers
This modifies `input_cmd_scroll_button` to utilize the mouse button
helper `get_mouse_button` when parsing the button. x11 axis buttons are
not supported with this command and `CMD_INVALID` will be returned, but
all other x11 buttons, button event names, and button event codes should
be working
2019-01-10 12:45:52 -05:00
Brian Ashworth 3d6440ec26 bar_cmd_bind: utilize mouse button helpers
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing
mouse buttons. This also introduces `cmd_bar_bindcode`, which will use
`get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the
two commands are encapsulated in a single file with shared code.

This also modifies swaybar to operate off of event codes rather than x11
button numbers, which allows for any mouse button to be used.

This introduces two new IPC properties:
- For `get_bar_config`, `event_code` has been added to the `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`.
- Likewise for `click_events`, `event` has been added and will include
the event code for the button clicked. If the event code can be mapped
to a x11 button, `button` will still be the x11 button number.
Otherwise, `button` will be `0`.
2019-01-10 12:43:10 -05:00
Brian Ashworth aa1c838f97 seat_cmd_cursor: utilize mouse button helpers
This modifies `seat_cmd_cursor` to utilize `get_mouse_button` when
parsing mouse buttons for the `press` and `release` operations. All x11
buttons, button event names, and button event codes are supported.
For x11 axis buttons, `dispatch_cursor_axis` is used instead of
`dispatch_cursor_button`. However the `press`/`release` state is ignored
and the either axis event is processed. This also removes support for
`left` and `right` in favor of `BTN_LEFT` and `BTN_RIGHT`.
2019-01-10 11:47:34 -05:00
emersion 212baf2f75
Merge pull request #3400 from ianyfan/config-brace
config.c: fix brace detection at end of file
2019-01-10 13:29:21 +01:00
Ryan Dwyer ed5aafd90b Refactor seat operations to use an interface
This splits each seat operation (drag/move tiling/floating etc) into a
separate file and introduces a struct sway_seatop_impl to abstract the
operation.

The move_tiling_threshold operation has been merged into move_tiling.

The main logic for each operation is untouched aside from variable
renames.

The following previously-static functions have been made public:
* node_at_coords
* container_raise_floating
* render_rect
* premultiply_alpha
* scale_box
2019-01-10 22:04:42 +10:00
Ian Fan 00f8d0209f config.c: fix brace detection at end of file 2019-01-10 10:59:07 +00:00
Ian Fan 15ac580b28
Merge pull request #3341 from RedSoxFan/mouse-bindings-improved
Improve mouse button parsing: helpers and bind{code/sym}
2019-01-10 10:55:22 +00:00
emersion 9abac85888
Merge pull request #3399 from RedSoxFan/fix-output-destruction-segfaults
Fix segfaults on output destruction
2019-01-10 09:20:07 +01:00
Brian Ashworth 8fd3f32c79 Fix segfaults on output destruction
This fixes two causes of segfaulting when an output is destroyed.

The first occurred when an output was never enabled. The issue was that
the destroy signal was never initialized so when it was emitted, sway
segfaulted. This was fixed by moving the initialization into
`output_create` since all outputs, regardless of whether they have ever
been enabled, will be destroyed at some point.

The second occurred when the cursor was on an output that was being
destroyed. The sway output would have already been removed, but if there
are other outputs, a cursor rebase would still occur. Since the
wlr_output still existed and the sway output was destroyed, the cursor
could be over nothing, resulting in a segfault when trying to get the
sway output, which was destroyed.
2019-01-10 03:07:36 -05:00
Brian Ashworth 4dba42555f get_inputs: add libinput send events mode
Add `libinput_send_events` to the IPC output for `get_inputs` to allow
scripting of mode changes.
2019-01-09 23:17:27 -05:00
Brian Ashworth 55e1d599a2 input_cmd_events: implement toggle
Implements toggling input events during runtime. This will not attempt
to toggle to a mode that is not supported by the device.

When toggling the wildcard input, the device specific input configs are
altered. Each device will cycle one supported mode.
2019-01-09 23:17:27 -05:00
Brian Ashworth 124085eba9 swaybar: obey height if given
If there is a bar height given, use that as the height rather than as a
minimum height. This matches i3-gaps behavior.
2019-01-09 20:58:00 -05:00
Brian Ashworth a8b3ae9284 cursor: allow scrolling tabs/stack on title border
This allows tabbed and stacked containers to be scrolled through when
the cursor is over the border of the title bar. The borders around the
other three edges of the contents should not be affected by this change.
2019-01-09 18:15:15 -05:00
Brian Ashworth eefa6b1ad3 bind{code,sym}: utilize mouse button helpers
This modifies `bindcode` and `bindsym` to use `get_mouse_bindcode` and
`get_mouse_bindsym`, respectively, to parse mouse buttons. Additionally,
the `BINDING_MOUSE` type has been split into `BINDING_MOUSECODE` and
`BINDING_MOUSESYM` to match keys and allow for mouse bindcodes to be
used. Between the two commands, all button syms and codes should be
supported, including x11 axis buttons.
2019-01-09 11:29:04 -05:00
Brian Ashworth 6f6a9af60e Add helpers for improved mouse button parsing
The following helper functions have been added to aid with parsing mouse
buttons from a string:

1. `get_mouse_bindsym`: attempts to parse the string as an x11 button
(button[1-9]) or as an event name (ex BTN_LEFT or BTN_SIDE)
2. `get_mouse_bindcode`: attempts to parse the string as an event code
and validates that the event code is a button (starts with `BTN_`).
3. `get_mouse_button`: this is a conveniency function for callers that
do not care whether a bindsym or bindcode are used and attempts to parse
the string as a bindsym and then bindcode.

None of these functions are used in this commit. The sole purpose of
this commit is to make the larger set more granular and easier to
review/manipulate. There will be a series of commits following this one
that will modify any command which uses a mouse button to use these
helpers.
2019-01-09 11:29:04 -05:00
Brian Ashworth 4696f49ecc reload: reset input configs
This resets all input options to their defaults on reload. This also
fixes some debug log typos in `input_manager_libinput_config_pointer`.
2019-01-09 11:24:15 -05:00
Ryan Dwyer 14cab78612 Reset container dimensions when moving into workspace from direction 2019-01-09 11:22:23 -05:00
Jan Beich 0a4c4f3e52 Simplify evdev includes on FreeBSD by relying on up-to-date package
evdev-proto is installed by a dependency, so some files have been missed:

  In file included from ../sway/input/cursor.c:3:
  /usr/local/include/libevdev-1.0/libevdev/libevdev.h:30:10: fatal error: 'linux/input.h' file not found
  #include <linux/input.h>
	   ^~~~~~~~~~~~~~~
  ../swaybar/i3bar.c:3:10: fatal error: 'linux/input-event-codes.h' file not found
  #include <linux/input-event-codes.h>
	   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-01-09 11:02:05 +00:00
emersion d06782c5e7
Merge pull request #3386 from RedSoxFan/seat-reload-wait
reload: apply seat cfgs after reading entire cfg
2019-01-09 10:01:17 +01:00
emersion 8daea2bfec
Merge pull request #3390 from RedSoxFan/execute-seat
cmd_bind: pass the seat to execute_command
2019-01-09 09:59:09 +01:00
emersion 51bc466e2b
Merge pull request #3389 from RedSoxFan/swap-context-seat
cmd_swap: use handler context seat
2019-01-09 09:54:16 +01:00
Brian Ashworth fdc262d402 cmd_bind: pass the seat to execute_command
`seat_execute_command` was incorrectly setting
`config->handler_context.seat` before calling `execute_command`. Since
`execute_command` was being called with a `NULL` seat argument,
`execute_command` was setting `config->handler_context.seat` to the
default seat. This resulted in all bindings being executed on the
default seat and causing undesired behavior for devices on other seats.
2019-01-09 01:50:40 -05:00
Brian Ashworth c4122e3975 cmd_swap: use handler context seat
Use the handler context seat instead of the default seat
2019-01-09 01:37:46 -05:00
Brian Ashworth 1feb2ce064 keyboard: update repeat timer before execution
Since the keyboard can be destroyed by executing a binding (reloading
with a different seat attachment config), update the repeat timer before
executing the binding.
2019-01-09 01:07:29 -05:00
Brian Ashworth f33969358c reload: apply seat cfgs after reading entire cfg
Wait until all seat configs have been read before applying them on
reload. This prevents unnecessary attachment/detachment of input
devices and therefore creation/destruction of seat devices as
individual lines are read.
2019-01-09 01:06:21 -05:00
Drew DeVault da8f24de1d
Merge pull request #3385 from robertgzr/reset_output_mapping
cursor: allow mapping to all outputs
2019-01-08 20:36:56 -05:00