Commit Graph

89 Commits

Author SHA1 Message Date
Brian Ashworth 477bca5e28 Terminate swaybg in output_disable
Moves the call to `terminate_swaybg` from inside `apply_output_config` to
`output_disable`. The former was only called when an output was being
disabled. The latter is called when an output is being disabled and when
an output becomes disconnected. Without this, disconnecting an enabled
output would result in a defunct swaybg process.
2018-12-19 09:24:15 +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
Brian Ashworth 9b41db32ec Fix identifier output configs on reload
When generating default output configs to reset the outputs to their
default settings on reload, the output name was being used.
Additionally when determining the output config to apply, if there was
an output config with the output name, that was being used without
checking for an identifier config. This caused sway to completely ignore
the users specified output config.

To fix this issue, the following changes have been made:
1. Default output configs as created for the identifier now instead of
name. This actually makes more sense anyway since you could hotplug
multiple different outputs to the same port.
2. In get_output_config, which is only used to determine which output
config to apply, output configs for both the name and identifier are
queried. If both are found, a new output config is generated with the
identifier config merged on top of the name config. If just one is found,
a copy of that config is returned. This change also requires that the
result from get_output_config be freed after use to prevent memory
leaks, which required some minor changes to logic in
apply_output_config_to_outputs.
2018-12-03 08:51:27 +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
emersion bf7af9c690
Merge pull request #3083 from c-edw/feature/StripWorkspaceName
Implement strip_workspace_name.
2018-11-19 17:56:18 +01:00
Spencer Michaels 70bc4c3ab6 Add scroll factor config option. 2018-11-18 13:49:30 -05:00
Connor E 4bd46fb079 Implement strip_workspace_name. 2018-11-17 16:11:28 +00:00
Connor E eda1bf769f More frees. 2018-11-13 14:42:00 +00:00
Connor E b5d95f264d Add some missing frees. 2018-11-13 13:45:01 +00: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
Brian Ashworth 00745d6280 Fix bar subcommand handler structs and selection 2018-10-13 08:00:01 -04:00
Brian Ashworth d3f0e52784 bar-bindsym: address ianyfan's comments 2018-10-09 08:12:46 -04:00
Brian Ashworth 1c969e86f5 Implement bar bindsym 2018-10-09 08:12:46 -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 41bfd8c790 swaybar: allow null status_command
Sway sets a default status_command which runs date every second. This
patch removes this behaviour so the user can have a NULL status bar if
desired.

I had to swap swaybar's event_loop_poll and wl_display_flush so that it
would map the initial surface.
2018-10-08 22:23:55 +10: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
PP ae2b70f59e add tap-and-drag setting to sway-input 2018-09-29 11:49:41 +02:00
Brian Ashworth af45ee2d8b Handle shell special characters in bg file path
This changes it back so the path given to swaybg is enclosed in quotes.

Additionally, the only character that is escaped in the path stored is
double quotes now. This makes it so we don't need to keep an exhaustive
list of characters that need to be escaped.

The end user will still need to escape these characters in their config
or when passed to swaybg.
2018-09-28 23:12:24 -04:00
Ian Fan a6c5628fa7 input config: merge left_handed option 2018-09-27 09:25:43 +01:00
Brian Ashworth baeb28ea62 Implement support for input wildcard 2018-09-23 19:56:52 -04:00
emersion 82f1393cbb swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
2018-09-20 18:37:51 +02:00
Ian Fan 8e8a5ca217 config: free strings fields when freeing input config 2018-09-19 12:55:49 +01:00
Brian Ashworth c246cf84c8 Call wlr_output_enable on enable/disable if needed 2018-09-05 14:00:00 -04: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
emersion 349d1f3be8 Do not modeset disabled outputs 2018-09-01 18:56:53 +02:00
Drew DeVault 10c2c09cf6
Merge pull request #2513 from RyanDwyer/rename-root-outputs
Rename sway_root.outputs to sway_root.all_outputs
2018-08-26 10:50:02 -04: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 2e7401772e Rename sway_root.outputs to sway_root.all_outputs
This list includes disabled outputs.

When sway_container is demoted, we'll need to store the root's children
(ie. enabled outputs) in the sway_root. It makes sense to put these in a
list called `outputs`, so I'm renaming the existing list in advance.
2018-08-25 23:41:11 +10:00
Ryan Dwyer b6058703fa Refactor destroy functions and save workspaces when there's no outputs
This changes the destroy functions to the following:

* output_begin_destroy
* output_destroy
* workspace_begin_destroy
* workspace_destroy
* container_begin_destroy
* container_destroy
* view_begin_destroy
* view_destroy

The terminology was `destroy` and `free`, and it has been changed to
`begin_destroy` and `destroy` respectively.

When the last output is disconnected, its workspaces will now be stashed
in the root. Upon connection of a new output they will be restored.

There is a new function `workspace_consider_destroy` which decides
whether the given workspace should be destroyed or not (ie. empty and
not visible).

Calling container_begin_destroy will no longer automatically reap the
parents. In some places we want to reap the parents and in some we
don't, so this is left to the caller.

container_reap_empty_recursive and container_reap_empty have been
combined into one function and it will recurse up the tree.
2018-08-24 22:17:28 +10:00
Brian Ashworth 43d1ffc9dd Allow a fallback color to be specified for swaybg
This allows for a color to be set when the wallpaper does not fill the
entire output. If specified, the fallback color is also used when the
image path is inaccessible.
2018-08-08 15:37:06 -04:00
Marien Zwart 7d8413d962 Reset signal mask after fork
wlroots uses wl_event_loop_add_signal to handle SIGUSR1 from Xwayland.
wl_event_loop_add_signal works by masking the signal and receiving it from a
signalfd. The signal mask is preserved across fork and exec, so subprocesses
spawned by Sway start with SIGUSR1 masked. Most subprocesses do not expect this
and never unmask the signal, resulting in missing functionality or unexpected
behavior for processes that use SIGUSR1 (such as i3status).

Fix this by unmasking all signals between fork and exec.
2018-08-02 21:31:34 +10:00
ProgAndy 2166dbe2e4 Implement setting NumLock and CapsLock status
After setting the keymap, try to enable NumLock and disable CapsLock.
This only works if sway has the xkb master state and controls the keyboard.
Prepare configuration settings for later use as well.
2018-07-25 17:24:45 +02:00
Brian Ashworth bc7d332109 Reset outputs on reload 2018-07-20 22:17:20 -04:00
Brian Ashworth 9605ab45f1 Fix output wildcard handling 2018-07-20 12:32:29 -04:00
Ian Fan 9559e3e2af config output: free command string if unused 2018-07-15 21:51:00 +01:00
Brian Ashworth 13c6627ddb Implement tap_button_map for input devices 2018-07-14 01:01:47 -04:00
Robert Kubosz 08edaf4e76
increase maximum value of button identifier
and also cleanup spaces
2018-07-12 12:08:53 +02:00
Robert Kubosz 41b80c28df
add scroll button option
This commit introduces a scroll_button option, which is intended to be
used with scroll_method. Now user can edit his sway config and add an
scroll_button option to device section.
2018-07-11 22:03:06 +02:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Dominique Martinet 9f5d539657 config: add a couple of forgotten frees 2018-07-05 08:13:10 +09:00
Dominique Martinet 248ea93c1a bar config: fix uninitialized accesses on init error
If init fails halfway through it will call the destroy function,
which needs some coherent stuff filled.
Allocate with calloc and fill in what cannot fail first

Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 9c8fb7d025 invoke_swaybar: fix message length header size
size_t/ssize_t are 8 bytes on 64bit systems, so use the proper size to
transmit that information.
This could lead to ridiculously large alloc as len is not initialized to zero

Found through static analysis
2018-07-02 08:03:41 +09:00
Brian Ashworth a1b5b93d29 Store sway_outputs so that they can be reenabled 2018-06-06 20:11:24 -04:00
Mattias Eriksson 8fbafbfab5 Idle handling for dpms/lockscreen et al
Swayidle handles idle events and allows
for dpms and lockscreen handling. It also
handles systemd sleep events, and can
raise a lockscreen on sleep

Fixes #541
2018-05-13 00:30:09 +02:00
db 22170bde77 Fix layer surface crash on output destroy
Before freeing sway_output, NULL the wlr_output reference to it. Check for that
NULL in layer_shell handle_destroy. Don't damage null container in unmap.
Additionaly, terminate swaybg if its output is being disabled.
2018-05-01 19:05:32 +02:00
Geoff Greer 5587af1782 Rename len to msg_len. Avoids an aliased variable that was a little confusing to follow. 2018-04-26 18:16:29 -07:00