1
1
mirror of https://github.com/swaywm/sway synced 2024-09-24 03:01:05 +02:00
Commit Graph

353 Commits

Author SHA1 Message Date
emersion
212baf2f75
Merge pull request #3400 from ianyfan/config-brace
config.c: fix brace detection at end of file
2019-01-10 13:29:21 +01:00
Ian Fan
00f8d0209f config.c: fix brace detection at end of file 2019-01-10 10:59:07 +00:00
Jan Beich
0a4c4f3e52 Simplify evdev includes on FreeBSD by relying on up-to-date package
evdev-proto is installed by a dependency, so some files have been missed:

  In file included from ../sway/input/cursor.c:3:
  /usr/local/include/libevdev-1.0/libevdev/libevdev.h:30:10: fatal error: 'linux/input.h' file not found
  #include <linux/input.h>
	   ^~~~~~~~~~~~~~~
  ../swaybar/i3bar.c:3:10: fatal error: 'linux/input-event-codes.h' file not found
  #include <linux/input-event-codes.h>
	   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-01-09 11:02:05 +00:00
Brian Ashworth
f33969358c reload: apply seat cfgs after reading entire cfg
Wait until all seat configs have been read before applying them on
reload. This prevents unnecessary attachment/detachment of input
devices and therefore creation/destruction of seat devices as
individual lines are read.
2019-01-09 01:06:21 -05:00
emersion
140bc2dd5b
Merge pull request #3275 from ianyfan/remove-readline
Rewrite strip_whitespace and remove readline.c
2019-01-08 10:05:37 +01: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
bd35879e1c fixup! config.c: re-enable backslash continuation in config file 2019-01-01 09:01:25 +00:00
Ian Fan
a9c5158a77 config.c: re-enable backslash continuation in config file 2019-01-01 09:01:25 +00:00
Ian Fan
a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
Ian Fan
967566e37f stringop.c: rewrite strip_whitespace 2019-01-01 09:01:24 +00: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
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
1897edabba Rework default output configs
Default output configs were generated on reload to reset an output to
its default settings. The idea was that anything that was removed from
the config or changed at runtime and not in the config should be reset
on reload. Originally, they were created using the output name. Recently,
they were changed to use the output identifier. It turns out that there
are issues of shadowing with that solution as well. This should fix
those issues.

Instead of generating the default output configs on reload and storing
them in the output config list to merge on top of, they are now only
generated when retrieving the output config for an output during a
reload. This means that the default output configs are never stored
anywhere and just used as a base to merge unaltered user configs on top
of during a reload.

Starting with a blank output config, merges get applied in the following
order:
1. Default output config (only during a reload)
2. Wildcard config (only if neither output name or output identifier
exist)
3. Output name config
4. Output identifier config
2018-12-13 18:37:25 +01:00
Ian Fan
98c1e19466 list.c: rename free_flat_list to list_free_items_and_destroy 2018-12-09 01:15:38 +00:00
Ian Fan
c8776fac42 Cleanup list code 2018-12-09 01:15:38 +00:00
Ian Fan
19e831ed3d list.c: Remove list_foreach
Most occurrences have been replaced by `free_flat_list` which has been
moved from stringop.c to list.c. The rest have been replaced by for loops.
2018-12-09 00:37:50 +00:00
Ian Fan
bca21ee0cf config: do not set $XDG_CONFIG_HOME if unset or empty
Instead redefine the config paths to use the default $HOME/.config
2018-12-03 13:28:31 +01:00
Ian Fan
de66ed4beb config: set $XDG_CONFIG_HOME if empty
Before, it was only set if it was not set, but it should also be done
when empty.
2018-12-03 12:12:21 +01:00
Brian Ashworth
e5f90f25d7 Introduce a way to show config warnings in swaynag
Adds the function `config_add_swaynag_warning(char *fmt, ...)` so that
handlers can add warnings to the swaynag config log in a uniform way.
The formatting is identical to errors and include the line number, line,
and config path.

This also alters the background file access warning to use the function
and introduces a warning for duplicate bindings.
2018-11-28 11:09:01 -05:00
Ryan Dwyer
af7a97623b
Merge pull request #3185 from emersion/remove-xopen-source
Replace _XOPEN_SOURCE with _POSIX_C_SOURCE
2018-11-26 21:25:45 +10:00
Brian Ashworth
e6562c8cd2 Implement title alignment
This adds support for `i3 4.16`'s ability to set the title alignment.
The command is `title_align left|center|right`.

When the title is on the right, marks are moved to the left. Otherwise,
they are on the right.
2018-11-25 22:08:58 -05: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
Florent de Lamotte
7555c7efdc Adding commands for configuring titlebar borders and padding 2018-11-22 10:30:04 +01:00
Ryan Dwyer
4e8bf5b328 Fix double free of mode
config->current_mode is a pointer into the config->modes list, and each
mode has already been freed.

Same with bars.
2018-11-15 23:48:11 +10:00
Connor E
eda1bf769f More frees. 2018-11-13 14:42:00 +00:00
Drew DeVault
7fa7f4f48d
Merge pull request #3085 from 7415963987456321/master
Remove extra line.
2018-11-08 20:07:41 -05:00
7415963987456321
965abe077a Remove extra line 2018-11-09 00:57:09 +00:00
Brian Ashworth
9e8aa39530 Implement per side and per direction outer gaps
This introduces the following command extensions from `i3-gaps`:
* `gaps horizontal|vertical|top|right|bottom|left <amount>`
* `gaps horizontal|vertical|top|right|bottom|left all|current
set|plus|minus <amount>`
* `workspace <ws> gaps horizontal|vertical|top|right|bottom|left
<amount>`

`inner` and `outer` are also still available as options for all three
of the above commands. `outer` now acts as a shorthand to set/alter
all sides.

Additionally, this fixes two bugs with the prevention of invalid gap
configurations for workspace configs:
1. If outer gaps were not set and inner gaps were, the outer gaps
would be snapped to the negation of the inner gaps due to `INT_MIN`
being less than the negation. This took precedence over the default
outer gaps.
2. Similarly, if inner gaps were not set and outer gaps were, inner
gaps would be set to zero, which would take precedence over the
default inner gaps.

Fixing both of the above items also requires checking the gaps again
when creating a workspace since the default outer gaps can be smaller
than the negation of the workspace specific inner gaps.
2018-11-07 22:44:11 -05: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
Rouven Czerwinski
f54287eaf3 config: mention that reload message is also printed on validation 2018-11-05 21:06:28 +01:00
Brian Ashworth
31f82830b2 config: remove peeked + expanded line log entries
The peeked and expanded line log entries were useful during the switch
to generic code blocks and subcommands. However, it has been a while
since those were introduced and the log entries are no longer helpful
for any remaining issues with config parsing. Instead of keeping them
as clutter in the log, they can just be removed.
2018-10-22 17:52:41 -04: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
Tarmack
36d9037f2c fix_edge_gaps: Allow negative values for outer gaps.
While allowing negative values for the outer gaps it is still prevented that negative values move windows out of the container. This replaces the non-i3 option for edge_gaps.
2018-10-13 17:42:49 +02: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
Rouven Czerwinski
1eb0dc2922 config: remove double free of config->swaynag_command
Fixes #2796
2018-10-09 13:14:02 +02:00
Brian Ashworth
3f328b6276
Merge branch 'master' into popup-during-fullscreen 2018-10-08 15:18:49 -04:00
Brian Ashworth
09c3c33081 Allow swaynag to be disabled 2018-10-08 09:59:38 -04:00
emersion
c988b03d85 Allow swaybg to be disabled
Same as #2791 but for swaybg.

Fixes #2790
2018-10-08 15:08:33 +02: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
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
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
Brian Ashworth
bb25194844 Handle border options for gaps
Fixes `hide_edge_borders smart` when gaps are in use.
Implements `hide_edge_borders smart_no_gaps` and `smart_borders
on|no_gaps|off`.

Since `smart_borders on` is equivalent to `hide_edge_borders smart`
and `smart_borders no_gaps` is equivalent to `hide_edge_borders
smart_no_gaps`, I opted to just save the last value set for
`hide_edge_borders` and restore that on `smart_borders off`. This
simplifies the conditions for setting the border.
2018-10-01 21:19:06 -04:00
Ryan Dwyer
138d10d5d6 Rename workspace_outputs to workspace_configs and fix memory leak
When we eventually implement `workspace <ws> gaps inner|outer <px>`,
we'll need to store the gaps settings for workspaces before they're
created. Rather than create a workspace_gaps struct, the approach I'm
taking is to rename workspace_outputs to workspace_configs and then add
gaps settings to that.

I've added a lookup function workspace_find_config. Note that we have a
similar thing for outputs (output_config struct and output_find_config).

Lastly, when freeing config it would create a memory leak by freeing the
list items but not the workspace or output names inside them. This has
been rectified using a free_workspace_config function.
2018-09-28 22:35:38 +10:00
Ryan Dwyer
ec9c4de564 Introduce tiling_drag directive 2018-09-11 17:17:19 +10:00
Ryan Dwyer
9215ca0f01 Align titles to baseline
This does the following:

* Adds a baseline argument to get_text_size (the baseline is the
distance from the top of the texture to the baseline).
* Stores the baseline in the container when calculating the title
height.
* Takes the baseline into account when calculating the config's max font
height.
* When rendering, pads the textures according to the baseline so they
line up.
2018-09-08 16:25:07 +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
d6cd79c342 Implement iterators per container type
This introduces the following `for_each` functions:

* root_for_each_workspace
* root_for_each_container
* output_for_each_workspace
* output_for_each_container
* workspace_for_each_container

And introduces the following `find` functions:

* root_find_output
* root_find_workspace
* root_find_container
* output_find_workspace
* output_find_container
* workspace_find_container
* container_find_child

And removes the following functions:

* container_descendants
* container_for_each_descendant
* container_find

This change is preparing the way for demoting sway_container. Eventually
these functions will accept and return sway_outputs, sway_workspaces and
sway_containers (meaning a C_CONTAINER or C_VIEW).

This change also makes it easy to handle abnormalities like the
workspace floating list, root's scratchpad list and (once implemented)
root's saved workspaces list for when there's no connected outputs.
2018-08-18 23:38:54 +10:00