aboutsummaryrefslogtreecommitdiff
path: root/include/sway/input
AgeCommit message (Collapse)Author
2018-10-21Make workspace back_and_forth seat-specificRyan Dwyer
* When using multiple seats, each seat has its own prev_workspace_name for the purpose of workspace back_and_forth. * Removes prev_workspace_name global variable. * Removes unused next_name_map function in tree/workspace.c. * Fixes memory leak in seat_destroy (seat was not freed).
2018-10-20Minor refactor of input managerRyan Dwyer
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
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-19Fix logic used for mouse_warping outputRyan Dwyer
Turns out we don't need to store the previous focus, and it should be based on which output the cursor was in.
2018-10-19Merge pull request #2875 from RedSoxFan/input-device-bindingsDrew DeVault
cmd_bind{sym,code}: Implement per-device bindings
2018-10-19Consider cursor warp when switching workspacesRyan Dwyer
Fixes a regression introduced in 24a90e5d86441fc345356eb3767e5a6880dcedbd. consider_warp_to_focus has been renamed to seat_consider_warp_to_focus, moved to seat.c and made public. It is now called when switching workspaces via `workspace <ws>`.
2018-10-18cmd_bind{sym,code}: Implement per-device bindingsBrian Ashworth
bindsym --input-device=<identifier> ... bindcode --input-device=<identifier> ...
2018-10-18Remove cursor warping from seat_set_focusRyan Dwyer
Because cursor warping was the default behaviour in seat_set_focus, there may be cases where we may have been warping the cursor unintentionally. This patch removes cursor warping from seat_set_focus and only does it in the focus command. This is managed by a static function in focus.c. To know whether to warp or not, we need to know which node had focus previously. To keep track of this easily, seat->prev_focus has been introduced and is set to the previous in seat_set_focus.
2018-10-17Merge pull request #2820 from Emantor/fix-mouse-warping-containerDrew DeVault
Fix mouse warping container
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-16Prevent duplicate workspace::focus eventsRyan Dwyer
Previously we would compare the last focus's workspace with the new focus's workspace to determine if we need to emit an IPC workspace::focus event. This doesn't work when moving the focused container to a new workspace. This adds a workspace property to the seat which stores the last emitted workspace::focus workspace. Using this method, after moving the container, refocusing it will trigger exactly one workspace::focus event: from the old workspace to the new workspace.
2018-10-15Introduce seat_set_raw_focus and remove notify argument from seat_set_focus_warpRyan Dwyer
This introduces seat_set_raw_focus: a function that manipulates the focus stack without doing any other behaviour whatsoever. There are a few places where this is useful, such as where we set focus_inactive followed by another call to set the real focus again. With this change, the notify argument to seat_set_focus_warp is also removed as these cases now use the raw function instead. A bonus of this is we are no longer emitting window::focus IPC events when setting focus_inactive, nor are we sending focus/unfocus events to the surface. This also fixes the following: * When running `move workspace to output <name>` and moving the last workspace from the source output, the workspace::focus IPC event is no longer emitted for the newly created workspace. * When splitting the currently focused container, unfocus/focus events will not be sent to the surface when giving focus_inactive to the newly created parent, and window::focus events will not be emitted.
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-09-16Rename seat_get_active_child to seat_get_active_tiling_childRyan Dwyer
Also renames container to con in one function to prevent ugly line wrapping.
2018-09-14Update for swaywm/wlroots#1243emersion
2018-09-11Implement tiling dragRyan Dwyer
Hold floating_modifier and drag a tiling view to a new location.
2018-09-11Rename OP_MOVE to OP_MOVE_FLOATINGRyan Dwyer
In preparation for introducing OP_MOVE_TILING.
2018-09-06Introduce seat_set_focus_container and seat_set_focus_workspaceRyan Dwyer
These are the same as seat_set_focus, but accept a specific type rather than using nodes. Doing this adds more typesafety and lets us avoid using &con->node which looks a little ugly. This fixes a crash that pretty much nobody would ever come across. If you have a bindsym for "focus" with no arguments and run it from an empty workspace, sway would crash because it assumes `container` is not NULL.
2018-09-05Implement type safe arguments and demote sway_containerRyan Dwyer
This commit changes the meaning of sway_container so that it only refers to layout containers and view containers. Workspaces, outputs and the root are no longer known as containers. Instead, root, outputs, workspaces and containers are all a type of node, and containers come in two types: layout containers and view containers. In addition to the above, this implements type safe variables. This means we use specific types such as sway_output and sway_workspace instead of generic containers or nodes. However, it's worth noting that in a few places places (eg. seat focus and transactions) referring to them in a generic way is unavoidable which is why we still use nodes in some places. If you want a TL;DR, look at node.h, as well as the struct definitions for root, output, workspace and container. Note that sway_output now contains a workspaces list, and workspaces now contain a tiling and floating list, and containers now contain a pointer back to the workspace. There are now functions for seat_get_focused_workspace and seat_get_focused_container. The latter will return NULL if a workspace itself is focused. Most other seat functions like seat_get_focus and seat_set_focus now accept and return nodes. In the config->handler_context struct, current_container has been replaced with three pointers: node, container and workspace. node is the same as what current_container was, while workspace is the workspace that the node resides on and container is the actual container, which may be NULL if a workspace itself is focused. The global root_container variable has been replaced with one simply called root, which is a pointer to the sway_root instance. The way outputs are created, enabled, disabled and destroyed has changed. Previously we'd wrap the sway_output in a container when it is enabled, but as we don't have containers any more it needs a different approach. The output_create and output_destroy functions previously created/destroyed the container, but now they create/destroy the sway_output. There is a new function output_disable to disable an output without destroying it. Containers have a new view property. If this is populated then the container is a view container, otherwise it's a layout container. Like before, this property is immutable for the life of the container. Containers have both a `sway_container *parent` and `sway_workspace *workspace`. As we use specific types now, parent cannot point to a workspace so it'll be NULL for containers which are direct children of the workspace. The workspace property is set for all containers, except those which are hidden in the scratchpad as they have no workspace. In some cases we need to refer to workspaces in a container-like way. For example, workspaces have layout and children, but when using specific types this makes it difficult. Likewise, it's difficult for a container to get its parent's layout when the parent could be another container or a workspace. To make it easier, some helper functions have been created: container_parent_layout and container_get_siblings. container_remove_child has been renamed to container_detach and container_replace_child has been renamed to container_replace. `container_handle_fullscreen_reparent(con, old_parent)` has had the old_parent removed. We now unfullscreen the workspace when detaching the container, so this function is simplified and only needs one argument now. container_notify_subtree_changed has been renamed to container_update_representation. This is more descriptive of its purpose. I also wanted to be able to call it with whatever container was changed rather than the container's parent, which makes bubbling up to the workspace easier. There are now state structs per node thing. ie. sway_output_state, sway_workspace_state and sway_container_state. The focus, move and layout commands have been completely refactored to work with the specific types. I considered making these a separate PR, but I'd be backporting my changes only to replace them again, and it's easier just to test everything at once.
2018-08-18Don't send motion if the cursor hasn't movedRyan Dwyer
Prevents GTK+ comboboxes from immediately closing.
2018-08-18Rename mousedown to down and make seat operation a named enumRyan Dwyer
2018-08-18Implement mousedown operationRyan Dwyer
This allows you to move the cursor off the surface while dragging its scrollbar.
2018-08-17Refactor seat_get_focus functionsRyan Dwyer
Fixes #2467. This commit introduces seat_get_focus_inactive_floating to supplement seat_get_focus_inactive_tiling, and uses it during `focus mode_toggle` which fixes a focus bug. This also refactors the seat_get_focus_inactive functions so that they do their selection logic themselves rather than offloading it to seat_get_focus_by_type which was getting bloated. seat_get_focus_by_type is now removed. Lastly, this commit changes seat_get_focus to just return the first container in the focus stack rather than looping and calling seat_get_focus_by_type.
2018-08-12Implement resizing tiled containers via cursorRyan Dwyer
* The OP_RESIZE seat operation has been renamed to OP_RESIZE_FLOATING, and OP_RESIZE_TILING has been introduced. * Similar to the above, seat_begin_resize and handle_resize_motion have been renamed and tiling variants introduced. * resize.c's resize_tiled has to be used, so container_resize_tiled has been introduced in resize.c to allow external code to call it.
2018-08-01ipc: prevent emitting a workspace::focus event when moving a container to a ↵Ian Fan
different workspace or output When a container is moved from, say, workspace 1 to workspace 2, workspace 2 is focused in order to arrange the windows before focus is moved back to workspace 1, which caused a workspace:focus event from workspace 2 to workspace 1 to be emitted. This commit inhibits that event.
2018-07-29Bindings use advised keyboard repeat parametersfrsfnrrg
Now 'repeat_delay' and 'repeat_rate' control the initial delay and rate (per second) of repeated binding invocations. If the repeat delay is zero, binding repetition is disabled. When the repeat rate is zero, the binding is repeated exactly once, assuming no other key events intervene.
2018-07-29Implement key repeat for pressed key bindingsfrsfnrrg
Each sway_keyboard is provided with a wayland timer event source. When a valid keypress binding has been found, a callback to handle_keyboard_repeat is set. Any key event will either clear the callback or (if the new key event is a valid keypress binding) delay the callback again.
2018-07-28Add virtual keyboard protocolDrew DeVault
Ref #2373
2018-07-28When unfloating, return container to previously focused tiled containerRyan Dwyer
This introduces seat_get_focus_inactive_tiling and updates `focus mode_toggle` to use it instead, because the previous method wasn't guaranteed to return a tiling view.
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-22Store last button and use it when views request to move or resizeRyan Dwyer
2018-07-22Prevent re-uploading the same cursor image multiple timesRyan Dwyer
2018-07-22Replace static handle_end_operation with seat_end_mouse_operationRyan Dwyer
2018-07-22Implement xdg shell request_move and request_resize eventsRyan Dwyer
Also does a few other related things: * Now uses enum wlr_edges instead of our own enum resize_edge * Now uses wlr_xcursor_get_resize_name and removes our own find_resize_edge_name * Renames drag to move for consistency
2018-07-22Implement floating_modifier and mouse operations for floating viewsRyan Dwyer
This implements the following: * `floating_modifier` configuration directive * Drag a floating window by its title bar * Hold mod + drag a floating window from anywhere * Resize a floating view by dragging the border * Resize a floating view by holding mod and right clicking anywhere on the view * Resize a floating view and keep aspect ratio by holding shift while resizing using either method * Mouse cursor turns into resize when hovering floating border or corner
2018-07-18Don't unfocus when an override redirect window is mappedemersion
2018-07-15Make focus part of transactionsRyan Dwyer
Rather than maintain copies of the entire focus stack, this PR transactionises the focus by introducing two new properties to the container state and using those when rendering. * `bool focused` means this container has actual focus. Only one container should have this equalling true in its current state. * `struct sway_container *focus_inactive_child` points to the immediate child that was most recently focused (eg. for tabbed and stacked containers).
2018-06-23Fix crash when deleting last child in a tabbed or stacked containerRyan Dwyer
There was no `current` child because the container was destroyed. This makes it fall back to looking in the parent's current children list.
2018-06-12Fix keyboard shortcut handling inconsistenciesfrsfnrrg
* Ensure that modifier keys are identified even when the next key does not produce a keysym. This requires that modifier change tracking be done for each sway_shortcut_state. * Permit regular and --release shortcuts on the same key combination. Distinct bindings are identified for press and release cases; note that the release binding needs to be identified for both key press and key release events. * Maintain ascending sort order for the shortcut state list, and keep track of the number of pressed key ids, for simpler (and hence faster) searching of the list of key bindings. * Move binding duplicate detection into get_active_binding to avoid duplicating error messages.
2018-06-09Render drag iconsemersion
2018-06-01Comment to explain sway_shortcut_state listsfrsfnrrg
2018-06-01Rewrite shortcut handling code to avoid hardcoded valuesfrsfnrrg
The same shortcut algorithm is now used for keycodes, raw keysyms, and translated keysyms. Pressed keysyms are now stored in association with the keycodes that generated them. Modifier keycodes (and associated keysyms) are identified retroactively by the subsequent change to the modifier flags.
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-21Don't track damage for views on inactive tabsRyan Dwyer
2018-05-20Fix border commands from changing focusBrian Ashworth
2018-04-21Default to current time when triggering cursor eventsemersion
2018-04-10Clean up cursor simulation code.Danny Bautista
2018-04-10Implement cursor event simulation with sway commands.Danny Bautista