Commit graph

111 commits

Author SHA1 Message Date
Brian Ashworth
dca02944ce Implement floating_modifier <mod> [inverse|normal] 2018-07-24 18:41:08 -04:00
Ryan Dwyer
2f1b84a0f3 Fix crash when clicking certain surfaces
cont was NULL.
2018-07-24 21:12:24 +10:00
Ryan Dwyer
e7c10f1871 Make mod+resize work in any direction
This makes it so if you hold mod and right click on a surface to resize
it, the resize direction is chosen based on which quarter of the surface
you've clicked. The previous implementation only resized towards the
bottom right.
2018-07-24 20:20:00 +10:00
frsfnrrg
94dd8823a0 Invoke mouse bindings
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-23 21:38:29 -04:00
Ryan Dwyer
0db6f2ef58 Fix some cases where the cursor doesn't update
cursor_set_image only uploads the named image if it doesn't match the
previous named image. This means when setting the cursor image to a
surface as given by a client, we have to clear the currently stored
image.
2018-07-24 09:09:49 +10:00
Ryan Dwyer
d21d4b83a3 Set cursor when beginning resize and move operations 2018-07-22 23:10:19 +10:00
Ryan Dwyer
009b426024 Fix damage when shrinking a floating view using cursor 2018-07-22 23:10:19 +10:00
Ryan Dwyer
5ba2ae9c6a Implement request_move and request_resize for xwayland views
I discovered we have to send a click event when ending the move or
resize operation to make xwayland's requests work correctly.
2018-07-22 23:10:19 +10:00
Ryan Dwyer
3faceadffe Fix focus bug with floating containers 2018-07-22 23:10:19 +10:00
Ryan Dwyer
011d1ebfa4 Consider view's min/max sizes when resizing 2018-07-22 23:10:19 +10:00
Ryan Dwyer
9df660ee31 Store last button and use it when views request to move or resize 2018-07-22 23:10:19 +10:00
Ryan Dwyer
6767d8a593 Prevent re-uploading the same cursor image multiple times 2018-07-22 23:10:19 +10:00
Ryan Dwyer
0c87bff5d1 Replace static handle_end_operation with seat_end_mouse_operation 2018-07-22 23:10:19 +10:00
Ryan Dwyer
ff445cc855 Implement xdg shell request_move and request_resize events
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-22 23:10:19 +10:00
Ryan Dwyer
1b3b75a094 Use wlr_keyboard_get_modifiers 2018-07-22 23:10:19 +10:00
Ryan Dwyer
dd337127d8 Use separate function for choosing edge cursor 2018-07-22 23:10:19 +10:00
Ryan Dwyer
350e9ea929 Fix clicking xwayland menus 2018-07-22 23:10:19 +10:00
Ryan Dwyer
c299b6b5cd Use max multiplier when resizing while preserving ratio 2018-07-22 23:10:19 +10:00
Ryan Dwyer
2c6616050a Make mod + resize do it from the top left corner 2018-07-22 23:10:19 +10:00
Ryan Dwyer
3aadf944ae Use WLR_MODIFIER_SHIFT 2018-07-22 23:10:19 +10:00
Ryan Dwyer
9fbe13b9be Implement floating_modifier and mouse operations for floating views
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-22 23:10:19 +10:00
Ryan Dwyer
8533c35a9f Fix crash and render issues involving cursor_send_pointer_motion
Fixes #2303, as well as a crash.

To replicate the crash:

* Have multiple outputs
* In config: for_window [<criteria>] workspace foo
* Also in config: workspace foo output <left-output-name>
* Focus the right output, and ensure workspace foo doesn't exist
* Launch the app that triggers the criteria

When the view maps, it calls workspace_switch which calls
send_set_focus which calls cursor_send_pointer_motion which calls
transaction_commit_dirty. This call to transaction_commit_dirty is not
meant to happen at this time because the tree isn't guaranteed to be in
a consistent state, but I'm not sure how exactly this leads to the crash
or render issues.

In this case the transaction is already committed by the view
implementation's handle_map function. So the solution is to remove it
from cursor_send_pointer_motion and add it to the other functions in
cursor.c which call cursor_send_pointer_motion.
2018-07-19 19:49:50 +10:00
Ryan Dwyer
a120d4c79f Make focus part of transactions
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-07-15 22:08:26 +10:00
emersion
63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Brian Ashworth
c833ae64bc Fix pointer button events for layer surfaces 2018-07-05 23:01:35 -04:00
Tony Crisci
e9ad10c2d6 dont focus-follow-mouse when keyboard grab 2018-06-24 20:30:43 -04:00
emersion
cfd02918c0
Render drag icons 2018-06-09 13:26:03 +01:00
Scott Leggett
609c420501 Initialise previous cursor position.
Fix the problem with focus jumping to the container under the cursor
when first starting sway.
2018-06-06 20:45:02 +10:00
Ryan Dwyer
bcdb676abb Don't set focus to NULL when clicking a surface which has no container 2018-06-04 11:31:25 +10:00
Ryan Dwyer
e4e912ea91 Store swayc coordinates as layout-local 2018-06-01 23:14:58 +10:00
Ryan Dwyer
1f2e399ade Implement floating 2018-06-01 23:14:58 +10:00
Scott Leggett
4d8120ccf3 Improve comment. 2018-05-28 02:35:24 +10:00
Scott Leggett
b57f88e7db Avoid assert on container type. 2018-05-28 02:25:42 +10:00
Scott Leggett
1b8de39287 Move previous cursor_position inline. 2018-05-28 02:14:19 +10:00
Scott Leggett
0039f7a4fd Simplify logic, remove redundant variables. 2018-05-28 01:38:46 +10:00
Scott Leggett
dd86444e59 Rely on view_is_visible rather thank walking the tree ourselves. 2018-05-28 01:38:46 +10:00
Scott Leggett
4cd304e4ba Store previous position in sway_cursor. 2018-05-28 01:37:43 +10:00
Scott Leggett
06098bef98 Focus containers only on entry. 2018-05-27 15:29:48 +10:00
Drew DeVault
fea654a6ce Replace oft-failing abort with if statement
Fixes #2045
2018-05-26 10:35:15 -04:00
Ivan Chebykin
464ec44b00
Check for next_focus before assert 2018-05-26 15:54:49 +03:00
Ivan Chebykin
6e6b0decd9
Fix usage of sway_assert 2018-05-26 15:51:36 +03:00
Ivan Chebykin
820a8c9c2d
Moved visibility check of of loop, added asserts 2018-05-26 13:34:14 +03:00
Ivan Chebykin
740234a4bc
Break after first tabbed/stacked layout 2018-05-25 17:45:41 +03:00
Ivan Chebykin
53516fa03f
Fix mouse focusing for horizontal/vertical views in tabbed containers 2018-05-25 17:22:25 +03:00
Ivan Chebykin
f85d3e15ba
Fixed styling issues 2018-05-25 16:54:43 +03:00
Ivan Chebykin
e19fe56e2f
Focus inactive container instead of checking cursor position 2018-05-25 16:54:43 +03:00
Ivan Chebykin
3b67253312
Skip all nested containers 2018-05-25 16:54:43 +03:00
Ivan Chebykin
c62efbb5ce
Implement correct focusing for tabbed containers 2018-05-25 16:54:43 +03:00
Ivan Chebykin
c1be4b0153
Fix focusing from other containers 2018-05-25 16:54:43 +03:00
Ivan Chebykin
87af08966a
Don't focus tabbed and stacked containers on mouseover 2018-05-25 16:54:43 +03:00