Commit graph

494 commits

Author SHA1 Message Date
Rouven Czerwinski cc858e605a seat: unhide the cursor if it is warped to focus
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-07 10:30:19 -05:00
Rouven Czerwinski fde900861a cursor: move unhide and timeout retrieval into separate functions
The unhide and timeout retrieval functions are needed in a later commit. No
functional changes.
2019-01-07 10:30:19 -05:00
David96 ee50134634 Apply tiling_drag_threshold to all containers 2019-01-03 12:52:37 -05:00
Brian Ashworth 5bf4daf263 Implement tiling_drag_threshold
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-02 23:33:33 +01:00
Ian Fan 967566e37f stringop.c: rewrite strip_whitespace 2019-01-01 09:01:24 +00:00
Brian Ashworth 4a3ada303b Apply implicit fallback seat config
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-31 11:37:07 +01:00
Brian Ashworth 4d88c95790 hide_cursor: change to a seat subcommand
This makes hide_cursor a seat subcommand, which allows for seat specific
timeouts.
2018-12-30 14:17:24 +01:00
Brian Ashworth 09bb71f650 Verify seat fallback settings on reload
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-30 14:12:36 +01:00
Brian Ashworth 3e8f548d1d Revamp seat configs
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-29 19:40:40 +01:00
Brian Ashworth 0dbf2673a1 Remove button from state on release during op
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-29 16:36:48 +01:00
Brian Ashworth 3248c823ed Split image_surface handling into own function 2018-12-25 13:31:56 +01:00
Brian Ashworth 5fca74a1f1 Implement hide_cursor <timeout> command
Allows the cursor to be hidden after a specified timeout in
milliseconds
2018-12-25 13:31:56 +01:00
Brian Ashworth a223030b70 Change mouse buttons to x11 map and libevdev names
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-25 13:27:08 +01:00
Brian Ashworth 88d96bc41f Combine output_by_name and output_by_identifier
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-20 19:55:29 +01:00
Brian Ashworth 0ea54833d4 Focus node before tiling drag if on titlebar
Before attempting to drag a tiling container by its titlebar,
focus it. This fixes clicking on titlebars to focus a container.
2018-12-17 16:55:44 -05:00
Brian Ashworth 8d7ebc258a Allow tiling views to be dragged by the titlebar
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-17 09:08:26 +01:00
Rostislav Pehlivanov 1442d4e688 Update for swaywm/wlroots#1377
-Werror is eͫ̐ͭ҉vi͆ͦ̏ͦlͥ̀͒̊͂͛
2018-12-16 15:04:06 +01:00
Brian Ashworth c2499772b9 Fix focusing on non-visible workspace
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-14 13:59:54 -05:00
Brian Ashworth bc981b2bbb Keep focus when destroying containers on nonvis ws
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-12-12 10:13:50 +01:00
emersion 3a310f92ab
Replace _XOPEN_SOURCE with _POSIX_C_SOURCE
And make sure we don't define both in the same source file.
2018-11-25 17:19:43 +01:00
Spencer Michaels 70bc4c3ab6 Add scroll factor config option. 2018-11-18 13:49:30 -05:00
emersion cad851805b
Use #if instead of #ifdef 2018-11-18 00:33:06 +01:00
Ryan Dwyer be9348d25c Move view {x,y,width,height} into container struct
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-17 21:29:42 +10:00
emersion 4ce18d2744
Fix segfault in dispatch_cursor_button 2018-11-15 16:35:19 +01:00
Connor E 4a21981855 Add focus_follows_mouse always. (#3081)
* Add focus_follows_mouse_mode.

* Fail if focus_follows_mouse is invalid.

* Fix indentation.
2018-11-06 21:58:08 +01:00
madblobfish 417a10f477 removed unneeded code fragment 2018-11-04 17:38:13 +01:00
Drew DeVault c18cd9dd03
Merge pull request #3021 from Snaipe/singlekey-binding-trigger
binding: match single-key bindings if no multi-key binding matched
2018-11-03 17:57:59 +01:00
Ryan Dwyer 528c7495bb Move view border properties to container struct
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-31 23:56:20 +10:00
Franklin "Snaipe" Mathieu f8e83ee20a binding: match single-key bindings if no multi-key binding matched
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-29 13:04:19 +00:00
mwenzkowski 66ae58d62a cursor: fix uninitialized pointer in cursor_rebase 2018-10-28 17:33:27 +01:00
Drew DeVault aa21d1b867
Merge pull request #3010 from Emantor/fix/cursor_warping_view_map
input-manager: consider cursor warping on input_manager_set_focus
2018-10-28 12:40:26 +01:00
Rouven Czerwinski 6f87d0c2cf input-manager: consider cursor warping on input_manager_set_focus
input_manager_set_focus is used to set the focus after mapping the view in
view_map. This needs to consider to warp the cursor as well, since for
WARP_CONTAINER, the cursor should warp to the newly created view.
2018-10-28 10:29:10 +01:00
Konstantin Kharlamov cd3c2f4553 seat: don't traverse the list to check if it's empty
Found by introspection.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2018-10-27 21:10:10 +03:00
Ryan Dwyer 63d076dc2a Fix focus after a non-visible workspace's last container is destroyed
The code being changed is responsible for updating the focus stack when
a container is destroyed in a different part of the tree to where the
real focus is. It's attempting to set focus_inactive to a sibling (or
parent if no siblings) of the container that is being destroyed, then
put our real focus back on the end of the focus stack.

The problem occurs when the container being destroyed is in a different
workspace. For example:

* Have a focused view on workspace 1
* Have workspace 2 not visible with a single view that is unmapping
* The first call to seat_set_raw_focus sets focus to workspace 2 because
it's the parent
* Prior to this patch, the second call to seat_set_raw_focus would set
focus to the view on workspace 1
* Later, when using output_get_active_workspace, this function would
return workspace 2 because it's the first workspace it finds in the
focus stack.

To fix this, workspace 1 must be placed on the focus stack between
workspace 2 and the focused view. That's what this patch does.

Lastly, it also uses seat_get_focus_inactive to choose the focus. This
fixes a crash when a view unmaps while a non-container is focused (eg.
swaylock), because focus is NULL.
2018-10-26 19:15:12 +10:00
Ryan Dwyer 60a1d79de7 Rebase the cursor after applying transactions
This approaches cursor rebasing from a different angle. Rather than
littering the codebase with cursor_rebase calls and using transaction
callbacks, this just runs cursor_rebase after applying every transaction
- but only if there's outputs connected, because otherwise it causes a
crash during shutdown.

There is one known case where we still need to call cursor_rebase
directly, and that's when running `seat seat0 cursor move ...`. This
command doesn't set anything as dirty so no transaction occurs.
2018-10-25 23:37:40 +10:00
Ryan Dwyer 641fbe576e When scrolling on a tab titlebar, set focus_inactive if not focused
For example, create layout H[view T[view view view]], focus the view in
the hsplit and scroll the mouse wheel over the tab title bars. Prior to
this patch, focus would be given to a descendant of the tabbed
container. This patch keeps the focus on the hsplit view.

This also renames some of the variables used in this part of the code to
make it be easier to follow.
2018-10-24 23:59:09 +10:00
Ryan Dwyer 9c965ec58c seat_update_capabilities: Set cursor image while we have the capability 2018-10-23 22:00:57 +10:00
Ryan Dwyer 450a0661d7 Fix dormant cursor when using multiple seats
The cursor's image would be removed or set when the seat's capabilities
were updated, but there was nothing to prevent the image from being set
at other times.
2018-10-23 21:38:30 +10:00
Ryan Dwyer c5a6c37275 Make workspace back_and_forth seat-specific
* 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-21 11:26:22 +10:00
Drew DeVault 551e05ba90
Merge pull request #2888 from RyanDwyer/remove-raise-floating
Remove raise_floating directive
2018-10-20 15:30:54 +02:00
Mihai Coman 3daf963d4d Fix crash when defaut seat is not created
Function input_manager_get_default_seat should always return a seat.
2018-10-20 11:48:49 +03:00
Ryan Dwyer b9b1b0e566 Remove raise_floating directive
The directive controlled whether floating views should raise to the top
when the cursor is moved over it while using focus_follows_mouse. The
default was enabled, which is undesirable. For example, if you have two
floating views where one completely covers the other, the smaller one
would be inaccessible because moving the mouse over the bigger one would
raise it above the smaller one.

There is no known use case for having raise_floating enabled, so this
patch removes the directive and implements the raise_floating disabled
behaviour instead.
2018-10-20 17:51:32 +10:00
Ryan Dwyer c006717910 Minor refactor of input manager
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-20 13:11:43 +10:00
Drew DeVault 5b8257b88f
Merge pull request #2872 from RyanDwyer/cursor-rebase
Introduce cursor_rebase
2018-10-20 05:06:03 +02:00
Ryan Dwyer 9b828939e5 Fix crash when ending tiling drag
If the container being dragged has a parent that needs to be reaped, it
must be reaped after we've reinserted the dragging container into the
tree. During reaping, handle_seat_node_destroy tries to refocus the
dragging container which isn't possible while it's detached.
2018-10-20 08:57:09 +10:00
Ryan Dwyer 9ea71f292b Introduce cursor_rebase
This function "rebases" the cursor on top of whatever is underneath it,
without triggering any focus changes.
2018-10-19 22:47:54 +10:00
Ryan Dwyer 4d743b64d0 Fix logic used for mouse_warping output
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-19 22:28:02 +10:00
Drew DeVault 96e3686ae8
Merge pull request #2875 from RedSoxFan/input-device-bindings
cmd_bind{sym,code}: Implement per-device bindings
2018-10-19 14:00:03 +02:00
Ryan Dwyer a2fdac2c4b Consider cursor warp when switching workspaces
Fixes a regression introduced in
24a90e5d86.

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-19 08:00:13 +10:00
Brian Ashworth 2e637b7368 cmd_bind{sym,code}: Implement per-device bindings
bindsym --input-device=<identifier> ...
bindcode --input-device=<identifier> ...
2018-10-18 13:42:01 -04:00
Ryan Dwyer 24a90e5d86 Remove cursor warping from seat_set_focus
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-18 23:08:45 +10:00
Drew DeVault 765c80e5f7
Merge pull request #2820 from Emantor/fix-mouse-warping-container
Fix mouse warping container
2018-10-17 15:57:13 +02:00
Rouven Czerwinski d69cf4c23c seat: use new warping functions for cursor warping during focus warp 2018-10-16 15:47:02 +02:00
Rouven Czerwinski 0969bf758b cursor: functions to warp cursor to container and workspace
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-16 15:47:02 +02:00
Ryan Dwyer 05284b65db Prevent duplicate workspace::focus events
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-16 08:17:24 +10:00
Ryan Dwyer 26278b694c Introduce seat_set_raw_focus and remove notify argument from seat_set_focus_warp
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-15 21:06:24 +10:00
Ian Fan 2f1fd80726 swaybar: show hidden bar on key event
Since wayland does not currently allow swaybar to create global
keybinds, this is handled within sway and sent to the bar using a custom
event, so as not to pollute existing events, called bar_state_update.
2018-10-14 13:33:12 +01:00
Thiago Mendes 8e147b3f1d
Add libinput send_events config for touch 2018-10-10 23:15:31 +02:00
Drew DeVault 5d19906556
Merge pull request #2806 from v-gu/add-libinput-support-for-keyboard
add libinput config for keyboard
2018-10-10 17:07:38 +02:00
Ryan Dwyer ed33d95b6a
Merge branch 'master' into mouse-warping-container 2018-10-10 21:50:29 +10:00
Rouven Czerwinski 41991542ca Add mouse_warping container
This option always moves the cursor into the middle of the container if the warp
variable is true in seat_set_focus_warp.

Fixes #2577
2018-10-10 12:45:21 +02:00
Ryan Dwyer 416bb7a214 Fix floating click events
* Set focus to a floating container when clicking its title bar.
* Raise floating when user clicks title bar or decorations (in the
seat_begin functions).
* In container_at, it only returned a floating container if the user had
clicked the surface. This makes it use floating_container_at instead.
2018-10-10 16:58:32 +10:00
Vincent Gu 073aa4149f add libinput config for keyboard
add send_events support
2018-10-09 22:03:27 +08:00
Ryan Dwyer f23588de3c Introduce container_is_transient_for 2018-10-08 23:00:36 +10:00
Ryan Dwyer 832ebc8966 Implement popup_during_fullscreen
This introduces a new view_impl function: is_transient_for. Similar to
container_has_ancestor but works using the surface parents rather than
the tree.

This patch modifies view_is_visible, container_at and so on to allow
transient views to function normally when they're in front of a
fullscreen view.
2018-10-08 22:49:59 +10:00
Ryan Dwyer 88a5e26c6e Remove unneeded variable 2018-10-08 20:40:47 +10:00
Ryan Dwyer 82423991a8 Reload config using idle event
This patch makes it so when you run reload, the actual reloading is
deferred to the next time the event loop becomes idle. This avoids
several use-after-frees and removes the workarounds we have to avoid
them.

When you run reload, we validate the config before creating the idle
event. This is so the reload command will still return an error if there
are validation errors. To allow this, load_main_config has been adjusted
so it doesn't apply the config if validating is true rather than
applying it unconditionally.

This also fixes a memory leak in the reload command where if the config
failed to load, the bar_ids list would not be freed.
2018-10-08 19:28:53 +10:00
Ryan Dwyer c620f76bea Move sticky containers when switching workspace via criteria
* Create a view on workspace 1
* Switch to workspace 2 (on the same output) and create a floating
sticky view
* Use criteria to focus the view on workspace 1

Previously, we only moved the sticky containers when using
workspace_switch, but the above method of focusing doesn't call it. This
patch relocates the sticky-moving code into seat_set_focus_warp.

A side effect of this patch is that if you have a sticky container
focused and then switch workspaces, the sticky container will no longer
be focused. It would previously retain focus.

In seat_set_focus_warp, new_output_last_ws was only set when changing
outputs, but now it's always set. This means new_output_last_ws and
last_workspace might point to the same workspace, which means we have to
make sure we don't destroy it twice. It now checks to make sure they're
different, and to make this more obvious I've moved both calls to
workspace_consider_destroy to be next to each other.
2018-10-06 19:16:41 +10:00
Ryan Dwyer 44b550298e Fix crash when flattening container after moving
container_flatten removes the container from the tree (via
container_replace) before destroying it. When destroying, the recent
changes to handle_seat_node_destroy incorrectly assumes that the
container has a parent.

This adds a check for destroying a container which is no longer in the
tree. If this is the case, focus does not need to be changed.
2018-10-05 16:39:20 +10:00
Drew DeVault eecebcafc6 Fix #2763 2018-10-04 15:00:18 -04:00
emersion 0d5c2f75b5
Merge pull request #2760 from RyanDwyer/swaylock-handle-output-disconnect
Give focus to another swaylock surface when output is disconnected
2018-10-04 14:18:13 +02:00
Ryan Dwyer 4feedbf7cf Ignore unrelated cursor buttons while doing seat operations
* Click and hold a scrollbar
* Drag the cursor onto another surface
* While still holding the original button, press and release another
cursor button
* Things get weird

There's two ways to fix this. Either cancel the seat operation and do
the other click, or continue the seat operation and ignore the other
click. I opted for the latter (ignoring the click) because it's easier
to implement, and I suspect a second click during a seat operation is
probably unintentional anyway.
2018-10-04 20:57:03 +10:00
Ryan Dwyer 32cb631143 Give focus to another swaylock surface when output is disconnected
* Have multiple outputs
* Launch swaylock
* Unplug an output (possibly has to be the last "connected" one)
* The swaylock surface on the remaining output would not respond to key
events

This was happening because when the output destroys, focus was not given
to the other swaylock surface.

This patch makes focus be transferred to another surface owned by the
same Wayland client, but only if input was inhibited by the surface
being destroyed, and only if it's in the overlay layer. I figure it's
best to be overly specific and relax the requirements later if needed.

This patch removes a check in seat_set_focus_surface which was
preventing focus from being passed from a layer surface to any other
surface. I don't know of a use case for this check, but it's possible
that this change could produce issues.
2018-10-04 19:36:19 +10:00
Jonathan Buch 7727d54faf
Fix focusing topmost floating windows
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-10-03 16:23:14 +02:00
Jonathan Buch ec713125c6
Simplify raising a container in seat
* Factor out raising a floating window into s separate function to
  enable reuse.
2018-10-03 16:23:14 +02:00
Jonathan Buch 298ccb539c
Add configuration for raising containers on focus
* New configuration option: raise_floating
  (From the discussion on https://github.com/i3/i3/issues/2990)
* By default, it still raises the window on focus, otherwise it
  will raise the window on click.
2018-10-03 16:23:12 +02:00
Ryan Dwyer 5dd535b67a Add sanity check for empty focus stack 2018-10-03 22:09:20 +10:00
Drew DeVault 06c214a800
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
2018-10-03 13:03:06 +02:00
Ryan Dwyer 677e112733 Set focus_inactive on a sibling when a container closes in an inactive workspace
To reproduce the problem, create layout
H[view V[view view view-focused]], then switch to another workspace and
have the previously focused view in the vsplit close (eg. using
criteria, or an mpv video finishing). Return to the workspace using
`$mod+<num>` and the entire vsplit would be focused. This happens
because handle_seat_node_destroy would only set a new focus if the
currently focused view or a parent was being destroyed. To fix it, it
needs to set a sibling of the destroying container to focus_inactive
regardless of the current focus, then restore current focus if needed.

This patch changes the function accordingly. Additionally:

* The function now makes an early return if the node being destroyed is
a workspace.
* set_focus has been renamed to needs_new_focus. This variable is true
if the head focus needs to be changed.
2018-10-02 15:45:20 +10:00
Brian Ashworth 742d1764a6 Fix smart gaps 2018-10-01 09:41:15 -04:00
Drew DeVault 8f6aca2166
Merge pull request #2725 from PumbaPe/add-tap-and-drag
Add tap and drag to sway-input
2018-09-30 13:44:11 +02:00
Arkadiusz Hiler 1e70f7b19e Turn funcs() into funcs(void)
If they really do not take undefined number of arguments.
2018-09-30 14:09:05 +03:00
emersion a53171669a
Merge pull request #2698 from ianyfan/hide-cursor
Only show cursor if pointer configured
2018-09-29 14:32:05 +02:00
PP ae2b70f59e add tap-and-drag setting to sway-input 2018-09-29 11:49:41 +02:00
Ryan Dwyer 7b138e5ef0 Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also
removes sway_xdg_shell{_v6}_view.deco_mode and
view->has_client_side_decorations as we can now get these from the
border.

You can use `border toggle` to cycle through the modes including CSD, or
use `border csd` to set it directly. The client must support the
xdg-decoration protocol, and the only client I know of that does is the
example in wlroots.

If the client switches from SSD to CSD without us expecting it (via the
server-decoration protocol), we stash the previous border type into
view.saved_border so we can restore it if the client returns to SSD. I
haven't found a way to test this though.
2018-09-27 22:51:37 +10:00
Drew DeVault 5912be46c3
Merge pull request #2704 from ianyfan/tablet-config
input: enable configuring tablets with libinput
2018-09-27 02:07:15 -05:00
Alexander Bakker d129108cdd Add a missing null check for moving tiling containers 2018-09-25 22:19:46 +02:00
Ian Fan 6194a445d3 input: enable configuring tablets with libinput 2018-09-24 12:49:20 +01:00
Ian Fan a10fef9ae8 cursor: allow cursor_set_image to accept a NULL image to hide cursor 2018-09-24 12:34:09 +01:00
Ian Fan dafb0526d7 seat: only show cursor if pointer configured 2018-09-24 10:55:42 +01:00
Brian Ashworth baeb28ea62 Implement support for input wildcard 2018-09-23 19:56:52 -04:00
Ryan Dwyer 271b24ddfb Fix GtkMenuBar always opening first item
It seems like advertising that we support touch when we don't, while
using SSD, makes GtkMenuBar misbehave. Please don't ask me why...
2018-09-23 22:00:18 +10:00
Ryan Dwyer bf5933c501 Implement tab cycling using mouse wheel
Firstly, a change had to be made to the container_at functions. If you
create layout `T[view H[view view]]` and hover the second tab, the
container_at functions would return the focus_inactive child. They now
return the split container itself. To compensate for this,
dispatch_cursor_button has been adjusted to find the focus_inactive
child before focusing it.

The actual implementation of wheel scrolling is pretty straightforward.
This uses handle_cursor_axis, so I took a similar approach to
handle_cursor_button (ie. creating a dispatch_cursor_axis function).
2018-09-22 10:42:59 +10:00
Ryan Dwyer f6e218a643 Rename seat_get_active_child to seat_get_active_tiling_child
Also renames container to con in one function to prevent ugly line
wrapping.
2018-09-16 22:01:54 +10:00
Ryan Dwyer 48bc15e758 Make seat_get_active_child ignore floating children
seat_get_active_child is used to get the active tiling child in a few
places, such as outputs getting their active workspace and
tabbed/stacked containers getting their visible child. When a workspace
uses a tabbed or stacked layout and contains a focused floating view,
calling seat_get_active_child on the workspace would incorrectly return
the floating view. This changes it so it will return the tiling child.

This fixes the following bug:

* Create layout T[view view] then float one of the views
* Attempt to click the tiling view to give it focus - it wouldn't work
because seat_get_active_child would return the floating view
2018-09-16 21:57:19 +10:00
emersion 7699c5444c Update for swaywm/wlroots#1243 2018-09-14 19:21:44 +02:00
Ryan Dwyer 679c7eb08c Minor fixes to tiling drag implementation
* Make container_add_sibling's `after` argument a boolean.
* Use a constant for drop layout border
* Make thickness an int
* Add button state check
* Move comments in seat_end_move_tiling
2018-09-12 08:46:46 +10:00
Ryan Dwyer 403905c11b Fix line length 2018-09-11 23:24:57 +10:00
Ryan Dwyer 8bb40c24c7 Implement tiling drag
Hold floating_modifier and drag a tiling view to a new location.
2018-09-11 21:34:21 +10:00
Ryan Dwyer d4e80cf301 Rename OP_MOVE to OP_MOVE_FLOATING
In preparation for introducing OP_MOVE_TILING.
2018-09-11 16:56:05 +10:00