Commit graph

48 commits

Author SHA1 Message Date
Ryan Dwyer 7586f150c0 Implement type safe arguments and demote sway_container
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-09-05 18:01:43 +10:00
Ryan Dwyer 07a897b3b7 Don't send motion if the cursor hasn't moved
Prevents GTK+ comboboxes from immediately closing.
2018-08-18 09:29:18 +10:00
Ryan Dwyer b637b61a7a Rename mousedown to down and make seat operation a named enum 2018-08-18 09:18:32 +10:00
Ryan Dwyer a36625a482 Implement mousedown operation
This allows you to move the cursor off the surface while dragging its
scrollbar.
2018-08-18 09:18:32 +10:00
Ryan Dwyer 3a888163a0 Refactor seat_get_focus functions
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-17 17:32:53 +10:00
Ryan Dwyer b4a0363d17 Implement resizing tiled containers via cursor
* 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-12 10:45:54 +10:00
Ian Fan 03eaf444a4 ipc: prevent emitting a workspace::focus event when moving a container to a 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-08-01 16:57:15 +01:00
Ryan Dwyer da2a87f6c7 When unfloating, return container to previously focused tiled container
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-28 22:41:04 +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 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 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
emersion 747725b8bb Don't unfocus when an override redirect window is mapped 2018-07-18 20:00:48 +01: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
Ryan Dwyer 32b865e610 Fix crash when deleting last child in a tabbed or stacked container
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-23 17:47:28 +10:00
emersion cfd02918c0
Render drag icons 2018-06-09 13:26:03 +01:00
Ryan Dwyer efc07fb3d4 Don't track damage for views on inactive tabs 2018-05-21 20:16:56 +10:00
Tony Crisci e7771c507a 80char 2018-04-08 15:32:19 -04:00
Tony Crisci de811823b6 seat focus inactive children foreach 2018-04-07 16:14:12 -04:00
Tony Crisci c0f9ee7bd1 seat get focus inactive view 2018-04-07 16:06:36 -04:00
emersion 2b357af7ee
Give keyboard focus to unmanaged xwayland surfaces
This fixes dmenu
2018-04-07 14:03:30 -04:00
Drew DeVault d2d050d59c Address review feedback 2018-04-04 18:47:48 -04:00
Drew DeVault b7e7794912 Implement input-inhibit in sway, swaylock 2018-04-04 18:47:48 -04:00
Drew DeVault 06fbd51ff5 Add input inhibitor to input manager 2018-04-04 18:47:48 -04:00
Drew DeVault 56078edd65 Give exclusive focus to layers above shell layer 2018-04-02 21:09:09 -04:00
Tony Crisci d434da5632 Merge branch 'wlroots' into split-containers 2018-04-02 16:09:27 -04:00
Tony Crisci 35445b40a2 remove unused attachment config 2018-04-02 12:16:00 -04:00
Tony Crisci 53bb7ea996 dont copy seat config on the seat 2018-04-02 10:37:31 -04:00
Tony Crisci e677c5b204 rename seat functions 2018-04-02 08:45:37 -04:00
Tony Crisci 7706d83160 basic split containers 2018-03-31 15:37:16 -04:00
Drew DeVault f2332dc75c Address review feedback 2018-03-31 15:20:43 -04:00
Tony Crisci dc8c9fbeb6 Revert "Merge pull request #1653 from swaywm/revert-1647-refactor-tree"
This reverts commit 472e81f35d, reversing
changes made to 6b7841b11f.
2018-03-29 23:41:33 -04:00
Drew DeVault d0c7f66e95
Revert "Refactor tree" 2018-03-29 23:29:29 -04:00
Tony Crisci b90099b4b7 rename container functions 2018-03-29 16:40:40 -04:00
Tony Crisci 83d09cf594 remove swayc_t typedef 2018-03-29 14:31:10 -04:00
Tony Crisci 66a975038c add doc to sway_seat_get_focus_inactive() 2018-02-20 19:01:02 -05:00
Tony Crisci 946d9459c5 get swayc in direction 2018-02-14 14:30:27 -05:00
Tony Crisci a7d49da239 separate seat get focus and seat get focus inactive 2018-02-07 18:17:57 -05:00
Tony Crisci 5151502298 basic focus overhaul 2018-02-04 14:08:54 -05:00
Dominique Martinet 5766f426aa config reload: destroy old seat when removed from config
This adds new sway_seat_destroy and sway_cursor_destroy helpers
and compare new and old config on free
2018-01-22 07:26:37 +01:00
Tony Crisci d3d3604760 fix header includes 2017-12-16 08:33:22 -05:00
Tony Crisci 92fef27eaa basic configuration 2017-12-14 11:11:56 -05:00
Tony Crisci 163edc5a90 sway input device 2017-12-12 08:29:37 -05:00
Tony Crisci 9ae906cd37 sway pointer 2017-12-10 16:57:38 -05:00
Tony Crisci 609f63934a basic keyboard 2017-12-10 15:01:09 -05:00
Tony Crisci 21626e8153 seat focus on button press 2017-12-10 11:11:47 -05:00
Tony Crisci 7c67bea942 sway xcursor manager 2017-12-09 11:51:28 -05:00
Tony Crisci d76e745b73 input include directory 2017-12-08 08:07:47 -05:00
Renamed from include/sway/seat.h (Browse further)