aboutsummaryrefslogtreecommitdiff
path: root/include/sway/input/cursor.h
AgeCommit message (Collapse)Author
2024-02-28Convert to new pointer enumsSimon Ser
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4575
2023-07-24Add support for cursor-shape-v1Simon Ser
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4106
2023-06-26input: Move wlr_pointer_gestures_v1 to sway_input_managerMark Bolhuis
On multi-seat configurations a zwp_pointer_gestures_v1 global was created for every seat. Instead, create the global once in the input manager, to be shared across all seats.
2023-05-04Add support for touch cancel eventshrdl
2023-02-20Implement seatop_touchStacy Harper
Atm we got issue with the touch position sent to the clients. While holding contact, leaving the initial container will continue to send motion event to the client but with the new local position from the new container. This seatop goal is to send the position of the touch event, relatively to the initial container layout position.
2023-01-07Improve tablet tool button handling.John Chadwick
This change allows the tablet tool button to be used for floating mod resize. In addition, it attempts to ensure that tablet tool events are consistent such that tablet v2 events and pointer events will never be interleaved, and such that the tool buttons count will never fall out of sync and cause tool button emulation to break. Some of this logic is similar to what is done for tablet tool tip, but not quite identical, because of the complication that we have to deal with multiple inputs that can overlap eachother. Fixes #7036.
2022-05-30sway: add bindgesture commandFlorian Franzen
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
2022-03-17sway/input: follow up wlroots input device events renamingSimon Zeni
2022-01-22input/cursor: pass through pointer hold gesturesTudor Brindus
This just follows swaywm/wlroots#3047, so `wl_pointer_gestures_v1` clients can be notified of these events.
2022-01-13Upgrade for wlroots surface refactoringSimon Ser
See [1] for details. [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3412
2021-07-26Fix wl_pointer.frame not sent on touch emulationSimon Ser
When emulating touch, the simulating_pointer_from_touch field is set to true. It's switched back to false when a touch_up event is received. However we need to ensure we always send a wl_pointer.frame event following a group of other wl_pointer events. Since a touch_frame event is always guaranteed to come after a group of touch events, unset simulating_pointer_from_touch in the touch_frame handler instead of the touch_up handler. Add a new field to know whether the touch_frame handler should stop emulation.
2021-07-08Add support for touch frame eventsSimon Ser
Update for the breaking change in [1]. [1]: https://github.com/swaywm/wlroots/pull/3001
2020-12-06input/cursor: unhide cursor on synthetic inputTudor Brindus
Fixes #5847.
2020-11-01commands/focus: force container warp when fulfilling `focus mode_toggle`Tudor Brindus
This commit switches focusing behavior to force a warp when executing `focus mode_toggle`. Fixes #5772.
2020-10-30hide_cursor: Add an option to hide when typingTamir Zahavi-Brunner
Add an option for the `hide_cursor` command to hide the cursor when typing, i.e. whenever a key is pressed.
2020-06-18input/pointer: don't trigger pointer bindings for emulated inputTudor Brindus
Prior to this commit, a tablet device could trigger mouse button down bindings if the pen was pressed on a surface that didn't bind tablet handlers -- but it wouldn't if the surface did bind tablet handlers. We should expose consistent behavior to users so that they don't have to care about emulated vs. non-emulated input, so stop triggering bindings for any non-pointer devices.
2020-06-18input/cursor: send idle events based off device type, not input typeTudor Brindus
Previously, a tablet or touch device could report activity as a pointer device if it went through pointer emulation. This commit refactors idle sources to be consistently reported based on the type of the device that generated an input event, and now how that input event is being processed.
2020-05-29input/cursor: rename `simulated_tool_tip_down` to be more accurateTudor Brindus
This is a tiny cleanup commit that renames `simulated_tool_tip_down` to `simulating_pointer_from_tool_tip`, making it match `simulating_pointer_from_touch`. This is a better name since it makes it clear that it's the *pointer* that's being simulated, not the tool tip.
2020-05-21input/pointer: only warp cursor when the confine region has changedTudor Brindus
Refs #5268.
2020-05-13Implement pointer simulation if client hasn't bound to touchDavid96
2020-05-02input/cursor: make cursor rebasing cursor type-agnosticTudor Brindus
This commit refactors `cursor_rebase` into `cursor_update_image`, and moves sending pointer events to the two existing call sites. This will enable this code to be reused for tablets. Refs #5232
2020-05-01input/cursor: release simulated tool tip button when over v2 surfaceTudor Brindus
d88460f addressed sending v2 tool tip up when over a non-v2 surface. This commit addresses the other direction. Fixes #5230.
2020-04-22input/cursor: fix hide cursor timeouts on tablets and touchscreensTudor Brindus
This commit refactors `cursor_handle_activity` to also take the idle source, so that it can be reused for tablet and touch activity. Previously, the timeouts would be tracked, but the cursor would never be un-hidden for anything but pointers. Fixes #5169.
2020-01-05input/cursor: handle image surface destroyBrian Ashworth
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.
2019-12-07input/cursor: pass gesture events to clientsBenjamin Cheng
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-09-25input: Add support for tablet protocol.John Chadwick
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-03-17Introduce default seatopRyan Dwyer
This introduces a `default` seat operation which is used when no mouse buttons are being held. This means there is now always a seat operation in progress. It allows us to separate `default` code from the standard cursor management code. The sway_seatop_impl struct has gained callbacks `axis`, `rebase` and `end`, and lost callbacks `finish` and `abort`. `axis` and `rebase` are only used by the default seatop. `end` is called when a seatop is being replaced by another one and allows the seatop to free any resources, though no seatop currently needs to do this. `finish` is no longer required, as each seatop can gracefully finish in their `button` callback. And `abort` is not needed, as calling `end` would achieve the same thing. The struct has also gained a bool named allow_set_cursor which allows the client to set a new cursor during `default` and `down` seatops. Seatops would previously store which button they were started with and stop when that button was released. This behaviour is changed so that it only ends once all buttons are released. So you can start a drag with $mod+left, then click and hold right, release left and it'll continue dragging while the right button is held. The motion callback now accepts dx and dy. Most seatops don't use this as they store the cursor position when the seatop is started and compare it with the current cursor position. This approach doesn't make sense for the default seatop though, hence why dx and dy are needed. The pressed_buttons array has been moved from the sway_cursor struct to the default seatop's data. This is only used for the default seatop to check bindings. The total pressed button count remains in the sway_cursor struct though, because all the other seatops check it to know if they should end. The `down` seatop no longer has a `moved` property. This was used to track if the cursor moved and to recheck focus_follows_mouse, but seems to work without it. The logic for focus_follows_mouse has been refactored. As part of this I've removed the call to wlr_seat_keyboard_has_grab as we don't appear to use keyboard grabs. The functions for handling relative motion, absolute motion and tool axis have been changed. Previously the handler functions were handle_cursor_motion, handle_cursor_motion_absolute and handle_tool_axis. The latter two both called cursor_motion_absolute. Both handle_cursor_motion and cursor_motion_absolute did very similar things. These are now simplified into three handlers and a single common function called cursor_motion. All three handlers call cursor_motion. As cursor_motion works with relative distances, the absolute and tool axis handlers convert them to relative first.
2019-02-12Rebase cursor when a layer surface mapsemersion
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-01-30Implement pointer-constraints-unstable-v1Las
2019-01-27Update for swaywm/wlroots#1503emersion
2019-01-16bar_cmd_tray_bind: Use mouse button helpersBrian Ashworth
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-13Merge pull request #3343 from RedSoxFan/seat-cursor-buttons-improvedDrew DeVault
Improve mouse button parsing: seat cursor buttons
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-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-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.
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-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-10-19Introduce cursor_rebaseRyan Dwyer
This function "rebases" the cursor on top of whatever is underneath it, without triggering any focus changes.
2018-10-18cmd_bind{sym,code}: Implement per-device bindingsBrian Ashworth
bindsym --input-device=<identifier> ... bindcode --input-device=<identifier> ...
2018-10-16cursor: functions to warp cursor to container and workspaceRouven Czerwinski
The new functions allow a cursor to be warped without changing the focus. This is a preparation commit to handle cursor warping not only in seat_set_focus_warp.
2018-10-03Fix focusing topmost floating windowsJonathan Buch
Re-focus on the container on which the cursor hovers over. A special case is, if there are menus or other subsurfaces open in the focused container. It will prefer the focused container as long as there are subsurfaces. This commit starts caching the previous node as well as the previous x/y cursor position. Re-calculating the previous focused node by looking at the current state of the cursor position does not work, if the environment changes.
2018-07-23Invoke mouse bindingsfrsfnrrg
The mouse binding logic is inspired/copied from the keyboard binding logic; we store a sorted list of the currently pressed buttons, and trigger a binding when the currently pressed (or just recently pressed, in the case of a release binding) buttons, as well as modifiers/container region, match those of a given binding. As the code to execute a binding is not very keyboard specific, keyboard_execute_command is renamed to seat_execute_command and moved to where the other binding handling functions are. The call to transaction_commit_dirty has been lifted out.
2018-07-22Prevent re-uploading the same cursor image multiple timesRyan Dwyer
2018-05-28Move previous cursor_position inline.Scott Leggett
2018-05-28Store previous position in sway_cursor.Scott Leggett
2018-05-27Focus containers only on entry.Scott Leggett
2018-05-20Fix border commands from changing focusBrian Ashworth