Commit Graph

154 Commits

Author SHA1 Message Date
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 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
Drew DeVault 030b5bc024
Merge pull request #2603 from emersion/fix-dnd
Fix drag-and-drop
2018-09-07 11:09:02 -04:00
emersion 251a7ebc4b Fix drag-and-drop 2018-09-07 15:43:15 +02:00
Ryan Dwyer 908095ef9a Introduce seat_set_focus_container and seat_set_focus_workspace
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-06 19:26:56 +10:00
Ryan Dwyer 6f71749398 Fix clicking workspace buttons
Because node_at_coords was returning the workspace's node, it
interpreted this as clicking the focused workspace which was a no op.
2018-09-05 18:01:43 +10:00
Ryan Dwyer e5c9204b49 Focus empty workspace when clicking it
Also removes container_at_coords as this function is no longer
necessary.
2018-09-05 18:01:43 +10:00
Ryan Dwyer eccfcde2eb Fix crash when moving mouse over a fullscreen split container 2018-09-05 18:01:43 +10:00
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 5dbbab7bdc Remove layout.c
When we have type safety we'll need to have functions for
workspace_add_tiling and so on. This means the existing container
functions will be just for containers, so they are being moved to
container.c. At this point layout.c doesn't contain much else, so I've
relocated everything and removed the file.

* container_swap and its static functions have been moved to the swap
command and made static.
* container_recursive_resize has been moved to the resize command and
made static.
* The following have been moved to container.c:
    * container_handle_fullscreen_reparent
    * container_insert_child
    * container_add_sibling
    * container_add_child
    * container_remove_child
    * container_replace_child
    * container_split
* enum movement_direction and sway_dir_to_wlr have been moved to util.c.

Side note: Several commands included layout.h which then included
root.h. With layout.h gone, root.h has to be included by those commands.
2018-08-26 12:05:16 +10:00
Ryan Dwyer 2b5a404ac9 Replace hacky L_FLOATING container with a list
Workspaces previously had a magical `workspace->floating` container,
which had a layout of L_FLOATING and whose children were actual floating
views. This allowed some conveniences, but was a hacky solution because
the container has to be exempt from focus, coordinate transactions with
the workspace, and omit emitting IPC events (which we didn't do).

This commit changes it to be a list directly in the sway_workspace. The
L_FLOATING layout is no longer used so this has been removed as well.

* Fixes incorrect check in the swap command (it checked if the
containers had the L_FLOATING layout, but this layout applied to the
magical container).
* Introduces workspace_add_floating
2018-08-19 16:18:33 +10:00
Drew DeVault d4a32800d5
Merge pull request #2460 from RyanDwyer/implement-mousedown
Implement mousedown operation
2018-08-18 09:32:04 -04:00
Ryan Dwyer d22420689d Fix mod+resize
Fixes #2479.

It was missing a mod_pressed check.

This also moves the parent traversal into the `if` block.
2018-08-18 17:50:37 +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 4d023c0390 Make mod+resize a floating container resize the container itself
Rather than resizing the split within the container.
2018-08-12 10:45:54 +10:00
Ryan Dwyer e9d46ccbdd Use col-resize and row-resize cursor images 2018-08-12 10:45:54 +10:00
Ryan Dwyer 1893515d3a Fix right-click/popups and add state checks 2018-08-12 10:45:54 +10:00
Ryan Dwyer 2dceae6224 Allow resizing tiled views via mod key 2018-08-12 10:45:54 +10:00
Ryan Dwyer f4280e506b Refactor dispatch_cursor_button
There was a separate function dispatch_cursor_button_floating which
dealt with the resize and move operations, but as resize is not really
limited to floating views, it doesn't make as much sense to have this
separate. So both functions are now combined into one.

Additionally, dispatch_cursor_button now uses a pattern of returning
early instead of using else-ifs.
2018-08-12 10:45:54 +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
Ryan Dwyer f5dc3ac09d Don't call send_pointer_notify_button when doing move or resize 2018-08-08 22:32:59 +10:00
Ryan Dwyer 4c5dc6f135 Focus floating views when beginning move/resize operations 2018-08-08 22:28:13 +10:00
Ryan Dwyer c17f0870ef Fix crash when moving cursor over a fullscreen split container
Calling container_at_view fails an assertion if the container isn't a
view. Calling tiling_container_at works correctly, as that function
checks if the container is a view and calls container_at_view if so.
2018-08-03 18:08:20 +10:00
emersion b336564511 Fix pointer events for fullscreen views 2018-08-02 22:48:43 +01:00
minus e72f86784c Fix crash on mouse motion on fullscreen container
container_at expects a workspace, not the fullscreened container.
Fixes #2409
2018-08-02 23:19:01 +02:00
Ryan Dwyer 8392eae40f Revert "Revert "Fix popups""
This reverts commit 9aa258d33a.

Reverting the revert, so that popups can be fixed.
2018-08-02 23:36:36 +10:00
Drew DeVault 9aa258d33a Revert "Fix popups"
This reverts commit de86d65627.
2018-08-02 09:05:46 -04:00
Drew DeVault 9564c73c0d
Merge pull request #2391 from RyanDwyer/fix-popups-v2
Fix popups (v2)
2018-08-01 22:02:12 -04: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 de86d65627 Fix popups
Fixes the render and container_at order for popups.

Fixes #2210

For rendering:

* render_view_surfaces has been renamed to render_view_toplevels
* render_view_toplevels now uses output_surface_for_each_surface (which
is now public), as that function uses wlr_surface_for_each_surface which
doesn't descend into popups
* Views now have a for_each_popup iterator, which is used by the
renderer to render the focused view's popups
* When rendering a popup, toplevels (xdg subsurfaces) of that popup are
also rendered

For sending frame done, the logic has been updated to match the
rendering logic:

* send_frame_done_container no longer descends into popups
* for_each_popup is used to send frame done to the focused view's popups
and their child toplevels

For container_at:

* floating_container_at is now static, which means it had to be moved
higher in the file.
* container_at now considers popups for the focused view before checking
containers.
* tiling_container_at has been introduced, so that it doesn't call
container_at recursively (it would check popups recursively if it did)
2018-07-31 18:41:30 +10:00
Ryan Dwyer 0b6b6716e2 Fix clicking a floating split container
It would focus the split container rather than the child.

This commit makes it track the child and the split container separately
and send the surface click to the child.
2018-07-28 22:41:04 +10:00
Ryan Dwyer 08cfba2192 Allow containers to float
Things worth noting:

* When a fullscreen view unmaps, the check to unset fullscreen on the
workspace has been moved out of view_unmap and into container_destroy,
because containers can be fullscreen too
* The calls to `container_reap_empty_recursive(workspace)` have been
removed from `container_set_floating`. That function reaps upwards so it
wouldn't do anything. I'm probably the one who originally added it...
* My fix (b14bd1b0b1) for the tabbed child
crash has a side effect where when you close a floating container, focus
is not given to the tiled container again. I've removed my fix and
removed the call to `send_cursor_motion` from `seat_set_focus_warp`. We
should consider calling it from somewhere earlier in the call stack.
2018-07-28 22:41:04 +10:00
Ryan Dwyer 27a20a4884 Allow containers to be fullscreen 2018-07-26 08:27:07 +10:00
Drew DeVault fc718f629a
Merge pull request #2350 from ppascher/xwayland-optional
Added meson option to allow building sway without xwayland support
2018-07-25 08:27:40 -04:00
Pascal Pascher f95cb9a7c1 reverted includes of "sway/config.h" and replaced with "config.h" from meson build 2018-07-25 13:32:20 +02:00
Pascal Pascher 79a45d4a40 more style fixes, included "sway/config.h" where needed 2018-07-25 12:17:10 +02:00
Brian Ashworth 3a75bb7f32 Change button var passed to seat_begin_move 2018-07-24 18:52:54 -04:00
Brian Ashworth dca02944ce Implement floating_modifier <mod> [inverse|normal] 2018-07-24 18:41:08 -04:00
Pascal Pascher 2bf893248a style fixes, exclude sway/desctop/xwayland.c when enable_xwayland: false 2018-07-24 23:37:41 +02:00
Pascal Pascher 24ad1c3983 Added meson option "enable_xwayland" (default: true) to enable/disable xwayland support 2018-07-24 22:16:06 +02: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