aboutsummaryrefslogtreecommitdiff
path: root/sway/input
AgeCommit message (Collapse)Author
2019-01-15Resize only current and immediate siblings rather than all siblingsRyan Dwyer
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-14Disarm key repeat on reloadBrian Ashworth
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-13Merge pull request #3343 from RedSoxFan/seat-cursor-buttons-improvedDrew DeVault
Improve mouse button parsing: seat cursor buttons
2019-01-13Merge pull request #3342 from RedSoxFan/scroll-buttons-improvedDrew DeVault
Improve mouse button parsing: input scroll_button
2019-01-13Merge pull request #3402 from RyanDwyer/refactor-seatopsDrew DeVault
Refactor seat operations to use an interface
2019-01-13Merge pull request #3388 from RedSoxFan/reset-inputs-on-reloadDrew DeVault
reload: reset input configs
2019-01-10input_cmd_scroll_button: utilize mouse btn helpersBrian Ashworth
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-10seat_cmd_cursor: utilize mouse button helpersBrian Ashworth
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-10Refactor seat operations to use an interfaceRyan Dwyer
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-10Merge pull request #3341 from RedSoxFan/mouse-bindings-improvedIan Fan
Improve mouse button parsing: helpers and bind{code/sym}
2019-01-10Merge pull request #3399 from RedSoxFan/fix-output-destruction-segfaultsemersion
Fix segfaults on output destruction
2019-01-10Fix segfaults on output destructionBrian Ashworth
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-09cursor: allow scrolling tabs/stack on title borderBrian Ashworth
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-09Add helpers for improved mouse button parsingBrian Ashworth
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-09reload: reset input configsBrian Ashworth
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-09Simplify evdev includes on FreeBSD by relying on up-to-date packageJan Beich
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-09keyboard: update repeat timer before executionBrian Ashworth
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-08Merge pull request #3385 from robertgzr/reset_output_mappingDrew DeVault
cursor: allow mapping to all outputs
2019-01-09cursor: allow mapping to all outputsRobert Günzler
Running `input "<input>" map_to_output *` resets the mapping to all outputs
2019-01-08Merge pull request #3275 from ianyfan/remove-readlineemersion
Rewrite strip_whitespace and remove readline.c
2019-01-07seat: unhide the cursor if it is warped to focusRouven Czerwinski
Unhide the cursor if container warping is enabled. Also set the image_surface to NULL during view_unmap, otherwise the cursor will try to access the surface which is currently being unmapped.
2019-01-07cursor: move unhide and timeout retrieval into separate functionsRouven Czerwinski
The unhide and timeout retrieval functions are needed in a later commit. No functional changes.
2019-01-03Apply tiling_drag_threshold to all containersDavid96
2019-01-02Implement tiling_drag_thresholdBrian Ashworth
Implements `tiling_drag_threshold <threshold>` to prevent accidental dragging of tiling containers. If a container (and all of its descendants) are unfocused and the tile bar is pressed, a threshold will be used before actually starting the drag. Once the threshold has been exceeded, the cursor will change to the grab icon and the operation will switch from `OP_MOVE_TILING_THRESHOLD` to `OP_MOVE_TILING`.
2019-01-01stringop.c: rewrite strip_whitespaceIan Fan
2018-12-31Apply implicit fallback seat configBrian Ashworth
The implicit fallback seat config needs to be applied (if created). Otherwise, the input devices will still be removed from the implicit default seat on reload when there is any seat config.
2018-12-30hide_cursor: change to a seat subcommandBrian Ashworth
This makes hide_cursor a seat subcommand, which allows for seat specific timeouts.
2018-12-30Verify seat fallback settings on reloadBrian Ashworth
This fixes an issue where on reload, all input devices that were added via an implicit fallback to the default seat would be removed from the default seat and applications would crash due to the seat having no capabilities. On reload, there is a query for a seat config with the fallback setting set (it can either be true or false). If no such seat config exists, the default seat is created (if needed) and has the implicit fallback true applied to its seat config. This is the same procedure that occurs when a new input is detected.
2018-12-29Revamp seat configsBrian Ashworth
This makes seat configs work like output and input configs do. This also adds support for wildcard seat configs. A seat config is still created in the main seat command handler, but instead of creating a new one in the subcommands and destroying the main seat command's instance, the seat subcommands modify the main one. The seat config is then stored, where it is merged appropriately. The seat config returned from `store_seat_config` is then applied. When attempting to apply a wildcard seat config, a seat specific config is queried for and if found, that is used. Otherwise, the wildcard config is applied directly. Additionally, instead of adding input devices to the default seat directly when there is no seat configs, a seat config for the default seat is created with only fallback set to true, which is more explicit. It also fixes an issue where running a seat command at runtime (with no seat config in the sway config), would result in all input devices being removed from the default seat and leaving sway in an unusable state. Also, instead of checking for any seat config, the search is for a seat config with a fallback option seat. This makes it so if there are only seat configs with fallback set to -1, the default seat is still created since there is no explicit notion on what to do regarding fallbacks. However, if there is even a single fallback 0, then the default seat is not used as a fallback. This will be needed for seat subcommands like hide_cursor where the user may only want to set that property without effecting anything else.
2018-12-29Remove button from state on release during opBrian Ashworth
This fixes a bug in `dispatch_cursor_button` where if there was an operation occurring, the button would not be removed from the state on release. This resulted in the button appearing to be permanently pressed and caused mouse bindings to not match correctly.
2018-12-25Split image_surface handling into own functionBrian Ashworth
2018-12-25Implement hide_cursor <timeout> commandBrian Ashworth
Allows the cursor to be hidden after a specified timeout in milliseconds
2018-12-25Change mouse buttons to x11 map and libevdev namesBrian Ashworth
This modifies the way mouse bindings are parsed. Instead of adding to BTN_LEFT, which results in button numbers that may not be expected, buttons will be parsed in one of the following ways: 1. `button[1-9]` will now map to their x11 equivalents. This is already the case for bar bindings. This adds support for binding to axis events, which was not possible in the previous approach. 2. Anything that starts with `BTN_` will be parsed as an event code name using `libevdev_event_code_from_name`. This allows for any button to be mapped to instead of limiting usage to the ones near BTN_LEFT. This also adds a dependency on libevdev, but since libevdev is already a dependency of libinput, this should be fine. If needed, this option can have dependency guards added. Binding changes: - button1: BTN_LEFT -> BTN_LEFT - button2: BTN_RIGHT -> BTN_MIDDLE - button3: BTN_MIDDLE -> BTN_RIGHT - button4: BTN_SIDE -> SWAY_SCROLL_UP - button5: BTN_EXTRA -> SWAY_SCROLL_DOWN - button6: BTN_FORWARD -> SWAY_SCROLL_LEFT - button7: BTN_BACK -> SWAY_SCROLL_RIGHT - button8: BTN_TASK -> BTN_SIDE - button9: BTN_JOYSTICK -> BTN_EXTRA Since the axis events need to be mapped to an event code, this uses the following mappings to avoid any conflicts: - SWAY_SCROLL_UP: KEY_MAX + 1 - SWAY_SCROLL_DOWN: KEY_MAX + 2 - SWAY_SCROLL_LEFT: KEY_MAX + 3 - SWAY_SCROLL_RIGHT: KEY_MAX + 4
2018-12-20Combine output_by_name and output_by_identifierBrian Ashworth
This combines `output_by_name` and `output_by_identifier` into a single function called `output_by_name_or_id`. This allows for output identifiers to be used in all commands, simplifies the logic of the callers, and is more efficient since worst case is a single pass through the output list.
2018-12-17Focus node before tiling drag if on titlebarBrian Ashworth
Before attempting to drag a tiling container by its titlebar, focus it. This fixes clicking on titlebars to focus a container.
2018-12-17Allow tiling views to be dragged by the titlebarBrian Ashworth
Enables titling views to be dragged by the titlebar. This is in addition to using the modifier and dragging them from anywhere on the container surface. Floating views already allow this behavior.
2018-12-16Update for swaywm/wlroots#1377Rostislav Pehlivanov
-Werror is eͫ̐ͭ҉vi͆ͦ̏ͦlͥ̀͒̊͂͛
2018-12-14Fix focusing on non-visible workspaceBrian Ashworth
My previous attempt was not quite right. Changing the focus stack on a non-visible workspace should only be blocked if the focus would be set to the workspace itself
2018-12-12Keep focus when destroying containers on nonvis wsBrian Ashworth
Changing the focus stack when destroying a container's node on a non-visible workspace (on an non-focused output) incorrectly causes the non-visible workspace to become visible. If the workspace is empty, it will not be destroyed since it is now visible. Additionally since there was no workspace::focus event, swaybar still shows the previous workspace as focus-inactive. It also makes no sense to change visible workspaces due to a container on a non-visible workspace being destroyed. Since the focus will either be set when switching to the non-visible workspace or the workspace will be destroyed due to being empty, there is no need to change the focus stack when destroying a container on a non-visible workspace.
2018-11-25Replace _XOPEN_SOURCE with _POSIX_C_SOURCEemersion
And make sure we don't define both in the same source file.
2018-11-18Add scroll factor config option.Spencer Michaels
2018-11-18Use #if instead of #ifdefemersion
2018-11-17Move view {x,y,width,height} into container structRyan Dwyer
This renames/moves the following properties: * sway_view.{x,y,width,height} -> sway_container.content_{x,y,width,height} * This is required to support placeholder containers as they don't have a view. * sway_container_state.view_{x,y,width,height} -> sway_container_state.content_{x,y,width,height} * To remain consistent with the above. * sway_container_state.con_{x,y,width,height} -> sway_container_state.{x,y,width,height} * The con prefix was there to give it contrast from the view properties, and is no longer useful. The function container_set_geometry_from_floating_view has also been renamed to container_set_geometry_from_content.
2018-11-15Fix segfault in dispatch_cursor_buttonemersion
2018-11-06Add focus_follows_mouse always. (#3081)Connor E
* Add focus_follows_mouse_mode. * Fail if focus_follows_mouse is invalid. * Fix indentation.
2018-11-04removed unneeded code fragmentmadblobfish
2018-11-03Merge pull request #3021 from Snaipe/singlekey-binding-triggerDrew DeVault
binding: match single-key bindings if no multi-key binding matched
2018-10-31Move view border properties to container structRyan Dwyer
This will be needed to implement layout saving and restoring, as we need to be able to configure borders on a placeholder container which has no view.
2018-10-29binding: match single-key bindings if no multi-key binding matchedFranklin "Snaipe" Mathieu
This makes bindings more snappy when the user is typing faster than his keycaps are releasing. Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
2018-10-28cursor: fix uninitialized pointer in cursor_rebasemwenzkowski