Compare commits

...

3034 Commits

Author SHA1 Message Date
Manuel Stoeckl 40ca4150b2 sway/commands/output: Add command to set color profile
This makes it possible to render output buffers in a different color
space, by specifying an ICC profile for the output.
2024-06-07 19:01:49 +02:00
Violet Purcell 2e9139df66 Update for versioned wlroots files
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4614
2024-05-28 20:21:07 +02:00
Simon Ser d0bd591ee7 Drop server.h include from input/input-manager.h
The only reason it's included there is for a declaration of
struct sway_server, but we can just forward-declare it.

This avoids rebuilding almost all of Sway when touching server.h.
All other server.h includes are from source files, not headers.
2024-05-27 09:28:43 -04:00
Simon Ser df69367d92 input/text_input: ensure keyboard is set before sending modifiers
Clients get confused when modifier events are sent before the
keymap.
2024-05-27 09:27:45 -04:00
Simon Ser 700f4805bc server: hide xdg_output from unprivileged clients
Regular Wayland clients shouldn't care about the position or size
of outputs. Hide xdg_output from unprivileged clients to make sure
they're not doing shenanigans with this information.
2024-05-27 09:27:20 -04:00
thal a168b20299 tree/view: Do not clip to geometry if using CSD
If a floating window is using CSD, the geometry should not be used to
define the clipping region. Otherwise drop shadows and such may be
clipped excessively.
2024-05-24 00:18:44 +02:00
Simon Ser 9704152414 build: drop xwayland option
Instead of having a build-time option to enable/disable xwayland
support, just use the wlroots build config: enable xwayland in
Sway if it was enabled when building wlroots. I don't see any
use-case for disabling xwayland in Sway when enabled in wlroots:
Sway doesn't pull in any additional dependency (just pulls in
dependencies that wlroots already needs). We have a config command
to disable xwayland at runtime anyways.

This makes it so xwayland behaves the same way as other features
such as libinput backend and session support. This also reduces
the build matrix (less combinations of build options).

I think we originally introduced the xwayland option when we didn't
have a good way to figure out the wlroots build config from the
Sway build system.
2024-05-21 11:44:39 -04:00
Anna (navi) Figueiredo Gomes fd3b643d15 sway/config/output.c: fix null deref on output config
If there's no config for the output, oc is null, but some screens might
have a default rotation, causing the log call to dereference a null
pointer.

Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-05-18 16:25:42 +02:00
Simon Ser 796898519b build: disable wayland-protocols subproject tests by default 2024-05-18 13:48:17 +02:00
Manuel Stoeckl dcdb72757a desktop/layer_shell: provide fractional scale on creation
Also, send a matching wl_surface.preferred_buffer_scale event.
2024-05-07 16:18:43 +02:00
Simon Ser 30f5c3a911 tree/container: ensure pixman rect is valid in container_arrange_title_bar()
Fixes "Invalid rectangle passed" errors printed by Pixman.
2024-05-07 16:15:13 +02:00
Alexander Orzechowski b463957021 sway_text_node: Allow 0 text width
special case negative numbers instead.
2024-05-07 16:14:58 +02:00
Kenny Levinsen 2686afb95c config/output: Print output state during tests
Instead of having each search function print its various test decisions,
print the full state at the end of every search. This makes it much
clearer what state a particular test includes.
2024-05-02 16:16:42 +02:00
Kenny Levinsen 4c28916d68 config/output: Search for output config fallbacks
The original sway output config implementation enabled one output at a
time, testing modes, render formats and VRR support as it went along.
While this sort of fallback is easy to do, it has the downside of not
considering the effect of neighbor outputs on the configuration
viability.

With backend-wide commits, we can now better consider the effect of
neighbor outputs, but to handle the fact that we commit all outputs at
once we need to perform a more elaborate search of viable
configurations.

Implement a recursive configuration search for when the primary
configuration failed to apply.
2024-05-02 16:16:42 +02:00
Kenny Levinsen ee5c4f38c9 config/output: Use all outputs for config merge
When storing a config, we need to find the output that is being
configured to extract its identifier. output_by_name_or_id does not
return outputs that are disabled, and using this makes it impossible to
merge configurations related to disabled outputs.

Switch to all_outputs_by_name_or_id.

Fixes: https://github.com/swaywm/sway/issues/8141
2024-05-02 08:44:04 -04:00
Kenny Levinsen 646019cad9 desktop/output: Fix check if config should be stored
We want to check if a config_head existed for the current
matched_output_config, so we should check cfg->output. sway_output is a
temporary variable from a previous wl_list_for_each, and does not
contain anything useful to us.

Fixes: https://github.com/swaywm/sway/issues/8128
2024-04-23 13:31:30 +02:00
Kenny Levinsen ffcde7a70c server: Use wlr_renderer_get_texture_formats
wlr_renderer_get_{dmabuf|shm}_texture_formats have been replaced by a
unified wlr_renderer_get_texture_formats interface using buffer caps.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4644
2024-04-21 17:19:33 +02:00
Simon Ser 087226d997 config/output: drop fast path in store_output_config()
If there is no output currently connected, we still want to merge
to any existing config.

It shouldn't matter to iterate over the list of outputs to do
nothing anwyays.
2024-04-13 00:55:28 +02:00
Simon Ser f11c5d562e config/output: fix NULL derefs in store_output_config()
../sway/config/output.c:33:21: runtime error: member access within null pointer of type 'struct sway_output'
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==7856==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000080 (pc 0x63da8558205c bp 0x7ffdc35881a0 sp 0x7ffdc3588160 T0)
    ==7856==The signal is caused by a READ memory access.
    ==7856==Hint: address points to the zero page.
        #0 0x63da8558205c in output_get_identifier ../sway/config/output.c:33
        #1 0x63da855865c3 in store_output_config ../sway/config/output.c:220
        #2 0x63da855d4066 in cmd_output ../sway/commands/output.c:106
        #3 0x63da8547f2e3 in config_command ../sway/commands.c:425
        #4 0x63da8548f3fc in read_config ../sway/config.c:822
        #5 0x63da8548a224 in load_config ../sway/config.c:435
        #6 0x63da8548b065 in load_main_config ../sway/config.c:507
        #7 0x63da854bee8d in main ../sway/main.c:351
        #8 0x77e2ea643ccf  (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
        #9 0x77e2ea643d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
        #10 0x63da8547ad64 in _start (/home/simon/src/sway/build/sway/sway+0x372d64) (BuildId: 3fa2e8838c1c32713b40aec6b1e84bbe4db5bde8)

Fixes: 1267e47de9 ("config/output: Refactor handling of tiered configs")
2024-04-13 00:55:28 +02:00
Kenny Levinsen 1267e47de9 config/output: Refactor handling of tiered configs
Output configuration can be applied to a particular output in three
ways: As a wildcard, by connector name and by identifier. This in turn
means that three different configurations must be handled at any given
time.

In the current model, this is managed by merging new configuration into
every other matching configuration. At the same time, an additional
synthetic configuration is made which matchehes both identifier and name
at the same time, further complicating logic.

Instead, manage and store each configuration independently and merge
them in order when retrieving configuration for an output. When changes
are made to a less specific configuration, clear these fields from more
specific configurations to allow the change to take effect regardless of
precedence.

Fixes: https://github.com/swaywm/sway/issues/8048
2024-04-12 17:32:26 +02:00
Ferdinand Bachmann bc258a3be2
input: add Super as alternative for Mod4
This PR implements alternative human-readable names for the logo key
(Mod4) as proposed in #8084.
2024-04-05 16:40:28 +02:00
Daniel Kahn Gillmor dcb142bf5e sway-ipc(7): Escape backslashes correctly in GET_CONFIG output
Without this change, i see the following in the sway-ipc manpage:

```

   9. GET_CONFIG
       MESSAGE
       Retrieve the contents of the config that was last loaded

       REPLY
       An object with a single string property containing the contents of  the
       config

       Example Reply:
           {
                "config": "set $mod Mod4nbindsym $mod+q exitn"
           }
```
2024-03-30 01:16:22 +01:00
Simon Ser 9e14651077 input: pass wlr_seat_client to wlr_seat_touch_notify_cancel()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4613
2024-03-28 11:49:20 +01:00
Kenny Levinsen a4ef37752f commands/output/toggle: Use free_output_config 2024-03-28 10:45:20 +01:00
Kenny Levinsen 26a9a6b479 output/config: Remove unused test_output_config 2024-03-28 10:45:20 +01:00
Kenny Levinsen c3fca26d30 config/output: Make merge_output_config static 2024-03-28 10:45:20 +01:00
Kenny Levinsen 9becff0ba5 output/config: Remove reset_outputs and co.
apply_output_config_to_outputs uses the specified output config to check
which outputs to apply to, and to use as backup when no config is found.
If any config matches the output, the specified config will be
disregarded.

The only remaining user of apply_output_config_to_outputs is
reset_outputs, which called apply_output_config_to_outputs with either
the first stored wildcard config, or a new empty wildcard config.

Providing a stored or empty wildcard config is practically the same as
calling `apply_all_output_configs`. Replace uses of `reset_outputs` with
`apply_all_output_configs` and remove the now unused functions.
2024-03-28 10:45:20 +01:00
Kenny Levinsen 56e97b7d60 config/output: Remove apply_output_config 2024-03-28 10:45:20 +01:00
Kenny Levinsen 3b419020a3 desktop/output: Use apply_output_configs for output mgmt 2024-03-28 10:45:20 +01:00
Kenny Levinsen 98be797356 Use apply_all_output_configs to light up outputs
This allows us to test and if necessary degrade the entire backend
configuration to light everything up.
2024-03-28 10:45:20 +01:00
Kenny Levinsen 923f642b70 output/config: Add apply_all_output_configs
Apply all output configs as they are. This differs from
apply_output_config_to_outputs, which tries to apply a specific output
config.
2024-03-28 10:45:20 +01:00
Kenny Levinsen 3e03eb3a01 config/output: Introduce apply_output_configs
Introduce apply_output_configs, which applies the specified matched
output configs as a single backend commit.

Reimplement apply_output_config_to_outputs using apply_output_configs.
2024-03-28 10:45:20 +01:00
Kenny Levinsen e2f3ebad8c config/output: Split apply_output_config
Applying an output config has two stages: Atomic application of
wlr_output_state, and applicaiton of non-atomic state like output
layout.

Split the latter out into finalize_output_config for use in a later
commit.
2024-03-28 10:45:20 +01:00
Ferdinand Bachmann 125c74338a man: document supported modifier names 2024-03-28 10:26:34 +01:00
Andri Yngvason 5a7477cb8f Implement transient seat management 2024-03-18 09:07:21 +01:00
Simon Ser dc9f217307 man: document that the scale might be adjusted
fractional-scale only supports representing fractions of 120.

References: https://github.com/swaywm/sway/issues/8057
2024-03-14 23:22:32 +01:00
Simon Ser 9139da6149 man: drop fractional scale warning
With the fractional-scale protocol, clients can render without
being downscaled.
2024-03-14 23:22:32 +01:00
Simon Ser 3bc75221bc Re-create renderer when lost 2024-03-14 22:55:46 +01:00
Simon Ser 2b08e79061 server: fix wlr_seat use-after-free on exit
Same as [1].

I originally tried to properly handle seat destruction, but that
turned out to be a can of worms [2].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4590
[2]: https://github.com/swaywm/sway/pull/8034
2024-03-14 11:59:25 +01:00
Alexander Orzechowski 2e951163c5 Force bilinear scaling when scaling down 2024-03-09 11:47:42 +01:00
Simon Ser 23389ebd1f config/output: drop enabling flag
This was useful when wlroots backends were updating the current
mode on their own. This is no longer the case.
2024-03-08 09:12:12 -05:00
Simon Ser 3ef5abd405 xdg-shell: send WM capabilities 2024-03-08 09:52:14 +03:00
Simon Ser 4e6d7612ff xdg-shell: implement popup repositioning 2024-03-08 09:52:14 +03:00
Simon Ser f2a0e81b24 Fetch input device vendor/product from libinput
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4582
2024-03-07 09:53:40 -05:00
Simon Ser 59f6292383 config: add fallback without env vars for keysym translation XKB keymap 2024-03-06 11:14:50 -05:00
Simon Ser fd9ab9ee06 config: error out on keysym translation XKB state failure
If we can't create the XKB keymap used for keysym translation,
gracefully error out instead of crashing. This can happen if the
XKB_DEFAULT_LAYOUT is set to an invalid value, for instance.

Closes: https://github.com/swaywm/sway/issues/7789
2024-03-06 11:14:50 -05:00
Ronan Pigott 5e18ed3cf0 commands/move: do not force focus on the moved container
My code archaeology isn't good enough to determine what this is here
for, but it isn't correct. We should be able to move containers in a
direction without focusing them. AFAICT i3 doesn't do this, so we
shouldn't either.

This fixes ipc commands like move <dir> with criteria that apply to
containers which are not the current focus.
2024-03-01 10:13:41 +01:00
Luofan Chen 2058209a13 input: Rename WLR_INPUT_DEVICE_TABLET_TOOL to WLR_INPUT_DEVICE_TABLET
wlroots has changed the naming, causing the following build errors when
building:

error: ‘WLR_INPUT_DEVICE_TABLET_TOOL’ undeclared
2024-03-01 09:53:43 +01:00
llyyr 0b84d82b9a ipc: add `scratchpad_state` property to GET_TREE
See previous commit. This restores ipc parity with i3.
2024-02-29 00:51:43 +01:00
llyyr 2867ef646b ipc: add `floating` property to GET_TREE
i3 has had this property for over a decade but it wasn't documented
until a couple of years ago, so it was likely missed when developing
sway. Add the property to get us closer to ipc parity with i3.
2024-02-29 00:51:43 +01:00
Simon Ser fca8474e9b Convert to new pointer enums
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4575
2024-02-28 14:28:11 -05:00
llyyr 469411d484 text_input: don't destroy scene_node twice 2024-02-28 09:34:25 +01:00
Simon Ser 829c75b9c9 Add release script 2024-02-26 09:02:06 -05:00
Simon Ser fc640d5f6c Define _POSIX_C_SOURCE globally
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2024-02-23 17:43:19 +03:00
Simon Ser 07b0598526 input/text_input: fix dangling listeners 2024-02-23 14:05:52 +01:00
llyyr d6150b6bb0 input/text_input: parent wlr_box may be uninitialized 2024-02-20 16:19:40 +01:00
Access 7c11c463a3
text_input: Implement input-method popups
Co-authored-by: tadeokondrak <me@tadeo.ca>
2024-02-20 10:53:20 +01:00
Aleksei Bavshin d19810eba8 xdg-activation: distinguish activation and urgency requests
Check if the app that requested a token has provided a valid input
serial and a focused surface. Downgrade activation request to urgency
otherwise.

This is mostly in line with what other Wayland compositors decided to
do, and offers a better security than the original logic.
2024-02-17 00:54:30 -07:00
Ronan Pigott f6d22f8e68 launcher: track the seat in the launcher ctx
This is a more suitable place to track the requesting seat, since we are
able to respond appropriately to destroy notifications.
2024-02-17 00:54:30 -07:00
Simon Ser 541e6e260c Drop unnecessary includes from sway/server.h 2024-02-15 15:56:36 +01:00
Simon Ser ca40663d42 Fix build with wlroots DRM backend disabled
The header is not installed by wlroots when the DRM backend is
disabled. We don't need it here, so don't include it.

Closes: https://github.com/swaywm/sway/issues/7943
2024-02-15 09:44:12 -05:00
Kirill Primak 7a2ff7ba81 view: drop ext_foreign_destroy
It's not used and causes a crash when a view is destroyed.
2024-02-12 19:05:13 +01:00
Alexander Orzechowski 09c360d503 layer_shell: Handle popups through popup descriptor
We tried to synchronize layer shell popups with the parent layer shell
on commits, but this is subtly wrong because we would only update
the position for one layer shell that was committed, but not any other
layer that might be affected. By moving handling to the scene descriptor
we can iterate all popups and ensure they are synchronized.
2024-02-12 19:19:22 +03:00
Alexander Orzechowski 1846944f04 xdg_shell: Extract struct for popup descriptor 2024-02-12 19:19:22 +03:00
Alexander Orzechowski 1dc661af17 layer_shell: Arrange popups even if exclusive zone doesn't change 2024-02-12 19:19:22 +03:00
Merlin Lex 1b5515400d ext-foreign-toplevel-list: Implement protocol
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4543
2024-02-12 15:36:44 +01:00
Simon Ser 88b2abf5f2 config: use format_str() instead of hand-rolled snprintf() 2024-02-08 16:11:24 -05:00
Simon Ser 93d391651c commands: make primary_selection a config-only command
It's not possible to switch this at runtime.
2024-02-05 20:54:48 +01:00
Simon Ser f7a0f06dff commands: note how xwayland/primary_selection are reset on reload 2024-02-05 11:07:33 +01:00
Simon Ser ecfef1348a commands/primary_selection: drop duplicate bool parsing 2024-02-05 11:06:24 +01:00
Violet Purcell 6b2aa83246 sway/config.c: only reset primary_selection at launch
Otherwise, an error will be shown whenever reloading due to the value of
primary_selection being reset to true.
2024-02-05 11:04:36 +01:00
Simon Ser 88e99fa84f Drop old security config remnants 2024-02-03 23:00:52 +01:00
Alexander Orzechowski ba427a469a Ensure get_text_width() returns a positive value
Closes: https://github.com/swaywm/sway/issues/7940
2024-02-02 00:54:26 +01:00
Tamino Bauknecht c8676fad54 sway/output: Improve logging of swaybg execvp failure and more checks
This doesn't catch the error if a background changing command is
executed via swaymsg, but improves logging.
The additional checks at least propagate if e.g. forking failed.
2024-01-29 14:12:39 +01:00
Simon Ser e39b0b816b build: bump version to 1.10-dev 2024-01-26 15:25:14 +01:00
Kirill Primak f202bc84d2 Chase wlroots!4443 2024-01-25 16:13:33 +01:00
Kirill Primak a4e85332a1 Chase wlroots!4003 2024-01-23 10:45:58 +01:00
Alexander Orzechowski e8c421e917 layer_shell: Fix typo of return instead of continue
Otherwise we would skip arranging the rest of the surfaces if one of them
isn't initialized.
2024-01-21 22:01:35 +01:00
Daniel De Graaf 2c2625acd3 Fix SIGSEGV on output destroy
```
Program terminated with signal SIGSEGV, Segmentation fault.
144                             struct wlr_layer_surface_v1 *layer_surface = surface->layer_surface;
[Current thread is 1 (Thread 0x7f1f7c5b3ac0 (LWP 2473))]
(gdb) bt
```

Add a NULL check in `find_mapped_layer_by_client` like the one in `arrange_surface`.
2024-01-21 17:32:00 +03:00
Simon Ser 08a06a7b6b Add debug flag to re-enable wl_drm
7e69a7076f ("Drop wl_drm") has dropped wl_drm, however a lot of
software wasn't quite ready for this (Xwayland, libva, amdvlk).
Keep wl_drm disabled by default to pressure the wl_drm phase-out,
but add a -Dlegacy-wl-drm flag for users to restore the previous
behavior in the meantime.

References: https://github.com/swaywm/sway/issues/7897
2024-01-20 14:42:58 -05:00
Simon Ser ae33f4eb37 Clarify gdk-pixbuf dependency purpose
swaybg is out-of-tree so not relevant here. swaybar's tray doesn't
actually depend on gdk-pixbuf, but gdk-pixbuf enables more image
formats for swaybar tray when available.

Closes: https://github.com/swaywm/sway/issues/7913
2024-01-19 12:22:55 +01:00
Alexander Orzechowski 5fc85c5066 scene_graph: port wlr_forgein_toplevel_management output enter/leave events 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 7c635b61fe remove damage debug options
Now that we use wlr_scene, wlroots handles these. If available use
the wlroots debug options instead.
2024-01-18 18:36:54 +03:00
Alexander Orzechowski bab6b79af2 Fix SIGSEGV on surface destroy
```
Program terminated with signal SIGSEGV, Segmentation fault.

warning: Section `.reg-xstate/3960717' in core file too small.
0  container_get_siblings (container=0x55bcde4797f0) at ../sway/tree/container.c:1228
1228		if (list_find(container->pending.workspace->tiling, container) != -1) {
[Current thread is 1 (Thread 0x7fa23b4a2940 (LWP 3960717))]
(gdb) bt full=
No symbol "full" in current context.
(gdb) bt full
0  container_get_siblings (container=0x55bcde4797f0) at ../sway/tree/container.c:1228
1  0x000055bcdb62c704 in edge_is_external (cont=0x55bcde4797f0, edge=(WLR_EDGE_TOP | WLR_EDGE_LEFT))
    at ../sway/input/seatop_default.c:54
        siblings = 0x55bcde4797f0
        index = 32766
        layout = L_NONE
        __PRETTY_FUNCTION__ = "edge_is_external"
2  0x000055bcdb62c96f in find_resize_edge (cont=0x55bcde4797f0, surface=0x0, cursor=0x55bcddd5c2e0)
    at ../sway/input/seatop_default.c:106
        edge = (WLR_EDGE_TOP | WLR_EDGE_LEFT)
3  0x000055bcdb620b3c in cursor_update_image (cursor=0x55bcddd5c2e0, node=0x55bcde4797f0) at ../sway/input/cursor.c:144
        edge = WLR_EDGE_NONE
4  0x000055bcdb62eb8f in handle_rebase (seat=0x55bcddd5a740, time_msec=488992944) at ../sway/input/seatop_default.c:773
        e = 0x55bcddd5c8e0
        cursor = 0x55bcddd5c2e0
        surface = 0x0
        sx = 0
        sy = 0
5  0x000055bcdb62c531 in seatop_rebase (seat=0x55bcddd5a740, time_msec=488992944) at ../sway/input/seat.c:1585
6  0x000055bcdb620a7d in cursor_rebase (cursor=0x55bcddd5c2e0) at ../sway/input/cursor.c:126
        time_msec = 488992944
7  0x000055bcdb620ac4 in cursor_rebase_all () at ../sway/input/cursor.c:136
        seat = 0x55bcddd5a740
8  0x000055bcdb61cc95 in transaction_apply (transaction=0x55bcde5b28c0) at ../sway/desktop/transaction.c:704
9  0x000055bcdb61ccdb in transaction_progress () at ../sway/desktop/transaction.c:716
10 0x000055bcdb61d1f9 in transaction_commit_pending () at ../sway/desktop/transaction.c:836
        transaction = 0x55bcde5b28c0
11 0x000055bcdb61d596 in _transaction_commit_dirty (server_request=true) at ../sway/desktop/transaction.c:912
12 0x000055bcdb61d5ac in transaction_commit_dirty () at ../sway/desktop/transaction.c:916
13 0x000055bcdb65f579 in view_unmap (view=0x55bcde2ff180) at ../sway/tree/view.c:847
        parent = 0x55bcde489010
        ws = 0x55bcdde19080
        seat = 0x55bcddd5a198
14 0x000055bcdb61e461 in handle_unmap (listener=0x55bcde2ff368, data=0x0) at ../sway/desktop/xdg_shell.c:394
        xdg_shell_view = 0x55bcde2ff180
        view = 0x55bcde2ff180
        __PRETTY_FUNCTION__ = "handle_unmap"
15 0x00007fa23c4ae87f in wlr_signal_emit_safe (signal=0x55bcde46cf38, data=0x0) at ../util/signal.c:29
        pos = 0x55bcde2ff368
        l = 0x55bcde2ff368
        cursor = {link = {prev = 0x55bcde2ff368, next = 0x7ffe240702a0}, notify = 0x7fa23c4ae7c9 <handle_noop>}
        end = {link = {prev = 0x7ffe24070280, next = 0x55bcde46cf38}, notify = 0x7fa23c4ae7c9 <handle_noop>}
16 0x00007fa23c47c3c7 in unmap_xdg_surface (surface=0x55bcde46ce30) at ../types/xdg_shell/wlr_xdg_surface.c:40
        __PRETTY_FUNCTION__ = "unmap_xdg_surface"
        popup = 0x55bcde46ce60
        popup_tmp = 0x55bcde46ce60
        configure = 0x7ffe24070360
        tmp = 0x55bcde488020
17 0x00007fa23c47cd47 in xdg_surface_role_precommit (wlr_surface=0x55bcde488020, state=0x55bcde4881a8)
    at ../types/xdg_shell/wlr_xdg_surface.c:330
        surface = 0x55bcde46ce30
18 0x00007fa23c4813b2 in surface_commit_state (surface=0x55bcde488020, next=0x55bcde4881a8) at ../types/wlr_compositor.c:407
        __PRETTY_FUNCTION__ = "surface_commit_state"
        invalid_buffer = false
        subsurface = 0xbd8e9aecae023300
--Type <RET> for more, q to quit, c to continue without paging--
19 0x00007fa23c48192a in surface_handle_commit (client=0x55bcde488850, resource=0x55bcde2fdb80) at ../types/wlr_compositor.c:523
        surface = 0x55bcde488020
20 0x00007fa23bb5ed4a in  () at /usr/lib/libffi.so.8
21 0x00007fa23bb5e267 in  () at /usr/lib/libffi.so.8
22 0x00007fa23c517323 in  () at /usr/lib/libwayland-server.so.0
23 0x00007fa23c5125cc in  () at /usr/lib/libwayland-server.so.0
24 0x00007fa23c5151ca in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
25 0x00007fa23c512d37 in wl_display_run () at /usr/lib/libwayland-server.so.0
26 0x000055bcdb616885 in server_run (server=0x55bcdb68c5c0 <server>) at ../sway/server.c:307
27 0x000055bcdb61594e in main (argc=3, argv=0x7ffe24070af8) at ../sway/main.c:433
```

It seems to be happening because of this set of events all happening
in the span of a single transaction:
1. You kill a tiled window that is the only window in a workplace.
2. Sway will destroy the workspace but not yet the container - this
   makes `con->pending.workspace` NULL.
3. Cursor glyphs get recomputed causing sway to recompute if the cursor
   is on a container edge. 
4. That computation causes an access to the NULL workspace. Crash.
2024-01-18 18:36:54 +03:00
Alexander Orzechowski 9da295c11f scene_graph: Implement toplevel clipping 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 09e11dabb2 scene_graph: Port opacity and filter modes 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 2e53de80bb scene_graph: Arrange scene graph on transaction apply 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 5f0801b6f2 container: Don't track outputs
The scene graph abstraction does this for us
2024-01-18 18:36:54 +03:00
Alexander Orzechowski 1e018e72b4 Delete old damage tracking code
The new scene graph abstraction handles this for us.
2024-01-18 18:36:54 +03:00
Alexander Orzechowski 06ad734e70 scene_graph: Port view saved buffers 2024-01-18 18:36:54 +03:00
Alexander Orzechowski ed2724bd6c xwayland: Cleanup geometry handling on commit
Instead of doing this roundabout thing where we get the surface from the
view, let's instead get it from the `wlr_surface_state` that we already
track in `handle_commit`. This makes the NULL state impossible which is
what the old `get_geometry` is checking for and generally cleans
things up a little bit.

Also don't check if the geometry x/y changed, those will always
be 0 for xwayland.
2024-01-18 18:36:54 +03:00
Alexander Orzechowski 6e5fc4c2aa scene_graph: Port xwayland 2024-01-18 18:36:54 +03:00
Alexander Orzechowski b38ed8b479 scene_graph: Port xdg_shell 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 08c484f46f transaction: ready signals will return success bools 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 6d7b1321db scene_graph: Port container server side decorations 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 188811f808 scene_graph: Port layer_shell 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 5b8b505af5 input: Query scene graph for relevant surface/node intersections 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 946fc80945 Introduce sway_text_node
This is a helper on top of a wlr_scene_buffer that will handle text
rendering for us.
2024-01-18 18:36:54 +03:00
Alexander Orzechowski 869baff252 renderer: Remove in favor of scene_graph 2024-01-18 18:36:54 +03:00
Alexander Orzechowski bac3ab5526 seat: Remove dead seatop_render function 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 9a57966606 scene_graph: Port ext_session_v1 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 0639bde9fb scene_graph: Port seatop_move_tiling indicators 2024-01-18 18:36:54 +03:00
Alexander Orzechowski c640c3015f scene_graph: Port seat drag icons 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 9c17cba0b2 renderer: Render scene_graph 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 0e1a02bf0a scene_graph: Introduce sway_scene_descriptor
Across a wayland compositor, there are multiple shells: It can be
a toplevel, or a layer_shell, or even something more meta like a drag
icon or highlight indicators when dragging windows around.

This object lets us store values that represent these modes of operation
and keep track of what object is being represented.
2024-01-18 18:36:54 +03:00
Alexander Orzechowski 1b09238645 scene_graph: Use built-in linux dmabuf feedback handling 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 1eb16d1367 scene_graph: Maintain `wlr_scene_node`s for the sway tree. 2024-01-18 18:36:54 +03:00
Alexander Orzechowski dbd2fbf430 view: init function should return a success bool 2024-01-18 18:36:54 +03:00
Alexander Orzechowski b4d7e84d38 desktop: Rename layers to shell_layers
This code will be deleted later, but for the time being rename
it so it doesn't conflict with future properties.
2024-01-18 18:36:54 +03:00
Kirill Primak 2c69e19fd3 layer-shell: don't configure uninitialized surfaces 2024-01-17 16:54:37 +01:00
Kirill Primak 8d1b0cecd9 layer-shell: wait for an initial commit before configuring 2024-01-17 16:54:37 +01:00
Kirill Primak 904d256581 layer-shell: don't try to unmap on destroy
A surface is guaranteed to be unmapped on destruction.
2024-01-17 16:54:37 +01:00
Simon Ser c5fd8c050f Mark DRM lease protocol privileged
Allowing sandboxed clients to request DRM leases has security
implications.
2024-01-08 11:17:26 -05:00
Simon Ser 7e69a7076f Drop wl_drm
See https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4397
2024-01-04 08:21:33 +01:00
Simon Ser fa294a9094 readme: add swaybg as optional dep 2024-01-02 14:08:18 +01:00
Simon Ser 95265fba59 input: reconfigure send_events on output hotplug
Closes: https://github.com/swaywm/sway/issues/7890
2024-01-02 14:07:35 +01:00
Billli11 0aceff7469
Remove wlr_presentation in sway_server struct
It is no longer in use.
2023-12-28 11:28:28 +01:00
Bill Li 64d644f0da Chase wlroots!4482 2023-12-27 20:57:35 +01:00
Simon Ser 22d0dd8bde Check wlr_pointer_constraint_v1_state.cursor_hint.enabled
Update for a wlroots breaking change which resets the committed
mask.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4478
2023-12-25 11:57:30 +01:00
Alexander Orzechowski bbabb9aae8 output: Destroy when output layout is destroyed
Since output layout is destroyed when the wayland display is destroyed
we run into a destroy listener order problem: Either the display starts
destroying the outputs first, in which case we're good: The existing
handling will clean up. However, things go wrong if the display decides
to destroy the output layout first. In this case, sway will hold
invalid references to the output layout as part of each output so that
when it finally goes to destroy them, sway will dereference destroyed
output layout bits.

Ref: https://github.com/swaywm/sway/pull/6844#issuecomment-1843599513
2023-12-13 18:10:03 +01:00
Simon Ser c6edbb7e5a input/seat: simplify seat_is_input_allowed()
Use an early return to make the code more readable.
2023-12-13 10:11:35 +01:00
Simon Ser e8a0205607 input/seat: rename seat_set_exclusive_client() 2023-12-13 10:11:35 +01:00
Simon Ser 607b8aed0c input/seat: inline seat_set_exclusive_client() with NULL client 2023-12-13 10:11:35 +01:00
Simon Ser 7ad8c80bfe input/{keyboard,switch}: rename input_inhibited variable to locked
This is more descriptive now.
2023-12-13 10:11:35 +01:00
Simon Ser dbd70faf2e input/seat: drop exclusive_client
This was a input-inhibit concept.
2023-12-13 10:11:35 +01:00
Simon Ser a6ef12d968 Detect proprietary DisplayLink drivers
evdi is open-source, but is just some condom for their proprietary
user-space driver.
2023-12-12 10:04:14 -05:00
Simon Ser ff07eab85b Detect Nvidia proprietary driver via drmGetVersion()
This is less punishing for users with the Nvidia driver loaded but
not used by Sway (e.g. for CUDA).
2023-12-12 10:04:14 -05:00
Simon Ser b81c4da494 Drop fglrx detection
This ancient driver doesn't do KMS. So we were never able to run
with it anyways.
2023-12-12 10:04:14 -05:00
Tamino Bauknecht 255ff665c5 sway: raise error on non-accessible background file 2023-12-12 09:39:46 -05:00
Simon Ser bf2b79b284 desktop/xwayland: correctly handle association on o-r change
When override-redirect changes, we need to setup/teardown listeners,
just like we do for map.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3773
2023-12-06 23:24:44 +03:00
mrusme ae3acf26f8 Update sway.5.scd
Make it extra extra extra clear, because I had to stumbled upon https://github.com/swaywm/sway/issues/3292 to understand this.
2023-12-04 16:30:20 +01:00
Alexander Orzechowski f12023b1a2 Don't destroy output layout on exit
wlroots will destroy this object itself.
2023-12-01 09:11:20 +01:00
Sergei Trofimovich 2cd73a33c2 sway/config.c: use `memcpy()` for known buffer size
`gcc-14` added a new warning around dangerous use of `strncpy()` withi
known overflow:

    ../sway/config.c: In function 'do_var_replacement':
    ../sway/config.c:983:33: error: '__builtin___strncpy_chk' specified bound depends on the length of the source argument [-Werror=stringop-truncation]
      983 |                                 strncpy(newptr, var->value, vvlen);
          |                                 ^
    ../sway/config.c:971:45: note: length computed here
      971 |                                 int vvlen = strlen(var->value);
          |                                             ^~~~~~~~~~~~~~~~~~

It's a bit fishy to rely on truncating behaviour of `strncpy()`. The
change uses `memcpy()` as more explicit way to express copy of `vvlen`
bytes.
2023-11-29 10:30:17 +01:00
apreiml bc7d15d64d Update README.de.md to match the EN one 2023-11-24 12:10:47 +01:00
Manuel Stoeckl e633fe0b40 common: move load_image to swaybar
swaynag, swaymsg, and sway do not use this function and are
unlikely to in the future.
2023-11-23 20:42:04 +01:00
Manuel Stoeckl 439122e887 common: rename load_background_image to load_image 2023-11-23 20:42:04 +01:00
Manuel Stoeckl 39b9c0d6ba common: Drop unused render_background_image
And the associated background_mode enum.
2023-11-23 20:42:04 +01:00
Kirill Primak 47e6a1164c xdg-shell: chase events update 2023-11-23 19:41:57 +01:00
Simon Ser 128b6253a9 Pass wl_display to wlr_output_layout
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4310
2023-11-23 16:13:19 +03:00
Simon Ser fd6d6f1d97 Add wlr/util/transform.h includes
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4097
Closes: https://github.com/swaywm/sway/issues/7830
2023-11-23 16:13:19 +03:00
llyyr a946b1aecf Chase wlroots!4440
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4440
2023-11-22 00:42:55 +03:00
llyyr 4ad15a4015 meson: bump wlroots version after 0.17.0 release 2023-11-22 00:42:55 +03:00
Matt Fellenz bff991dfdc Use locale time format for default bar command 2023-11-21 17:42:09 +01:00
Simon Ser 9d666a08e1 Fix reference to wlr_output_event_commit.committed
This has been dropped from wlroots. Previous commit missed that.
2023-11-21 16:52:19 +01:00
Simon Ser 072fa60cb4 Add support for security-context-v1
As a first step, deny access to privileged protocols to sandboxed
apps.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3589
2023-11-21 15:12:42 +01:00
Simon Ser 5bdd608514 Apply gamma LUT when an output re-enabled
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3679
2023-11-21 15:05:58 +01:00
EBADBEEF 86f96a786b view: re-apply criteria when window gets unmapped
Remove any existing executed criteria items at unmap time. If a window
gets unmapped but not destroyed, we want to reapply 'for_window'
criteria. Fixes #6905.
2023-11-21 14:57:58 +01:00
NemuiBanila c3ec141b34 seat: Fix cursor theme reload for tablet tool 2023-11-21 11:35:49 +01:00
Lina Banik f7a40cfa2f seat: Fix reloading cursor theme after change
This reverts commit afde6369
"seat: avoid unneeded reloading xcursor theme".
Always avoiding to reload the xcursor theme prevents reloading the
cursor even when this is desired. Instead seat_configure_xcursor
can determine whether a full reload is necessary.

To stay with the spirit of the reverted change, cursors are only fully
reloaded, if the theme has changed.

Fixes #6931
2023-11-21 11:35:49 +01:00
Simon Ser 5c99b98805 input/input-manager: drop input_manager_configure_all_inputs
This is now unused.
2023-11-16 16:29:07 +01:00
Simon Ser 7036769bea Only reconfigure input mappings on output change
Fully reconfiguring all input devices on output change takes a
loooong time. Let's just reconfigure what we need: only mappings
depend on outputs.
2023-11-16 16:29:07 +01:00
Simon Ser caa92ddee8 input/seat: rename seat_apply_input_config
seat_apply_input_mapping is a lot more descriptive.
2023-11-16 16:29:07 +01:00
Simon Ser 01dcad80e1 input/seat: don't configure mappings for switches
Switch devices cannot be mapped to an output/region, stop trying
to do so.
2023-11-16 16:29:07 +01:00
Sergei Trofimovich 020a572ed6 swaynag/config.c: fix build against gcc-14 (-Walloc-size)
`gcc-14` added a new `-Walloc-size` warning that makes sure that size of
an individual element matches size of a pointed type:

        https://gcc.gnu.org/PR71219

`sway` triggers it on `calloc()` calls where member size is used as
`1` (instead of member count):

    swaynag/config.c:169:65: error: allocation of insufficient size '1'
     for type 'struct swaynag_button' with size '48' [-Werror=alloc-size]
      169 | struct swaynag_button *button = calloc(sizeof(struct swaynag_button), 1);
2023-11-03 13:25:27 +01:00
Bill Li 6f6b82793d chase wlroots!4411
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4411
    fix #7802
2023-10-31 09:51:19 +01:00
Kirill Primak f2425b4fd6 xdg-shell: send maximized if tiled isn't supported
wlroots doesn't do it automatically anymore.
2023-10-29 17:21:18 +01:00
Dudemanguy 647521244a xdg_shell: don't update wlr_toplevel if the container has no size yet
3d5ae9813d added logic to change the
underlying wlr_toplevel size for floating containers, but it does it
even if the container has no actual coordinates yet. This doesn't really
make sense to update the toplevel size in this case since there's many
things that could affect the initial coordinates (sway commands,
fullscreen state, etc.). Skip this by doing a crude check to see if the
current container state has any width.
2023-10-27 17:36:32 -07:00
Kirill Primak 47263aca28 view: check if the buffer was uploaded on save
wlr_surface_has_buffer() is insufficient; if a client has committed a
buffer but it couldn't be applied, NULL deref happens in the next line.
2023-10-24 14:35:57 +02:00
Tamino Bauknecht 0dfaf7ea63 config/output: Allow approximation of output refresh rate
Previous behavior was that only if resolution and refresh rate match
exactly, the mode was accepted. As fallback, the mode with the highest
refresh rate and the same resolution was chosen.

New behavior is that the mode with the closest match for the refresh
rate is used with a limit of up to 1Hz. The fallback behavior stays the same.

Additionally, the logging was made more verbose.
2023-10-23 11:05:08 +02:00
Tamino Bauknecht f2425b5163 gitignore: Ignore clangd-generated directory .cache/ 2023-10-23 11:05:08 +02:00
Alexander Orzechowski 4326a26ad6 Chase wlroots!4331 2023-10-06 14:39:12 +03:00
iff 8a8fb76ec1 Update sway-input.5.scd 2023-10-05 10:04:32 +02:00
Simon Ser 7cf4e1d5c6 Drop support for KDE's idle protocol
We support the standard idle-notify protocol since Sway 1.8.
2023-10-05 00:01:54 +02:00
Ashraf b3519c2d2f Translate README to Arabic 2023-09-14 13:37:50 +02:00
Jan Beich 68caa8deba readme: Stop recommending setuid bit for non-logind systems
- Optional since Sway 1.6 per swaywm/wlroots@bad1e9afa8
- Deprecated in Sway 1.7 per 67d3d952b6
- Removed in Sway 1.8 per e5728052b5
- Ignored in future versions (keeps root priveleges)
2023-09-13 10:21:59 +02:00
Manuel Stoeckl 8edc48f6dd sway/server: Fix null pointer crash when Xwayland disabled 2023-09-10 08:33:10 +09:00
Johan Sköld d952ce403e i3 compat: Adding support for the `all` criteria
Matches all views. i3 PR: https://github.com/i3/i3/pull/4460

Fixes #7110
2023-09-07 10:42:54 +09:00
iff 3dd2f4a67f
commands/input/map_from_region: don't treat 0x prefix as hex identifier
When using the `map_from_region` for pen tables, we will usually make
the available area as big as possible while maintaining the proportions
with the screen.

As most of the tablets uses a 16:10 ratios while the most popular screen
ratios is still 16:9, the argument for most people should be `0x0 1x0.9`
to have the maximum effective area.

However, the argument above won't work because the current code will
treat `0x...` as a hexadecimal number, instead of setting both `x` and
`y` to `0`.

This fix allows the use of the following syntax:

```
input type:tablet_tool {
	map_from_region 0x0 1x0.9
}
```
2023-09-07 01:31:35 +00:00
denppa 89f8531268
build: fix build with wayland-scanner subproject 2023-08-30 23:57:25 +09:00
Dudemanguy 3d5ae9813d xdg_shell: update wlr_toplevel size on client resizes
If a floating client resizes itself, sway updates several of its
internal dimensions to match but not wlr_toplevel. This means that the
next time wlroots sends a toplevel configure event, it can have wrong
coordinates that resize the client back to its old size. To fix this,
let's just use wlr_xdg_toplevel_set_size so the wlr_toplevel has the
same dimensions as sway.

Exactly the same as 0183b9d35d but the
logic is onlly applied to xdg_shell and not xwayland.
2023-08-28 17:04:53 -07:00
Dudemanguy 60a94b4916 Revert "view: update wlr_toplevel size on client resizes"
This isn't the right fix for this issue because the xwayland code also
uses this function and updating the wlr_toplevel there doesn't make
sense and also causes problems. Fixes #7722.

This reverts commit bf44690ee8.
2023-08-28 17:04:53 -07:00
Dudemanguy bf44690ee8 view: update wlr_toplevel size on client resizes
If a floating client resizes itself, sway updates several of its
internal dimensions to match but not wlr_toplevel. This means that the
next time wlroots sends a toplevel configure event, it can have wrong
coordinates that resize the client back to its old size. To fix this,
let's just use wlr_xdg_toplevel_set_size so the wlr_toplevel has the
same dimensions as sway. Fixes #5266.
2023-08-26 13:44:37 -07:00
Simon Ser 4a2210577c Hide xwayland_shell_v1 from regular clients
Regular clients are not allowed to use this interface. wlroots
already sends a protocol error if a non-Xwayland client tries to
use this interface, but let's remove all temptation by hiding it
completely.
2023-08-24 18:27:22 +02:00
luzpaz d84b3832f4 Fix typo 2023-08-23 20:18:13 +02:00
Kirill Primak a908651821 chore: chase wlroots xdg-surface role rework 2023-08-21 18:41:32 +02:00
Leonardo Hernández Hernández 363c57984d chase wlroots!4316
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4316
2023-08-19 21:06:26 -07:00
Simon Ser bb91b7f5fa Move contrib/ to separate repository
User-contributed scripts are being moved over to this repository:
https://github.com/OctopusET/sway-contrib
2023-08-02 17:18:38 +02:00
ookami eebbecc780 Rebase all cursors in handle_surface_map
Fix swaylock showing transient cursor after locked.
2023-07-31 21:00:20 +02:00
Simon Ser f8ddd97e0e output: drop current_mode
This is now unused.
2023-07-31 16:25:01 +02:00
Simon Ser 170598d71b desktop/output: fix output manager enabled state
With recent wlroots changes, backends which don't support output
modes can now support being disabled.

We were always marking mode-less outputs as disabled. Stop doing
that, check whether the output takes up some space in the layout
instead.
2023-07-31 16:25:01 +02:00
Simon Ser d3626efe5e desktop/output: drop handle_mode()
We already perform the exact same logic on transform/scale change.
2023-07-31 16:25:01 +02:00
Simon Ser d557b6876b desktop/output: drop logic to handle backend-applied mode
The wlroots backends no longer magically apply output modes behind
the compositor's back.
2023-07-31 16:25:01 +02:00
Alexander Orzechowski df8aad9c5a swaynag: Implement wp_cursor_shape_v1 2023-07-31 10:34:11 +02:00
Alexander Orzechowski f436de9200 swaybar: Implement wp_cursor_shape_v1 2023-07-31 10:34:11 +02:00
Simon Ser 6bd11ad0df Add support for cursor-shape-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4106
2023-07-24 11:28:31 +02:00
bretello dc634c4a13 fix crash when resizing tiled scratchpad windows
Splitting and then hiding a scratchpad container results in
a segfault.

fixes #6693
2023-07-23 11:10:26 -07:00
Nick Kipshidze c3e6390073 Add Georgian README
I am a native Georgian speaker.

I have translated sway's README.md
2023-07-20 08:36:29 +02:00
Simon Ser ee4637b086 Deprecate seat idle_wake
Sway has two knobs to control idling:

- seat idle_inhibit: when the seat is active (ie. not idle), this
  extends the active state. When the seat is idle, this is
  ignored.
- seat idle_wake: when the seat is idle, this wakes up the seat.
  When the seat is active, this is ignored.

The motivation for the deprecation is two-fold:

- The concept of "seat idle state" is ill-defined. Each idle-notify-v1
  client will pass a different idle timeout. With the old logic, a
  seat was declared idle if and only if all idle-notify-v1 timeouts have
  expired. However, if only a portion of the timeouts have expired,
  then some clients would wake up, and the rest would stay active.
  This is inconsistent with the definition of idle_inhibit/idle_wake:
  idle_inhibit was used for clients which are waking up.
- It never worked properly with the new idle-notify-v1 protocol
  and no-one noticed. Only the legacy KDE idle protocol is taken
  into account, but that protocol is not used anymore.
2023-07-19 09:28:33 +02:00
Simon Ser a34d785a26 swaynag: handle wayland-cursor failures
Same as 92244c87db ("swaybar: handle wayland-cursor failures")
but for swaynag.

Closes: https://github.com/swaywm/sway/issues/7671
2023-07-17 10:01:46 +02:00
Artturin 9107907969 chase wlroots 'presentation-time: add separate helper for zero-copy '
67447d6cb4
2023-07-15 15:21:35 +02:00
nukoseer 6c234d013a Calculate tiled resize amount relative to parent container
sway should shrinks/grows tiled windows according to parent container
for ppt unit for i3 compatibility.

Resolves: #7593
2023-07-13 13:27:46 -07:00
Simon Ser fc16fb6549 Send wl_surface.preferred_buffer_scale
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3696
2023-07-12 09:59:00 +02:00
Manuel Stoeckl 92244c87db swaybar: handle wayland-cursor failures
Updating the cursor is not essential, so this change prints
a warning when wl_cursor_theme_load or wl_cursor_theme_get_cursor
fail instead of crashing or exiting.
2023-07-08 09:36:50 +02:00
llyyr 20ffe545ba swaybar: don't set current workspace as not visible
When `wrap_scroll yes` is configured and there's only one workspace
open, swaybar will mark it as not visible if the user scrolls on it and
eventually incorrectly fail the `active->visible` assert.
Fix this by making sure that new and current workspace aren't the same.
2023-06-27 14:40:57 -07:00
Mark Bolhuis 20c91335f6 input: Move wlr_pointer_gestures_v1 to sway_input_manager
On multi-seat configurations a zwp_pointer_gestures_v1 global was
created for every seat.

Instead, create the global once in the input manager, to be shared
across all seats.
2023-06-26 22:57:46 +02:00
Simon Ser 974a8629a8 Use "default" XCursor instead of "left_ptr"
"left_ptr" is the legacy XCursor name. "default" is the cursor
spec name.
2023-06-25 22:38:10 +02:00
Hodong 7fbd9fbf28
swaybar: remove the argument of StatusNotifierHostRegistered
According to
https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierWatcher/
there is no argument for the StatusNotifierHostRegistered signal.
2023-06-23 17:54:08 +02:00
Simon Ser b762f455d9 idle-inhibit-v1: simplify with server global
We only have a single running server, no need to keep track of
multiple server instances. Also no need to support multiple
idle inhibit managers.
2023-06-23 12:32:38 +02:00
Simon Ser 5411ed4ef0 Use wlr_cursor_unset_image()
A bit cleaner.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4209
2023-06-19 19:48:53 +02:00
Simon Ser 6f1a3b6652 Use wlr_cursor_set_xcursor()
wlr_xcursor_manager_set_cursor_image() is deprecated.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4170
2023-06-19 19:48:53 +02:00
Alexander Orzechowski 876687000d render: Use wlroots scale filter 2023-06-19 19:14:28 +02:00
Cezary Drożak c08762901e input/libinput: add scroll_button_lock method
Closes https://github.com/swaywm/sway/issues/6987

Co-authored-by: JJGadgets <git@jjgadgets.tech>
Co-authored-by: DeltaWhy <mike5713@gmail.com>
2023-06-16 15:30:04 +02:00
Rouven Czerwinski 8b4b65d665 gamma_control_v1: handle destroyed output
In case a display is unplugged, the sway output may be removed from the
userdata before the gamma_control can be reset. In this case we can't
schedule a commit on the output, simply return within the function.

backtrace full:

  #0  handle_gamma_control_set_gamma (listener=0x4856a8 <server+616>, data=0x7ffce1ed59c0) at ../sway/desktop/output.c:1105
          server = 0x485440 <server>
          event = 0x7ffce1ed59c0
          output = 0x0
  #1  0x00007f430d1dca0c in wl_signal_emit_mutable ()
     from /nix/store/ky1g6ylzr2m4bq8fy0gzrnqmjr6948k5-wayland-1.22.0/lib/libwayland-server.so.0
  No symbol table info available.
  #2  0x00007f430d142370 in gamma_control_destroy (gamma_control=0x29eb9b0) at ../types/wlr_gamma_control_v1.c:37
          manager = 0x27e33e0
          output = 0x2a10770
          event = {output = 0x2a10770, control = 0x0}
  #3  0x00007f430d14239b in gamma_control_handle_output_destroy (listener=<optimized out>, data=<optimized out>)
      at ../types/wlr_gamma_control_v1.c:59
          gamma_control = <optimized out>
  #4  0x00007f430d1dca0c in wl_signal_emit_mutable ()
     from /nix/store/ky1g6ylzr2m4bq8fy0gzrnqmjr6948k5-wayland-1.22.0/lib/libwayland-server.so.0
  No symbol table info available.
  #5  0x00007f430d12a0e0 in wlr_output_destroy (output=output@entry=0x2a10770) at ../types/output/output.c:384
          cursor = <optimized out>
          tmp_cursor = <optimized out>
          layer = <optimized out>
          tmp_layer = <optimized out>
  #6  0x00007f430d114ecf in disconnect_drm_connector (conn=conn@entry=0x2a10770) at ../backend/drm/drm.c:1757
          __PRETTY_FUNCTION__ = "disconnect_drm_connector"
  #7  0x00007f430d117078 in scan_drm_connectors (drm=drm@entry=0x1eebab0, event=event@entry=0x7ffce1ed5c1c) at ../backend/drm/drm.c:1597
          c = <optimized out>
          wlr_conn = 0x2a10770
          drm_conn = 0x2e760d0
          conn_id = <optimized out>
          index = 4
          i = 4
          res = 0x2e761f0
          seen_len = 5
          seen = {true, true, true, true, true, false}
          new_outputs_len = 0
          new_outputs = 0x7ffce1ed5ab0
          conn = <optimized out>
          tmp_conn = <optimized out>
          index = <optimized out>
  #8  0x00007f430d113425 in handle_dev_change (listener=0x1eebbb0, data=0x7ffce1ed5c18) at ../backend/drm/backend.c:157
          drm = 0x1eebab0
          change = 0x7ffce1ed5c18
  #9  0x00007f430d1dca0c in wl_signal_emit_mutable ()
     from /nix/store/ky1g6ylzr2m4bq8fy0gzrnqmjr6948k5-wayland-1.22.0/lib/libwayland-server.so.0
  No symbol table info available.
  #10 0x00007f430d111696 in handle_udev_event (fd=<optimized out>, mask=<optimized out>, data=<optimized out>)
      at ../backend/session/session.c:213
          event = {type = WLR_DEVICE_HOTPLUG, {hotplug = {connector_id = 0, prop_id = 0}}}
          devnum = <optimized out>
          dev = 0x1ed9460
          session = <optimized out>
          udev_dev = 0x2e70db0
          sysname = 0x2e73c60 "card0"
          devnode = <optimized out>
          action = 0x7f430d6677b5 "change"
          seat = <optimized out>
          __PRETTY_FUNCTION__ = "handle_udev_event"
  #11 0x00007f430d1de8e2 in wl_event_loop_dispatch ()
     from /nix/store/ky1g6ylzr2m4bq8fy0gzrnqmjr6948k5-wayland-1.22.0/lib/libwayland-server.so.0
  No symbol table info available.
  #12 0x00007f430d1dc445 in wl_display_run () from /nix/store/ky1g6ylzr2m4bq8fy0gzrnqmjr6948k5-wayland-1.22.0/lib/libwayland-server.so.0
  No symbol table info available.
  #13 0x000000000041daa5 in server_run (server=server@entry=0x485440 <server>) at ../sway/server.c:338
  No locals.
  #14 0x000000000041cf4d in main (argc=<optimized out>, argv=0x7ffce1ed5fe8) at ../sway/main.c:415
          verbose = false
          debug = false
          validate = false
          allow_unsupported_gpu = false
          config_path = 0x0
        c = <optimized out>

where event->output->data is NULL:

  (gdb) p event->output->data
  $5 = (void *) 0x0
2023-06-14 10:13:12 +02:00
Alexander Orzechowski 59c27c94d3 gamma_control_v1: Reset dirty flag 2023-06-11 20:53:39 +02:00
33KK be14cd96cd
Fix `bindsym --to-code` not respecting input configs
Fixes #7535
2023-06-11 11:36:30 +02:00
Shaked Flur 6a1c176d14
man: add --inhibited and --no-repeat to bindsym and bindcode usage 2023-06-09 12:23:05 +02:00
Simon Ser 65b1a6964c desktop/output: fix damage bitfield in wlr_output_state 2023-06-09 11:41:41 +02:00
Simon Ser f3b8c9feee desktop/output: use detached output state for page-flips
This avoids relying on the implicit wlr_output.pending state.
2023-06-08 14:33:23 -07:00
Simon Ser b1b3563d54 Handle gamma-control-v1 set_gamma events
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4046
2023-06-08 22:11:50 +02:00
Erik Reider 913a7679cb Add support for wlr-layer-shell ON_DEMAND keyboard interactivity
This allows for layer shell surfaces to receive focus while the surface is explicitly focused, i.e allowing
text fields to receive keyboard input just like a regular surface.
2023-06-06 09:07:05 +02:00
Artturin 7ab8cb2ee6 chase wlroots wlr_renderer_begin_buffer_pass change
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4159

> ../sway/desktop/output.c:618:47: error: too few arguments to function 'wlr_renderer_begin_buffer_pass'
>   618 |         struct wlr_render_pass *render_pass = wlr_renderer_begin_buffer_pass(
>       |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-06-05 23:12:20 +02:00
Kirill Primak b5cb49bce9 xwayland: fix mapped state check in OR handlers 2023-06-03 09:12:12 +02:00
Kirill Primak c001a57e8b lock: listen to the correct map signal 2023-06-02 22:22:29 +02:00
Kirill Primak c9e1dab318 chore: chase wlroots map logic unification 2023-06-02 20:11:42 +02:00
Kirill Primak 72881b5d12 xwayland: don't rely on event source being data
This pattern is being slowly removed from wlroots.
2023-06-02 20:11:42 +02:00
Erik Reider 48d6eda3cb Fix layer old damage not being offset by the monitor layout coords 2023-05-20 16:56:25 +02:00
hrdl 01b0c11394 seatop_down: Call seatop_begin_default after sending touch events
This is consistent with pointer tablet and button events.

Fixes #7577.
2023-05-11 12:47:56 +02:00
Simon Ser 19cc36accc render: fix titlebar texture clipping
We need to provide an unclipped dst_box.

Fixes: https://github.com/swaywm/sway/issues/7573
Regressed by: https://github.com/swaywm/sway/pull/7552
2023-05-09 18:12:06 +02:00
Kenny Levinsen 0a951517ae render: Clear using wlr_output dimensions
Clear was done using sway_output's logical dimensions, instead of the
wlr_output physical dimensions. This meant that when output scaling was
applied, only a part of the screen would be cleared.

Use the wlr_output dimensions instead.

Regressed by: https://github.com/swaywm/sway/pull/7552
2023-05-09 15:55:31 +02:00
Kenny Levinsen 393c29fc59 render: Apply clip to rendered texture correctly
The new wlr_render_pass API provides src_box, dst_box and clip
parameters for texture rendition. Rather than clipping the dst_box,
which control the projection matrix and leads to compression, intersect
the damage and clip box and pass these as a clip parameter.

Fixes: https://github.com/swaywm/sway/issues/7579
Regressed by: https://github.com/swaywm/sway/pull/7552
2023-05-09 15:55:31 +02:00
Mukundan314 a79994e119 swaybar: always subscribe to mode and workspace
always subscribe to mode and workspace events, since we might need them
after bar config updates even if we don't need them initially.
2023-05-09 12:42:56 +02:00
hrdl 3cd7c71780 handle_touch_cancel: fix begin default
I forgot to call seatop_begin_default in
e8f7551e46.
2023-05-04 17:34:54 +02:00
hrdl e8f7551e46 Add support for touch cancel events 2023-05-04 13:30:57 +02:00
Alexander Orzechowski db7638a0e5 Don't crash if there is no damage during render 2023-05-02 23:25:50 +02:00
Alexander Orzechowski 029b99b482 render: Use wlr_render_pass 2023-05-02 18:31:55 +02:00
Alexander Orzechowski 07cdf6ccd0 render: Don't pass matrix into render_texture 2023-05-02 18:31:55 +02:00
Alexander Orzechowski d5cc474aef render: pass rendering state together in a struct
This lets us easily add rendering state that we need in the future
2023-05-02 18:31:55 +02:00
Alexander Orzechowski 33cfdbe886 xdg_shell: Fix crash if popup generates while toplevel is in the scratchpad 2023-04-16 19:55:00 +02:00
Simon Ser 08c1946d71 Use format_str() throughout 2023-04-14 18:34:54 +02:00
Simon Ser ac8962eb62 common/gesture: use format_str()
We already had a similar function in there.
2023-04-14 18:34:54 +02:00
Simon Ser ea279f4df3 swaynag: add printf attribute to swaynag_log() 2023-04-14 18:34:54 +02:00
Simon Ser 96cebb4fe6 config: add printf attribute to config_add_swaynag_warning() 2023-04-14 18:34:54 +02:00
Simon Ser a7b50f6c9c commands: add printf attribute to cmd_results_new()
And fix the resulting build failures.
2023-04-14 18:34:54 +02:00
Simon Ser d6915f6428 commands/floating_minmax_size: fix error strings
cmd_results_new() does not take the command name as argument.
2023-04-14 18:34:54 +02:00
Simon Ser bd58df61ef pango: add printf attribute
This allows the compiler to catch mismatches between the format
string and the arguments passed in.

Need to add -Wno-format-zero-length because we pass an empty string
on purpose in swaybar/render.c.
2023-04-14 18:34:54 +02:00
Simon Ser aab4c9da5f Add format_str() and vformat_str()
Simple helpers to allocate and format a string.
2023-04-14 18:34:54 +02:00
Simon Ser 4118c49349 Use output_match_name_or_id() in workspace functions 2023-04-14 18:34:54 +02:00
Simon Ser fcec581748 Use output_match_name_or_id() in apply_output_config_to_outputs() 2023-04-14 18:34:54 +02:00
Simon Ser 04904ab9a5 Use all_output_by_name_or_id() in merge_id_on_name()
No need to iterate over the outputs manually.
2023-04-14 18:34:54 +02:00
Simon Ser 8d95638df6 Introduce output_match_name_or_id()
Reduces code duplication.
2023-04-14 18:34:54 +02:00
Elyes Haouas 63f9bdf001 Fix old style function definitions
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2023-04-14 18:21:43 +02:00
Simon Ser ab4f460597 Set output damage during direct scan-out
During direct scan-out, pass the damaged region to the wlroots
backend.
2023-04-14 17:43:37 +02:00
Simon Ser 777df22377 Skip direct scan-out commit when damage is empty
When there is no damage, no need to perform an output commit, even
when direct scan-out is used.
2023-04-14 17:43:37 +02:00
Simon Ser 5e847fe3c8 Pass version to wlr_compositor_create()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3696
2023-04-14 17:26:03 +02:00
Alexander Orzechowski dadf3e9b78
Chase wlroots!4067 2023-04-06 22:03:52 +02:00
Simon Ser e8fb7f53b8 Remove duplicate wlr_damage_ring_set_bounds() call
We already do this in handle_commit().
2023-04-06 16:35:21 +02:00
Erik Reider fa7b686e61
Fix damage-ring bounds not being set when unplugging -> plugging in monitor
#7524 was a partial fix. Seems like this is still an issue when
unplugging and plugging the monitor back in.

Closes: https://github.com/swaywm/sway/issues/7528
2023-04-06 10:40:49 +02:00
Alexander Orzechowski 9cf66e8c7c swaybar: Lift background clearing out of main rendering function
This avoids us from using a bogus background_color value that
mutates as swaybar renders things and deciding opacity depending on
that.

Also remove a redundant full surface clear. Just directly write our
desired background color.
2023-04-02 01:58:02 +02:00
Alexander Orzechowski 5d5b21dcce swaybar: Set opaque region properly
The opaque region is set incorrectly if updated on-the-fly if switching from an opaque to a non opaque background.
2023-04-02 01:58:02 +02:00
Simon Ser dee032d0a0 ipc: add LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM entry
This was introduced in the last libinput release.

Fixes the following error:

    ../sway/ipc-json.c:928:17: error: enumeration value 'LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM' not handled in switch [-Werror=switch]
      928 |                 switch (libinput_device_config_accel_get_profile(device)) {
          |                 ^~~~~~
2023-03-27 10:56:16 +02:00
Ronan Pigott 6701b90c55 Add a .mailmap file 2023-03-26 23:22:30 +02:00
Simon Ser 4f6e559dec man: deprecate seat cursor move/set/press/release
The Wayland protocol better serves this purpose, and is supported
by more compositors.
2023-03-26 23:22:04 +02:00
Erik Reider ac1ed638e9 Init the damage_ring bounds on output creation
Otherwise the initial bounds would be `INT_MAX` until `handle_mode` or `handle_commit` is called :)
2023-03-26 23:00:08 +02:00
Ankit Pandey f21090f978 root: Set inactive focus when scratchpad is moved to new workspace
Fixes an issue where an already visible scratchpad window being moved due to
'scratchpad show' leaves the entire workspace at the top of the focus stack in
the old workspace. Moving by 'focus output' back to the old workspace would
focus the entire workspace instead of just the last active container.
2023-03-24 13:20:13 -07:00
Ankit Pandey 90c2d631e2 root: Try to preserve relative positions of floating containers
This makes the behavior of floating containers more consistent with i3.
The coordinates of the container are scaled when the size of the
workspace it is on changes or when the container is moved
between workspaces on different outputs.

For scratchpad containers, add a new state that preserves the dimensions
of the last output the window appeared on. This is necessary because
after a container is hidden in the scratchpad, we expect it to be in the
same relative position on the output when it reappears. We can't just
use the container's attached workspace because that workspace's
dimensions might have been changed or the workspace as a whole could
have been destroyed.
2023-03-14 23:26:42 -07:00
Stanislav Ochotnický ebeed7e303 man: add warning for hide_cursor configuration
See https://github.com/swaywm/sway/issues/6297
2023-03-11 11:58:05 -05:00
Simon Zeni 51c9376c07
ci: add libdisplay-info dependency 2023-02-28 23:19:33 +01:00
novenary b28e1b0d3c Disable direct scanout for surfaces with popups 2023-02-28 15:38:05 +01:00
llyyr b757ef94ef sway{,bar}: use default font hint style
CAIRO_HINT_STYLE_FULL attempts to maximize contrast at the expense
of fidelity, this makes most fonts that haven't been hand hinted,
which makes up the majority of fonts out there, appear much worse.

In the absence of explicitly set hint style, cairo will default to
CAIRO_HINT_STYLE_SLIGHT, which attempts to improve contrast while
retaining fidelity to the original shapes, which is what we want.
2023-02-27 13:55:08 -05:00
rj1 d63497698b fix typo 2023-02-25 10:50:43 +01:00
Robin Jarry 9498e4d261 Allow windows in scratchpad to set the urgent flag
When a window in the scratchpad container requests for
xdg_activation_v1, it is ignored no matter what the value of
focus_on_window_activation is.

At least allow windows in the scratchpad to set the urgent flag. When
focus_on_window_activation is set to "focus", show the parent scratchpad
where the contained requested for xdg_activation_v1.
2023-02-22 11:41:43 -07:00
Simon Ser 16b0afd433 Check for empty damage before attaching render buffer
Check whether output->damage_ring.current is empty before calling
wlr_output_attach_render(). Saves us from having to un-do that
via wlr_output_rollback().
2023-02-22 13:37:44 -05:00
Simon Ser c2ccc0c9d4 Move output commit out of output_render()
That way output_render() only does what it says on the tin.
2023-02-22 13:37:44 -05:00
Simon Ser d6cb4fa8de Constify pixman_region32_t for rendering functions 2023-02-22 13:37:44 -05:00
Simon Ser 423459723b Adjust scale for fractional-scale-v1 2023-02-22 10:14:31 -05:00
Stacy Harper 4666d1785b Implement seatop_touch
Atm we got issue with the touch position sent to the clients. While
holding contact, leaving the initial container will continue to send
motion event to the client but with the new local position from the new
container.

This seatop goal is to send the position of the touch event, relatively
to the initial container layout position.
2023-02-20 10:35:10 -05:00
Simon Ser 7d2e4a5106 layer-shell: enter output before surface is mapped
This sends fractional-scale-v1 events before the first configure
event. That way clients have all of the metadata they need to render
the first frame.
2023-02-20 12:20:42 +01:00
Simon Ser 7a6c7d60d5 Update surface fractional scale on output change
Closes: https://github.com/swaywm/sway/issues/7464
2023-02-20 12:11:07 +01:00
Ronan Pigott 633d409b88 container: rehome the container_swap function into container.c
This function was already declared in container.h but defined in
commands/swap.c for some unknown reason. Everything in commands/ assumes
the handler context has been set appropriately by the command preludes
but this function snuck its way into seatop_* which doesn't set anything
in the handler context.

The fact that the seatop drag actions manipulate the focus without
custody of the seat means they are definitely very broken in multiseat.
2023-02-19 20:07:39 -05:00
Daniel Hill 788118f194 Fix map_to_output * turning off device
Signed-off-by: Daniel Hill <daniel@gluo.nz>
2023-02-18 20:15:28 +01:00
Simon Ser 9162b536f6 Add support for fractional-scale-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3511
2023-02-10 20:36:15 +01:00
Simon Ser 1cab17ada2 Introduce surface_{enter,leave}_output()
We can centralize all output-related surface events from there.
2023-02-10 20:36:15 +01:00
Łukasz Adamczak 8e4b659578 Clarify documentation for window_rect 2023-02-10 11:17:50 -07:00
Łukasz Adamczak fadfbe8dba Correct window_rect.y with hide_edge_borders
With `hide_edge_borders both` (or at least `vertical`),
`window_rect.y` will equal `border_thickness` for SOME windows,
but it will be 0 for windows adjacent to top screen edge.

Therefore setting it to `border_thickness` is not sufficient.

This commit changes it to the actual y offset of content
into the container.
2023-02-10 11:17:50 -07:00
Ronan Pigott 1b27e8c8fd xdg-activation: fix urgency when the client does not specify a seat
xdg-activation is now too strict in only allowing tokens with a seat to
activate a surface. Clients may rely on this behavior for urgency hints.
The seat argument is still useful in case the client does provide a seat
so we can activate it on the desired seat.

Fixes: 842609da64 (view: make request_activate take a seat, 2022-11-30)
2023-02-09 20:02:32 +01:00
Simon Ser b4ce0a30c1 Use wlr_linux_dmabuf_feedback_v1_init_with_options()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3933
Closes: https://github.com/swaywm/sway/issues/7436
Closes: https://github.com/swaywm/sway/pull/7437
2023-02-07 13:35:56 -05:00
Baltazár Radics 7d0351b411 ipc: add ability to subscribe to output event 2023-02-06 11:02:52 +01:00
Ronan Pigott 4cda9ee3a3 launcher: support external launcher tokens 2023-02-05 00:53:47 -07:00
Ronan Pigott dbc1eec850 launcher: make launcher context seat aware 2023-02-05 00:53:47 -07:00
Ronan Pigott 842609da64 view: make request_activate take a seat
This way we can move focus on the same seat an activation token
originates from.
2023-02-05 00:53:47 -07:00
Simon Ser 0780d3a465 ci: install hwdata-dev on Alpine
We're missing the pkg-config file so the DRM backend gets disabled.
2023-02-04 20:48:20 -07:00
Simon Ser 0695f3fa2a swaymsg: s/inactive/disabled/
The JSON field is named "active", but that's confusing for users:
`output disable` is the command which results in `active = false`
outputs. Use the same terminology in end-user messages.
2023-02-02 12:00:06 -05:00
Simon Ser f22d4dbab7 swaymsg: print output power status 2023-02-02 12:00:06 -05:00
Radical 412b80983e
Add Norwegian READMR
Added a Norwegian README file `README.no.md` and added a link to it in
the original `README.md` file.
2023-02-02 17:45:01 +01:00
Simon Ser 9959e6b8dc Convert to *_try_from_wlr_surface()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991
2023-02-02 14:53:15 +03:00
Tobias Predel b31e97e55d root: free non_desktop_outputs list on root_destroy
This fixes a memory leak because the non_desktop_outputs list was not
freed when the root was destroyed.
2023-02-02 09:39:58 +01:00
Simon Ser ae2d14ceeb Convert to wlr_xwayland_surface_try_from_wlr_surface()
Accomodate for the breaking changes in [1].

[1]: fbf5982e38
2023-02-01 23:38:12 +01:00
Simon Ser 40eb29e7c5 ipc: add support for output event
For compatibility with i3 [1].

[1]: https://i3wm.org/docs/ipc.html#_output_event
2023-02-01 11:32:57 -05:00
Cedric Sodhi 2e33b0276f Added reference for event types to swaymsg manpage 2023-02-01 16:22:15 +01:00
Simon Ser ab9b164e52 Switch default menu to wmenu
Switch the default menu to wmeny (https://sr.ht/~adnano/wmenu),
a Wayland-native alternative to dmenu. This removes the dependency
on Xwayland for the default config.

wmenu is small (same scope as dmenu) and has the same flags as dmenu.
One downside is that it's not widely packaged by distributions yet.

We still depend on dmenu_path.
2023-01-30 15:08:16 -05:00
Alexander Courtis 2c0f68b7c6
Apply new adaptive sync value from wlr-output-management
fixes #7394

Test cases:
* zwlr_output_configuration_head_v1_set_adaptive_sync 0->0, no change
* 0->1, enabled
* 1->0, disabled
* 1->1, no change

Similar tests with an incapable display resulted in `"Adaptive sync
failed, ignoring"` messages as expected.
2023-01-23 14:17:52 +01:00
Simon Ser 36f627d0fa Check return value of wlr_renderer_begin()
Since [1], wlr_renderer_begin() can fail. Check its return value
and bail.

This fixes an assertion error (when begin() fails and then we try
to render something) after a GPU reset.

[1]: a541c9510a
2023-01-21 14:16:21 +01:00
Tobias Bengfort a7b9f6fedc focus_on_window_activation: raise if floating 2023-01-20 17:04:26 +01:00
Simon Ser 6a3e265326 Fix pointer events for ext-session-lock surfaces
We were never sending any pointer event to ext-session-lock
surfaces.
2023-01-18 11:23:05 -05:00
Simon Ser d5b69d5912 Fix indentation in surface_is_xdg_popup() 2023-01-18 16:48:38 +01:00
Simon Ser 284966fd57 Send wl_surface.enter for ext-session-lock surfaces 2023-01-18 00:48:24 +01:00
Kirill Primak 53c9a4a643 input/tablet: handle focusing NULL surface
Additionally, rename the function responsible for switching focus to
match its behavior better.
2023-01-16 15:37:59 -05:00
Manuel Stoeckl 5e73acb431 swaynag: call swaynag_destroy on clean exit
And fix the fallout of the swaynag_destroy having evolved without
being tested:
* wl_display_disconnect was called too early
* `button_close` and `swaynag.details.button_details` needed to be
  heap allocated, since they are added to swaynag.buttons, and all
  entries of swaynag.buttons are freed in swaynag_destroy
* To keep things simpler, disconnect the lifetime of the 'Toggle details'
  button text config setting from the button itself.
2023-01-16 10:47:42 -05:00
Ronan Pigott 2f2cdd60de input: enable user xkb configs with cap_sys_nice 2023-01-11 11:32:09 +01:00
John Chadwick 3061999ec5 Improve tablet tool button handling.
This change allows the tablet tool button to be used for floating mod
resize. In addition, it attempts to ensure that tablet tool events are
consistent such that tablet v2 events and pointer events will never be
interleaved, and such that the tool buttons count will never fall out of
sync and cause tool button emulation to break.

Some of this logic is similar to what is done for tablet tool tip, but
not quite identical, because of the complication that we have to deal
with multiple inputs that can overlap eachother.

Fixes #7036.
2023-01-07 23:52:27 -05:00
Alexander Orzechowski 88c17ece3b warp_to_constraint_cursor_hint: Handle NULL view
This might be the wrong fix, but the crash is happening because the ->data
field on an xwayland surface is NULL. A NULL data field is normal for
unmanaged surfaces, however it seems clients can do weird things: They can
create a cursor lock on a regular xwayland surface then make it unmanaged
by calling override_redirect. In this case, the xwayland server should
destroy the cursor lock, which is does, but does so in the wrong order
making it try to dereference a NULL pointer after sway has acknowledged
its new unmanaged status.

```
(gdb) bt full
0  0x000055fd91934861 in warp_to_constraint_cursor_hint (cursor=0x55fd93486c00)
    at ../sway/input/cursor.c:1243
        sy = 605
        lx = 6.9527431433545762e-310
        sx = 1272
        view = 0x0
        con = 0x7ffd1cdfe400
        ly = -6.949595189996421e+59
        constraint = 0x55fd93e7faa0
1  0x000055fd91934976 in handle_constraint_destroy (listener=0x55fd93f0fd58, data=0x55fd93e7faa0)
    at ../sway/input/cursor.c:1266
        sway_constraint = 0x55fd93f0fd30
        constraint = 0x55fd93e7faa0
        cursor = 0x55fd93486c00
2  0x00007fda8275bf6e in wl_signal_emit_mutable () at /usr/lib/libwayland-server.so.0
3  0x00007fda82e57016 in pointer_constraint_destroy (constraint=0x55fd93e7faa0)
    at ../subprojects/wlroots/types/wlr_pointer_constraints_v1.c:49
4  0x00007fda82e570dc in pointer_constraint_destroy_resource (resource=0x55fd933cf8f0)
    at ../subprojects/wlroots/types/wlr_pointer_constraints_v1.c:66
        constraint = 0x55fd93e7faa0
5  0x00007fda8275d8ba in  () at /usr/lib/libwayland-server.so.0
6  0x00007fda8275f6a9 in wl_resource_destroy () at /usr/lib/libwayland-server.so.0
7  0x00007fda82e56fb3 in resource_destroy (client=0x55fd93ea52e0, resource=0x55fd933cf8f0)
    at ../subprojects/wlroots/types/wlr_pointer_constraints_v1.c:39
8  0x00007fda81d8f4f6 in  () at /usr/lib/libffi.so.8
9  0x00007fda81d8bf5e in  () at /usr/lib/libffi.so.8
10 0x00007fda81d8eb73 in ffi_call () at /usr/lib/libffi.so.8
11 0x00007fda8275aada in  () at /usr/lib/libwayland-server.so.0
12 0x00007fda8275f01c in  () at /usr/lib/libwayland-server.so.0
13 0x00007fda8275d9e2 in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
14 0x00007fda8275e197 in wl_display_run () at /usr/lib/libwayland-server.so.0
15 0x000055fd919264d3 in server_run (server=0x55fd919a3a80 <server>) at ../sway/server.c:320
16 0x000055fd91925457 in main (argc=1, argv=0x7ffd1cdfed98) at ../sway/main.c:411
        verbose = false
        debug = false
        validate = false
        allow_unsupported_gpu = false
        config_path = 0x0
        c = -1
```
2023-01-04 10:37:36 +01:00
Carl Smedstad 714559812e Use correct length for strncmp comparison 2023-01-03 21:50:56 +01:00
Carl Smedstad 9425ce2fba Replace math functions that promote float to double 2023-01-03 21:50:56 +01:00
Carl Smedstad d8212243c9 Remove redundant return statements 2023-01-03 21:50:56 +01:00
Carl Smedstad 6ec57271b6 Make cmd_handler.command const 2023-01-03 21:50:56 +01:00
Carl Smedstad 9540591105 Add missing includes & remove duplicates 2023-01-03 21:50:56 +01:00
Carl Smedstad e3257e646c Remove duplicate declarations 2023-01-03 21:50:56 +01:00
Simon Ser 9e15e2fd4f tree/container: drop unnecessary check in container_get_siblings()
The check for container->pending.workspace already covers this.

References: https://github.com/swaywm/sway/pull/7315#issuecomment-1341716204
2023-01-03 11:01:02 -07:00
Simon Ser 0c23b0ec33 man: fix typo in output disable docs 2023-01-03 10:59:02 -07:00
Simon Ser bd7466e1b7 swaynag: drop swaynag_type.font
It's too easy to have this go out of sync with font_description.
2022-12-22 17:42:33 +01:00
Simon Ser fd0af78e43 swaynag: fix NULL font description
The font description was only set if provided on the CLI. It was
left NULL for the defaults and when reading from the config file.

Closes: https://github.com/swaywm/sway/issues/7186
2022-12-22 17:42:33 +01:00
Kenny Levinsen 1ade0ce753 seat: Set keyboard if seat keyboard is NULL
sway sends wl_keyboard.enter on seat focus change and when a keyboard
active on a seat is configured. If all keyboards are removed and a
keyboard is added back without changing the focused client, no new
notify event would be sent despite having keyboard focus. This could
lead to key events without notify, which is a protocol violation.

As a quick fix, when configuring a keyboard on a seat where no keyboard
is currently active, activate the keyboard so that a focused surface
will receive a notify event.

Regressed by: e1b268af98
Closes: https://github.com/swaywm/sway/issues/7330
2022-12-19 10:02:58 +01:00
Ankit Pandey e3c63bf58d commands/move: Warp cursor after moving workspace to another output
This makes sway's behavior consistent with i3 when `mouse_warping` is
set to any value besides `none`.

Fixes #7027.
2022-12-19 00:31:09 -07:00
Baltazár Radics fbf9191fb8 Fix input command order (rotation_angle)
efd83cb8 added the rotation_angle command but it didn't insert it in
the proper place in the list, so the repeat_delay and repeat_rate
commands became unusable.
2022-12-09 22:36:33 +01:00
Lucas Zampieri efd83cb8b9 Add libinput RotationAngle
This patch adds the libinput option RotationAngle to sway.

Signoff-by: Lucas Zampieri <lzampier@redhat.com>
2022-12-09 11:28:53 +01:00
Ronan Pigott 991d75904f criteria: be lenient on window_role and instance too 2022-12-08 21:20:45 +01:00
Simon Ser de3e6a0da0 ci: install Xwayland .pc file
See https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3621
2022-12-08 21:17:10 +01:00
Aidan Dang c32a507303 Add `primary_selection` config option
See: https://github.com/swaywm/sway/issues/4511

Adds a bool config option `primary_selection`, which explicitly
enables/disables the primary selection clipboard. Defaults to enabled.

This is implemented as a launch-only option which enables or disables the creation of the
`zwp_primary_selection_device_manager_v1` global.

Co-authored-by: Tilde Rose <t1lde@protonmail.com>
2022-12-05 14:09:29 +01:00
Kenny Levinsen e1b268af98 seat: Avoid sending redundant keymaps on reload
When we reload the config, we reset every input device and re-apply
configuration from the config file. This means that the keyboard keymap
is updated at least once during config reload, more if the config file
contains keyboard configuration.

When they keyboard keymap changes and is updated through wlr_seat, the
keymap ends up sent to every keyboard bound in every client, seemingly
multiple times. On an x230 of mine with a keyboard layout set in the
config file, I see 42 keymap events sent to foot on config reload.

Reduce events from keyboard configurations by skipping all but the
currently active keyboard for the seat, and by clearing the active
keyboard during input manager device reset. After this change, I only
see a single just-in-time keymap event.

Fixes: https://github.com/swaywm/sway/issues/6654
2022-12-04 13:01:41 -07:00
Simon Zeni 6b3245ac77 sway/lock: handle mode in output commit handler 2022-12-01 23:27:22 +01:00
Simon Zeni aa03a8fcb5 sway/desktop/output: listen to output mode in commit handle 2022-12-01 23:27:22 +01:00
Simon Ser 3bd657c726 Chase breaking changes in wlroots!3903
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3903
2022-11-30 17:18:20 +01:00
AsciiWolf e1d457c824 Fix typo in Czech README translation 2022-11-30 14:43:43 +01:00
Simon Ser d41f11e6bd build: fix have_xwayland when xcb-icccm is not found
xcb-icccm is required to build Xwayland support.
2022-11-29 11:47:21 -05:00
Simon Ser a358d6760e build: move completions to separate file 2022-11-28 18:51:45 -05:00
nerdopolis dca0bb5749 Fix build on Debian Stable 2022-11-28 23:42:41 +01:00
Simon Ser f54d22ca2a build: remove trailing newline at end of file 2022-11-28 20:00:49 +01:00
Simon Ser e62299daa4 Make libinput backend optional 2022-11-28 13:28:15 -05:00
Simon Ser 46170580b2 Make session optional 2022-11-28 13:28:15 -05:00
Simon Ser e795ea6a0c Make DRM backend optional 2022-11-28 13:28:15 -05:00
Simon Ser 5b64e2fc31 Make GLES2 optional 2022-11-28 13:28:15 -05:00
AsciiWolf 456f49db35 Translate README to Czech 2022-11-28 11:26:06 +01:00
Simon Ser 81518e299c build: bump version to 1.9-dev 2022-11-26 23:25:54 +01:00
Simon Ser 37e4a3d637 build: drop unused wayland-egl dependency 2022-11-26 18:15:57 +01:00
Joan Bruguera 94b69acf0d swaybar: Make hotspots block bar release bindings
The previous commit prioritized hotspots before bar bindings for press events,
which matches i3's behaviour. However, since hotspots don't need to do any
processing on release events, those were not handled, and simply fell through
to `bindsym --release` bar bindings (if any).

This is counter-intuitive, and doesn't match i3's behaviour. Instead in case
a hotspot handles the press event, it should also handle the release event,
doing nothing, but blocking the event from triggering a --release bar binding.

E.g., in Sway, without this commit, this config. shows a text on tray clicks:

    bar {
        # ...
        bindsym --release button1 exec swaynag -m I_got_the_release_event.
    }

But the same configuration in i3 (with i3-nagbar) doesn't show the text.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-11-26 10:17:53 +01:00
Joan Bruguera 53f9dbd424 swaybar: Prioritize hotspot events to bar bindings
This is consistent with i3bar's behaviour, and for example, allows binding a
command to button1, while still being able to click on tray icons or other
zones on the bar's status line which may have their own bindings.

E.g., in Sway, without this commit, this config. makes tray icons unclickable:

    bar {
        # ...
        bindsym button1 exec swaynag -m You_clicked_the_tray._Want_some_help?
    }

But the same configuration in i3 (with i3-nagbar) keeps tray items clickable.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-11-26 10:17:53 +01:00
Ronan Pigott 28fda4c0d3 launcher: export X startup ids and use them for workspace matching 2022-11-26 09:48:58 +01:00
Ronan Pigott 30ad4dc4a5 launcher: export xdga tokens and use them for workspace matching 2022-11-26 09:48:58 +01:00
Ronan Pigott bdeb9f9565 launcher: fudge the interface a bit
We want to create a context before knowing the pid it will match with.
2022-11-26 09:48:58 +01:00
Ronan Pigott 66568508c0 launcher: initialize launcher_ctxs once on startup 2022-11-26 09:48:58 +01:00
Ronan Pigott 864b3a9a18 view: associate launch contexts with views
Views now maintain a reference to a launch context which, as a last
resort, is populated at map time with a context associated with its pid.
This opens the possibility of populating it before map via another
source, e.g. xdga-tokens or configuration.
2022-11-26 09:48:58 +01:00
Ronan Pigott d75c9f9722 launcher: rename pid_workspace to launcher_ctx
Soon we will match views with more than just a pid.
2022-11-26 09:48:58 +01:00
Ronan Pigott bd66f4943d launcher: use xdga tokens
This reuses wlroots token tracking for workspace matching. It doesn't
export any xdga tokens for clients yet.
2022-11-26 09:48:58 +01:00
Ronan Pigott 3b49f2782e launcher: track workspaces by node
This removes the need to rename the pid_workspaces when a workspace
is renamed.

It also opens the possibility of tracking other node types. Tracking
containers would allow application to be placed correctly in the
container tree even if the user has moved their focus elsewhere since
it was launched.
2022-11-26 09:48:58 +01:00
Ronan Pigott 1c4b94ae3c node: prettify node type names 2022-11-26 09:48:58 +01:00
Ronan Pigott eb5021ef99 root: move the workspace matching code to its own file
This removes the pid_workspace bits from tree/root before it gets
too interesting.

No functional change.
2022-11-26 09:48:58 +01:00
Simon Ser af8a5a8918 build: drop intermediate libraries for protocols 2022-11-25 10:51:20 +01:00
Simon Ser e5475d9310 build: drop "server" from target name for protocol code 2022-11-25 10:48:07 +01:00
Simon Ser 5be5a038da build: unify server & client protocol generation
No need to make a difference here, let's just generate header
files for both.
2022-11-25 10:46:53 +01:00
Simon Ser 366f6ef3d3 build: drop wayland-scanner fallback 2022-11-25 10:46:00 +01:00
Manuel Stoeckl e2bc8866f4 Use shm_open instead of mkstemp
shm_open is more reliable because it does not require
a writeable filesystem folder, unlike mkstemp.
2022-11-25 00:05:12 +01:00
Simon Ser 7623292734 Update for wlroots!3814
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3814
2022-11-15 22:26:43 +01:00
Simon Ser 717e9ef581 ipc: add view content type
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3599
2022-11-15 11:06:51 -05:00
Simon Ser 907ca48a61 Listen to the output request_state event
References: https://github.com/swaywm/wlroots/pull/2693
2022-11-15 11:05:47 -05:00
Simon Ser 024c3e4428 input/seat: locally compute drag icon offset
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3861
2022-11-15 16:58:20 +03:00
Simon Zeni e1be46875d sway/server: specify wlr-layer-shell version on creation 2022-11-14 16:10:55 +01:00
Kirill Primak 85005b52fe output: set damage ring bounds to pixel values
Fixes: https://github.com/swaywm/sway/issues/7254
2022-11-12 11:50:04 +01:00
Alexander Orzechowski 34933bb843 workspace_create: Don't allow NULL name 2022-11-11 23:44:03 +01:00
Joe Kappus fdde67405e build: bump wlroots dependency to 0.17.0 2022-11-11 22:31:18 +01:00
Baltazár Radics 5c239eaac5 container_get_siblings: handle NULL workspace 2022-11-11 18:57:29 +01:00
Simon Ser d945c8f519 lock: fix crash on output destroy
Closes: https://github.com/swaywm/sway/issues/7120
2022-11-11 17:01:50 +01:00
Kirill Primak 7862fa670e
Use wlr_damage_ring
wlr_output_damage is to be replaced with wlr_damage_ring, so use that.
2022-11-11 16:29:04 +01:00
Simon Ser dcd2076f38 Use wl_signal_emit_mutable()
This function fixes segfaults when emitting a signal potentially
removes arbitrary listeners.
2022-11-10 22:27:38 +03:00
Kirill Primak 6c3b35701d ci: install hwdata 2022-11-09 10:43:44 +01:00
Callum Andrew 3e19836f0e criteria: allow matching for NULL string criteria 2022-11-04 10:02:11 +01:00
Puck Meerburg e40eb338b9 criteria: allow matching on empty (NULL) titles 2022-10-30 10:57:19 +01:00
Puck Meerburg 0fdeb4ca84 tree: support formatting null titles
Any windows that have never had a title set visually behave closer to
that of an empty title, but are unformattable, as the code bails out
early on a NULL title.
2022-10-30 10:57:19 +01:00
pudiva chip líquida 7cc8ab6d6c Support libinput's 1.21 new dwtp option
Support the new dwtp (disable while trackpointing) option introduced in
libinput 1.21, allowing users to control whether the trackpoint (like
those in Thinkpads, but not only) should be disabled while using the
keyboard/touchpad.

See: https://gitlab.freedesktop.org/libinput/libinput/-/issues/731
2022-10-30 10:56:34 +01:00
Alexander Orzechowski a61815d385 container_floating_set_default_size: Store workspace size box on the stack 2022-10-29 00:47:01 +02:00
Daniel De Graaf 8aa89dc277 Fix focus tracking when session lock is active
Remove the incorrect attempt to block focus changes when an input grab
is present and replace it with the same logic used for layer_shell-based
screen lockers: restore the focus after changing it.

This fixes a use-after-free of seat->workspace if outputs are destroyed
while a screen lock is enabled.
2022-10-28 19:41:24 +02:00
Daniel De Graaf 8f7bb145b7 Rework session lock keyboard focus handling
When removing outputs, it is possible to end up in a situation where
none of the session lock client's surfaces have keyboard focus,
resulting in it not receiving keyboard events.  Track the focused
surface and update it as needed on surface destroy.
2022-10-28 19:41:24 +02:00
Yaroslav de la Peña Smirnov 9d99bb956f Fix keymap being NULL and segfaulting on dev add
Moved `libinput_config` to the callers of
`sway_input_configure_libinput_device` so that we send the event after
the added event.
2022-10-23 11:56:29 +02:00
Tudor Brindus 5e514e6474 input: tweak focus behavior to allow focusing parent containers
Sway focuses the inactive child when focusing split containers. However,
there is currently no way to focus the parent container itself by mouse.
A user must use the keyboard to do so.

This commit maintains the current behavior, but makes it such that a
second click on the split container titlebar (i.e., after its children
are visible) focuses the split container itself.
2022-10-21 10:05:00 +02:00
Simon Ser 9400bd963c Add support for ext-idle-notify-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3753
2022-10-14 15:56:07 +02:00
cparm 99fd096d69 Avoid double free in criteria_destroy() 2022-10-13 14:56:10 +02:00
Simon Ser 7a6afc5199 Fix leaks in criteria_destroy() 2022-10-10 09:51:01 -04:00
Tudor Brindus c7bced9329 input: focus container when scrolling on titlebar
Fixes #6503.
2022-10-10 08:56:51 +02:00
Tudor Brindus 09354db878 input: focus floating container when clicked on border
Fixes #7209.
2022-10-10 08:55:21 +02:00
Ferdinand Schober 99acdb4e62 Use keyboard_state.focused_surface directly 2022-10-09 10:07:51 +02:00
Ferdinand Schober be7707874a use seat directly 2022-10-09 10:07:51 +02:00
Ferdinand Schober e2bb5799af check for NULL 2022-10-09 10:07:51 +02:00
Ferdinand Schober d5659948f1 allow pointer_constraints on layer_shell surfaces 2022-10-09 10:07:51 +02:00
ohno418 07c827b4be Improve Japanese translation 2022-10-08 10:12:00 +02:00
Andri Yngvason b00b05f792 sway/commands/output: Add command for unplugging non-physical outputs 2022-10-07 19:17:39 +02:00
Simon Ser 04f8a655e7 build: simplify protocol paths
No need for arrays here.
2022-10-04 09:48:29 +02:00
Simon Ser 78b5c0a77e swaymsg: show mode picture aspect ratio 2022-10-03 13:35:52 +02:00
Simon Ser f70d1e1b95 ipc: expose mode picture aspect ratio 2022-10-03 13:35:52 +02:00
マリウス b0fc83485d man: Add XWayland information 2022-09-25 20:05:16 +02:00
Alex Maese cffb006feb swaymsg: show non-desktop property when pretty printing outputs 2022-09-19 07:26:45 -04:00
Alex Maese 52f0e3a4d5 sway: add non-desktop outputs to json when running `swaymsg -t get_outputs` 2022-09-19 07:26:45 -04:00
Alex Maese c015db4a9f sway: Add non-desktop-output type
Currently, when encountering a non-desktop display, sway offers the
output for leasing and returns without storing it in a sway specific
output type like `struct sway_output`.  Additionally, running
`swaymsg -t get_outputs` doesn't show non-desktop outputs.

This commit stores the non-desktop outputs into a struct called
`sway_output_non_desktop`, and adds them to a list on `sway_root`
2022-09-19 07:26:45 -04:00
Filip Szczepański 1c368fbb5f Fix crash in xdg_activation_v1.c
wlr_xdg_surface_from_wlr_surface() can return a NULL pointer, so check for NULL before dereferencing it.
2022-09-13 00:59:18 +03:00
Simon Ser 07bfeb2abc config/output: test adaptive sync
Required for [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3637
2022-08-30 20:15:29 +02:00
Simon Ser aaa6c4ac89 ipc: drop WLR_OUTPUT_ADAPTIVE_SYNC_UNKNOWN case
This has been removed from wlroots.
2022-08-30 20:15:29 +02:00
Baltazár Radics 6e023257e8 man: sway(5) move fixes 2022-08-11 08:21:37 +02:00
Martin Michlmayr ebf441b359 sway-output.5: improve display of parameter
Since "width" and "height" are separate parameters, show them as such.
2022-08-08 08:03:27 +02:00
Simon Ser 89d73beedb Enable single-pixel-buffer-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3428
2022-08-04 18:44:58 +02:00
llyyr 9e879242fd grimshot: fix tilde expansion within quotes 2022-07-30 09:25:24 +02:00
Baltazár Radics a5a44ba95b ipc: make get_deco_rect check config->hide_lone_tab
Without this, the `IPC_GET_TREE` ipc call would return false information
about the container's `deco_rect` and `rect` properties if
`hide_edge_borders --i3` was in effect.
2022-07-26 12:06:10 +02:00
llyyr e98b97a45b swaymsg: fix floating_nodes being ignored
Fix floating_nodes being ignored in pretty_print_tree.
2022-07-26 10:56:50 +02:00
Kirill Primak 6b97c4fa71 input: chase delta_discrete semantics change 2022-07-15 14:14:41 -04:00
zkldi 8d8a21c9c3 fix: remove redundant empty statement in main.c
This semi-colon looks like a typo. Luckily, it has no effect on the code as it's treated as an empty statement leading the switch case.

Really straightforward nitpick change, was just something I was confused by when reading over the code.
2022-07-12 16:07:51 +02:00
Simon Ser b69d637f7a Remove internal references to DPMS
While at it, use an int for the config field, just like we do for
all other fields.
2022-07-04 21:58:24 +03:00
Simon Ser 798e3c8858 config.in: switch to `output power` 2022-07-04 21:58:24 +03:00
Simon Ser 11e05c5711 ipc: add "power" to output reply 2022-07-04 21:58:24 +03:00
Hugo Osvaldo Barrera 80e386fd97 Reuse parsed PangoFontDescription
Avoids parsing the configured font each time text is rendered.
2022-07-01 13:05:58 +02:00
Hugo Osvaldo Barrera 75605491a5 Reject font values that are invalid for pango
Use pango to parse font configuration early, and reject the command as
invalid if the value is invalid for pango. Since we're already parsing
the font into a `PangoFontDescription`, keep that instance around and
avoid re-parsing the font each time we render text.

Fixes: https://github.com/swaywm/sway/issues/6805
2022-07-01 13:05:58 +02:00
Hugo Osvaldo Barrera 9e8866ae20 Avoid unecessary string copy 2022-07-01 13:05:58 +02:00
Thomas Jost a55472c6d8 Strip quotes in bindsym --input-device=...
If the input device is quoted, which is common when using variables in the
config file, those quotes must be ignored here, or the input device will be
ignored.

Fixes #7029.
2022-06-25 11:27:49 +02:00
Simon Ser 445bc2a943 Rename dpms output command to power
The "dpms" command refers to VESA Display Power Management
Signaling, a deprecated standard. It's superseded by VESA DPM.

Instead of tying out command name to a particular standard, use the
neutral term "power".
2022-06-23 14:47:50 -04:00
Simon Ser 122d8ce954 Remove access to wlr_input_device union
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3626
Closes: https://github.com/swaywm/sway/issues/7077
2022-06-22 12:44:15 -04:00
kraftwerk28 49cef51e6e Allocate enough space for `cmd_results->error` 2022-06-16 09:32:44 +02:00
Simon Ser 1c69d0e72f config/output: use wlr_output_commit_state
This makes the code more robust because we don't potentially leave
bad state in wlr_output.pending behind anymore. This also fixes a
bug.

Closes: https://github.com/swaywm/sway/issues/7043
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3610
2022-06-10 11:35:30 +02:00
Greg Depoire--Ferrer 956b689d6a swaynag: move close_button up to fix SIGSEGV
When swaynag_parse_options encounters '--dismiss-button' (or its
shorthand '-s'), it sets the text of the first button in the
swaynag.buttons list, which is expected to exist and to be the dismiss
button, to the one passed by the user.

Commit 4780afb68b ("swaynag: statically
allocate button_close, and move declaration") moved the list
initialization to after swaynag_parse_options is called which made that
code fail.

For example, the command 'swaynag --dismiss-button Dismiss' crashes and
'swaynag --message Message --button Yes "" --dismiss-button Dismiss'
shows the wrong buttons.

Move it back to before swaynag_parse_options is called.
2022-06-05 19:05:26 +02:00
Kenny Levinsen e5728052b5 Refuse to start when SUID is detected
This ensures that those surprised by the deprecation of SUID operation
receive an error rather than accidentally having sway run as root.

This detection will be removed in a future release.
2022-06-03 12:37:40 +02:00
Simon Ser 251a648e2c ipc: remove chatty debug log messages
These aren't particularly useful, and clobber the debug logs.
2022-05-30 18:44:18 +02:00
Simon Ser a5c2e9fee0 build: link with -pthread
Fixes the following FreeBSD error:

    ld: error: undefined symbol: pthread_getschedparam
    >>> referenced by realtime.c:25 (../sway/realtime.c:25)
    >>>               sway/sway.p/realtime.c.o:(set_rr_scheduling)

Fixes: a3a82efbf6 ("realtime: request SCHED_RR using CAP_SYS_NICE")
2022-05-30 18:40:26 +02:00
Florian Franzen cab2189aa6 sway: add bindgesture command
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
2022-05-30 12:20:43 +02:00
LordRishav a535ed310f
Add a Hindi (हिन्दी) translation to the README
Hindi is one of the most prominent languages of the Indian Subcontinent.
This commit adds the translation of the README into the Hindi language.
Some of the words are still written in English because there wasn't an
appropriate technical term of the word in the language.

Co-authored-by: Surendrajat <surendrajat@protonmail.com>
2022-05-27 21:09:18 +02:00
Kirill Primak 6a59e38aeb xdg-shell: schedule a configure on maximize request
This commit reverts 03879290db and
fc84bcb7fb.
2022-05-27 15:49:57 +02:00
Kirill Primak 26a0e97634 chore: chase wlroots xdg-shell update 2022-05-27 15:42:22 +02:00
Simon Ser d0b9bf94a5 Handle NULL output make/model/serial 2022-05-26 15:42:56 -04:00
Simon Ser f0d57da315 De-duplicate IPC output descriptions 2022-05-26 15:42:56 -04:00
Hongyi 42b61ab27a
Polish the language in README.zh-CN.md & sync with English one
Co-Authored-By: Urey. Xue <urey.s.knowledge@gmail.com>
2022-05-24 07:40:47 +02:00
Daniel De Graaf 75b2d0b105 ext-session-lock: disable direct scan-out when locked 2022-05-23 08:15:51 +02:00
Rouven Czerwinski a3a82efbf6 realtime: request SCHED_RR using CAP_SYS_NICE
Try to gain SCHED_RR (round-robin) realtime scheduling privileges before
starting the server. This requires CAP_SYS_NICE on Linux systems.
We additionally register a pthread_atfork callback which resets the
scheduling class back to SCHED_OTHER (the Linux system default).

Due to CAP_SYS_NICE, setting RLIMIT_RTPRIO has no effect on the process
as documented within man 7 sched (from Linux):

  Privileged (CAP_SYS_NICE) threads ignore the RLIMIT_RTPRIO limit;
  as with older kernels, they can make arbitrary changes to
  scheduling policy and priority. See getrlimit(2) for further
  information on RLIMIT_RTPRIO

Note that this requires the sway distribution packagers to set the
CAP_SYS_NICE capability on the sway binary.

Supersedes #6992
2022-05-18 11:20:17 +02:00
Rouven Czerwinski 3f600565e4 server: request xdg-shell v2
Wlroots does not yet support the newer xdg-shell versions and now
requires the compositor to set the supported xdg-shell version during
creation. Set this to v2 for sway as well.

Fixes https://github.com/swaywm/sway/issues/7001
2022-05-16 11:20:39 -04:00
-k ffc603d451 man: Fix trailing spaces 2022-05-11 19:55:51 +02:00
-k 28941cee20 Add descriptions for `stacking` and `tabbed` layouts
Resolves #5918
2022-05-11 19:07:54 +02:00
Simon Ser 1e9be019b2 Replace strncpy with memcpy
strncpy is useless here, is dangerous because it doesn't guarantee
that the string is NUL-terminated and causes the following warning:

    ../sway/criteria.c: In function ‘criteria_parse’:
    ../sway/criteria.c:712:25: error: ‘strncpy’ destination unchanged after copying no bytes [-Werror=stringop-truncation]
      712 |                         strncpy(value, valuestart, head - valuestart);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-05-11 11:47:49 -04:00
Michael Weiser 7cfa150788 config: Remove unused mouse binding structure
Mouse bindings are handled alongside normal bindings. Remove the unused
separate data structure definition to avoid confusion.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2022-05-11 10:19:27 +02:00
Nihal Jere c85d9af2b6 swaynag: combine consecutive declaration/assignments 2022-05-07 15:57:18 +02:00
Nihal Jere e8028be839 swaynag: improve robustness when loading config 2022-05-07 15:57:18 +02:00
Nihal Jere 5d924f2b12 swaynag: do error checking and rename read_from_stdin
read_from_stdin not only read from stdin, but trimming trailing
newlines, so rename it to reflect this.
2022-05-07 15:57:18 +02:00
Daniel De Graaf a7898637de Avoid inspecting a NULL view in seat_set_focus
Fixes #6968
2022-04-30 00:36:44 +02:00
Daniel De Graaf 519038a7e9 Implement ext-session-lock-v1 2022-04-29 09:06:36 +02:00
Victor Makarov 70d30ac72b
xkb_switch_layout: fix relative layout switches
Fixes #6011
2022-04-28 13:20:44 +02:00
Alan 3caf6914fe Update grimshot.1.scd
Fixed typo. The object is **files**, which is plural. **image** modifies files; it's not countable.
2022-04-23 22:34:11 +02:00
Alice Carroll a5f01a0e04 Support cursor capture in grimshot
Refactor argument parser

Bring back `sh` compatibility

Default to NOTIFY=no
2022-04-21 10:41:48 +02:00
Eskil 2dace6b824
Add Swedish README 2022-04-18 18:51:45 +02:00
kraftwerk28 acdb48a59c Chase wlroots X11 hints update 2022-04-18 08:57:16 +02:00
Thomas Hebb d726e50643 layer_shell: keep output non-NULL wherever possible
Our layer shell implementation assigns every layer surface to an output
on creation. It tracks this output using the output field on the
underlying wlr_layer_surface_v1 structure. As such, much of the existing
code assumes that output is always non-NULL and omits NULL checks
accordingly.

However, there are currently two cases where we destroy a
sway_layer_surface and output is NULL. The first is when we can't find
an output to assign the surface to and destroy it immediately after
creation. The second is when we destroy a surface in response to its
output getting destroyed, as we set output to NULL in
handle_output_destroy() before we call wlr_layer_surface_v1_destroy(),
which is what calls the appropriate unmap and destroy callbacks.

The former case doesn't cause any problems, since we haven't even
allocated a sway_layer_surface at that point or registered any
callbacks. The latter case, however, currently triggers a crash (#6120)
if a popup is visible, since our popup_handle_unmap() implementation
can't handle a NULL output.

To fix this issue, keep output set until right before we free the
sway_layer_surface. All we need to do is remove some of the cleanup
logic from handle_output_destroy(), since as of commit c9060bcc12
("layer-shell: replace close() with destroy()") that same logic is
guaranteed to be happen later when wlroots calls handle_destroy() as
part of wlr_layer_surface_v1_destroy().

This lets us remove some NULL checks from other unmap/destroy callbacks,
which is nice. We also don't need to check that the wlr_output points to
a valid sway_output anymore, since we unset that pointer after disabling
the output as of commit a0bbe67076 ("Address emersions comments on
output re-enabling") Just to be safe, I've added assertions that the
wlr_output is non-NULL wherever we use it.

Fixes #6120.
2022-04-13 10:05:24 +02:00
Daniel De Graaf cf413b9c0b Shuffle variables to satisfy -Werror=restrict
This also fixes an invalid strlen invocation on uninitialized memory.
2022-04-09 18:27:57 +02:00
Daniel De Graaf 20181974c2 Avoid format-truncation warning
The existing code gives this error when compiled with GCC 12:

../sway/server.c: In function ‘server_init’:
../sway/server.c:217:75: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  217 |                 snprintf(name_candidate, sizeof(name_candidate), "wayland-%d", i);
      |                                                                           ^~
../sway/server.c:217:66: note: directive argument in the range [-2147483647, 32]
  217 |                 snprintf(name_candidate, sizeof(name_candidate), "wayland-%d", i);
      |                                                                  ^~~~~~~~~~~~
../sway/server.c:217:17: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16
  217 |                 snprintf(name_candidate, sizeof(name_candidate), "wayland-%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Because i is never negative, this is a false positive, but it is easy to
change i to unsigned to silence the error.
2022-04-09 18:27:57 +02:00
Yasin Silavi 09553a7b5b Fix farsi label 2022-04-07 19:36:46 +02:00
Manuel Stoeckl 8f036b6f78 sway/main: move constants off the stack
This makes stack traces from gdb slightly easier to read.
2022-03-29 08:42:17 +02:00
Oğuz Ersen fb3330c1fb bash-completion: localize variables 2022-03-27 11:27:57 +02:00
Leonardo Hernández Hernández 6c4c0387a2 sway/input: wlr_seat_keyboard() now takes wlr_keyboard 2022-03-23 18:09:54 +01:00
Leonardo Hernández Hernández ca016689a0 sway/input: fix bad position of wlr_drag 2022-03-22 09:00:28 +01:00
Simon Zeni 440d0bc22d sway/input: follow up wlroots input device events renaming 2022-03-17 21:52:59 +03:00
Simon Zeni 49b3ac9a2c sway/input/seat: take output name from specialized input device 2022-03-17 21:52:59 +03:00
Simon Zeni 0345148ea6 sway/input/cursor: take device mm size from wlr_tablet 2022-03-17 21:52:59 +03:00
Nihal Jere 1e79088a72 remove unnecessary strlen call 2022-03-15 11:40:32 +01:00
Nihal Jere 78758ef369 swaynag: remove redundant status variables in main
Instead, we just use `status` for all failures.
2022-03-15 11:40:32 +01:00
Nihal Jere 20729a6a5e swaynag: remove unnecessary zero of swaynag struct
Global variables are initialized to 0.
2022-03-15 11:40:32 +01:00
Nihal Jere 4780afb68b swaynag: statically allocate button_close, and move declaration
Every swaynag has a close button, so it doesn't make sense to
allocate it dynamically. The declaration is moved later to when
it is actually needed.
2022-03-15 11:40:32 +01:00
Nihal Jere 0babfce4b5 swaynag: allocate button_details with details
They are used together, so it doesn't make sense to allocate them
separately.
2022-03-15 11:40:32 +01:00
Bill Li f167acce3a Updating criteria checking with PCRE2 2022-03-15 11:28:04 +01:00
Simon Ser 3dffe7f3a6 swaybar: set opaque region
When the background color is fully opaque, set the surface's opaque
region to the whole surface.
2022-03-14 13:02:17 -04:00
Simon Ser dd8b6f5e68 swaybar: remove swaybar_output.input_region
No need to keep the region around, we can immediately destroy it
after the wl_surface.set_input_region request.
2022-03-14 13:01:29 -04:00
ndren f614f35e73
Replace pcre with pcre2
Closes: https://github.com/swaywm/sway/issues/6838
2022-03-12 14:02:32 +01:00
Simon Ser 04676936e7 Remove WLR_SWITCH_STATE_TOGGLE usage
Ref [1].

[1]: 4792446ee8
2022-03-08 13:24:11 -05:00
Nicolas Avrutin 9f98c38d3e commands/focus: fix segfault when no container is already focused.
Fixes #6690.
2022-03-06 18:24:16 -07:00
Moon Sungjoon 3444ce7302 sway/input: destroy sway_switch properly
Fix: #6861
Added seat_device_destroy function to seat_device_destroy function.
2022-03-05 20:39:47 +01:00
Alexander Gramiak d6f279902a sway/input: don't pass possibly invalid modifiers pointer
active_keyboard may be NULL, in which case an invalid pointer could be
passed to wlr_input_method_keyboard_grab_v2_send_modifiers. This
procedure call is unnecessary since wlroots commit 372a52ec "input
method: send modifiers in set_keyboard", so the call can simply be
removed.

Fixes #6836.
2022-03-04 08:37:07 +01:00
Nihal Jere 061ffc30ea swaynag: die on all allocation failures 2022-02-28 11:24:13 -05:00
Thomas Hebb 0ee54a5243 Don't enter seatop_move_floating when fullscreen
Currently, a floating window that's been fullscreened can send us
xdg_toplevel::move, and we'll enter seatop_move_floating, which lets us
drag the surface around while it's fullscreen. We don't want
this--fullscreen surfaces should always be aligned to the screen--so add
the same check that seatop_default already does when entering this mode.

Tested with Weston's weston-fullscreen demo, which sends a move request
if you click anywhere on its surface.
2022-02-24 12:12:12 +01:00
Thomas Hebb b38b845c63 Remove some erroneous apostrophes in comments 2022-02-22 09:50:58 +01:00
Simon Zeni 85d1c98476 sway/input: use wlr_input_device from input device base 2022-02-21 20:25:47 +03:00
Simon Zeni f8990523b4 sway/commands: add missing wlr_keyboard interface include in xkb_switch_layout 2022-02-21 20:25:47 +03:00
Simon Ser f707f583e1 Remove all sprintf calls
Replace them with snprintf, which ensures buffer overflows won't
happen.
2022-02-08 09:20:13 -05:00
Muhamed Hobi ac7892371c Fix snprintf compiler warning 2022-02-08 09:43:32 +01:00
Simon Ser 9a6687ee04 xdg-shell: use wlr_xdg_popup in sway_xdg_popup
Improved type safety.
2022-02-07 23:22:16 +03:00
Simon Ser f795aa1c95 xdg-shell: use wlr_xdg_toplevel in sway_view
Improved type safety.

Closes: https://github.com/swaywm/sway/issues/6813
2022-02-07 23:22:16 +03:00
Simon Ser 5c00f1f113 readme: use relative links for translations 2022-02-07 11:04:47 +01:00
Simon Ser 01706f7c90 readme: sort language list alphabetically 2022-02-07 11:03:03 +01:00
Simon Ser c256fd4743 readme: add link to Italian translation 2022-02-07 10:56:31 +01:00
Marco Rubin 3a75b4a6a8 Translated README into Italian 2022-02-07 10:55:55 +01:00
Alexander Browne 36f5467993 Minor update to focus_on_window_activation
Removed xwayland limitation since wayland clients are supported via xdg-activation.
2022-02-06 09:11:06 +01:00
Kirill Primak 30d27b5996 Chase wlroots xdg-shell refactor 2022-02-03 21:01:28 +01:00
Kirill Primak ee7668c1f2 chore: chase wlr_output_layout_get_box() update
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3439
2022-01-31 11:44:03 +01:00
Tuomas Yrjölä 69b430201c xwayland: listen to `request_activate` event
When REAPER submenu is closed `XCB_CLIENT_MESSAGE` with type
`NET_ACTIVE_WINDOW` is sent to set focus to parent menu.

Closes: https://github.com/swaywm/sway/issues/6324
2022-01-31 11:23:36 +01:00
Simon Ser 518e18a54b Use bools for CLI flags 2022-01-31 11:04:26 +01:00
Kirill Primak cd1ee0e172 swaynag: remove buffer destruction condition
An address of a variable can never be NULL, so checking it doesn't make
sense; and `destroy_buffer()` can operate on already destroyed buffers
anyway.

Fixes #6780
2022-01-23 10:41:57 -05:00
Tudor Brindus 8ca2847b42 input/cursor: pass through pointer hold gestures
This just follows swaywm/wlroots#3047, so `wl_pointer_gestures_v1`
clients can be notified of these events.
2022-01-22 23:43:46 +01:00
Ronan Pigott feea4b4410 cmd/swap: error on swapping a container with itself 2022-01-22 19:08:15 +01:00
Tobias Bengfort b4fd4bca0e tray: do not render passive items
https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem/#org.freedesktop.statusnotifieritem.status
2022-01-19 09:20:27 +01:00
Simon Ser a1905c6a08 build: execute wlroots subproject before finding deps
wlroots often requires dependencies more recent than Sway's.
Executing the wlroots subproject first will give Meson a chance to
find these newer dependencies, possibly via subprojects.

The subproject will override the "wlroots" dependency when executed,
so we don't need to use get_variable anymore.

References: https://github.com/swaywm/sway/pull/6498#issuecomment-1001746017
2022-01-18 13:57:50 -05:00
Rouven Czerwinski e4909ab4a3 transaction: destroying nodes aren't hidden
Commit 37d7bc6998 ("transaction: Only wait for ack from visible
views") introduced a check which uses view_is_visible() to check if a view
is still visible on the screen. However view_is_visible() will early
return in case the node is in the destroying state. This is incorrect
for transactions, since a destroying view which is visible will trigger
configure events for other clients. This bug was visible when repeatedly
opening and closing two views side by side, since we ignore the
destroying node we get a frame where the still open view is shown with
the old configure values and the rest is the desktop background. The
next frame is than correct again.

Fix this by considering destroying views as visible, we correctly wait
for them and send the configure events to other views in time, fixing
the background flicker.

Fixes #6473
2022-01-18 19:42:15 +01:00
Patrick Hilhorst b2ee964434 treat fullscreen windows as 'tiled' for commands/focus 2022-01-18 13:25:53 +01:00
Tudor Brindus 7d1ccafae5 input/cursor: treat swipe begin as idle activity too
Accidentally overlooked in fd53f80.
2022-01-17 23:17:36 +01:00
Tudor Brindus fd53f80156 input/cursor: count pointer gestures as idle activity
Fixes https://github.com/swaywm/sway/issues/6765.
2022-01-17 23:05:19 +01:00
Simon Ser 0ffd8178fe commands/focus: drop trailing whitespace 2022-01-16 19:15:57 +01:00
Simon Ser d6f8820a8b Upgrade for wlroots surface refactoring
See [1] for details.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3412
2022-01-13 14:01:37 +03:00
Kirill Chibisov dbaf2e4fdb build: fix building with basu
02b412a introduced the use of list for sdbus deps, however
it was assuming that all packages which were in a list has a version
higher than 239. That is true for libsystemd and libelogind, since they
use the same versions, however basu is using version numbers which are
way lower than what libsystemd/libelogind are using, so basu only build
is failing.
2022-01-12 17:25:34 +01:00
Aleksei Bavshin aa443629b5 xdg-shell: use toplevel geometry to adjust the popup box
`popup_unconstrain` uses view coordinates to init the output box for
popups. However wlroots expects the box to be set in a toplevel surface
coordinate system, which is not always equal to view. The difference
between those is a window geometry set via xdg-shell.

GTK4 reserves some space for client-side decoration and thus has a
window with top left corner not matching to (0, 0) of a surface. The box
calculated without taking that into account was slightly shifted
compared to the actual output and allowed to position part of the popup
off screen.
2022-01-12 14:55:56 +01:00
Kenny Levinsen e1db1f8218 Print deprecation notice when running SUID
SUID privilege drop is needed for the "builtin"-backend of libseat,
which copied our old "direct" backend behavior for the sake of
compatibility and ease of transition.

libseat now has a better alternative in the form of seatd-launch. It
uses the normal seatd daemon and libseat backend and takes care of SUID
for us.

Add a soft deprecation warning to highlight our future intent of
removing this code. The deprecation cycle is needed to avoid surprises
when sway no longer drops privileges.
2022-01-11 12:05:55 +01:00
Kenny Levinsen 470e04e8da meson: check: false on run_command
Future meson releases will change the default and warns when the
implicit default is used, breaking builds.

Explicitly set check: false to maintain behavior and silence warnings.
2022-01-11 11:51:49 +01:00
Simon Ser 6cb69a40c7 Add safety assert in parse_movement_unit
Let's add this just in case a caller passes argc == 0.

References: https://github.com/swaywm/sway/issues/6737#issuecomment-1008082540
2022-01-09 10:17:02 +01:00
Simon Ser e2b4c573d6 Destroy sub-surfaces with parent layer-shell surface
Closes: https://github.com/swaywm/sway/issues/6337
2022-01-08 19:07:27 -07:00
David96 1bf1d84b75 commands/move: Fix crash when pos_y is omitted
Fixes #6737
2022-01-09 00:58:42 +01:00
David Rosca f92329701b container: Fix crash when view unmaps + maps quickly
Followup on 4e4898e90f.

If a view quickly maps and unmaps repeatedly, there will be multiple
destroyed containers with same view in a single transaction. Each of
these containers will then try to destroy this view, resulting in use
after free.
The container should only destroy the view if the view still belongs
to the container.

Simple reproducer: couple XMapWindow + XUnmapWindow in a loop followed
by XDestroyWindow.

See #6605
2022-01-07 18:25:13 +01:00
Nathan Schulte 107d15fafd swaybar: fix tray item icon scaling, positioning 2022-01-07 15:06:29 +01:00
Nathan Schulte bb60381c75 swaybar: fix tray_padding vs min-height re: scale
Co-authored-by: xdavidwu <xdavidwuph@gmail.com>
2022-01-07 15:06:29 +01:00
Thomas Hebb 921b0a8633 input/seat: unset has_focus when focus_stack becomes empty
We currently track the focus of a seat in two ways: we use a list called
focus_stack to track the order in which nodes have been focused, with
the first node representing what's currently focused, and we use a
variable called has_focus to indicate whether anything has focus--i.e.
whether we should actually treat that first node as focused at any given
time.

In a number of places, we treat has_focus as implying that a focused
node exists. If it's true, we attempt to dereference the return value of
seat_get_focus(), our helper function for getting the first node in
focus_list, with no further checks. But this isn't quite correct with
the current implementation of seat_get_focus(): not only does it return
NULL when has_focus is false, it also returns NULL when focus_stack
contains no items.

In most cases, focus_stack never becomes empty and so this doesn't
matter at all. Since focus_stack stores a history of focused nodes, we
rarely remove nodes from it. The exception to this is when a node itself
goes away. In that case, we call seat_node_destroy() to remove it from
focus_stack and free it. But we don't unset has_focus if we've removed
the final node! This lets us get into a state where has_focus is true
but seat_get_focus() returns NULL, leading to a segfault when we try to
dereference it.

Fix the issue both by updating has_focus in seat_node_destroy() and by
adding an assertion in seat_get_focus() that ensures focus_stack and
has_focus are in sync, which will make it easier to track down similar
issues in the future.

Fixes #6395.

[1] There's some discussion in #1585 from when this was implemented
about whether has_focus is actually necessary; it's possible we could
remove it entirely, but for the moment this is the architecture we have.
2022-01-07 14:08:24 +01:00
Seth Barberee b8995ced8f [IPC] Add repeat delay/rate info to keyboard
Closes #6735

wlroots already has the info in the struct so let's access it and print it out.
2022-01-04 10:55:05 +01:00
Simon Ser eaeb173a4b build: bump version to 1.8-dev
Historically we've been sticking with the last release number in
the master branch. However that's a bit confusing, people can't
easily figure out whether they're using a release or a work-in-progress
snapshot. Only the commit hash appended to the version number may
help, but that's not very explicit and disappears when using a
tarball.

We could bump the version in master to the next release number.
However during the RC cycle there would be a downgrade from 1.8 to
1.8-rc1. Also it would be hard to tell the difference between a
stable release and an old snapshot.

This patch introduces a new pre-release identifier, "dev". It's
alphabetically before "rc" so it should be correctly sorted by
semver comparisons. "dev" is upgraded to "rc" (and then to stable)
when doing a release. The master branch always uses a "dev"
version, only release branches use "rc" or stable versions.
2021-12-23 19:08:59 +01:00
Simon Ser 59aebaa5f9 Add cairo_image_surface_create error handling
cairo_image_surface_create can fail, e.g. when running out of
memory or when the size is too big. Avoid crashing in this case.

Closes: https://github.com/swaywm/sway/issues/6531
2021-12-21 14:52:08 -07:00
Simon Ser 414950bbc8 swaybar: fix errno handling in status_handle_readable
If getline fails once, it was not reset before the next getline
call. errno is only overwritten by getline on error.
2021-12-21 12:12:54 +01:00
Simon Ser 513fa00a5e swaymsg: add GET_TREE pretty-printing 2021-12-21 11:07:11 +01:00
Simon Ser d9ce781d4c swaymsg: replace if with switch in pretty_print 2021-12-21 11:07:11 +01:00
Sefa Eyeoglu 17ee30d070 build: bump wlroots dependency to 0.16.0 2021-12-19 12:17:13 +01:00
Ronan Pigott 9ecbfe3665 output: emit node::destroy event
Now output_begin_destroy emits the node::destroy event similar to
workspace_begin_destroy. It currently has no listeners, since they
listen to output::disable or wlr_output::destroy instead.
2021-12-17 14:39:48 +01:00
Ronan Pigott ebfe432ec3 output: change output::destroy to output::disable
This changes output::destroy to output::disable and emits it only
once when an output is disabled, instead of twice in succession.
2021-12-17 14:39:48 +01:00
RoastVeg f2b6d1ec29 Handle border width and height on minimum floating sizes
This fixes: https://github.com/swaywm/sway/issues/5337

Co-authored-by: Moon Sungjoon <sumoon@seoulsaram.org>
2021-12-14 10:30:10 +01:00
Cole Mickens 0b4e3d39eb meson.build: require wayland-protocols 1.24
As far as I can tell `ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT` is introduced in wayland-protocols 1.24.
2021-12-14 10:00:15 +01:00
Simon Ser 57a7b3998e swaynag: remove xdg-output logic
We can just get the output name from wl_output directly, now that
wl_output version 4 exists.
2021-12-13 20:17:20 -06:00
Simon Ser 4732325f59 Add support for linux-dmabuf surface hints
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/1376
2021-12-13 09:59:33 -06:00
Alexander Orzechowski 8a3026337f view: Fix null dereference
There seems to be a null pointer access that can happen. I was able to
reproduce this by running the cemu emulator[1] with the new collabora
wine wayland driver[2] and opening and closing some sub menus.

Adding a trival null check seems to do the trick to stop sway from
crashing and returning to tty and everything else works normally.

[1]: http://cemu.info/
[2]: https://www.winehq.org/pipermail/wine-devel/2021-December/203035.html

Stack trace from lldb:

* thread #1, name = 'sway', stop reason = signal SIGSEGV: invalid address (fault address: 0xf8)
    frame #0: 0x00005555555c3fc3 sway`view_child_init(child=0x0000555555f67940, impl=0x00005555555ee030, view=0x00005555565bc590, surface=0x00005555565b6940) at view.c:1117:25
   1114		wl_signal_add(&view->events.unmap, &child->view_unmap);
   1115		child->view_unmap.notify = view_child_handle_view_unmap;
   1116	
-> 1117		struct sway_workspace *workspace = child->view->container->pending.workspace;
   1118		if (workspace) {
   1119			wlr_surface_send_enter(child->surface, workspace->output->wlr_output);
   1120		}
(lldb) up
error: sway {0x000342ab}: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x67) attribute, but range extraction failed (invalid range list offset 0x67), please file a bug and attach the file at the start of this error message
frame #1: 0x00005555555c39f8 sway`view_child_subsurface_create(child=0x00005555564a10d0, wlr_subsurface=0x0000555556586910) at view.c:985:2
   982 		}
   983 		subsurface->child.parent = child;
   984 		wl_list_insert(&child->children, &subsurface->child.link);
-> 985 		view_child_init(&subsurface->child, &subsurface_impl, child->view,
   986 			wlr_subsurface->surface);
   987 	
   988 		wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy);
(lldb) up
frame #2: 0x00005555555c3c2a sway`view_child_handle_surface_new_subsurface(listener=0x00005555564a1130, data=0x0000555556586910) at view.c:1031:2
   1028		struct sway_view_child *child =
   1029			wl_container_of(listener, child, surface_new_subsurface);
   1030		struct wlr_subsurface *subsurface = data;
-> 1031		view_child_subsurface_create(child, subsurface);
   1032	}
   1033	
   1034	static void view_child_handle_surface_destroy(struct wl_listener *listener,
(lldb) up
frame #3: 0x00007ffff78f4bfe libwlroots.so.10`wlr_signal_emit_safe(signal=0x00005555565b2470, data=0x0000555556586910) at signal.c:29:3
   26  			wl_list_remove(&cursor.link);
   27  			wl_list_insert(pos, &cursor.link);
   28  	
-> 29  			l->notify(l, data);
   30  		}
   31  	
   32  		wl_list_remove(&cursor.link);
(lldb) up
frame #4: 0x00007ffff78e5a41 libwlroots.so.10`subsurface_parent_commit(subsurface=0x0000555556586910) at wlr_surface.c:517:3
   514 	
   515 		if (!subsurface->added) {
   516 			subsurface->added = true;
-> 517 			wlr_signal_emit_safe(&subsurface->parent->events.new_subsurface,
   518 				subsurface);
   519 		}
   520 	}
(lldb) up
frame #5: 0x00007ffff78e56fa libwlroots.so.10`surface_commit_state(surface=0x00005555565b21b0, next=0x00005555565b2338) at wlr_surface.c:439:3
   436 			wl_list_insert(&surface->current.subsurfaces_above,
   437 				&subsurface->current.link);
   438 	
-> 439 			subsurface_parent_commit(subsurface);
   440 		}
   441 		wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
   442 				pending.link) {
(lldb) up
frame #6: 0x00007ffff78e5b88 libwlroots.so.10`surface_handle_commit(client=0x0000555556564c80, resource=0x0000555556599a20) at wlr_surface.c:555:3
   552 		if (surface->pending.cached_state_locks > 0 || !wl_list_empty(&surface->cached)) {
   553 			surface_cache_pending(surface);
   554 		} else {
-> 555 			surface_commit_state(surface, &surface->pending);
   556 		}
   557 	}
   558 	
(lldb) up
frame #7: 0x00007ffff7000d4a libffi.so.8`___lldb_unnamed_symbol118 + 82
libffi.so.8`___lldb_unnamed_symbol118:
->  0x7ffff7000d4a <+82>: leaq   0x18(%rbp), %rsp
    0x7ffff7000d4e <+86>: movq   (%rbp), %rcx
    0x7ffff7000d52 <+90>: movq   0x8(%rbp), %rdi
    0x7ffff7000d56 <+94>: movq   0x10(%rbp), %rbp
(lldb) up
frame #8: 0x00007ffff7000267 libffi.so.8`___lldb_unnamed_symbol115 + 439
libffi.so.8`___lldb_unnamed_symbol115:
->  0x7ffff7000267 <+439>: movq   -0x38(%rbp), %rax
    0x7ffff700026b <+443>: subq   %fs:0x28, %rax
    0x7ffff7000274 <+452>: jne    0x7ffff70004e7            ; <+1079>
    0x7ffff700027a <+458>: leaq   -0x28(%rbp), %rsp
(lldb) up
frame #9: 0x00007ffff795a173 libwayland-server.so.0`___lldb_unnamed_symbol271 + 371
libwayland-server.so.0`___lldb_unnamed_symbol271:
->  0x7ffff795a173 <+371>: movq   0x8(%r12), %rax
    0x7ffff795a178 <+376>: movq   0x8(%rax), %rdi
    0x7ffff795a17c <+380>: movl   (%r12), %eax
    0x7ffff795a180 <+384>: testl  %eax, %eax
(lldb) up
frame #10: 0x00007ffff795555c libwayland-server.so.0`___lldb_unnamed_symbol210 + 588
libwayland-server.so.0`___lldb_unnamed_symbol210:
->  0x7ffff795555c <+588>: jmp    0x7ffff7955435            ; <+293>
    0x7ffff7955561 <+593>: nopl   (%rax)
    0x7ffff7955568 <+600>: callq  *0xd76a(%rip)
    0x7ffff795556e <+606>: cmpl   $0xb, (%rax)
(lldb) up
frame #11: 0x00007ffff795804a libwayland-server.so.0`wl_event_loop_dispatch + 202
libwayland-server.so.0`wl_event_loop_dispatch:
->  0x7ffff795804a <+202>: addq   $0xc, %r15
    0x7ffff795804e <+206>: cmpq   %r15, %rbp
    0x7ffff7958051 <+209>: jne    0x7ffff7958038            ; <+184>
    0x7ffff7958053 <+211>: movq   0x8(%rsp), %rcx1
(lldb) up
frame #12: 0x00007ffff7955bc7 libwayland-server.so.0`wl_display_run + 39
libwayland-server.so.0`wl_display_run:
->  0x7ffff7955bc7 <+39>: movl   0x8(%rbx), %eax
    0x7ffff7955bca <+42>: testl  %eax, %eax
    0x7ffff7955bcc <+44>: jne    0x7ffff7955bb0            ; <+16>
    0x7ffff7955bce <+46>: popq   %rbx
(lldb) up
frame #13: 0x00005555555756eb sway`server_run(server=0x00005555555f0640) at server.c:296:2
   293 	void server_run(struct sway_server *server) {
   294 		sway_log(SWAY_INFO, "Running compositor on wayland display '%s'",
   295 				server->socket);
-> 296 		wl_display_run(server->wl_display);
   297 	}
(lldb) up
frame #14: 0x0000555555574947 sway`main(argc=1, argv=0x00007fffffffe8d8) at main.c:428:2
   425 			swaynag_show(&config->swaynag_config_errors);
   426 		}
   427 	
-> 428 		server_run(&server);
   429 	
   430 	shutdown:
   431 		sway_log(SWAY_INFO, "Shutting down sway");
(lldb) up
frame #15: 0x00007ffff761db25 libc.so.6`__libc_start_main + 213
libc.so.6`__libc_start_main:
->  0x7ffff761db25 <+213>: movl   %eax, %edi
    0x7ffff761db27 <+215>: callq  0x7ffff7635630            ; exit
    0x7ffff761db2c <+220>: movq   (%rsp), %rax
    0x7ffff761db30 <+224>: leaq   0x163929(%rip), %rdi
(lldb) up
frame #16: 0x00005555555656be sway`_start + 46
sway`_start:
->  0x5555555656be <+46>: hlt    
    0x5555555656bf:       nop    
sway`deregister_tm_clones:
    0x5555555656c0 <+0>:  leaq   0x8aeb9(%rip), %rdi       ; optind@GLIBC_2.2.5
    0x5555555656c7 <+7>:  leaq   0x8aeb2(%rip), %rax       ; optind@GLIBC_2.2.5

Signed-off-by: Alexander Orzechowski <orzechowski.alexander@gmail.com>
2021-12-13 14:51:13 +01:00
Vsevolod f7725011ef
Add focused_tab_title 2021-12-10 16:09:29 +01:00
Simon Ser 3f58f12617 Fixup headless output names
We use the headless backend to create a special fallback output
used when no other output is connected. However this messes up the
"real" headless output names users have come to expect (e.g.
currently the first headless output will be named "HEADLESS-2"
instead of "HEADLESS-1").

Fix this by setting the output name with [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3395
2021-12-09 10:47:01 -06:00
M.Zeinali 1eaa61f503
readme: use right-to-left marks in ir translation 2021-12-07 15:26:57 +01:00
Kirill Primak 03a29ed36d output: remove surface buffer damage check
A surface can have effective damage even without any buffer damage
committed.
2021-12-06 16:44:34 +01:00
Simon Ser b518b1295c Delete .clang-format
This file isn't accurate, and clang-format can't describe our code
style.

References: https://github.com/swaywm/sway/pull/6249#issuecomment-986214042
2021-12-06 08:27:11 -06:00
Simon Ser 02b412a3d4 build: use list for sdbus dep
This allows to simplify our logic. Meson will pick the first found
library.
2021-11-26 12:10:18 -06:00
Simon Zeni 0cd8efe0bb sway: replace noop_output by fallback_output
wlroots removed the support for the noop backend. Instead we rely on the
headless backend to provide the fallback output.
2021-11-25 17:48:34 +01:00
Simon Ser 729e18bff5 Replace wlr_headless_backend_create_with_renderer call
Update for the wlroots breaking change in [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3367
2021-11-25 09:39:06 -06:00
Ludvig Michaelsson f627cd77d6 swaybar: signal status command's process group
Make the status command a process group leader and change the kill(2)
calls to target the new process group. Signals sent by swaybar will then
be received by both the status command and its children, if any. While
here, check the result of fork(2).

Without this, children spawned by the status command may not receive the
signals sent by swaybar. As a result, these children may be orphaned on
reload.

The issue could be shown by setting the bar to

    bar {
        status_command i3status | tee /tmp/i3status.out
    }

which would leave orphaned processes for each reload of sway

    $ ps o pid,ppid,cmd | grep i3status | grep -v grep
    43633   43624 sh -c i3status | tee /tmp/i3status.out
    43634   43633 i3status
    43635   43633 tee /tmp/i3status.out

    $ swaymsg reload

    $ ps o pid,ppid,cmd | grep i3status | grep -v grep
    43634       1 i3status
    43635       1 tee /tmp/i3status.out
    43801   43788 sh -c i3status | tee /tmp/i3status.out
    43802   43801 i3status
    43803   43801 tee /tmp/i3status.out

This fixes #5584.
2021-11-25 12:09:12 +01:00
Aleksei Bavshin 94dc486f0e ipc: make `bar <bar_id> mode|hidden_state` behave as documented
sway-bar(5) says:

> For compatibility with i3, bar mode <mode> [<bar-id>] syntax is
> supported along with the sway only bar <bar-id> mode <mode> syntax.

while the actual behavior is that `bar_cmd_mode` ignores already
selected `config->current_bar` and applies the change to all the
configured bars.
2021-11-25 11:32:46 +01:00
Manuel Stoeckl a23cdbbea1 Add 'output render_bit_depth [8|10]' command
This makes it possible to hint to the renderer and backends how many
bits per channel the buffers that the compositor draws windows onto
should have. Renderers and backends may deviate from this if they
do not support the formats with higher bit depth.
2021-11-23 15:51:54 +01:00
Simon Zeni 5865af75cf sway: create wlr_renderer and wlr_allocator
wlroots now required the compositor to create its own wlr_renderer and
wlr_allocator to initialize the wlr_output
2021-11-18 17:47:19 +01:00
Kirill Primak cbecc5cbae container: fix surface_is_popup() 2021-11-15 10:12:23 +01:00
Eric Engestrom bb7bb3676d sway: allow IPCs on proprietary drivers
Proprietary drivers require --unsupported-gpu to be allowed, and IPCs
require no option to be passed.

The only way to satisfy both is to run IPCs before checking for
proprietary drivers.
2021-11-14 10:43:09 +03:00
Manuel Stoeckl fc25e4944e Update URL to wlroots project (GitHub->GitLab) 2021-11-02 08:43:24 +01:00
Simon Ser 38020d157d Bump RLIMIT_NOFILE
Wayland compositors handle many file descriptors: client
connections, DMA-BUFs, sync_files, wl_data_device pipes, and so
on. Bump the limit to the max.

Closes: https://github.com/swaywm/sway/issues/6285
2021-10-30 08:19:35 -06:00
bR3iN 9969de9e00 Add smart_gaps inverse_outer command
Add a subcommand for `smart_gaps` that enables outer gaps only
on workspaces with exactly one visible child.
Also add documentation for `smart_gaps toggle`.
2021-10-29 13:37:58 +02:00
Rasmus Moorats aaf68cf423 fix cursor input for layer-shell surfaces
previously, fullscreen global containers would grab cursor input
even if a shell-layer surface was on top of it

related issue: https://github.com/swaywm/sway/issues/6501
2021-10-26 15:13:37 +03:00
Jason Nader 9303bed4d4 refactor: use JSON_MAX_DEPTH everywhere 2021-10-25 10:18:40 +02:00
Sefa Eyeoglu b223f70250 refactor: use sway_abort instead 2021-10-22 09:57:05 +02:00
Sefa Eyeoglu 96baef8ae9 fix: use sane value for json_tokener max_depth
INT_MAX causes a NULL pointer if there is not enough memory available to
fit (INT_MAX * sizeof(struct json_tokener_srec)).
2021-10-22 09:57:05 +02:00
Sefa Eyeoglu 944d7031c5 fix: handle NULL from json_tokener_new_ex
if there is not enough memory to fit json_tokener and (depth *
json_tokener_srec) in RAM, don't segfault.
2021-10-22 09:57:05 +02:00
siikamiika 21d2fdf74c view: add new container as a sibling of tiled view
If the focused container is floating by itself, create a new container
in tiling mode as a sibling of the inactive focused container instead of
creating it as a sibling of everything that is in tiling mode in that
workspace. This is the i3 behavior.
2021-10-21 13:16:36 -07:00
siikamiika 197d0ab82f commands/focus: focus view inside container
seat_get_focus_inactive_floating and seat_get_focus_inactive_tiling do
not always return a view, so get the previously focused view from the
container with seat_get_focus_inactive_view. This is the i3 behavior.
2021-10-21 13:13:54 -07:00
David Rosca 215787e8b2 xwayland: Clear wlr_xwayland_surface in handle_destroy
If the destroyed xwayland view is in transaction, it won't
be destroyed immediately. wlr_xwayland_surface then becomes
dangling pointer.

Closes #6605
Closes #5884
2021-10-19 10:42:19 +03:00
Simon Ser b48cb6b0ec Remove --my-next-gpu-wont-be-nvidia
Nvidia has historically been a bad actor in the open-source graphics
ecosystem because they required a special EGLStreams code-path
instead of exposing the de-facto standard GBM API. However, with
their upcoming release they now support GBM as well.

This is a push in the right direction for Nvidia, so there's no
reason we should be more hostile to them than to any other proprietary
driver. Let's remove the --my-next-gpu-wont-be-nvidia flag, and advise
users to use --unsupported-gpu now.

Note, proprietary Nvidia drivers are still unsupported by the Sway
project (just like all other proprietary drivers).
2021-10-19 09:26:06 +02:00
Jason Nader db70f6496c swaymsg: fix misplaced return value 2021-10-18 14:20:24 +02:00
Jason Nader 55cd8abd76 swaymsg: be explicit about the json parser error 2021-10-18 14:20:24 +02:00
Jason Nader f873bcc4e1 swaymsg: use INT_MAX max JSON depth when parsing IPC response
Same reasoning as fe11caeac9.
Without this, swaymsg would fail with a cryptic error message
when the JSON was nested too deep.
2021-10-18 14:20:24 +02:00
Nihal Jere 119f31edb4 config.in: use swaynag -B instead of -b
'-b' spawns a terminal, which is unnecessary for this use case
2021-10-17 21:30:33 +02:00
Simon Ser 1df2450689 github: don't truncate debug logs
This happens a lot, the latest one is [1].

[1]: https://github.com/swaywm/sway/issues/6570
2021-10-17 21:28:51 +02:00
Birger Schacht ca8c6c3d18 Fix a couple of typos 2021-10-16 02:16:12 -04:00
Simon Ser 0c210a5e68 Handle present events with NULL timespec field
See [1].

[1]: https://github.com/swaywm/wlroots/pull/3245
2021-10-15 19:34:03 +02:00
Jonas Große Sundrup 555cd96e05 cross-reference further documentation 2021-10-15 15:20:40 +02:00
Jonas Große Sundrup 35d29185a8 change incorrectly documented output types 2021-10-15 15:20:40 +02:00
Jonas Große Sundrup bccf76d90b clarify the type of raw output 2021-10-15 15:20:40 +02:00
siikamiika f4db502d44 use node_is_view 2021-10-10 09:35:15 +02:00
Jari Ronkainen 624ffa4516 Improve built-in touchscreen detection
Adds detection code to handle pci-*-platform-* strings
in ID_PATH

References: https://github.com/swaywm/sway/issues/6590

Signed-off-by: Jari Ronkainen <ronchaine@gmail.com>
2021-10-08 19:09:42 +02:00
Nathan Schulte 83310f5abf swaybar: fix cairo_font_options leak 2021-10-08 09:33:03 +02:00
Tassilo Horn a47f8ef478 Fix compile after wlroots commit c3e54021f8bbf3ec1c1e5906459be0ae85f5fb8c 2021-10-07 21:29:37 +03:00
Simon Ser 06e97e51af readme: drop recommendation about packaging
- The contact info is out-of-date
- Sway is packaged in many distributions now
- I don't think we necessarily need to mention this in the README
2021-10-07 19:08:58 +03:00
Bartel Sielski 8fa7b99859 idle_inhibit: Fix tree view after changes in commit 152a559e
Commit 152a559e replaced the view pointer in the inhibitor struct with a
pointer to the wlr_inhibitor for application inhibitors. But this was not
changed in the sway_idle_inhibit_v1_application_inhibitor_for_view function.
This caused a bug in the sway tree view where the application inhibitor is
always "none".
2021-10-04 16:25:35 +02:00
Elyes HAOUAS 8aae6a8eab sway-input.5.scd: Fix spelling errors
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:21:28 +02:00
Evgeniy Khramtsov ff468584ab commands: Remove unused code after 1d3681f521
Clang 13 reports:

../sway/commands.c:470:23: error: variable 'context' set but not used
[-Werror,-Wunused-but-set-variable]
        enum command_context context = 0;
                             ^
Last use of was removed in commit 1d3681f521.

Downstream PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258813
2021-10-01 15:45:09 +02:00
Simon Ser c43f1fbf1c Chase wlr_xdg_surface breaking changes
See [1].

[1]: https://github.com/swaywm/wlroots/pull/3106
2021-10-01 00:21:56 +03:00
Simon Ser 1bd8e3b469 Add support for DRM panel orientation
References: https://github.com/swaywm/wlroots/pull/3205
2021-09-28 21:27:15 +02:00
Simon Ser 5fdc1c894d readme: add missing space 2021-09-28 21:01:28 +02:00
Kirill Primak 5fd5d6434e layer-shell: fix commit handler
This commit makes sure the extents are kept up-to-date, fixes not
damaging the surface if its layer shell-specific state didn't change,
and adds a check if the layer shell-specific state didn't change but the
surface got mapped/unmapped, which could affect keyboard focus.
2021-09-25 22:21:51 +03:00
Kirill Primak c11b5db4d6 layer-shell: check `committed` bitmask
This avoids infinite configure-ack_configure-commit loop.
2021-09-24 14:40:59 +02:00
Kirill Primak b7b3ef6dcf layer-shell: chase wlr layer surface refactor 2021-09-23 21:32:56 +02:00
Kirill Primak b7b96399e1 xdg-shell: remove unused request_maximize listener 2021-09-21 14:29:37 +02:00
Kirill Primak b1d41db6cf Revert "xdg_shell: schedule configure on maximize requests"
This reverts commit 4dd46f06ac, as the
logic is now handled by wlroots.
2021-09-21 14:29:37 +02:00
Kirill Primak eb03298b46 xdg-shell: chase wlr xdg toplevel refactor 2021-09-21 10:12:27 +02:00
Simon Ser 82d5f12914 Add -Dnoscanout debug option
This can help debugging direct scan-out issues, such as [1].

[1]: https://github.com/swaywm/wlroots/issues/3185
2021-09-20 14:22:35 +02:00
Nathan Schulte 033061aee6 swaybar: properly draw blocks with transparent black border
while the draw itself is a no-op, alignment must still be accounted
this requires more signalling about the blocks (border_set; was the
border set?)
2021-09-20 09:53:32 +02:00
Hugo Osvaldo Barrera a345180520 Drop hardcoded font metric values 2021-09-20 09:25:47 +02:00
Hugo Osvaldo Barrera c16b2a26ed Avoid unecessary font metric calculations
Prior to 62d90a8e, titlebar's font height (and other related values)
would change any time any titlebar's content changed, so these values
were recalculated each time any titlebar's content changed (or a new
titlebar was created).

However, since the above was merge, these values no longer change so
often and we only need to recalculate them when the configured font
changes (and stop calling `config_update_font_height` each time
titlebars are rendered).

This commit removes all the unecessary calls to this function and avoids
all those unecessary calculations. Whenever the font strays from the
default value, the `font` command is called, and it calls
`config_update_font_height`, which is enough to keep the value always up
to date.

I've also added a default value to the `font_baseline` config, since
otherwise that's zero for setups that don't explicitly specify a font.
2021-09-20 09:25:47 +02:00
aajonusonline 49da73d4ac sway-ipc.7.scd: fix typo 2021-09-19 17:28:37 +02:00
Christian Llupo f1f283dd77 README: Added Greek translation 2021-09-19 14:14:42 +02:00
Nathan Schulte 8d0a84f3c7 swaybar: properly draw urgent block right border
introduced via #3287 -- https://github.com/swaywm/sway/pull/3287/files#diff-a1e918ce0bc71f4f7934767541319e724a51a34a5418ecdc286065e50921eda4L239
uncovered via #3394 -- https://github.com/swaywm/sway/pull/3394/files#diff-a1e918ce0bc71f4f7934767541319e724a51a34a5418ecdc286065e50921eda4R258
2021-09-15 09:26:08 +02:00
Simon Ser 9727db67cf build: remove scdoc stdin/stdout hack
Since [1], Meson allows feeding the input file as stdin and
capturing stout to the output file. We don't need the sh hack
anymore.

[1]: https://github.com/mesonbuild/meson/pull/8923
2021-09-15 08:21:20 +02:00
Kenny Levinsen 94e041b5f6 readme: Align Danish translation with main README 2021-09-13 17:05:28 +02:00
Simon Ser 1b86008721 readme: mention seatd
When seatd is used, it isn't necessary to suid the sway binary.
2021-09-13 16:10:05 +02:00
xdavidwu 806b59eca3 swaynag: fix pointer button events on scaled outputs
sway#6504 simplified rendering code by setting scaling at cairo, but
that also changed button position records into ones without scale
multiplication, breaking button events. This fixes it by not multiplying
scale on events handling as well.
2021-09-13 14:46:01 +02:00
Simon Ser 3f7a04df22 Rename pango_printf to render_text
This avoids using the pango_ prefix, reserved for functions coming
from the Pango library.
2021-09-13 14:22:51 +02:00
Simon Ser 671bb448a1 readme: link to gamja for IRC
gamja offers a better experience than Kiwi.

Obviously I'm 100% biased. Completely fine to not make the switch if someone feels differently.
2021-09-13 10:58:45 +02:00
Simon Ser d0cb52db64 readme: switch to Libera Chat for ir 2021-09-13 08:29:12 +02:00
Caduser2020 57ae751655 Simplify swaybar/swaynag scaling code
Use `cairo_scale` to set the scale factor, removing redundant
multiplications by `output->scale`.
2021-09-12 09:05:12 +02:00
Simon Zeni 30c28ff8f7 introduce wlr_drm_lease_v1
This prevents sway from extending the desktop to i.e. VR headsets, and makes
them available for DRM leasing.

Non-desktop wlr_outputs will be offered through the wlr_drm_lease_v1_manager
interface for client to lease.
2021-09-09 15:25:19 +02:00
Kirill Primak e76e13ef85 view: fix child position calc
Previously, the position was calculated incorrectly for nested
subsurfaces.
2021-09-08 09:36:17 +02:00
lbonn adf9e16c88 build: subproject support for wayland-protocols
As in wlroots: [1]

[1]: https://github.com/swaywm/wlroots/pull/2953
2021-09-08 08:19:40 +02:00
Kirill Primak 91d6d00414 render: fix -Ddamage=rerender 2021-09-07 14:52:29 +02:00
Kirill Primak ae80bdedf9 surface: chase wlr subsurface list/link change 2021-09-06 17:39:28 +02:00
Kirill Primak 72b0491ca0 view: fix saved buffer order 2021-09-05 12:31:46 +02:00
Daniel De Graaf 69a7b9215e Fix overly-wide mark textures
The width of the texture needs to be calculated using the string that is
actually displayed in the texture.
2021-09-04 17:23:06 +02:00
Ronan Pigott 00b10a93f1 commands: update split none command for a047b5ee4 2021-09-04 00:24:47 +02:00
Ronan Pigott de3c290427 command: implement split none 2021-09-03 23:50:20 +02:00
Simon Plakolb 4baf845a3a seatop_down: End if surface is destroyed or other seatop starts
If the surface the pointer started to interact with is destroyed we also
want the seatop_down to end. In case a drag is initiated we receive a
call to handle_end.
2021-09-02 13:13:40 -04:00
Simon Plakolb 9e58425cb3 input: Use seatop_down on layer surface click
This solves an issue where layer-shell items would not receive a button
release event when the pointer left them while being pressed. The
default seatop changes focus immediately while seatop_down defers any
focus changes until the pointer is released or seatop_down is destroyed.
2021-09-02 13:13:40 -04:00
David Rosca 57d6f6f19e Add `output modeline` command
Only works with DRM backend.
2021-08-31 17:29:40 +02:00
Tudor Brindus daaec72ac0 desktop/xwayland: restack surface upon activation
This commit updates Sway for swaywm/wlroots#2915.
2021-08-28 22:04:31 +02:00
Nihal Jere 1ea5f015f5 config.in: use portable hour specifier
`%l` is GNU specific. `%I` does the same thing but padded by zeros,
and is POSIX compliant.
2021-08-27 19:28:56 +02:00
Hugo Osvaldo Barrera 9acb015755 Deduplicate code for rendering titlebar texts
The title itself and marks were being rendered by two very-similar yet
different functions, and any changes made to one had to be reflected on
the other.

This mostly prevents such oversights from happening, and keeps makes
sure we keep both consistent.
2021-08-27 10:12:57 +02:00
Hugo Osvaldo Barrera 62d90a8e95 Use fixed titlebar heights
Use fixed titlebar heights. The default height is calculated based on
font metrics for the configured font and current locale.

Some testing with titles with emoji and CJK characters (which are
substantially higher in my setup) shows that the titlebars retain their
initial value, text does shift up or down, and all titlebars always
remain aligned.

Also drop some also now-unecessary title_height calculations.

Makes also needed to be updated, since they should be positioned with
the same rules.
2021-08-26 20:16:14 +02:00
grumpey bb3fd0abc5 Update Pango font description URL in sway.5.scd
Along with f4cda51 fixes #6217.
2021-08-19 18:06:29 +02:00
quinno d0c5c5a60b Fix typo in sway.5.scd
small typo fix (ptt => ppt)
2021-08-16 14:05:48 +02:00
Simon Ser c9060bcc12 layer-shell: replace close() with destroy()
Update for the wlroots breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3108
2021-08-14 20:29:59 +02:00
Eric Engestrom b17cf58a4d cmd_bind_or_unbind_switch: fix copy/paste typo error message
`[0]` is the switch type, not its state; we want `[1]` for that, and
it's a string not an int :)
2021-08-14 10:46:17 +02:00
Simon Ser 4cdc4ac63a Fallback to other output modes if preferred mode fails
Sometimes the preferred mode is not available due to hardware
constraints (e.g. GPU or cable bandwidth limitations). In these
cases it's better to fallback to lower modes than to end up with
a black screen.
2021-08-12 21:06:26 +02:00
Ronan Pigott f67ed6772c layer_shell: damage previous area when a surface shrinks
When a layer surface shrinks we need to damage the area it previously
occupied, but we don't know the location of all its subsurfaces in the
previous state, so instead damage a rectangle that encloses the entire
previous extent.
2021-08-12 10:05:12 +02:00
Dudemanguy acf946fe4c xdg-decoration: let floating clients set borders
The xdg-decoration protocol allows clients to request whether they want
to use server side decorations or client side decorations. Currently,
sway ignores this and always enforces whatever the server is currently
set to. Although tiled clients cannot be allowed to set borders, there
is no harm in listening requests from floating clients. Sidenote: also
fix an unrelated style error.
2021-08-12 10:02:17 +02:00
Simon Ser 7a15e715b7 Document view_map 2021-08-12 00:15:04 +02:00
mzeinali b345d6e5d2 Add persian README file 2021-08-10 15:55:57 +02:00
David Rosca d0fe721fbb seatop_down: Change type of sx, sy to double in begin_seatop_down
Losing the precision resulted in wlr_cursor and wlr_seat::pointer_state
getting out of sync during pointer motion in seatop_down.
Since the difference was always under 1 px, it was practically
impossible to notice in normal use.

But because of being out of sync, cursor_rebase would always end up
incorrectly calling wlr_seat_pointer_notify_motion from
seatop_default_begin (on releasing mouse button) which broke cursor
locking.

See #5405
Closes #4632
2021-08-05 09:26:11 -04:00
frogtile f4cda5157e
man: update Pango font description URL
The old URL gives a 404.
2021-08-04 02:15:04 +02:00
Simon Zeni 6ffa4b1f70 view: remove reference to wlr_wl_shell_surface 2021-07-27 17:31:29 +02:00
Simon Ser daf9ad1af7 swaybar: log Wayland display errors 2021-07-26 16:58:28 +02:00
Simon Ser a71bbdd322 swaybar: exit cleanly when disconnected from IPC 2021-07-26 16:58:28 +02:00
Simon Ser 2e03a61262 Fix wl_pointer.frame not sent on touch emulation
When emulating touch, the simulating_pointer_from_touch field is
set to true. It's switched back to false when a touch_up event is
received. However we need to ensure we always send a wl_pointer.frame
event following a group of other wl_pointer events.

Since a touch_frame event is always guaranteed to come after a group
of touch events, unset simulating_pointer_from_touch in the touch_frame
handler instead of the touch_up handler. Add a new field to know whether
the touch_frame handler should stop emulation.
2021-07-26 16:58:11 +02:00
Tobias Stoeckmann e7f4e50da0 Fix crash when starting without HOME
If HOME environment variable is not set, sway fails startup with a
segmentation fault due to null pointer dereference.

Also check calloc return value and only perform the fallback code when
really needed.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2021-07-23 20:05:16 +02:00
bR3iN c9458b9fb1 Add `gaps <type> <scope> toggle <px>` command
Add a subcommand for `gaps` that allows to toggle gaps at
runtime. This functionality is part of i3-gaps since [1]
but is missing in sway.

[1] https://github.com/Airblader/i3/pull/264
2021-07-22 10:12:33 +02:00
Dylan Araps 2024725cc0 Add meson options to enable/disable swaybar and swaynag 2021-07-21 18:24:09 +02:00
Hugo Osvaldo Barrera 96102184ab grimshot: Exit 1 on cancellation
Whenever the selection is cancelled by the user, exit 1, since not
screenshot has been taken.
2021-07-10 13:03:42 +02:00
Simon Ser 7114030159 Add support for touch frame events
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3001
2021-07-08 09:18:20 +02:00
Simon Ser 4832fc937f Update wlr_box includes
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3011
2021-07-07 11:29:14 +02:00
Dudemanguy c41dc33590 container: ignore borders in fullscreen windows
When setting the geometry from content for floating windows, the
coordinates for borders are normally taken into account. However in the
case of a floating fullscreen window, we should not be doing this. Since
the content of the container takes the space of the entire output, this
causes the calculated borders to neccesarily be outside of the output.
This later causes a problem when sending surface entrance events since
in a multi-monitor setup, the border coordinates will overlap with
another output despite the surface not actually being on that output at
all. The fix is to just ignore border coordinates for a floating
fullscreen container since fullscreen, of course, does not actually have
any borders. Fixes #6080.
2021-07-06 22:54:24 +02:00
Simon Ser 22226560e3 tree/container: fix indentation 2021-07-05 10:09:39 +02:00
Jack Byrne 1b8719f167 Change 'Danish' to 'Dansk' in README
Danish is the only language in the README that is not named in its own language.

<sorry for the frivolity but the inconsistency bugs me>
2021-06-30 16:16:53 +02:00
Simon Ser 56733bc6fe ci: make Meson warnings fatal
New warnings can be hard to notice in CI, since CI will just pass in
that case. Meson sometimes uses warnings for important mistakes, e.g.
invalid option.

Let's turn warnings into errors so that we can spot these more easily.
2021-06-30 13:37:00 +02:00
Simon Ser 151193b4cd build: use ExternalProgram.full_path instead of path
ExternalProgram.path has been deprecated.
2021-06-30 13:37:00 +02:00
Simon Ser 5f3773f21e build: use Dependency.get_variable instead of get_pkgconfig_variable
Dependency.get_pkgconfig_variable has been deprecated.
2021-06-30 13:37:00 +02:00
Simon Ser 8348178c66 build: use meson.global_build_root()
meson.build_root() is deprecated.

References: https://github.com/mesonbuild/meson/pull/8629
2021-06-30 13:37:00 +02:00
Simon Ser 5cdce42d1b contrib: drop incr_version script
This isn't used anymore.
2021-06-24 18:35:00 +02:00
Simon Ser c53ef02385 build: bump wlroots dependency to 0.15.0 2021-06-23 14:32:31 +02:00
Kenny Levinsen 4df9f49dc1 ci: Test wlroots static linking 2021-06-23 09:55:36 +02:00
Kenny Levinsen 80315217f7 input: Move get_current_time_msec in from util
get_current_time_msec is only used in cursor.c, so we can move it in and
make it static. This is primarily intended to avoid a symbol collision
with wlroots, which we unfortunately do not have a good solution for
yet.
2021-06-23 09:55:36 +02:00
Ragnar Groot Koerkamp f81dc1ecc0 Update clang format to better match existing code 2021-06-22 20:21:45 +02:00
Ragnar Groot Koerkamp c0c4e260c4 Revert "Add workspace {prev,next}_on_output --create"
This reverts commit 487c83f0de.

The --create flag is undocumented, not in i3, and at least partially
broken (#5913), so this removes the feature.
2021-06-22 19:00:31 +02:00
novenary dbc326ba84 Don't apply hide_edge_borders to any floating container
This fixes the following scenario:
- Place a floating window so its border is right at the edge of the
  screen
- Create a new split
- The border disappears
- Moving the window does not restore the border
2021-06-20 15:39:04 -04:00
Ragnar Groot Koerkamp d5c71231e5 Only call workspace_auto_back_and_forth when needed
Instead of disabling it for some workspace subcommands, this explicitly
calls it only in the 2 places it's actually needed: for switching to a
named or numbered workspace.
2021-06-18 16:15:02 +02:00
Ragnar Groot Koerkamp 3080f1b9ce Move auto_back_and_forth logic out of workspace_switch
This extracts the code to a separate workspace_auto_back_and_forth
function.
It also removes the bool argument by adding an extra if statement at the call
site, and repurposes the no_auto_back_and_forth variable to
auto_back_and_forth for simpler understanding.
2021-06-18 16:15:02 +02:00
Ragnar Groot Koerkamp 771cff23fb Fix #6299 Disable auto_back_and_forth for next_on_output
This forces no_auto_back_and_forth to true for `workspace
next_on_output` and `workspace prev_on_output` to keep parity with i3.
In i3, running next_on_output never changes focus to another output.
In Sway currently, with workspace_auto_back_and_forth set to yet,
running next_on_output on an output with only a single active workspace
will typically end up focussing the other output:
1. next_on_output focusses the current workspace, because it's the only
one
2. auto_back_and_forth focusses the last focussed workspace, because the
current workspace to focus is the current one. This will usually be on
the other monitor if the workspace there was last focussed.
2021-06-18 09:37:28 +02:00
James Edwards-Jones d13090be54 swaynag: adds option to set wayland shell layer
Uses --layer/-y set to overlay|top|bottom|background
2021-06-17 11:47:49 +02:00
Rahiel Kasim 75a4122f7a fix typo in sway-output.5.scd 2021-06-13 17:22:33 +02:00
Daniel Eklöf 3bf99198a6 sway: restore SIGPIPE handler before exec:ing swaybar
Sway ignores SIGPIPE (by installing a SIG_IGN handler), in order to
“prevent IPC from crashing Sway”.

SIG_IGN handlers are the *only* signal handlers inherited in
sub-processes. As such, we should be a good citizen and restore the
SIGPIPE handler to its default handler.

Original bug report:
https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1806907.html
2021-06-05 11:50:11 +02:00
Daniel Eklöf 1dd6df6a5d sway: commands: exec: restore SIGPIPE before exec:ing
Sway ignores SIGPIPE (by installing a SIG_IGN handler), in order to
“prevent IPC from crashing Sway”.

SIG_IGN handlers are the *only* signal handlers inherited in
sub-processes. As such, we should be a good citizen and restore
the SIGPIPE handler to its default handler.

Original bug report:
https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1806907.html
2021-06-05 11:50:11 +02:00
Daniel Otero b997147284 config: Fix swaybar pango_markup inconsistency
Until now, swaybar did not have pango markup enabled by default, even if
the sway config had it on. This patch aims to mimic the i3 behavior, but
maintaining the functionality of the "pango_markup" sway config command.
2021-06-03 14:18:23 +02:00
Bill Doyle cad6e59b93 Only defer seat attachment during initial startup
Deferred commands are only run once, during sway startup. This means
that deferring seat attachment based on whether we are reading the
config prevents devices from being reattached to the correct seat during
a config reload. Instead, only defer if the config is not yet active.

Fixes #6048.
2021-06-03 14:07:18 +02:00
Simon Ser 3162766eef Iterate over subsurfaces below the parent surface
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/2948
2021-06-03 14:06:29 +02:00
Simon Ser 9755684fb0 Implement xdg-activation-v1
See https://github.com/swaywm/wlroots/pull/2718.
2021-06-02 19:39:40 +02:00
sergio 92ba229094 details-gackground typo fix 2021-05-28 17:18:36 +02:00
Simon Ser f443c73a2a readme: switch back to IRC web client 2021-05-26 22:09:05 +02:00
apt-ghetto 1651f21061 Fix IRC links in READMEs and templates
Change the webchat links from freenode.net to point to the new
destination libera.chat.

Co-authored-by: Simon Ser <contact@emersion.fr>
2021-05-26 08:25:13 +02:00
Bart Pelle e318b27685 docs: fix invalid release signing keys 2021-05-25 21:17:54 +02:00
Tobias Langendorf 12e223e797 remove usage of `wlr_texture_get_size`
update for wlroots 6369f7093178f0d66414eb67c312a403bfbb84a4
2021-05-17 10:48:54 +02:00
Ronan Pigott 5a73dc1bc2 view: commit transactions for foreign toplevel requests 2021-05-17 08:57:20 +02:00
Manuel Stoeckl 31b4b96ebf commands/exec: stop truncating >4095-byte commands 2021-05-10 10:57:58 +02:00
Ronan Pigott 137dbf3e6d cmd_fullscreen: ignore fullscreen request on workspaces 2021-05-10 10:30:44 +02:00
Issam E. Maghni d45623c2db cairo: Replace <cairo/cairo.h> by <cairo.h>
For full context, read
https://gitlab.freedesktop.org/cairo/cairo/-/issues/479
TL;DR, cairo’s pc file adds `/cairo` to CFLAGS.
So namespace cairo shouldn’t be used.
2021-05-10 10:28:32 +02:00
Drew DeVault 009c58fc95 config.in: change terminal emulator to foot
This is my preferred terminal emulator now. Seeing as the default config
file is basically "Drew's preferences watered down a bit for a general
audience", I reckon it should be updated accordingly :)
2021-05-06 20:52:51 +02:00
tomKPZ f9a5c18c93 Add tab dragging functionality
Implements functionality described in [1].  Please see the issue for a
video with a demonstration of the new behavior.

An issue is that titlebars cover up a significant portion of the top
edge drop area.  The solution is simply to change the edge drop area
hitbox to start at the contents instead of the container.

[1] https://github.com/swaywm/sway/issues/6218
2021-05-06 00:24:55 -04:00
Erik Reider d65e67face Added scroll_factor input variable to ipc output 2021-05-05 19:50:15 +02:00
Simon Ser d7ec66d563 build: remove sd-bus status item
sd-bus == tray, no need to print the same thing twice.
2021-05-04 21:07:04 +02:00
Elyesa f8d7c170cd
Add Turkish README 2021-05-03 11:58:18 +02:00
Bartłomiej Burdukiewicz 7c74f01f0a main: removed vc4 detection code.
Signed-off-by: Bartłomiej Burdukiewicz <bartlomiej.burdukiewicz@gmail.com>
2021-04-29 18:04:34 +02:00
Rouven Czerwinski 30e400c0a3 view: handle case where map_ws is NULL
When a criteria places the view into the scratchpad, map_ws is NULL and
trying to access map_ws->fullscreen will result in SIGSEGFAULT with:

  #0  0x0000000000455327 in should_focus (view=0x15a6a70) at ../sway/tree/view.c:604
          prev_con = 0x0
          len = <optimized out>
          seat = 0x12233c0
          prev_ws = 0x1264c80
          map_ws = 0x0
          criterias = <optimized out>
          seat = <optimized out>
          prev_con = <optimized out>
          prev_ws = <optimized out>
          map_ws = <optimized out>
          criterias = <optimized out>
          len = <optimized out>
          num_children = <optimized out>
  #1  view_map (view=view@entry=0x15a6a70, wlr_surface=0x15a5cb0, fullscreen=<optimized out>, fullscreen_output=<optimized out>, decoration=<optimized out>) at ../sway/tree/view.c:809
          __PRETTY_FUNCTION__ = "view_map"
          ws = <optimized out>
          seat = <optimized out>
          node = <optimized out>
          target_sibling = <optimized out>
          container = 0x1625400
          set_focus = <optimized out>
          app_id = <optimized out>
          class = <optimized out>
  #2  0x0000000000423a7e in handle_map (listener=0x15a6c78, data=<optimized out>) at ../sway/desktop/xdg_shell.c:454
          xdg_shell_view = 0x15a6a70
          view = 0x15a6a70
          xdg_surface = 0x15a6620
          csd = <optimized out>
  #3  0x00007f508bd3674c in wlr_signal_emit_safe (signal=signal@entry=0x15a6718, data=data@entry=0x15a6620) at ../subprojects/wlroots/util/signal.c:29
          pos = 0x15a6c78
          l = 0x15a6c78
          cursor = {link = {prev = 0x15a6c78, next = 0x7fff53d58190}, notify = 0x7f508bd366c0 <handle_noop>}
          end = {link = {prev = 0x7fff53d58170, next = 0x15a6718}, notify = 0x7f508bd366c0 <handle_noop>}
  #4  0x00007f508bd15b29 in handle_xdg_surface_commit (wlr_surface=<optimized out>) at ../subprojects/wlroots/types/xdg_shell/wlr_xdg_surface.c:384
          surface = 0x15a6620
  #5  0x00007f508bd2e981 in surface_commit_state (surface=surface@entry=0x15a5cb0, next=next@entry=0x15a5e18) at ../subprojects/wlroots/types/wlr_surface.c:455
          __PRETTY_FUNCTION__ = "surface_commit_state"
          invalid_buffer = <optimized out>
          subsurface = 0x15a6038
  #6  0x00007f508bd2f53b in surface_commit_pending (surface=0x15a5cb0) at ../subprojects/wlroots/types/wlr_surface.c:474
          next_seq = 3
          next_seq = <optimized out>
  #7  surface_commit (client=<optimized out>, resource=<optimized out>) at ../subprojects/wlroots/types/wlr_surface.c:542
          surface = 0x15a5cb0
          subsurface = <optimized out>

If map_ws is NULL we assume the view is places into the scratchpad and
return false as well.
2021-04-29 09:06:05 +02:00
Ronan Pigott a6dc829ed0 xdg-shell: ignore unecessary fullscreen request ouput hints 2021-04-26 13:14:24 -07:00
Ronan Pigott c12169953a workspace: reap empty parents when adding tiles 2021-04-26 13:14:24 -07:00
Simon Ser fd36289faa Remove support for arbitrary rotations
There was some unused code-paths for rendering surfaces with an
arbitrary rotation applied. This was imported from rootston.

Since we don't have plans to make use of this, remove it.
2021-04-26 10:36:25 +02:00
Kenny Levinsen 4e6f515253 desktop/render: Pass explicit clip box to render
render_surface_iterator previously deduced the clip box from an optional
container passed with render data. This causes problems when offsets in
view geometry need to be compensated for in the clip dimensions.

Instead, prepare the clip box in render_view_toplevels where the offsets
are being applied, and compensate for them immediately.

A similar compensation is applied to render_saved_view.

Closes: https://github.com/swaywm/sway/issues/6223
2021-04-26 09:24:12 +02:00
Kenny Levinsen 7ec9d07fc5 Remove usage of surface->sx|sy
These coordinates contain the all-time accumulated buffer attach point,
which is a way to perform incremental client-side initiated movement of
windows, intended as a way to maintain logical window positioning while
compensating for layout changes such as folding in a left side panel.

This value is not useful for implementing this feature, and break things
if they ever become non-zero. Their inclusion in calculations also tend
to cause confusion.

Remove usage of these coordinates, removing the ability for clients to
move themselves. This may again be supported if a better API is made
available from wlroots.
2021-04-26 09:24:12 +02:00
Tudor Brindus 80128d23ba tree/view: don't give focus to views mapped under fullscreen views
Fixes #6211.
2021-04-25 11:20:56 +02:00
Dominique Martinet 8529141150 view_destroy: fix use-after-free with subsurface_destroy
remove view from its own unmap event listener so when subsurfaces
link try to remove themselves they won't run into it.

This fixes the following ASAN use-after-free error on a build slightly
modified to instrument wl_list operations:
==71705==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000829a0 at pc 0x000000508eb7 bp 0x7ffec8fd8030 sp 0x7ffec8fd8028
WRITE of size 8 at 0x6160000829a0 thread T0
    #0 0x508eb6 in wl_list_remove ../common/list.c:181
    #1 0x4f4998 in view_child_destroy ../sway/tree/view.c:1131
    #2 0x4f38fa in subsurface_handle_destroy ../sway/tree/view.c:946
    #3 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #4 0x7fda5072f0dd in subsurface_destroy ../types/wlr_surface.c:649
    #5 0x7fda507312c4 in subsurface_handle_surface_destroy ../types/wlr_surface.c:1094
    #6 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #7 0x7fda5072f305 in surface_handle_resource_destroy ../types/wlr_surface.c:677
    #8 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce)
    #9 0x7fda508187f2 in wl_client_destroy (/lib64/libwayland-server.so.0+0xc7f2)
    #10 0x7fda50818e5f in wl_client_connection_data (/lib64/libwayland-server.so.0+0xce5f)
    #11 0x7fda50818219 in wl_event_loop_dispatch (/lib64/libwayland-server.so.0+0xc219)
    #12 0x7fda50818984 in wl_display_run (/lib64/libwayland-server.so.0+0xc984)
    #13 0x43122c in server_run ../sway/server.c:254
    #14 0x42f47c in main ../sway/main.c:433
    #15 0x7fda503cab74 in __libc_start_main (/lib64/libc.so.6+0x27b74)
    #16 0x40f6fd in _start (/opt/wayland/bin/sway+0x40f6fd)

0x6160000829a0 is located 288 bytes inside of 592-byte region [0x616000082880,0x616000082ad0)
freed by thread T0 here:
    #0 0x7fda50f01a27 in free (/lib64/libasan.so.6+0xaea27)
    #1 0x4532d8 in destroy ../sway/desktop/xdg_shell.c:262
    #2 0x4ed17b in view_destroy ../sway/tree/view.c:67
    #3 0x4ed300 in view_begin_destroy ../sway/tree/view.c:83
    #4 0x454a3f in handle_destroy ../sway/desktop/xdg_shell.c:507
    #5 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #6 0x7fda506e2c87 in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:481
    #7 0x7fda506e3018 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:516
    #8 0x7fda506dfbe5 in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #9 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce)

previously allocated by thread T0 here:
    #0 0x7fda50f01ed7 in calloc (/lib64/libasan.so.6+0xaeed7)
    #1 0x454bc8 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:528
    #2 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7fda506e2363 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:378
    #4 0x7fda5072e368 in surface_commit_state ../types/wlr_surface.c:455
    #5 0x7fda5072e51d in surface_commit_pending ../types/wlr_surface.c:474
    #6 0x7fda5072ea58 in surface_commit ../types/wlr_surface.c:542
    #7 0x7fda4fb3ac03 in ffi_call_unix64 (/lib64/libffi.so.6+0x6c03)

Fixes #5168
2021-04-22 23:19:08 +02:00
Simon Ser 31a2252e83 commands/exec_always: log error on execlp failure
And exit(1) instead of indicating success.
2021-04-22 23:12:49 +02:00
Simon Ser 7beeb9e61b Use execlp("sh") instead of execl("/bin/sh")
This stops assuming the POSIX shell command is located in /bin.
2021-04-22 23:12:49 +02:00
Simon Ser e3e99d961d Avoid creating zero-sized textures for marks
Same as 6327f1b361 ("Avoid creating zero-sized textures for titlebars")
but for marks.
2021-04-20 17:29:16 +02:00
Simon Ser 3173a4f353 Use cairo_image_surface_get_stride instead of guessing it 2021-04-20 17:28:30 +02:00
Simon Ser 6327f1b361 Avoid creating zero-sized textures for titlebars
Creating a zero-sized wlr_texture is incorrect.
2021-04-20 17:22:06 +02:00
Michael Weiser 730efbc89c Prevent use-after-free on first bar subcommand error
If any error is encountered during execution of the first subcommand of
a freshly created bar configuration, parsing apparently is to be aborted
and the current bar config is freed. The pointer to that memory is left
dangling though, leading to a use-after-free on successive bar
subcommands. This quite reliably ends in a crash like so:

sway -c reproducer.config
00:00:00.083 [sway/config.c:865] Error on line 2 'foo bar': Unknown/invalid command 'foo' (s)
free(): double free detected in tcache 2
00:00:00.608 [swaynag/swaynag.c:451] failed to register with the wayland display
Aborted (core dumped)

Minimal reproducer config:
bar {
        foo bar
        position top
}

Other messages:
malloc(): unaligned fastbin chunk detected
double free or corruption (fasttop)

The invalid command has to be the first for a newly created bar config.
Removing the command or switching order so it's not the first one masks
the problem.

Prevent this from occuring by resetting the pointer to NULL after
freeing the memory.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2021-04-18 20:53:36 -07:00
Ronan Pigott ecfd687977 cmd_fullscreen: allow fullscreen on fullscreen split containers
Using the fullscreen command on a child of a fullscreen split
container will now fullscreen the child instead of unfullscreening
the parent.
2021-04-16 11:36:14 +02:00
ash lea eb9e77f4ea container: don't set fullscreen on children
the original behavior set fullscreen for all descendents of a container,
which causes issues when firefox is one of those children because it
sends its own set_fullscreen request in response to being fullscreened.
2021-04-15 16:58:27 -07:00
Kenny Levinsen 4e77bc2935 meson: libseat is no longer optional
See: https://github.com/swaywm/wlroots/pull/2839
2021-04-14 23:29:09 +02:00
Kenny Levinsen fcfe52de29 ci: Install libseat 2021-04-14 23:29:09 +02:00
fwsmit 8106f01c17 desktop/layer_shell: fix centering for opposing anchors 2021-04-12 12:13:25 -07:00
Elyes HAOUAS b40c6448e6 desktop/layer_shell.c: Fix misspelled "exclusive"
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-04-12 18:07:18 +02:00
Simon Ser 78fc9d0d2d Log wlroots version on startup
Can be useful to make sure a bugfix is included. In the future maybe
the wlroots version string could include a commit hash when built
from source, too.
2021-04-12 16:18:17 +02:00
Ronan Pigott a558866f42 container: retain focus position on floating enable
When a tiling container is floated, the focus stack needs to be
appropraitely modified to return the container to its original
position in the tree upon floating disable, like i3.
2021-04-11 21:01:33 -04:00
Simon Ser 1a72049c04 Remove WLR_HAS_XDG_FOREIGN checks
References: https://github.com/swaywm/wlroots/pull/2833
2021-04-11 19:14:05 +02:00
Simon Ser 86b08e3257 desktop/render: remove unused wlr_gles2_texture_attribs
We were calling wlr_gles2_texture_get_attribs, but we were never
using the result.
2021-04-11 12:15:51 +02:00
Simon Ser e49a98fcb3 build: stop checking for logind
wlroots has removed its logind session backend [1]. It now relies
on libseat only.

[1]: https://github.com/swaywm/wlroots/pull/2786
2021-04-11 12:14:40 +02:00
Aljaz Gantar 1a0f86be4e refactor icon_for_window function 2021-04-09 22:08:53 +02:00
Aljaz Gantar 61df9eb62a fix type error when class_name none 2021-04-09 22:08:53 +02:00
Simon Ser 7a68a28475 build: update wlroots dependency version to 0.14.x
The latest commit of Sway always requires the latest commit of
wlroots.
2021-04-08 08:55:20 +02:00
Simon Ser 8cd014cab7 build: bump version to 1.6 2021-04-07 22:02:55 +02:00
István Donkó 6e34aac2f1
Add Hungarian translation for the README
Co-authored-by: Tamás Táncos <tamas.tancos@emarsys.com>
2021-04-03 14:26:53 +02:00
Simon Ser 4402507b7b readme: make it clearer that meson takes a dir as argument
"build" can easily be misinterpreted as a Meson subcommand.
2021-04-03 14:24:53 +02:00
Ronan Pigott 62fbf33ce2 output: damage whole output when exiting scanout 2021-04-01 12:24:33 +02:00
Simon Ser db0d63313d Remove advice about Firefox from issue template
Firefox got a lot better. I think now would be a good time to remove
the advice from the issue template. We can always add it back if we
start getting invalid bug reports again.
2021-03-30 18:32:55 +02:00
Simon Ser 276a37a605 ci: add xcb-util-wm dependency for wlroots
This is now a mandatory dependency for wlroots.
2021-03-30 18:22:01 +02:00
columbarius 1d62d6bfa0
config: allow whitespaces in config path 2021-03-25 17:22:26 +01:00
Ivan Fedotov 346f5a9d14 Add toggle logic inside DPMS handler
Logic that obtains current DPMS state is put inside the handler.

sway_output from which the current DPMS state will be obtained is selected by the following logic:
* For '-' and '--' the focused output is used;
* For '*' error "Cannot apply toggle to all outputs" is reported;
* For everything else all_output_by_name_or_id() is used.

Fixes #5929.
2021-03-25 11:01:04 +01:00
Simon Ser a9563a3710 build: update version to v1.6-rc2 2021-03-24 09:47:39 +01:00
Kenny Levinsen d79ea9a0db view: subsurface NULL check in view_from_wlr_surface
Necessary NULL checks had been added to xdg_shell and xwayland surfaces,
but subsurfaces had been missed.
2021-03-24 00:55:15 +01:00
Tudor Brindus 03daa53a0e swaybar: fail gracefully on tokener creation fail
This commit adds missing error-handling to the creation of the tokener
instance. The stack depth parameter is used to initialize an array that
json-c prefaults ahead of time, causing INT_MAX to result in out of
memory errors.

Also drop the depth to 256 to prevent this OOM.

Though this fix is not very satisfactory -- json-c could be made to
not prefault -- it should do for now. At the very least, swaybar will
not crash.

Fixes #6126.
2021-03-22 14:10:53 +01:00
Tudor Brindus 47f1f9b63e swaybar: use INT_MAX max JSON depth when parsing IPC response
There's no inherent limit on the nesting Sway can generate, and the
default used by `json_tokener_new`, 32, can plausibly be hit during
regular usage.

Fixes #6115.
2021-03-21 23:34:07 +01:00
Kenny Levinsen 152a559e30 idle_inhibit: Store wlr inhibitor instead of view
When an application inhibited idle, a view pointer was stored and a
destroy listener was registered to the wlr inhibitor. As the wlr
inhibitor lives longer than the view, this lead to a dangling view
pointer between view unmap and inhibitor destroy.

Store a pointer to the wlr inhibitor instead of to the view, and look up
the view when needed, which may at any point be NULL. This also allows
for an inhibitor to remain functional if a surface is re-mapped.
2021-03-21 12:27:29 +01:00
Kenny Levinsen 70842f4e14 view: Handle NULL role object when role is set
wlr_(xdg|xwayland)_surface_from_wlr_surface can return NULL even though
wlr_surface_is_(xdg|xwayland)_surface returned true.
2021-03-21 12:27:29 +01:00
Kenny Levinsen 3287b12fff ci: Update alpine xwayland package name 2021-03-20 13:25:14 +01:00
Kenny Levinsen 6271bd06e9 swaybar: Use position from wl_pointer.enter
Only wl_pointer.motion was used to update pointer position, which would
cause issues if the pointer was not moved prior to wl_pointer.button.

This also fixes touch input through wl_pointer emulation, which fires
wl_pointer.button immediately after wl_pointer.enter.

Copied from a similar fix made to swaynag.

Closes: https://github.com/swaywm/sway/issues/6109
2021-03-20 11:56:13 +01:00
Pi-Yueh Chuang 6059c744f8
swaybar: silence missing IconThemePath message
IconThemePath is not a standard property in XDG's StatusNotifierItem
specification, so missing this property should not be logged as an error.

This patch changes the log level to SWAY_DEBUG when swaybar queries the
value of IconThemePath so that swaybar won't log the returned message as
an error if IconThemePath does not exist.

Closes: https://github.com/swaywm/sway/issues/6092
2021-03-17 09:49:04 +01:00
Simon Ser adf7a6f892 build: update version to v1.6-rc1 2021-03-16 18:04:39 +01:00
xdavidwu e5913f8106
Implement input method keyboard grab 2021-03-12 12:18:08 +01:00
Simon Ser 585abdb357 xwayland: simplify override-redirect focus restoration
No need to grab the xwayland surface from the wlr_surface, the
parent is already an xwayland surface.
2021-03-12 10:52:12 +01:00
Vyivel ba6c0eb18b output: simplify layer surface iteration 2021-03-11 10:55:25 +01:00
Kenny Levinsen 2e06403548 container: Add view_container_content_at
container_at checks if the position provided matches the currently
focused container with view_container_at as a fast path.

view_container_at checks using the main container geometry, which
includes the titlebar and border area. If a tabbed container is focused,
then positions over unfocused tabs are incorrectly reported as belonging
to the focused container, breaking focus on click.

Add view_container_content_at for use in the focused container fast path
which only tests container content area, and fall back to full workspace
scans for border and titlebar areas.

Closes: https://github.com/swaywm/sway/issues/6074
2021-03-10 17:50:57 +01:00
Fenveireth 837605d68d swaybar: use text subpixel antialias only where it would look good
Closes #5605

Text Subpixel antialiasing is :

- FreeType makes glyph bitmaps containing coverage percentage for each
  subpixel, instead of pixel
- Then draw by performing the blend for each subpixel, instead of pixel (e.g.
  dual-source blending in opengl)

And there's only one Alpha channel, so this extra coverage data can't
leave Cairo to reach the compositor through there.
Therefore, it can't work as intended if output text alpha != bar background
alpha. Disable it for those cases, enable it elsewhere

As for color emojis, they are RGBA bitmaps. If drawn with text alpha=1.0
and background alpha=1.0 (should be completely opaque bar), then with
'CAIRO_OPERATOR_SOURCE' then texels with alpha < 1.0 result in a blend with
whatever's behind the bar, instead of the bar background
2021-03-07 19:18:53 -05:00
Kenny Levinsen d358aab8d9 container: Limit tiled focus to container geometry
container_at would maintain the current focus as long as a position was
over one of the container view's surfaces. If an oversized surface was
being clipped, this lead to weird focus behavior.

Instead, use view_container_at for this test, which intersects the
container box before looking at surfaces.
2021-03-01 16:14:10 +01:00
Kenny Levinsen a6544f5a64 render: Clip surfaces to container bounds
If a surface is associated with a sway container, we limit the
destination box to the container dimensions.

Floating views and popups are exempt from this clipping.
2021-03-01 16:14:10 +01:00
ftilde 1afedcb94c Fix for_window criteria and mouse button bindings
Previously, the special case handling of scratchpad and unmark commands
was (probably accidentally) limited to criteria directly handled in the
execute_command function. This would exclude: 1. for_window criteria, as
these are handled externally for views and 2. and mouse bindings which
select target the node currently under the mouse cursor.

As a concrete example `for_window [app_id="foobar"] move scratchpad,
scratchpad show` would show (or hide due to the toggling functionality)
another window from the scratchpad, instead of showing the window with
app_id "foobar".

This commit replaces the "using_criteria" flag with "node_overridden"
with the more general notion of signifying that the node (and
container/workspace) in the current command handler context of the sway
config is not defined by the currently focused node, but instead
overridden by other means, i.e., criteria or mouse position.
2021-02-25 09:48:39 -05:00
lbonn c6e7cf1ae5 focus: beyond fullscreen when focused explicitly
When issuing a focus command on a specific container, users expect to
proceed it even if is hidden by a fullscreen window.

This matches the behavior of i3.
2021-02-25 09:40:20 -05:00
Simon Ser eea9c6331f Automatically map built-in touchscreens/tablets to built-in panels
Detect whether an output is built-in via its type. Detect whether
a touchscreen or tablet tool is built-in via its ID_PATH property.
2021-02-25 09:38:00 -05:00
Simon Ser 641b8719ad man: document `input XXX map_to_output *`
This is useful to reset the output mapping.
2021-02-25 09:38:00 -05:00
Quantum e01a3c85f6 render: handle containers without output when rendering titles
In e0a94bee8d, it was believed that if the
container is being rendered, it must have an output.

This turned out not to be the case. When rendering a container, all its
children are rendered, even if the children is positioned off screen and
thus not having any output. This is the cause of the crash in #6061.

This commit introduces a null-check, which fixes #6061.
2021-02-25 00:43:02 -05:00
Tadeo Kondrak bb41b7b814 output: Reconfigure xcursor when applying output config
Before this commit, when an output had its scale dynamically changed,
Sway would not load a cursor theme with the new scale. This results
in stale cursor images when moving the cursor into an area controlled
by the compositor, like the background or resize areas.

To reproduce:
- Using IPC, set an output scale to a value that isn't currently used
- Move the cursor into a compositor-controlled area
- The cursor will not change
2021-02-24 20:54:48 +01:00
Simon Ser 307b26a149 build: stop cargo-culting assignment alignment
The Sway style guide says we shouldn't align assignments.
2021-02-23 20:32:11 +01:00
Tadeo Kondrak de471e67d3 build: Add dependency on libdrm
As of 66343839b1, sway now uses a
libdrm header. Add this dependency to the build system so headers from
it can be used on systems where pkg-config is required to find them.
2021-02-23 20:27:38 +01:00
Kenny Levinsen 95901d906a shells: Update comment about size change on commit 2021-02-23 19:38:05 +01:00
Kenny Levinsen 1989b18ff2 transaction: Remove unused ready_immediately 2021-02-23 19:38:05 +01:00
Kenny Levinsen 35b9a41720 transaction: Note if instructions are server requests
On server request, we need to send configure events to inform the client
of the new intended size. If the client changes size itself, sending a
configure event will only cause problems.

Use transaction_commit_dirty_client to distinguish between the two
transaction causes.
2021-02-23 19:38:05 +01:00
Simon Ser 66343839b1 Fix wl_shm_format passed to wlr_texture_from_pixels
See https://github.com/swaywm/wlroots/pull/2744
2021-02-23 17:42:04 +01:00
Mark Stosberg 8f2eeae285 grimshot: document support for piping to STDOUT. 2021-02-23 17:07:53 +01:00
Dimitris Triantafyllidis aac1582ea9 Fix #5643, #5064: rounding issues in floating-point -> integer conversions
Currently, various floating-point expressions involving
the coordinates of borders, titlebars and content surfaces
are directly assigned to integers, and so they are rounded
towards zero.

This results in off-by-one distances between these elements
when the signs of their coordinates differ.

Fixed by wrapping these expressions with a call to
floor before the assignment.
2021-02-22 21:23:35 -05:00
Kenny Levinsen 1a6471be17 view: Set parent for view_child subsurfaces on init
view_child_init was calling view_init_subsurfaces, which did not set the
parent attribute for the subchildren. This lead to the subchildren
acting as standalone children. If the parent was an xdg_popup, this
would make the subchild unaware of the popup position.

Introduce view_child_init_subsurfaces for view_child_init to use
instead.

Closes: https://github.com/swaywm/sway/issues/6038
2021-02-23 00:17:32 +01:00
Kenny Levinsen 79e43b19d7 view: Mark subchildren as unmapped in view_child_destroy
The subchildren lose their parent association at this point, so they
will not be able to see that the parent is unmapped.

Instead, just set the subchildren to be unmapped directly.
2021-02-23 00:17:32 +01:00
Kenny Levinsen e7af5b6309 view: Recursively check mapped of view_child tree
A subsurface may be set to mapped without its parent.
2021-02-23 00:17:32 +01:00
Kenny Levinsen 2c917a8c34 container: Add container_is_current_floating
Needed to check if containers are currently floating from render code,
as container_is_floating checks pending state.
2021-02-22 23:55:22 +01:00
Quantum e0a94bee8d render: scale titlebars correctly when straddling outputs
When a container straddles multiple outputs, the title bar is only rendered
at the scale of the "effective" output. If the title bar straddles onto
another output with a different scale factor, it was drawn at the wrong size.

In this commit, we take into consideration the scale the title was rendered
at and scale it accordingly so that it appears at the right size on the other
outputs.

This fixes #6054.
2021-02-22 02:08:37 -05:00
Tadeo Kondrak f58f054c87 Fix incorrect damage being applied on popups
To reproduce:

- Open a floating window and a popup that hangs over the bottom or right
- Move the window in the direction of the popup overhang
- The previous position of the popup is damaged, not the new one
2021-02-21 17:30:49 -05:00
Simon Ser b4950e2a6d build: use wlroots dependency variables
Instead of manually parsing header files and having two different
code-paths depending on whether a subproject is used, use
dependency variables which can come from either the subproject or
pkg-config.

References: https://github.com/swaywm/wlroots/pull/2734
2021-02-21 17:16:14 -05:00
Falke Carlsen 4e02a598a3 Fix typo in README.dk.md 2021-02-18 12:47:14 +01:00
Daniil 2ad14b372e
Update Russian translation 2021-02-17 09:21:08 +01:00
Kenny Levinsen 35342d89a9 render: Use current instead of pending fullscreen 2021-02-16 22:05:00 -05:00
Kenny Levinsen a047b5ee4a container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.

Instead, use the state struct for both current and pending.
2021-02-16 22:05:00 -05:00
David96 28cadf5580 Add missing transaction commits to seatop_default
Every seat_set_focus* should be followed by a transaction_commit_dirty.
In cases where the focus change is followed by a seatop_begin* this is
not needed, as transaction_commit_dirty is then called by the
seatop_begin* function.

Fixes #6034
2021-02-16 09:35:48 -05:00
Pierre-Albéric TROUPLIN a3d45c3280 Prevent inactive-windows-transparency.py to crash on lockscreen 2021-02-16 11:45:10 +01:00
Tadeo Kondrak 42cbaf278c text_input: Add support for focusing layer-shell surfaces 2021-02-15 18:24:47 -05:00
Kenny Levinsen c8bf84c82d transactions: Amend pending transactions
The transaction system contains a necessary optimization where a popped
transaction is combined with later, similar transactions. This breaks
the chronological order of states, and can lead to desynchronized
geometries.

To fix this, we replace the queue with only 2 transactions: current and
pending. If a pending transaction exists, it is updated with new state
instead of creating additional transactions.

As we never have more than a single waiting transaction, we no longer
need the queue optimization that is causing problems.

Closes: https://github.com/swaywm/sway/issues/6012
2021-02-16 00:18:26 +01:00
Jan Palus b944735b47 Align ordering of core node properties with i3
Try to better mimic JSON node structure produced by i3 which might be
relied on by already existing tools. In particular having "type" right
after "id" is quite handy for streaming high-performance JSON parsers
such as simdjson (which are handy for maintaining responsiveness on
resource constrained systems).

refer ab2a22a78b/src/ipc.c (L338)
2021-02-15 18:14:27 -05:00
Kenny Levinsen 37d7bc6998 transaction: Only wait for ack from visible views
Transactions currently wait for all configures to be acked, regardless
fo what they were sent to. This includes views that are hidden in tabbed
or stacked containers. If these views do not ack the configure in
response to a single frame callback, they can cause transaction
timeouts.

Check if a container is hidden before registering the configure serial
and saving any view buffers.

Closes: https://github.com/swaywm/sway/issues/6023
2021-02-15 16:58:19 -05:00
Tadeo Kondrak c88f7ad1d0 text_input: Only send surrounding_text and content_type if supported 2021-02-15 16:45:35 -05:00
Tadeo Kondrak b0e8f4ade2 text_input: Ignore text_input disable from unfocused windows
Before this commit, there would be cases where focus changes from one
window to another, the new window activates text_input, then the old
window sends a deactivate request, making text_input unfocused
completely.
2021-02-15 16:44:15 -05:00
Kenny Levinsen 31a01bb80d input: Commit transactions in seatop_default
This is needed for focus_follows_mouse, and was accidentally omitted in
the previous transaction commit shuffle.
2021-02-15 13:49:47 -05:00
Kenny Levinsen b5b628cb41 input: Only commit transactions when necessary
There is no need to check for transactions at the end of every user
input, as the vast majority of input will not issue transactions. This
implementation can also hide where changes are made without an
appropriate transaction commit, as a future unrelated input would issue
the commit instead.

Instead, commit transactions in places where changes are made or are
likely to be made.
2021-02-14 13:19:08 -05:00
Simon Ser b1b104152e readme: update French translation
Update to latest English README and improve wording.
2021-02-10 09:44:38 +01:00
Kenny Levinsen 63a6635163 view: Read geometry directly in view_update_size 2021-02-09 09:37:10 +01:00
Kenny Levinsen 82b1019658 shells: Align geometry change commit handling
xdg_shell and xwayland handled geometry changes differently despite
needing mostly identical behavior. The xwayland implementation has been
changed to match that of xdg_shell.
2021-02-09 09:37:10 +01:00
Kenny Levinsen 90fa6953ea shells: Only center tiled views on size change
The size of a tiled container cannot change in response to new buffer
sizes, so there is no need to commit a new transaction. Instead, simply
recenter the view with the new geometry, leaving the full transaction
flow for floating containers.
2021-02-09 09:37:10 +01:00
Kenny Levinsen 50205ade9d transaction: Move centering to view_center_surface
This will allow us to reuse it for centering elsewhere.
2021-02-09 09:37:10 +01:00
Kenny Levinsen cf1e3be228 view: Save surface x and y on saved buffers
We need to use surface_x and surface_y when rendering and damaging saved
buffers as these compensate for views that have been centered due to
being smaller than their container.

Add them to the surface positions on the saved buffer so we have the
values from the time the buffer was saved.
2021-02-09 09:37:10 +01:00
Kenny Levinsen 63420a2caa swaynag: Use position from wl_pointer.enter
Only wl_pointer.motion was used to update pointer position, which would
cause issues if the pointer was not moved prior to wl_pointer.button.

This also fixes touch input through wl_pointer emulation, which fires
wl_pointer.button immediately after wl_pointer.enter.

Closes: https://github.com/swaywm/sway/issues/5991
2021-02-07 20:18:53 -05:00
Manuel Stoeckl 169b90f90b Make command line option lists const 2021-02-04 09:49:06 +01:00
Manuel Stoeckl 8f2cd3236f Make Wayland request listeners static const when possible 2021-02-04 09:49:06 +01:00
Manuel Stoeckl cb3c727632 Declare all struct cmd_handler arrays const
And make the functions handling these arrays use const types.
2021-02-04 09:49:06 +01:00
Aleksei Bavshin 89b4bc4bc7 xdg-foreign: add v1 and v2 implementations
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-02-02 09:32:49 +01:00
Konstantin Pospelov 8b7008a296 Check the output state for recorded workspaces
Sway records pid, workspace, and output for every new process. However, if the
output gets disabled and the workspace disappears, the workspace is still
re-created on the disabled output. This commit adds a check for the enabled
flag, so that NULL will be passed to workspace_create() in this case.
2021-01-30 11:24:43 +01:00
Manuel Stoeckl f8c6fc1944 desktop/layer_shell: Fix allocation type mismatch 2021-01-30 02:28:39 -05:00
Kenny Levinsen 4d43f1dd99 desktop/output: Disable head if mode is NULL
wlr_output_configuration_head_v1_create normally fills out the head
"enabled" field to match the wlr_output state. We overwrite this to also
set the head as enabled if it is only turned off with DPMS.

However, in some cases we may not have a mode for this display, in which
case setting it as enabled will lead to a segfault later on. Therefore,
enabled conditional on the presence of a mode.
2021-01-26 10:26:37 +01:00
Martin Michlmayr ac7c81e3b9 Fix typo in bug reporting template 2021-01-26 09:08:00 +01:00
fwsmit 241ce2af83 Implement foreign toplevel fullscreen output hints 2021-01-25 11:54:44 -07:00
BrassyPanache 62ec528c8c Adhere to ICCCM focus specification
For certain applications (e.g. JetBrains) the parent window controls
input. We need to adhere to the ICCCM input focus specification to
properly handle these cases.

Relates to swaywm/wlroots#2604
2021-01-20 10:50:04 +01:00
Simon Ser 38571e6a0c Log when config file is not found
This happens when Sway is not installed on the system, so there's no
default config in /etc.
2021-01-17 18:07:13 +01:00
Simon Ser 43f82078cf Raise verbosity of error message in load_main_config 2021-01-17 18:07:13 +01:00
SpizzyCoder 7cf25d3b98 Changed fprintf(stdout,...) to printf(...) for more readable code 2021-01-16 20:24:41 +01:00
Ronan Pigott 915ba01ff1 config/output: correct refresh rate rounding error 2021-01-15 22:53:19 +01:00
Ronan Pigott 0d04864fd1 swaymsg: use 3 digits for fractional part of the refresh rate
The fractional part of the real number we want to represent never has
more than 3 decimal digits, so use 3 decimal digits of precision.

e.g. 'swaymsg -t get_outputs' would show a refresh rate of 59934 mHz
as 59.933998 Hz, now correctly as 59.934 Hz.
2021-01-15 21:32:42 +01:00
Simon Ser 97adba0516
protocols: update layer-shell-unstable-v1 to v4
This is taken from wlr-protocols commit d1598e82240d ("layer-shell: add
keyboard_interactivity.on_demand").
2021-01-12 22:38:45 +01:00
Simon Ser 1c3cfd3bac Rename output_layer_for_each_surface_{toplevel,popup}
Swap the "surface" part for consistency with wlroots' naming.
2021-01-12 11:25:34 +01:00
Simon Ser 5438cc158a Switch to wlr_xdg_surface_for_each_popup_surface
Instead of calling wlr_xdg_surface_for_each_popup and then
wlr_surface_for_each_surface, use the new for_each_popup_surface helper
introduced in [1] that does it in one go.

[1]: https://github.com/swaywm/wlroots/pull/2609
2021-01-12 11:25:34 +01:00
Mukundan314 a7414885d2 Fix #5940
Fallback to focused_statusline instead of statusline on focused output
2021-01-11 10:51:21 +01:00
Simon Ser 661cdac2d6
desktop/xwayland: use index constants for atom array
This ensures we don't swap two atoms by mistake.
2021-01-08 14:58:58 +01:00
Simon Ser cbd82b4117
man: update maintainer
Also remove the AUTHORS section from swaybar-protocol(7), for
consistency with the rest of the man pages.
2021-01-08 09:33:51 +01:00
Simon Ser af6ee89e42
readme: remove unused ref 2021-01-08 09:32:28 +01:00
Simon Ser 40bdd0eecf
Remove call for action from WM enhancement issue template
i3 feature set is mostly frozen as well, so we shouldn't advise people
to open feature requests there. Moreover, i3 will disregard feature
requests from sway users (because it doesn't benefit the i3 project
itself).

There is now no good way to request new WM features, and this is by
design. This aligns with [1].

[1]: fc1148da7f
2021-01-04 15:21:28 +01:00
Drew DeVault fc1148da7f CONTRIBUTING.md: Add note on sway's scope 2021-01-04 09:18:13 -05:00
Ronan Pigott d1bf3b8a86 cmd_move: update container representation in sibling swaps 2021-01-04 00:31:25 -05:00
Andri Yngvason 9ef5cc03f1 input/seat: Reset command handler context in seat_destroy()
This fixes a dangling reference which causes a use-after-free.
2021-01-01 19:02:56 +01:00
Andri Yngvason e11bc058ac input/seat: Clean up focus_stack in seat_destroy()
This fixes use-after-free when seat_destroy() has been called.
2021-01-01 19:02:56 +01:00
Andri Yngvason 98eece53ad input: Clean up input_method_relay in seat_destoy()
This fixes a crash that happens when input_method_new or text_method_new
events are emitted after the seat has been freed.
2021-01-01 19:02:56 +01:00
Simon Ser 53f5197c26 Remove create_renderer_func argument
It's removed upstream [1].

[1]: https://github.com/swaywm/wlroots/pull/2561
2020-12-30 19:36:55 +01:00
Jan Beich 92dc53b4f3 ci: enable basu on freebsd 2020-12-29 12:08:43 +01:00
Drew DeVault e8e7bbc85f Remove Patreon links from README.*.md 2020-12-26 20:14:24 -05:00
Drew DeVault 261865c4d1 Remove .github/FUNDING.yml
Since I'm no longer a maintainer of, or regular contributor to, this
project, it doesn't make sense to solicit donations.
2020-12-26 20:12:08 -05:00
William Culhane 7c9706de71 grimshot: Fix man page issues
This fixes a few formatting errors in SYNOPSIS, moves the command
options out of SYNOPSIS, swaps the labels on the SYNOPSIS and
DESCRIPTION sections, creates an EXAMPLES section and slightly rewords
parts of the OPTIONS, DESCRIPTION, EXAMPLES, and OUTPUT sections.
2020-12-26 17:37:41 +01:00
Ronan Pigott d1c4ed1867 container: set fullscreen mode before attempting focus 2020-12-24 23:34:55 +01:00
Ronan Pigott 5f1fe33d36 workspace: rework workspace prev|next like i3
Changes workspace prev|next commands to visit each numbered or named
workspace first before considering workspace from the other category
2020-12-20 00:58:42 -05:00
Ronan Pigott 89ffeaae49 commands/move: reset geometry of promoted containers 2020-12-20 00:58:42 -05:00
Ronan Pigott 432c4df6e7 commands/move: squash workspace after directional con move 2020-12-20 00:58:42 -05:00
Ronan Pigott 8eb0c54693 introduce workspace_squash
workspace_squash is container_flatten in the reverse
direction. Instead of eliminating redundant splits that are
parents of the target container, it eliminates pairs of
redundant H/V splits that are children of the workspace.

Splits are redundant if a con and its grandchild have the
same layout, and the immediate child has the opposite split.

For example, layouts are transformed like:

    H[V[H[app1 app2]] app3] -> H[app1 app2 app3]

i3 uses this operation to simplify the tree after moving
heavily nested containers to a higher level in the tree via
an orthogonal move.
2020-12-20 00:58:42 -05:00
Ronan Pigott e95c299f0a commands/move: rework container_move_in_direction
This changes the move command to better match i3
behavior after the layout changes.

workspace_rejigger handled the case where containers would
escape their workspace in an orthogonal move by changing
the layout to accomodate them, but this case is now handled
within the loop.
2020-12-20 00:58:42 -05:00
Ronan Pigott ece6a1d408 Change workspace_layout to match i3 behavior
In i3, the workspace_layout command does not affect the
workspace layout. Instead, new workspace level containers
are wrapped in the desired layout and the workspace layout
always defaults to the output orientation.
2020-12-20 00:58:42 -05:00
Ronan Pigott b4850876dc Revert "commands/move: maintain workspace_layout when moving"
This is in preparation for changing the workspace_layout
command to work like it does in i3.

This reverts commit b4a75a1ab2.
2020-12-20 00:58:42 -05:00
Tudor Brindus 971aa90ccc commands/move: don't flatten on move; reap empty former parent instead
Some comparisons of current Sway versus i3 behavior:

1) T[T[T[app]]] + move left
* Sway: T[app]
* i3:   T[T[app]]

2) H[V[H[V[app]]]] + move left
* Sway: H[app]
* i3:   H[V[app]]

After this commit, Sway behavior matches i3. The intermediate states
are now:

    T[T[T[app]]] -> T[T[app T[]]] -> T[T[app]]
    H[V[H[V[app]]]] -> H[V[app H[V[]]]] -> H[V[app]]
2020-12-20 00:58:42 -05:00
Ronan Pigott d54c8e885b commands/layout: don't change the layout of workspaces with children
In i3 the layout command on a workspace affects the workspace layout
only on empty workspaces. Otherwise children are placed in a new
container with the desired layout to preserve the workspace layout.
2020-12-20 00:58:42 -05:00
Ronan Pigott 2478f2f010 container: don't split single children
In i3 splits are ineffective on singleton H/V containers,
and the command is interpreted to affect the parent layout
instead.
2020-12-20 00:58:42 -05:00
Simon Ser 33b64667ae Test output before direct scan-out
This avoids some log spam.

Eventually when we wire up the atomic test commit this will take care of
the other log spam referenced below.

References: https://github.com/swaywm/sway/pull/5010
References: https://github.com/swaywm/wlroots/issues/2181
Closes: https://github.com/swaywm/wlroots/issues/2532
2020-12-20 00:51:46 -05:00
Simon Ser fce8287a06 readme: use references for links
This avoids cluttering the README text with URLs.
2020-12-18 18:33:04 -05:00
Rouven Czerwinski 30afb6c14a ISSUE_TEMPLATE: the wiki is community maintained
Mention that the github wiki may contain outdated information scripts
and old workarounds and that sway the sway project does not provide
support for it.
2020-12-18 11:21:35 +01:00
Simon Ser e835d3563b
readme: remove link to non-existing wiki page 2020-12-18 11:12:14 +01:00
Simon Ser 50347787ac
readme: releases are signed with E88F5E48
See https://github.com/swaywm/wlroots/issues/2462#issuecomment-723578521
2020-12-18 11:11:30 +01:00
Arav K c9fe0626ca Fix swaybar tray for non-systemd
Meson's generated config.h header defines false macros as 0, not
undefined.  This means that the header line, which was checking for the
definition existing, not a non-zero value, was incorrect.  Now the
swaybar tray can be used with systemd, elogind, or basu.
2020-12-16 21:19:20 +01:00
Ronan Pigott ba943c694c ci: fix archlinux builds
The "xorg-server-xwayland" package has become "xorg-xwayland" in Arch.
Our egl requirement was previously satisfied by xorg-server-xwayland's
dependency on libgl, which "xorg-xwayland" does not have. So add the
libegl dependency as well.
2020-12-14 10:15:55 +01:00
Simon Ser 1dbb699036
common/log: write log importance
When colors aren't used, write the log importance to stderr. This makes
it easier to grep for errors and avoids mistaking error messages for
debug messages.

This is [1] ported to Sway.

[1]: https://github.com/swaywm/wlroots/pull/2149
2020-12-10 09:26:02 +01:00
Simon Ser a68c6a00ca Route wlroots logs into Sway logging infrastructure
Instead of letting wlroots print messages to stdout, route debugging
messages into Sway's logging functions. This allows a more consistent
output (e.g. if Sway or wlroots changes its output style, they don't get
out-of-sync).

I also added a [wlr] prefix to wlroots messages, not yet sure it's a
good thing.
2020-12-09 23:57:12 -05:00
Simon Ser a52176f830 build: add basu as sd-bus provider 2020-12-09 17:39:20 -05:00
Simon Ser fdbe98512a build: introduce sd-bus-provider option
This allows to select a specific provider for the sd-bus library.
2020-12-09 17:39:20 -05:00
Simon Ser 968c005760 build: use WLR_HAS_* to decide whether suid is required
Maybe systemd/elogind is found but wlroots was built without them. Print
the warning message depending on the WLR_HAS_* defines instead.

While at it, don't print the message if wlroots has been build with
libseat.
2020-12-09 17:39:20 -05:00
Simon Ser a1591c23d2
Handle secondary headless backend failures 2020-12-08 16:15:48 +01:00
Isaac Freund 5ad3990a6c Drop gtk-primary-selection support 2020-12-08 11:15:03 +01:00
Vlad Pănăzan 71725a8eae Add layer shell subsurfaces
Damage subsurfaces created by layer surfaces on map, unmap and
commit. This fixes the flicker of Gtk Popovers.

Fixes #5617
2020-12-07 12:30:13 +01:00
Tudor Brindus cc2c0d5966 input/cursor: unhide cursor on synthetic input
Fixes #5847.
2020-12-06 09:38:49 +01:00
Paul Riou b5cc11b226 criteria: fix crash when comparing NULL properties
For each following combinations of criteria & command below, the command would
crash sway without the fix.
It's particular about the __focused__ criteria, where the view matches part of
the criteria but not the focused app, leading to a failure when calling
`strcmp` with NULL.

"xterm" is a non-wayland app (X11) and "kitty" is. Both are terminals.

    # "class" is specific to X11
    # The view is X11 (xterm) leading to the criteria checking for the
    # focused app's class, leading to a crash
    for_window [class="__focused__"] floating enable
    exec kitty -e xterm

    # Similarly, crash as the focused app (xterm) has no app_id when the view has one
    for_window [app_id="__focused__"] floating enable
    exec xterm -e kitty

    # If the view has a title but not the focused app: NULL title will crash criteria checking
    for_window [title="__focused__"] floating enable
    exec xterm -title "" -e xterm
2020-12-04 10:49:49 +01:00
Paul Riou 4583feee59 common: make 'lenient_strcmp' arguments const
Prevents build failures when calling the function with 'const char *'
arguments.
This is also more accurate since the function is not expected to modify
the args.
2020-12-04 10:49:49 +01:00
Ronan Pigott 32b93ef6ea xdg_shell: allow views to change geometry anytime
Currently, when sway sends a configure with some geometry and the
client responds with a different geometry in a commit that acks that
configure, sway ignores the new size. Sway applies the surface
geometry it had requested to the container, not what was actually
committed, in the following transaction.

This change allows any client commit to change its surface geometry,
even if it is a response to a configure event.
2020-11-24 09:47:23 +01:00
Rex Hackbro f1afef5533 document parse_error 2020-11-21 11:42:29 +01:00
Tudor Brindus f5ca4c26ac Small wording change to README.ja.md
見落とされていた英語の単語を置き換える。
2020-11-16 14:08:59 -05:00
Simon Ser 83389da583
Log which output is using direct scan-out 2020-11-16 13:53:49 +01:00
Brian Ashworth 9d6787d10d input/keyboard: fix Group# bindings for keyboard groups
The keyboard group's effective keyboard layout was never being changed
due to a condition that incorrectly preventing it from being performed.
The IPC event that follows the change was correctly being prevented.
2020-11-12 10:52:45 +01:00
Tudor Brindus 07042486c3 tree/container: introduce `container_is_sticky[_or_child]` functions
To query whether a container is sticky, checking `con->is_sticky` is
insufficient. `container_is_floating_or_child` must also return true;
this led to a lot of repetition.

This commit introduces `container_is_sticky[_or_child]` functions, and
switches all stickiness checks to use them. (Including ones where the
container is already known to be floating, for consistency.)
2020-11-11 20:43:58 -05:00
Simon Ser a56098a24e
Add missing includes for wlr_input_device.h
References: https://github.com/swaywm/wlroots/pull/2470
2020-11-11 15:40:50 +01:00
Simon Ser bb342ac5e6
Replace wlr_key_state with wl_keyboard_key_state
References: https://github.com/swaywm/wlroots/pull/2446
2020-11-11 11:00:55 +01:00
Simon Ser 5ae4f65045
build: bump wlroots dependency to 0.12.0 2020-11-08 15:15:34 +01:00
Tudor Brindus 0df5753aed input/seatop_default: consider fullscreen views to have no edges
Previously, `find_edge` on a single fullscreen view would occasionally
return an edge rather than `WLR_EDGE_NONE`. This would trigger entry
into `seatop_resize_tiling`, which doesn't have meaning for a fullscreen
view.

The result was that the fullscreen container hitbox was considered to be
that of where it'd be if it were tiling, so most clicks would not go
through.

Fixes #5792.
2020-11-05 12:25:15 +01:00
heitor b42ed32041 fix typo 2020-11-05 08:36:59 +01:00
heitor 3a78edd93a update portuguese README (fix typos, update informations...) 2020-11-05 08:36:59 +01:00
Tudor Brindus c523aa623b input: fully change focus when scrolling tabs/stacks
When scrolling on a tabbed/stacked container, i3 focuses its
inactive-focused focused child. Sway does the same, but then resets the
focus to whatever was focused previously.

Ref e5992eed16/src/click.c (L207-L219)
2020-11-01 04:05:38 -05:00
Tudor Brindus 60d95414d4 commands/focus: force container warp when fulfilling `focus mode_toggle`
This commit switches focusing behavior to force a warp when executing
`focus mode_toggle`.

Fixes #5772.
2020-11-01 03:43:00 -05:00
Tudor Brindus 8c12e71a66 input: remove motion deltas from seatop callbacks
Straightforward cleanup, they haven't been used for a while.
2020-10-31 23:15:32 +01:00
Tamir Zahavi-Brunner 96578aa91e hide_cursor: Add an option to hide when typing
Add an option for the `hide_cursor` command to hide the cursor when
typing, i.e. whenever a key is pressed.
2020-10-30 09:59:54 +01:00
mwenzkowski 4799cb0960 output: Revert implementation of evacuate_sticky()
The function evacuate_sticky() was changed in commit 32788a93 to be used
by workspace_for_each_container() to make the code more readable. But I
overlooked that it is not safe to use workspace_for_each_container() to
remove container from a workspace. This commit restores the previous
implementation for evacuate_sticky().
2020-10-28 09:45:12 -04:00
Dimitris Triantafyllidis 39328ca4e4 In container_split, set a floating container's view to tiled
Currently, when a floating container with a view is split and
children are added to it, the new views are rendered as tiled,
while the first view stays in floating style.

Here this is addressed by setting the view to tiled as soon
as the container is split, by duplicating the "view part" of
the logic in container_set_floating(..., false). Since the new
container of the view is no longer considered floating, it
makes sense to set the view to tiling at this point.

The view would have to be set back to floating if it was possible
to "unsplit" the container.
2020-10-28 00:36:33 -04:00
mwenzkowski 32788a93f2 output: evacuate sticky containers only if new output has a workspace
Sticky floating containers on an otherwise empty workspace can only be
evacuated if the new output has an active workspace. The noop output may
not have one and in that case we have to move the whole workspace to the
new output.
2020-10-27 19:26:26 -04:00
Dimitris Triantafyllidis 0cb9282aee Smart borders fix: always show borders for floating containers
Currently, in view_autoconfigure, the only condition for show_border
is !view_is_only_visible. view_is_only_visible does not cross the
boundary between the workspace's tiling and floating lists and does not
differentiate between them.

The result is, that in a workspace with zero or more tiling containers
and a single floating container, the floating container will lose its
borders as soon as it is split, provided that a only one view is visible
within the floating container.

Fixed by adjusting the condition for show_borders.
2020-10-25 21:59:40 -04:00
mwenzkowski 13a67da614 container: Fix NULL pointer dereference
Reset the workspace layout to the output's default only if the workspace
is actually attached to an output.

Fixes #5762
2020-10-24 19:40:25 -04:00
Ronan Pigott d06c1ac1e9 commands/move: fix crash when moving sphsc child 2020-10-24 02:15:30 -04:00
Daniel De Graaf 1be66c98f2 commands/resize: don't consider 1px resizes to be invalid
A "resize shrink width 1px" will cause grow_x to be 0 while grow_width is -1,
incorrectly rejecting the command even though the resize is not a noop.  Fix
this by checking width/height instead of x/y.
2020-10-22 09:10:10 +02:00
Ronan Pigott 9e272a7986 tiling_resize: abandon resize if a sibling con dies 2020-10-20 20:23:50 +02:00
Tudor Brindus cc8d318aa1 transaction: make transaction collapsing smarter with > 2 views
Sway maintains a list of pending transactions, and tries to merge
consecutive transactions applying to the same views into one. Given
a pending transactions list on views {A, B, C} of:

  A -> A' -> A'' -> B -> B' -> B''

Sway will collapse the transactions into just A'' -> B''. This works
fine when doing things like resizing views by their border. However,
when interactively resizing layouts like H[V[A B] C], we end up with
pending transaction lists like:

  A -> B -> C -> A' -> B' -> C' -> A'' -> B'' -> C''

Previously, Sway would not be able to simplify this transaction list,
and execute many more transactions than would be necessary (the final
state is determined by {A'', B'', C''}).

After this commit, the transaction list gets simplified to A'' -> B'' ->
C'', resolving performance problems (that were particularly noticeable
with high-refresh-rate mice).

Fixes #5736.
2020-10-19 01:40:10 +02:00
Tudor Brindus 8355884fbd transaction: validate X transaction completions by geometry, not size
Xwayland views are aware of their coordinates, so validating transaction
completions should take into account the reported coordinates of the
view. Prior to this commit they didn't, and matching dimensions would
suffice to validate the transaction.

Also introduced `transaction_notify_view_ready_immediately` to support
the fix from d0f7e0f without jumping through hoops to figure out the
geometry of an `xdg_shell` view.
2020-10-18 22:37:42 +02:00
Tudor Brindus 5bd6a5ce3f transaction: don't reconfigure X views unless integral coords changed
Sway logical coordinates are doubles, but they get truncated to integers
when sent to Xwayland through `xcb_configure_window`. X11 apps will not
respond to duplicate configure requests (from their truncated point of
view) and cause transactions to time out.

Fixes #5035.
2020-10-18 22:12:16 +02:00
Ronan Pigott 33affb33d2 tiling_drag: emit window move ipc events 2020-10-18 21:56:35 +02:00
Tudor Brindus 181798c2fe xwayland: listen to `set_geometry` event
Closes #5735, refs #3007.

This makes the "Search everywhere" dialog in JetBrains IDEs movable.
2020-10-18 15:18:53 +02:00
Ronan Pigott 5bcbc0b4a9 seat: use default output mapping if there is no input config 2020-10-16 18:34:09 +02:00
Ludvig Michaelsson d6ac30753d swaybar: don't expand separator_block_width if separator is false
When swaybar receives the following JSON body

    [
        {
            "full_text": "foo",
            "separator": false,
            "separator_block_width": 0
        },
        {
            "full_text": "bar"
        }
    ]

it should not draw any separator or any space between the two blocks.
However, since swaybar calculates that separator_block_width
0 is too small to fit any configured separator, it will override the
separator_block_width with some non-zero value. This patch changes
that such that the necessary separator_block_width is only expanded if
the block has 'separator: true'.

This should be in line to what i3 does, as its documentation of the
i3bar protocol for separator states that "[...] if you disable the
separator line, there will still be a gap after the block, unless you
also use separator_block_width".
2020-10-12 16:02:41 +02:00
Tudor Brindus ed247c031c input/tablet: add tool_mode option to set tablet tools as relative input
Closes #4139.
2020-10-12 15:01:37 +02:00
Tudor Brindus 136add4e12 input/cursor: default tablet lens tool to relative motion
It is recommended that mouse and lens cursor tool default to relative
mode and all pen-like tools to absolute mode.

Refs
https://wayland.freedesktop.org/libinput/doc/1.11.3/tablet-support.html#tablet-relative-motion.
2020-10-12 15:01:37 +02:00
Tarmack 989123a2a5 Add support for workspace_min_width bar option. 2020-10-11 19:12:42 +02:00
Tobias Langendorf 657587964e xwayland: support views that change override-redirect status 2020-10-10 09:53:41 +02:00
Tudor Brindus 392d4808c3 commands/move: fix single-split escaping on move
Prior to this commit, having a layout like T[app1 V[app2]], focusing
app2, and then doing `move left` would result in T[app2 app1]. Now, the
resulting layout is T[app1 app2], which matches i3 behavior.

`container_flatten` updates `container->parent`, meaning that the
existing check would never be true.
2020-10-04 21:02:35 -04:00
Tudor Brindus bc239b2f6b desktop/render: show indicators for top-level split
i3 shows indicators for the workspace-level pseudo-split, but Sway does
not, as of b977c02. This commit replaces the floating container check
with a call to `container_is_floating`, which has some more robust
checks in place.

Fixes #5699.
2020-10-04 20:54:58 -04:00
David96 c150177a94 Make focus_follows_mouse work when hovering a layer-shell surface on another output
Fixes #5668
2020-09-26 17:42:14 -04:00
John Mako 4537c8b3d4 check parent surface before it is destroyed 2020-09-19 21:31:31 +02:00
Rouven Czerwinski 41999d7c9f cursor: update hide timer during config apply
We can't arm the timer during cursor creation since the config may not
be ready yet. Instead arm the timer while applying the input
configuration, by this time the configuration has been parsed and we can
arm the hide timer.

Fixes #5686
2020-09-16 07:53:57 +02:00
Geoffrey Casper 65a751a21f server: Avoid using "wayland-0" as WAYLAND_DISPLAY
See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/486
2020-09-16 00:14:20 +02:00
Jonas Hohmann 7aea4692b0 Fix minor typos in German README 2020-09-15 09:55:48 +02:00
Rouven Czerwinski 299a159add cursor: arm cursor hide timer immediately
According to the wayland docs, wayland timers are disarmed on creation.
This leads to the cursor not being hidden if there is no activity after
creation, since the timer is armed on activity, but not at creation.
Arm the timer after creation to ensure the cursor is hidden even if
there is no cursor activity after creation.

Fixes #5684
2020-09-15 09:55:30 +02:00
Tudor Brindus 2efecc14ef input/pointer: update cursor activity after updating button counts
Otherwise, Sway will not re-hide a cursor after the last button has been
released.

Needed alongside afa890e to fix #5679.
2020-09-14 22:28:21 -04:00
Mustafa Abdul-Kader eb1c09030e swaynag: add details background option
Adds a new config option for details background for swaynag

issue/#5673
2020-09-14 22:13:01 -04:00
Rouven Czerwinski afa890e8e9 input/cursor: reset event source after unhide
Reset the event source after unhiding the cursor, to ensure that the
timeout starts after showing the cursor. Also remove the open coded
variant in seat_consider_warp_to_focus().

Fixes #5679
2020-09-14 18:14:08 -04:00
BrassyPanache 7ca9ef12f8 Re-focus on parent surface if it is available
My primary issue was IntelliJ IDEA's code suggestion pop-up not returning focus
to the active editing window.

I have spent some time looking at the changes of @Xyene (#5398) and
@RyanDwyer (#2103). I think my proposed change maintains the status
quo for the most part whilst fixing my focus issue.

I have verified that @Xyene's fix for IntelliJ sub-menus still works.

I have done basic testing which consists of:

- Chrome
- IntelliJ IDEA 2020.2.1
- VSCode
- Alacritty

It seems to hold up. I at least didn't see any obvious errors.

Relates to #3007
2020-09-04 17:00:22 -04:00
oliver-giersch a543fa35ff swaynag: adds option to separately specify the text color for buttons 2020-09-04 18:17:42 +02:00
Érico Rolim 08095e99f3 swaymsg.1: expand tip for multi-word strings.
Strings with commas inside, such as the ones used for
xkb_{config,layout} commands, count as multi-word strings.
2020-09-04 12:37:12 +02:00
Brian Ashworth 2ea5d2985a input/libinput: remove input type property bias
This changes it so all libinput config options are set on any device
that supports it. Previously, only a subset of libinput config options
were being considered depending on the input type. Instead of trying to
guess which properties the device may support, attempt to set any
configured property regardless of the device type. All of the functions
already have early returns in them for when the device does not actually
support the property. This brings the configuration side inline with
describe_libinput_device for the IPC side. This change was prompted
by a tablet tool showing the calibration matrix property in the IPC
message, but not being able to actually change it since that property
was only being considered for the touch input type.
2020-09-03 10:46:06 +02:00
Simon Ser 2c76923282 Use wlr_output_event_commit
Instead of listening to both transform and scale events, we can listen
to the commit event and use the new wlr_output_event_commit struct to
decide what to do.

This de-duplicates some of the work we were doing twice when an output
was re-configured.

Depends on [1].

[1]: https://github.com/swaywm/wlroots/pull/2315
2020-08-27 13:57:10 -06:00
Konstantin Pospelov fd216b3a81 exec: fix validation during config reload
Split cmd_exec_always into separate methods for general validation and
process creation. This fixes a potential call of join_args with 0 arguments.
2020-08-24 09:41:54 +02:00
Simon Ser 6991ac8c70 Handle SIGINT
Gracefully exit on SIGINT, like we do for SIGTERM.
2020-08-11 18:37:11 -04:00
Mark Stosberg 45aa5c104c swaymsg.1: correct typo 2020-08-05 20:41:07 -04:00
Ronan Pigott b7f28cd6b7 view: remove foreign toplevel listeners on destroy 2020-08-05 11:05:49 +02:00
Ronan Pigott f478f4cc66 view: implement foreign toplevel fullscreen request 2020-08-05 11:05:49 +02:00
Ronan Pigott a01573016a view: implement foreign toplevel fullscreen indicator 2020-08-05 11:05:49 +02:00
Hubert Hirtz c5c632aaae Document required '\n' in swaybar-protocol
The following statusbar output is not considered by sway to be following
the swaybar-protocol:

    {"version":1}[[{"full_text":"2.89","urgent":false}],

However this one is:

    {"version":1}\n[[{"full_text":"2.89","urgent":false}],

Both outputs contain a header with the required values and an unfinished
array of objects with the required values, but the first one is showed
verbatim.
2020-08-04 10:39:29 +02:00
Rex Hackbro 8fb9f3b711 document force_display_urgency_hint 2020-08-03 15:39:48 +02:00
Rex Hackbro 12a9ae013e fix force_display_urgency_hint parsing 2020-08-03 15:39:48 +02:00
Rex Hackbro d25e308f9c fix typos 2020-08-03 10:41:38 +02:00
Antonin Décimo 5c67d99794 common/loop: check return of realloc 2020-07-30 22:02:42 -04:00
Antonin Décimo bbf7b92fe4 Fix incorrect format specifiers 2020-07-30 22:02:42 -04:00
Antonin Décimo a1c6052383 Log empty value if envvar is not defined
If the environment variable is not defined, getenv returns NULL.
Passing a NULL pointer to the "%s" format specifier is undefined
behavior. Even if some implementations output "(null)", an empty
string is nicer.
2020-07-30 22:02:42 -04:00
Antonin Décimo 2960b2c9b6 cmd/bar/colors: fix dereference of null pointer
`!*rgba` tests if the first byte of rgba isn't `'\0'`.
`hex_to_rgba_hex` returns NULL if `parse_color` fails. There's a null
pointer dereference in that case. The intended behavior is `!rgba`.
2020-07-30 22:02:42 -04:00
Antonin Décimo 8033b575f7 ipc: fix aligment issue of data buffer
The pointer `data` is cast to a more strictly aligned pointer type. To
prevent issues, the `data32` buffer is removed and its occurrences are
replaced with an offset from the `data` buffer.
2020-07-30 22:02:42 -04:00
Thayne McCombs b20d52f71d Use wlr_output_layout_output_at to get output for move to cursor 2020-07-27 11:27:47 +02:00
Thayne McCombs cfa403fc58 Keep windows in bounds on move to position mouse
If the mouse/cursor/pointer is near the edge of an output when a "move
position to pointer" command is run, then the floating container will be
constrained to fit inside the bounds of the output as much as possible.

This behavior matches what i3 does in this scenario. I also think it is
a better user experience.

Relates to #4906

The logic for the bounds check follows the implementation in i3: 7330778223/src/floating.c (L536)
2020-07-27 11:27:47 +02:00
Ronan Pigott dae74057b3 commands: disallow runtime include 2020-07-27 10:54:04 +02:00
Ronan Pigott 3520fd2c19 view: display scratchpad hidden containers when activated by ftm 2020-07-25 11:53:01 -04:00
Tobias Langendorf 4f718e6c75 Fix X11 clients getting stuck minimized
Usually it should be enough to simply not grant a client's
minimize request, however some applications (Steam, fullscreen
games in Wine) don't wait for the compositor and minimize anyway,
getting them stuck in an unrecoverable state.
Restoring them immediately lead to heavy flickering when unfocused
on my test application (Earth Defense Force 5 via Steam), so it's
preferable to grant their request without actually minimizing and
then restoring them once they are in focus again.
2020-07-22 18:50:57 -04:00
Charmander 66b7ac6a82 swaybar: allow status line cleanup to proceed when hidden
`determine_bar_visibility` stops and starts the status command process according to the bar’s visibility. If the bar was hidden during teardown, teardown would stall while waiting for the stopped status command process to exit.

This resumes a stopped status command during teardown and allows, for example, sway to reload or quit without leaving a swaybar instance behind each time.

Fixes #5536.

CONT before TERM as requested in review.
2020-07-22 09:40:37 +02:00
Antonin Décimo 7c7afa3b29 Fix typos in man page. 2020-07-21 17:45:09 +02:00
Nils Schulte b513981378 added ppt unit to move position command 2020-07-21 10:07:01 +02:00
Nils Schulte 6898d1963f moved and renamed movement-unit parsing to common 2020-07-21 10:07:01 +02:00
Ronan Pigott 36c3c222d2 sway.5: add missing underscore 2020-07-19 11:03:24 -04:00
Andri Yngvason ab8ded626b desktop: output: Scale custom output refresh rate
This fixes an issue with wlr-output-management causing the frame rate to
jump to 60000 Hz when setting a custom mode.
2020-07-18 18:21:51 +02:00
Michael Weiss 380f6c9b46 contrib/_incr_version: Disallow the "v"-prefixed version format
The check is a bit strange but should be POSIX compliant.
2020-07-17 05:44:24 -06:00
Michael Weiss 6deb4ff40b meson.build: Fix the version format
The current version is prefixed by a "v" and therefore breaks the output
of "swaymsg -rt get_version" which is implemented trough
"sscanf(SWAY_VERSION, "%u.%u.%u", &major, &minor, &patch)".

The prefixed "v" was added in 8b2ff2f1, probably by accident.
2020-07-17 05:44:24 -06:00
Simon Ser e215557ba0
Bump version to 1.5 2020-07-16 00:59:41 +02:00
Simon Ser 9f944ff05d
Bump wlroots dependency to 0.11.0 2020-07-16 00:59:25 +02:00
Tudor Brindus 6b9a9b6246 input/cursor: don't send wl_pointer.motion event on pointer unlock warp
On warping to a cursor hint, update the pointer position we track as
well, so that on the next pointer rebase we don't send an unexpected
synthetic motion event to clients.

Fixes #5405.
2020-07-15 19:40:09 +02:00
Michaël Defferrard 2f3afef95c readme: link to the development doc
The subproject compilation is the best way to test sway and wlroots but it's hidden. I only found it from comments in issues.
2020-07-15 19:13:41 +02:00
Vinko Kašljević c65cd1cffa Add check for empty GEOM variable
In case when slurp is used to select part of screen or a window, if user aborts
the selection, grimshot will capture the whole screen instead of exiting. This
is fixed with check for empty variable.
2020-07-15 18:49:32 +02:00
Campbell Vertesi acbe902815 Add note on quoting to swaymsg manpage 2020-07-15 16:17:11 +02:00
Ronan Pigott 4dd46f06ac xdg_shell: schedule configure on maximize requests 2020-07-14 15:46:02 +02:00
Simon Ser 9bb70283e9 Assert output is found before removing from list
References: https://github.com/swaywm/sway/issues/5483
2020-07-13 17:33:54 -04:00
Ronan Pigott 39d677af15 input: implement xdg_toplevel interactive resize hints 2020-07-13 00:21:52 -04:00
Jonas Große Sundrup 10ec97c073 rephrase swayidle-timout example to improve readability 2020-07-12 14:29:49 +02:00
Wai Hon Law 585236f168 Make the default workspace commands compatible with i3
**Problem**

When I rename the workspace to something like "1:web",
`$mod+1` does not move to the "1:web" with the default config. This breaks
the expectation of i3 users.

**Cause**

The default Sway binding for `$mod+1` does not have the number
keyword:

```
bindsym $mod+1 workspace 1
```

Instead, the default Sway binding for `$mod+1` is

```
bindsym Mod1+1 workspace number $ws1
```

e6662df114
is the corresponding commit from i3.
2020-07-11 20:18:11 -04:00
Simon Ser 5432f00adf config/output: don't change output state before commit
Previously, we called output_disable prior to wlr_output_commit. This
mutates Sway's output state before the output commit actually succeeds.
This results in Sway's state getting out-of-sync with wlroots'.

An alternative fix [1] was to revert the changes made by output_disable
in case of failure. This is a little complicated. Instead, this patch
makes it so Sway's internal state is never changed before a successful
wlr_output commit.

We had two output flags: enabled and configured. However enabled was set
prior to the output becoming enabled, and was used to prevent the output
event handlers (specifically, the mode handler) from calling
apply_output_config again (infinite loop).

Rename enabled to enabling and use it exclusively for this purpose.
Rename configure to enabled, because that's what it really means.

[1]: https://github.com/swaywm/sway/pull/5521

Closes: https://github.com/swaywm/sway/issues/5483
2020-07-10 18:18:27 -04:00
Geoffrey Casper ea3ba203cc Reload command now matches i3's implementation 2020-07-07 17:15:57 -04:00
Nick Diego Yamane e5954f321f seat/dnd: support null drag icon surfaces
As per the Wayland spec [1]:

> The icon surface is an optional (can be NULL) surface that provides an
> icon to be moved around with the cursor.

However, as of now Sway "start_drag" signal handler does not starts the
DND session unless a non-NULL drag icons is provided. This patch fixes
it by skipping handling of the drag icon if it is null.

Fixes #5509

[1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_data_device

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
2020-07-07 00:05:35 +02:00
Brian Ashworth bac9559665 ISSUE_TEMPLATE: Use the newer issue templates
This utilizes the newer Github issue templates. They allow for the user
to specify what type of issue they are submitting to allow for a more
specific issue template to be shown.

In addition to a hopefully easier to read/parse/follow bug report
template, this also include templates for enhancements and i3
compatibility. This also includes a link to the IRC under the section
title Questions.

For the three templates, the labels bug, enhancement, and i3-compat will
be automatically applied for the appropriate report to assist in
triaging.

Hopefully, this will result in less questions and issues for new window
management functionality on Github and allow for better quality issues
being submitted. At the very least, it allows us to outline our
stances for bugs, enhancements, and i3-compatibility in an easier to
read format.
2020-07-06 23:30:14 +02:00
Jan Beich 1d149230ea protocols: sync wlr-layer-shell-unstable-v1 with wlroots 2020-07-05 09:58:39 +02:00
Tudor Brindus b4a75a1ab2 commands/move: maintain workspace_layout when moving
Fixes #5157.
2020-07-03 18:40:59 -04:00
wb9688 17ff13fc84 Replace unprintable characters in input device id 2020-07-03 14:59:20 +02:00
Simon Ser b5a35c484f tree/view: fix segfault in view_update_title
xdg-shell doesn't allow clients to set the title to NULL, so we
shouldn't need to call wlr_foreign_toplevel_handle_v1_set_title with an
empty string to reset the old one.

Closes: https://github.com/swaywm/sway/issues/5488
2020-07-03 09:23:35 +02:00
Simon Ser eb4fa18308 Unset DISPLAY when wlr_xwayland fails
Avoids having applications connect to a leftover DISPLAY when Xwayland
fails to initialize.
2020-07-02 23:55:56 -04:00
Simon Ser dfccd2a4c4 Don't set xwayland cursor when wlr_xwayland failed
This causes a NULL pointer dereference.
2020-07-02 23:55:56 -04:00
Simon Ser 1bfbf262cc seat: fix segfault in sway_input_method_relay_set_focus
sway_input_method_relay_set_focus was called before
sway_input_method_relay_init.

Closes: https://github.com/swaywm/sway/issues/5503
2020-07-02 17:11:05 -04:00
Tudor Brindus 92891fb1ed commands/move: unwrap workspace container on move to new workspace
If moving e.g. `T[app app]` into a new workspace with `workspace_layout
tabbed`, then post-move the tree in that workspace will be `T[T[app
app]]`. This still happens with horizontal or vertical workspace layout,
but is less visible since those containers have no decorations.

Fixes #5426.
2020-07-01 18:43:20 -04:00
Tudor Brindus 105bf23998 Minor wording changes in Romanian README.md translation 2020-07-01 21:30:18 +02:00
Drew DeVault 8b2ff2f1b3 Update version to v1.5-rc2 2020-07-01 14:36:29 -04:00
Johan Bjäreholt 1f8dbb320a tree/view: Make foreign-toplevel app_id fallback to class
It is not a part of the foreign-toplevel-management protocol to get the
class of a toplevel, only for getting the app_id.
For xwayland clients this is an issue because that means that you cannot
identify what application the toplevel refers to which is the point of
the app_id property.

By falling back to class when an app_id does not exist solves this problem.

Phoc also uses app_id and class interchangeably in their implementation
of foreign-toplevel-management, in fact they always do that and not only
for just this protocol.
c8d8a4c544/src/xwayland.c (L236)
2020-07-01 17:21:57 +02:00
Isaac Freund 76adcc3fd3 output: simplify loop over layer surfaces 2020-06-30 16:19:00 +02:00
Kenny Levinsen 492267a5d6 seat: Refocus seat when wlr_drag is destroyed
wlr_drag installs grabs for the full duration of the drag, leading to
the drag target not being focused when the drag ends. This leads to
unexpected focus behavior, especially for the keyboard which requires
toggling focus away and back to set.

We can only fix the focus once the grabs are released, so refocus the
seat when the wlr_drag destroy event is received.

Closes: https://github.com/swaywm/sway/issues/5116
2020-06-30 13:27:51 +02:00
Kenny Levinsen d0f7e0f481 transaction: Mark client resize immediately ready
If a client commits a new size on its own, we create a transaction for
the resize like any other. However, this involves sending a configure
and waiting for the ack, and wlroots will not send configure events when
there has been no change. This leads to transactions timing out.

Instead, just mark the view ready immediately by size when the client
is already ready, so that we avoid waiting for an ack that will never
come.

Closes: https://github.com/swaywm/sway/issues/5490
2020-06-30 10:59:33 +02:00
Tudor Brindus bb85b9070d tree/view: fix smart borders with tabbed/stacked ancestor
Fixes #5484.
2020-06-27 21:05:58 -04:00
Tudor Brindus c822427091 input/pointer: correctly handle bindings for synthetic events
This commit addresses a regression introduced in 8fa74ad.

Fixes #5481.
2020-06-25 21:32:15 +02:00
Simon Ser ba0232e6f0
Update version to 1.5-rc1 2020-06-24 19:29:13 +02:00
taminaru 64f080fa27 Add Romanian translation 2020-06-23 22:59:27 +02:00
Drew DeVault 8d5e627bc9 Implement wlr-foreign-toplevel-management-v1 2020-06-23 22:26:00 +02:00
Tudor Brindus eeb90a7963 input_cmd_click_method: fix typo in error text 2020-06-19 22:48:53 +02:00
Tudor Brindus 2270b4c213 input/seat: don't notify keyboard grabs with NULL surface on shutdown
Fixes #5469, a minor regression introduced in #5368.
2020-06-19 18:46:01 +02:00
Tudor Brindus b3f08597cd input: disable events for map_to_output devices when output not present
Fixes #3449.
2020-06-19 10:02:22 +02:00
Tudor Brindus d328c2439c input/pointer: don't trigger pointer bindings for emulated input
Prior to this commit, a tablet device could trigger mouse button down
bindings if the pen was pressed on a surface that didn't bind tablet
handlers -- but it wouldn't if the surface did bind tablet handlers.

We should expose consistent behavior to users so that they don't have to
care about emulated vs. non-emulated input, so stop triggering bindings
for any non-pointer devices.
2020-06-18 22:35:01 +02:00
Tudor Brindus 82c439c4f1 input/cursor: send idle events based off device type, not input type
Previously, a tablet or touch device could report activity as a pointer
device if it went through pointer emulation. This commit refactors idle
sources to be consistently reported based on the type of the device that
generated an input event, and now how that input event is being
processed.
2020-06-18 22:35:01 +02:00
David Arnold 21b77f376d grimshot: fix POSIX compliance
source is not POSIX compliant, '.' is.
https://stackoverflow.com/a/11588629
2020-06-17 22:33:10 +02:00
David Arnold 62e28f6129 grimshot: Unary operator expected
fixes this error:
/usr/local/bin/grimshot: line 22: [: ==: unary operator expected
2020-06-17 22:32:05 +02:00
Simon Ser e19bd1e474 Add support for viewporter
Depends on [1].

[1]: https://github.com/swaywm/wlroots/pull/2092
2020-06-17 10:18:58 -06:00
Tudor Brindus 8fa74add82 input/pointer: don't trigger pointer bindings for emulated input
Prior to this commit, a tablet device could trigger mouse button down
bindings if the pen was pressed on a surface that didn't bind tablet
handlers -- but it wouldn't if the surface did bind tablet handlers.

We should expose consistent behavior to users so that they don't have to
care about emulated vs. non-emulated input, so stop triggering bindings
for any non-pointer devices.
2020-06-16 19:21:55 +02:00
Tudor Brindus 20deb8ec16 input/tablet: focus appropriate node on tip down
This commit makes tablet input more usable when `focus_follows_mouse` is
set to `no`.

Previously, tapping down on surfaces that bound tablet input would not
switch focus, whereas tapping on surfaces that didn't (and hence went
through pointer emulation) did.
2020-06-16 17:58:13 +02:00
Brian Ashworth 33aa59d4c6 input/keyboard: wlr_keyboard_group enter and leave
This adds support for wlr_keyboard_group's enter and leave events. The
enter event just updates the keyboard's state. The leave event updates
the keyboard's state and if the surface was notified of a press event
for any of the keycodes, it is refocused so that it can pick up the
current keyboard state without triggering any keybinds.
2020-06-16 17:53:23 +02:00
Jason Nader 45859be03f i3-compat: add GET_BINDING_STATE IPC command 2020-06-14 00:55:14 -04:00
Simon Ser f9361ae36c Remove view child surface_{map,unmap} listeners on destroy 2020-06-12 19:37:19 -04:00
Ronan Pigott 90d936d4ad view: fix surface_new_subsurface use-after-free 2020-06-13 00:55:33 +02:00
Luke Drummond c22caa54a8 swaybar: ensure correct init order for status_line
`$WAYLAND_SOCKET` is unset by `wl_display_connect` after it has
successfully connected to the wayland socket.

However, subprocesses spawned by swaybar (status-command) don't have
access to waybar's fds as $WAYLAND_SOCKET is O_CLOEXEC. This means any
status command which itself tries to connect to wayland will fail if
this environment variable is set.

Reorder display and status-command initialization so that this variable
is not set and add an assert so we can enforce this invariant in future.
2020-06-12 14:45:40 +02:00
Simon Ser bf8d23a836 Log Sway version on startup 2020-06-11 08:44:09 -06:00
Luke Drummond 62a530513c swaynag: sway_abort on failure to properly register
In case `wl_display_roundtrip` returns an error after registering for
events, print a more user-friendly error message and exit.

Previously, if the build did not have assertions enabled, this would
likely result in a segfault. With assertions enabled, it's not user
friendly to terminate with internal implementation information.
2020-06-10 15:50:31 +02:00
Tudor Brindus ed08f2f20c tree/view: fix smart gaps when ancestor container is tabbed or stacked
Fixes #5406.
2020-06-08 19:01:45 -04:00
Tudor Brindus 14e887bc3d input: tweak resize behavior to not change tab focus on border click
If a resize is triggered on a tabbed or stacked container, change focus
to the tab which already had inactive focus, rather than to the tab
whose border was clicked -- otherwise, we'd change the active tab when
the user probably just wanted to resize.
2020-06-08 18:23:09 -04:00
Graham Christensen a974300652 swaynag: allow specifying more buttons which execute and dismiss
I don't love -z / -Z, but I figure this patch is far from being
accepted for other reasons too.
2020-06-09 00:00:14 +02:00
Tudor Brindus ce494a5811 input/tablet: allow moving tiling tablet v2 surfaces by pen input
Closes #5293.
2020-06-07 10:46:14 +02:00
Tudor Brindus 7dec1f8398 input/tablet: allow moving floating tablet v2 surfaces by pen input
Refs #5293.
2020-06-07 10:46:14 +02:00
Tudor Brindus 53dc83fb68 tree/container: introduce `container_toplevel_ancestor` helper
This allows us to not have to explicitly write the same while loop
everywhere.
2020-06-07 10:46:14 +02:00
Tudor Brindus d7900c6e5e common/util: fix `get_current_time_msec` returning microseconds
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util.c` so that it can be reused elsewhere
without having to consider these pitfalls.
2020-06-06 13:38:41 +02:00
TheAvidDev d835df38de Add wayland_client dependency to common 2020-06-06 11:03:04 +02:00
Thomas Hebb 84ec8f92a6 Use new wlroots API for clearing keyboard/pointer focus during grabs
We are not allowed to do what we did in #5222 and pass a `NULL` surface
wlr_seat_pointer_notify_enter(), and it's causing crashes when an
xdg-shell popup is active (see #5294 and swaywm/wlroots#2161).

Instead, solve #5220 using the new wlroots API introduced in
swaywm/wlroots#2217.
2020-06-05 17:24:23 +02:00
Kalyan Sriram e3e548a648
Save transform during transaction
Closes: https://github.com/swaywm/sway/issues/5412
2020-06-05 14:13:18 +02:00
Tudor Brindus f7e050c58f input/cursor: refactor tablet tool tip events into seatops
This commit moves tool tip event generation into seatops. In doing so,
some corner cases where we'd erroneously (but likely harmlessly)
generate both tablet and pointer events simultaneously are eliminated.
2020-06-04 10:20:32 +02:00
Kenny Levinsen f8dd7df1f5 shells: Resize on commit if geometry x/y changes
Client-side decorations lead to changes to y position, so make sure we
catch that.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 5a4a7bc0da container: Remove useless surface dimensions
The adjustments to resize logic left them unnecessary.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 7670f1a521 transaction: Improve transaction commentary
Some comments where slightly misleading.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 645cf76f8a transaction: Account for full size when centering content
The centering logic needs to take borders, titlebars and CSDs into
account. Instead of using the main surface geometry, use the container
and view geometry, which account for this.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 4edd429053 view: update_size should only update pending size
Updating the current size outside transactions lead to rendering
glitches during resizes.
2020-06-03 16:41:17 +02:00
Kenny Levinsen fcd0ab8f33 view: Save all buffers associated with view
During the execution of a resize transaction, the buffer associated
with a view's surface is saved and reused until the client acknowledges
the resulting configure event.

However, only one the main buffer of the main surface was stored and
rendered, meaning that subsurfaces disappear during resize.

Iterate over all, store and render buffers from all surfaces in the view
to ensure that correct rendering is preserved.
2020-06-03 16:41:17 +02:00
Tudor Brindus 613abdda6f xwayland: pass focus to previous unmanaged surface on unmap
This is necessary because some applications (e.g. Jetbrains IDEs)
represent their multi-level menus as unmanaged surfaces, and when
closing a submenu, the main menu should get input focus.

Closes #5347.
2020-06-01 17:58:15 +02:00
Tudor Brindus 83866558d3 tree/container: refactor `tiling_container_at` to check bounds
This fixes bugs where a floating container would take input way past its
borders when its parent was fullscreen, since the call to
`tiling_container_at` in input/cursor.c's `node_at_coords` did not check
bounds.
2020-05-30 02:16:15 -04:00
Damien Tardy-Panis 0cbd26f0da Add views idle inhibition status in get_tree output
Fixes #5286
2020-05-29 17:29:41 -04:00
Brian Ashworth 8cdcb77e12 seat_cmd_cursor: emit frame events
This emits frame events for the seat_cmd_cursor subcommands. The
wl_pointer frame event are required to notify clients when to process
the events. It will now be emitted after cursor movement, button press,
button release, and axis events.
2020-05-29 15:37:40 -04:00
Tudor Brindus 6da1631090 input/cursor: rename `simulated_tool_tip_down` to be more accurate
This is a tiny cleanup commit that renames `simulated_tool_tip_down` to
`simulating_pointer_from_tool_tip`, making it match
`simulating_pointer_from_touch`.

This is a better name since it makes it clear that it's the *pointer*
that's being simulated, not the tool tip.
2020-05-29 08:44:56 +02:00
Tudor Brindus 6f7b548589 ipc: invert output transformation when necessary
After swaywm/wlroots#2023, #4996 inverted configuration transformations.
For consistency, we should undo (double-apply) the inversion when
communicating via IPC.

Closes #5356.
2020-05-28 09:49:10 +02:00
Tudor Brindus 6ea45395c7 input/pointer: send pointer enter event on confine warp
The spec has this to say about sending events on confine creation:

  Whenever the confinement is activated, it is guaranteed that the
surface the pointer is confined to will already have received pointer
focus and that the pointer will be within the region passed to the
request creating this object.

...and on region update:

  If warped, a wl_pointer.motion event will be emitted, but no
wp_relative_pointer.relative_motion event.

Prior to this patch, sway did neither, and updated the hardware cursor
position without notifying the underlying surface until the next motion
event. This led to inconsistent results, especially in applications that
draw their own software cursor.
2020-05-28 09:44:00 +02:00
Tudor Brindus 704d675a36 Log Xwayland startup failures
Though unlikely, this commit makes server initialization totally
explicit in the logs.
2020-05-27 18:58:23 +02:00
Tudor Brindus d71fed95da input/cursor: keep reference to cursor in constraint
set_region accepts a NULL *data, so we can't use it to reference the
constraint and find the cursor through its seat.

Fixes #5386.
2020-05-26 16:24:52 +02:00
Tudor Brindus 34e0cad9ac input/cursor: fix heap-buffer overflow in constraint set_region
Fixes #5383, caused by an oversight in 6f0a0bd.
2020-05-25 21:30:53 +02:00
Tudor Brindus 5d13f647f9 input/tablet: add seatop_down entry for tablet input
Currently, when tablet input exits a window during an implicit grab, it
passes focus to another window.

For instance, this is problematic when trying to drag a scrollbar, and
exiting the window &mdash; the scrollbar motion stops. Additionally,
without `focus_follows_mouse no`, the tablet passes focus to whatever
surface it goes over regardless of if there is an active implicit.

If the tablet is over a surface that does not bind tablet handlers, sway
will fall back to pointer emulation, and all of this works fine. It
probably should have consistent behavior between emulated and
not-emulated input, though.

This commit adds a condition for entering seatop_down when a tablet's
tool tip goes down, and exiting when it goes up. Since events won't be
routed through seatop_default, this prevents windows losing focus during
implicit grabs.

Closes #5302.
2020-05-25 10:01:00 +02:00
Tudor Brindus c632d47bf8 common/log: use bright black rather than black for SWAY_DEBUG
On some terminals under default settings, black is truly rendered as
`#000`, making it unreadable when the background is also black.

Closes #5141.
2020-05-24 14:54:05 +02:00
lbonn 848a6fdb21 ipc: show marks of containers without view in tree 2020-05-22 08:21:22 +02:00
Érico Rolim 1d3681f521 Remove code related to the security features
- Remove struct definitions
- Remove struct members
- Remove initializations and frees
2020-05-21 10:57:00 +02:00
Martin Michlmayr 06fc42359b Fix typos in comments 2020-05-21 10:52:59 +02:00
Tudor Brindus 6f0a0bd385 input/pointer: only warp cursor when the confine region has changed
Refs #5268.
2020-05-21 10:45:08 +02:00
Milkey Mouse 45e4e92172 swaybar: add NULL check when listing workspaces
For some reason my version of sway doesn't show workspace names:

    $ swaymsg -t get_outputs
    Output HDMI-A-1 '(null) (null) (null)' (inactive)
    Output HDMI-A-2 '(null) (null) (null)' (inactive)

Which is weird, but it's no reason to crash swaybar. The field is
totally missing from the JSON, so it ends up doing strcmp(NULL, name)
which is undefined behavior.
2020-05-20 23:11:02 +02:00
Martin Michlmayr 2bf14cb747 sway.5: make formatting more consistent 2020-05-20 14:11:34 +02:00
Brian Ashworth 5c32a48453 input: fix reloading crash due to keyboard group configuring
Keyboard group keyboards should not call sway_keyboard_configure. They
do not have an input config and they derive their state from the
keyboards within the group.

For some reason, I got sway_keyboard_configure and
seat_configure_keyboard mixed up and thought seat_reset_device called
the latter.

Calling sway_keyboard_configure with a keyboard group's keyboard is not
supported and can cause issues. If any clients are listening to the ipc
input event, a sigsegv will occur due to not every property - such as
identifier - being wired up for keyboard group keyboard's.

This also adds an assertion to sway_keyboard_configure to ensure that
this does not occur in the future and any instances are quickly caught.
2020-05-19 15:42:32 -04:00
Eric Engestrom 9b5895be63 bash completion: swaymsg accepts --version, not --verbose 2020-05-15 13:04:32 +02:00
Brian Ashworth 975b8a90ad input: reset keyboard groups keyboard on reset all
If the keyboard that triggers the reload binding is using the default
keymap, default repeat delay, and default repeat rate, the associated
keyboard group is never being destroyed on reload. This was causing the
keyboard group's keyboard not to get disarmed and result in a
use-after-free in handle_keyboard_repeat.

If the keyboard was not using the defaults for all three settings, then
it's associated keyboard would get destroyed during the reset - which
did disarm the keyboard group's keyboard. In this case, the
use-after-free would not occur.

This adds a block to input_manager_reset_all_inputs that resets the
keyboard for all keyboard groups in all seats, which will disarm them.
Since the inputs are all being reset anyway, which will reset all
individual keyboards, it is not necessary to be selective on which ones
get reset.
2020-05-14 23:51:17 -04:00
Érico Rolim aa48b926be security.d: remove directory
Remove the entries from meson.build as well.
2020-05-14 09:36:09 +02:00
Michael Weiser 0f11aa037a commands: Add per-view shortcuts_inhibitor command
Add a separate per-view shortcuts_inhibitor command that can be used
with criteria to override the per-seat defaults. This allows to e.g.
disable shortcuts inhibiting globally but enable it for specific,
known-good virtualization and remote desktop software or, alternatively,
to blacklist that one slightly broken piece of software that just
doesn't seem to get it right but insists on trying.

Add a flag to sway_view and handling logic in the input manager that
respects that flag if configured but falls back to per-seat config
otherwise. Add the actual command but with just enable and disable
subcommands since there's no value in duplicating the per-seat
activate/deactivate/toggle logic here. Split the inhibitor retrieval
helper in two so we can use the backend half in the command to retrieve
inhibitors for a specific surface and not just the currently focused
one. Extend the manual page with documentation of the command and
references to its per-seat sibling and usefulness with criteria.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-05-13 21:22:16 -04:00
David96 2473cac32c Implement pointer simulation if client hasn't bound to touch 2020-05-13 14:29:15 -04:00
Adam Kürthy 7a294b2668 Really fix floating window border resize problems
Fixes: https://github.com/swaywm/sway/pull/5250
2020-05-13 11:07:31 +02:00
Tudor Brindus 2262ae60f4 input/cursor: don't apply pointer constraint to emulated tablet input
Closes #5268.
2020-05-13 08:58:23 +02:00
Kenny Levinsen a8a6ed667d Simplify repaint scheduling documentation
The current documentation for repaint scheduling is very technical and
somewhat confusing.

Closes: https://github.com/swaywm/sway/issues/4769
2020-05-11 10:36:33 +02:00
Paul Ouellette b1d08db5f5 Fix some mistakes in grimshot docs 2020-05-10 17:25:54 -04:00
Tudor Brindus 726d187d3c input/tablet: simplify parameter plumbing for tablet references
This is a small cleanup commit for removing `sway_tablet` parameters
from functions that already accept `sway_tablet_tool`, since the tablet
reference can be accessed through `tool->tablet`.
2020-05-10 16:49:35 +02:00
Tudor Brindus 7c37e9d01e input/keyboard: use wlr_keyboard_keymaps_match from wlroots
Added in swaywm/wlroots#2172, so that sway doesn't need to maintain
an independent copy of this function.
2020-05-08 17:48:43 -04:00
Hugo Osvaldo Barrera 9cda5a5bd6 grimshot: Skip creating a temp file when copying 2020-05-05 20:18:19 +02:00
Hugo Osvaldo Barrera f82de63856 grimshot: Add a man page 2020-05-05 20:18:19 +02:00
Hugo Osvaldo Barrera b10b6b552b grimshot: Add a separate flag for notifications
Make notifications a separate flag. Personally, I trigger grimshot
myself most of the time (via sway bindsym) rather than by some external
means, so I don't need to be notified of it happening.

However, keep a flag with this functionality there for those scenarios
there it's necessary to inform the user.

Also print the file location when saving the screenshot.
2020-05-05 20:18:19 +02:00
Hugo Osvaldo Barrera 1191a41fb2 grimshot: Allow manually picking a window
(with slurp)
2020-05-05 20:18:19 +02:00
Hugo Osvaldo Barrera 25a0130e81 grimshot: Show usage when on invalid command
Show the usage output when an invalid command is received. Otherwise
things like `grimshot --help` save a screenshot, which is really
unexpected and hurts users trying to remember the right commands /
arguments.
2020-05-05 20:18:19 +02:00
Hugo Osvaldo Barrera 61d59180b8 grimshot: Avoid screenshots overwriting each other
Due to the date format used, if several screenshots are taken in
succession, each one overwrote the other.

This change set makes each one have a different name to avoid this.

Also avoid using spaces, since many scripts and tools are unhappy with
file names with spaces.
2020-05-05 20:18:19 +02:00
Hugo Osvaldo Barrera dce8abcdab grimshot: Allow configuring default directory
`$XDG_PICTURES_DIR` is a very loosely defined thing; it's a directory
where "pictures" are stored, which no clearer definition.

Some people use it for photographs they take, other use it for images
they save from the internet, and others use it for screenshots.

Having lots of tools save their output there (anything that's an image
goes there) can easily make it a kitchen sink.

To work around this, use `$XDG_SCREENSHOTS_DIR` as a target directory
for screenshots by default. If not-so-standard variable is unset, fall
back to the previous setting; `$XDG_PICTURES_DIR`.

This also drops an external dependency, which was (a) an overkill (b)
not flexible enough.
2020-05-05 20:18:19 +02:00
David96 e5fed6b246 Don't unhide cursor on touch events
Touch events hide the cursor so unhiding it again only causes it to
flicker.
2020-05-05 17:39:26 +02:00
Tudor Brindus 52bd6aecf2 input/cursor: remove erroneous cast for tablet tool button
The type expected by wlroots is uint32_t, which `event->button`
already is.
2020-05-02 21:16:21 +02:00
Tudor Brindus e262f93d0a input: rename pointer handlers to be unambiguous
This commit renames `motion` and `axis` handlers to `pointer_motion` and
`pointer_axis`, respectively, to disambiguate them from their tablet
(and future touch) handlers. `button` is left as-is, as it is generic
across input devices.
2020-05-02 18:28:06 +02:00
Tudor Brindus ae3ec745f8 input: refactor tablet motion into seatop handler
This commit moves tablet motion logic into a seatop handler.

As a side-effect of seatop implementations being able to receive
tablet motion events, fixes #5232.
2020-05-02 13:32:28 +02:00
Tudor Brindus 9362003cba input/cursor: disambiguate cursor functions from pointer functions 2020-05-02 13:32:28 +02:00
Tudor Brindus 0dc1863dce input/cursor: make cursor rebasing cursor type-agnostic
This commit refactors `cursor_rebase` into `cursor_update_image`, and
moves sending pointer events to the two existing call sites. This will
enable this code to be reused for tablets.

Refs #5232
2020-05-02 13:32:28 +02:00
Simon Ser 5e5e5f2ee5 Add a secondary headless backend
This allows the create_output command to work on DRM too.
2020-05-01 17:00:14 +02:00
Simon Ser 6021fc4a08 Fix invisible cursor on startup 2020-05-01 16:57:24 +02:00
Simon Ser f55de073c2 Don't assert the cursor theme loads
If it doesn't load, it's a runtime error, so we shouldn't use an
assertion.
2020-05-01 16:57:24 +02:00
skip-yell 59acc12b32
Add Korean README.md 2020-05-01 11:45:11 +02:00
Tudor Brindus 2913f39dcb input/cursor: release simulated tool tip button when over v2 surface
d88460f addressed sending v2 tool tip up when over a non-v2 surface.
This commit addresses the other direction.

Fixes #5230.
2020-05-01 11:00:49 +02:00
Nick Diego Yamane 091f580b7c input/seatop_default: properly notify pointer leave
Currently, clients receive wl_data_device::leave events only when the
pointer enters another surface, which leads to issues, such as #5220.
This happens because wlr_seat_pointer_notify_enter() is called when
handling motion events only for non-NULL surfaces.

Fixes #5220
2020-05-01 10:56:14 +02:00
Simon Ser 7251df94c1 build: improve feature summary
Use the Meson summary() built-in instead of manually formatting a
message.

wlroots already depends on Meson 0.54.0.
2020-05-01 03:25:49 +02:00
James Mills 2373af77d4
Fix typo in swaybar-protocol.7.scd 2020-04-30 15:15:58 +02:00
jhalmen 99897a6ca0 fix typos in sway-input.5.scd 2020-04-29 12:43:34 +02:00
Ejez 017f7984c7 Correct typo in sway-output.5.scd 2020-04-29 11:19:34 +02:00
Brian Ashworth 8fd450db16 ISSUE_TEMPLATE: note debug logs should be from TTY
It is common for user to attach a debug log from the Wayland backend
because they are running the command from inside of Sway. This just adds
a note that the debug logs should be obtained from a TTY. Anyone who is
actually using the Wayland or X11 backends and submitting an issue
related to them likely is already familiar with how to obtain a debug
log for the appropriate backend.
2020-04-29 08:33:20 +02:00
Simon Ser b8118eb2bf Redirect questions to wiki/IRC
The issue tracker has already enough traffic with bug reports and
feature requests.
2020-04-29 01:22:49 -04:00
Martin Dørum 4492e493e6 swaybar: Fix scrolling with precise trackpads 2020-04-28 21:46:37 +02:00
Thomas Hebb f18bcfcd69 Add each view's shell to JSON description
This is a criteria you can use to select windows since commit
484cc189e9 ("Add shell criteria token"), but there's no way to query
it for an existing window. This exposes its value in the output of
`swaymsg -t get_tree`.
2020-04-27 20:37:57 -04:00
Simon Ser 58703e4f24 man: add note about sway-input and sway-output pages 2020-04-27 18:01:13 -04:00
Tudor Brindus 5cf5349cd7 Add debug symbol stack trace note to ISSUE_TEMPLATE.md 2020-04-27 08:58:24 +02:00
Tudor Brindus a5c26e6a05 input/tablet: query tablet focused surface for cursor image check
`handle_tablet_tool_set_cursor` was copied from input/cursor.c's
`handle_request_set_cursor`, but the focused surface check was not
adjusted appropriately.

Fixes #5257.
2020-04-26 09:14:54 +02:00
Tudor Brindus c3c9737e8b config/output: reconfigure input devices after full output init
Previously in 3de1a39, it "worked by accident" in my testing since the
display being used in `map_to_output` was initialized first (the map
would not be applied because the display hadn't actually come online
yet), and was followed by a second display (at which point the map would
get applied for the first display).

Refs #5231
2020-04-26 09:13:39 +02:00
Tudor Brindus d77247117c input/cursor: correctly transfer focus when using tablet pen
Fixes #4819.

This commit ensures that `seat_set_focus` is called to transfer focus
when a window is selected via a pen. Previously, it would race with
`node_at_coords`, and only properly transfer focus if its returned
`surface` was NULL.
2020-04-24 18:54:48 +02:00
Tudor Brindus 3de1a3958e config/output: reconfigure input devices on new output
Some input rules, like `map_to_output`, are dependent on a specific
screen being present. This currently does not work for hotplugged
outputs, or outputs that are processed after the input device is
initially probed.

This commit fixes both cases, by reconfiguring inputs on each output
addition.

Fixes #5231.
2020-04-24 18:51:22 +02:00
Adam Kürthy 65302093cf Take window borders into account when resizing floating windows
Otherwise the borders can be resized to smaller than the minimum window size.
2020-04-24 18:41:33 +02:00
Tudor Brindus 44b2d3ad81 input/cursor: fix hide cursor timeouts on tablets and touchscreens
This commit refactors `cursor_handle_activity` to also take the idle
source, so that it can be reused for tablet and touch activity.
Previously, the timeouts would be tracked, but the cursor would never be
un-hidden for anything but pointers.

Fixes #5169.
2020-04-22 17:30:08 +02:00
Tudor Brindus c23182fd7a input/cursor: fix jerky resizing of non-tablet_v2 surfaces
This fixes resizing containers being very jerky under pointer emulation.

Refs #5232.
2020-04-22 17:24:01 +02:00
Tudor Brindus d88460f716 input/cursor: correctly send tablet_v2 up event when over non-v2 surface
If we started holding the tool tip down on a surface that accepts tablet
v2, we should notify that surface if it gets released over a surface
that doesn't support v2.

Since GTK supports tablet v2, this fixes the common case of starting a
drag over a GTK surface (e.g. scrollbar) and releasing it outside (e.g.
over the gaps between sway containers, or in a terminal).

Refs #5230.
2020-04-22 17:22:40 +02:00
Simon Ser 83d769805c Restrict relative output transforms to runtime changes
Prevent them from being used in the config file.

This is a breaking config file change.

References: https://github.com/swaywm/sway/issues/5236
2020-04-21 14:52:17 +02:00
Ihor Kalnytskyi 58eb0c4082 scdoc: unbindcode --input-device, not input-device
Apparently, there's a typo in Sway's man page where `input-device` of
`unbindcode` command has no dashes.
2020-04-20 12:20:27 +02:00
Ian Huang 276e0301e0 interpret "subpixel none" as CAIRO_ANTIALIAS_GRAY
See issue #5228. Currently, WL_OUTPUT_SUBPIXEL_NONE is ignored and
CAIRO_ANTIALIAS_SUBPIXEL is still set. This commit checks if subpixel is
set to none and if so, calls set_antialias with CAIRO_ANTIALIAS_GRAY.
This mirrors the functionality in Mako's
[PR261](https://github.com/emersion/mako/pull/261)
2020-04-20 09:26:37 +02:00
David96 2b15cf453e Don't transfer focus to NULL node on touch
Fixes #5185
2020-04-17 15:49:17 +02:00
Rouven Czerwinski 0efc28e2f5 input/seatop_default: release on empty workspace
Instead of handling presses and releases on empty workspaces as setting
focus to the workspace, handle releases by notifying the seat of a
pointer action. This way DnDs are correctly released if the button is
released over an empty workspace. This is achieved by removing the early
return and letting the handle_button() call seat_pointer_notify_button()
at the very end.

Fixes #3932
2020-04-15 13:40:38 +02:00
Di Ma c0bce9138b Fix a use-after-free error in switch binding 2020-04-14 19:41:30 -04:00
Di Ma 2bece94b9b Fix a use-after-free error in switch binding 2020-04-14 19:41:30 -04:00
Di Ma c1c2fe04bb Fix a use-after-free error in switch binding 2020-04-14 19:41:30 -04:00
Di Ma a3e574f63f Fix a use-after-free error in switch binding 2020-04-14 19:41:30 -04:00
Simon Ser b300bace0f Implement create_output command for headless backend 2020-04-14 16:06:20 +02:00
Andri Yngvason b18d943442 input: keyboard: Never group virtual keyboards.
This fixes #5134
2020-04-14 12:07:24 +02:00
Andri Yngvason 46599df0a2 input: Mark virtual devices as such
This is for internal configuration purposes
2020-04-14 12:07:24 +02:00
roshal a1275055ea add dots to man 2020-04-14 10:10:35 +02:00
Simon Ser 4d13cee59a Use bitshifts for bitfields
Instead of hardcoded power of 2 values, use bitshifts. This makes the
enums more readable, avoids mistakes, and makes it clear how much of the
int32_t bit space we have left.

While at it, fix other minor style issues.
2020-04-10 18:08:46 -04:00
Aleksei Bavshin 525b48ede7 Adjust focus order to match rendering order of layer shell popups. 2020-04-10 10:45:47 +02:00
David96 8c62278207 Render layer shell popups over the top layer 2020-04-10 10:45:47 +02:00
Rouven Czerwinski ac0637708f output: remove damage listeners in damage destroy
Instead of removing the destroy listeners in the output destroy, remove
them in the damage destroy handler. Fixes the following use after free:

  ==646625==ERROR: AddressSanitizer: heap-use-after-free on address 0x61200017cab8 at pc 0x0000004f8f29 bp 0x7ffdf465ad30 sp 0x7ffdf465ad20
  WRITE of size 8 at 0x61200017cab8 thread T0

      #0 0x4f8f28 in wl_list_remove ../common/list.c:181
      #1 0x43dd24 in handle_destroy ../sway/desktop/output.c:790
  (`wl_list_remove(&output->damage_destroy.link);` here, 214e3030e1dce master branch)
      #2 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #3 0x7f0e57390954 in wlr_output_destroy ../types/wlr_output.c:365
      #4 0x7f0e5735e37f in backend_destroy ../backend/x11/backend.c:128
      #5 0x7f0e57348147 in wlr_backend_destroy ../backend/backend.c:47
      #6 0x7f0e57356f75 in multi_backend_destroy ../backend/multi/backend.c:54
      #7 0x7f0e5735710e in handle_display_destroy ../backend/multi/backend.c:107
      #8 0x7f0e573f23e4 in wl_display_destroy (/lib64/libwayland-server.so.0+0x93e4)
      #9 0x42f0b2 in server_fini ../sway/server.c:177
      #10 0x42dd01 in main ../sway/main.c:414
      #11 0x7f0e570f7041 in __libc_start_main (/lib64/libc.so.6+0x27041)
      #12 0x40e3bd in _start (/opt/wayland/bin/sway+0x40e3bd)

  0x61200017cab8 is located 120 bytes inside of 320-byte region [0x61200017ca40,0x61200017cb80)
  freed by thread T0 here:
      #0 0x7f0e57aa9357 in __interceptor_free (/lib64/libasan.so.6+0xb0357)
      #1 0x7f0e5738b877 in wlr_output_damage_destroy ../types/wlr_output_damage.c:143
      #2 0x7f0e5738b2b9 in output_handle_destroy ../types/wlr_output_damage.c:13
      #3 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #4 0x7f0e57390954 in wlr_output_destroy ../types/wlr_output.c:365
      #5 0x7f0e5735e37f in backend_destroy ../backend/x11/backend.c:128
      #6 0x7f0e57348147 in wlr_backend_destroy ../backend/backend.c:47
      #7 0x7f0e57356f75 in multi_backend_destroy ../backend/multi/backend.c:54
      #8 0x7f0e5735710e in handle_display_destroy ../backend/multi/backend.c:107
      #9 0x7f0e573f23e4 in wl_display_destroy (/lib64/libwayland-server.so.0+0x93e4)

  previously allocated by thread T0 here:
      #0 0x7f0e57aa9887 in __interceptor_calloc (/lib64/libasan.so.6+0xb0887)
      #1 0x7f0e5738b532 in wlr_output_damage_create ../types/wlr_output_damage.c:91
      #2 0x43e4a7 in handle_new_output ../sway/desktop/output.c:875
      #3 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #4 0x7f0e57357261 in new_output_reemit ../backend/multi/backend.c:143
      #5 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #6 0x7f0e5736030a in wlr_x11_output_create ../backend/x11/output.c:253
      #7 0x7f0e5735e309 in backend_start ../backend/x11/backend.c:113
      #8 0x7f0e573480fb in wlr_backend_start ../backend/backend.c:36
      #9 0x7f0e57356e61 in multi_backend_start ../backend/multi/backend.c:31
      #10 0x7f0e573480fb in wlr_backend_start ../backend/backend.c:36
      #11 0x42f4ba in server_start ../sway/server.c:205
      #12 0x42dbd7 in main ../sway/main.c:394
      #13 0x7f0e570f7041 in __libc_start_main (/lib64/libc.so.6+0x27041)

Fixes #5158
2020-04-10 10:20:21 +02:00
Simon Ser 34dccd4224 Don't add disabled outputs back to output layout
Return early from apply_output_config if the output is disabled.
This restores our previous behavior [1].

[1]: 0cdcf66bbc (diff-4f65f4327e987fef8ec3796cdb07644eL349)
2020-04-09 15:45:29 +02:00
Simon Ser 97a6524a5a Fix initial modeset
An if branch takes care of the case where the output needs to be turned
off (DPMS'ed or disabled). The other branch needs to unconditionally
enable the output.

output->current_mode is already taken care of in apply_config.

Sorry about that, probably made a bad change by mistake after my DRM testing.

Closes: https://github.com/swaywm/sway/issues/5193
2020-04-09 15:45:29 +02:00
Simon Ser c9fa751042 ci: remove epoll-shim hardcoded pkg-config file
The upstream package now provides one.
2020-04-08 16:37:00 +02:00
Simon Ser 3df32d0310 ci: don't build scdoc
scodc is now available in all distributions we have CI for.
2020-04-08 16:37:00 +02:00
Simon Ser f03d50f54b Add test-only support to wlr-output-management-unstable-v1
Use the new test_output_config function to implement
wlr-output-management-unstable-v1's test request.
2020-04-08 16:36:40 +02:00
Simon Ser 0cdcf66bbc Introduce test_output_config
This function checks whether the backend would accept an output
configuration, without applying the changes.
2020-04-08 16:36:40 +02:00
Simon Ser 40e87fa98a Stop checking wlr_output_attach_buffer return value
Update for [1]. Everything is now checked at commit-time.

[1]: https://github.com/swaywm/wlroots/pull/2097
2020-04-08 16:36:40 +02:00
Thomas Hebb 3078f23258 config: fix unfocused text color
This color, both in i3 and as described in sway(5), defaults to #888888.
However, the actual default also has an alpha of 88 instead of FF,
meaning it ends up significantly darker than intended.
2020-04-04 23:25:04 +02:00
Dominique Martinet 4e82d0fb15 build: make completions respect install prefixes
Tell pkgconfig about prefix and datadir as required in the .pc files, so
if the prefix isn't standard nothing is installed outside of it.

For fish, this requires https://github.com/fish-shell/fish-shell/pull/6778

Fixes swaywm/swaybg#13
2020-04-04 17:55:09 +02:00
Leo 3c96a1d374 im: Fix crash when im destorying and no focused surface exists 2020-04-04 11:42:04 +02:00
xdavidwu e6805ce6e9 im: remove listener on pending surface destoryed 2020-04-04 11:42:04 +02:00
xdavidwu 4e1e5e4e33 im: make text-input listeners per text-input 2020-04-04 11:42:04 +02:00
xdavidwu 9d455b48e4 input-method: avoid and log unneeded set_focus 2020-04-04 11:42:04 +02:00
xdavidwu 1241b42c88 input-method: remove surface listener before set
This make sure pending focused surface listener is not reachable from
old surface.
2020-04-04 11:42:04 +02:00
xdavidwu 5886187c6e Port input method and text input from rootston
This ports swaywm/wlroots#1203, swaywm/wlroots#1303,
swaywm/wlroots#1308, swaywm/wlroots#1759 rootston part to sway.

Co-Authored-By: Leo Chen <leo881003@gmail.com>
2020-04-04 11:42:04 +02:00
Some Chinese Guy 7c44c76989 swapped hiding the cursor and sending a touch event as a more logical sequence 2020-04-03 16:47:11 +02:00
Dominique Martinet 284dcb2dc7 swaynag: exit on wl_display_roundtrip error
fixes loop when sway closes the socket in the middle of querying outputs,
see #5138.
2020-04-02 23:27:57 +02:00
Tobi Fuhrimann ac3444295d Reference wev instead of xev 2020-04-02 23:25:34 +02:00
Simon Ser 3a5d9b3b32 Update for new wlr_buffer API
Update for [1].

[1]: https://github.com/swaywm/wlroots/pull/2044
2020-04-02 23:23:56 +02:00
Leon Plickat dffc184a68 change apply_exclusive() to closer match layer shell protocol
With these changes, sway will respect positive exclusive zones of layer
surfaces anchored to one or three sides.

This matches the protocol, which states that a positive exclusive zone
should be respected, "if the surface is anchored to one edge or an
edge and both perpendicular edges". If the surfaces is "anchored to
only two perpendicular edges (a corner), anchored to only two
parallel edges or anchored to all edges a positive value will be
treated the same as zero".
2020-03-30 17:45:05 +02:00
Ian Fan 65501f0e46 tray: track SNI callbacks
This removes any pending messages once the item is destroyed.
Furthermore, this installs SNI event calbacks asynchronously
in order to prevent sd-bus from bypassing pending messages.
2020-03-30 17:31:00 +02:00
Ian Fan 68f53cd509 tray: tidy code
This includes some refactoring and fixing a small memory leak.
2020-03-30 17:31:00 +02:00
Ian Fan 3b894c387d tray: allow themes to inherit from multiple themes 2020-03-30 17:31:00 +02:00
Ian Fan 66f0c91bb8 tray: better errors when parsing index.theme 2020-03-30 17:31:00 +02:00
Ian Fan b54f5e170a swaybar: fix memory leaks 2020-03-30 17:31:00 +02:00
Linus Heckemann df48c48123 add --no-repeat option for bindings
This allows e.g. triggering one command while a key is held, then
triggering another to undo the change performed by it afterwards. One
use case for this is triggering push-to-talk functionality for VoIP
tools without granting them full access to all input events.

Fixes #3151
2020-03-30 14:18:27 +02:00
Simon Ser 5e41e6600b Change focus_on_window_activation default to urgent
Before the default was "smart". This means a visible app could steal focus
whenever it wanted to. This can be an issue since having focus allows for
e.g. clipboard access.

This commit changes the default to "urgent" instead.

Closes: https://github.com/swaywm/sway/issues/5139
2020-03-29 20:58:15 +02:00
Some Chinese Guy 63e45bf321 switched to setting focus with seat_set_focus 2020-03-29 20:50:36 +02:00
Some Chinese Guy 798fc24081 Added focus following for touch_down 2020-03-29 20:50:36 +02:00
Dominique Martinet 484f7677b0 swaynag: fix segfault on exit when arguments are not correct
swaynag_destroy is called on all cleanup cases and needs the lists to be valid,
just init them early
2020-03-29 11:17:32 +02:00
rinpatch 214e3030e1 sway.5: fix missing background scaling mode in a block example 2020-03-28 20:33:07 +01:00
Josh Shone 82d02ce782 Fix hit test for floaters that cross outputs
In the case of multiple overlapping floating windows, this commit fixes an issue where the wrong window would be focused in response to a cursor if one of the windows came from a different output (overhanging).
2020-03-27 21:32:26 +01:00
r-c-f 854497b242
check for workspace command name arg
* check for workspace command name arg (fix #5131)

For the 'workspace <name> output <output>' command, output_location must
be greater than zero or the attempt to get the workspace name with
join_args will segfault or abort() (depending on the flavor of
sway_assert() in use). This checks and returns an error instead.

* put workspace output error string on one line

To ease grepping as requested

* check for name in workspace gaps command as well

A malformed command here will lead to the same result seen in #5131, so
add a check. Done inside the cmd_workspace_gaps() function itself, to
take advantage of the existing 'Expected...' string.
2020-03-24 16:07:12 +01:00
Leo 0b9feb6f39 Fix redundant call to seat_send_focus()
This commit fix calling to seat_send_focus() twice when a view is
closed. This codes revert #2580, but the original issue nolonger
exists.
2020-03-23 17:30:02 +01:00
Simon Ser b34c198f0b Fix output mode usage
The "Hz" part is required.
2020-03-21 17:46:06 +01:00
Jason Nader fcd524bb0d sway/input/cursor.c: fix undefined behaviour when event is NULL 2020-03-16 14:27:36 +01:00
Dennis Schridde 6498542b24 Document input selector precedence
Signed-off-by: Dennis Schridde <devurandom@gmx.net>
2020-03-15 18:05:14 -04:00
Jason Nader 3ed780c783 sway/input/cursor.c: move NULL check to where it should be 2020-03-15 14:30:32 +01:00
Jason Nader 8b21bc6a79 commands/bind.c: remove unnecessary check 2020-03-15 14:30:05 +01:00
Jason 55016729a5 Update fish completions
`--config` should autocomplete filepaths
2020-03-13 10:11:25 +01:00
Jason Nader 50dc49f35a Limit workspace numbers within 0..INT32_MAX
See 83c7aff089
2020-03-12 19:43:45 -04:00
Olivier Fourdan 7dd9cd29a6 input: Avoid creating the PAD device multiple times
If a pad device for a tablet exists, reloading the configuration,
removing/reading the device or even suspending the system will recreate
the same Wayland input device multiple times.

Make sure we don't re-create the same Wayland device more than
necessary.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2020-03-12 18:02:09 +01:00
Simon Ser 5efdde8868 readme: git is an optional dependency 2020-03-12 14:51:42 +01:00
Michael Weiser 30e666f171 commands: Adjust style in cursors command
Remove some unnecessary brackets in an error condition check identified
during review of the shortcuts inhibitor command code (#5021).

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser 3ee5aace33 commands: Add shortcuts_inhibitor command
Add a command to influence keyboard shortcuts inhibitors. In its current
form it can be used to activate, deactivate or toggle an existing
inhibitor on the surface currently receiving input. This can be used to
define an escape shortcut such as:

bindsym --inhibited $mod+Escape seat - shortcuts_inhibitor deactivate

It also allows the user to configure a per-seat default of whether
keyboard inhibitors are honoured by default (the default) or not. Using
the activate/toggle command they can then enable the lingering inhibitor
at a later time of their choosing.

As a side effect this allows to specifically address a named seat for
actions as well, whatever use-case that might serve.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser eeac0aa170 input: Add support for keyboard shortcuts inhibit
Adding support for the keyboard shortcuts inhibit protocol allows remote
desktop and virtualisation software to receive all keyboard input in
order to pass it through to their clients so users can fully interact
the their remote/virtual session. The software usually provides its own
key combination to release its "grab" to all keyboard input. The
inhibitor can be deactivated by the user by removing focus from the
surface using another input device such as the pointer.

Use support for the procotol in wlroots to add support to sway. Extend
the input manager with handlers for inhibitor creation and destruction
and appropriate bookkeeping. Attach the inhibitors to the seats they
apply to to avoid having to search the list of all currently existing
inhibitors on every keystroke and passing the inhibitor manager around.
Add a helper function to retrieve the inhibitor applying to the
currently focused surface of a seat, if one exists.

Extend bindsym with a flag for bindings that should be processed even if
an inhibitor is active. Conversely this disables all normal shortcuts if
an inhibitor is found for the currently focused surface in
keyboard::handle_key_event() since they don't have that flag set. Use
above helper function to determine if an inhibitor exists for the
surface that would eventually receive input.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Michael Weiser ef9c597fcb config: Fix typo in reload bindsym flag bitmask
Fix a typo in the bit mask value of the BINDING_RELOAD flag introduced
in commit 152e30c37 so it can work as intended.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-03-11 23:51:37 -04:00
Bor Grošelj Simić 27d5cf1316 input: implement cycling through keyboard layout list 2020-03-11 12:12:23 +01:00
Ian Fan 28e3187df1 ipc: add missing required properties 2020-03-10 15:55:54 +01:00
Tadeo Kondrak 91c0ffd6cf Null check sway_layer_surface when checking damage
Before this change, an overlay layer-shell surface without a buffer
attached would segfault the compositor on screen damage.
2020-03-10 10:59:05 +01:00
Jan Beich fafc060909 common/log: bump POSIX version used after e81d9fde66
../common/log.c:63:16: error: use of undeclared identifier 'CLOCK_MONOTONIC'
        clock_gettime(CLOCK_MONOTONIC, &start_time);
                      ^
../common/log.c:75:16: error: use of undeclared identifier 'CLOCK_MONOTONIC'
        clock_gettime(CLOCK_MONOTONIC, &ts);
                      ^
2020-03-07 12:05:51 +01:00
Simon Ser e81d9fde66 common/log: improve time prefix
Same as [1].

[1]: https://github.com/swaywm/wlroots/pull/2052
2020-03-07 00:35:35 +01:00
Simon Ser a2d49099e1 Add adaptive_sync_status to output IPC reply 2020-03-07 00:32:04 +01:00
Simon Ser 5d692b0581 Add an adaptive_sync output command
This enables/disables adaptive synchronization on the output.

For now, the default is disabled because it might cause flickering on
some hardware if clients don't submit frames at regular enough
intervals. In the future an "auto" option will only enable adaptive sync
if a fullscreen client opts-in via a Wayland protocol.
2020-03-07 00:32:04 +01:00
Simon Ser 9d0aa0cb83 Use wlr_client_buffer
Update for breaking changes in [1].

[1]: https://github.com/swaywm/wlroots/pull/2043
2020-03-06 23:57:43 +01:00
Simon Ser 241684eb1d Drop sway_output.surface_needs_frame
wlr_output_schedule_frame now sets output->needs_frame [1], so this
isn't needed anymore.

[1]: https://github.com/swaywm/wlroots/pull/2053
2020-03-06 21:37:53 +01:00
Simon Ser f5ba8006c9 Only schedule a frame if client has requested a frame callback
When a client hasn't damaged its surface, we only need to schedule an
output frame if the client has requested a frame callback.
2020-03-06 21:37:53 +01:00
Simon Ser c0811fcf87 Make handle_destroy and output_repaint_timer_handler static 2020-03-04 03:09:43 +01:00
Jason Nader 476773dd32 ipc-server: improve error message 2020-02-29 19:59:42 +01:00
Brian Ashworth 7fea36750e sway.5: correct description of workspace [number]
This correct the description of the commmand:
workspace [--no-auto-back-and-forth] [number] <[num:]name>

Previously, the number and num pieces were being confused. This also
documents the behavior of the --no-auto-back-and-forth flag.
2020-02-29 02:03:03 +01:00
Bill Doyle 920d85d35f Only destroy swaybar surface via ipc when needed 2020-02-27 15:34:49 +01:00
Ryan Dwyer 2045ac3472 Introduce pid criteria token
This can be used as a workaround to flag terminal windows as urgent when
commands are completed, until urgency is introduced in the Wayland
protocol.

Configure your shell to run `swaymsg "[pid=$PPID] urgent enable"` when
commands are completed, and use a terminal which uses one process per
window.
2020-02-27 14:03:22 +01:00
Simon Ser 5ed01c861a Add support for wlr-output-power-management-unstable-v1 2020-02-26 16:26:13 +01:00
Brian Ashworth e0f8235fbf Revert "Don't apply exclusive zones of unmapped layer-shell surfaces"
This reverts commit e1eda8a09c.
2020-02-25 08:35:43 +01:00
Simon Ser e1eda8a09c Don't apply exclusive zones of unmapped layer-shell surfaces
Backport of [1].

[1]: https://github.com/emersion/rootston/pull/15/files
2020-02-24 19:38:36 -05:00
Simon Ser f2a60d2d05 Fix get_int_prop(WINDOW_TYPE) crash 2020-02-19 12:07:15 -05:00
Torstein Husebø af294289b1 treewide: fix typos 2020-02-18 21:53:57 +01:00
Brian Ashworth ec7d3f181d input_cmd_events: add support for input types
This adds support for input type configs to input_cmd_events. This works
similar to the wildcard handling that existed where configs for the
devices are stored and the type config is reset to INT_MIN so that it
does not override.

This also condenses the toggle_send_events and
toggle_wildcard_send_events functions into a single function to reduce
code duplication.
2020-02-18 18:08:45 +01:00
Brian Ashworth 0c23525d47 tree/view: do not attempt enter on hidden child
If a subsurface is created for a surface that is associated with a
scratchpad hidden view, do not attempt to send an enter to it. The
subsurface is not on any output and since there is no workspace
associated with the view, attempting to get the output for the NULL
workspace will result in a SIGSEGV.
2020-02-18 10:27:37 +01:00
Jason Nader d2cab83833 i3compat: add `window_type` to IPC response
i3 added these in i3/i3#3797
2020-02-17 21:58:05 +01:00
Jason Nader 8608a1c38b i3compat: add `window_type` to IPC response
i3 added these in i3/i3#3797
2020-02-17 21:58:05 +01:00
Simon Ser f96dbf748a Specify that output transform applies clockwise rotations 2020-02-17 21:47:36 +01:00
Simon Ser ab00f7f319 Fix output transform rotation direction
This patch makes it so users that have configured their screen with a
transform don't have to update their config after the wlroots breaking
change.

References: https://github.com/swaywm/wlroots/pull/2023
2020-02-17 21:47:36 +01:00
Simon Ser a5a4d32816 Fix output transform anticlockwise
This wouldn't have any effect if the transform was flipped.
2020-02-17 21:47:36 +01:00
Brian Ashworth 8b593677d2 output: fix updating output manager config
The output manager config is created when the output is created. It is
updated when the mode, transform, scale, or layout for the output
changes, as well as, when the output is destroyed.

Since the output->enabled property was not being set before calling
apply_output_config, the output event handlers were early returning and
never updating the output manager config when the output state was
committed.

This fixes the issue by setting output->enabled in apply_output_config
below the output disabling section. There are also a few other minor
changes that are required to function.

Additionally, this renames output_enable to output_configure to better
describe the recent changes.
2020-02-16 09:42:22 +01:00
Yorick van Pelt 447967ad3a Fix crash: use wlr_output->name instead of possibly missing oc->name
Fixes segfault on start:
https://gist.github.com/yorickvP/89eccb3782c6edb22aeda6ce9c6d4fcb
2020-02-13 13:05:17 +01:00
Brian Ashworth 7999845357 cmd_swap: fix test_mark condition
The condition in test_mark was checking the negation of list_seq_find.
This works fine for the first mark, but fails for every other mark. This
fixes the condition to check for anything other than -1, which is the
value returned from list_seq_find for index not found.
2020-02-13 10:26:14 +01:00
Simon Ser 47763c99f9 Apply the output scale filter after the output commit
The smart output filter uses the current output scale.
2020-02-11 20:52:02 -05:00
Simon Ser f5fa0c7124 Stop calling apply_output_config from output_enable
The only output_enable caller is now apply_output_config. Stop calling
apply_output_config from output_enable to simplify the code and avoid
the back-and-forth between these two functions.

output_enable is now the symmetric of output_disable: it just marks the
output as enabled and performs bookkeeping (e.g. creating teh default
workspace). It is called from apply_output_config after the output
commit, so that it can read the current output state and act
accordingly.

This change also allows us to avoid an extraneous wlr_output_commit.

References: https://github.com/swaywm/sway/issues/4921
2020-02-11 20:52:02 -05:00
Simon Ser 5e90080468 Call apply_output_config instead of output_enable
apply_output_config will call output_enable if necessary.

This fixes a lone wlr_output_enable call (without a matching
wlr_output_commit call) which was a no-op.
2020-02-11 20:52:02 -05:00
Simon Ser 555b0d4087 Fix output scale auto-detection
Closes: https://github.com/swaywm/sway/issues/4960
2020-02-11 20:52:02 -05:00
Brian Ashworth 33a984bbc5 config: fix validation exit code and log level
This makes it so invalid configs will return the exit code 1 when the
validation flag is given. This also reduces the log level to SWAY_ERROR,
which makes it so only the errors are shown. If someone wants more
verbose output, the can use the -V/--verbose or -d/--debug flags.
Additionally, this also makes it so swaybg will not be spawned when
validating the config.
2020-02-11 16:02:11 +01:00
Teddy Reed 31a83bd48d Fix ordering of setgid and setuid
It looks like the code to drop privileges may have been broken via
commit 37f0e1f. That commit reverted the correct order from #911, which
first drops the gid then the uid. If setuid is called first then the
target user may not have the ability to setgid.
2020-02-11 10:17:45 +01:00
Brian Ashworth 0b709702c1 container_at_{tabbed,stacked}: check x-axis bounds
The container_at_tabbed and container_at_stacked container were checking
the bounds along the y-axis, but not the x-axis. This made it possible
to cause a segfault for specific resolution, horizontal gap, and
workspace children lengths. The issue is that child_index was -1 and was
resulting in a buffer underflow. Adding the x-axis bound checks for
early returns should prevent this from happening.
2020-02-11 10:09:37 +01:00
Andri Yngvason 803e89018a input: Map virtual-pointer to the requested output 2020-02-10 21:54:00 +01:00
Hristo Venev 7affe5c1bd swaybar: fix i3bar relative coordinates when scaling is used
24e8ba048a did not take scaling into account.
The hotspot size used pixel coordinates, the absolute coordinates were logical,
and the relative coordinates were completely wrong.

This commit makes all coordinates use logical values. If
`"float_event_coords":true` is sent in the handshake message, coordinates are
sent as floating-point values.

The "scale" field is an integer containing the scale value.
2020-02-10 18:58:09 +01:00
Hristo Venev fca32b6334 Do not truncate pointer coordinates to int.
This increases the precision of the clicks when using i3bar.
2020-02-10 18:58:09 +01:00
Till Hofmann 0f5157668d Avoid calling strcmp on nullptr
The function group_handler may get a nullptr as `new_group`. If that's
the case, return true, as if `new_group` was the empty string.

Also make the conversion to bool explicit when calling `strcmp`.
2020-02-10 13:29:07 +01:00
Simon Ser 46561fc914 Fix seat_set_focus_layer crash when disabling output
This fixes the following crash:

    #0  0x00007f7daac3af25 in raise () at /usr/lib/libc.so.6
    #1  0x00007f7daac24897 in abort () at /usr/lib/libc.so.6
    #2  0x00007f7daac24767 in _nl_load_domain.cold () at /usr/lib/libc.so.6
    #3  0x00007f7daac33526 in  () at /usr/lib/libc.so.6
    #4  0x0000555bfbc35029 in seat_set_focus_layer (seat=0x555bfd76d860, layer=0x555bfdda2ff0)
        at ../sway/input/seat.c:1164
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
    #5  0x0000555bfbc35029 in seat_set_focus_layer (seat=seat@entry=0x555bfd76d860, layer=0x555bfdda2ff0)
        at ../sway/input/seat.c:1164
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
    #6  0x0000555bfbc25899 in handle_output_destroy (listener=0x555bfdb90688, data=<optimized out>)
        at ../sway/desktop/layer_shell.c:263
            layer = 0x555bfdd6b040
            sway_layer = 0x555bfdb90610
            seat = 0x555bfd76d860
            client = 0x555bfdb76d70
            set_focus = <optimized out>
    #7  0x0000555bfbc5b669 in wl_signal_emit (data=0x555bfd795930, signal=0x555bfd795ae0)
        at /usr/include/wayland-server-core.h:472
            l = <optimized out>
            next = 0x555bfdb6a3e8
            __PRETTY_FUNCTION__ = "output_disable"
            index = <optimized out>
    #8  0x0000555bfbc5b669 in output_disable (output=output@entry=0x555bfd795930)
        at ../sway/tree/output.c:263
            __PRETTY_FUNCTION__ = "output_disable"
            index = <optimized out>
    #9  0x0000555bfbc3b890 in apply_output_config (oc=0x555bfd7d73d0, output=output@entry=0x555bfd795930)
        at ../sway/config/output.c:321
            wlr_output = 0x555bfd7afaf0
            scale = <optimized out>
            output_box = <optimized out>
    #10 0x0000555bfbc28309 in handle_output_manager_apply
        (listener=0x555bfbc7f148 <server+488>, data=0x555bfdca6eb0) at ../sway/desktop/output.c:936
            wlr_output = <optimized out>
            output = 0x555bfd795930
            oc = <optimized out>
            server = 0x555bfbc7ef60 <server>
            config = 0x555bfdca6eb0
            config_head = 0x555bfdb79350
            ok = true
    #11 0x00007f7dab4fbf7c in wlr_signal_emit_safe (signal=<optimized out>, data=0x555bfdca6eb0)
        at ../subprojects/wlroots/util/signal.c:29
            pos = 0x555bfbc7f148 <server+488>
            l = 0x555bfbc7f148 <server+488>
            cursor =
              {link = {prev = 0x555bfbc7f148 <server+488>, next = 0x7fff238a8390}, notify = 0x7f7dab4fbef0 <handle_noop>}
            end =
              {link = {prev = 0x7fff238a8370, next = 0x555bfd7419f8}, notify = 0x7f7dab4fbef0 <handle_noop>}
    #12 0x00007f7daa45469a in ffi_call_unix64 () at /usr/lib/libffi.so.6
    #13 0x00007f7daa453fb6 in ffi_call () at /usr/lib/libffi.so.6
    #14 0x00007f7daae6f82f in  () at /usr/lib/libwayland-server.so.0
    #15 0x00007f7daae6c193 in  () at /usr/lib/libwayland-server.so.0
    #16 0x00007f7daae6d7f2 in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
    #17 0x00007f7daae6c39c in wl_display_run () at /usr/lib/libwayland-server.so.0

This crash happens because focus can only be set on mapped surfaces.
2020-02-06 17:19:58 +01:00
Anders 4e46bdf73d criteria: match containers without view
Closes #4929

Replaces criteria_get_views with criteria_get_containers which can
return containers without views when the criteria only contains
container properties.
2020-02-04 19:52:21 -05:00
Cyril Levis 3f0225eea3 Change wording 2020-02-04 23:52:08 +01:00
Cyril Levis 0f97580552 Add the possibility to capture only one screen if several screens are use. 2020-02-04 23:52:08 +01:00
Lucas M. Dutra 84ea03109d fix typo 2020-02-04 19:02:27 +01:00
Nathan Rossi ffbf10d07b ipc: Handle unsupported binding event types
Handle binding event types that cannot be encoded gracefully by dropping
the event. This prevents issues for binding types like BINDING_SWITCH,
where the event would cause a crash.
2020-01-30 15:03:54 +01:00
salkin-mada 1dbc7f7521 add danish README 2020-01-27 11:31:41 -07:00
Jason Nader 5568f14e71 Docs: Add marks field to get_tree response 2020-01-24 10:37:21 +01:00
thermitegod 29a5ce5f65 Fix compiling with -fno-common 2020-01-24 10:16:59 +01:00
Jamelly Ferreira 9c93e1c0ce Adding the link to the Portuguese on the English version of README.md 2020-01-23 12:26:55 -07:00
Jamelly Ferreira 47a09f74ca Adding a version of README.md in Portuguese 2020-01-23 12:26:55 -07:00
Drew DeVault ab77efc6ca
Update version to 1.4 2020-01-22 20:40:37 +01:00
Eli Schwartz 4a73f69d10 fish-completion: use the correct fallback directory
fish completions should never be installed to share/fish/completions/ as
that directory is reserved exclusively for completions shipped as part
of the fish source code.

Use the same vendor_completions.d/ directory which the default fish
configuration uses.
2020-01-22 18:05:29 +01:00
Eli Schwartz 03e8ce7b20 completion: use pkg-config to get install location for bash/fish
Both shells provide pkg-config files which declare their designated
completionsdir. Use this as the primary source of truth.
2020-01-22 18:05:29 +01:00
Eli Schwartz fe558cf627 meson: use join_paths to build paths, instead of string concat
It makes sure to handle paths as paths, and is generally safer and the
blessed solution.
2020-01-22 18:05:29 +01:00
Alex Maese 8faaf52f7f Add documentation for floating_modifier 2020-01-20 09:19:04 -07:00
Alex Maese 86ee240a4a Add ability to remove the floating modifier 2020-01-20 09:19:04 -07:00
Jason Nader a576bc27bf Check argc>0 before strcasecmp. Should shortcircuit 2020-01-18 10:36:03 +01:00
Jason Nader 450b40c635 commands/move: Fix crash when required args not provided
Fixes #4919.
2020-01-18 10:36:03 +01:00
Brian Ashworth 9d827ef493 output: apply oc to outputs using wl_for_each_safe
If applying an output config to an output fails, the output may be
destroyed. To be able to handle this situation correctly,
apply_output_config_to_outputs needs to use wl_list_for_each_safe.
2020-01-16 19:55:24 -07:00
Ronan Pigott 5501d14a2e cmd_split: Refuse to split scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott 72ad35ba16 cmd_move: Fix crash when moving to scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Ronan Pigott d88d4bbd9d Fix crash when showing scratchpad hidden split containers 2020-01-16 21:48:25 -05:00
Brian Ashworth 18507e62fd desktop/output: fix mem leak in handle_new_output
This fixes a memory leak of oc (the output config) in handle_new_output.
Output configs returned from find_output_config are not stored and need
to be freed after use.
2020-01-16 18:14:49 -07:00
Ronan Pigott 1bd51d9377 sway.5: Document missing bindsym flags for unbindsym
sway.5: Remove indents within long command descriptions
2020-01-16 16:15:50 +01:00
Ronan Pigott 5215cdfa92 sway-input.5: Document repeat_delay and repeat_rate only once 2020-01-16 16:15:50 +01:00
Ronan Pigott 33fc9c5f1f ipc-json: Remove unnecessary dereference 2020-01-16 16:15:50 +01:00
Ronan Pigott f68961fbe6 commands/split: Fix error message typos 2020-01-16 16:15:50 +01:00
Simon Ser 0d2a3fa835 Revert "Make all the container dimensions integers"
This reverts commit 79c5f5ba12.

Fixes: https://github.com/swaywm/sway/issues/4908
2020-01-15 17:56:14 +01:00
Brian Ashworth a4e4e21edf container: add inactive fullscreen to focus stack
When a container was being made fullscreen and it is on the focused
workspace for a seat, focus was being set to the container. However,
when the container was on a non-focused workspace, the focus stack
wasn't being touched. When assigning a fullscreen container to a
workspace or moving a fullscreen container to a different workspace,
this would make it so the fullscreen container was never added to the
focus stack for the workspace thus preventing access to the workspace.
This adds the container to the top of the focus stack, behind the
container on the focused workspace.
2020-01-14 07:38:57 -07:00
Jason c3353bb273 Docs: explain why menu command should be passed to sway
It was not obvious to me why until I saw a comment from @RyanDwyer on Reddit, so I think it's better to add an explanation.
2020-01-13 21:36:08 -05:00
Simon Ser 679aa6032d Fix unreliable scaling filter
Two changes were made:

- Bind the texture before glTexParameteri
- Set the scaling filter before each wlr_render_texture_with_matrix call

Logging in wlroots allows to check that the scaling filter is properly
set prior to rendering.

Fixes: 6968fb3123 ("add scale_filter output config option")
Closes: https://github.com/swaywm/sway/issues/4798
2020-01-13 12:36:14 -07:00
Jason Nader c976a14933 Amend typo 2020-01-13 13:20:16 +01:00
Cassandra McCarthy 8b251f068f integer scaling, not integral 2020-01-10 07:03:24 -07:00
JR Boyens 0106dd135c Use transparency arg in the window focus event 2020-01-09 19:53:53 -07:00
Brian Ashworth c99d423ad9 view: remove workspace pid mapping for assigns
If a view is mapped to a workspace using an assign, the pid should still
be removed from the pid mapping list. This prevents child processes from
matching against it and mapping a view to a likely undesired workspace.
2020-01-09 09:52:37 +01:00
Brian Ashworth 1e2a2b0778 input/cursor: handle setting a NULL image surface
This fixes a crash when attempting to listen to a signal on a NULL
cursor image surface. If the surface is NULL, the listener is just
reinitialized using wl_list_init.
2020-01-06 10:12:28 +01:00
Brian Ashworth 897c36b12c input/cursor: handle image surface destroy
This adds a listener for the destroy event of the cursor image surface.
This prevents a use-after-free when the last visible image surface is
freed, there has not been a new cursor set, and the cursor is reshown.
2020-01-05 23:03:34 +01:00
Brian Ashworth b977c02e35 render: do not render indicator on floating views
This adds a check to make it so the indicator is only rendered on views
with a parent, which floating views do not. Since floating views do not
have a parent, the workspace layout was being incorrectly used to
determine whether to show the split indicator previously. This has no
impact on floating containers and a view within a floating container
will still have indicators rendered appropriately.
2020-01-05 22:16:44 +01:00
Andri Yngvason fd24b1afd8 swaybar: Fix input device removal
Before swaybar would exit with a protocol error when a pointer or touch
device was removed.
2020-01-05 19:57:05 +01:00
Andri Yngvason 4c29a53386 swaynag: Add multi-seat support
This also adds cleanup for all seat resources
2020-01-05 19:57:05 +01:00
Ross Schulman b758b43085 Fix small typo in sway-input(5) 2020-01-05 11:16:15 -05:00
Thayne McCombs 218950c88d Add missing items to documentation for GET_TREE response in ipc.
A few items in the response for the get_tree ipc call were missing from
the documentation. This adds some documentation for them.
2020-01-05 10:53:16 +01:00
Rouven Czerwinski 1e44247baa xwayland: handle size_hints == NULL
In case xcb-iccm is not installed on the system, size_hints will be
null. Handle this as if the get_constraints functions was not
implemented and return the defaults.

Fixes #4870
2020-01-03 14:02:19 +01:00
Andri Yngvason d510684c47 input: Assign virtual input devices to their selected seats 2020-01-01 10:21:04 -07:00
Pedro Côrte-Real 79c5f5ba12 Make all the container dimensions integers
Containers are always fixed to the pixel grid so position and size them
with integers instead of doubles.

Functionally this should be no different since rounding down is already
being done on things like layout. But it makes it clear what the
intention is and avoids bugs where fractional pixels are used. The
translating and moving code is still using doubles because the cursors
can have fractional pixels and thus the code is plumbed that way. But
that could also probably be changed easily by doing the integer
conversions earlier and plumbing with int.
2020-01-01 10:14:40 -07:00
Pedro Côrte-Real bd1fb76e0f Make sure we don't calculate fractional pixel gaps
When gaps are resized for lack of space the calculation could result in
a gap size of non-integer pixels. This would result in containers
located at non-integer pixels which would be subtly broken.
2020-01-01 10:14:29 -07:00
Pedro Côrte-Real 8008344762 Avoid numerical instability in resize
Because the layout code rounds down the dimensions of the windows
resizing would often be off by one pixel. The width/height fraction
would not exactly reflect the final computed width and so the resize
code would end up calculating things wrong.

To fix this first snap the container size fractions to the pixel grid
and only then do the resize. Also use round() instead of floor() during
layout to avoid a slightly too small width. This applies in two cases:

1. For the container we are actually resizing using floor() might result
   in being 1px too small.
2. For the other containers it might result in resizing them down by 1px
   and then if the container being resized is the last all those extra
   pixels would make the resize too large.

Fixes #4391
2020-01-01 10:14:29 -07:00
Drew DeVault ed02261551 Update wlroots version 2019-12-31 11:18:58 -05:00
Drew DeVault 2a00bb0650 _incr_version: always overwrite old version number 2019-12-31 10:31:40 -05:00
Drew DeVault a44ae8869b _incr_version: prompt for target wlroots release 2019-12-31 10:27:13 -05:00
Josef Gajdusek f501a60c14 Add virtual pointer protocol 2019-12-31 16:04:50 +01:00
Paul Riou 2b5e75032b Fix sway_log using non initialised output_config pointer
This fixes a crash where the `oc->name` would be accessed by sway_log()
even when `oc` was NULL.
2019-12-31 15:56:32 +01:00
Simon Ser ef2332f7a6 Re-add support for wlr_output's atomic API
This reverts commit 724926ea6a and
re-applies commit 6e0565e9de.

Outputs now need to be explicitly enabled when performing a modeset.
We need to roll back wlr_output_attach_render when we decide not to
render.

See also: https://github.com/swaywm/wlroots/pull/1797 (wlroots PR)
See also: https://github.com/swaywm/sway/pull/4355 (Original sway PR)
See also: https://github.com/swaywm/sway/pull/4434 (Revert sway PR)
2019-12-30 11:24:11 -07:00
NightFeather 658b779662 Add Chinese (zh-TW) translation of README
Co-authored-by: xdavidwu <xdavidwuph@gmail.com>
2019-12-30 09:45:06 +01:00
Brian Ashworth de43f7c1db cmd_client_*: support optional args for i3 compat
For i3 compatibility, allow the indicator and child_border colors values
to be optional. The indicator will fallback to sane defaults and
child_border will fallback to the background color for the class.
2019-12-29 10:40:06 +01:00
Whemoon Jang ed9b4e6aeb Fix typo in swaybar-protocol.7.scd 2019-12-28 13:36:00 -05:00
Brian Ashworth f898ca9a83 bar_cmd_colors: remove add_color
This is the third commit in a series of commits to refactor color
handling in sway. This removes add_color from commands.c. It was only
being used by bar_cmd_colors. This also changes the functions to use
parse_color which is used to validate rgb(a) colors throughout the code
base and is also what i3bar is using to parse the colors after they are
passed over ipc. After parsing the color and ensuring it is valid, the
rgba hex string is then generated using snprintf. This refactor also
ensures that all the colors for the command are valid before applying
any of them.
2019-12-28 10:07:25 +01:00
Brian Ashworth 66dc33296c cmd_client_*: refactor duplicated code
This is the second in a series of commits to refactor the color handling
in sway. This removes the duplicated color parsing code in
sway/commands/client.c. Additionally, this combines the parsing of
colors to float arrays with that in sway/config.c and introduces a
color_to_rgba function in commom/util.c.

As an added bonus, this also makes it so non of the colors in a border
color class will be changed unless all of the colors specified are
valid. This ensures that an invalid command does not get partially
applied.
2019-12-28 10:07:25 +01:00
Brian Ashworth 97f9f0b699 parse_color: return success + drop fallback color
This is the first in a series of commits to refactor the color handling
in sway. This changes parse_color to return whether it was success and
no longer uses 0xFFFFFFFF as the fallback color. This also verifies that
the string actually contains a valid hexadecimal number along with
the length checks.

In the process of altering the calls to parse_color, I also took the
opportunity to heavily refactor swaybar's ipc_parse_colors function.
This allowed for several lines of duplicated code to be removed.
2019-12-28 10:07:25 +01:00
Brian Ashworth 088b374b1a layer-shell: refocus if keyboard interactive lost
When arranging layer-shell layers, verify that the currently focused
layer, if any, for each seat is still keyboard interactive. If the layer
is no longer keyboard interactive and there is not a keyboard
interactive overlay or top layer to change the focus to, refocus the
focus inactive node for the seat.
2019-12-27 11:38:56 +01:00
Ronan Pigott bd42415b5d config/output: apply scale_filter even when scale has not changed 2019-12-27 11:38:05 +01:00
Manuel Stoeckl 1d483c340d desktop/surface: Fix crash when timer is NULL
When many surfaces are created, sway can run out of file descriptors,
making wl_event_loop_add_timer (which creates a timerfd) fail and
return NULL. This patch posts a "no memory" error when that is the case,
and only removes the timer if it was created.

(Why "no memory"? It is not easy to distinguish between failures due to
running out of memory and failures due to running out of file
descriptors. Also, using the newer `wl_client_post_implementation_error`
function would lead to an increased version requirement for the
libwayland-server dependency.)
2019-12-24 13:03:50 +01:00
Drew DeVault aa8fe58421 License wallpapers as CC-0 2019-12-16 14:35:58 -05:00
Brian Ashworth 452a615bb8 seat_cmd_keyboard_grouping: change keymap to smart
This removes `seat <seat> keyboard_grouping keymap` and replaces it with
`seat <seat> keyboard_grouping smart`. The smart keyboard grouping will
group based on both the keymap and repeat info. The reasoning for this
is that deciding what the repeat info should be for a group is either
arbitrary or non-deterministic when multiple keyboards in the group have
repeat info configured (unless somehow exposed to the user in a
reproducible uniquely identifiable fashion).
2019-12-16 12:03:11 -05:00
Brian Ashworth 2b51c5b294 input/seatop_default: fix focusing floating titles
When clicking on the titlebar of a floating container (or descendant of
a floating container), the top-level floating container was being
focused and then allowing you to move the top-level floating container.
This made it so you couldn't switch to a different tab/stack within the
floating container. With this patch, the focus inactive view for the
container that the titlebar is associated with is focused, then the
traversal to the top-level floating container is performed to use with
the move floating operation.
2019-12-16 12:02:05 -05:00
Brian Ashworth 0278c4db6f root_scratchpad_hide: disable fullscreen descendants
Any descendant of a scratchpad container may be fullscreen so checking
to see if the top-level scratchpad container is fullscreen in
root_scratchpad_hide is not sufficient. This iterates through all
descendants of the scratchpad container
2019-12-16 12:01:42 -05:00
Brian Ashworth 218b5b9dc0 config/input: set type for new identifier configs
When an input becomes available, the input type config for that device
type will be merged underneath the input identifier config, provided
they both exist. If an input type config gets added or modified at a
later point, then those changes get merged onto the input identifier
configs for that type. However there was a missing case of the input
identifier config being added after the device is already available and
the input type config existing. This makes it so that the first time an
input identifier config gets stored, there will be a check to see if it
matched any of the available devices. If it does, then there will be a
search for the associated input type config, which will be merged
underneath the input identifier config if found.
2019-12-14 09:31:42 -05:00
Brian Ashworth f9ce8749dc input/keyboard: defer wlr_keyboard_group destroy
This defers the destruction of wlr_keyboard_groups until idle. This is
to prevent the keyboard group's keyboard from being destroyed in the
middle of handling a keyboard event. This would occur when changing the
keymap of the last keyboard in a group with a keyboard binding. The
prevents crashing when attempting to update the xkb state of the
keyboard group's keyboard. The sway_keyboard_group is still immediately
destroyed so that the group is no longer used
2019-12-13 09:53:51 +01:00
Brian Ashworth f365ffef34 input/keyboard: remove group listeners on destroy
This adds two missing calls to wl_list_remove to remove the key and
modifier listeners for the keyboard group's keyboard when destroying
the keyboard group. This fixes some crashes when changing the keymap of
the last keyboard in a group with a keyboard binding.
2019-12-13 09:53:51 +01:00
Simon Ser 2f84d6e349 Auto-detect output scale
If the screen DPI is high enough, auto-enable scale=2 (if the user
hasn't set the scale).

Uses heuristics based on [1].

[1]: 0521706617/src/backends/meta-monitor.c (L1590)

Closes: https://github.com/swaywm/sway/issues/1800
2019-12-12 19:00:24 -05:00
Drew DeVault 2f3c6cccf5 Add seat <seat> idle_{inhibit,wake} <sources...>
This adds seat configuration options which can be used to configure what
events affect the idle behavior of sway.

An example use-case is mobile devices: you would remove touch from the
list of idle_wake events. This allows the phone to stay on while you're
actively using it, but doesn't wake from idle on touch events while it's
sleeping in your pocket.
2019-12-12 10:37:30 -05:00
Ronan Pigott f645f8efd6 Fix lingering workspace with scratchpad show
Showing a window in the scratchpad can move a visible scratchpad window
from another workspace to the current one. If the scratchpad window was
the last visible container in that workspace, the old workspace should
be destroyed.
2019-12-12 06:51:13 -05:00
Brian Ashworth b7f0656fab layer-shell: unfocus output-less layer on unmap
If a layer is focused by any seat, it needs to be unfocused on unmap. If
the unmap was due to an output being disabled, there would not be a
sway_output and unmap would do an early return. This results in a
use-after-free if the layer was focused by any seat prior to being
unmapped. This change just moves the refocusing code above the early
returns.
2019-12-10 21:09:48 -05:00
Benjamin Cheng 2d0f15debb input/cursor: remove gesture listeners in destroy
Part of #4794. Forgot to remove gesture listeners when the
cursor is destroyed.
2019-12-07 12:55:37 -05:00
Benjamin Cheng 9ef026e804 input/cursor: pass gesture events to clients
Some wayland clients (mostly GTK3 apps) like eog or evince support
gestures like pinch-to-zoom. These gestures are given to clients
via the pointer_gestures_v1 protocol. This is already supported in
wlroots, so we just need to hook up the events here in sway.

Fixes #4724
2019-12-07 12:26:21 -05:00
Thorben Günther 1cad862458 A Script to change sway workspace name.
This script automatically changes the workspace name when an application
gets closed, moved or openend.
2019-12-06 15:52:33 -05:00
Thorben Günther 6235423544 Improve transparency script
Transparency gets reset when the script is terminated.
Added command line option to set transparency strength without changing
the script.
Added support for multiple displays.
2019-12-06 15:52:33 -05:00
Brian Ashworth fe7ec8024c config: apply input type configs on reload
When making the reload validation improvements, I forgot that input type
configs are stored in a separate list. This makes it so input type
configs are correctly applied on reload.
2019-12-04 02:11:22 +01:00
Jayce Fayne ad189d27f9 Revert "fix bar_state_update/input event"
This reverts commit a3da7fec32.
2019-12-02 19:57:06 +01:00
Rex Hackbro a3da7fec32 fix bar_state_update/input event 2019-12-01 16:40:26 -05:00
Kenny Levinsen 275af2ad62 output: Restore previous max_render_time behavior 2019-12-01 12:44:07 +01:00
Kenny Levinsen d1eab10266 output: Schedule idle frames if we do not render
Repaint scheduling delays output render and frame done events from
output frame events, and block idle frame events from being scheduled in
between output frame done and output render in this period of time.

If a surface is committed after its frame done event, but before output
render, idle frame requests will be blocked, and the surface relies on
the upcoming render to schedule a frame.

If when the repaint timer expires, output render is deemed unnecessary,
no frame will be scheduled. This can lead to surfaces never having their
frame callbacks fire.

To fix this, we store that a surface has requested a frame in
surface_needs_frame. When the repaint expires, if no render is deemed
necessary, we check this flag and schedule an idle frame.

Fixes #4768
2019-12-01 12:44:07 +01:00
Kenny Levinsen 57f615e122 output: Replace block_idle_frame with frame_pending 2019-12-01 12:44:07 +01:00
Ronan Pigott 6968fb3123 add scale_filter output config option 2019-11-29 18:13:37 +01:00
Kenny Levinsen 4b57953628 output: Ensure that frame_done is delayed on max_render_time
max_render_time can be set on output, view, or both. However, if only
applied to the output, send_frame_done_iterator would erroneously send
frame_done immediately, ignoring the output max_render_time. As
damage_handle_frame processed max_render_time correctly, idle frames
would be blocked in anticipation of the delay that was meant to happen.

Without the delay, frame events would be dispatched during the idle
frame block, and some clients would never receive the frame done events
they had requested, at least not until something else actively drove
another render.

Respecting both view and output max_render_time in
send_frame_done_iterator ensures that the frame events are always
correctly delayed.

Fixes #4756
2019-11-28 23:40:36 +01:00
Rex Hackbro 9979382d56 Rename 'node' to 'nodes' in swayipc doc 2019-11-28 23:29:17 +01:00
Brian Ashworth 0cdad33f1a input/keyboard: reset seat keyboard on destroy
If a sway keyboard is being destroyed, then the keyboard is being
removed from a seat. If the associated wlr_keyboard is the currently
set keyboard for the wlr_seat, then we need to reset the wlr_seat's
keyboard to NULL so it doesn't reference an invalid device for the seat.
The next configured keyboard from the seat or the next keyboard from
that seat that has an event will then become the seat keyboard.
Similarly, this needs to be done for a wlr_keyboard_group's keyboard
when the wlr_keyboard_group is being destroyed.
2019-11-28 10:34:49 +01:00
Brian Ashworth 1a5797803a config: improvements to the reload validation
For the validation pass of reloading, there is no need to touch swaybg,
swaynag, inputs, outputs, or seats. This drastically improves the speed
of a reload by skipping over the expensive I/O configuration and
handling of wayland clients. As long as the syntax is valid, the
CMD_FAILURE's can be relayed during the actual reload.
2019-11-27 02:04:13 +01:00
Brian Ashworth 90e3d25009 input/keyboard: check keyboard group before remove
In sway_keyboard_destroy, only remove the keyboard from a keyboard
group, if it is part of a keyboard group. If the keyboard is not part of
a keyboard group, then there is nothing to remove it from
2019-11-26 11:31:55 +01:00
Paul Riou 3334d11adc input: seat: Fix seat device list not initialised before use
When being created, non first seats would get through the list of devices
without the list being first initialised -> segfault.
Issue introduced with ab0248a545

Fixes #4750: Crash when reloading Sway with multiple seats configured
2019-11-24 21:51:06 +01:00
Jason 939c7b2d52 Amend typos 2019-11-23 11:48:31 +01:00
Simon Ser 1d3cbe9f27 Use new presentation-time helper
This has the advantage to (1) reduce boilerplate and (2) make us
correctly handle wlr_output_event_present.commit_seq.
2019-11-21 11:19:00 -05:00
Brian Ashworth 5d882cb5fc Add support for wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. This is useful for keyboards that
are split into multiple input devices despite appearing as one physical
keyboard in the user's mind.

This adds support for wlr_keyboard_groups to sway. There are two
keyboard groupings currently supported, which can be set on a per-seat
basis. The first keyboard grouping is none, which disables all grouping
and provides no functional change. The second is keymap, which groups
the keyboard devices in the seat by their keymap. With this grouping,
the effective layout and repeat info is also synced across keyboard
devices in the seat. Device specific bindings will still be executed as
normal, but everything else related to key and modifier events will be
handled by the keyboard group's keyboard.
2019-11-21 10:42:10 -05:00
Brian Ashworth 2f858a1ada input_cmd_xkb_file: allow shell path expansion
This allows for shell path expansion for input_cmd_xkb_file. The logic
has been extracted from output_cmd_background
2019-11-21 10:36:15 -05:00
Brian Ashworth 66725f2e27 input/keyboard: cleanup xkb_file error handing
This fixes an inverted fclose return value check and simplifies the
error handling and logging for xkb_file in sway_keyboard_compile_keymap
2019-11-21 09:49:25 -05:00
Ivan Molodetskikh ba8586e282 Add note about backends to output max_render_time 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 76210c141d output: check wlr_output in repaint handler
It's possible for the output to be disconnected in just the right moment
for wlr_output to be NULL in the repaint handler, causing a crash. This
check fixes that crash.
2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 7f8a47855c Add max_render_time to view JSON 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh fe84ec2f24 Add max_render_time to output JSON 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh bd9a53f1a3 view: add max_render_time 2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 5421198489 Add sway_surface
For extending wlr_surface with additional things.
2019-11-17 20:18:42 +01:00
Ivan Molodetskikh 022df2542b output: add max_render_time 2019-11-17 20:18:42 +01:00
Simon Ser cb905effde Add -Wno-missing-braces
-Wmissing-braces makes it annoying to zero-initialize structs with = {0}
when the first field is a struct. See for instance [1].

[1]: https://builds.sr.ht/~sircmpwn/job/110425
2019-11-17 17:21:13 +01:00
Manuel Mendez 8ffa3cf439 grimshot: fix branching on command exit status
The previous behavior was incorrect because `if` was checking the return
status of the `[` command which was never going to be an error. `[`
seems to only return an error if no args are provided. This was
basically a useless use of `[` anyway since it was just meant as a
straight interpretation of command exit, something that `if` can do
itself.

Compare:

```sh
[ ]; echo ?=$?
[ /bin/false ]; echo ?=$?
if [ /bin/false ]; then echo this is the unintended bug; fi
if /bin/false; then echo this will not be printed; fi
```
2019-11-17 17:18:54 +01:00
Tadeo Kondrak 7f54495b5e Use an enum instead of a marker string for map_to_ 2019-11-17 13:34:24 +01:00
Tadeo Kondrak 4829f1c26a Implement input map_to_region command 2019-11-17 13:34:24 +01:00
Rouven Czerwinski df1a046875 xwayland: get_constraints using size hints
Previously, Xwayland windows did not have size_constraints implemented,
resulting in the window being resizable. This implements the constraints
through the X11 size hints supplied by the window itself.
2019-11-16 10:18:26 +01:00
Ronan Pigott 37afbc4dbc seatop_default: handle focus for unmanaged xwayland windows last
Fixes #4707
2019-11-08 19:06:00 -05:00
Simon Ser f576bcdb8c Use wlr_output_preferred_mode instead of the last mode
Instead of relying on the order of modes, use wlr_output_preferred_mode
to get the preferred mode.
2019-11-05 14:00:23 -05:00
Simon Ser 01b5350bdc Fix segfault in set_mode
best is NULL prior to being assigned to a mode.

Closes: https://github.com/swaywm/sway/issues/4705
Fixes: f33dcd4c60 ("Prefer higher refresh rate default modes")
2019-11-05 13:35:56 -05:00
Ronan Pigott f33dcd4c60 Prefer higher refresh rate default modes 2019-11-05 10:34:44 +01:00
Ronan Pigott 3975ca28c2 smart_borders: separate smartness from edge types 2019-11-04 21:16:27 -05:00
Simon Ser 38b37247ff Add --custom to `output mode` command
This forces to set the mode as a custom mode.
2019-11-04 19:40:47 -05:00
Ronan Pigott eaee087c17 seatop_default: handle focus for xwayland_unmanaged views 2019-11-04 23:56:27 +01:00
Ronan Pigott d159b98744 seatop_move_floating: make container respect pointer constraint 2019-11-04 23:53:30 +01:00
Ronan Pigott 1f469e1692 focus: do nothing on focus prev|next for workspaces 2019-11-04 23:48:39 +01:00
Sheena Artrip 7efb5d4673 Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.
set_cloexec is defined by both sway and wlroots (and who-knows-else),
so rename the sway one for supporting static linkage. We also remove
the duplicate version of this in client/.

Fixes: https://github.com/swaywm/sway/issues/4677
2019-11-01 12:41:08 -04:00
lbonn cf95de9cae focus: add a NULL check in `focus <direction>`
container is checked for NULL in other conditions earlier, it's not
obvious that it can't be undefined here.
2019-11-01 12:18:09 -04:00
lbonn 30fa7d191e Fix potential NULL reference on cleanup
If allocation of bindings failed.

Found with clang-tidy
2019-11-01 12:18:09 -04:00
lbonn a6307aed00 Fix various memory leaks
Found with clang-tidy
2019-11-01 12:18:09 -04:00
lbonn 32caabc7a1 seat: simplify a strdup 2019-11-01 12:18:09 -04:00
Robert Günzler 354e705a7b Skip line continuation when it is a comment
Currently commented lines ending in the backslash character will be
concatenated with the following line.

```
 # with this comment \
exec swaynag -m 'will not run'
```

This change modifies `getline_with_cont` to stop reading when the
initial character is a '#'.
2019-10-31 23:05:06 +01:00
Simon Ser 1a253ca7ab Fix presentation feedback when scanning out fullscreen view
Closes: https://github.com/swaywm/sway/issues/4663
2019-10-27 11:07:48 -04:00
Simon Ser ad07886543 Handle layer changes for layer shell surfaces
Closes: https://github.com/swaywm/sway/issues/4644
References: 1982106c9b
2019-10-27 11:07:18 -04:00
Ronan Pigott 7c9b71f5c6 criteria: make literal comparison for __focused__ values 2019-10-27 11:06:05 -04:00
Ronan Pigott f5f12a69f6 focus: support focus prev|next [sibling] 2019-10-27 11:02:57 -04:00
Simon Ser ec14a00e8c Fix segfault in wlr_output_manager_v1_set_configuration
Calling wlr_output_manager_v1_set_configuration with an enabled output
and a NULL mode is incorrect if the output doesn't support modes.

When DPMS'ing an output, wlr_output_enable(output, false) is called.
This de-allocates the CRTC and sets wlr_output.current_mode to NULL.

Because we mark DPMS'ed outputs as enabled, we also need to provide a
correct output mode. Add a field to sway_output to hold the current
mode.

Closes: https://github.com/swaywm/wlroots/issues/1867
2019-10-27 10:51:02 -04:00
Simon Ser 58a40ce07b Fix apply_output_config return value when enabling output
apply_output_config would call output_enable and always return true,
even if the output couldn't be enabled.
2019-10-27 10:51:02 -04:00
Kirill Chibisov 43bd8dc437 Fix tiled containers resize with mouse
Fixes regression introduced in 2c1a11016c
2019-10-23 17:21:09 +02:00
Konstantin Pospelov 06fcebc542 swaybar: fix typo in the loop over pixmaps
Fixes #4665.
2019-10-23 09:53:16 +02:00
Konstantin Pospelov fa0abaf7cf swaybar: do not retry search for tray icons
In case a tray icon cannot be found or does not have a desirable size,
swaybar retries the search again and again, which increases load on disk
and CPU. This commit solves it by storing target_size for each icon, so
that swaybar does not search for an icon of some size if it already tried to.

Fixes #3789.
2019-10-21 17:22:25 +02:00
Danilo Spinella a5b6f40937 Fix refresh rate scale of output
When applying config, value mode->refresh is mHz; convert it to Hz before
assigning it to the temporary output config. oc->refresh_rate will
be converted back to mHz in set_mode function.

Fix debug log printing GHz instead of Hz.
2019-10-21 14:22:20 +02:00
lbonn 3ee3a9ef60 focus: support focus_wrapping workspace
Following i3 support: https://github.com/i3/i3/pull/3407
2019-10-17 13:48:52 +03:00
A. M. Joseph 74c0e7921a xwayland.c handle_map(): NULL out xsurface->data() to prevent crashing.
When changing a surface from managed to unmanaged in handle_map(), the
call to handle_destroy(.., view) causes the sway_xwayland_view pointed
to by the untyped wlr_xwayland_surface.data field to become invalid
garbage, yet the untyped wlr_xwayland_surface.data continues to point
at it.  In particular: view_get_*(view_from_wlr_surface(..)), even
with appropriate NULL checking, will crash sway when this codepath is
exercised (reliable test case: drop-down menus in Google Earth).
2019-10-17 11:40:16 +03:00
Drew DeVault d19f4f7bf8 Updates per wlroots layer shell changes 2019-10-16 10:24:15 -04:00
Lauri 992726a823 Grimshot: a helper for screenshots within sway
Usage:
   grimshot copy|save win|screen|area [FILE]
Troubleshoot:
   grimshot check

Requirements:
  - `grim`: screenshot utility for wayland
  - `slurp`: to select an area
  - `swaymsg`: to read properties of current window
  - `wl-copy`: clipboard utility
  - `jq`: json uliity to parse swaymsg output
  - `notify-send`: to show notifications
  Those are needed to be installed, if unsure, run `grimshot check`

Examples:

 `grimshot copy win` - to copy current window
 `grimshot save area` - to select area and save it to default file (Pictures/Grimshot-$datetime.png)
`grimshot save screen ~/screenshot.png` - to save screenshot under ~/screenshot.png
`grimshot` - usage
`grimshot check` - verify if tools are installed
2019-10-16 10:08:08 -04:00
Simon Ser 72ba9bef4b build: always use the project version
Don't use the latest tag, always use the project version for the version
string. Because of version branches, getting the version from Git can be
unreliable.

Closes: https://github.com/swaywm/sway/issues/4631
2019-10-16 09:42:28 -04:00
Rouven Czerwinski 344c259ec0 sway(5): move workspace_layout to config only
According to the source files, workspace_layout is a configuration only
command, move it to the correct section within the man page.
2019-10-16 14:21:45 +03:00
Drew DeVault 533acbe679
Update version to 1.2 2019-10-12 22:58:05 +03:00
Drew DeVault 12505e4c27 Update .github/FUNDING.yml 2019-10-11 19:36:58 -04:00
Wieland Hoffmann f79f00dbfb sway(5): Highlight valid values in the description of tiling_drag 2019-10-09 23:32:08 +03:00
Wieland Hoffmann 42db4468a0 sway(5): Add a missing verb 2019-10-09 23:32:08 +03:00
Simon Ser b4d785cf39 build: bump wlroots version to 0.8.1 2019-10-08 12:42:40 -04:00
Tadeo Kondrak 352a3e1f79 build: remove rootston from wlroots subproject
Fixes an invalid option warning from Meson.
2019-10-02 20:40:03 -04:00
Arkadiusz Hiler cf18bd8879 Fix syntax in examples in sway-output(5)
Some examples use comma to separate x and y for setting the output
position which is wrong.

Let's change it to spaces, as correctly demonstrated in the
`output <name> position|pos <X> <Y>` section.
2019-10-02 17:37:54 -04:00
Sebastian Krzyszkowiak edcd353a00 layer-shell: Fix damage tracking of nested popups
Popups are positioned relative to local surface coordinates of the
parent surface. There's no need to consider values set with
xdg_surface.set_window_geometry for parent surfaces.
2019-09-29 19:50:58 +03:00
Simon Ser 00c4c7e8cc Fix direct scan-out flickering
Sometimes when using direct scan-out, some flickering between the
fullscreen app and the regular desktop could be seen.

This happened because we called wlr_output_attach_render and then
wlr_output_attach_buffer for direct scan-out. wlr_output_attach_render
makes the OpenGL context current but also attaches the OpenGL buffer to
the primary plane apparently (all of this happens inside
eglMakeCurrent).

This patch moves the scan-out logic outside of output_render, before
wlr_output_attach_render. This lines it up with rootston's
implementation. This also makes more sense since no rendering is
involved when using direct scan-out.

Sorry about that, I should've tested this with more clients. The new
code has been tested with mpv and a GLFW demo.
2019-09-26 10:36:18 -04:00
John Chadwick 7e420cb6e4 input: Add support for tablet protocol.
Sway has basic support for drawing tablets, but does not expose
properties such as pressure sensitivity. This implements the wlr tablet
v2 protocol, providing tablet events to Wayland clients.
2019-09-25 23:10:33 -04:00
Simon Ser 875edc9c2f Add support for fullscreen view direct scan-out 2019-09-25 23:00:08 -04:00
Drew DeVault 8053aed9df config.in: set default term to alacritty 2019-09-25 22:40:04 -04:00
Simon Ser 08b3eaf930 build: update wlroots version, be more strict
wlroots versions are incompatible with each other. Often our users struggle
with figuring out that their wlroots version is too old after a new release.
Use a more strict version check to prevent building sway with incompatible
wlroots versions.
2019-09-23 11:27:11 -04:00
Ronan Pigott ec66bb987a view: create container before selecting workspace 2019-09-22 15:18:51 -04:00
Simon Ser c41c24d684 Error out on unknown debug flag
Otehrwise it's pretty easy to misremember a flag and think damage=rerender is
enabled when it's not.
2019-09-22 15:17:59 -04:00
Brian Ashworth da0ad4c39e view: always populate pid
If the view was mapped as fullscreen or the view was assigned either a
workspace or output, the pid was not being populated since it was
occurring as part of the pid mapping check in select_workspace. This
extracts the pid population and makes it so it is always executed
2019-09-20 20:47:59 +03:00
xdavidwu 3a2e860848 swaybar: make status block text render in the same way as others
Other components like workspace button, status line (error or plain
text) already render text at integer coords. This make status block
also render text at integer coords.
2019-09-20 11:31:50 -04:00
Ivan Molodetskikh fba248ed5e render: set surface as sampled for presentation 2019-09-19 19:47:24 +03:00
Martin Michlmayr a085e6495c swaymsg.1: fix typos 2019-09-12 14:56:36 +03:00
Martin Michlmayr c11c8a583f sway-output.5: fix variable name
__foo__ is verbatim in scdoc, but we want the variable foo in italic,
i.e. _foo_.
2019-09-11 15:34:11 +03:00
Martin Michlmayr 8724900e38 swaymsg.1: fix description of --pretty 2019-09-10 00:14:59 +03:00
Ivan Molodetskikh db6a9d08f9 Add Russian translation of the README 2019-09-09 19:09:57 +03:00
Aleksis 982e01f46c remove unused layer shell surface variable 2019-09-07 20:22:54 +03:00
Brian Ashworth aa8ea2fa82 sway.5: clarify that a marks are unqiue
This just clarifies that a mark can only be set for a single window
since they are used as unique identifiers
2019-09-05 22:04:02 +03:00
Nils ANDRÉ-CHANG 21717d2ed2 Fix type (an -> and) 2019-09-05 22:02:33 +03:00
Versus Void 2c1a11016c Do not search for edges on subsurfaces, fix #4381
Subsurfaces (in most cases popups) aren't decorated by sway
and will never have any borders, but may be drawn beyond container
boundaries producing false positive when searching for edge.
So we want to skip edge search when handling mouse event on subsurface.
2019-09-05 17:41:23 +03:00
Brian Ashworth 1fd2c6ba49 swaybar: complete barconfig_update event handling
This adds complete support for the barconfig_update ipc event. This also
changes the bar command and subcommand handlers to correctly emit the
event. This makes it so all bar subcommands other than id and
swaybar_command are dynamically changeable at runtime. sway-bar.5 has
been updated accordingly
2019-09-04 16:48:50 -10:00
Brian Ashworth 187306640b seatop_default: only focus container on press
This matches i3's behavior of only focusing a container when pressed.
This allows for `bindsym button1 nop`, `bindsym BTN_LEFT nop`, or
`bindcode 272 nop` to be used to disable focusing when clicking on the
title (or with additional flags to bind{code,sym} other portions of
the container).

Without this additional condition, the user would need both
`bindsym button1 nop` and `bindsym --release button1 nop` to override
both the pressed and released behavior.
2019-09-04 16:48:34 -10:00
Ben Brown 0ad5e355bd Add icon_theme_path to find_icon() search if set
find_icon() will search in theme appropriate subdirs.
2019-09-04 03:32:45 -04:00
xPMo 42a7860dcf Fix bar_state_update docs 2019-09-03 22:22:25 -04:00
Ben Brown b46c53957f Fix typo for the force/immediate option in xwayland_mode enum 2019-09-02 17:06:38 +03:00
Simon Ser 1b396273bb man: document how to specify multiple xkb layouts and options
This isn't described in xkeyboard-config(7).
2019-09-02 08:39:25 +09:00
Simon Ser 53e01bf5c7 layer-shell: don't give focus to unmapped layer surfaces
Focused layers are not cleared when destroyed, they are cleared on unmap.
Giving focus to an unmapped layer surface is (1) incorrect and (2) triggers a
use-after-free.

Closes: https://github.com/swaywm/sway/issues/4517
2019-09-01 09:58:03 +09:00
Kenny Levinsen b2ee5bc05d Ensure that seat->focused_layer is cleared on unmap
The current seat may have changed between the last focus change and
this unmap, so we need to scan through all seats to find our layer.
2019-09-01 00:03:18 +03:00
xdavidwu 07d7af593d seat: set cursor image only if no pointer cap previously
This make seat_update_capabilities set cursor image only if
there was no pointer cap before update. This avoid resetting
cursor to left_ptr if an input device is removed.
2019-08-31 23:13:12 +09:00
xdavidwu afde6369b8 seat: avoid unneeded reloading xcursor theme
Load xcursor theme on configuring pointer or tablet tool only if
there was no pointer cap before.
2019-08-31 23:12:33 +09:00
Martin Michlmayr 3dcfa2ee90 Fix markup syntax in man pages 2019-08-31 22:50:39 +09:00
Brian Ashworth 1a8b9fda8a cmd_mode: don't reset to default after subcommand
In cmd_mode, the mode is currently being reset to the default mode after
a mode subcommand handler is executed. This stores and restores the mode
instead
2019-08-27 13:45:04 +09:00
Drew DeVault c55bc40cc1 chmod +x contrib/_incr_version 2019-08-27 12:30:48 +09:00
Drew DeVault c2030b9abd Add _incr_version to contrib/ 2019-08-27 12:29:42 +09:00
asdfjkluiop f07b9afee5 A layer-shell will only be focused if it is non-null 2019-08-27 10:09:41 +09:00
Michael Aquilina a298cad05c Fix formatting for title_format in man 5 sway
Use explicit linebreaks to make scdoc use a separate line for each entry
listed
2019-08-25 09:19:05 +09:00
Dark c3fbb01e07 Update titlebar borders to match i3's current behavior. 2019-08-24 00:41:19 -04:00
Brian Ashworth 90bef0364b cmd_move: fix move to scratchpad hidden container
When moving to a scratchpad hidden container (using `move
[window|container] [to] mark <mark>`), this moves the container to the
scratchpad (equivalent to `move [window|container] [to] scratchpad`).

Previously, this would crash since the destination did not have a
workspace.
2019-08-23 09:12:06 +09:00
Laurent Bonnans a074e0f504 ipc: collapse multi-container command results
Match i3's behavior and only return one status response per command,
even if it applies to several nodes.

Also returns an error if the criteria returns an empty match.

Closes #4483
2019-08-22 13:09:38 -04:00
Brian Ashworth aa9ba58169 sway.5: remove mention of floating_scroll
It looks like floating_scroll was still in the sway(5) man page as a
remnant of the 0.x era. This just removes it from the man page since it
is no longer a valid command. Mouse bindings with Button4-7 can be used
instead
2019-08-22 10:40:13 +09:00
lbonn 7baa3ffece Allow moving a container hidden in scratchpad
(as i3 allows it)

Just update the container's coordinates so that they will be applied at
the next show.
2019-08-20 13:09:52 -04:00
Brian Ashworth ff7d979d99 cmd_xwayland: add force for immediate launch
This just adds a force option to cmd_xwayland that allows for xwayland
to be immediately launched instead of lazily launched. This is useful
for slower machines so it can be part of the startup time instead of
when the user is actively trying to use it
2019-08-20 11:34:34 +09:00
Brian Ashworth 384afc5cb5 input/keyboard: send released only if pressed sent
This keeps track of whether surfaces received a key press event and
will only send a key release event if the pressed event was sent. This
also requires changing the keycodes that are sent via wl_keyboard_enter
to only include those that were previously sent. This makes it so
surfaces do not receive key release events for keys that they never
received a key press for and makes it so switching focus doesn't leak
keycodes that were consumed by bindings.
2019-08-20 11:14:56 +09:00
Simon Ser 7488d33d42 Remove xdg-shell v6 support
All major toolkits and apps have gained xdg-shell stable support.

Closes: https://github.com/swaywm/sway/issues/3690
2019-08-20 10:57:20 +09:00
Ilia Bozhinov 06c36f8435 properly check pixman_region32_contains_rectangle return
pixman_region32_contains_rectangle() returns
pixman_region_intersection_t not a bool.
2019-08-19 12:28:40 +03:00
Brian Ashworth 8441711990 input/seatop_down: add axis handler
This adds an axis handler to seatop_down so that it is possible to
manually scroll while having a mouse button down. This is mainly useful
for selecting text. Some applications may not automatically scroll when
the cursor is near the edge of the application or the user may just
prefer manually scrolling for more control over the scrolling speed.
2019-08-16 08:57:17 +03:00
Brian Ashworth 6061d083ca sway{,-bar}.5: add link to pango font description
This just specifies that both cmd_font and bar_cmd_font should be
specified using the pango font description and adds a link to the pango
documentation regarding the font description
2019-08-16 08:53:55 +03:00
Drew DeVault cb8f68d74b layer-shell: add support for popups 2019-08-14 22:10:05 +03:00
Brian Ashworth f36240208c workspace_split: focus middle if workspace focused
In workspace_split, the middle container that wraps the workspace's
children should be focused for any seat that is focusing the workspace
2019-08-14 13:19:16 +09:00
Brian Ashworth 75a7b02529 container_replace: copy {width,height}_fraction
This copies the width and height fractions from the container to the
container replacing it. Without setting these values, the container
is treated as a new container and throws off the existing sizing. Since
one container is replacing the other, it makes sense for the sizing to
remain the same.
2019-08-14 13:18:57 +09:00
Brian Ashworth 9bac7e6558 swaymsg.1: add tip about two hyphens for commands
This adds a tip to the command section about using two hyphens before a
command to signal that no swaymsg options will follow to allow for sway
commands with leading hyphens.
2019-08-13 11:31:51 +09:00
Brian Ashworth acd3db4fe1 workspace: do not destroy if any seat is focusing
Since each seat has its own focus, do not destroy a workspace until it
is no longer focused by any seat. This prevents seats from being forced
to evacuate the workspace just because another seat switched focus away
from it
2019-08-13 11:30:28 +09:00
Brian Ashworth 3e33e1c76f handle_seat_node_destroy: do not focus own node
In handle_seat_node_destroy, it was possible to focus the node attached
to the seat node that is being destroyed when an empty workspace was
being destroyed in a multiple seat environment. This resulted in
infinite recursion when attempting to destroy the workspace. This just
moves the seat node destruction higher so it cannot be the focus
inactive for the seat. This is the same ordering that is applied to
destruction of seat nodes for containers
2019-08-13 10:16:32 +09:00
Brian Ashworth 804aacb8c7 workspace: prefer identifiers for output priority
Since output names can change in various configurations, including
DisplayPort MST, prefer output identifiers for the output priority.
Users can still use `workspace <ws> output <names-or-ids>`, but any
output that is programmatically added to the list will be added under
the output identifier. If the output name exists in the list (from the
user workspace output configs), then that will be retained instead of
switching to the output identifier for that output.
2019-08-13 09:16:45 +09:00
Antonin Décimo 813e120979 Remove redundant checks 2019-08-12 09:42:11 +09:00
Antonin Décimo 3af52d86f7 Fix memory leaks 2019-08-12 09:42:11 +09:00
Antonin Décimo 0570eb19e5 view_update_size: fix surface_width/height mismatch 2019-08-12 09:42:11 +09:00
Antonin Décimo 9be76e6b12 input: check pointer against nullptr 2019-08-12 09:42:11 +09:00
Antonin Décimo 1d6d26cdec ipc-client: remove useless free for failed malloc 2019-08-12 09:42:11 +09:00
Sebastian Krzyszkowiak dac9c9c72b layer_shell: Guard against negative exclusive zone
This can happen with surfaces that set negative margins.
2019-08-12 09:33:30 +09:00
Drew DeVault 6200ecbc1d Remove rootston from build manifests 2019-08-09 09:59:44 +09:00
Rouven Czerwinski 724926ea6a Revert "Add support for wlr_output's atomic API"
This reverts commit 6e0565e9de.

This is required for the revert on swaywm/wlroots#1781
2019-08-07 16:25:37 +09:00
Brian Ashworth dc5d76cf3b sway.5: explain how to enable pango markup in font
This clarifies the syntax to use for the font command to enable pango
markup support.
2019-08-07 14:05:11 +09:00
Brian Ashworth 19d05d3ae0 config/output: rebase cursors after config applied
When applying an output config, an output may transform or be altered
in some way that effects the cursor. In order for the cursor images to
be updated properly, all cursors need to be rebased after applying
output configs.
2019-08-07 13:50:07 +09:00
Brian Ashworth f59b665792 cmd_mode: make modes case sensitive
This mirrors a change in i3 4.17 that makes binding modes case
sensitive
2019-08-06 11:32:26 +09:00
Brian Ashworth a8a239e2f1 swaymsg: return 2 for sway errors
This mirrors a change in i3 4.17 that returns 2 for errors from sway,
including invalid command, command failed, and invalid subscription
requests
2019-08-06 11:31:39 +09:00
Brian Ashworth 56b5ad777c input/cursor: do not hide when buttons are pressed
This just adds a small quality of life improvement to the cursor hiding
functionality. The cursor will no longer be hidden unless all buttons
are released.
2019-08-06 11:31:12 +09:00
Brian Ashworth a9e31d925f cmd_swap: add floating support
For feature parity with i3 4.17, this just adds floating container
support to the swap command
2019-08-06 11:30:17 +09:00
Jeff Peeler 140ce785fe cmd_opacity: add relative opacity changes
This enhances the opacity command to support relative assignment as well
as the currently implemented absolute assignment. The syntax is copied
from the same format that gaps uses for relative and absolute setting.
An example usage in a sway config looks like:

// relative change (this feature)
bindsym button4 opacity plus .1
bindsym button5 opacity minus .1

// absolute change (this feature)
bindsym button4 opacity set 1
bindsym button5 opacity set .3

// old way, still supported
bindsym button4 opacity 1
bindsym button5 opacity .3
2019-08-05 22:10:36 -04:00
Brian Ashworth 90d8a4df32 input/libinput: typo fixes (get -> get_default)
This just fixes some typos in the reset functions that were using
the get calls instead of get_default
2019-08-03 15:46:05 +02:00
Antonin Décimo c1a5f61622 Remove unused variable 2019-08-02 20:55:49 +03:00
Antonin Décimo 7e5c2d7afa Allocator sizeof operand mismatch
Result of 'calloc' is converted to a pointer of type 'char *', which
is incompatible with sizeof operand type 'char **'
2019-08-02 20:55:49 +03:00
Simon Ser 6e0565e9de Add support for wlr_output's atomic API
See https://github.com/swaywm/wlroots/pull/1762
2019-08-02 10:01:50 -04:00
Brian Ashworth 8ee054b1b9 bindsym/code: add group support
This adds support for specifying a binding for a specific group. Any
binding without a group listed will be available in all groups. The
priority for matching bindings is as follows: input device, group, and
locked state.

For full compatibility with i3, this also adds Mode_switch as an alias
for Group2. Since i3 only supports this for backwards compatibility
with older versions of i3, it is implemented here, but not documented.
2019-08-01 18:54:58 +03:00
Brian Ashworth 14562fdbee input/keyboard: don't reset layout for same keymap
In sway_keyboard_config, do not change the keymap when the new keymap
is unchanged, unless this is during a config reload. The reasoning for
this is to prevent the effective layout from being reset to index 0 for
input config changes unrelated to the keymap.
2019-08-01 18:27:01 +03:00
Paul Ouellette f567a40d59 Fix typo in sway(5) manpage 2019-07-31 21:45:52 -04:00
Brian Ashworth 75de31d36e libinput: fix set_send_events
This just fixes the check in set_send_events for whether the mode has
changed. LIBINPUT_CONFIG_SEND_EVENTS_ENABLED is 0 so the bitmask check
cannot be fixed, but Sway doesn't allow multiple modes to be set anyway
(not really sure why you would need to) so a basic equality check works
2019-07-31 22:32:13 +03:00
Brian Ashworth fc955716d4 input/libinput: fix typo in set_middle_emulation
This fixes a typo in set_middle_emulation where it would set left
handed instead of middle emulation.
2019-07-28 09:19:59 -04:00
Pedro Côrte-Real cefc608cb9 Fix resize sibling amount calculations
Sibling amounts were being calculated after the original fraction had
been altered. This led to broken resize amounts. Fix that by calculating
things upfront before adjusting values which also makes the code
cleaner.

For sanity checks also calculate the sibling amount with the
ceiling so we never go below the sanity check even by one pixel.

Fixes #4386
2019-07-27 23:36:16 -04:00
Simon Ser f984f21b6a Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.

This commit si similar to wlroots' ca45f4490ccc ("Remove all wayland-server.h
includes").
2019-07-27 17:16:56 -04:00
Ashkan Kiani e4bba906b6 Avoid adding duplicate criteria for no_focus and command 2019-07-27 03:53:05 +03:00
Brian Ashworth 17c9a0e84f arrange: remove gaps for workspace location deltas
When arranging the workspace, prev_x and prev_y should be ignoring the
current gaps otherwise the workspace diff_x and diff_y location deltas
will be off. When the deltas are off, each arrangement of the workspace
would incorrectly move floaters an extra -workspace->current_gaps.left
along the x-axis and an extra -workspace->current_gaps.top along the
y-axis.
2019-07-26 18:13:27 +03:00
Brian Ashworth 1a16262903 ipc: add input::libinput_config event
This adds a libinput_config change type to the input event for when
the libinput config for a device changes

In order for this to be possible to track, the libinput config code
had to be refactored. It is now extracted into a separate file to
isolate it from the rest of the input management code.
2019-07-23 20:45:46 +03:00
Brian Ashworth 6effca7b61 ipc: add an input event
This adds an ipc event related to input devices. Currently the
following changes are supported:
- added: when an input device becomes available
- removed: when an input device is no longer available
- xkb_keymap_changed: (keyboards only) the keymap changed
- xkb_layout_changed: (keyboards only) the effective layout changed
2019-07-23 20:45:46 +03:00
Brian Ashworth 36aa67e549 input_cmd_xkb_switch_layout: support input types
This just adds input type config support to input_cmd_xkb_switch_layout
so that `input type:keyboard xkb_switch_layout <idx>` will work
2019-07-18 08:20:54 +03:00
Brian Ashworth 92b22ee9ea cmd_output: support current output alias
Similar to seat command, this provides an alias for the current output.
Instead of the output name or identifier, `-` can be used to operate on
the focused output by name and `--` can be used to operate on the
focused output by its identifier. This will prevent operating on the
no-op output when using either alias.
2019-07-17 21:25:09 -04:00
Ed Younis 37308f6549 input_cmd_xkb_*: cleanup includes 2019-07-17 19:26:58 -04:00
Ed Younis eb770e88b7 Implement input_cmd_xkb_file (#3999)
Adds a new commend "xkb_file", which constructs the internal
xkb_keymap from a xkb file rather than an RMLVO configuration.
This allows greater flexibility when specifying xkb configurations.
An xkb file can be dumped with the xkbcomp program.
2019-07-17 19:26:58 -04:00
rpigott 3716c53d35 Add missing description for focus_on_window_activation command in docs. 2019-07-17 18:31:02 -04:00
jasperro 1e66fa0d23 Added Dutch translation of README 2019-07-17 12:36:52 -04:00
Josef Gajdusek ac87df23ea Update output manager on layout change
The output manager config was not properly updated if the position
of the output got changed.
2019-07-17 19:36:15 +03:00
Sauyon Lee 9af0b4d2ea Make fullscreen check for fullscreen parents
This ensures that a child of a fullscreen container cannot
be fullscreened.
2019-07-17 09:25:36 -04:00
Pedro Côrte-Real 95c444de33 Sanity check gaps on the outside of the workspace
Avoid gaps that are too large around the workspace that you end up
without any usable space for children.

Fixes #4308
2019-07-15 23:46:27 -04:00
Pedro Côrte-Real 99192a92f9 Avoid negative outer gaps
Make sure we never let the gaps around the workspace go negative.

Fixes #4304
2019-07-15 23:46:27 -04:00
Pedro Côrte-Real 44c2fafa4f Sanity check gaps between tiled containers
When the gaps become too large for the space available gracefully
reduced them all the way to 0 if needed.

Fixes #4294
2019-07-15 23:46:27 -04:00
Pedro Côrte-Real d0233af3b3 Rework gaps code to be simpler and correct
Instead of tracking gaps per child apply gaps in two logical places:

1. In tiled containers use the layout code to add the gaps between
windows. This is much simpler and guarantees that the sizing of children
is correct.
2. In the workspace itself apply all the gaps around the edge. Here
we're in the correct position to size inner and outer gaps correctly and
decide on smart gaps in a single location.

Fixes #4296
2019-07-15 23:46:27 -04:00
Manuel Stoeckl 2dc4978d8a Use -fmacro-prefix-map to strip build path
Because meson does not provide a simple way to get the relative build
path, it is computed with a pair of foreach loops. As meson does not
have a simple way to compute string length (except via underscorify
and 63 split operations), the build script uses a shell command
instead.

If the compiler does not suppot -fmacro-prefix-map, then fall back
to passing in the relative path prefix, and use its length to offset
the uses of __FILE__ in log messages so that the build path is at
least still not included in the logs. This is significantly more
efficient than calling _sway_strip_path.
2019-07-15 16:35:50 -04:00
Pedro Côrte-Real e3a3917d3a Layout tiled using a width/height fraction
Instead of using container->width/height as both the input and output
of the layout calculation have container->width_fraction/height_fraction
as the share of the parent this container occupies and calculate the
layout based on that. That way the container arrangement can always be
recalculated even if width/height have been altered by things like
fullscreen.

To do this several parts are reworked:

- The vertical and horizontal arrangement code is ajusted to work with
  fractions instead of directly with width/height
- The resize code is then changed to manipulate the fractions when
  working on tiled containers.
- Finally the places that manipulated width/height are adjusted to
  match. The adjusted parts are container split, swap, and the input
  seat code.

It's possible that some parts of the code are now adjusting width and
height only for those to be immediately recalculated. That's harmless
and since non-tiled containers are still sized with width/height
directly it may avoid breaking other corner cases.

Fixes #3547
Fixes #4297
2019-07-14 11:13:55 -04:00
Pedro Côrte-Real 1312b5bb9f Layout correctly with several new windows
If there is more than one new window layout correctly by calculating the
default size of the new windows using the information of how many of
them there are in total.

This helps with issue #3547 but doesn't fix it in all situations. Things
now work correctly if the first layout of new windows happens after
leaving fullscreen. But if for some reason an arrange_container() gets
called while we are fullscreen the windows will still be incorrectly
sized after saved_width/saved_height get used to restore the first
window's size before going fullscreen.
2019-07-14 11:13:55 -04:00
Brian Ashworth c312a10cc7 cmd_split: fix toggle split for non-split layouts
Previously, `layout toggle` and `layout toggle split` would set L_VERT
when layout was L_HORIZ, otherwise it would set L_HORIZ. This meant
that when the layout was L_TABBED or L_STACKED, it would always be
L_HORIZ. This extends #4315 (which corrects the handling when multiple
layouts are given) to try prev_split_layout,
config->default_orientation, and then falling back to L_VERT when the
output is taller than wide and L_HORIZ when wider than tall.
2019-07-11 10:46:56 -04:00
Brian Ashworth 5ffcea4c28 cmd_layout: toggle split for tabbed/stack default
This fixes the logic of split for layout toggle when the default
layout is L_TABBED or L_STACKED. When the default layout is L_TABBED
or L_STACKED, the container/workspace may not have a prev_split_layout.
This was causing L_NONE to be returned by get_layout_toggle, which was
being handled as a syntax error. This adds logic to try
config->default_orientation when prev_split_layout is L_NONE. If that
is also L_NONE, then L_VERT is used when the output is taller than
wide, otherwise, L_HORIZ is used.
2019-07-10 15:29:38 -04:00
Brian Ashworth 6096d31eed config/output: correctly set width/height in apply
In apply_output_config, this sets output->{width,height} using the
values in the output box. Previously, they were being set using
wlr_output_transformed_resolution, which takes the width and height
from the wlr_output and just checks whether they should be swapped
based on the transform. This did not take into account the output's
scale. wlr_output_effective_resolution could be used instead, which
handles both transform and scale. However, the values in the output box
have already been processed by wlr_output_effective_resolution so they
can just be used directly
2019-07-10 14:03:15 -04:00
Brian Ashworth 32265d9136 input/libinput: only reset supported options
This adds checks to the input_manager_libinput_reset_* functions to
only attempt resetting supported options on reload. This should have no
functional difference to the user, but will remove several `Failed to
apply libinput config: Unsupported configuration option` lines from the
log that can be noisy and potential red herrings.
2019-07-09 11:50:02 -04:00
Brian Ashworth 152e30c374 cmd_bindswitch: add option to execute on reload
This adds a --reload flag to cmd_bindswitch that allows for the binding
to be executed on reload. One possible use case for this is to  allow
users to disable outputs when the lid closes and enable them when the
lid opens without having to open and re-close the lid after a reload.
2019-07-09 10:00:57 +03:00
Sebastian Parborg 538b36c0e2 Make mouse drag in tiled mode swap containers if no edge is selected
Now the highlighted center area of containers triggers a swap action
instead of moving around the containers.
2019-07-09 02:56:55 -04:00
Sergei Dolgov c9cb5ced7f calibration_matrix: expect 6 individual values
Example usage from command line:

    swaymsg input type:touch calibration_matrix -- -1 0 1 0 -1 1
2019-07-05 18:41:56 +03:00
Sergei Dolgov a5c6816095 calibration_matrix: add the current matrix to the IPC description for libinput devices 2019-07-05 18:41:56 +03:00
Sergei Dolgov bcceb61b43 Use isnan 2019-07-05 18:41:56 +03:00
Sergei Dolgov 01ec18e802 Add calibration_matrix config option
Can be used to change the orientation of a touchscreen.

Example usage with swaymsg:

    # identity
    swaymsg input type:touch calibration_matrix '"1 0 0 0 1 0"'

    # 90 degree clockwise
    swaymsg input type:touch calibration_matrix '"0 -1 1 1 0 0"'

    # 180 degree clockwise
    swaymsg input type:touch calibration_matrix '"-1 0 1 0 -1 1"'

    # 270 degree clockwise
    swaymsg input type:touch calibration_matrix '"0 1 0 -1 0 1"'

Documentation:

    https://wayland.freedesktop.org/libinput/doc/latest/absolute-axes.html#calibration-of-absolute-devices
2019-07-05 18:41:56 +03:00
Brian Ashworth f5d1c27226 swaybar-protocol.7: fix block border descriptions
This corrects the description of border_{top,bottom,left,right} in the
block properties table in swaybar-protocol.7. The values should be an
integer denoting the width/height rather than a boolean denoting
whether to show them.
2019-06-28 10:34:09 +03:00
random human 0ba959f1ce tree: set correct border value before creating floater 2019-06-27 11:13:02 -04:00
Manuel Stoeckl 5becce8005 Replace meson generator with custom_target
This change mimics the wlroots protocol meson.build. It replaces
meson generators with custom_targets, which will only run wayland-scanner
once per output file.

The idle protocol is not used by any clients, so its client protocol
header is not generated.

The check for the availability of the private-code scanner options has
been removed, since the wlroots dependency requires wayland >= 1.16.
2019-06-24 09:38:41 +03:00
Brian Ashworth a18d1c55ce ws-output-priority: fix logic issue in find_output
The function used for comparing two output names in the workspace
output priority lists was inverted. This was causing priority to not be
stored correctly resulting in workspaces not always being restored or
moved to the desired outputs
2019-06-23 09:57:38 +03:00
murray b59139c239 use surface coordinates for damaging buffers 2019-06-22 12:16:32 +03:00
Brian Ashworth d0d01810f3 cmd_mode: allow runtime creation and modification
This allows for modes to be created, bindings to be added to modes, and
bindings to be removed from modes at runtime. Additionally, this also
allows for `mode <mode>` to be deferred in the config to set an initial
mode.
2019-06-20 10:14:19 -04:00
Brian Ashworth fc3253cc35 cmd_seat: split action and config handlers
This separates the logic for seat subcommand handlers that only perform
actions on the seat and handlers that alter the seat config. The former
group can immediately free the seat config after running the command as
it is only used by the subcommand to find the name of the seat to
operate on. The latter group alters the seat config so it will need to
go through the storage and application stage (assuming success).
2019-06-20 10:15:09 +03:00
Brian Ashworth c346c020bf config: fix find_handler logic
Without this change, the handlers listed in the config_handlers or
command_handlers arrays (depending on reading or active) in commands.c
would be valid subcommands. To make matters worse, they would also take
precedence over the defined subcommand handlers.

This corrects find_handler to only work on the handler array given
instead of implicitly trying others.
2019-06-20 10:13:58 +03:00
Brian Ashworth 5069b53d6c config/xwayland: retain xwayland status on reload
Since xwayland can only be enabled/disabled at launch, the xwayland
status should be retained on reload. Having `xwayland enabled|disabled`
in the config, should not cause `config->xwayland` to be invalid on
reload. This also returns `CMD_FAILURE` with a message that xwayland
can only be enabled/disabled on launch when trying to set the invalid
status on reload. This allows swaynag to notify the user that the
change will not take effect until sway is restarted.
2019-06-19 07:40:52 +03:00
Rouven Czerwinski ddad41f423 Fix sway crashes for scratchpad layouts
Currently container_replace removes the container from the scratchpad
and re-adds it afterwards. For the split commands this results in the
container being send to the scratchpad, which results in a NULL segfault
if the same container should be shown.
Pass an optional workspace to root_scratchpad_add_container, if the
workspace is passed the window will continue to show on the workspace.
If NULL is passed it is sent to the scratchpad.
This was an issue if no other window except the scratchpad container was
on the workspace.

Fixes #4240
2019-06-16 12:29:16 -04:00
Robert Sacks bdd4d69205 Add missing underscore in bindswitch documentation
The missing underscore after "toggle" causes the underline to continue
for a whole sentence.
2019-06-14 21:23:20 -04:00
Brian Ashworth 9670ccee68 bindings: defer while initiailizing
This adds the logic to defer binding execution while sway is still
initializing. Without this, the binding command would be executed, but
the command handler would return CMD_DEFER, which was being treated as
a failure to run. To avoid partial executions, this will defer all
bindings while config->active is false.
2019-06-12 07:56:41 +03:00
Matt Coffin 2b5bf78faf Fix segfaults caused by faulty command parsing
This patch fixes faulty command parsing introduced by
f0f5de9a9e. When that commit allowed
criteria reset on ';' delimeters in commands lists, it failed to account
for its inner ','-parsing loop eating threw the entire rest of the
string.

This patch refactors argsep to use a list of multiple separators, and
(optionally) return the separator that it matched against in this
iteration via a pointer. This allows it to hint at the command parser
which separator was used at the end of the last command, allowing it to
trigger a potential secondary read of the criteria.

Fixes #4239
2019-06-11 14:40:36 -04:00
Simon Ser 3f77591b00 Add docs for new IPC keyboard properties 2019-06-10 01:54:05 -04:00
Simon Ser 3f2518edc1 Add missing docs for xkb_switch_layout 2019-06-10 01:41:44 -04:00
Simon Ser 2bccb387d8 Add a new xkb_switch_layout command
This allows users to programatically change the active layout.
2019-06-09 15:20:14 -04:00
Simon Ser 84e4061bf4 ipc: add xkb_layout_names and xkb_active_layout_index
These can be useful to implement per-window layouts as a script.

See https://github.com/swaywm/sway/issues/2361
2019-06-09 15:04:50 -04:00
Brian Ashworth 5b1a8d62b9 config/input: validate xkb keymap before storing
This allows for an optional validation stage when storing an input
config. Currently, only the xkb keymap is validated. If storing the
delta input config will result in any invalid xkb keymaps, the input
config will not be stored and error will be populated with the first
line of the xkbcommon log.
2019-06-09 20:13:22 +03:00
Brian Ashworth be2d2a299a commands/input: perform basic keymap validation
Before the delta input config is stored, this attempts to compile a
keymap with it. If the keymap fails to compile, then the first line of
the xkbcommon log entry will be included with a `CMD_FAILURE`, the
entire xkbcommon log entry will be included in the sway error log, and
the delta will not be stored.

This only handles basic issues such as a layouts not existing. This
will NOT catch more complex issues such as when a variant does
exist, but not for the given layout (ex: `azerty` is a valid variant,
but the `us` layout does not have a `azerty` variant).
2019-06-09 20:13:22 +03:00
Alex Maese 4d93b96b6e Unhide cursor on cursor activity after touch 2019-06-08 12:02:28 -04:00
Aidan Harris f17eae9043 Fix segfault with "xwayland false" (#4228)
Commit 190546fd31 failed to consider the
edge case where xwayland is disabled via the sway config. This leads to
a SEGFAULT when setting the xwayland cursor since the xwayland server is
not running.
2019-06-08 17:28:10 +03:00
Abdelhakim Qbaich 9bfbb0dd49 Add the missing constant for the switch input type 2019-06-07 10:15:03 +03:00
Daniel Eklöf b4b274cdce check for empty string before calling strtoul() and check errno
Note: since strtoul() has no real error return code (both 0 and
ULONG_MAX may be returned on both success and failure), set errno=0
before calling strtoul().
2019-06-05 14:40:29 -04:00
Daniel Eklöf 900d3287f9 swaybar/nag: use xcursor theme defined by XCURSOR_THEME/SIZE
If the XCURSOR_THEME and/or XCURSOR_SIZE environment variables are
set, use the theme and size they define.

If they're not set, use the same defaults as before (system default
theme, size=24).
2019-06-05 14:40:29 -04:00
Brian Ashworth f0f5de9a9e criteria: reset on semicolon separation
This matches i3's behavior of only retaining criteria across comma
separated commands. When separating commands with a semicolon, the
criteria is reset and allows for new criteria to be set, if desired.
2019-06-05 11:02:35 -04:00
Daniel Eklöf 190546fd31 add seat sub command 'xcursor_theme'
New 'seat <name> xcursor_theme <theme> [<size>]' command that
configures the default xcursor theme.

The default seat's xcursor theme is also propagated to XWayland, and
exported through the XCURSOR_THEME and XCURSOR_SIZE environment
variables. This is done every time the default seat's configuration is
changed.
2019-06-05 11:00:10 -04:00
Brian Ashworth 799f5a2cd5 cmd_hide_edge_borders: add missing arg count check
This adds the missing argument count check after the --i3 flag
processing in cmd_hide_edge_borders. Without the check,
`hide_edge_borders --i3` would result in a SIGSEGV instead of a syntax
error. There are some minor adjustments to make it so nothing gets
altered if this check fails
2019-06-04 08:47:36 +03:00
Drew DeVault 6b6eb147ec Bump meson version to 1.1 2019-06-03 08:50:12 -04:00
Rouven Czerwinski 5ff330e6bc desktop: output: fix use-after-free in destroy
handle_destroy would mark the output es being destroyed and commit the
transaction. Committing the transaction results in the output being
freed, the output manager can not retrieve the server reference
afterwards, resulting in the following use-after-free:

==22746==ERROR: AddressSanitizer: heap-use-after-free on address 0x614000017088 at pc 0x560c1ac17136 bp 0x7ffeab146f20 sp 0x7ffeab146f10
READ of size 8 at 0x614000017088 thread T0
    #0 0x560c1ac17135 in handle_destroy ../sway/desktop/output.c:566
    #1 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #2 0x7f38af5d3dfc in drm_connector_cleanup ../subprojects/wlroots/backend/drm/drm.c:1448
    #3 0x7f38af5d2058 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1240
    #4 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #5 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #6 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #7 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)
    #8 0x7f38aef5c39b in wl_display_run (/usr/lib/libwayland-server.so.0+0x939b)
    #9 0x560c1ac0afbe in server_run ../sway/server.c:225
    #10 0x560c1ac09382 in main ../sway/main.c:397
    #11 0x7f38aed35ce2 in __libc_start_main (/usr/lib/libc.so.6+0x23ce2)
    #12 0x560c1abea10d in _start (/usr/local/bin/sway+0x3910d)

0x614000017088 is located 72 bytes inside of 432-byte region [0x614000017040,0x6140000171f0)
freed by thread T0 here:
    #0 0x7f38af82df89 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66
    #1 0x560c1acbd1ed in output_destroy ../sway/tree/output.c:243
    #2 0x560c1ac23ce5 in transaction_destroy ../sway/desktop/transaction.c:66
    #3 0x560c1ac26b71 in transaction_progress_queue ../sway/desktop/transaction.c:348
    #4 0x560c1ac284ca in transaction_commit_dirty ../sway/desktop/transaction.c:539
    #5 0x560c1ac17110 in handle_destroy ../sway/desktop/output.c:564
    #6 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #7 0x7f38af5d3dfc in drm_connector_cleanup ../subprojects/wlroots/backend/drm/drm.c:1448
    #8 0x7f38af5d2058 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1240
    #9 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #10 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #11 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #12 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)

previously allocated by thread T0 here:
    #0 0x7f38af82e5a1 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:95
    #1 0x560c1acbc228 in output_create ../sway/tree/output.c:91
    #2 0x560c1ac17ba2 in handle_new_output ../sway/desktop/output.c:656
    #3 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #4 0x7f38af5e4ce8 in new_output_reemit ../subprojects/wlroots/backend/multi/backend.c:143
    #5 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #6 0x7f38af5d26d4 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1294
    #7 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #8 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #9 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #10 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)

SUMMARY: AddressSanitizer: heap-use-after-free ../sway/desktop/output.c:566 in handle_destroy
Shadow bytes around the buggy address:
  0x0c287fffadc0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c287fffadd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffade0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffadf0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffae00: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x0c287fffae10: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffae20: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffae30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa
  0x0c287fffae40: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c287fffae50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fffae60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Retrieve the reference before the output is destroyed and update the
output_management state with the saved reference.
2019-06-02 19:36:16 +03:00
Simon Ser 4105982169 Remove orbital gamma-control protocol 2019-06-02 10:12:58 -04:00
Kenny Levinsen 4925882920 Use parent get_root_coords in subsurfaces
Subsurfaces need access to the parent get_root_coords impl for positioning in
popups. To do this, we store a reference to the parent view_child where
applicable.

Fixes #4191.
2019-05-30 14:25:07 -04:00
Brian Ashworth c3532bc8a1 Add swaybar protocol documentation
This adds swaybar-protocol.7.scd documenting the swaybar status line
protocol including some differences from the i3bar counterpart.
2019-05-30 10:54:23 -04:00
Brian Ashworth 6afb392823 bindings: allow unlocked and locked bindings
This changes the behavior of bindings to make the `BINDING_LOCKED` flag
conflicting, which will allow for both unlocked and locked bindings.

If there are two matching bindings and one has `--locked` and the other
does not, the one with `--locked` will be preferred when locked and
the one without will be preferred when unlocked.

If there are two matching bindings and one has both a matching
`--input-device=<input>` and `--locked` and the other has neither, the
former will be preferred for both unlocked and locked.

This also refactors `get_active_binding` in `sway/input/keyboard.c`
to make it easier to read.
2019-05-30 10:47:42 +03:00
Josef Gajdusek 2c6a10c4ba Provide current DPMS state in GET_OUTPUTS 2019-05-28 22:43:11 -04:00
Brian Ashworth 18476b0ec1 common/ipc-client: remove ipc recv timeout log
This just removes the ipc recv timeout log statement in
`ipc_recv_set_timeout`. The `tv_sec` field of `struct timeval` has
varying types and/or sizes depending on the platform and architecture.
On some of these, the current format string will cause compilation
errors. Additionally, the log statement is not extremely useful and the
function is currently only used by swaymsg, which has a hardcoded log
level that will prevent it from even being shown, so there is no point
in even keeping it.
2019-05-27 08:02:10 +03:00
Brian Ashworth de5cfa7232 input/switch: fix indentation of file
This just changes the indentation of `sway/input/switch.c` to use
tabs instead of spaces since I messed up and missed it when approving
the PR that added the file.
2019-05-27 07:55:24 +03:00
Drew DeVault e92ac7d552
Create FUNDING.yml 2019-05-25 12:35:43 -04:00
Josef Gajdusek 0e582f1a51 Update output manager config on all output events
The output manager config was not properly updated when output
configuration was changed through some other means (such as a command).
2019-05-24 22:52:07 +03:00
Josef Gajdusek b3a5effef2 Implement wlr-output-management-v1 2019-05-24 18:59:14 +03:00
Brian Ashworth 00cffb8e20 commands/bar: fix mode and hidden_state at runtime
For compatibility with i3, `bar mode` and `bar hidden_state` do not
require bar-ids (in the normal location) at runtime since they follow
the alternative syntax: `bar mode|hidden_state <option> [<bar-id>]`

This removes the incorrect error that the bar-id is missing for those
two bar subcommands
2019-05-22 22:33:10 +03:00
Nick Paladino 08ec88692a Make comment casing consistient
Makes the first letter of all the comments uppercase. THus making the config file more consistient
2019-05-21 08:12:49 -06:00
Alyssa Ross e4f1ffe601 commands/bar: improve error for invalid subcommand
Running a command like this produced a confusing error message:

    $ swaymsg bar bar-0 colors background #ff0000
    Error: Unknown/invalid command 'bar-0'

This patch makes the error message use argv[1] instead of argv[0] (from
config_subcommand's implementation), so it actually uses the name of the
command, rather than the id of the bar.
2019-05-19 11:47:16 -04:00
Alyssa Ross 5fb5984e94 bar: fix segfault with missing or invalid bar id
Prior to this patch, if I ran something like this, sway would crash:

    swaymsg bar height 50

or

    swaymsg bar not-a-bar-id color bg #ff0000

This was in contrast to other bar subcommands, like status_command,
which would exit with a "No bar defined" message.

The difference between the subcommands that crashed and the ones that
exited was that some subcommands had a check to see if a bar was
specified, while others just assumed that it had been and carried on
until they segfaulted.

Because this check was identical in every subcommand it was present in,
and I couldn't think of a case where it would be valid to run a bar
subcommand without specifying which bar to apply it to, I moved this
check from individual subcommands into the bar command, which is already
responsible for actually setting the specified bar. This reduced code
duplication, and fixed the crash for the subcommands that were missing
this check.
2019-05-17 15:33:57 -04:00
Nomeji 578c1956ac Add infos to help using for_window to man 5 2019-05-14 10:40:22 -06:00
Brian Ashworth 23c64ab22d input/keyboard: attempt default keymap on failure
This attempts to use the default keymap when the one defined in the
input config fails to compile. The goal is to make it so the keyboard
is always in a usable state, even if it is not the user's requested
settings as usability is more important.

This also removes the calls to `getenv` for the `XKB_DEFAULT_*` family
of environment variables. The reasoning is libxkbcommon will fallback
to using those (and then the system defaults) when any of the rule
names are `NULL` or an empty string anyway so there is no need for
sway to duplicate the efforts.
2019-05-14 08:23:26 -06:00
Moelf ed2e553b8d Implement output toggle
discussed in #4136, this can't handle wildcard but won't crash.
2019-05-14 00:11:04 -04:00
Brian Ashworth 18ce0eec60 Spawn swaybar as a wayland client
This just makes it so swaybar is handled as a wayland client
2019-05-12 11:02:42 +03:00
Brian Ashworth 8c8e6a6c90 config/output: fix typo in merge_id_on_name
This fixes a typo in `merge_id_on_name` for output configs that
resulted in incorrect id-on-name output configs being generated.
Instead of using the output that matched the name or identifier, the
first output in the list was being used instead. This could cause
merging across unrelated output configs and preventing output configs
from being applied correctly
2019-05-09 23:52:01 +03:00
Drew DeVault 9dca18b6f7 Add Firefox note to ISSUE_TEMPALTE.md 2019-05-06 15:32:37 -04:00
Brian Ashworth 51c077798c Destroy swaybg client on reload
When reloading, this destroys the old config's swaybg client before
spawning the new config's swaybg. This fixes a race condition where the
old config's swaybg client's destroy was being called after the new
config's swaybg client was being spawned. This was causing the
reference to the new swaybg client to be removed and never destroyed.

This also modifies handle_swaybg_client_destroy to grab the config
reference using wl_container_of on the listener since the swaybg client
may be the old config swaybg client and should be used instead of the
global config instance
2019-05-04 09:06:43 +03:00
Simon Ser 32087ad77d Fix xdg-decoration unconfigured if set before first commit
In case a set_mode/unset_mode request is sent before the first commit, we need
to handle the value and send our preference accordingly.

This fixes xdg-decoration support for Qt apps.
2019-05-03 15:37:32 -06:00
Drew DeVault 464a3b4fdd Bump required wlroots version 2019-05-03 13:10:53 -04:00
Brian Ashworth c8e4ca355d swaymsg: fix quiet error reporting
This makes it so swaymsg still returns the correct successful or failed
error code when in quiet mode
2019-05-03 11:09:49 -06:00
Brian Ashworth c118618278 sway.5.scd: clarify workspace config commands
This clarifies that `workspace <name> output <outputs...>` and
`workspace <name> gaps ...` do not operate on existing workspaces.
Additionally, alternate commands/solutions that operate on existing
workspaces are listed.
2019-04-30 21:38:00 -06:00
Brian Ashworth 13cbb3b7fc cmd_move: add support for output current
This adds support for the following commands for i3 compatibility:
- `move [window|container] [to] output current`
- `move workspace to [output] current`
- `move workspace [to] output current`

The above commands are only useful when used with criteria.
2019-04-30 15:22:02 -06:00
Alex Maese 3b3e0560be Fix a silly mistake 2019-04-28 21:07:47 +03:00
Alex Maese 5b454ac441 Don't send pointer motion when rebasing the cursor 2019-04-28 21:07:47 +03:00
Alex Maese 866a19b743 Clear pointer focus during move and resize seatops 2019-04-28 21:07:47 +03:00
Lane Surface 812651d53e Remove extra inclusion of stdio.h 2019-04-27 20:53:21 -06:00
Ilja Kocken e41e8d3330 Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
jajo-11 957a704936 Add German translation of the README 2019-04-27 15:05:43 -06:00
Simon Ser 9aafef352b Don't submit too much damage 2019-04-27 09:50:49 -06:00
Konstantin Pospelov e6fbb3c6bb config: fix clang warning 2019-04-26 20:56:48 +03:00
Konstantin Pospelov c42497aca0 bindsym: change xkb_rule_names initialization 2019-04-26 20:56:48 +03:00
Konstantin Pospelov ddf63ffabe bindsym: consider xkb_rule_names for --to-code 2019-04-26 20:56:48 +03:00
Konstantin Pospelov d27a5e1cb0 bindsym: update the man page to include --to-code 2019-04-26 20:56:48 +03:00
Konstantin Pospelov 998de8fbc5 bindsym: change default keymap for --to-code
Replace XKB_DEFAULT_LAYOUT with NULL as the default layout.
2019-04-26 20:56:48 +03:00
Konstantin Pospelov f1609abe4c config: simplify keysym translation fields
Do not store `xkb_keymap` since it can be retrieved from `xkb_state`.
2019-04-26 20:56:48 +03:00
Konstantin Pospelov a09c144b8b Implement bindsym --to-code
* `bindsym --to-code` enables keysym to keycode translation.
* If there are no `xkb_layout` commands in the config file, the translation
uses the XKB_DEFAULT_LAYOUT value.
* It there is one or more `xkb_layout` command, the translation uses
the first one.
* If the translation is unsuccessful, a message is logged and the binding
is stored as BINDING_KEYSYM.
* The binding keysyms are stored and re-translated when a change in the input
configuration may affect the translated bindings.
2019-04-26 20:56:48 +03:00
Simon Ser bd32b300fb ci: enable all features
If unspecified, feature options are set to "auto", which means enabled only if
the required dependencies are found. In CI we don't want to miss compilation
errors because a dependency hasn't been found and code isn't built.

Leave FreeBSD out for now because it uses a subproject (haven't found a way to
make auto_features=enabled only apply to the toplevel project).
2019-04-25 10:00:55 -06:00
Drew DeVault 236ca63419 swaybg: split into standalone project
The new upstream is https://github.com/swaywm/swaybg

This commit also refactors our use of gdk-pixbuf a bit, since the only
remaining reverse dependency is swaybar tray support.
2019-04-25 18:44:28 +03:00
Drew DeVault f62c755a9f Remove obsolete README translations
Everything which still mentioned wlc has been removed.
2019-04-25 11:18:05 -04:00
bschacht 8adb70f9c5 Set the correct version for wlroots dependency 2019-04-25 09:31:38 +03:00
Brian Ashworth 462ad4ea83 cmd_move: respect workspace layout when inserting
When moving a container to become a direct child of the workspace and
the workspace's layout is tabbed or stacked, wrap it in a container
with the same layout. This allows for the following:
- Run `layout tabbed|stacked` on an empty workspace (or use
  `workspace_layout tabbed|stacked` in the config)
- Open some views
- Move one of the views in any direction
- Open another view
- The new container should also be `tabbed`/`stacked`
2019-04-24 19:12:24 -06:00
Brian Ashworth dc7a3930a7 swaybar: add multiseat support
This just adds multiseat support to swaybar
2019-04-24 07:16:37 -06:00
Brian Ashworth 583ceff6f6 swaybar: hide mode visibility improvements
This allows swaybar to become visible when the mode changes (to any
mode other than the default). swaybar will be hidden again when the
modifier is pressed and released or when switching back to the default
mode.

This also applies the same logic to visible by urgency to hide swaybar
when the modifier is pressed and released.

These changes are to match i3's behavior.
2019-04-24 07:14:48 -06:00
Simon Ser b6e55064fe Update for wlroots#1660 2019-04-23 14:37:44 -06:00
Scott Anderson e3d94cb83e Fix uninitialized read for wlr_surface_send_frame 2019-04-21 14:06:15 +03:00
Maxime “pep” Buquet 20762ecb3c Validate icon_struct in read_theme_file
The read_theme_file function used to return an invalid icon_struct in
some cases, for example when an empty index.theme file was read.

This makes sure the struct we're returning is always valid as per the
Icon Theme specification.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-04-20 16:41:02 -04:00
Brian Ashworth 9099adbbe6 swaynag: revamp type configs
This revamps the type configs for swaynag. All sizing attributes for
swaynag are now `ssize_t` instead of `uint32_t` to allow for a default
value of `-1`, which allows for `0` to be a valid value. Additionally,
the initialization of the type configs has been changed from a simple
calloc to use a new function `swaynag_type_new`. `swaynag_type_new`
calloc's the memory, checks for an allocation failure, sets the name,
and all sizes to -1. The layering order has also been changed to
default, general config, type config, and as highest priority command
line arguments. Finally, `swaynag_type_merge` has been modified to
handle the layering and sizing changes.
2019-04-20 09:14:41 -06:00
Brian Ashworth 59d9a991b4 ipc: fix criteria for emitting bar_state_update
This fixes the criteria for emitting a `bar_state_update` event to
notify swaybar (and any other bars utilizing the event) on whether the
bar is visible by modifier. It is not enough to only emit the event
when both the bar mode and bar hidden state are `hide` since it is
possible to release the modifier while hidden state is `show` and then
change hidden state to `hide` without pressing the modifier. This also
emits the event whenever visible by modifier is set and should no
longer be regardless of the mode and state to ensure that it gets
properly cleared. If visible by modifier is not set and the bar is not
in `hide`/`hide`, then no events will be sent and visible by modifier
will not be set
2019-04-20 09:09:11 -06:00
Brian Ashworth 09595da0bc cmd_move: allow for all i3 syntax options
This modifies cmd_move to allow for the syntax options allowed by i3.
The following syntaxes are supported:
- `move left|right|up|down [<amount> [px]]`
- `move [--no-auto-back-and-forth] [window|container] [to] workspace
   <name>|next|prev|next_on_output|prev_on_output|current|number <num>`
- `move [window|container] [to] output <name/id>|left|right|up|down`
- `move [window|container] [to] mark <mark>`
- `move workspace to [output] <name/id>|left|right|up|down`
- `move [window|container] [to] [absolute] position <x> [px] <y> [px]`
- `move [window|container] [to] [absolute] position center`
- `move [window|container] [to] position mouse|cursor|pointer`

This also allows retains the following syntax option that is not
supported by i3, but is supported in sway 1.0:
- `move workspace [to] output <name/id>|left|right|up|down`

The changes are:
- `window` and `container` are now optional
- `output` is now optional for `move workspace` when `to` is given

There is also stricter command checking now. If `absolute` or
`--no-auto-back-and-forth` are given for commands that do not support
them, it will be treated as invalid syntax instead of being silently
ignored.
2019-04-19 08:39:57 -06:00
mwenzkowski 5e925f06e0 hide_edge_borders.c: add missing case for --i3
Disable the i3-compatible behavior if the option '--i3' is not given.
Previously it was only possible to disable it by changing the config
file. Now it also works via swaymsg.
2019-04-19 00:05:49 +03:00
Alex Maese 35ddd9aab3 Add unbindsym/unbindcode command for swaybar 2019-04-17 23:29:43 -04:00
Alex Maese 8d4f8aea46 Add unbindswitch command 2019-04-17 23:29:43 -04:00
Alex Maese 852f1f0b34 Create unbindsym and unbindcode commands 2019-04-17 23:29:43 -04:00
Brian Ashworth d7d29fe546 swaymsg: add timeout and type checks
This adds a 3 second timeout to the initial reply in swaymsg. This
prevents swaymsg from hanging when `swaymsg -t get_{inputs,seats}` is
used in i3. The timeout is removed when waiting for a subscribed event
or monitoring for subscribed events.

This also adds type checks to commands where i3 does not reply with all
of the properties that sway does (such as `modes` in `get_outputs`).

This is mostly just a behavioral adjustment since swaymsg should run on
i3. When running under i3, some command reply's (such as the one for
`get_outputs) may have more useful information in the raw json than the
pretty printed version.
2019-04-17 09:07:08 +03:00
Ashkan Kiani aa4deef8a8 Fix the payload type returned by IPC
If a client is subscribed and sends a subsequent ipc command which
causes event updates, then those event updates override the
`client->current_command` and send the incorrect type for the payload
associated with the command.

Example:

SUBSCRIBE {window}
RUN_COMMAND focus -> PAYLOAD_TYPE is 0x80000002 for window events

Therefore, we decouple the `client->current_command` by passing it as an
argument to the ipc_send_reply function, avoiding a data race. The same
is done for the `client->payload_length` as a precautionary measure for
the same reason.
2019-04-16 23:48:44 -04:00
mwenzkowski 9ac2342a67 Don't apply hide_edge_borders to floating windows
This change matches i3's behavior.
2019-04-16 17:05:49 -04:00
mwenzkowski e9e1fbc501 view.c: refactor view_autoconfigure() 2019-04-16 17:05:49 -04:00
Ashkan Kiani 2f9eed659d Add documentation for rename workspace 2019-04-16 07:34:07 -06:00
Ranieri Althoff fd6903673b Send disabled output available modes on IPC get_outputs
- Also fix missing trailing newline on pretty print

Signed-off-by: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com>
2019-04-16 00:16:20 -04:00
Connor E b2cfcebef6 Add deprecation warnings for new_float, new_window, and force_focus_wrapping. 2019-04-14 20:44:12 -04:00
Benjamin Cheng bd3720585e Implement input type configs (#3784)
Add support for configurations that apply to a type of inputs
(i.e. natural scrolling on all touchpads). A type config is
differentiated by a `type:` prefix followed by the type it
corresponds to.

When new devices appear, the device config is merged on top of its
type config (if it exists). New type configs are applied on top of
existing configs.
2019-04-14 19:31:36 -04:00
Benjamin Cheng 6737b90cb9 Add heuristics to differentiate touchpads
Use libinput_device_config_tap_get_finger_count to determine whether
a pointer is a touchpad.

swaymsg is also updated to reflect the new touchpad type.
2019-04-14 19:31:36 -04:00
Brian Ashworth 6961bf2e4c Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and
swaybg are already done
2019-04-14 12:41:59 +03:00
Brian Ashworth 8c69da11bb swaynag: fix pointer management
Currently on master, swaynag will retrieve a pointer instance whenever
the capabilities change and WL_SEAT_CAPBILITY_POINTER is set. The
pointer instances were never being destroyed so swaynag received events
multiple times due to having several instances of the pointer.

This fixes it so if there is already a pointer instance, swaynag does
not attempt to retrieve another. Additionally, if the pointer
capability is removed, the pointer instance is destroyed.
2019-04-14 10:24:19 +03:00
Brian Ashworth 69a1a0ff99 Fix scratchpad fullscreen behavior and crash
When setting fullscreen on a hidden scratchpad container, there was a
check to see if there was an existing fullscreen container on the
workspace so it could be fullscreen disabled first. Since the workspace
is NULL, it would cause a SIGSEGV. This adds a NULL check to avoid the
crash.

This also changes the behavior of how fullscreen is handled when adding
a container to the scratchpad or changing visibility of a scratchpad
container to match i3's. The behavior is as follows:
- When adding a container to the scratchpad or hiding a container back
  into the scratchpad, there is an implicit fullscreen disable
- When setting fullscreen on a container that is hidden in the
  scratchpad, it will be fullscreen when shown (and fullscreen disabled
  when hidden as stated above)
- When setting fullscreen global on a container that is hidden in the
  scratchpad, it will be shown immediately as fullscreen global. The
  container is not moved to a workspace and remains in the
  scratchpad. The container will be visible until fullscreen disabled
  or killed. Since the container is in the scratchpad, running
  `scratchpad show` or `move container to scratchpad` will have no
  effect

This also changes `container_replace` to transfer fullscreen and
scratchpad status.
2019-04-13 08:48:37 -06:00
Ashkan Kiani 913445e112 Fix potential null accesses 2019-04-13 08:35:17 -06:00
Simon Ser e7d6b8ec3e swaybg: add manpage 2019-04-13 10:26:17 -04:00
Ashkan Kiani 27f51360b7 Fix scratchpad logic for floating windows
When a tiled window is sent to the scratchpad, we want to use sane
defaults, which is to center it and resize it to the default.

For floating windows, we want to use their existing geometry.
2019-04-12 16:52:24 -04:00
Martin Michlmayr 090e101581 sway-input.5: add xkeyboard-config(7) to "see also"
Since xkeyboard-config(7) is mentioned in the man page, add a reference
to the "see also" section.
2019-04-12 21:45:13 +03:00
Brian Ashworth bd4c3957ba cmd_focus: raise floating for `<criteria> focus`
Floaters are currently raised for `focus <direction>`. This extends the
same functionality to `<criteria> focus`.
2019-04-11 09:19:45 -06:00
Brian Ashworth 195226120f Honor output for xdg_toplevel_set_fullscreen
This honors the fullscreen output request for
`xdg_toplevel_set_fullscreen` and `zxdg_toplevel_v6_set_fullscreen`.

If the request was sent before mapping, the fullscreen output request
will be retrieved from the client_pending state for the toplevel. The
output will be passed to `view_map` and if there is a workspace on the
output, the view will be placed on that workspace.

If the request comes in after being mapped, the view will be moved to
the workspace on the output (if there is one) before becoming
fullscreen.
2019-04-11 09:18:48 -06:00
Jan Beich e0324fc88c config/output: unbreak on 32-bit architectures
sway/config/output.c:624:54: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                sway_log(SWAY_DEBUG, "spawn_swaybg cmd[%ld] = %s", k, cmd[k]);
                                                       ~~~         ^
                                                       %zu
include/log.h:40:74: note: expanded from macro 'sway_log'
        _sway_log(verb, "[%s:%d] " fmt, _sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
                                                                                ^~~~~~~~~~~
2019-04-08 14:02:52 -06:00
Dmitri Kourennyi 4b892a79aa Add margin to short_text handling.
Add a 3xscale margin matching other spacing in swaybar as part of short
text width calculations
2019-04-04 14:14:08 -06:00
Dmitri Kourennyi 94dc57f3c5 Ensure predicted position for short text handling doesn't overflow.
- Predicted status line can be negative, so corresponding variables should
  not be unsigned. Changed to double as position is actually calculated as
  double.
2019-04-04 14:14:08 -06:00
Dmitri Kourennyi 0553e75b53 Implement handling of short_text field of i3 input protocol.
Matches i3bar behavior of setting all blocks to use the short_text if the full
text width does not fit.
2019-04-04 14:14:08 -06:00
Brian Ashworth 75e7bd24cc swaybg: one instance for all outputs
This makes it so there will only be one swaybg instance running
instead of one per output. swaybg's cli has been changed to a xrandr
like interface, where you select an output and then change properties
for that output and then select another output and repeat. This also
makes it so swaybg is only killed and respawned when a background
changes or when reloading.
2019-04-04 20:08:21 +03:00
Brian Ashworth 0ad905f23c idle_inhibit: fix crash during view destruction
This fixes a crash for application set idle inhibitors when their
associated view is being destroyed. There is a call to
`view_is_visible` to determine is the view is visible and it assumes
that the view has an container, but it is possible for the container
to already have been destroyed at this point. There is a NULL check for
the view in `check_active` and this re-adds the NULL check for the
container that I accidentally dropped when refactoring during the
inhibit_idle command PR
2019-04-03 19:46:08 +03:00
Brian Ashworth f0f20f96aa root_scratchpad_hide: fix crash when layer focused
This fixes a crash in `root_scratchpad_hide` when a layer surface is
focused. Since `seat_get_focus` is NULL when a layer surface is
focused, the call to `node_has_ancestor` was causing a SIGSEGV since it
was attempting to access the parent of NULL. This changes the call to
`seat_get_focus_inactive`, which will return a node even when a layer
surface is focused and is also guaranteed to have something in the
focus stack if a scratchpad container is being hidden (otherwise there
would not be any containers yet).
2019-04-03 19:45:17 +03:00
Dacheng Gao 1e1d9e1299 fix broken link to README.zh-CN.md 2019-04-02 10:35:21 +03:00
Dacheng Gao 5e0a928201 fix typo 2019-04-02 08:42:10 +03:00
Drew DeVault f3140506a8 Update formatting of zh-cn link in README.md 2019-04-01 10:56:56 -04:00
Dacheng Gao 4938da2a34 add link to README-zh-CN 2019-04-01 08:55:49 -06:00
Dacheng Gao 078935ac88 fix cs 2019-04-01 08:55:49 -06:00
Dacheng Gao 3353bb5832 fix cs 2019-04-01 08:55:49 -06:00
Dacheng Gao a32125c984 add chinese translation 2019-04-01 08:55:49 -06:00
Brian Ashworth 679c058fac scratchpad: set initial size
This matches i3's behavior of setting scratchpad containers to 50% of
the workspace's width and 75% of the workspace's height, bound by the
minimum and maximum floating width/height.
2019-03-31 17:49:05 -06:00
Brian Ashworth 0676ace97f floating: fix size of non-view containers
This fixes the sizing of floating non-view containers. On master, the
floater will get set to the maximum width and height, which by default
is the entire output layout. When setting a non-view container to
floating, this will set a sane default size of 50% of the workspace
width and 75% of the workspace height, or whatever the closest is that
the minimum and maximum floating width/height values allow for. On all
future calls to `floating_natural_resize`, the width and height will be
kept unless they need to be changed to respect the min/max floating
width/height values.
2019-03-31 17:49:05 -06:00
Brian Ashworth dd28e6a6d6 Fix xwayland configure request scratchpad crash
This fixes a crash in `container_init_floating` when a xwayland view
sends a configure request while in the scratchpad.

`container_init_floating` gets called so the configured minimum and
maximum sizes gets respected when resizing to the requested size. Since
the workspace was NULL, it would SIGSEGV when attempting to get the
workspace's output for the output box retrieval.

This extracts the resizing portion of `container_init_floating` into a
separate function. If the container is in the scratchpad, it will just
be resized and skip the centering.

Additionally, `container_init_floating` has been renamed to
`container_floating_resize_and_center` to more accurately describe what
it does.
2019-03-31 09:32:23 +03:00
Alex Maese 31eeda11b0 Fix a crash in swaybar when an icon dir is not readable 2019-03-30 20:13:34 +02:00
Ryan Dwyer 2cae0d5e3a Fix null pointer crash when doing tiling drag
* Create layout S[V[view view] view]
* Drag bottom view to the top
* Sway would crash when the cursor hovers the V[view view] title while
dragging
2019-03-29 09:26:06 -06:00
Jan Pokorný bfdee1319f bindings: fix overwrite log argument mismatch
Thanks, @RedSoxFan, for the review spotting another instance.
2019-03-27 12:07:52 -04:00
Ashkan Kiani 3a31889d7c Fix crash for floating command on scratchpad window 2019-03-26 23:38:23 -04:00
Igor Sviatniy e9d096468a Update README.uk.md 2019-03-26 07:25:02 -06:00
Brian Ashworth d9de5b8758 Implement inhibit_idle command
This implements the following command to set/unset a user idle
inhibitor for a view:
`inhibit_idle focus|fullscreen|open|none|visible`

The modes are as follows:
- focus: inhibited when the view is focused by any seat
- fullscreen: inhibited when the view is fullscreen (or a descendant of
  a fullscreen container) and is visible on any output
- open: inhibited until the view is closed or the inhibitor is unset or
  changed
- none: unsets any user set idle inhibitors for the view
- visible: inhibited when the view is visible on any output

This should have no effect on idle inhibitors set by the applications
themselves and those should still work as intended.

Since this operates on the view in the handler context, it is possible
to set it on the currently focused view, on any existing view with
criteria, or for any future view with for_window.
2019-03-24 19:26:12 -06:00
Philipe Goulet 8d2c982f3f Fix #3924
Removes "unescape_string(argv[i]);".

Since "do_var_replacement(argv[i])" never adds escape
characters, it is both wrong and unnecessary to remove escape characters
on the next line.

This caused characters that were meant to be escaped to not be anymore.
2019-03-24 19:04:15 -06:00
Philz69 c3d7036867 Updated the french readme (#3964)
* Updated the french readme

Removed the image at the start of the readme.
Removed the mention of bounties.
Updated the dependencies.
Removed a few lines that were not present in the english readme anymore.

* Fix errors.

Fixed capitalisation.
Changed "root" to italics.
2019-03-24 21:19:13 +02:00
Geoff Greer 6e3046878d Add support for manually setting subpixel hinting on outputs.
Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this.

Addresses https://github.com/swaywm/sway/issues/3163
2019-03-24 09:37:24 +02:00
mliszcz 200833caae Allow for workspace renaming during exec handling
This change adds support for renaming a workspace when `exec` command
is being processed by keeping sway_workspace and pid_workspace names in
sync.

The change can be verified by running following command:

swaymsg exec <application>; swaymsg rename workspace number 1 to 5

Fixes: #3952
2019-03-23 17:49:27 -04:00
Brian Ashworth cd8b4ace92 fix opening a floating view on the NOOP output
Since the NOOP output has no size, the minimum floating size is greater
than the workspace size for the NOOP output. In this case, the floater
gets centered in the output instead of the workspace. However, the
NOOP output is not part of the output layout and thus has a NULL box.
Attempting to access the properties of this box was causing a segfault.

This fixes the issue by just setting the floater's box to all zeroes
when mapping on the NOOP output. When the workspace gets moved from the
NOOP output to a new output, any floater whose width or height is zero
or has an x or y location outside of the output, gets passed to
`container_init_floating` again. This will then set the appropriate
size and centering. For any floater that has a valid size and location,
they are preserved.
2019-03-23 23:39:42 +02:00
Brian Ashworth 7d2076cbff criteria: fix __focused__ when no focus or unset
This fixes the behavior of `__focused__` when there is no focused view
to match i3's behavior of successfully matching no views instead of
returning an error of a missing value. It also applies the same logic
when a token is not applicable (or unset) for a view such as `app_id`
for a focused xwayland view or `class` for a focused xdg-shell view.

This adds an `autofail` boolean to `struct criteria`. If it is set to
`true`, then `criteria_matches_view` will immediately bail out as a
no match. If `autofail` is set, the criteria will also not be
considered empty by `criteria_is_empty`.

To set this new `autofail` property, `get_focused_prop` will now take
in a boolean pointer of the same name. If `__focused__` is supported
for the token and there is no focused view or the focused view does not
have a value for the token, then the boolean will be set to true. In
`parse_token`, the boolean value will be checked and if set to true,
then `criteria->autofail` will be set to true and `parse_token` will
bail successfully. Tokens will still be parsed to make sure the whole
criteria is syntactically valid, which is also why
`&criteria->autofail` is not passed to `get_focused_prop` and a local
boolean is declared in `parse_token`.
2019-03-23 09:53:23 +02:00
Brian Ashworth 8cd7f0171a cmd_mode: allow cmd_set to be a subcommand
This allows set to be used in mode blocks
2019-03-23 08:07:25 +02:00
Ryan Dwyer cdcc2a5bb5 Support focus <direction> for floating containers
This kind of worked before in that focus would change, but it wasn't
intentionally supported and had side effects such as not raising
the container, and being unable to cycle through all floaters depending
on the direction used.

This commit makes it properly supported. The new focus is chosen based
on the distance to the center point of each floating container in the
workspace, and the container is raised.

In a multi output setup, if both visible workspaces have floating
containers, focus will NOT cross into the other output. It is assumed
the user will use a workspace binding in this case.

If two floating containers occupy the exact same center point and you
try to focus in a direction, the behaviour is undefined.
2019-03-20 08:55:28 -06:00
Ryan Walklin bdb402404c Support WLR_INPUT_DEVICE_SWITCH in sway
This commit adds support for laptop lid and tablet
mode switches as provided by evdev/libinput and
handled by wlroots.

Adds a new bindswitch command with syntax:
bindswitch <switch>:<state> <command>

Where <switch> is one of:
tablet for WLR_SWITCH_TYPE_TABLET_MODE
lid for WLR_SWITCH_TYPE_LID

<state> is one of:
on for WLR_SWITCH_STATE_ON
off for WLR_SWITCH_STATE_OFF
toggle for WLR_SWITCH_STATE_TOGGLE

(Note that WLR_SWITCH_STATE_TOGGLE doesn't map to
libinput and will trigger at both on and off events)
2019-03-19 23:58:47 -04:00
Ryan Dwyer bfa20e65d8 Clean up focus follows mouse logic
Firstly, this fixes a recent regression where having
`focus_follows_mouse yes` and hovering an inactive tab caused it to gain
focus. The code was missing a view_is_visible check.

The code is handling the logic for both focus_follows_mouse yes and
focus_follows_mouse always, where the latter will apply when nudging the
mouse after a workspace switch. However, the view_is_visible check
didn't apply when using focus_follows_mouse always, so hovering a tab
with that configuration would cause is to focus. This was a bug. When
adding the view_is_visible check, it now applies to both yes and always.

Note that the comment about the split container was wrong. At this point
the hovered node cannot be a split container because it passed the
node_is_view check. The comment has been removed.

Lastly, the else condition is completely removed. This didn't appear to
have any practical use. Setting focus to the result of
seat_get_focus_inactive is very likely going to be a no op. There is a
slim chance that this will break something, and if so I'd like to find
out what so it can be properly documented in the code.
2019-03-19 14:38:06 -06:00
Ryan Dwyer e9a476244d Remove debug tree
This feature has served its purpose. It's better to use IPC now.
2019-03-18 11:29:19 -04:00
Ryan Dwyer 38bd60c4b3 Document the title_format command 2019-03-18 11:27:36 -04:00
Brian Ashworth 0327c999d7 config/output: handle wildcard in get_output_config
In #3916, I overlooked that `get_output_config` does not handle
wildcards unless the config is reloading, which is a remnant of older
iterations of the output config handling that went unnoticed due to
`output_find_config` handling it. With the current version of the
output config handling, having `get_output_config` handle wildcard
configs is actually preferable. This fixes having only a wildcard
output config in the config file or when connecting/enabling a new
output with only a wildcard config existing.
2019-03-17 18:05:27 +02:00
Ryan Dwyer 7b9ae42331 Introduce default seatop
This introduces a `default` seat operation which is used when no mouse
buttons are being held. This means there is now always a seat operation
in progress. It allows us to separate `default` code from the standard
cursor management code.

The sway_seatop_impl struct has gained callbacks `axis`, `rebase` and
`end`, and lost callbacks `finish` and `abort`. `axis` and `rebase` are
only used by the default seatop. `end` is called when a seatop is being
replaced by another one and allows the seatop to free any resources,
though no seatop currently needs to do this. `finish` is no longer
required, as each seatop can gracefully finish in their `button`
callback. And `abort` is not needed, as calling `end` would achieve the
same thing. The struct has also gained a bool named allow_set_cursor
which allows the client to set a new cursor during `default` and `down`
seatops.

Seatops would previously store which button they were started with and
stop when that button was released. This behaviour is changed so that it
only ends once all buttons are released. So you can start a drag with
$mod+left, then click and hold right, release left and it'll continue
dragging while the right button is held.

The motion callback now accepts dx and dy. Most seatops don't use this
as they store the cursor position when the seatop is started and compare
it with the current cursor position. This approach doesn't make sense
for the default seatop though, hence why dx and dy are needed.

The pressed_buttons array has been moved from the sway_cursor struct to
the default seatop's data. This is only used for the default seatop to
check bindings. The total pressed button count remains in the
sway_cursor struct though, because all the other seatops check it to
know if they should end.

The `down` seatop no longer has a `moved` property. This was used to
track if the cursor moved and to recheck focus_follows_mouse, but seems
to work without it.

The logic for focus_follows_mouse has been refactored. As part of this
I've removed the call to wlr_seat_keyboard_has_grab as we don't appear
to use keyboard grabs.

The functions for handling relative motion, absolute motion and tool
axis have been changed. Previously the handler functions were
handle_cursor_motion, handle_cursor_motion_absolute and
handle_tool_axis. The latter two both called cursor_motion_absolute.
Both handle_cursor_motion and cursor_motion_absolute did very similar
things. These are now simplified into three handlers and a single common
function called cursor_motion. All three handlers call cursor_motion. As
cursor_motion works with relative distances, the absolute and tool axis
handlers convert them to relative first.
2019-03-17 10:02:04 -06:00
Ryan Dwyer fb3475e291 Replace seatup allows_events with button callback 2019-03-17 10:02:04 -06:00
Brian Ashworth 73605dac2a config/output: revamp identifier/name layering
This revamps the way that output configs are handled when referencing
an output by both identifier and name. If an output is always referred
to by name or by identifier, this should have no noticeable change. As
soon as there is a name output config and an identifier output config
that matches an output, an output config is generated that is named
`<identifier> on <name>` that is generated with the identifier output
config merged on top of the name output config and stored. When a
change to either is stored, the delta is merged on top of that
"id on name" output config, as well. If the "id on name" output config
exists, it has the highest precedence and will be used when applying
a config to the output.

This fixes the following case:
- `swaymsg output <name> bg /path/to/wallpaper1 fill`
- `swaymsg output <identifier> bg /path/to/wallpaper2 fill`
- `swaymsg output <name> dpms on`

Without this, the wallpaper is changed to `/path/to/wallpaper1`. With
this, the wallpaper remains `/path/to/wallpaper2`.
2019-03-16 10:41:02 -06:00
Brian Ashworth 3106ef23a7 Fix output config retrieval for new outputs
This removes `output_find_config`, which would take the first matching
output config it found. This is fine if only a name output config,
identifier output config, or even just wildcard exist, but if there is
a name output config and identifier output config, they are not merged.
Instead, this introduces find_output_config, which is just a wrapper
for `get_output_config`. This ensures that both the name and identifier
output configs are respected.

This fixes the following case:
- For simplicity in this example, remove all output configs from config
- Run `swaymsg output <name> bg #ff0000 solid_color`
- Run `swaymsg output <identifier> scale 2`
- Disconnect and reconnect output

Without this, the output will have the background, but not the scale.
With this, the output will have both the background and scale
2019-03-16 10:40:46 -06:00
Flakebi 2578669de7 Flush stdout in swaymsg when in subscribe mode 2019-03-16 12:32:09 -04:00
minus 264e213c08 Fix quoting of commands passed to for_window
E.g. `for_window [class="mpv"] move container to output "Dell Inc. ..."`
does not work because the executed move command only uses `Dell` as
output name.
2019-03-15 14:52:38 -04:00
Brian Ashworth e687e120e0 output_cmd_background: validate colors
This validates the color and fallback color in `output_cmd_background`
to ensure that only colors of the form `#RRGGBB` are accepted.
2019-03-15 09:50:10 +02:00
Brian Ashworth d8f74e4706 Set prev_workspace_name based off of focus
This moves setting `seat->prev_workspace_name` from `workspace_switch`
to `set_workspace`. `workspace_switch` is only called when using a
`workspace` command to change the workspace so any workspace change
based on criteria was not altering `seat->prev_workspace_name`. By
moving it to `set_workspace`, which is called by `seat_set_focus`, it
will change any time focus changes to a node on a different workspace
2019-03-14 10:03:45 -06:00
Stephan Hilb d64e8ba946 swaybar: fix loading of malformed icon theme
If the icon index.theme contained a key-value pair without a preceding
group header, entry_handler() would be called with a zero pointer and
lead to a segfault.
Set the error flag and break on such malformed files.
2019-03-13 22:04:04 -06:00
Brian Ashworth acdb4ed7a3 xwayland: handle floating configure request size
This makes it so the container gets resized by a configure request for
xwayland floating views. The minimum and maximum sizes are also
respected. Previously, the configure request was resizing the surface
to the size requested, but never changing the container size. This
caused the surface to be rendered outside of the container or to be
smaller than the container. The former is never ideal and the latter
makes no sense for floating views since the container itself can just
be shrunk.
2019-03-13 09:06:04 +01:00
Brian Ashworth 52a61671e9 criteria: change workspace to support regex
This changes the workspace criteria to support regex instead of basic
strings. This matches i3's behavior.
2019-03-12 20:52:09 -06:00
Brian Ashworth 3330faded5 Handle seat_get_focused_workspace returning NULL
This modifiers the callers of seat_get_focused_workspace to handle
getting NULL as the return value, if they did not already.
2019-03-12 19:14:04 +01:00
3ap a280facd5f config.in: allow launch apps with args via dmenu
Without this change you can't execute apps with command line arguments (e.g. firefox -P profile) because -P will be parsed as argument for "swaymsg exec".
2019-03-12 08:16:45 -06:00
Brian Ashworth 1bab5a9553 get_deco_rect: fix floaters on tabbed/stacked ws
This fixes the decoration rects for floating containers on a workspace
that is either tabbed or stacked. Without this, the floater would
incorrectly try to calculate where it's tab or stack decorations were
on the workspace. This would cause a SIGFPE (due to a divide-by-zero)
when the floater was on a tabbed workspace without any tiling children.
Furthermore, the floater does not care what the workspace's layout is
and should just use the location relative to the workspace. This should
have no effect on children of a floating container.
2019-03-11 21:31:47 -06:00
Peter Grayson 79369681ab Repair swaynag crash reading message from stdin
When swaynag is run with the -l/--detailed-message option, a crash may
occur if the detailed message read from stdin is large enough. E.g.:

    swaynag -m hello -l < ~/.config/sway/config

The root cause is that the read_from_stdin() function under-allocates
memory for the destination buffer which causes that buffer to be overflowed
when copying line data to it with snprintf().

The repair is to allocate one more byte for the terminating null byte.

N.B. although getline() returns the number of bytes read excluding a
terminating null byte, the line buffer is terminated with a null byte. Thus
we have a guarantee that the line buffer will be null terminated (which is
important when copying with snprintf()).
2019-03-11 23:00:39 -04:00
Ian Fan 055d662baa commands: allow tiled sticky containers to be moved
Namely, to a workspace on the same output.
However, tiled sticky children of floating containers are still restricted.
2019-03-11 21:49:37 -04:00
emersion 076257a978 Stop using wlr_output->{lx,ly}
Also fixes sway_output->{lx,ly,width,height} not being updated. Also fixes
output_get_in_direction adding buffer coords to layout coords.
2019-03-11 12:43:01 -04:00
emersion bcde298a71 Fix size_t temporary underflow in log_loaded_themes
`len` will underflow but will overflow right after, so it's not as bad as it
may appear. Still better not to under/overflow at all.

Fixes https://github.com/swaywm/sway/issues/3862
2019-03-11 12:12:46 -04:00
Ryan Dwyer 783b3d6b37 Fix click behaviour
By the time seatop_allows_events was called, seatop_impl was already
NULL, causing the function to always return false. This means a press
event was sent to clients without a corresponding release event.

This patch moves the call to seatop_finish to after the
seatop_allows_events check.
2019-03-11 14:55:54 +01:00
Ryan Dwyer d16845d5f0 Don't send button events to surfaces when dragging or resizing
It turns out sending button events during all seat operations is not
desirable. This patch introduces a new property
`seatop_impl.allows_events` which allows each operation to define
whether button events should be passed to the surface or not.

The `down` seat operation is the only one that supports this. As all the
other seatops don't support it, the calls to seat_pointer_notify_button
prior to starting them have been removed.
2019-03-11 14:55:54 +01:00
Ian Fan 00570c139e stringop.c: refactor a few functions 2019-03-11 14:42:58 +01:00
Ian Fan be1543d301 stringop.c: clean up headers 2019-03-11 14:42:58 +01:00
Ian Fan 5c8424c074 stringop.c: remove unused functions
The only use of `join_list` in swaybar/tray/icon.c has been rewritten.
2019-03-11 14:42:58 +01:00
Brian Ashworth 017a7c4da1 sway_view_child: add listener for view unmap
Since not all child views's have an unmap event, it is possible for it
to still be mapped (default state) in the destruction handler. When
the destruction handler is called, the corresponding view may have
already been freed and the memory location reallocated. This adds a
listener for the view unmapping and removes the mapped status. This
ensures that the child view is damaged due to destruction while the
view still exists and not after.
2019-03-11 10:02:52 +01:00
Brian Ashworth 20c4d242f6 detect_proprietary: use strncmp
Only the main nvidia module needs to be blocked. Others such as
nvidiafb are benign and do not need to be blocked
2019-03-10 22:16:09 -06:00
Brian Ashworth a729bda17f fullscreen: init floating on disable without size
If a container gets mapped as fullscreen and set to floating by
criteria, the size and location are never set for the floating
container. This adds a check in container_fullscreen_disable for a
width or height of 0 and calls container_init_floating
2019-03-10 23:55:22 +01:00
emersion a418349c18 meson: use pkg-config var for scdoc path 2019-03-10 18:18:08 -04:00
Ben Challenor 30931ad9e7
Make raw keysyms take precedence over translated
Allows both BackSpace and Shift+BackSpace to be bound under the US
keyboard layout, per #3705.
2019-03-10 23:01:49 +01:00
emersion 191305468c Fix crash in cmd_workspace when layer surface has focus 2019-03-10 14:59:34 -06:00
Drew DeVault 83b68b2154 Update language in sway.desktop & sway(1) 2019-03-10 15:09:52 -04:00
Brian Ashworth 9a75f0010f arrange: use int not size_t for title offsets
This changes `apply_tabbed_layout` and `apply_stacked_layout` to use
`int` instead of `size_t`. This is necessary for tabbed and stacked
containers to be positioned correctly when the y-location is negative.
The reasoning for this is signed plus unsigned is always an unsigned
value. This was causing the y-location of the container to be
positioned near `INT_MIN` due to an unsigned integer underflow
2019-03-10 13:07:32 -06:00
Brian Ashworth c02d2a0128 damage: remove output_damage_view
This removes `output_damage_view` since it is unnecessary. The logic
has been moved into its only caller `output_damage_from_view`. When
damaging the whole view, `output_damage_whole_container` should be used
instead
2019-03-10 01:23:03 +01:00
Brian Ashworth 7580718d12 output_damage_whole_container: damage subsurfaces
This adds an iterative call in `output_damage_whole_container` to
damage the subsurfaces for all visible views that are inside of the
container. This is needed to damage subsurfaces that extend outside the
box of the container. Without this, those subsurfaces will create
artifacts when moving or resizing.
2019-03-10 01:20:36 +01:00
Jeff Peeler a73e8f1328 fix "directive argument is null" errors 2019-03-09 14:59:28 -07:00
minus 5fab8a2ad4 Fix crash when moving window to scratchpad 2019-03-09 11:21:41 +01:00
Peter Grayson 1a9145e409 Add missing swaymsg completions
The `-m/--monitor` option was missing from the bash and fish completions.

The `subscribe` IPC message type was missing from the bash, fish, and zsh
completions.

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2019-03-08 15:28:35 -05:00
Peter Grayson b7fe5097e9 Add -p/--pretty option to swaymsg
This new option forces pretty (non-raw/non-JSON) output. By default, when
not using a tty, swaymsg outputs using the "raw" format. This makes it
impossible to, for example, pipe the pretty output to a pager such as
`less` since piping does not use a tty.

The new -p/--pretty option gives the user explicit control over the output
format while retaining the default tty-dependent behavior.

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2019-03-08 14:29:39 -05:00
Brian Ashworth 7f700e08ac ipc: describe libinput device configuration
This adds the device configurations to the ipc response for libinput
devices. Only supported configuration options for the device will be
added. This also moves `libinput_send_events` inside a new `libinput`
object that contains the rest of the configuration options. sway-ipc(7)
has been updated to reflect the changes and document the new additions.
2019-03-07 08:41:19 -07:00
Brian Ashworth 0df76ed96a ipc: fix fullscreen deco_rect
This fixes the deco_rect reported by the ipc for fullscreen containers
to be all zeroes. Children of the fullscreen container should still
have their decorations reported correctly
2019-03-06 10:49:45 -07:00
Brian Ashworth 8ada2daba5 ipc: fix rect for stacked children
This now takes all titlebars for stacked children into account for the
ipc property `rect`
2019-03-06 10:49:32 -07:00
emersion 8b6bd106aa Fix container_parent_layout for scratchpad windows 2019-03-06 11:50:23 -05:00
Brian Ashworth 19df2e5906 ipc: change {,deco_}rect to match i3
This fixes the `deco_rect` and `rect` properties in the IPC responses
to match i3's behavior.

`deco_rect` should be relative to the parent node, not the current
node. This also takes tabbed and stacked decorations into account and
will calculate `deco_rect` for all containers since tabbed and stacked
child containers will have decorations.

`rect` should exclude the window decorations.
2019-03-06 10:05:00 +01:00
emersion a6711740bc Set DISPLAY after initializing Xwayland
This is necessary after https://github.com/swaywm/wlroots/pull/1596
2019-03-04 21:16:00 +01:00
Brian Ashworth 3f184cf188 meson: update scdoc requirement to >= 1.9.2
Since scdoc 1.9.1 is bugged, this updates the meson version check to
>= 1.9.2 and drops the version requirement from the README. This should
make it more obvious to users who have 1.9.1 that they need to update
scdoc to be able to compile man pages and hopefully cut down on the
duplicate issues
2019-03-04 08:44:17 -07:00
Ryan Dwyer bdac0df4f8 Allow concurrent clicks
If two cursor buttons are pressed at the same time, the client will now
be notified of the second button press.

The main reason for not sending the concurrent presses was due to an
early return in dispatch_cursor_button if a seatop is in progress. This
patch makes it call seat_pointer_notify_button prior to returning. But
it also has to make sure there's not a mismatch in events such as a
release without a press.

Prior to this patch, the down seatop would send press and release events
in its begin and finish functions. No other seatops did this. A press
event would be sent prior to starting tiling drag, but never an
associated release.

After this patch, no seatops send their own press or release events. We
send them prior to calling the seatop begin functions, then the first
part of dispatch_cursor_button handles all presses during seatops and
when releasing the seatop.
2019-03-04 07:51:22 -07:00
Brian Ashworth a053823f39 sway.1.scd: document environment vars set by sway
This just documents the few environment variables set by sway in
sway.1.scd
2019-03-03 18:47:32 +01:00
Brian Ashworth 23f075e71d render_floating: skip fullscreen floaters
If a floater is fullscreen either on a workspace or globally, it
should not be rendered on any output is is not fullscreened on. When
rendering it on an output it should not be rendered on, there will be
an extraneous border along the adjacent side of the output. This adds
a check in render_floating to skip all fullscreened floaters
2019-03-03 09:25:10 +01:00
Noam Preil 1c329f2fe6 Fixes crash in spawn_swaybg (closes #3733) 2019-03-03 01:08:05 +01:00
Brian Ashworth 430359519c floating_maximum_size: change default behavior
This changes the way zero (which is the default) is interpreted for both
the width and height of `floating_maximum_size`. It now refers to the
width and height of the entire output layout, which matches i3's
behavior.

This also removes duplicated code to calculate the floating constraints
in three files. Before this, `container_init_floating` used two-thirds
of the workspace width/height as the max and the entire workspace
width/height was used everywhere else. Now, all callers use a single
function `floating_calculate_constraints`.
2019-03-02 09:10:26 +01:00
hugbubby 37f0e1f1a2 Minor fix of code duplication.
Removes 3~ lines of code that didn't need to be restated.
2019-03-02 00:49:02 +01:00
emersion 77b16a5124 ci: use scdoc-git because 1.9.1 is broken 2019-03-01 12:32:00 -07:00
emersion f98410c090 meson: check scdoc version 2019-03-01 10:25:47 -05:00
emersion 88b283c557 seat: don't send button release when not pressed
All seat operations except "down" eat the button pressed event and don't send
it to clients. Thus, when ending such seat operations we shouldn't send the
button released event.

This commit moves the logic used to send pressed/released into the "down"
operation.
2019-02-28 23:02:06 -05:00
Ian Fan 416c6ecb99 tray: fix pixmap colors
by converting from network byte order to host byte order
2019-02-28 18:31:52 +01:00
Drew DeVault 6728db28a2
Merge pull request #3790 from RedSoxFan/sway-ipc-clarify-window-rect
sway-ipc.7: clarify window_rect omits decorations
2019-02-27 22:20:16 -05:00
Brian Ashworth 56217bfbc0 sway-ipc.7: clarify window_rect omits decorations
According to the i3 ipc documentation, `window_rect` excludes the window
decorations from the calculation. This just clarifies that in
`sway-ipc.7.scd`
2019-02-27 22:11:58 -05:00
emersion 4431ae68fc Add output dpms to manpage 2019-02-27 16:33:03 -05:00
Drew DeVault 9f58b27d86
Merge pull request #3766 from RedSoxFan/sway-ipc-scdoc
Add sway-ipc.7.scd to document IPC protocol
2019-02-27 16:01:55 -05:00
Drew DeVault 51d27d1549
Merge pull request #3786 from emersion/wlroots-version
Set minimum wlroots version
2019-02-27 16:01:27 -05:00
Drew DeVault aea33551fb
Merge pull request #3787 from emersion/meson-print-features
Print Meson features
2019-02-27 16:00:28 -05:00
emersion 6658d69271
Print Meson features 2019-02-27 21:26:50 +01:00
emersion 8228fa60d4
Set minimum wlroots version 2019-02-27 21:13:16 +01:00
Brian Ashworth f876009c7f Add sway-ipc.7.scd to document IPC protocol
This add `sway-ipc.7.scd` that documents the IPC protocol.

This also increased the minimum scdoc version from 1.8.1 to 1.9.0 to
allow for table cells to be continued on the following line
2019-02-27 13:23:10 -05:00
Rouven Czerwinski d016848bce config: remove double assignement to result in get_output_config 2019-02-27 00:35:51 -05:00
Rouven Czerwinski 4e028dba47 cursor: intitialize sx and sy to zero
If node_at_coords does an early return without setting these values, they can be
used uninitialized later. Initialize both to zero.
2019-02-27 00:35:51 -05:00
Rouven Czerwinski 35d610a43c cursor: remove unused node assignement
The node variable is not used before its reassigned later in the function,
remove the assignement.
2019-02-27 00:35:51 -05:00
Brian Ashworth efe370ba12 execute_command: do not strip qoutes for cmd_mode
`cmd_mode` performs its own quote stripping for the mode string to
avoid double stripping quotes for `cmd_bindcode` and `cmd_bindsym` in
`config_command` and `execute_command`. Stripping quotes in
`execute_command` for `cmd_mode` will also result in double stripping,
which will cause issues for any mode string with spaces, such as pango
markup.
2019-02-26 08:06:50 +01:00
Carlo Abelli b00b0fb9d3 fix smart_borders description in manual
The wording for smart_borders was opposite the actual behavior.
2019-02-25 14:52:29 -05:00
Connor E 9032be4f08 Allow 0 degree transform (normal transform). 2019-02-25 11:28:29 +01:00
Milkey Mouse 2f7247e08a swaybar: add overlay mode (fix #1620)
Overlay mode puts the bar above normal windows and passes through/ignores any
touch/mouse/keyboard events that would be sent to it.
2019-02-24 20:05:47 -05:00
db 2510e3df38 add --i3 flag to hide_edge_borders
Enables i3-compatible behavior regarding hiding the title bar on tabbed and
stacked containers with one child.

Related issues and merge requests: #3031, #3002, #2912, #2987.
2019-02-24 15:26:37 -05:00
Connor E d4b1e71b91 Make load_include_configs void. Fix some cases where WD would not be restored. 2019-02-24 00:01:35 -05:00
minus 713883f04c Fix crash exiting fullscreened floating container
container_floating_move_to_center and container_fullscreen_disable were
calling recursively when the container spawned as a fullscreen floating
container (via for_window). Such a window now doesn't crash sway anymore
but is still configured with a wrong, zero size, making it not directly
usable.
2019-02-23 21:40:03 -05:00
Caleb Bassi f84ac3f114 ipc: add missing fields to disabled outputs
i3 requires all outputs to have certain fields, including 'primary', 'current_workspace', and 'rect' which were missing on disabled outputs.

https://i3wm.org/docs/ipc.html#_outputs_reply
2019-02-23 20:27:59 +01:00
Drew DeVault d1588e3739 swaybar: cycle workspaces on touch drag 2019-02-23 20:00:20 +01:00
Drew DeVault 4599907de7 swaybar: process hotspots on touch tap 2019-02-23 20:00:20 +01:00
Drew DeVault 512619a9a1
Merge pull request #3700 from emersion/refactor-dnd
Update for swaywm/wlroots#1517
2019-02-23 13:15:38 -05:00
emersion 656541bcc4
Update for swaywm/wlroots#1517 2019-02-23 19:04:10 +01:00
Brian Ashworth 9350a52c0e handle_seat_node_destroy: update seat->workspace
If an unmanaged or layer surface is focused when an output gets
disabled and an empty workspace on the output was focused by the seat,
the seat needs to refocus it's focus inactive to update the value of
`seat->workspace`.
2019-02-23 09:21:19 +01:00
Tim Sampson cdf30033af fish: improve completions a little bit 2019-02-23 09:17:02 +01:00
Brian Ashworth bcec866c6b handle_layer_shell_surface: do not use noop output
If the noop output is focused (all other outputs disabled/disconnected),
do not auto assign a layer surface to it. The noop output is not enabled
and does not have the `output->layers` list initialized. It also does
not make sense to map the layer surfaces to something that is not
visible.
2019-02-23 09:15:35 +01:00
Rouven Czerwinski 3ead287064 view: set xdg_decoration->view to NULL, check decoration destroy
Fixes heap-use-after-free:

==32046==ERROR: AddressSanitizer: heap-use-after-free on address 0x615000064d20 at pc 0x55571ce4d303 bp 0x7fff545c64c0 sp 0x7fff545c64b0
WRITE of size 8 at 0x615000064d20 thread T0
    #0 0x55571ce4d302 in xdg_decoration_handle_destroy ../sway/xdg_decoration.c:13
    #1 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #2 0x7f64009d3c46 in toplevel_decoration_handle_resource_destroy ../types/wlr_xdg_decoration_v1.c:65
    #3 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)
    #4 0x7f6400a19fed in wl_resource_destroy (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7fed)
    #5 0x7f64009d3d1f in toplevel_decoration_handle_surface_destroy ../types/wlr_xdg_decoration_v1.c:82
    #6 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #7 0x7f64009b059c in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:453
    #8 0x7f64009b0688 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:483
    #9 0x7f64009af08c in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #10 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)
    #11 0x7f6400a1e211  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0xc211)
    #12 0x7f6400a1e6fe  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0xc6fe)
    #13 0x7f6400a1a0ec in wl_client_destroy (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x80ec)
    #14 0x7f6400a1a1c4  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x81c4)
    #15 0x7f6400a1b941 in wl_event_loop_dispatch (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x9941)
    #16 0x7f6400a1a569 in wl_display_run (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x8569)
    #17 0x55571ce4c7fd in server_run ../sway/server.c:214
    #18 0x55571ce4ad59 in main ../sway/main.c:405
    #19 0x7f640071109a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #20 0x55571ce2cfa9 in _start (/usr/local/bin/sway+0x35fa9)

0x615000064d20 is located 32 bytes inside of 504-byte region [0x615000064d00,0x615000064ef8)
freed by thread T0 here:
    #0 0x7f6401531b70 in free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedb70)
    #1 0x55571ce6c72b in destroy ../sway/desktop/xdg_shell.c:252
    #2 0x55571cee3f7b in view_destroy ../sway/tree/view.c:60
    #3 0x55571cee4090 in view_begin_destroy ../sway/tree/view.c:73
    #4 0x55571ce6dd95 in handle_destroy ../sway/desktop/xdg_shell.c:464
    #5 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #6 0x7f64009b059c in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:453
    #7 0x7f64009b0688 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:483
    #8 0x7f64009af08c in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #9 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)

previously allocated by thread T0 here:
    #0 0x7f6401532138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
    #1 0x55571ce6df39 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:485
    #2 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7f64009b0167 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:350
    #4 0x7f64009ce2a5 in surface_commit_pending ../types/wlr_surface.c:372
    #5 0x7f64009ce523 in surface_commit ../types/wlr_surface.c:444
    #6 0x7f63ff63ddad in ffi_call_unix64 (/usr/lib/x86_64-linux-gnu/libffi.so.6+0x5dad)

Fixes #3759
2019-02-23 03:03:03 -05:00
Brian Ashworth f078a1ccb8 input/cursor: allow whole-window bindings on ws
To match i3's behavior, this allows mouse bindings to be triggered over
a workspace when `--whole-window` is given.
2019-02-22 13:32:34 +01:00
Ian Fan 923cd865f5
Merge pull request #3740 from Emantor/fix/ipc_allocs
Fix small memory leaks reported in #3658
2019-02-22 08:20:26 +00:00
Brian Ashworth 7252ca09a7 move scratchpad: hide visible scratchpad container
This makes it so running `move [to] scratchpad` on a container already
in the scratchpad does not return an error. To match i3's behavior, a
visible scratchpad container will be hidden and a hidden scratchpad
container will be treated as a noop.
2019-02-22 08:13:51 +01:00
Rouven Czerwinski 16ddd00102 commands/move: reintroduce wrongly removed NULL check
Commit d3d7956576 removed this NULL check, which
leads to the following backtrace:

  #0  0x0000557bd201df46 in node_is_view (node=0x0) at ../sway/sway/tree/node.c:41
  #1  0x0000557bd1ff5d4e in seat_get_focus_inactive (seat=0x557bd3fc7580, node=0x0) at ../sway/sway/input/seat.c:968
          current = 0x557bd2033485
  #2  0x0000557bd2009f24 in cmd_move_container (argc=3, argv=0x557bd46b19c0) at ../sway/sway/commands/move.c:557
          new_output_last_focus = 0x0
          error = 0x0
          node = 0x557bd469f360
          workspace = 0x557bd4572ee0
          container = 0x557bd469f360
          no_auto_back_and_forth = false
          seat = 0x557bd3fc7580
          old_parent = 0x0
          old_ws = 0x557bd4572ee0
          old_output = 0x557bd411f740
          destination = 0x557bd46a0cc0
          new_output = 0x557bd411f740
          new_output_last_ws = 0x0
          focus = 0x557bd469f360
          __PRETTY_FUNCTION__ = "cmd_move_container"
          new_workspace = 0x557bd4572ee0
  […]

Reintroduce the NULL check to fix the bug.

Fixes #3746
2019-02-22 00:52:57 -05:00
Brian Ashworth d3d7956576 Handle NULL from output_get_active_workspace
This modifies the places where output_get_active_workspace is called to
handle a NULL result. Some places already handled it and did not need a
change, some just have guard off code blocks, others return errors, and
some have sway_asserts since the case should never happen. A lot of this
is probably just safety precautions since they probably will never be
called when `output_get_active_workspace` is not fully configured with a
workspace.
2019-02-21 21:18:03 +01:00
Drew DeVault 79c133182d
Merge pull request #3743 from RedSoxFan/fix-output-get-active-workspace
output_get_active_workspace: check workspaces length
2019-02-21 09:14:19 -05:00
Brian Ashworth 03dfdb1edb output_get_active_workspace: check workspaces length
If an output's node was dirty and the transaction was committed before a
workspace was moved to or created for the output, the instruction would
have a bad value for `state->active_workspace` due to a missing
length check in `output_get_active_workspace`. If there was no focus on
the output, the first workspace was being returned. If the workspace
list was currently empty, the value was either garbage, or in the case of
an output being disabled and re-enabled, a workspace that may have been
previously freed. This just adds the length check to avoid returning out
of bounds value.
2019-02-21 08:06:35 -05:00
Rouven Czerwinski aa4ccd845c run_as_ipc_client: free response after running the IPC command
Fixes memory leaks in the form of:

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c799569f2 in ipc_recv_response ../common/ipc-client.c:94
    #2 0x563c79957062 in ipc_single_command ../common/ipc-client.c:138
    #3 0x563c798a56cc in run_as_ipc_client ../sway/main.c:127
    #4 0x563c798a6a3a in main ../sway/main.c:349
    #5 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:32:55 +01:00
Rouven Czerwinski a968a650e2 ipc-client: free payload after sending it over the socket
Fixes memory leaks in the form of:

Direct leak of 20 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c7995b36a in join_args ../common/stringop.c:268
    #2 0x563c798a6a1a in main ../sway/main.c:348
    #3 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:31:05 +01:00
Brian Ashworth 546b976baa output_evacuate: call workspace_consider_destroy
This calls `workspace_consider_destroy` on the workspace that was
visible on an output that a workspace was just evacuated to. This
prevents having hidden empty workspaces.
2019-02-20 20:17:45 +01:00
Drew DeVault b57761e833
Merge pull request #3735 from emersion/primary-selection-v1
Add wp-primary-selection-unstable-v1
2019-02-20 10:33:07 -05:00
emersion 444e00662c
Add wp-primary-selection-unstable-v1 2019-02-20 11:16:05 +01:00
Drew DeVault be0588efa9
Merge pull request #3728 from ljedrz/polish_readme
Add Polish README
2019-02-19 11:32:19 -05:00
Eric Drechsel 9bbf10bdfc layout cmd: always operate on parent container, like i3Fixes #3724 2019-02-19 10:50:49 -05:00
emersion b799a30962 Don't use SOCK_CLOEXEC
Manually set the CLOEXEC flag instead, since SOCK_CLOEXEC isn't POSIX.
2019-02-19 16:34:07 +01:00
emersion a42b5d079a ci: add FreeBSD 2019-02-19 16:34:07 +01:00
ljedrz 11bc369301 Add Polish README 2019-02-19 15:49:25 +01:00
Drew DeVault 99f6bdcc71
Merge pull request #3726 from emersion/alpine-ci
ci: add Alpine build
2019-02-19 08:55:56 -05:00
emersion b4836ecbcc
ci: add Alpine CI 2019-02-19 12:11:16 +01:00
Drew DeVault c939453bea
Merge pull request #3714 from emersion/fix-drag-icon-map-listener
Fix drag icon map listener not removed
2019-02-18 15:29:07 -05:00
Drew DeVault cb49b0f6a4
Merge pull request #3715 from yorickvP/ipc-visible
Feature: Add 'visible' key to view json response
2019-02-18 15:25:48 -05:00
Yorick van Pelt fc397f52bb
Add 'visible' key to view json response 2019-02-18 13:57:16 +01:00
emersion 59f2056022
Fix drag icon map listener not removed 2019-02-18 13:19:58 +01:00
Drew DeVault a1e171080d
Merge pull request #3712 from RedSoxFan/fix-typo-seat-cursor
seat_cmd_cursor: fix typo in expected syntax
2019-02-18 05:18:46 +01:00
Drew DeVault e625c0b18c
Merge pull request #3713 from RedSoxFan/fix-mouse-bindings
Use container under cursor for mouse bindings
2019-02-18 05:16:20 +01:00
Brian Ashworth 041594d2ab Use container under cursor for mouse bindings
This matches i3's behavior of executing mouse bindings in regards to the
container under the cursor instead of what is focused.
2019-02-17 20:33:37 -05:00
Brian Ashworth 73c8e63438 seat_cmd_cursor: fix typo in expected syntax
This just fixes a typo in the expected syntax for seat_cmd_cursor
2019-02-17 20:16:23 -05:00
Brian Ashworth faf15ee733 workspace_next_name: fallback to next available number
This changes `workspace_next_name` to use the next available number as
the workspace name instead of the number of outputs. This fixes the case
where a number that is already in use could be returned. The workspace
numbers in use have no relation to the number of outputs so it makes
more sense to use the lowest available number
2019-02-17 19:15:19 +01:00
Drew DeVault 487c83f0de Add workspace {prev,next}_on_output --create
This creates the next workspace if you hit the end.
2019-02-17 11:50:07 -05:00
Drew DeVault cd10e755c1 Remove refs to unimplemented debuglog command
Closes #3695
2019-02-17 09:52:19 -05:00
emersion 7baaa3a0f8 Disconnect swaybg instead of killing it
This is much more reliable. This also fixes race conditions when killing swaybg
while it's doing a wl_display_roundtrip.
2019-02-16 19:11:22 -05:00
emersion 806129d3cc
Fix Meson subproject boolean default options 2019-02-17 00:50:53 +01:00
Brian Ashworth f7f5b172a0 sway-input.5: document wildcard and identifier troubleshooting
This documents the wildcard character for both inputs and seats. There
is also a tip added on trying the wildcard to verify a setting if the
identifier does not appear to be working.
2019-02-16 23:50:37 +01:00
emersion 8ab64d3fcc Remove unused header include/sway/tree/output.h 2019-02-16 17:40:56 -05:00
Brian Ashworth 272ca06171 Fix reload freeze when not modsetting current mode
This fixes the issue of the display freezing on reload with
wlroots#1545.

On master, all output configs are applied on reload. This may cause an
output to have its config applied up to three times, instead of just
once. The three cases are: output name, output identifier, and wildcard.
Not only is this inefficient, but it can cause swaybg to be spawned and
immediately killed.

However, swaybg requires two roundtrips of wl_display (to obtain needed
globals) before it enters its normal event loop. Modesetting will
roundtrip the wl_display. Without modesetting, waitpid for killing
swaybg could block infinitely due to swaybg being blocked by
wl_display_roundtrip.

This only configured an output once. It either uses the wildcard config
or creates an empty wildcard config and applies that. This also fixes a
bug where an output would not be reset when there is no output config to
apply to it.
2019-02-16 23:37:36 +01:00
Drew DeVault 0bafc55176
Merge pull request #3701 from emersion/meson-subproject-disable-unneeded
Disable unneeded wlroots subproject features
2019-02-16 22:57:42 +01:00
Ian Fan f54077dbca tray: fix memory leaks 2019-02-16 21:49:16 +01:00
Ian Fan 26d6360feb tray: when a service is lost, remove all matching items
Before, only the first matching item would be removed, which could leave
stale items.
2019-02-16 21:49:16 +01:00
Vincent Vanlaer cfacf85755 Check layout before getting pointer surface coords
This fixes issues of clients at the edge of the screen, like swaybar,
ignoring buttons.
2019-02-16 21:46:19 +01:00
emersion 859a884e82
Disable unneeded wlroots subproject features 2019-02-16 11:57:41 +01:00
Drew DeVault 5c78e5cd2c
Merge pull request #3698 from yabirgb/master
Spanish translation of the README
2019-02-16 04:44:31 +01:00
Yábir García db351dc670 Fix accents 2019-02-16 04:29:36 +01:00
Yábir García 9e590c4d01 Add spanish link to the home README 2019-02-16 04:17:18 +01:00
Yábir Benchakhtir 3c59069cb0
Spanish translation of the README 2019-02-16 03:57:14 +01:00
Drew DeVault cdbf8e8b25
Merge pull request #3692 from ianyfan/swaybar
Fix crash and memory leak on bar termination
2019-02-15 16:25:28 +01:00
Ian Fan d3c527220a tray: use correct parameter to set bus slot to floating
Counter-intuitively, `sd_bus_slot_set_floating` expects 0 to set it to
floating.
2019-02-15 15:15:45 +00:00
Ian Fan 5484f308b9 swaybar: prevent signal handler from firing during termination
This prevents a heap-use-after-free crash when sway terminates.
2019-02-15 14:09:14 +00:00
Brian Ashworth 96de2b539c apply_output_config: dpms on before modeset
On the DRM backend, if an output is dpms'd off and a different output is
hotplugged, the CRTC for the output is reclaimed. When modesetting an
output without a CRTC, a CRTC will not be given to an output that is not
desired to be enabled. This splits setting the dpms state in
apply_output_config. If the output should be dpms on, the it is enabled
before attempting to modeset. Otherwise, it is dpms'd off after setting
everything else.

This also adds DPMS_ON to the default output configs.
2019-02-15 09:43:48 +01:00
Brian Ashworth e8c472aee9 seatop_move_tiling: do not move to descendant
In seatop_move_tiling, it is possible to cause a stack overflow by
dragging a container into one of its descendants. This disables the
ability to move into a descendant.
2019-02-14 14:07:13 +01:00
Brian Ashworth ab42874f71 seat: allow tree focus changes while layer focused
This allows the focused inactive tree node and visible workspaces to be
changed while a surface layer has focus. The layer temporarily loses
focus, the tree focus changes, and the layer gets refocused.
2019-02-14 11:01:08 +01:00
Drew DeVault cc39bbdff3
Merge pull request #3675 from RedSoxFan/fix-move-tiling-self
seatop_move_tiling: use tab/stack parent not self
2019-02-14 00:50:44 +01:00
Brian Ashworth 9b8249c350 seatop_move_tiling: use tab/stack parent not self
When moving a descendant of a tabbed or stacked container, it is possible
for the target node to be the node being moved. This causes a segfault in
`handle_finish` since the node will be detached and then attempted to be
attached to it own parent, which is NULL due to the detach. In this
case, the target node should not be set to the node being moved, but the
parent of the node. This also allows for a descendant of a tabbed or
stacked container to be dragged out of the tabs/stacks and to be a
sibling of the tabbbed/stacked container, which was not previously
possible.
2019-02-13 14:32:47 -05:00
Brian Ashworth d168d65f2c subsurface_get_root_coords: break on NULL
It is possible for `wlr_surface_is_subsurface` to return true, but
`wlr_surface_from_wlr_surface` to be NULL. This adds a NULL check to the
value returned by `wlr_surface_from_wlr_surface` and breaks out of the
while loop in `subsurface_get_root_coords`.
2019-02-13 09:51:40 +01:00
Brian Ashworth 1bccde68a4 cursor: relative-pointer-v1 time is usec
In handle_cursor_motion, the timestamp passed to
`wlr_relative_pointer_manager_v1_send_relative_motion` should be
microseconds (not milliseconds) according to relative-pointer-v1 spec.
2019-02-13 09:49:34 +01:00
athrungithub 98b40d31c1 Don't remove from scratchpad on move to workspace
on move container window to another workspace,
not remove from scratchpad.
2019-02-12 23:47:10 -05:00
Drew DeVault c44794bedc
Merge pull request #3665 from emersion/layer-map-rebase
Rebase cursor when a layer surface maps
2019-02-12 23:22:33 +01:00
Drew DeVault f390a6ef8c
Merge pull request #3667 from emersion/fix-meson-version
Fix --version when building from tarball
2019-02-12 23:22:13 +01:00
emersion cfee167b7b
Fix --version when building from tarball 2019-02-12 23:13:24 +01:00
emersion 97c89b24b8
Rebase cursor when a layer surface maps
Also removes an extraneous arrange_outputs call, it's already called if
necessary in arrange_layers.

Updates https://github.com/swaywm/sway/issues/3080
2019-02-12 22:57:23 +01:00
Brian Ashworth fb4f29289f workspace_get_initial_output: handle focused layer
When a layer surface is focused, `seat_get_focused_workspace` will be
NULL. This changes `workspace_get_initial_output` to use output of the
focus inactive. If the focus inactive is also NULL, then either the
first output or the noop output will be used as fallbacks.
2019-02-11 10:13:16 +01:00
Brian Ashworth 2540e8ea79 Abort early when XDG_RUNTIME_DIR is not set
This aborts sway and displays an error message about XDG_RUNTIME_DIR
not being set without initializing the wl_display or logging any other
information.
2019-02-11 10:11:41 +01:00
Brian Ashworth d2c896ed84 fix misc memory leaks
This fixes a few misc memory leaks reported by asan:
- Items of `config->config_chain` are now freed instead of just the list
itself
- `bar->swaybar_command` is now freed
- The result returned by a seat subcommand is now returned instead of
leaked
2019-02-11 10:10:48 +01:00
Brian Ashworth a64a3ee6bb ipc: handle unnamed xkb_active_layout_name
If the active xkb_layout does not have a name, use `NULL` instead of
`json_object_new_string(NULL)`. This also makes it so swaymsg will pretty
print this as `(unnamed)`.
2019-02-11 01:07:11 +01:00
Brian Ashworth 418c19fe52 view: remove pointer constraints on unmap
If the view has any pointer constraints, ensure they are removed
before the view is unmapped and the surface is no longer tied to the
view.
2019-02-10 21:29:45 +01:00
Brian Ashworth 3952d4f4f3 input/keyboard: respect solo repeat_{rate,delay}
If `repeat_rate` or `repeat_delay` is set without the other being set,
the default was being used for both. This changes the logic to respect
the value given and use the default for the other when only one is set.
2019-02-10 18:45:02 +01:00
Rouven Czerwinski 605e515a93 fix double free for mode toggle if bar was invisible
If the bar was set to "invisible" and subsequently "toggle" was send twice, the
new mode was never set and the bar->mode was double freed.
Fix this by not requiring the bar->mode to be "hide" and instead show it
unconditionally, because it was either hidden or invisible.

Fixes #3637
2019-02-10 17:13:11 +01:00
Brian Ashworth 995b6edab6 container_at_stacked: skip titles when zero pixels
It is possible to make the title bars have a zero pixel height while
stacked, by using a blank font and no padding. This causes a division by
zero when attempting to calculate the child index in
container_at_stacked, which then results in a segfault when attempting
to access the child at that bad index (INT_MIN). This just skips the
check to see if the cursor is over a title bar of a child of a stacked
container when the title bar height is zero since there will be no title
bars.
2019-02-09 09:24:43 +01:00
Brian Ashworth f5190d1f79 bar_cmd_modifier: add support for none
sway-bar(5) documents `modifier none`, which comes from i3. This
implements the functionality for `modifier none` since it was not
previously implemented. The bar modifier toggles visibility of the bar
when the bar mode is set to hide. When the bar modifier is set to
`none`, the ability to toggle visibility of the bar will be disabled.
2019-02-08 16:02:45 +01:00
Drew DeVault f00fbe6861
Merge pull request #3619 from swaywm/revert-3595-ErrorIfConfigNotExist
Revert "Return false if config could not be loaded."
2019-02-08 03:30:11 +01:00
Drew DeVault 82d7a70b03 Revert "Return false if config could not be loaded."
This reverts commit 855368b67e.
2019-02-07 21:22:53 -05:00
Drew DeVault 385cf330ae Revert "Restore CWD if returning early."
This reverts commit 921e42c6c0.
2019-02-07 21:22:53 -05:00
Brian Ashworth ec5da0ca5b seat_configure_tablet_tool: configure xcursor
Since a tablet tool provides the WL_SEAT_CAPABILITY_POINTER capability,
sway will attempt to use the xcursor manager to set a cursor image. If
the tablet tool was the first (and possibly only) device to provide the
capability for the seat, the xcursor manager was not being configured
before attempting to set a cursor image. This was due to
`seat_configure_xcursor` only being called in `seat_configure_pointer`.
Since the xcursor manager was NULL in this case, it would cause a
segfault when attempting to set a cursor image. This adds a call to
`seat_configure_xcursor` in `seat_configure_tablet_tool` to ensure that
the seat has a xcursor manager.
2019-02-07 09:41:58 +01:00
Brian Ashworth 5a32a74b2d load_main_config: use given path, store realpath
Since `load_include_config` compares against the realpath of a config
file when checking if a config has already been added, the main config's
realpath has to be added to the config_chain.

However, includes from the main config should be processed relative to
the path given to allow for symbolic links. This stores the realpath in
`config->config_chain`, but uses the given path for all other
operations.
2019-02-07 09:41:05 +01:00
Brian Ashworth ee56428b64 Clarify error for options and positional args
When both options and positional arguments are given, sway would print
the error `Don't use options with the IPC client`. Over the past
several months, it seems like users are including this error message in
issues instead of a debug log due to not understanding that the error
message means there is an issue with their command.

This makes the error message more verbose and will hopefully make it so
more users understand that the message is not a bug in sway, but with
the command used.
2019-02-06 19:38:25 +01:00
Connor E 921e42c6c0 Restore CWD if returning early. 2019-02-06 18:23:20 +01:00
Connor E 855368b67e Return false if config could not be loaded. 2019-02-06 18:23:20 +01:00
Drew DeVault cdfc719494
Merge pull request #3597 from dnkl/fix-inverted-bitmask-check-in-ipc-has-event-listeners
ipc_has_event_listeners: fix inverted check of subscribed_events
2019-02-06 15:27:43 +01:00
Daniel Eklöf d3b3eb019a ipc_has_event_listeners: fix inverted check of subscribed_events
subscribed_events is a bit mask, with each *set* bit representing an
event the client has subscribed to.
2019-02-06 15:16:48 +01:00
Brian Ashworth c65057ef8b load_main_config: add realpath to config_chain
Since `load_include_config` compares against the realpath of a config
file when checking if a config has already been added, the main config's
realpath has to be added to the config_chain.
2019-02-06 09:36:33 +01:00
emersion 9b1905acf9 Fix close_popups for xdg-shell
wlr_xdg_popup_destroy will destroy popups, so we need to walk the tree
carefully. It's enough to just destroy all direct children, since destroying
the parent will also destroy all children.
2019-02-05 22:31:05 -05:00
Drew DeVault a3c5314856
Merge pull request #3587 from RedSoxFan/fix-background-missing-file
output_cmd_background: fix no file + valid mode
2019-02-05 22:09:59 +01:00
Brian Ashworth 89afb761ba output_cmd_background: fix no file + valid mode
If output_cmd_background is given a valid mode as the first argument,
then there is no file given and an error should be returned.

join_args should not be called with an argc of zero since it sets the
last character to the null terminator. With an argc of zero, the length
is zero causing a heap buffer overflow when setting the byte before the
start of argv to '\0'. This probably will not ever generate a segfault,
but may cause data corruption to whatever is directly before it in
memory. To make other such cases easier to detect, this also adds a
sway_assert in join_args when argc is zero.
2019-02-05 14:13:27 -05:00
Drew DeVault 09c2a46b3d
Merge pull request #3582 from c-edw/FixUninitializedInputManager
Initialize server so input manager is available.
2019-02-05 16:50:55 +01:00
Connor E e1b8190d2c Initialize server so input manager is available. 2019-02-05 15:39:22 +00:00
Drew DeVault 1fde9a9355
Merge pull request #3581 from c-edw/ValidateConfigNoInitialize
If validating the config, do it as early as possible.
2019-02-05 16:30:39 +01:00
Connor E 886789c197 If validating the config, do it as early as possible. 2019-02-05 14:37:22 +00:00
Drew DeVault fb73f84d0e
Merge pull request #3579 from RedSoxFan/fix-workspace-gaps-double-free
cmd_workspace_gaps: fix double free on bad amount
2019-02-05 14:41:52 +01:00
Drew DeVault a6363d1206
Merge pull request #3573 from RedSoxFan/ipc-newlines
IPC_COMMAND: split on newline
2019-02-05 14:39:10 +01:00
Drew DeVault 876bc9e44c
Merge pull request #3578 from jubalh/version
Set version in project file
2019-02-05 14:37:31 +01:00
Brian Ashworth f2abe0570f cmd_workspace_gaps: fix double free on bad amount
This fixes a double free in cmd_workspace_gaps when the amount given is
invalid. The end pointer from strtol is part of the argument and should
not be freed. Freeing the end pointer could result in a double free or
bad free depending on whether or not the end pointer was at the start of
the argument
2019-02-05 08:35:00 -05:00
Michael Vetter 77587ee632 Set version in project file
Let's set the version in the meson file instead of declaring it outside.

In case git is installed we use the git hash as version. Instead it
isn't (like on a clean build system), let's use the version defined in
the project.
2019-02-05 14:32:05 +01:00
Brian Ashworth 288e35f99e IPC_COMMAND: split on newline
This splits commands given in IPC_COMMAND on newline to match i3's
behavior.
2019-02-05 07:39:21 -05:00
emersion 478b128c26 Fix quote stripping
Let's not use !strcmp(…) anymore.
2019-02-05 07:15:25 -05:00
Brian Ashworth 1e65cc1ea6 execute_command: dont strip quotes for exec_always
This removes quote stripping for `exec_always` in `execute_command`.
Since `exec_always` commands will be deferred in the config and
processed by `execute_command`, the quotes need to be left intact
like they are for `exec`.
2019-02-05 09:37:31 +01:00
Brian Ashworth 665381d305 swaynag: remove trailing newlines in config
Now that swaynag uses getline (instead of the old readline), the
trailing newline characters have to be removed when reading the config
2019-02-05 09:35:44 +01:00
Brian Ashworth 920c64f569 load_include_configs: fix wordexp fail condition
This fixes the failure condition for the wordexp call in
load_include_configs. The only success value is zero. Since the error
codes are positive, having the check be less than zero was causing
segfaults on failure when accessing the words.
2019-02-05 09:33:45 +01:00
Drew DeVault a1a99421a1
Merge pull request #3562 from vilhalmer/focus_follows_mouse-workspace-last-inactive
Focus workspace inactive node with focus_follows_mouse
2019-02-03 20:15:21 +01:00
Drew DeVault 4ef5b49906
Merge pull request #3564 from RedSoxFan/seat-cursor-do-not-create
seat_cmd_cursor: do not create non-existing seat
2019-02-03 20:14:45 +01:00
Brian Ashworth 7299b9a6ca seat_cmd_cursor: do not create non-existing seat
If a seat does not exist in seat_cmd_cursor, do not create it. A seat
without any attachments is useless since it will have no capabilities.

This changes `input_manager_get_seat` to have an additional argument
that dictates whether or not to create the seat if it does not exist.
2019-02-03 14:01:29 -05:00
Brian Ashworth 8e60efe0bf
Merge pull request #3563 from vilhalmer/fix-wildcard-seat-constrain-crashes-during-reconfig
Fix wildcard seat constrain crashes during reconfig
2019-02-03 14:00:37 -05:00
vilhalmer f8a9117149
Fall back to wildcard in sway_cursor_constrain 2019-02-03 13:46:44 -05:00
vilhalmer 907595b10d
Skip constraining cursor if no seat config 2019-02-03 13:44:37 -05:00
vilhalmer da59ffa8a0
Skip wildcard seat config in destroy_removed_seats 2019-02-03 13:41:35 -05:00
vilhalmer a3332c70bf
Focus ws inactive node with focus_follows_mouse 2019-02-03 12:12:40 -05:00
Drew DeVault bbfe13a248
Merge pull request #3551 from c-edw/RevertDoubleFrees
Revert double frees.
2019-02-03 09:55:54 +01:00
Drew DeVault b41f9f9158
Merge pull request #3554 from RedSoxFan/seat-current-alias
cmd_seat: allow - to be used as alias for current
2019-02-03 09:53:37 +01:00
Brian Ashworth f425e81fbe cmd_seat: allow - to be used as alias for current
This allows for `-` (hyphen) to be used as an alias for the current seat
while sway is running. This alias was chosen since it is unlikely to
interfere with any desirable seat identifier
2019-02-02 22:02:28 -05:00
Brian Ashworth 1bd7400c4d seat_cmd_attach: defer while reading
Since the seats and inputs are not yet available while the config is
being read, defer seat attachment requests
2019-02-03 00:23:28 +01:00
Stefan Schick 0952c9f91d Fix #3445: swaybar tray inerited thems not processed 2019-02-01 21:47:28 -05:00
Connor E 2f2a887377 Revert "More frees."
This reverts commit eda1bf769f.
2019-02-01 11:52:37 +00:00
Connor E 49b667272b Revert "Add some missing frees."
This reverts commit b5d95f264d.
2019-02-01 11:51:03 +00:00
Drew DeVault de76c4e071
Merge pull request #3543 from emersion/relative-pointer-usec
relative-pointer-v1: time is in usec, not msec
2019-02-01 09:27:00 +01:00
Drew DeVault 47271552b0
Merge pull request #3550 from RedSoxFan/seat-pointer-constraint
pointer_constraint: change to a seat subcommand
2019-02-01 09:26:30 +01:00
Brian Ashworth ebe5399ed6 pointer_constraint: change to a seat subcommand
This changes the `pointer_constraint` command to be a subcommand of seat
to allow for per-seat settings. The current implementation that is not a
seat subcommand will only operate on the current seat and will segfault
in the config due to `config->handler_context.seat` only being set at
runtime.

This also allows for the wildcard identifier to be used to alter the
pointer constraint settings on all seats and allows for the setting to
be merged with the rest of the seat config.
2019-01-31 22:58:52 -05:00
v44r 204e1f4712 Rebase #1636 against current master 2019-01-31 15:37:57 +01:00
emersion 1049f360e1
readme: scdoc 1.8.1 is now required 2019-01-31 14:54:50 +01:00
Drew DeVault 82461c4165 Updates for scdoc 1.8.1 2019-01-31 08:42:29 -05:00
Ashkan Kiani aee9942145 Add details on `--whole-window` for bindsym
Updates sway.5 to include information on the usage of the `--whole-window` option in the context of the `bindsym` command, which modifies mouse bindings to allow them to operate over the whole window instead of just the titlebar. Also includes the disclaimer about mouse bindings only working over the title bar.

Also fixes the escaping of the `BTN_LEFT` and `BTN_RIGHT` key mention.
Add notes on --border and --exclude-titlebar

Update the flags for bindcode command.
2019-01-30 22:55:22 +01:00
emersion dde9fc19de
relative-pointer-v1: time is in usec, not msec 2019-01-30 21:30:44 +01:00
Drew DeVault 0c975af1fb Send pointer frames on tool events 2019-01-30 14:09:50 -05:00
Drew DeVault 4b87edeba4 Missed a spot in pointer constraints 2019-01-30 14:06:44 -05:00
Drew DeVault a6d41254c9 Add pointer_constraint command 2019-01-30 19:53:59 +01:00
absrd ee4b8a3938 Add relative pointer 2019-01-30 19:53:59 +01:00
Las cedde21c96 Implement pointer-constraints-unstable-v1 2019-01-30 19:53:59 +01:00
athrungithub 5cb3d4769c criteria & scratchpad verify if show in another workspace (#3522)
check if scratchpad is show in another workspace
2019-01-30 09:05:46 -05:00
Drew DeVault 4f4424f66c
Merge pull request #3535 from RedSoxFan/cleanup-log-on-config-failure
Cleanup config reading failure error logs
2019-01-29 13:38:56 -05:00
Brian Ashworth f0fd6119cf Cleanup config reading failure error logs
This cleans up the log when sway fails to read a config file. The
following changes have been made:
- A missing error message has been added to the log when the config file
is a directory instead of a regular file
- In main, `goto` statements have been added after the `sway_terminate`
calls instead of wrapping every block in `if (!terminate_request)`
- Unnecessary NULL-checks around calls to free in `main` have been
removed
- Deferred command execution has been extracted to a separate function
and the `Running deferred commands` log message will not be shown when
there are no deferred commands.
2019-01-29 13:18:53 -05:00
Peter Grayson f49ad5977e Document cursor moving between adjacent outputs
Add a sentence to sway-output.5.scd to highlight that the cursor can
only be moved between immediately adjacent outputs.

References issue #3529

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2019-01-28 21:36:48 -05:00
Drew DeVault 606f6a3707
Merge pull request #3530 from RyanDwyer/fix-assertion
Remove bad assertion in container_handle_fullscreen_reparent
2019-01-28 17:14:41 -05:00
Ryan Dwyer 8995694a2f Remove bad assertion in container_handle_fullscreen_reparent
The assertion could trigger when called from workspace_wrap_children.
2019-01-29 08:05:55 +10:00
Drew DeVault 22237e0b42
Merge pull request #3528 from emersion/cleanup-log-env
Cleanup log_env
2019-01-28 16:06:12 -05:00
emersion 7c72327ab5
Cleanup log_env
SWAY_CURSOR_* are not used anymore. LD_PRELOAD_PATH doesn't exist and has been
replaced with LD_PRELOAD.
2019-01-28 21:59:10 +01:00
mwenzkowski 7c27d73b02 Check xdg_surface's role before using its toplevel
Don't access xdg_surface->toplevel if xdg_surface->role is equal to
WLR_XDG_SURFACE_ROLE_NONE, since this could lead to crash. The same
checks are added for xdg_surface_v6.

Fixes #3311
2019-01-28 16:14:35 +01:00
Ryan Dwyer 6b8bf10941 Introduce container_is_scratchpad_hidden
Just a convenience function that improves readability of the code.

Other things worth noting:

* container_get_siblings and container_sibling_index no longer use the
const keyword
* container_handle_fullscreen_reparent is only ever called after
attaching the container to a workspace, so its con->workspace check has
been changed to an assertion
2019-01-28 10:35:40 +01:00
Connor E 68a28e482f Add note about required scdoc version to README. 2019-01-28 01:55:08 -05:00
Ryan Dwyer 0a9ff774ad Center surface inside container when it's too small
The goal here is to center fullscreen views when they are both too small
for the output and refuse to resize to the output's dimensions. It has
the side effect of also centering the view when it's too small for its
container.

Example clients that have this behaviour are emersion's hello-wayland
and weston.

It works by introducing surface_{x,y,width,height} properties to the
container struct. The x and y represent layout-local coordinates where
the surface will be rendered. The width and height are only used to
track the surface's previous dimensions so we can detect when the client
has resized it and recenter and apply damage accordingly.

The new surface properties are calculated when a transaction is applied,
as well as when a view resizes itself unexpectedly. The latter is done
in view_update_size. This function was previously restricted to views
which are floating, but can now be called for any views.

For views which refuse to resize *smaller* than a particular size, such
as gnome-calculator, the surface is still anchored to the top left as
per the current behaviour.
2019-01-28 01:17:21 -05:00
Drew DeVault 783fadab28
Merge pull request #3423 from RyanDwyer/fullscreen-global
Implement fullscreen global
2019-01-27 18:06:50 -05:00
Drew DeVault 897250c65f
Merge pull request #3519 from emersion/pointer-frame
Update for swaywm/wlroots#1503
2019-01-27 11:44:09 -05:00
Drew DeVault cd22d555e8 Remove unnecessary underscores in man pages 2019-01-27 11:27:48 -05:00
emersion a452f8f822
Update for swaywm/wlroots#1503 2019-01-27 12:59:46 +01:00
Ryan Dwyer 20aa8ee67d Implement fullscreen global 2019-01-25 08:29:21 +10:00
Drew DeVault 5f45a4bbc1
Merge pull request #3509 from ianyfan/log-errno
Use sway_log_errno instead of strerror
2019-01-24 09:24:02 -05:00
Ian Fan 5d6f906bd7 Use sway_log_errno instead of strerror 2019-01-24 11:33:54 +00:00
emersion 75406bb93b Update for swaywm/wlroots#1402 2019-01-24 11:48:19 +01:00
Jan Beich ba96983bf0 Make json-c include respect pkg-config --cflags
json-c.pc contains `Cflags: -I${includedir}/json-c`, so `<json-c/json.h>`
won't be found unless the parent directory is searched by default.
2019-01-23 21:50:06 -05:00
Drew DeVault 1a1133dcc5
Merge pull request #3504 from unraised/unraised-build-fix
Fix build failure in config.c
2019-01-23 11:24:46 -05:00
unraised c0dc740b2b
Fix build failure in config.c 2019-01-23 10:09:23 -06:00
Drew DeVault 8b056cfc82
Merge pull request #3500 from progandy/validate_pixmaps
swaybar: fix crash with some tray icon pixmaps
2019-01-23 09:21:08 -05:00
Drew DeVault 1803e7748b
Merge pull request #3502 from lukaslihotzki/master
Fix tray icon updates
2019-01-23 09:20:37 -05:00
Lukas Lihotzki f7ed97e2a7 Fix tray icon updates
Apparently, IconThemePath needs to be reread on NewIcon signal.
This fixes tray icon updates in electron apps with libappindicator-gtk3.
2019-01-23 13:08:43 +01:00
progandy dcabe0e6da swaybar: fix crash with some tray icon pixmaps
Discard pixmaps for icons where width and height are 0 or not equal.

Fixes #3487
2019-01-23 00:04:00 +01:00
Brian Ashworth 9e6c6ce332 swaybar: fix command malloc in workspace command
This fixes a typo on the malloc line in ipc_send_workspace_command. The
plus one to the size for the null-terminator was outside of the malloc
call, which was causing the incorrect pointer to be freed later in the
function.
2019-01-22 20:10:19 +01:00
Ian Fan d7d906c7fd background-image.c: remove stdbool header 2019-01-22 12:58:24 -05:00
Ian Fan d8f3e6e19a swaybar: fix workspace command
Escape quotes and backslashes, allowing switching to workspace names
like "1" (including quotes) and \
2019-01-22 18:48:33 +01:00
Drew DeVault 04aa41de34
Merge pull request #3496 from mstoeckl/fix-san
Fix dead stores found by scan-build
2019-01-22 11:04:56 -05:00
M Stoeckl 0af5b26e41 Fix dead stores found by scan-build
In addition to removing unused code, two minor problems are fixed:
 (1) `resize set` and `resize adjust` did not error when given
too many arguments.
 (2) `orientation` was incorrectly overridden to be 'U' for
scroll events in the swaybar tray `handle_click` function.
2019-01-22 10:12:04 -05:00
Drew DeVault 71a37ad186
Merge pull request #3494 from ianyfan/commands
i3 command behaviour compatibility fixes
2019-01-22 07:55:31 -05:00
Brian Ashworth 8ce57f0a77 root_scratchpad_remove_container: do not show
This removes the call to `root_scratchpad_show` from
`root_scratchpad_remove_container` and places it in the
`cmd_move_container`. This also moved the IPC `window::move` event to
`cmd_scratchpad`.
2019-01-22 13:13:34 +01:00
Ian Fan de9a357de8 util.c: remove numlen function
Its uses have been replaced by snprintf, which is more in line with its usage.
2019-01-22 13:10:25 +01:00
Ian Fan ec0013b9f5 commands: allow setting floating on scratchpad containers 2019-01-22 11:47:48 +00:00
Ian Fan 34dea3d9d2 commands: allow tiled containers to be stickied
This also stops stickied containers from losing its sticky status when
it is tiled, allowing it to be immediately stickied when floated again.
2019-01-22 11:47:48 +00:00
Ryan Dwyer 42f8a038c9 Remove assumption that noop output will be called NOOP-1 2019-01-22 09:55:13 +01:00
Ryan Dwyer 7f8ea60e71 Don't allow noop output to be configured 2019-01-22 09:55:13 +01:00
Ryan Dwyer e815e48cee Hide noop output in IPC 2019-01-22 09:55:13 +01:00
Ryan Dwyer 75e7ce82f5 Prevent noop output from being enabled 2019-01-22 09:55:13 +01:00
Ryan Dwyer 2301349ad5 Use noop output when there's no outputs connected
Instead of having NULL workspace->output pointers, use a noop output.
This should be safer.
2019-01-22 09:55:13 +01:00
Brian Ashworth ab0248a545 seat_create: set initial focus for added seats
This sets the initial focus for all seats other than the first seat,
which gets it focus on launch. The ensures that all seats have something
focused.
2019-01-22 09:33:58 +01:00
Connor E 39cf477090 swaynag: Small graphical fix, add offset of +1 to X/Y. 2019-01-22 03:32:51 -05:00
Brian Ashworth f493fb526d
Merge pull request #3485 from mstoeckl/minimize-deps
Remove wlroots dependency for sway(bar|bg|msg|nag)
2019-01-22 01:02:48 -05:00
M Stoeckl 4b1eaaf731 Removed unused wlroots dependency for sway(bg|bar|msg|nag)
Also remove direct libm dependency where unused.
2019-01-21 13:04:15 -05:00
M Stoeckl c040defd5f Fix edge case bug in numlen, dropping use of math.h functions
(Specifically, numlen when called with INT_MIN gave an incorrect
result, because abs(INT_MIN) == INT_MIN < 0.)
2019-01-21 12:46:45 -05:00
M Stoeckl d7ff776552 Move sway-specific functions in common/util.c into sway/
Modifier handling functions were moved into sway/input/keyboard.c;
opposite_direction for enum wlr_direction into sway/tree/output.c;
and get_parent_pid into sway/tree/root.c .
2019-01-21 12:39:16 -05:00
Ian Fan 410c961388 swaybar: fix setting floating watcher slots 2019-01-21 16:05:15 +01:00
Drew DeVault cddb057343
Merge pull request #3480 from RedSoxFan/input-modes-improved-toggle
input_cmd_events: allow toggle modes to be listed
2019-01-21 09:28:47 -05:00
Drew DeVault 1fb6918f9e
Merge pull request #3482 from emersion/meson-systemd-version
meson: set minimum systemd version
2019-01-21 09:25:11 -05:00
emersion e134da3023
Fix one remaining wlr_log call 2019-01-21 13:02:03 +01:00
M Stoeckl 1211a81aad Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.

wlr_log_init is still invoked in sway/main.c

This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-21 12:59:42 +01:00
emersion 51e4b94270
meson: set minimum systemd version
sd_bus_slot_set_floating has been introduced in systemd 239.
2019-01-21 12:56:32 +01:00
Brian Ashworth 5c834d36e1 Log libinput_config_status errors
This add errors from calls to `libinput_device_config_*_set` to the
debug log. This may be useful when looking at issues related to input
devices and config settings not working.
2019-01-21 08:46:36 +01:00
Brian Ashworth 91c1f44956 input_cmd_events: allow toggle modes to be listed
This extends `input <identifier> events toggle` to allow for an optional
list of modes to toggle through. If no event modes are listed, all
supported modes are cycled through (current behavior). If event modes
are listed, they will be cycled through, defaulting to the first mode
listed when the current mode is not in the list. This modes listed will
also not be checked to see if the device supports them and may fail.
2019-01-21 02:13:01 -05:00
Connor Edwards 9df3a9136c Allocate minimum size necessary in pango text functions. (#3473)
* Allocate minimum size necessary in pango text functions.

* Handle malloc failure.
2019-01-20 15:03:30 +01:00
Drew DeVault a3d3504072
Merge pull request #3468 from emersion/fix-output-gain-crtc
Fix re-enabling outputs gaining a CRTC
2019-01-20 09:01:33 -05:00
M Stoeckl 62260ab56e Fix backup methods in get_socketpath for IPC client
Previously, the success of `getline` was tested by checking if the
buffer it allocates is nonempty and has a nonzero first byte. As
 `getline` does not explicitly zero out its memory buffer, this may
fail (e.g., with AddressSanitizer). Instead, we check that at least one
character was returned on standard output.

Also, trailing newlines (if present) are now removed.
2019-01-19 18:45:25 +01:00
Brian Ashworth afac6ced6e apply_output_config: remove output_i
output_i was used in apply_output_config when swaybar used wl_output
index numbers instead of xdg-output names. This is no longer needed.
2019-01-19 17:28:26 +01:00
emersion 0bf3252d8b
Fix re-enabling outputs gaining a CRTC
If output->configured is true, then the output has been modeset correctly and
we don't need to try again. If output->enabled is true, then we are in the
process of configuring the output and we shouldn't do anything.
2019-01-19 10:19:59 +01:00
emersion 07f4c1e3a9 swaynag: fix XDG_CONFIG_HOME handling 2019-01-19 09:07:08 +01:00
M Stoeckl 695948e689 Fix memory leaks in swaybar 2019-01-19 08:42:52 +01:00
emersion 2ae2d09c4c Prevent crashes in handle_transform and handle_scale too 2019-01-19 08:29:46 +01:00
emersion 3b7a7462a2 Fix crash in cursor_rebase with multiple screens
Designing the output configuration sequence without invalid state is tricky.

We have one function, apply_output_config, that takes an output and (besides
other things) performs a modeset and inserts the output in the output layout.
The modeset can fail, in which case we don't want the output to be enabled.
We also have an output_enable function, which calls output_apply_config and
also configures the output's workspace and inserts it in the root container.

Now, we have two choices.

Either we configure the output before it's been inserted in the root container
and then, if the modeset was successful, we insert it and create the workspace.
The main issue with this approach is that configuring the output triggers a
handful of signals, namely wlr_output.mode and wlr_output_layout.change. In
those event handlers, we need to make sure to ignore these outputs in the
process of being configured.

Either we first insert the output, create the workspace and then try to
configure it. It means we need to undo everything if the modeset fails. The
main issue with this solution is that it enables and disables the output very
quickly, creates a workspace and immediately destroys it, and maybe moves
views back and forth (see output_evacuate).

I've tried to make it so an output isn't enabled then immediately disabled. We
already have code for ignoring outputs when the output is being destructed.

Fixes https://github.com/swaywm/sway/issues/3462
2019-01-19 08:29:46 +01:00
Scott Anderson 1cce14e7c7
Merge pull request #3464 from emersion/meson-check-wlroots-xwayland
Make sure wlroots has been built with xwayland
2019-01-19 12:30:13 +13:00
emersion 35d73345d9
meson: make sure wlroots has been built with xwayland 2019-01-18 23:47:46 +01:00
Drew DeVault 639b66b676
Merge pull request #3452 from emersion/meson-features
Use Meson feature options
2019-01-18 15:39:07 -05:00
Drew DeVault 60220fcecd
Merge pull request #3460 from emersion/output-enable-segfault
Fix segfault in output_enable
2019-01-18 10:16:22 -05:00
emersion 6ff54d0640
Fix segfault in output_enable 2019-01-18 14:52:40 +01:00
Drew DeVault dd4a6586b2
Merge pull request #3457 from emersion/swaybg-no-escape
Don't escape swaybg arguments anymore
2019-01-18 08:23:48 -05:00
Drew DeVault 978d6cd854
Merge pull request #3455 from emersion/output-no-crtc
Better handle outputs without CRTC
2019-01-18 08:23:25 -05:00
emersion a737d7ecc4
Better handle outputs without CRTC
This happens if you plug in more outputs than supported by your GPU.

This patch makes it so outputs without CRTCs appear as disabled. As soon as
they get a CRTC (signalled via the mode event), we can enable them.
2019-01-18 10:09:10 +01:00
emersion dc1eac0cf1 output: remove output_add_listeners
Simplify the code by registering signals when outputs are created and removing
signals when they are destroyed.
2019-01-18 10:08:34 +01:00
emersion d803861504
Don't escape swaybg arguments anymore
swaybg used to be invoked with sh, which made escaping necessary. This is no
longer necessary.

Fixes https://github.com/swaywm/sway/issues/3456
2019-01-18 09:22:33 +01:00
emersion 765d7bc94f
meson: remove extraneous parentheses 2019-01-18 08:44:02 +01:00
emersion bb2f007ad3
meson: remove rpath options 2019-01-18 08:26:44 +01:00
emersion ab35e0383f
meson: remove unused dependencies 2019-01-18 08:22:59 +01:00
emersion ba16f16e4d
meson: add gdk-pixbuf and man-pages options 2019-01-18 08:21:43 +01:00
emersion 08a5b304e4
Use Meson feature options 2019-01-17 18:26:24 +01:00
Drew DeVault 5a0c4234b8
Merge pull request #3447 from emersion/remove-swaylock-includes
Remove swaylock headers and unicode.c
2019-01-17 08:13:19 -05:00
Drew DeVault 60a16bbf41
Merge pull request #3448 from emersion/swaybg-xdg-output
swaybg fixes
2019-01-17 08:12:53 -05:00
emersion f951c2357f
Remove unicode.c 2019-01-17 12:45:41 +01:00
emersion fe3f4882ed
Don't use sh when spawning swaybg 2019-01-17 11:20:08 +01:00
emersion 808d0e1c51
swaybg: use wl_surface_damage_buffer 2019-01-17 11:14:36 +01:00
emersion 000b313985
swaybg: use output names instead of output indexes 2019-01-17 11:13:10 +01:00
emersion b29d19bf0d
Remove swaylock headers 2019-01-17 10:26:42 +01:00
Connor E 70637b40fe Fixes for small existing bugs. 2019-01-16 13:02:26 +01:00
Connor E de6f5b3453 Use static arrays where possible. 2019-01-16 13:02:26 +01:00
Connor E aa9d7d8ca1 Remove usage of VLAs. 2019-01-16 13:02:26 +01:00
Brian Ashworth 02bbefda20 bar_cmd_tray_bind: Use mouse button helpers
This modifies `bar_cmd_tray_bindsym` to use `get_mouse_bindsym` for
parsing mouse buttons. This also introduces `bar_cmd_tray_bindcode`,
which will use `get_mouse_bindcode` for parsing mouse buttons. Like with
sway bindings, the two commands are encapsulated in a single file to
maximize shared code.

This also modifies tray bindings to work off of events codes rather than
x11 buttons, which allows for any mouse buttons to be used.

For `get_bar_config`, `event_code` has been added to the `tray_bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
2019-01-16 11:12:45 +01:00
Brian Ashworth 247817f68c layer_shell: do not SIGABRT sway on zero outputs
If there are no outputs, do not SIGABRT when a layer surface is created,
just close the layer surface.
2019-01-16 10:55:25 +01:00
Brian Ashworth 81e595e6e8 cmd_resize: allow resizing hidden scratchpad by px
Allow resizing a hidden scratchpad container by px. Resizing a hidden
scratchpad container by ppt is still not allowed since there is no
workspace
2019-01-16 09:30:43 +01:00
Brian Ashworth 638b04b3e0 seatop_begin_down: raise floating
In `seatop_begin_down`, raise the floating container. This appears to
have been dropped in the transition to seatops.
2019-01-15 22:45:01 +01:00
Brian Ashworth 686b853047 Do not send ipc_event_shutdown from ipc client
In `sway_terminate`, `ipc_event_shutdown` was being sent regardless
which mode sway was running in. When running as an ipc client,
`sway_terminate` should just exit
2019-01-15 22:41:54 +01:00
Rouven Czerwinski f7309778a7 cursor: send clear_focus on hide and enter event on unhide
Clear the focus when we hide the cursor and show it again during the unhide
action. The unhide function will rebase the cursor after the unhide.

Tested by looking at the WAYLAND_DEBUG=1 output of termite.

Also call cursor_handle_activity before sending pointer events to send the enter
events to the surface if the cursor was hidden before.

Fixes #3431
2019-01-15 14:06:48 -05:00
Connor E 023c92423e Remove wlr_xdg_surface_send_close. 2019-01-15 09:13:27 +01:00
Brian Ashworth a68bc5f449 Do not damage view child when container is NULL
In `view_child_damage`, do not damage the surface if it has been
unmapped or if the container is NULL.
2019-01-15 09:06:42 +01:00
Brian Ashworth 3087942c35 Handle hidden scratchpad containers in commands
This fixes the handling of hidden scratchpad containers for some
commands. For the most part, this just prevents running the commands on
hidden scratchpad containers, but there are some commands that have some
special handling for them.
2019-01-15 09:05:27 +01:00
Brian Ashworth bbd312c95a
Merge pull request #3422 from RyanDwyer/resize-immediate-siblings
Resize only current and immediate siblings rather than all siblings
2019-01-14 21:45:14 -05:00
Ryan Dwyer 289130430f Fix invalid pointers when using resize grow width on first/last siblings 2019-01-15 08:17:41 +10:00
Ryan Dwyer 2024f1da72 Resize only current and immediate siblings rather than all siblings
For example, create layout V[view view view] and resize the leftmost
view using mod+rightclick. Previously, the edge between view 2 and 3
would be adjusted as well. Now this edge will remain constant, which
matches the behaviour of i3.

To do this operation correctly, the resize tiling seatop now keeps track
of two containers, as the container that resizes horizontally will be a
different container to the one which resizes vertically (one will be an
ancestor). The tiling resize seatop now figures out these containers
during the start of the operation and keeps references to them in the
event. A new function container_find_resize_parent has been introduced
to do this. This function is also used by the resize command.

During cursor motion, the seatop logic is similar to before, but now has
to choose the correct container to resize.

In resize.c, container_resize_tiled and resize_tiled have been merged
into one. One of them originally did nothing except pass the values
through to the other.

container_resize_tiled now takes a simplified approach where it just
finds the immediate siblings on either side and resizes them without
worrying about the others. The parellel_coord and parallel_size
functions are no longer needed and have been removed.
2019-01-15 08:01:21 +10:00
Brian Ashworth 2573606b60 Disarm key repeat on reload
When resetting the keyboard during reload, disarm the key repeat on all
keyboards since the bindings (and possibly keyboard) will be freed before
the key repeat can go off.
2019-01-14 20:15:23 +01:00
Brian Ashworth 2257368f1a CONTRIBUTING.md: mention tab width for line length
Adds a note about assuming a tab width equal to 4 spaces when
determining the line length to CONTRIBUTING.md
2019-01-14 19:46:54 +01:00
Ian Fan 2f36db15d4 config.in: update swayidle/swaylock example 2019-01-14 18:08:13 +01:00
Brian Ashworth 15cd8b6a86
Merge pull request #3403 from mstoeckl/ipcleanup
Remove 'input' field of IPC command return json
2019-01-14 11:44:18 -05:00
M Stoeckl 2a684cad5f Remove now-unused "input" argument of cmd_results_new
Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))`
applied to `cmd_results_new`.

String usage constants have been converted from pointers to arrays when
encountered. General handler format strings were sometimes modified to
include the old input string, especially for unknown command errors.
2019-01-14 08:05:29 -05:00
M Stoeckl 6d392150a7 Remove 'input' field of IPC command return json
This field is not in i3 and provides imprecise and redundant information.
(Specifically, when swaymsg is given a list of commands, the IPC return
array already indicates precisely which number command failed; knowing
the name of the command is not useful when multiple commands of the
same type are provided.)
2019-01-14 07:58:02 -05:00
emersion 64ef936673
Merge pull request #3418 from RyanDwyer/remove-resize-axis
Replace resize_axis with wlr_edges
2019-01-14 11:19:18 +01:00
Ryan Dwyer b322432eff Use uint32_t where resize axis might contain a bitfield 2019-01-14 20:10:49 +10:00
emersion 3ea176bb04
Merge pull request #3419 from ianyfan/swaynag
swaynag: handle empty $XDG_CONFIG_HOME better
2019-01-14 10:50:43 +01:00
Ian Fan 8729c65311 swaynag: handle empty $XDG_CONFIG_HOME better
Set config path to fallback instead of setting $XDG_CONFIG_HOME
2019-01-14 09:45:18 +00:00
Ryan Dwyer 22ac1c121a Replace resize_axis with wlr_edges
This patch removes the resize_axis enum in favour of wlr_edges. As
wlr_edges has no `horizontal` or `vertical` value, it denotes these by
bitwise `or`ing the left/right and up/down values. Two constants are
defined to make it easier to refer to these.

This will allow the tiling resize seatop to utilise the functions in
this file. resize_axis was local to the resize command and couldn't be
exposed in function arguments.
2019-01-14 19:05:48 +10:00
emersion 89ad3f2bbb
Merge pull request #3417 from swaywm/remove-swaylock
Split swaylock into separate project
2019-01-14 08:57:20 +01:00
Drew DeVault 3fca8b8d22 Split swaylock into separate project 2019-01-13 21:40:26 -05:00
Drew DeVault 784178ed37 Remove WIP from README.md 2019-01-13 21:36:59 -05:00
Drew DeVault 4879d40695
Merge pull request #3144 from emersion/cmd-xwayland
Add xwayland command
2019-01-13 20:42:39 -05:00
Drew DeVault 81bb675274
Merge pull request #3344 from RedSoxFan/bar-mouse-bindings-improved
Improve mouse button parsing: bar mouse bindings
2019-01-13 20:41:05 -05:00
Drew DeVault 9f9ef76175
Merge pull request #3343 from RedSoxFan/seat-cursor-buttons-improved
Improve mouse button parsing: seat cursor buttons
2019-01-13 20:40:42 -05:00
Drew DeVault db1631b67d
Merge pull request #3342 from RedSoxFan/scroll-buttons-improved
Improve mouse button parsing: input scroll_button
2019-01-13 20:40:00 -05:00
Drew DeVault 23ab56bbf7
Merge pull request #3402 from RyanDwyer/refactor-seatops
Refactor seat operations to use an interface
2019-01-13 20:38:34 -05:00
Drew DeVault 08569aab36
Merge pull request #3388 from RedSoxFan/reset-inputs-on-reload
reload: reset input configs
2019-01-13 20:37:05 -05:00
Drew DeVault fc93cd20dc
Merge pull request #3397 from RedSoxFan/fix-swaybar-height
swaybar: obey height if given
2019-01-13 20:36:08 -05:00
Drew DeVault 4eb0767414
Merge pull request #3398 from RedSoxFan/toggle-input-events
input events: toggle and ipc get_inputs
2019-01-13 20:35:45 -05:00
Drew DeVault 9ce4d53e78
Merge pull request #3408 from RedSoxFan/bar-padding
swaybar: adjustable status padding
2019-01-13 20:34:13 -05:00
Drew DeVault 9b5ac08682
Merge pull request #3415 from RedSoxFan/swaybar-output-improved
swaybar: allow identifiers for output and tray
2019-01-13 20:33:44 -05:00
Brian Ashworth 50d36ef238 swaybar: allow identifiers for output and tray
This allows `bar output` and `bar tray_output` to specify an output
identifier. Output names should still work as well.

This parses the output identifier from the xdg_output description,
which wlroots currently sets to `make model serial (name)`. Since this
could change in the future, all identifier comparisons are guarded by
NULL-checks in case the description cannot be parsed to an identifier.
2019-01-13 12:06:35 -05:00
Ian Fan a43863aa60
Merge pull request #3412 from RedSoxFan/fix-cont-line-num
config: fix line number with continued lines
2019-01-12 22:05:18 +00:00
Drew DeVault bc808680b1 Split swayidle from sway 2019-01-12 11:24:06 -05:00
Brian Ashworth b43345a1a3 config: fix line number with continued lines
When the config has continued lines, `get_line_with_cont` may read more
than one line of the actual file. When displaying line numbers for error
messages, they should be the line number in the file to make it easy to
find and fix the issue.
2019-01-11 20:41:38 -05:00
Ian Fan d256182f49
Merge pull request #3411 from RedSoxFan/fix-brace-detect-seeking
config: do not reset pos when braces found
2019-01-12 01:25:44 +00:00
Brian Ashworth 39975ccfb5 config: do not reset pos when braces found
When a brace is found, the config file should not seek back to before
the brace, otherwise the brace will be read multiple times.
2019-01-11 20:02:20 -05:00
Brian Ashworth ca0a75d540 swaybar: add status_edge_padding command
This adds the bar subcommand `status_edge_padding <padding>` to set the
padding used when the status line is on the right edge of the bar.
2019-01-11 00:12:24 -05:00
Brian Ashworth c0f92cb2fb swaybar: add status_padding command
Adds the bar subcommand `status_padding <padding>` which allows setting
the padding used for swaybar. If `status_padding` is set to `0`, blocks
will be able to take up the full height of the bar.
2019-01-11 00:07:58 -05:00
Robinhuett 33d9de88ef swaylock: Add caps lock state to indicator
Implements customization for the indicator as proposed in #2788 with comments from #3367 in mind.
The default behaviour does not change exept for the caps lock text color.
2019-01-10 16:14:18 -05:00
Brian Ashworth 4e6bd53abf input_cmd_scroll_button: utilize mouse btn helpers
This modifies `input_cmd_scroll_button` to utilize the mouse button
helper `get_mouse_button` when parsing the button. x11 axis buttons are
not supported with this command and `CMD_INVALID` will be returned, but
all other x11 buttons, button event names, and button event codes should
be working
2019-01-10 12:45:52 -05:00
Brian Ashworth 3d6440ec26 bar_cmd_bind: utilize mouse button helpers
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing
mouse buttons. This also introduces `cmd_bar_bindcode`, which will use
`get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the
two commands are encapsulated in a single file with shared code.

This also modifies swaybar to operate off of event codes rather than x11
button numbers, which allows for any mouse button to be used.

This introduces two new IPC properties:
- For `get_bar_config`, `event_code` has been added to the `bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
- Likewise for `click_events`, `event` has been added and will include
the event code for the button clicked. If the event code can be mapped
to a x11 button, `button` will still be the x11 button number.
Otherwise, `button` will be `0`.
2019-01-10 12:43:10 -05:00
Brian Ashworth aa1c838f97 seat_cmd_cursor: utilize mouse button helpers
This modifies `seat_cmd_cursor` to utilize `get_mouse_button` when
parsing mouse buttons for the `press` and `release` operations. All x11
buttons, button event names, and button event codes are supported.
For x11 axis buttons, `dispatch_cursor_axis` is used instead of
`dispatch_cursor_button`. However the `press`/`release` state is ignored
and the either axis event is processed. This also removes support for
`left` and `right` in favor of `BTN_LEFT` and `BTN_RIGHT`.
2019-01-10 11:47:34 -05:00
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
Ryan Dwyer ed5aafd90b Refactor seat operations to use an interface
This splits each seat operation (drag/move tiling/floating etc) into a
separate file and introduces a struct sway_seatop_impl to abstract the
operation.

The move_tiling_threshold operation has been merged into move_tiling.

The main logic for each operation is untouched aside from variable
renames.

The following previously-static functions have been made public:
* node_at_coords
* container_raise_floating
* render_rect
* premultiply_alpha
* scale_box
2019-01-10 22:04:42 +10:00
Ian Fan 00f8d0209f config.c: fix brace detection at end of file 2019-01-10 10:59:07 +00:00
Ian Fan 15ac580b28
Merge pull request #3341 from RedSoxFan/mouse-bindings-improved
Improve mouse button parsing: helpers and bind{code/sym}
2019-01-10 10:55:22 +00:00
emersion 058428b8df
Merge pull request #3394 from RedSoxFan/bar-block-render
swaybar: fix rendering of border and background
2019-01-10 10:43:00 +01:00
emersion 9abac85888
Merge pull request #3399 from RedSoxFan/fix-output-destruction-segfaults
Fix segfaults on output destruction
2019-01-10 09:20:07 +01:00
Brian Ashworth 8fd3f32c79 Fix segfaults on output destruction
This fixes two causes of segfaulting when an output is destroyed.

The first occurred when an output was never enabled. The issue was that
the destroy signal was never initialized so when it was emitted, sway
segfaulted. This was fixed by moving the initialization into
`output_create` since all outputs, regardless of whether they have ever
been enabled, will be destroyed at some point.

The second occurred when the cursor was on an output that was being
destroyed. The sway output would have already been removed, but if there
are other outputs, a cursor rebase would still occur. Since the
wlr_output still existed and the sway output was destroyed, the cursor
could be over nothing, resulting in a segfault when trying to get the
sway output, which was destroyed.
2019-01-10 03:07:36 -05:00
Brian Ashworth 4dba42555f get_inputs: add libinput send events mode
Add `libinput_send_events` to the IPC output for `get_inputs` to allow
scripting of mode changes.
2019-01-09 23:17:27 -05:00
Brian Ashworth 55e1d599a2 input_cmd_events: implement toggle
Implements toggling input events during runtime. This will not attempt
to toggle to a mode that is not supported by the device.

When toggling the wildcard input, the device specific input configs are
altered. Each device will cycle one supported mode.
2019-01-09 23:17:27 -05:00
Brian Ashworth 124085eba9 swaybar: obey height if given
If there is a bar height given, use that as the height rather than as a
minimum height. This matches i3-gaps behavior.
2019-01-09 20:58:00 -05:00
Brian Ashworth 39873bc1f0 swaybar: fix rendering of border and background
This fixes the rendering of borders and backgrounds for blocks. This
also makes the following changes:
* both borders and padding are scaled with the output
* both lines and rectangles are rendered without an antialiasing to
avoid bleeding outside the desired area
2019-01-09 20:28:30 -05:00
emersion d0b9701820
Merge pull request #3396 from RedSoxFan/scroll-titlebar-border
cursor: allow scrolling tabs/stack on title border
2019-01-10 00:32:09 +01:00
Brian Ashworth a8b3ae9284 cursor: allow scrolling tabs/stack on title border
This allows tabbed and stacked containers to be scrolled through when
the cursor is over the border of the title bar. The borders around the
other three edges of the contents should not be affected by this change.
2019-01-09 18:15:15 -05:00
Brian Ashworth eefa6b1ad3 bind{code,sym}: utilize mouse button helpers
This modifies `bindcode` and `bindsym` to use `get_mouse_bindcode` and
`get_mouse_bindsym`, respectively, to parse mouse buttons. Additionally,
the `BINDING_MOUSE` type has been split into `BINDING_MOUSECODE` and
`BINDING_MOUSESYM` to match keys and allow for mouse bindcodes to be
used. Between the two commands, all button syms and codes should be
supported, including x11 axis buttons.
2019-01-09 11:29:04 -05:00
Brian Ashworth 6f6a9af60e Add helpers for improved mouse button parsing
The following helper functions have been added to aid with parsing mouse
buttons from a string:

1. `get_mouse_bindsym`: attempts to parse the string as an x11 button
(button[1-9]) or as an event name (ex BTN_LEFT or BTN_SIDE)
2. `get_mouse_bindcode`: attempts to parse the string as an event code
and validates that the event code is a button (starts with `BTN_`).
3. `get_mouse_button`: this is a conveniency function for callers that
do not care whether a bindsym or bindcode are used and attempts to parse
the string as a bindsym and then bindcode.

None of these functions are used in this commit. The sole purpose of
this commit is to make the larger set more granular and easier to
review/manipulate. There will be a series of commits following this one
that will modify any command which uses a mouse button to use these
helpers.
2019-01-09 11:29:04 -05:00
Brian Ashworth 4696f49ecc reload: reset input configs
This resets all input options to their defaults on reload. This also
fixes some debug log typos in `input_manager_libinput_config_pointer`.
2019-01-09 11:24:15 -05:00
Ryan Dwyer 14cab78612 Reset container dimensions when moving into workspace from direction 2019-01-09 11:22:23 -05:00
emersion f9cea7f09b
Merge pull request #3391 from jbeich/freebsd
Simplify FreeBSD build
2019-01-09 14:00:54 +01: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
emersion d06782c5e7
Merge pull request #3386 from RedSoxFan/seat-reload-wait
reload: apply seat cfgs after reading entire cfg
2019-01-09 10:01:17 +01:00
emersion 8daea2bfec
Merge pull request #3390 from RedSoxFan/execute-seat
cmd_bind: pass the seat to execute_command
2019-01-09 09:59:09 +01:00
emersion cfdb614e84
Merge pull request #3372 from ianyfan/tray
swaybar: handle SNI signals better
2019-01-09 09:58:09 +01:00
emersion 51bc466e2b
Merge pull request #3389 from RedSoxFan/swap-context-seat
cmd_swap: use handler context seat
2019-01-09 09:54:16 +01:00
emersion ff62425480
Merge pull request #3387 from RedSoxFan/keyboard-timer-before-execute
keyboard: update repeat timer before execution
2019-01-09 09:52:39 +01:00
Brian Ashworth fdc262d402 cmd_bind: pass the seat to execute_command
`seat_execute_command` was incorrectly setting
`config->handler_context.seat` before calling `execute_command`. Since
`execute_command` was being called with a `NULL` seat argument,
`execute_command` was setting `config->handler_context.seat` to the
default seat. This resulted in all bindings being executed on the
default seat and causing undesired behavior for devices on other seats.
2019-01-09 01:50:40 -05:00
Brian Ashworth c4122e3975 cmd_swap: use handler context seat
Use the handler context seat instead of the default seat
2019-01-09 01:37:46 -05:00
Brian Ashworth 1feb2ce064 keyboard: update repeat timer before execution
Since the keyboard can be destroyed by executing a binding (reloading
with a different seat attachment config), update the repeat timer before
executing the binding.
2019-01-09 01:07:29 -05: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
Drew DeVault da8f24de1d
Merge pull request #3385 from robertgzr/reset_output_mapping
cursor: allow mapping to all outputs
2019-01-08 20:36:56 -05:00
Robert Günzler 145ac2c571 cursor: allow mapping to all outputs
Running `input "<input>" map_to_output *` resets the mapping to all outputs
2019-01-09 02:33:30 +01:00
Ian Fan f87628e2ab swaybar: improve tray logging 2019-01-08 16:03:16 +00:00
Ian Fan d093c3ac55 swaybar: handle SNI signals better
This fixes a crash caused by callbacks not matching the right sender,
and frees old values later, before they are re-assigned.
2019-01-08 12:18:59 +00:00
Ian Fan b666fc76a6 swaybar: free the right item during tray destruction
Also added a comment to make more obvious the reason for comparing
sni->status[0] == 'N'
2019-01-08 12:17:53 +00: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
emersion 353d9ed74f
Merge pull request #3337 from RedSoxFan/fix-seat-cmd-cursor
seat_cmd_cursor: work on seat name provided
2019-01-08 09:44:11 +01:00
emersion 327236a7ab Add data-control-v1 2019-01-07 17:01:53 -05:00
Rouven Czerwinski cc858e605a seat: unhide the cursor if it is warped to focus
Unhide the cursor if container warping is enabled.
Also set the image_surface to NULL during view_unmap, otherwise the cursor will
try to access the surface which is currently being unmapped.
2019-01-07 10:30:19 -05:00
Rouven Czerwinski 0b18560952 view: use seat_consider_warp_to_focus in view_unmap
The view_unmap function contained an open coded version of
seat_consider_warp_to_focus, replace it with a call to the function.
2019-01-07 10:30:19 -05:00
Rouven Czerwinski fde900861a cursor: move unhide and timeout retrieval into separate functions
The unhide and timeout retrieval functions are needed in a later commit. No
functional changes.
2019-01-07 10:30:19 -05:00
emersion bd59602711
Merge pull request #3381 from oscarwcl/swayidle-inhibit-sleep
swayidle: Fix sleep inhibitor not being acquired
2019-01-07 13:34:04 +01:00
Oscar Cowdery Lack 5a24ed2bf2 swayidle: Fix sleep inhibitor not being acquired
Fixes #3377.
The sleep lock file descriptor was immediately closed after it was
acquired due to the dbus message being freed. Now the fd is duplicated
before the message is freed so the inhibitor stays active.
2019-01-07 22:55:42 +11:00
emersion 688f4137a5
Merge pull request #3378 from jbeich/master
Unbreak build on 32bit platforms
2019-01-06 13:59:39 +01:00
Jan Beich 4a11d0e470 Use %z for printing size_t
../sway/desktop/transaction.c:367:17: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                        transaction, transaction->num_waiting);
                                     ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/wlr/util/log.h:56:72: note: expanded from macro 'wlr_log'
        _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
                                                                              ^~~~~~~~~~~
../sway/desktop/transaction.c:477:5: error: format specifies type 'long' but the argument has type 'unsigned int' [-Werror,-Wformat]
                                transaction->num_configures - transaction->num_waiting + 1,
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/wlr/util/log.h:56:72: note: expanded from macro 'wlr_log'
        _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
                                                                              ^~~~~~~~~~~
../sway/desktop/transaction.c:478:5: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                                transaction->num_configures, ms,
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/wlr/util/log.h:56:72: note: expanded from macro 'wlr_log'
        _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
                                                                              ^~~~~~~~~~~
2019-01-06 12:20:59 +00:00
Drew DeVault 728e5700dd
Merge pull request #3367 from oscarwcl/swaylock-fix-capslock
swaylock: Fix caps lock not updating immediately
2019-01-05 23:45:38 -05:00
Ryan Dwyer 0cc56ebe94 Fix urgency documentation 2019-01-05 23:34:04 -05:00
Drew DeVault bb5b168b6f Update README.md 2019-01-05 15:21:11 -05:00
PlusMinus0 d87cded568 Fixed formulations. 2019-01-04 12:44:03 +01:00
PlusMinus0 1b341834a6 Update sway-output.5.scd
Some more clarifications because it seems scale questions are recurring.
2019-01-04 12:44:03 +01:00
David96 ee50134634 Apply tiling_drag_threshold to all containers 2019-01-03 12:52:37 -05:00
Réouven Assouly 1450a9e9f9 completion: use jq instead of sed for swaybar completion 2019-01-02 21:38:32 -05:00
Réouven Assouly cf00fb2ccc zsh: update completions 2019-01-02 21:38:32 -05: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
Oscar Cowdery Lack 76cd3f2642 swaylock: Fix caps lock not updating immediately
Partially fixes #2788. This change makes it so the lock screen is
redrawn whenever the caps lock modifier state changes, rather
on relying on the keypress event. This didn't work because
caps lock is disabled when the key is released, not pressed,
so the caps lock indicator does not go away until the next
keypress event.
2019-01-03 09:28:14 +11:00
Ian Fan 5bef06adfd fixup! stringop.c: rewrite strip_whitespace 2019-01-02 18:47:22 +00:00
Mack Straight a96e86744f Fix fullscreen view rendering crash
See issue #3359 for reproduction details. When a fullscreen view is
unmapped and there's a preceding transaction waiting, there may be
neither a saved buffer or a surface to render. This change matches
the equivalent code in render_view.
2019-01-01 10:08:27 -05: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
Gaël PORTAY 3b4cf3718b bash: add completion for swaybar 2018-12-31 22:35:57 -05:00
Drew DeVault 3d7c20f062
Merge pull request #3249 from ianyfan/tray
Swaybar tray
2018-12-31 15:43:23 -05:00
Ian Fan 9e31f5d79c swaybar: use KDE's SNI IconThemePath property 2018-12-31 20:40:18 +00:00
Ian Fan 371089f62c swaybar: handle new and lost StatusNotifierWatcher 2018-12-31 20:40:18 +00:00
Ian Fan 8ffb7f0529 swaybar: draw a sad face if SNI has no icon 2018-12-31 20:40:18 +00:00
Ian Fan f33b5c5223 swaybar: do not create tray if hidden 2018-12-31 20:40:18 +00:00
Ian Fan 2fd41fe9c8 swaybar: set bar dirty on SNI event 2018-12-31 20:40:18 +00:00
Ian Fan 6becde0246 swaybar: implement mouse events for tray 2018-12-31 20:40:18 +00:00
Ian Fan fa2c5282c1 swaybar: implement tray rendering 2018-12-31 20:40:18 +00:00
Ian Fan 6b03c68775 swaybar: implement tray config 2018-12-31 20:40:18 +00:00
Ian Fan 74655f835a swaybar: add StatusNotifierItem to tray 2018-12-31 20:40:18 +00:00
Ian Fan e6cb55e2f8 swaybar: add StatusNotifierHost to tray 2018-12-31 20:40:18 +00:00
Ian Fan 746600e6ed swaybar: implement icon themes and lookup for tray 2018-12-31 20:40:18 +00:00
Ian Fan 02df3f67aa swaybar: add StatusNotifierWatcher to tray 2018-12-31 20:40:18 +00:00
Ian Fan ef555012fa swaybar: add skeleton dbus code to tray 2018-12-31 20:40:18 +00:00
Ian Fan 5f65f33989 swaybar: add tray interface 2018-12-31 20:40:18 +00:00
Ian Fan 598e950296 swaybar: remove old tray implementation 2018-12-31 20:40:18 +00:00
Brian Ashworth 4a3ada303b Apply implicit fallback seat config
The implicit fallback seat config needs to be applied (if created).
Otherwise, the input devices will still be removed from the implicit
default seat on reload when there is any seat config.
2018-12-31 11:37:07 +01:00
John Chen 54d0f3a40e Set font options when computing text width.
Fix #2869
2018-12-31 01:37:33 -05:00
Mack Straight 828060af73 swaybar: fix double free
status->text should not be freed here. There are two scenarios:

* status->text has been set to an error by status_error. In this case
  the value shouldn't be freed because it's always a reference to a
  constant.
* status->text has been set to status->buffer because the bar is in
  text protocol mode. In this case it's a double free because the
  buffer is already freed after.
2018-12-31 01:19:14 -05:00
Brian Ashworth 69e0982439
Merge pull request #3352 from emersion/env-docs
Undocument SWAY_CURSOR_THEME and SWAY_CURSOR_SIZE
2018-12-30 21:26:48 -05:00
emersion 72f8d0ff59
Undocument SWAY_CURSOR_THEME and SWAY_CURSOR_SIZE
These are not yet implemented, and will be exposed as a configuration command
rather than env variables when implemented.

This also adds a reference to sway-input(5) in xkb env configuration. Maybe we
should just un-document these instead.
2018-12-31 01:42:33 +01: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 6ec2983d96 seat_cmd_cursor: work on seat name provided
Instead of simulating events on the current seat, this makes it so
seat_cmd_cursor respects the seat name provided by `seat <name> cursor
<args>`. It also adds support for simulating events on all seats when
the wildcard is given.

This also defers the command when reading the config, which allows the
user to set the initial position of the cursor when the command is
included in the config file.
2018-12-29 22:02:19 -05:00
Brian Ashworth 3e8f548d1d Revamp seat configs
This makes seat configs work like output and input configs do. This also
adds support for wildcard seat configs. A seat config is still created
in the main seat command handler, but instead of creating a new one in
the subcommands and destroying the main seat command's instance, the
seat subcommands modify the main one. The seat config is then stored,
where it is merged appropriately. The seat config returned from
`store_seat_config` is then applied. When attempting to apply a wildcard
seat config, a seat specific config is queried for and if found, that is
used. Otherwise, the wildcard config is applied directly.

Additionally, instead of adding input devices to the default seat
directly when there is no seat configs, a seat config for the default
seat is created with only fallback set to true, which is more explicit.
It also fixes an issue where running a seat command at runtime (with no
seat config in the sway config), would result in all input devices being
removed from the default seat and leaving sway in an unusable state.

Also, instead of checking for any seat config, the search is for a seat
config with a fallback option seat. This makes it so if there are only
seat configs with fallback set to -1, the default seat is still created
since there is no explicit notion on what to do regarding fallbacks.
However, if there is even a single fallback 0, then the default seat is
not used as a fallback. This will be needed for seat subcommands like
hide_cursor where the user may only want to set that property without
effecting anything else.
2018-12-29 19:40:40 +01:00
Brian Ashworth 4503ad2d19 sway-output(5): doc scaling consideration for pos
This copies the information regarding positioning outputs when there
is scaling involved from the wiki to sway-output(5).
2018-12-29 17:25:29 +01:00
Brian Ashworth ae8937b11a Add failure reply on IPC_SYNC
Since it was decided that sway will not support IPC_SYNC, just return
`{'success': false}` as a reply
2018-12-29 17:07:26 +01:00
Brian Ashworth 0dbf2673a1 Remove button from state on release during op
This fixes a bug in `dispatch_cursor_button` where if there was an
operation occurring, the button would not be removed from the state on
release. This resulted in the button appearing to be permanently pressed
and caused mouse bindings to not match correctly.
2018-12-29 16:36:48 +01:00
Drew DeVault c54258f323
Merge pull request #3346 from ermo/sway-bar_focused_statusline_colour-render-fix
swaybar: fix focused_statusline color parsing.
2018-12-29 10:24:34 -05:00
Rune Morling 612702591c swaybar: fix focused_statusline color parsing. 2018-12-29 13:34:52 +01:00
Brian Ashworth f50d161574
Merge pull request #3345 from RyanDwyer/fix-scratchpad-crash
Fix crash when scratchpad contains split containers
2018-12-28 23:57:34 -05:00
Ryan Dwyer dd8d2dedf7 Fix crash when scratchpad contains split containers
To reproduce:

* Launch two terminals in a workspace
* `focus parent` to select both terminals
* `move scratchpad`
* `scratchpad show` to show the terminals
* `scratchpad show` to hide the terminals
* `scratchpad show` - crash

When hiding the terminals, it should be moving focus to whatever is in
the workspace, but this wasn't happening because the focus check didn't
consider split containers. So the terminals were hidden in the
scratchpad while still having focus. This confused the next invocation
of scratchpad show, causing it to attempt to hide them instead of show
them, and the hide-related code caused a crash when it tried to arrange
the workspace which was NULL.

This patch corrects the focus check.
2018-12-29 14:45:42 +10:00
NokiDev 9bf1b7a029 added fullscreen_mode to get_tree output
Signed-off-by: NokiDev <noki.dev@gmail.com>
2018-12-25 15:24:01 +01:00
Brian Ashworth 3248c823ed Split image_surface handling into own function 2018-12-25 13:31:56 +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 a223030b70 Change mouse buttons to x11 map and libevdev names
This modifies the way mouse bindings are parsed. Instead of adding to
BTN_LEFT, which results in button numbers that may not be expected,
buttons will be parsed in one of the following ways:

1. `button[1-9]` will now map to their x11 equivalents. This is already
the case for bar bindings. This adds support for binding to axis events,
which was not possible in the previous approach.

2. Anything that starts with `BTN_` will be parsed as an event code name
using `libevdev_event_code_from_name`. This allows for any button to be
mapped to instead of limiting usage to the ones near BTN_LEFT. This also
adds a dependency on libevdev, but since libevdev is already a dependency
of libinput, this should be fine. If needed, this option can have dependency
guards added.

Binding changes:
- button1: BTN_LEFT -> BTN_LEFT
- button2: BTN_RIGHT -> BTN_MIDDLE
- button3: BTN_MIDDLE -> BTN_RIGHT
- button4: BTN_SIDE -> SWAY_SCROLL_UP
- button5: BTN_EXTRA -> SWAY_SCROLL_DOWN
- button6: BTN_FORWARD -> SWAY_SCROLL_LEFT
- button7: BTN_BACK -> SWAY_SCROLL_RIGHT
- button8: BTN_TASK -> BTN_SIDE
- button9: BTN_JOYSTICK -> BTN_EXTRA

Since the axis events need to be mapped to an event code, this uses the
following mappings to avoid any conflicts:
- SWAY_SCROLL_UP: KEY_MAX + 1
- SWAY_SCROLL_DOWN: KEY_MAX + 2
- SWAY_SCROLL_LEFT: KEY_MAX + 3
- SWAY_SCROLL_RIGHT: KEY_MAX + 4
2018-12-25 13:27:08 +01:00
Brian Ashworth 00d97cb195 sway(5): document tiling_drag
Adds documentation in sway(5) for the tiling_drag command
2018-12-24 11:15:31 +01:00
Milkey Mouse 82b0296964 swaylock: Submit password on Ctrl-D
Ctrl-D functions as EOF in most cases on the terminal. login(1) & many other
programs check the password on EOF, same as Enter. To make behavior consistent,
have swaylock submit the password on Ctrl-D.

This commit moves the handling for Enter into its own static function, which is
now also called on Ctrl-D.
2018-12-23 12:08:03 +01:00
Milkey Mouse 9877189ea3 swaylock: Clear password buffer on Ctrl-C
I've got in the habit of using Ctrl-C with login(1) to restart password entry.
If Sway does the same thing I don't have to retrain my login muscle memory ;)
2018-12-23 12:08:03 +01:00
Brian Ashworth cf7c77e56a Fix wlr_box_intersection args for wlroots 1441
The fix pushed to master missed wlr_box_intersection. This just fixes
those lines so sway renders properly again
2018-12-22 18:54:08 +01:00
Drew DeVault 788b715776 Fixes per wlroots#1441 2018-12-22 08:53:05 -05:00
Aidan Harris 0d3cf36c85 IPC_SUBSCRIBE ensure request object is an array
Fixes #3320
2018-12-22 14:02:29 +01:00
Brian Ashworth 88d96bc41f Combine output_by_name and output_by_identifier
This combines `output_by_name` and `output_by_identifier` into a single
function called `output_by_name_or_id`. This allows for output
identifiers to be used in all commands, simplifies the logic of the
callers, and is more efficient since worst case is a single pass through
the output list.
2018-12-20 19:55:29 +01:00
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
Ryan Dwyer 3a4f4f5d66 Return success when renaming a workspace to itself 2018-12-18 14:00:39 +01:00
Drew DeVault e726b5c445
Merge pull request #3308 from RedSoxFan/fix-titlebar-click
Focus node before tiling drag if on titlebar
2018-12-17 19:05:33 -05:00
Brian Ashworth 0ea54833d4 Focus node before tiling drag if on titlebar
Before attempting to drag a tiling container by its titlebar,
focus it. This fixes clicking on titlebars to focus a container.
2018-12-17 16:55:44 -05:00
Brian Ashworth 0d741782c4
Merge pull request #3305 from emersion/isue-template-stack-trace
issue template: add instructions for stack traces
2018-12-17 12:42:49 -05:00
emersion 4a42561a62
issue template: add instructions for stack traces 2018-12-17 18:38:15 +01:00
Brian Ashworth 4e2cfe0526 cmd_split: add null checks in do_split
Fixes a crash when running `split` commands with the workspace focused.
2018-12-17 18:23:32 +01:00
Brian Ashworth 5f25541022 Allow output ids and wildcard for workspace output
This allows for output identifiers and to be used in the `workspace
<workspace> output <outputs...>` command. Previously, only output names
would be allowed. If an output identifier was given, it would never match
an output. This also allows for the wildcard character (`*`) to be
specified, which can be used to generate a list of workspace names that
should be used when generating new workspaces
2018-12-17 16:25:44 +01:00
Brian Ashworth eb527ac01a swaynag: remove double free of details button
If there are no arguments or invalid arguments given, swaynag will free
`swaynag.details.button_details` under the `cleanup` label in main. It
then called `swaynag_destroy`, which would attempt to free it again.

Since `swaynag.details.button_details` is either freed on line 106 of
main (when there is no detailed message) or added to `swaynag.buttons`
on line 103 of main, there is no reason to manually free it in
`swaynag_destroy`.

Although I cannot reproduce a double free on my system, for some reason,
it should have actually resulted in a double free in all code paths.
2018-12-17 09:21:14 +01:00
Brian Ashworth 8d7ebc258a Allow tiling views to be dragged by the titlebar
Enables titling views to be dragged by the titlebar. This is in addition
to using the modifier and dragging them from anywhere on the container
surface. Floating views already allow this behavior.
2018-12-17 09:08:26 +01:00
Rostislav Pehlivanov 1442d4e688 Update for swaywm/wlroots#1377
-Werror is eͫ̐ͭ҉vi͆ͦ̏ͦlͥ̀͒̊͂͛
2018-12-16 15:04:06 +01:00
Brian Ashworth c8284176db swaynag: damage the cursor surface on update
When the cursor surface gets updated, it should be damaged.

This also bumps up `wl_compositor` to version 4 to be able to use
`wl_surface_damage_buffer`.
2018-12-15 09:51:44 +01:00
Brian Ashworth 35a82a8693 swaybar: fix cursor scale
This fixes a few issues with swaybar's cursor scaling:
1. The cursor scale is now changed when the output scale changes
2. The cursor scale is no longer bound by the max output scale when
swaybar is launched
3. Related to the previous item, the cursor is no longer tiny on low
scale outputs after the max output scale has changed

This also bumps up `wl_compositor` to version 4 to allow usage of
`wl_surface_damage_buffer`.
2018-12-15 09:26:50 +01:00
Ryan Dwyer cd714cc12a
Merge pull request #3291 from RedSoxFan/fix-focus-nonvis
Fix focusing on non-visible workspace
2018-12-15 09:51:56 +10:00
Brian Ashworth c2499772b9 Fix focusing on non-visible workspace
My previous attempt was not quite right. Changing the focus stack on a
non-visible workspace should only be blocked if the focus would be set
to the workspace itself
2018-12-14 13:59:54 -05: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
mwenzkowski 01420193ef Fix criteria execution in view_map
This patch moves view_execute_criteria(view) below the fullscreen code.
Previously, if a view requested to be started in fullscreen, this was
done after execution of criteria and hence it was impossible to disable
fullscreen via criteria.

Fixes #3285
2018-12-12 13:41:47 +01:00
Brian Ashworth 549d9fe489 swaybar: fix sep block width for mixed scales
When there are outputs with mixed scales, it was possible for swaybar to
alter `block->separator_block_width` for an output with a higher scale,
and use the changed value for a lower scale output. This caused there to
be larger than normal separation between blocks on the lower scale
outputs. The issue is more obvious the larger the scale difference
between the highest scale output and the lowest scale output.

This fixes the issue by using a local variable that is originally set to
`block->separator_block_width` for rendering, but if it needs to be
increased, the local variable is the only thing touched.
2018-12-12 10:23:57 +01:00
Brian Ashworth 8b4fe7dd15 swaybar: handle block->urgent
When `block->urgent` is set, use the urgent colors. This matches i3bar's
behavior. Previously, swaybar just ignored the property.

This also adds in rendering for right borders, which was missing.
2018-12-12 10:17:39 +01:00
Brian Ashworth bc981b2bbb Keep focus when destroying containers on nonvis ws
Changing the focus stack when destroying a container's node on a
non-visible workspace (on an non-focused output) incorrectly causes
the non-visible workspace to become visible. If the workspace is empty,
it will not be destroyed since it is now visible. Additionally since
there was no workspace::focus event, swaybar still shows the previous
workspace as focus-inactive. It also makes no sense to change visible
workspaces due to a container on a non-visible workspace being
destroyed.

Since the focus will either be set when switching to the non-visible
workspace or the workspace will be destroyed due to being empty, there
is no need to change the focus stack when destroying a container on a
non-visible workspace.
2018-12-12 10:13:50 +01:00
Brian Ashworth 6acbe84fdd Call wlr_output_enable for disabled new outputs
When a new output is detected and it is disabled by the output config,
call `wlr_output_enable(output->wlr_output, false)` to DPMS off the
output.
2018-12-10 08:59:24 +01:00
Ryan Dwyer b61a936c80
Merge pull request #3271 from ianyfan/list-cleanup
list.c: Remove list_foreach
2018-12-09 21:50:19 +10:00
Brian Ashworth e7efa0e27b
Merge pull request #3264 from ianyfan/resize-list
list: double list capacity when resizing instead of incrementing
2018-12-08 22:40:13 -05: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
Ryan Dwyer 0c3f0dfd16
Merge pull request #3260 from RedSoxFan/split-flatten
cmd_split: flatten when possible
2018-12-08 09:46:59 +10:00
Ian Fan bd6a639667 list: double list capacity when resizing instead of incrementing
This is the industry standard since it allows insertion to be amortized
O(1) time.
2018-12-06 12:02:55 +00:00
Brian Ashworth 7b23a1a0d8 cmd_split: flatten when possible 2018-12-05 21:46:02 -05:00
mwenzkowski cf6edaf26a Fix command list execution
Determine the container/workspace a command is run on, each time when a
command of the command list will be run.
Previously the container/workspace was determined only once at the
beginning of command list execution, which led to wrong behaviour
because commands wouldn't take into account when a previous command
changed the focused container.
2018-12-05 11:32:23 +01:00
Brian Ashworth 6ccc836ebf
Merge pull request #3252 from hvenev/swaybar-rel
Add relative coordinates in JSON for i3bar click events
2018-12-04 23:55:55 -05:00
Hristo Venev 24e8ba048a Add relative coordinates in JSON for i3bar click events
Compatibility with i3 commit 161db6f17d734ac9deb0a20e81b78d4b2a92ce68.
2018-12-04 12:49:21 +02: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 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
Brian Ashworth 2942bbbc60 cmd_focus: show scratchpad if hidden
If a scratchpad container is hidden, it is still focusable using
criteria and should be shown. This fixes a segfault when attempting to
rebase the cursor since previously the scratchpad container would not be
on any output.
2018-12-03 08:49:26 +01:00
Brian Ashworth 6788910fd7
Merge pull request #3239 from ForTheReallys/bindsym-no-warn
Add option to bindsym/bindcode to suppress warning on override
2018-12-02 22:41:22 -05:00
Alex Maese 1a1a2d96cb Add option to bindsym/bindcode to suppress warning on override 2018-12-02 21:35:44 -06:00
bschacht bf11a77884 fix typo
tranform -> transform
2018-12-02 20:48:53 +01:00
bschacht c4406c206e fix typo
bahavior -> behavior
2018-12-02 20:48:29 +01:00
Drew DeVault 974a3fbc59
Merge pull request #3227 from emersion/swap-buffers-damage-coords
Update for swaywm/wlroots#1403
2018-12-02 13:17:37 -05:00
emersion 20e7584c3a
Merge pull request #3228 from ianyfan/swayidle
meson.build: remove obsolete definition of swayidle_deps
2018-12-02 03:49:08 +01:00
Brian Ashworth 7702943e58
Merge pull request #3229 from mwenzkowski/fix-fullscreen-cmd
Fix fullscreen command and improve documentation
2018-12-01 14:33:36 -05:00
Ian Fan 49502494e7 meson.build: remove obsolete definition of swayidle_deps 2018-12-01 13:55:19 +00:00
emersion ed7bd683a7
Update for swaywm/wlroots#1403 2018-12-01 11:01:08 +01:00
emersion d5678a147f
Merge pull request #3226 from CameronNemo/musl
swaylock: fix build with musl libc
2018-12-01 08:35:22 +01:00
Cameron Nemo c6b2ee7291
swaylock: fix build with musl libc
Signed-off-by: Cameron Nemo <camerontnorman@gmail.com>
2018-11-30 23:22:09 -08:00
mwenzkowski 68668c22e5 sway.5: Improve documentation
Document the optional arguments of the fullscreen command.
2018-11-30 18:15:26 +01:00
mwenzkowski b5c92e5d3b Fix the error result of the fullscreen command
Changes the error result from CMD_INVALID to CMD_FAILURE, since
CMD_INVALID indicates an unknown command or parser error and neither
occurs where CMD_INVALID was used.
2018-11-29 17:03:04 +01:00
emersion fd37ded3a3
Merge pull request #3219 from RedSoxFan/swaymsg-object-success
swaymsg: parse success of single object
2018-11-29 09:10:00 +01:00
Brian Ashworth cf1793b4f1
Merge pull request #3218 from johnae/master
Fix json object ipc success return
2018-11-29 02:37:27 -05:00
John Axel Eriksson aef52154ec
Fix json object ipc return 2018-11-29 08:28:42 +01:00
Brian Ashworth e62ab6ddbd swaymsg: parse success of single object
Allows swaymsg to parse the success attribute of a single object
response. This is needed for the subscribe event.
2018-11-28 21:41:58 -05:00
emersion 9d18d81d48
Merge pull request #3216 from RedSoxFan/fix-empty-titlebars
Fix titlebar when no title or marks
2018-11-28 21:05:59 +01:00
emersion 659ab79b66
Merge pull request #3214 from RedSoxFan/fix-3156
Fix default_orientation auto
2018-11-28 21:00:34 +01:00
Brian Ashworth 14cb39c772 Fix titlebar when no title or marks
This fixes the rendering of the titlebar when there is no title or marks.
2018-11-28 14:20:58 -05:00
Brian Ashworth 71ae08530a Fix default_orientation auto
Since the output config is no longer applied before creating the default
workspace, the layout for default workspaces on an output may not be
correct. Due to the ordering of calls in output_enable being changed in
several bug fix PRs, this just fixes the layout after the call to
apply_output_config.
2018-11-28 13:52:54 -05:00
emersion 9924d72ab2
Merge pull request #3213 from RedSoxFan/fix-3203
Fix scratchpad segfault - NULL focused workspace
2018-11-28 19:16:01 +01:00
Brian Ashworth f52277f66e Fix scratchpad segfault - NULL focused workspace
When adding a container to the scratchpad, it was possible for focus to
be removed from the seat. This occurred when a single child was moved
from it's parent to the scratchpad due to the focus_inactive for the
parent being NULL. If the focus_inactive for the parent is NULL, the
focus_inactive for the workspace should be focused.
2018-11-28 13:02:54 -05:00
emersion 67c7cc53ae
Merge pull request #3206 from RedSoxFan/ipc-subscribe
Implement support for swaymsg -t SUBSCRIBE [-m]
2018-11-28 17:58:36 +01:00
emersion 2c31e82675
Merge pull request #3208 from RedSoxFan/bar-gaps
Implement bar gaps
2018-11-28 17:57:35 +01:00
Brian Ashworth 1bd8463481 Implement bar gaps
Adds the bar subcommand `gaps <amount>|<horizontal> <vertical>|<top>
<right> <bottom> <left>` to set gaps for swaybar. Due to restrictions on
margins for a layer_surface, only the sides that are anchored to an edge
of the screen can have gaps. Since there is support for per-side outer
gaps for workspaces, those should be able to be used instead for the
last side.
2018-11-28 11:24:14 -05:00
Brian Ashworth bf9a52bab0 Implement support for swaymsg -t SUBSCRIBE [-m]
In `i3 4.16`, `i3-msg` can be used with the message type `subscribe`
and has the ability to monitor for responses until killed. This adds
support for both to swaymsg.

If the JSON array of event types is malformed or contains an invalid
event, sway will send a response with `success` set to `false`. If
swaymsg sees this, it will not display the failure and exit.

If the `subscribe` event is successful, swaymsg will wait for the first
response and display that instead of the success message. If
`-m/--monitor` is given, swaymsg will continue monitor for responses
until killed or a malformed response is received.

For the `subscribe` event, the responses will always be printed as JSON.
If `-r/--raw` is given, the JSON will not be pretty printed, which may
be preferred when monitoring due to there being multiple responses.

Example: `swaymsg -t SUBSCRIBE -m "['window']"`
2018-11-28 11:19:18 -05:00
Brian Ashworth 5341e034df
Merge pull request #3212 from martinetd/move_floating
move to workspace: fix moving floating container to non-empty workspace
2018-11-28 11:16:14 -05:00
emersion ef18745951
Merge pull request #3202 from RedSoxFan/swaynag-config-warnings
Introduce a way to show config warnings in swaynag
2018-11-28 17:13:24 +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
Dominique Martinet 2543834172 move to workspace: fix moving floating container to non-empty workspace
moving a container to a non-empty workspace will find a container to move
to in the destination workspace and call container_move_to_container,
which must not just skip floating containers
2018-11-29 00:08:43 +09:00
Ryan Dwyer a22d0c0ff6
Merge pull request #3211 from emersion/child-view-unmapped-segfault
Fix segfault when destroying unmapped child view
2018-11-28 23:27:46 +10:00
emersion b98563d2d7
Fix segfault when destroying unmapped child view 2018-11-28 14:08:20 +01:00
Ryan Dwyer f737854e30
Merge pull request #3199 from emersion/handle-subsurface-destroy
Handle destroyed subsurfaces
2018-11-28 20:46:22 +10:00
emersion c931a13af9
Merge pull request #3207 from RedSoxFan/swaynag-no-term-buttons
Implement swaynag -B/--button-no-terminal
2018-11-28 09:44:26 +01:00
emersion 048b96a56d
Merge pull request #3204 from RedSoxFan/cmd-res-list
Change execute_command to return a list of results
2018-11-28 09:26:47 +01:00
emersion 60e1fb547c
Merge pull request #3209 from RedSoxFan/fix-3146
Do not strip quotes for cmd_mode
2018-11-28 08:01:17 +01:00
Brian Ashworth 315bca176c Do not strip quotes for cmd_mode
Like with cmd_bindsym and cmd_bindcode, the quotes should not be
stripped for cmd_mode. cmd_mode performs its own stripping for the mode
name and the only valid subcommands are cmd_bindsym and cmd_bindcode.
2018-11-28 01:28:03 -05:00
Brian Ashworth 673da83260 Implement swaynag -B/--button-no-terminal
In `i3 4.16`, `i3-nagbar` introduces the flags `-B/--button-no-terminal`
to run the action directly instead of inside a terminal. This implements
the flags for swaynag for compatibility.

Since swaynag does not use an equivalent to `i3-sensible-terminal`, the
flags `-b/--button` only uses a terminal when the environment variable
`TERMINAL` is set, otherwise it acts the same as these new flags.
2018-11-27 23:34:51 -05:00
Brian Ashworth 5c6f3d7266 Change execute_command to return a list of results
This matches i3's behavior of returning a list of results that contain
the result of each command that was executed. Additionally, the
`parse_error` attribute has been added to the IPC JSON reply.
2018-11-27 21:42:09 -05:00
emersion 1d30b7c0f6
Damage view child when destroyed 2018-11-27 21:13:08 +01:00
emersion fc79b7c2d2
Handle destroyed subsurfaces
Damage subsurfaces when they are destroyed. Since subsurfaces don't have an
unmap event we need to do that on destroy.

We also don't want to keep a sway_view_child when the wlr_subsurface has been
destroyed.

Fixes https://github.com/swaywm/sway/issues/3197
2018-11-27 11:46:30 +01:00
Drew DeVault dbf8e1cead
Merge pull request #3175 from emersion/rename-gtk-primary-selection
Update for swaywm/wlroots#1387
2018-11-26 18:41:30 -05:00
Brian Ashworth a22e7b13ad
Merge pull request #3168 from mihaicmn/scratchpad-events
Fix missing IPC scratchpad replies/move events
2018-11-26 12:02:27 -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
Ian Fan 0ebb4107bc
Merge pull request #3191 from emersion/fix-swayidle-busy-dispatch
swayidle: fix busy loop on writable FD
2018-11-26 09:33:30 +00:00
Mihai Coman 39db9b855d IPC: Use consistent function names across ipc-json 2018-11-26 11:15:40 +02:00
Mihai Coman 65c32e41d4 IPC: Add scratchpad containers to get_tree reply
This patch lists all hidden scratchpad containers as floating nodes
on "__i3_scratch" workspace. This workspace resides on "__i3" output.
2018-11-26 11:15:25 +02:00
Mihai Coman 6aafdd2321 IPC: Trigger move events for scratchpad containers
This patch allows IPC clients to receive window::move events
when containers are moved to scratchpad or when hidden containers
are shown via "scratchpad show" command.
2018-11-26 11:13:47 +02:00
emersion c2921b2e61
Merge pull request #3169 from RedSoxFan/title-align
Implement title alignment
2018-11-26 09:28:25 +01:00
Brian Ashworth 0e6e5af983
Merge pull request #3183 from emersion/fix-escape-pango
Fix pango title escaping
2018-11-25 22:25:12 -05: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 814dc1dfe5
swayidle: fix busy loop on writable FD
The wl_event_source_fd_update docs say:

> File descriptors are usually writable to begin with, so they do not need to
> be polled for writable until a write actually fails. When a write fails,
> the event mask can be changed to poll for readable and writable, delivering
> a dispatch callback when it is possible to write more. Once all data has
> been written, the mask can be changed to poll only for readable to avoid
> busy-looping on dispatch.

So we should only poll for WL_EVENT_WRITABLE if a write fails. I'm not yet sure
how to do this properly and Weston doesn't do it, so in the meantime I'll just
fix the busy loop. I'll ask them too.

Fixes https://github.com/swaywm/sway/issues/3190
2018-11-25 18:10:01 +01:00
emersion 91bbb2a7dd
Merge pull request #3184 from kupospelov/fix-resize
resize set: fix units for floating containers
2018-11-25 17:41:45 +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 d46d221118
Merge pull request #3049 from ianyfan/swayidle
Swayidle fixes
2018-11-25 13:47:21 +01:00
Konstantin Pospelov f9bde0030d resize set: add assertion for an invalid unit 2018-11-25 15:16:45 +03:00
Konstantin Pospelov a7b9e63cbc resize set: fix units for floating containers
This commit fixes the default size units for floating containers, so that
pixels are used if the units are not specified.
2018-11-25 12:33:11 +03:00
emersion b84bf3585c
Fix pango title escaping
This commit fixes two bugs.

First, commit [1] has inverted the condition when we escape pango markup. We
need to escape client-provided strings when markup is enabled.

Second, parse_title_format has a shortcut when title_format is set to `%title`,
and escape_pango_markup wasn't used anymore there.

Fixes https://github.com/swaywm/sway/issues/3181

[1]: caee2dff03
2018-11-25 09:09:32 +01:00
emersion 9b88ee0143
swayidle: fix dbus_event not to block 2018-11-24 23:26:57 +01:00
emersion 41ffb5b4d5
swayidle: listen when display becomes writable 2018-11-24 23:18:44 +01:00
Ian Fan 6358de3827
swaylock: fix display_event to not block 2018-11-24 23:10:05 +01:00
Ian Fan 6e2dccc2e9
swayidle: when acquiring sleep lock, initialize and free variables properly 2018-11-24 23:10:05 +01:00
emersion 827e5513e0
Merge pull request #3179 from baloo/baloo/title_format-pango_markup
fixes pango_markup support with title_format
2018-11-24 23:07:13 +01:00
Arthur Gautier caee2dff03 fixes pango_markup support with title_format
The support for pango_markup was broken in title_format because the
formated title was escaped. I think only the payload should be escaped.

This commit fixes 789a877b37
2018-11-24 08:26:43 -08:00
emersion d440468d2d
Merge pull request #3145 from fdlamotte/master
Adding commands for configuring titlebar borders and padding
2018-11-24 08:59:01 +01:00
emersion d9ed1f080b
Merge pull request #3178 from progandy/sysconfdir
Meson: Fix SYSCONFDIR definition
2018-11-24 08:06:25 +01:00
progandy c4bbd0d3c6 Meson: Fix SYSCONFDIR definition.
SYSCONFDIR was set to the wrong path if prefix is not '/usr' and
sysconfdir is an absolute path. Use join_paths() to fix it.

Also remove the special case for prefix '/usr'. In that case Meson
already sets sysconfdir to the absolute path '/etc', so just using
join_paths() will return the correct value.

    join_paths('/usr/local', 'etc') => '/usr/local/etc'
    join_paths('/usr/local', '/etc') => '/etc'
    join_paths('/usr', '/etc') => '/etc'
2018-11-23 23:30:46 +01:00
emersion cc28f9712e
Update for swaywm/wlroots#1387 2018-11-23 12:07:46 +01:00
Florent de Lamotte 7555c7efdc Adding commands for configuring titlebar borders and padding 2018-11-22 10:30:04 +01:00
emersion 77554f545e
Merge pull request #3158 from emersion/get-outputs-focused
ipc: fix focused in get_outputs reply
2018-11-22 09:16:14 +01:00
emersion d63f9028d7
Merge pull request #3171 from camoz/master
fix typo in swayidle(1)
2018-11-22 08:53:48 +01:00
camoz 075b080f54 fix typo in swayidle(1) 2018-11-21 23:13:23 +01:00
emersion cecf00b924
Merge pull request #3160 from camoz/master
fix typo in config.in
2018-11-20 22:53:29 +01:00
camoz 101e4e55a2 fix typo in config.in 2018-11-19 22:32:08 +01:00
emersion 2f1050796c
ipc: fix focused in get_outputs reply
It's set even if a child of the output is focused.
2018-11-19 19:57:41 +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
emersion 311c7db7e3
Add xwayland command 2018-11-19 17:38:37 +01:00
Drew DeVault 67d24e8fc5
Merge pull request #3152 from camoz/master
fix typo in config.in
2018-11-18 21:57:54 -05:00
camoz a476efc5a6 fix typo in config.in 2018-11-19 02:45:59 +01:00
Brian Ashworth b2c5248ad3
Merge pull request #3018 from sxmichaels/add-scroll-factor
Add scroll factor input command.
2018-11-18 14:05:03 -05:00
Spencer Michaels 70bc4c3ab6 Add scroll factor config option. 2018-11-18 13:49:30 -05:00
Drew DeVault b87250425f
Merge pull request #3147 from emersion/set10
Use #if instead of #ifdef
2018-11-18 08:22:25 -05:00
emersion cad851805b
Use #if instead of #ifdef 2018-11-18 00:33:06 +01:00
Connor E 4bd46fb079 Implement strip_workspace_name. 2018-11-17 16:11:28 +00:00
Drew DeVault eda3bfeed5
Merge pull request #3142 from RyanDwyer/move-view-properties
Move view {x,y,width,height} into container struct
2018-11-17 11:04:34 -05:00
Drew DeVault a5cdc293dc
Merge pull request #3143 from colemickens/grow
commands/resize: fix grow vars uninitialized
2018-11-17 11:03:42 -05:00
Ryan Dwyer be9348d25c Move view {x,y,width,height} into container struct
This renames/moves the following properties:

* sway_view.{x,y,width,height} ->
sway_container.content_{x,y,width,height}
    * This is required to support placeholder containers as they don't
    have a view.
* sway_container_state.view_{x,y,width,height} ->
sway_container_state.content_{x,y,width,height}
    * To remain consistent with the above.
* sway_container_state.con_{x,y,width,height} ->
sway_container_state.{x,y,width,height}
    * The con prefix was there to give it contrast from the view
    properties, and is no longer useful.

The function container_set_geometry_from_floating_view has also been
renamed to container_set_geometry_from_content.
2018-11-17 21:29:42 +10:00
Cole Mickens fb6ef83b16 commands/resize: fix grow vars uninitialized 2018-11-17 03:23:06 -08:00
Ryan Dwyer cb63321de6
Merge pull request #3132 from emersion/dispatch-cursor-btn-segfault
Fix segfault in dispatch_cursor_button
2018-11-17 20:24:01 +10:00
emersion b67baf5108
Merge pull request #3141 from tslocum/resize-set-floating-ppt
resize set: convert ppt to px for floating containers
2018-11-17 11:20:08 +01:00
Trevor Slocum f4ccc51da0 resize set: convert ppt to px for floating containers 2018-11-16 07:30:46 -08:00
emersion 4ce18d2744
Fix segfault in dispatch_cursor_button 2018-11-15 16:35:19 +01:00
Drew DeVault c36665bc17
Merge pull request #3130 from RyanDwyer/fix-mode-double-free
Fix double free of mode
2018-11-15 09:35:51 -05: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
Brian Ashworth 0451acfb75
Merge pull request #3128 from RyanDwyer/fix-unmap-crash
Fix double free when unmapping any view
2018-11-15 00:38:42 -05:00
Ryan Dwyer 2115ebe39d Fix double free when unmapping any view 2018-11-15 15:22:09 +10:00
Drew DeVault 932d6ee0d4
Merge pull request #3126 from emersion/swap-unused-function
Fix unused function in swap command
2018-11-14 21:43:40 -05:00
Drew DeVault 484bf591be
Merge pull request #3121 from c-edw/feature/MissingFrees
[WIP] Free unfreed resources.
2018-11-14 21:25:26 -05:00
emersion 98a953a872
Fix unused function in swap command
Also fixes a size_t cast to void *.
2018-11-14 19:31:43 +01:00
Drew DeVault 47cca240e2
Merge pull request #3102 from emersion/render-software-cursors
Render software cursors with wlr_output_render_software_cursors
2018-11-13 14:59:48 -05: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
Drew DeVault 27b930df24
Merge pull request #3117 from emersion/wlroots-config10
Use #if instead of #ifdef for WLR_HAS_*
2018-11-12 20:35:27 -05:00
emersion 2afd930914
Use #if instead of #ifdef for WLR_HAS_* 2018-11-12 22:23:06 +01:00
emersion 3b8d4a9212
Merge pull request #3116 from harishkrupo/master
IPC: Send keyboard layout info in IPC_GET_INPUTS
2018-11-12 21:26:00 +01:00
Harish Krupo d8ad429e39 IPC: Send keyboard layout info in IPC_GET_INPUTS
Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2018-11-12 22:00:22 +05:30
Drew DeVault 2e43f02427
Merge pull request #2979 from RedSoxFan/config-var-repl
Alter config variable replacement process
2018-11-12 11:13:59 -05:00
Drew DeVault ee6b0ce24a
Merge pull request #3113 from RedSoxFan/fix-ws-auto-back-and-forth
cmd_ws_auto_back_and_forth: fix negation
2018-11-11 16:16:28 -05:00
Brian Ashworth 62d69e9f14 cmd_ws_auto_back_and_forth: fix negation
In the conversion to `parse_boolean` for `cmd_ws_auto_back_and_forth`,
the `negation` was never removed causing the setting to be the opposite
of what it should be.
2018-11-11 16:05:13 -05:00
Drew DeVault 101515eb0c
Merge pull request #3108 from RedSoxFan/workspace-output-improved
Allow multiple outputs for workspace output
2018-11-11 11:30:27 -05:00
Brian Ashworth 12876932a9 Allow multiple outputs for workspace output
`i3 4.16` allows users to list multiple outputs for a workspace and the
first available will be used. The syntax is as follows:
`workspace <workspace> output <outputs...>`

Additionally when the workspace is created, the outputs get added to the
output priority list in the order specified. This ensures that if a higher
output gets connected, the workspace will move to the higher output. This
works the same way as if the user had a workspace on an output, disconnected
the output, and then later reconnected the output.
2018-11-11 11:22:38 -05:00
Brian Ashworth b277000601 Alter config variable replacement process
Currently, variables cannot contain commands and cannot span more than
one argument. This is due to variable replacement happening after
determining the handler and after splitting the config line into
arguments.

This changes the process to:
0. Check for empty lines and block boundaries
1. Split the arguments as before
2. Verify that the first argument is not a variable. If needed the
following occurs
    a. Perform variable replacement on just the first argument
    b. Join the arguments back together then split the arguments again. This is needed when the variable
contains the command and arguments for the command.
3. Determine the handler
4. If the handler is cmd_set, escape the variable name so that it does
not get replaced
5. Join the arguments back together, do variable replacement on the full
command, and split the arguments again
6. Perform any needed quote stripping or unescaping on arguments
7. Run the command handler

This allows for config snippets such as:

```
set $super bindsym Mod4
$super+a exec some-command
```

and

```
set $bg bg #ffffff solid_color
output * $bg
```
2018-11-10 21:53:10 -05:00
emersion 528f129c98
Render software cursors with wlr_output_render_software_cursors 2018-11-10 19:22:32 +01:00
Drew DeVault 80a1c340a9
Merge pull request #3098 from c-edw/feature/RefactorArgParse
Use parse_boolean where possible.
2018-11-10 08:06:11 -05:00
Connor E b865dabeba Use parse_boolean where possible. 2018-11-10 12:55:06 +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 cfcedfca71
Merge pull request #3091 from c-edw/feature/FocusFollowsMouseDoc
Update documentation for focus_follows_mouse.
2018-11-08 15:53:02 -05:00
Connor E 78d07f5be4 Update documentation for focus_follows_mouse. 2018-11-08 20:38:50 +00:00
Drew DeVault 5880478fb1
Merge pull request #3090 from RedSoxFan/resize-set-improved
resize set: implement width and height keywords
2018-11-08 14:39:20 -05:00
Brian Ashworth c248e96b84 resize set: implement width and height keywords
This implements the following syntaxes from `i3 4.16`:
* `resize set [width] <width> [px|ppt]`
* `resize set height <height> [px|ppt]`
* `resize set [width] <width> [px|ppt] [height] <height> [px|ppt]`

Additionally, a bug was fixed that caused setting the height of a tiled
container to change the width instead due to a typo.
2018-11-08 14:17:49 -05:00
emersion 0bc819dd8b
Merge pull request #3089 from sghctoma/fix-clang-build
Fix building with clang
2018-11-08 14:28:37 +01:00
sghctoma 7ead20bfcf Fix building with clang
The "struct sway_container *other" variable in swap.c was potentially
used uninitialized, depending on an "if" statement.
2018-11-08 13:57:04 +01:00
Ryan Dwyer aad2f444f0
Merge pull request #3087 from RedSoxFan/side-gaps
Implement per side and per direction outer gaps
2018-11-08 22:41:14 +10:00
Drew DeVault e53b4813fe
Merge pull request #3086 from RedSoxFan/fix-dup-inner-gaps
gaps: remove duplicate inner gaps
2018-11-08 07:06:41 -05: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
Brian Ashworth 6a42643784 gaps: remove duplicate inner gaps 2018-11-07 22:42:18 -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
emersion 001ec1f3fd
Merge pull request #3046 from tokyovigilante/relative-transform
Add relative output transform
2018-11-06 14:17:33 +01:00
Ryan Walklin 5032acb7a5 Add relative output transform
This commit enhances the output transform
command with options for a relative transform,
i.e. the provided transform will be applied as
an offset to the current transform. Append
`clockwise` to rotate clockwise from the current
rotation, or `anticlockwise` to rotate in the
opposite direction.

For example, if the output LVDS-1 is rotated
90 degrees clockwise, the command
`output LVDS-1 transform 90 clockwise`
will rotate the display to 180 degrees.
All transform options are supported,
including flipped transforms.

Relative transforms can only be applied to
a single output and cannot be used with
a wildcard (*) output specifier.
2018-11-05 22:58:27 +00:00
Drew DeVault 994c35e375
Merge pull request #3068 from emersion/effective-damage
Use wlr_surface_get_effective_damage
2018-11-05 21:31:22 +01:00
Drew DeVault 25bea8f6a5
Merge branch 'master' into effective-damage 2018-11-05 21:21:47 +01:00
Drew DeVault fbf1730557
Merge pull request #3078 from Emantor/fix/exec_always_double_load
Fix the double execution of exec_always commands on config reloads
2018-11-05 21:15:56 +01:00
Rouven Czerwinski f54287eaf3 config: mention that reload message is also printed on validation 2018-11-05 21:06:28 +01:00
Rouven Czerwinski 5fdffea99a commands/exec_always: defer command on config validation
The exec_always command was executed twice, since it was not checking for the
config->validating variable.
Fix this by defering the command if the configuration is validating.

Fixes #3072
2018-11-05 20:32:45 +01:00
emersion e9c77970fa
Merge pull request #3071 from RedSoxFan/fix-3064
Fix focus_wrapping yes
2018-11-05 18:59:44 +01:00
Brian Ashworth c8c1ecaf25 Fix focus_wrapping yes
It appears that the focus code that handles `focus_wrapping yes` was
removed during the conversion to type safety. This re-implements the
focus code for when `focus_wrapping` is set to `yes` (default). Neither
the `no` or `force` options appear to be effected and should be working.
2018-11-05 12:39:44 -05:00
Drew DeVault 77d581f144
Merge pull request #3075 from swaywm/revert-3073-swayidle_workaround
Revert "Work around swayidle never triggering on SIGUSR1"
2018-11-05 18:22:29 +01:00
Drew DeVault 9a3cd000a3
Revert "Work around swayidle never triggering on SIGUSR1" 2018-11-05 12:12:44 -05:00
Drew DeVault 0e985d6c8e
Merge pull request #3073 from oranenj/swayidle_workaround
Work around swayidle never triggering on SIGUSR1
2018-11-05 18:10:09 +01:00
Jarkko Oranen 4f21b6f670 Work around swayidle never triggering on SIGUSR1 2018-11-05 18:54:41 +02:00
emersion d0bb450681
Merge pull request #3066 from mwenzkowski/fix-gaps
Improvements to the runtime only part of the gaps command
2018-11-05 15:33:40 +01:00
emersion bcbd0a9b45
Merge pull request #3067 from madblobfish/three-trivial-fixes
Improve documentation and remove dead code
2018-11-04 23:30:57 +01:00
emersion 0e85b92250
Use wlr_surface_get_effective_damage 2018-11-04 23:21:37 +01:00
madblobfish e47b31c556 document swaymessage type for get_seats 2018-11-04 22:49:44 +01:00
mwenzkowski 67866dc378 gaps: Improve error reporting
Always raise an error if the runtime only gaps command is found in the
config file.
2018-11-04 20:40:14 +01:00
mwenzkowski 60df5cc9f8 Correct manpage regarding gaps command
The command 'gaps inner|outer all|current set|plus|minus <amount>'
is not valid in the configuration file, hence list it accordingly.
2018-11-04 20:10:41 +01:00
madblobfish 7d8ed7a3a7 added space after table in sway.5 manpage 2018-11-04 17:38:35 +01:00
madblobfish 417a10f477 removed unneeded code fragment 2018-11-04 17:38:13 +01:00
emersion d19648a304
Merge pull request #3061 from colemickens/output-current-mode
ipc: move refresh to current_mode
2018-11-03 23:44:04 +01:00
Cole Mickens ef888321ba ipc: move refresh from output to output->current_mode 2018-11-03 15:09:34 -07:00
Cole Mickens 71686ed0e7 fix: restore refresh to the modes_array 2018-11-03 15:09:34 -07:00
Drew DeVault c18cd9dd03
Merge pull request #3021 from Snaipe/singlekey-binding-trigger
binding: match single-key bindings if no multi-key binding matched
2018-11-03 17:57:59 +01:00
Drew DeVault baf4841d79
Merge pull request #3052 from colemickens/output-current-mode
Correct "Current mode" in `swaymsg -t get_outputs` for scaled outputs
2018-11-03 17:37:15 +01:00
Cole Mickens 1f486fe898 swaymsg: get_outputs: use output->current_mode for current mode display 2018-11-03 04:30:53 -07:00
Cole Mickens d05aeb77a0 sway-ipc: includes current_mode for each output 2018-11-03 04:30:49 -07:00
Drew DeVault 6297b757b1 Correction to dependency updates 2018-11-02 13:48:25 -04:00
Drew DeVault 842a555a2f Clean up dependencies in README.md 2018-11-02 13:47:52 -04:00
Drew DeVault b1aec1ef14
Merge pull request #3028 from emersion/disambiguate-drop-root-error
Make it clear that being able to restore root is a failure
2018-11-01 19:01:18 +01:00
emersion f90ff1210b
Teardown compositor when failing to drop permissions 2018-11-01 18:50:06 +01:00
emersion 9dae68eba5
Make it clear that being able to restore root is a failure 2018-11-01 18:49:42 +01:00
mwenzkowski cd0bae80b6 Fix #2992
Move a function call, such that data it depends on is initialized before.
2018-11-01 08:15:03 -04:00
Drew DeVault 8ad06f0ec5
Merge pull request #3041 from RyanDwyer/marks-props-to-container
Move view marks properties to container struct
2018-11-01 13:01:15 +01:00
Ryan Dwyer 9fc736f4e1 Move view marks properties to container struct
Like border properties, this will be needed to implement layout saving
and restoring.
2018-11-01 18:09:51 +10:00
Drew DeVault 480b03b734
Merge pull request #3040 from RyanDwyer/border-props-to-container
Move view border properties to container struct
2018-11-01 01:03:41 +01:00
Drew DeVault 35fda6765b
Merge pull request #3037 from RyanDwyer/focus-output-wrap
Wrap to fartherest output when running focus output
2018-11-01 01:01:17 +01:00
Ryan Dwyer bf19f63a79 Wrap to fartherest output when running focus output
Also moves the `opposite_direction` function into `util.c` as it's used
in two places now.
2018-11-01 08:29:45 +10:00
Drew DeVault f841d2ed74
Merge pull request #3042 from madblobfish/swaymsg-fish-completions
improved swaymsg completions for fish
2018-10-31 18:26:03 +01:00
madblobfish 4e20907364 improved swaymsg completions for fish 2018-10-31 17:56:33 +01:00
Ryan Dwyer 528c7495bb Move view border properties to container struct
This will be needed to implement layout saving and restoring, as we need
to be able to configure borders on a placeholder container which has no
view.
2018-10-31 23:56:20 +10:00
Drew DeVault e21a23348b
Merge pull request #3031 from atomnuker/master
Restore previous tabbed layout behavior
2018-10-31 14:51:04 +01:00
emersion e9c136b0ee
Merge pull request #3027 from madblobfish/remove-resolve_path
Remove resolve_path() from utils
2018-10-31 14:48:17 +01:00
Drew DeVault fbbf810668 Update ISSUE_TEMPLATE.md 2018-10-31 08:13:56 -04:00
madblobfish 1f23ec2d05 Revert "Add resolve_path() to utils"
This reverts commit c9694ee63d.
2018-10-31 13:04:08 +01:00
emersion d3a6263311
Merge pull request #3033 from RyanDwyer/remove-movement-direction
Remove enum movement_direction
2018-10-30 15:17:55 +01:00
Ryan Dwyer 7be309710d Remove enum movement_direction
There's no point having both movement_direction and wlr_direction. This
replaces the former with the latter.

As movement_direction also contained MOVE_PARENT and MOVE_CHILD items,
these are now checked specifically in the focus command and handled in
separate functions, just like the other focus variants.
2018-10-30 23:27:49 +10:00
Rostislav Pehlivanov b0fb2846fe Revert "Respect border settings when rendering lone tabbed/stacked child"
This reverts commit 65328ef60c.
2018-10-30 11:42:44 +00:00
Rostislav Pehlivanov a67e1b5873 Revert "tree/view.c: fix uninitialized variables warning"
This reverts commit 6414b5d288.
2018-10-30 11:42:37 +00:00
Drew DeVault b90af33570
Merge pull request #3020 from emersion/swaymsg-return-status
swaymsg: fix get_outputs status code
2018-10-29 19:08:41 +01:00
Franklin "Snaipe" Mathieu f8e83ee20a binding: match single-key bindings if no multi-key binding matched
This makes bindings more snappy when the user is typing faster than
his keycaps are releasing.

Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
2018-10-29 13:04:19 +00:00
emersion eb675f0dfd
swaymsg: fix get_outputs status code 2018-10-29 11:25:54 +01:00
emersion 1c2a356dcf
Merge pull request #3016 from mwenzkowski/fix-uninitialized-pointer
cursor: fix uninitialized pointer in cursor_rebase
2018-10-28 19:52:08 +01:00
Brian Ashworth d14a627c10
Merge pull request #3009 from emersion/swayidle-sigusr
swayidle: enter idle state on SIGUSR1
2018-10-28 13:31:02 -04:00
mwenzkowski 66ae58d62a cursor: fix uninitialized pointer in cursor_rebase 2018-10-28 17:33:27 +01:00
Drew DeVault 09f3f7b75f
Merge pull request #3011 from Emantor/fix/2922
output: initialize layers before usage in apply_config
2018-10-28 12:42:27 +01:00
Drew DeVault aa21d1b867
Merge pull request #3010 from Emantor/fix/cursor_warping_view_map
input-manager: consider cursor warping on input_manager_set_focus
2018-10-28 12:40:26 +01:00
Drew DeVault 5ea81e6f7e
Merge pull request #3008 from CameronNemo/patch-1
Create ISSUE_TEMPLATE.md
2018-10-28 12:36:23 +01:00
Rouven Czerwinski e4df675840 output: initialize layers and signal before using functions
The previous pull request #2993 tried to fix this by moving the function which
used the layers after the initilization.
Since this initialization is done unconditionally only depending on the struct
definition, move the layer initialization to the beginning of the function.
Also move the signal initialization of the destroy event.

Fixes #2992
2018-10-28 11:06:15 +01:00
Rouven Czerwinski 6f87d0c2cf input-manager: consider cursor warping on input_manager_set_focus
input_manager_set_focus is used to set the focus after mapping the view in
view_map. This needs to consider to warp the cursor as well, since for
WARP_CONTAINER, the cursor should warp to the newly created view.
2018-10-28 10:29:10 +01:00
emersion 5fcb814a73
swayidle: enter idle state on SIGUSR1 2018-10-28 09:16:42 +01:00
Cameron Nemo 93eec3e1b6
Create ISSUE_TEMPLATE.md 2018-10-27 20:19:30 -07:00
Drew DeVault 2ccf511cba
Merge pull request #3006 from Snaipe/remove-class
ipc: make json for view match i3's output more closely
2018-10-28 02:20:10 +02:00
emersion e3a0e3322b
Merge pull request #3000 from Robinhuett/workspace_address_output_by_name
Use output identifier for workspace config
2018-10-27 21:26:19 +02:00
emersion f9a276544b
Merge pull request #3003 from Hi-Angel/master
seat: don't traverse the list to check if it's empty
2018-10-27 21:22:03 +02:00
Konstantin Kharlamov cd3c2f4553 seat: don't traverse the list to check if it's empty
Found by introspection.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2018-10-27 21:10:10 +03:00
Franklin "Snaipe" Mathieu 03ca8596d6 ipc: make class, instance, and title window properties optional
i3 seems to make all window properties, with the exception of
transient_for, optional[1].

[1]: 315ff17563/src/ipc.c (L435-L450)

Signed-off-by: Franklin "Snaipe" Mathieu <snaipe@diacritic.io>
2018-10-27 18:41:26 +01:00
Franklin "Snaipe" Mathieu 259fe1e76f ipc: remove class key from view json
It turns out that i3 does not have a `class` key in the json description
of a view, but provides it through `window_properties.class`. Since
`window_properties` has been added by 8fc9328, we can remove `class`
altogether.

Signed-off-by: Franklin "Snaipe" Mathieu <snaipe@diacritic.io>
2018-10-27 18:39:17 +01:00
Drew DeVault 707f3ad275
Merge pull request #3001 from madblobfish/swaylock-completions-and-manpage
Reworked fish completions and moved stuff in swaylock manpage
2018-10-27 17:10:00 +02:00
madblobfish 31d1ffb88f added fish completions for swaynag 2018-10-27 16:54:32 +02:00
madblobfish 834f23f57a added fish completions for swayidle 2018-10-27 16:54:20 +02:00
Robinhuett 0a4cf4748d Use output identifier for workspace config 2018-10-27 15:56:06 +02:00
madblobfish fe32a745ee reordered swaylock manpage 2018-10-27 15:25:10 +02:00
madblobfish cff62bf846 updated fish completions for swaylock 2018-10-27 15:25:03 +02:00
Drew DeVault 5a98dfee02 Revert "Fix #2992"
This reverts commit 94985146ea.
2018-10-27 08:55:45 -04:00
emersion de250a523f
Merge pull request #2997 from RyanDwyer/fix-cursor-during-operation
Don't reset cursor during mouse operations
2018-10-27 11:23:57 +02:00
Ryan Dwyer d0dca7f35e Don't reset cursor during mouse operations 2018-10-27 19:12:55 +10:00
Ryan Dwyer e4053191e6
Merge pull request #2995 from colemickens/uninit-warnings
tree/view.c: fix uninitialized variables warning
2018-10-27 15:58:37 +10:00
Cole Mickens 6414b5d288 tree/view.c: fix uninitialized variables warning 2018-10-26 22:25:11 -07:00
Drew DeVault 25a8f7dcb8
Merge pull request #2994 from RyanDwyer/respect-lone-child-border
Respect border settings when rendering lone tabbed/stacked child
2018-10-27 05:29:47 +02:00
Ryan Dwyer 65328ef60c Respect border settings when rendering lone tabbed/stacked child
In i3, when a child of a tabbed or stacked container has no siblings,
its border settings are respected.

This patch achieves the same effect by rendering a lone tabbed/stacked
child as if it's a linear container. This makes the border settings be
respected.

Over in view_autoconfigure, we compensate for this by only adjusting
`y_offset` if there's multiple children.
2018-10-27 11:23:02 +10:00
Brian Ashworth b63669a2a0
Merge pull request #2993 from mwenzkowski/fix-2992
Fix #2992
2018-10-26 19:18:00 -04:00
mwenzkowski 94985146ea Fix #2992
Move a function call, such that data it depends on is initialized before.
2018-10-26 23:31:57 +02:00
Drew DeVault b52e005346
Merge pull request #2989 from RyanDwyer/fix-focus-glitchiness
Fix focus after a non-visible workspace's last container is destroyed
2018-10-26 16:02:11 +02:00
Ryan Dwyer 63d076dc2a Fix focus after a non-visible workspace's last container is destroyed
The code being changed is responsible for updating the focus stack when
a container is destroyed in a different part of the tree to where the
real focus is. It's attempting to set focus_inactive to a sibling (or
parent if no siblings) of the container that is being destroyed, then
put our real focus back on the end of the focus stack.

The problem occurs when the container being destroyed is in a different
workspace. For example:

* Have a focused view on workspace 1
* Have workspace 2 not visible with a single view that is unmapping
* The first call to seat_set_raw_focus sets focus to workspace 2 because
it's the parent
* Prior to this patch, the second call to seat_set_raw_focus would set
focus to the view on workspace 1
* Later, when using output_get_active_workspace, this function would
return workspace 2 because it's the first workspace it finds in the
focus stack.

To fix this, workspace 1 must be placed on the focus stack between
workspace 2 and the focused view. That's what this patch does.

Lastly, it also uses seat_get_focus_inactive to choose the focus. This
fixes a crash when a view unmaps while a non-container is focused (eg.
swaylock), because focus is NULL.
2018-10-26 19:15:12 +10:00
Drew DeVault b29beb1aa0
Merge pull request #2985 from mihaicmn/fix-retiling
Fix re-tiling for floating containers
2018-10-26 03:20:17 +02:00
emersion 1e8e7e16e7
Merge pull request #2984 from Ferdi265/master
sway-ipc: don't log errno if unneeded and add more descriptive errors
2018-10-25 22:35:38 +02:00
Mihai Coman 5323551a7f Fix re-tiling for floating containers
When a floating container is tiled (e.g.: 'floating toggle' or
'floating disable'), it should be placed after/below the inactive
focused container from the tiling layout.
2018-10-25 23:20:38 +03:00
Ferdinand Bachmann 6409a109f6 sway-ipc: don't log errno if unneeded and add more descriptive errors 2018-10-25 22:17:03 +02:00
Drew DeVault 73b7c5cc05
Merge pull request #2982 from Toromtomtom/master
protect newline
2018-10-25 22:03:30 +02:00
Tom Warnke 1670eafd7b protect newline 2018-10-25 21:48:39 +02:00
Drew DeVault 37eb83940f
Merge pull request #2980 from ppascher/allow_workspace_missing_output
Update workspace.c
2018-10-25 20:10:41 +02:00
ppascher 2123dfa15f
Update workspace.c
re-added missing output check after config load
2018-10-25 19:48:45 +02:00
ppascher db61d581a3
Update workspace.c
Remove output requirement for workspace command
2018-10-25 19:24:01 +02:00
emersion 6b59533646
Merge pull request #2973 from ianyfan/swaybar
swaybar: fix scrolling behaviour
2018-10-25 18:32:09 +02:00
Drew DeVault 51ad2676d0
Merge pull request #2975 from RyanDwyer/deny-commands-when-no-outputs
Deny several commands when there's no outputs connected
2018-10-25 17:10:36 +02:00
emersion 2507a5e447
Merge pull request #2974 from RyanDwyer/cursor-rebase-after-txn-apply
Rebase the cursor after applying transactions
2018-10-25 16:12:46 +02:00
Ryan Dwyer 885963f11f Deny several commands when there's no outputs connected 2018-10-26 00:03:44 +10:00
Ryan Dwyer 60a1d79de7 Rebase the cursor after applying transactions
This approaches cursor rebasing from a different angle. Rather than
littering the codebase with cursor_rebase calls and using transaction
callbacks, this just runs cursor_rebase after applying every transaction
- but only if there's outputs connected, because otherwise it causes a
crash during shutdown.

There is one known case where we still need to call cursor_rebase
directly, and that's when running `seat seat0 cursor move ...`. This
command doesn't set anything as dirty so no transaction occurs.
2018-10-25 23:37:40 +10:00
Drew DeVault ea2497d35c
Merge pull request #2950 from emersion/presentation-time
Implement the presentation-time protocol
2018-10-25 15:31:47 +02:00
Ian Fan 19421373b9 swaybar: when scrolling, check that there are workspaces to scroll on 2018-10-25 14:12:26 +01:00
Ian Fan c5541763c0 swaybar: fix scrolling behaviour
1. wrap_scroll has been fixed
2. release bindings are checked when returning early
2018-10-25 12:57:16 +01:00
Ian Fan c3fdabb725 swaybar: reverse order of workspaces list
This makes it congruent with its visual appearance, making it easier to
reason about.
2018-10-25 12:57:16 +01:00
emersion b1c49038a6
Merge pull request #2971 from RyanDwyer/document-output-identifiers
Document how to identify outputs by make, model and serial
2018-10-25 10:27:08 +02:00
emersion df64cb2827
Merge pull request #2970 from RyanDwyer/fix-scratchpad-size
Fix containers not being resized when entering scratchpad
2018-10-25 10:13:32 +02:00
Ryan Dwyer ea097631af Document how to identify outputs by make, model and serial 2018-10-25 18:08:29 +10:00
Ryan Dwyer f7aed5c7e5 Fix containers not being resized when entering scratchpad
This fixes a regression introduced by
662466e8db. When adding a container to the
scratchpad, setting container->scratchpad = true before
container_set_floating made container_set_floating believe that the
container was already floating. This fixes it by setting the property
afterwards instead.
2018-10-25 17:32:16 +10:00
Drew DeVault 41f744c224
Merge pull request #2925 from ianyfan/swaylock
swaylock: exit early if unable to get input inhibitor
2018-10-24 18:54:22 +02:00
Drew DeVault 9658d4bcc5
Merge pull request #2964 from RyanDwyer/tab-wheel-focus-inactive
When scrolling on a tab titlebar, set focus_inactive if not focused
2018-10-24 17:10:21 +02:00
Ryan Dwyer 641fbe576e When scrolling on a tab titlebar, set focus_inactive if not focused
For example, create layout H[view T[view view view]], focus the view in
the hsplit and scroll the mouse wheel over the tab title bars. Prior to
this patch, focus would be given to a descendant of the tabbed
container. This patch keeps the focus on the hsplit view.

This also renames some of the variables used in this part of the code to
make it be easier to follow.
2018-10-24 23:59:09 +10:00
Drew DeVault 46fc4ba4e3
Merge pull request #2957 from RyanDwyer/rebase-cursor-after-map
Rebase the cursor after mapping a view
2018-10-24 15:45:47 +02:00
Drew DeVault 2fa767ab57
Merge pull request #2954 from RyanDwyer/cursor-rebase-after-focus-direction
Rebase the cursor after focusing in a direction
2018-10-24 15:45:02 +02:00
emersion f2082a3d4c
Merge pull request #2961 from RyanDwyer/swaylock-multiseat
Add multiseat support to swaylock
2018-10-24 14:33:33 +02:00
Ryan Dwyer 17bb39cd49 Add multiseat support to swaylock 2018-10-24 22:04:16 +10:00
Ryan Dwyer bdae625cb3 Rebase the cursor after mapping a view
I originally put the rebase at the end of view_map, but at this point
the view is still at its native size and will ignore the motion event if
it falls outside of its native size. The only way to do this properly is
to rebase the cursor later - either after sending the configure, after
the view commits with the new size, or after applying the transaction. I
chose to do it after applying the transaction for simplicity.

I then attempted to just call cursor_rebase after applying every
transaction, but this causes crashes when exiting sway (and possibly
other places) because cursor_rebase assumes the tree is in a valid
state.

So my chosen solution introduces transaction_commit_dirty_with_callback
which allows handle_map to register a callback which will run when the
transaction is applied.
2018-10-24 19:38:52 +10:00
Ryan Dwyer 3c7fd145d5 Rebase the cursor after focusing in a direction
Prior to this patch, creating a tabbed container with two views,
switching tab and then scrolling without motion would cause the scroll
events to be sent to the old focus. To fix this, rebasing the cursor is
needed after changing focus.
2018-10-24 18:43:32 +10:00
Drew DeVault bdb176863c
Merge pull request #2933 from Snaipe/xwayland-window-properties
xwayland: populate window_properties in json for views
2018-10-24 01:13:15 +02:00
emersion a654ac1bd6
Implement the presentation-time protocol 2018-10-23 23:38:57 +02:00
Franklin "Snaipe" Mathieu 8fc9328334 xwayland: populate window_properties in json for views
window_properties is documented to contain a subset of the X11 properties
of a window (its title, class, instance, role, and transient ID). This
commit adds the missing json object from the get_tree output for
xwayland windows only.

This is a follow-up of #2911.

Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
2018-10-23 19:10:50 +01:00
Drew DeVault 7160b8aae9
Merge pull request #2942 from ianyfan/swaybar
swaybar: absorb bar_init function into bar_setup
2018-10-23 14:19:11 +02:00
Drew DeVault 862a4f69be
Merge pull request #2944 from RyanDwyer/fix-multiseat-dormant-cursor
Fix dormant cursor when using multiple seats
2018-10-23 14:18:58 +02:00
Ryan Dwyer 9c965ec58c seat_update_capabilities: Set cursor image while we have the capability 2018-10-23 22:00:57 +10:00
Ryan Dwyer 450a0661d7 Fix dormant cursor when using multiple seats
The cursor's image would be removed or set when the seat's capabilities
were updated, but there was nothing to prevent the image from being set
at other times.
2018-10-23 21:38:30 +10:00
Ian Fan 48cf430cee swaybar: absorb bar_init function into bar_setup 2018-10-23 12:25:52 +01:00
Ian Fan 9afcda59db swaybar: exit on display error 2018-10-23 12:22:51 +01:00
Ian Fan ebfb1388e2 swaylock: exit on display error 2018-10-23 11:49:33 +01:00
Ian Fan 7fffe0a98c swaylock: exit early if unable to inhibit input
This stops the program from going into a spinlock without exiting
2018-10-23 11:41:45 +01:00
Ryan Dwyer e33671fd9a
Merge pull request #2941 from ianyfan/commands
commands: clean up checkargs function +other small changes
2018-10-23 20:33:40 +10:00
Ian Fan 9227cb7d67 commands: replace EXPECTED_LESS_THAN with EXPECTED_AT_MOST
This makes it a bit more obvious what the expected number of arguments is.
2018-10-23 10:51:54 +01:00
Ian Fan 000d96e525 commands: clean-up checkarg function
Consolidates logic and fixes mistake that used argc instead of val for
determining plural.
2018-10-23 10:51:08 +01:00
Ian Fan 5364255f26 commands: remove EXPECTED_MORE_THAN
Its uses have been replaced with EXPECTED_AT_LEAST.
2018-10-23 10:17:58 +01:00
Ian Fan a9fdd5dd2a commands: print correct command on error for exec and opacity 2018-10-23 10:14:50 +01:00
emersion 970501f05e
Merge pull request #2940 from RyanDwyer/fix-swaybar-crash
Fix swaybar crash when there's no status_command
2018-10-23 10:50:36 +02:00
Ryan Dwyer 851b442f73 Fix swaybar crash when there's no status_command 2018-10-23 18:38:01 +10:00
Arnaud Vallette d'Osia a5cb4cca15 Advertize dependency on git 2018-10-23 09:56:56 +02:00
emersion 7583b0b8a5
Merge pull request #2936 from RedSoxFan/fix-swaynag-command
cmd_swaynag_command: fix typo in variable
2018-10-23 09:09:29 +02:00
Brian Ashworth 6a9930f451 cmd_swaynag_command: fix typo in variable
The custom swaynag_command was being stored as config->swaybg_command
instead of config->swaynag_command.
2018-10-22 21:19:22 -04:00
Drew DeVault 5c6240a906
Merge pull request #2935 from mteyssier/ref-output-docs
Add references to sway-output(5) in sway(5)
2018-10-23 01:55:58 +02:00
Ryan Dwyer 6e0097b6da
Merge pull request #2934 from RedSoxFan/config-log-cleanup
config: remove peeked + expanded line log entries
2018-10-23 08:23:29 +10:00
mteyssier f530ac6459 Add references to sway-output(5) in sway(5)
- update ref in the swaybg_command description
- add ref to sway-output(5) in See Also
- add an `output` command description
2018-10-23 00:00:36 +02: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
Drew DeVault 40c98768e1
Merge pull request #2929 from RyanDwyer/fix-scratchpad-resize
Fix crash when resizing container hidden in the scratchpad
2018-10-22 23:45:22 +02:00
Brian Ashworth bb06a57a71
Merge branch 'master' into fix-scratchpad-resize 2018-10-22 17:32:39 -04:00
Drew DeVault d9ed9445de
Merge pull request #2926 from RyanDwyer/fix-xwayland-floating-logic
Fix xwayland wants_floating logic
2018-10-22 22:12:57 +02:00
Ryan Dwyer 662466e8db Fix crash when resizing container hidden in the scratchpad
Firstly, the container was wrongly identifying as a tiling container
because it had no workspace.

Secondly, when calculating the maximum possible size we can't use the
workspace if it's not there, so we'll allow unlimited size in this case.
2018-10-23 00:02:08 +10:00
Drew DeVault cdbfc3338b
Merge pull request #2924 from RyanDwyer/fix-qt-menu-crash
Fix crash when quitting a QT app on the wayland backend using menu
2018-10-22 14:55:32 +02:00
Drew DeVault ef532154c3
Merge pull request #2923 from RyanDwyer/fix-move-to-fullscreen-crash
Fix crash when moving a container to a fullscreen workspace
2018-10-22 14:53:48 +02:00
Ryan Dwyer db2b545550
Merge pull request #2922 from RedSoxFan/fix-2905
cmd_reload: recalc font sizing + rebuild textures
2018-10-22 22:40:26 +10:00
Ryan Dwyer 16ef702645 Fix xwayland wants_floating logic 2018-10-22 21:51:10 +10:00
Ryan Dwyer 6deb726873 Fix crash when quitting a QT app on the wayland backend using menu
QT unmaps the view before destroying the popup. We destroyed the popup
in response to the view unmapping, but then we'd attempt to destroy it a
second time which caused a crash.

The patch removes the listener.

I tested it with GTK as well, and can confirm the popup is still being
destroyed.
2018-10-22 18:36:47 +10:00
Ryan Dwyer f04b8f0061 Fix crash when moving a container to a fullscreen workspace
Setting normal focus to the fullscreen view causes the old workspace to
start destroying. We then set focus to the old workspace which is no
longer attached in the tree.

As we are only setting focus_inactive on the fullscreen container, the
fix uses seat_set_raw_focus to avoid all the additional behaviour that
comes with it such as destroying the old workspace.
2018-10-22 18:02:33 +10:00
Brian Ashworth 80e8be71a3 cmd_reload: recalc font sizing + rebuild textures
When the config gets reloaded, the font height and baseline get reset to
0. If the config does not have a font command in it, the variables will
remain at 0 causing a transparent area where the title would be
rendered.

This makes it so the font height and baseline are recalculated. Additionally,
since the font height and baseline may have changed due to the reload, the
title and marks textures are rebuilt.
2018-10-21 22:57:29 -04:00
Drew DeVault a918844e52
Merge pull request #2913 from emersion/fix-swaybar-hotplug
swaybar: fix hotplug
2018-10-21 18:35:02 +02:00
emersion 2a32701b78
swaybar: fix hotplug 2018-10-21 17:46:40 +02:00
Drew DeVault 429787510e
Merge pull request #2909 from makepanic/issues/2906
Parse missing i3 window types
2018-10-21 16:40:53 +02:00
Christian 989bddc765 Parse missing i3 window types
fixes the parsing part of #2906
2018-10-21 15:59:04 +02:00
emersion a4d6835881
Merge pull request #2903 from RyanDwyer/seat-specific-backandforth
Make workspace back_and_forth seat-specific
2018-10-21 08:59:59 +02:00
Ryan Dwyer c5a6c37275 Make workspace back_and_forth seat-specific
* When using multiple seats, each seat has its own prev_workspace_name
for the purpose of workspace back_and_forth.
* Removes prev_workspace_name global variable.
* Removes unused next_name_map function in tree/workspace.c.
* Fixes memory leak in seat_destroy (seat was not freed).
2018-10-21 11:26:22 +10:00
emersion 3f02218b54
Merge pull request #2901 from ianyfan/swaybar
swaybar: render with minimum height, nominally text height
2018-10-20 22:52:56 +02:00
Ian Fan 1844a5bafb swaybar: render with minimum height, nominally text height 2018-10-20 21:21:57 +01:00
Drew DeVault 6e6476c3d5
Merge pull request #2900 from Hi-Angel/master
A script to make inactive windows transparent
2018-10-20 21:06:38 +02:00
Konstantin Kharlamov 0d5aaf5359 A script to make inactive windows transparent
Sway has ability to apply transparency to arbitrary windows. This script
wires up this functional to one of popular use-cases from
i3+<compositor_name>.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2018-10-20 21:58:00 +03:00
Drew DeVault a41b77ef29
Merge pull request #2896 from RyanDwyer/abort-proprietary
Abort if proprietary drivers are in use
2018-10-20 16:18:58 +02:00
Ryan Dwyer ebeb759873 Abort if proprietary drivers are in use
The idea here is we don't want users to be blissfully unaware that they
are running unsupported drivers. So we abort on startup, and force the
user to add a specific argument to bypass the check.
2018-10-21 00:01:09 +10:00
Drew DeVault 64534d2fd1
Merge pull request #2895 from RyanDwyer/fix-popup-damage
Fix popup damage issues when toplevel and/or popup uses geometry
2018-10-20 15:38:25 +02:00
Drew DeVault 551e05ba90
Merge pull request #2888 from RyanDwyer/remove-raise-floating
Remove raise_floating directive
2018-10-20 15:30:54 +02:00
Ryan Dwyer 93ec1af4d9 Fix popup damage issues when toplevel and/or popup uses geometry
The wlr_xdg_popup_get_toplevel_coords function has the following quirks:

* It does not do anything with the coordinates of the passed popup.
Instead, we are required to add them ourselves, which we do by passing
them to the function as the surface local values.
* It adds the geometry (shadows etc) of the toplevel itself, so the
coordinates are surface local rather than content local. For this
reason, we have to negate the toplevel's geometry
(child->view->geometry).
* I may be wrong, but the popup positions appear to be stored in surface
local coordinates rather than content local coordinates. The geometry
(shadows etc) of the popup itself must be negated (surface->geometry).
2018-10-20 23:18:56 +10:00
Drew DeVault c75098e96f
Merge pull request #2887 from RyanDwyer/bar-overlay
Put swaybar in overlay layer when using mode hide
2018-10-20 15:17:51 +02:00
Ryan Dwyer cafb1ff4f7
Merge pull request #2890 from mihaicmn/create-default-seat
Fix crash when defaut seat is not created
2018-10-20 19:43:58 +10:00
Mihai Coman 3daf963d4d Fix crash when defaut seat is not created
Function input_manager_get_default_seat should always return a seat.
2018-10-20 11:48:49 +03: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 a4ce5227c2 Put swaybar in overlay layer when using mode hide
This allows the bar to render over fullscreen views.
2018-10-20 16:48:43 +10:00
emersion 75ea19c71b
Merge pull request #2870 from RyanDwyer/refactor-input-manager
Minor refactor of input manager
2018-10-20 08:42:56 +02:00
emersion fe6aea1d02
Merge pull request #2886 from RyanDwyer/fix-headless-unmap-crash
Fix crash when view unmaps while no outputs connected
2018-10-20 08:37:48 +02:00
emersion 4bde0eb911
Merge pull request #2879 from Emantor/fix/swaybar_position
swaybar: disallow left and right position and print error on default
2018-10-20 08:35:20 +02:00
Rouven Czerwinski 17fb3b6994 commands/bar: remove left and right from allowed positions
"left" and "right" are not allowed positions for swaybar, remove them.
2018-10-20 08:21:44 +02:00
Rouven Czerwinski f52825336c swaybar: disallow left and right position and print error on default
The positions "left" and "right" are not allowed by the man page, remove them
from the allowed positions. Also print an error to stderr if we default to the
bottom position.

Fixes #2878
2018-10-20 08:21:44 +02: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
Ryan Dwyer ed771a6a6e Fix crash when view unmaps while no outputs connected
When a view unmaps, we call workspace_consider_destroy. This function
assumed the workspace would always have an output, but this is not the
case when hotplugged down to zero. The function now handles this and
allows itself to be destroyed when there is no output.

This means that workspace_begin_destroy must remove the workspace from
the root->saved_workspaces list to avoid an eventual dangling pointer,
so it does that now.

Lastly, when an output is plugged in again and it has to create a new
initial workspace for it, we must emit the workspace::init IPC event
otherwise swaybar shows no workspaces at all. I guess when you start
sway, swaybar is started after the workspace has been created which is
why this hasn't been needed earlier.
2018-10-20 13:07:33 +10:00
Drew DeVault 5b8257b88f
Merge pull request #2872 from RyanDwyer/cursor-rebase
Introduce cursor_rebase
2018-10-20 05:06:03 +02:00
Drew DeVault 3b8dd49583
Merge pull request #2885 from RyanDwyer/fix-tiling-drag-crash
Fix crash when ending tiling drag
2018-10-20 01:18:23 +02:00
Drew DeVault bb6c9f52c7
Merge pull request #2884 from c-edw/feature/2867_FixScalingParameter
Prevent overriding background mode after it's been set.
2018-10-20 01:16:24 +02:00
Ryan Dwyer 9b828939e5 Fix crash when ending tiling drag
If the container being dragged has a parent that needs to be reaped, it
must be reaped after we've reinserted the dragging container into the
tree. During reaping, handle_seat_node_destroy tries to refocus the
dragging container which isn't possible while it's detached.
2018-10-20 08:57:09 +10:00
Connor E d855837da2 Change initial background mode before arg parse. 2018-10-19 16:38:01 +01:00
emersion 0a4735c50c
Merge pull request #2883 from ponkyh/missing-stdlib
missing headers for swaybar/input.c
2018-10-19 15:18:05 +02:00
ossi.ahosalmi 79011e68df missing headers for swaybar/input.c 2018-10-19 15:55:30 +03:00
Ryan Dwyer 9ea71f292b Introduce cursor_rebase
This function "rebases" the cursor on top of whatever is underneath it,
without triggering any focus changes.
2018-10-19 22:47:54 +10:00
Drew DeVault 28f3b8cb03
Merge pull request #2882 from RyanDwyer/fix-mouse-warp-logic
Fix logic used for mouse_warping output
2018-10-19 14:40:56 +02:00
Ryan Dwyer 4d743b64d0 Fix logic used for mouse_warping output
Turns out we don't need to store the previous focus, and it should be
based on which output the cursor was in.
2018-10-19 22:28:02 +10:00
Drew DeVault 96e3686ae8
Merge pull request #2875 from RedSoxFan/input-device-bindings
cmd_bind{sym,code}: Implement per-device bindings
2018-10-19 14:00:03 +02:00
Drew DeVault 19adc3ff2d
Merge pull request #2877 from RyanDwyer/warp-on-workspace-switch
Consider cursor warp when switching workspaces
2018-10-19 02:49:13 +02:00
Ryan Dwyer a2fdac2c4b Consider cursor warp when switching workspaces
Fixes a regression introduced in
24a90e5d86.

consider_warp_to_focus has been renamed to seat_consider_warp_to_focus,
moved to seat.c and made public. It is now called when switching
workspaces via `workspace <ws>`.
2018-10-19 08:00:13 +10:00
Brian Ashworth 2e637b7368 cmd_bind{sym,code}: Implement per-device bindings
bindsym --input-device=<identifier> ...
bindcode --input-device=<identifier> ...
2018-10-18 13:42:01 -04:00
Brian Ashworth 30dbb8eba0
Merge pull request #2874 from ianyfan/swaybar
swaybar: separate input code to new file
2018-10-18 13:37:35 -04:00
Ian Fan 499150a91b swaybar: separate input code to new file 2018-10-18 14:19:00 +01:00
Drew DeVault d88b7a63f4
Merge pull request #2871 from RyanDwyer/untangle-cursor-warp
Remove cursor warping from seat_set_focus
2018-10-18 15:18:41 +02:00
Ryan Dwyer 24a90e5d86 Remove cursor warping from seat_set_focus
Because cursor warping was the default behaviour in seat_set_focus,
there may be cases where we may have been warping the cursor
unintentionally. This patch removes cursor warping from seat_set_focus
and only does it in the focus command. This is managed by a static
function in focus.c.

To know whether to warp or not, we need to know which node had focus
previously. To keep track of this easily, seat->prev_focus has been
introduced and is set to the previous in seat_set_focus.
2018-10-18 23:08:45 +10:00
Drew DeVault 103b7bc47d
Merge pull request #2868 from emersion/xcursor-env
Export XCURSOR_SIZE and XCURSOR_THEME
2018-10-17 22:19:01 +02:00
emersion fd9198a3a4 Export XCURSOR_SIZE and XCURSOR_THEME
These can be used by toolkits (currently Qt, libxcursor, glfw) to
choose a default cursor theme and size.

This backports this rootston commit:
3a181ab430
2018-10-17 21:10:30 +02:00
Drew DeVault 10d07478ad
Merge pull request #2858 from RyanDwyer/fix-move-to-floating-ws
Fix moving tiled containers to workspaces which only have floating views
2018-10-17 16:16:12 +02:00
Drew DeVault 46dafbf74a
Merge pull request #2864 from sghctoma/freebsd-fixes
FreeBSD fixes
2018-10-17 16:14:35 +02:00
Drew DeVault e46c3ffbc9
Merge pull request #2861 from RyanDwyer/fix-empty-workspace-crashes
Fix crashes when running certain commands on an empty workspace
2018-10-17 16:13:05 +02:00
Drew DeVault 765c80e5f7
Merge pull request #2820 from Emantor/fix-mouse-warping-container
Fix mouse warping container
2018-10-17 15:57:13 +02:00
Drew DeVault 8d56269d9c
Merge pull request #2862 from SpeedJack/fix-stringop-overflow
Fix overflow in strcpy
2018-10-17 15:55:49 +02:00
sghctoma af2cfa5221 Set sysconfdir to /etc only if prefix is /usr
PR #2855 basically hardcodes the config file path to /etc, which is a
problem on e.g. FreeBSD, where the expected path for config files of
non-base software is '/usr/local/etc'.
Meson sets sysconfdir to '/etc' explicitly only when prefix is '/usr',
so it is still possible to use '/usr/local' as prefix, and install the
config files under '/usr/local/etc'. This commit allows to do that by
setting sysconfdir based on the value of prefix.
2018-10-17 15:28:18 +02:00
Niccolò Scatena 8c86fff6dc
Fix stringop-overflow warnings 2018-10-17 13:00:12 +02:00
Ryan Dwyer 17014c34e2 Fix crashes when running certain commands on an empty workspace
This fixes crashes when running the border, mark, unmark and
title_format commands on an empty workspace.
2018-10-17 19:55:00 +10:00
sghctoma 2694fd72b6 Increase _POSIX_C_SOURCE to 200112L
CLOCK_MONOTONIC appeared in IEEE Std. 1003.1-200x, it was not part of
POSIX.1b (the 1993 version), and FreeBSD treats it accordingly.
2018-10-17 11:09:58 +02:00
Ryan Dwyer 799f285cd1 Fix moving tiled containers to workspaces which only have floating views
* Make a workspace which only contains floating views
* Switch to another workspace and create a tiled view
* Move the tiled view to the workspace with
`move container to workspace N`

The container would be added as a sibling to the floating view, which
makes the container floating while having the geometry of a tiled
container.

This changes it so it only looks for tiled containers in the workspace
with a fallback to the workspace itself.
2018-10-17 16:57:32 +10:00
Brian Ashworth 434cbaabf0
Merge pull request #2843 from c-edw/feature/2842_TruncateMessage
swaynag: Truncate message to 2048 chars.
2018-10-16 21:39:37 -04:00
Brian Ashworth 3a5a8aa5ad
Merge branch 'master' into feature/2842_TruncateMessage 2018-10-16 21:31:29 -04:00
Drew DeVault fa2d2c8559
Merge pull request #2855 from SpeedJack/sysconfdir-fhs-compliant
Make SYSCONFDIR FHS compliant when "prefix" is set
2018-10-16 23:50:42 +02:00
Connor E cfc533aa9c Truncate message, append buffer overflow message if too long.
Increase buffer size, remove macros.

Make variables lowercase.

Some more feedback.
2018-10-16 20:20:45 +01:00
Niccolò Scatena 027928bdeb
Set SYSCONFDIR to /etc even when "prefix" is set
SYSCONFDIR should be "/etc" even when prefix="/usr" to be FHS compliant.
This is the default in meson from v0.44.
2018-10-16 19:44:45 +02:00
Niccolò Scatena 615d4bf958
Revert "Fix SYSCONFDIR to include "prefix""
This reverts commit 6942f5b684.
SYSCONFDIR should be "/etc" even when prefix="/usr" to be FHS compliant.
This is the default in meson from v0.44.
2018-10-16 19:35:06 +02:00
Drew DeVault 18a2646c1d
Merge pull request #2852 from RyanDwyer/back-and-forth-crash
Fix crash when using workspace back_and_forth with no previous
2018-10-16 18:18:01 +02:00
Rouven Czerwinski 1f0aeae335 view: rewarp cursor during view_unmap
If the cursor is warped during the destruction of the workspace, we end up in
the wrong position. Warp the cursor after arrange_workspace() so we end up in
the correct position.
2018-10-16 15:47:02 +02:00
Rouven Czerwinski d69cf4c23c seat: use new warping functions for cursor warping during focus warp 2018-10-16 15:47:02 +02:00
Rouven Czerwinski 0969bf758b cursor: functions to warp cursor to container and workspace
The new functions allow a cursor to be warped without changing the focus.
This is a preparation commit to handle cursor warping not only in
seat_set_focus_warp.
2018-10-16 15:47:02 +02:00
Rouven Czerwinski 892446a0b6 view: move arrange_workspace into view_map
For mouse_warping cursor to correctly work on newly spawned containers,
the workspace needs to be arranged before the cursor is warped.

The shell functions each implement their own fullscreen and arrange checks,
move them into the view_map function and pass their states via boolean arguments.

Fixes #2819
2018-10-16 15:47:02 +02:00
Ryan Dwyer d0974d5c50 Fix crash when using workspace back_and_forth with no previous 2018-10-16 23:42:53 +10:00
Ian Fan 113751ea48
Merge pull request #2836 from RyanDwyer/set-set-raw-focus
Introduce seat_set_raw_focus and remove notify argument from seat_set_focus_warp
2018-10-16 10:59:09 +01:00
Ian Fan ac20690945
Merge branch 'master' into set-set-raw-focus 2018-10-16 10:50:56 +01:00
Ryan Dwyer 05284b65db Prevent duplicate workspace::focus events
Previously we would compare the last focus's workspace with the new
focus's workspace to determine if we need to emit an IPC
workspace::focus event. This doesn't work when moving the focused
container to a new workspace.

This adds a workspace property to the seat which stores the last emitted
workspace::focus workspace. Using this method, after moving the
container, refocusing it will trigger exactly one workspace::focus
event: from the old workspace to the new workspace.
2018-10-16 08:17:24 +10:00
Drew DeVault cd02d60a99
Merge pull request #2845 from colemickens/posix_clock
common/loop.c: add _POSIX_C_SOURCE for clock_gettime and CLOCK_MONOTONIC
2018-10-15 23:01:53 +02:00
Cole Mickens a9a9df75ec common/loop.c: add _POSIX_C_SOURCE for clock_gettime and CLOCK_MONOTONIC 2018-10-15 13:42:24 -07:00
Drew DeVault 4e4b922d79
Merge pull request #2839 from RyanDwyer/swaylock-version
Fix swaylock version string
2018-10-15 21:30:53 +02:00
Ryan Dwyer e644632198 Fix swaylock version string
The referenced constants were not defined so it always printed "version
unknown".

Also it would exit with code 1. It now exits with code 0.
2018-10-16 00:09:16 +10:00
Drew DeVault f6ad4908bc
Merge pull request #2838 from RyanDwyer/compositor-unavailable-crash
Sway clients: Exit gracefully when compositor is unavailable
2018-10-15 15:37:17 +02:00
Drew DeVault 97b9452171
Merge pull request #2835 from RyanDwyer/swap-crash
Fix crash in swap command
2018-10-15 15:35:50 +02:00
Ryan Dwyer 32ba8154b8 Sway clients: Exit gracefully when compositor is unavailable 2018-10-15 21:57:59 +10:00
Ryan Dwyer 26278b694c Introduce seat_set_raw_focus and remove notify argument from seat_set_focus_warp
This introduces seat_set_raw_focus: a function that manipulates the
focus stack without doing any other behaviour whatsoever. There are a
few places where this is useful, such as where we set focus_inactive
followed by another call to set the real focus again. With this change,
the notify argument to seat_set_focus_warp is also removed as these
cases now use the raw function instead.

A bonus of this is we are no longer emitting window::focus IPC events
when setting focus_inactive, nor are we sending focus/unfocus events to
the surface.

This also fixes the following:

* When running `move workspace to output <name>` and moving the last
workspace from the source output, the workspace::focus IPC event is no
longer emitted for the newly created workspace.
* When splitting the currently focused container, unfocus/focus events
will not be sent to the surface when giving focus_inactive to the newly
created parent, and window::focus events will not be emitted.
2018-10-15 21:06:24 +10:00
Ryan Dwyer fe803b89a7 Fix crash in swap command
When swapping containers that are in the root of the workspace, parent
will be NULL.
2018-10-15 19:40:40 +10:00
Drew DeVault 56c388b510
Merge pull request #2831 from swaywm/move-output-docs
Establish sway-output(5)
2018-10-14 17:04:55 +02:00
Drew DeVault b69060fc58 Establish sway-output(5) 2018-10-14 10:52:57 -04:00
Drew DeVault 53d90dd6a8
Merge pull request #2826 from RyanDwyer/common-eventloop
Implement common event loop for swaybar and swaylock
2018-10-14 16:34:22 +02:00
Drew DeVault 135f0fc7e7 Update README.MD (and README.*.md) 2018-10-14 10:33:38 -04:00
Ryan Dwyer c6f153d8f9 Event loop: Fix memmove and remove extraneous declaration 2018-10-15 00:26:27 +10:00
Ryan Dwyer 893f61d03a Event loop: Free fds and fix race condition 2018-10-15 00:26:27 +10:00
Ryan Dwyer 6921fdc6d6 Remove timerfd from loop implementation
timerfd doesn't work on the BSDs, so this replaces it with a timespec
for the expiry and uses a poll timeout to check the timers when needed.
2018-10-15 00:26:27 +10:00
Ryan Dwyer f98f351a52 swaylock: Don't wait too long for surface damage before verifying 2018-10-15 00:26:27 +10:00
Ryan Dwyer fa11b7f701 swaylock: clear password after 10 seconds 2018-10-15 00:26:27 +10:00
Ryan Dwyer c242712262 swaylock: Remove indicator after 3 seconds 2018-10-15 00:26:27 +10:00
Ryan Dwyer 9c833c661a swaylock: Use common event loop 2018-10-15 00:26:27 +10:00
Ryan Dwyer 4056c09e13 Move swaybar's event loop to common directory and refactor
* The loop functions are now prefixed with `loop_`.
* It is now easy to add timers to the loop.
* Timers are implemented using pollfd and timerfd, rather than manually
checking them when any other event happens to arrive.
2018-10-15 00:26:27 +10:00
Drew DeVault 7f2e6d812a Document `border csd` 2018-10-14 10:23:40 -04:00
Drew DeVault 4a05fbf8ab
Merge pull request #2751 from ianyfan/swaybar
Bar mode/hidden_state events
2018-10-14 15:13:50 +02:00
Ian Fan 85dd36e92b swaybar: add documentation for hide/hidden_state subcommands 2018-10-14 13:33:12 +01:00
Ian Fan 4dba7c084a swaybar: when hiding bar, save old height to be restored upon reshow
Previously, when the bar was hidden, the height would be set to 0.
This meant that if the bar was empty upon reshow, it would not render
since the height was still 0, which made it seem there was a problem.
Now, the height is not reset, but the width is, to indicate upon reshow
that the layer surface needed reconfiguring.
2018-10-14 13:33:12 +01:00
Ian Fan a29ee77411 swaybar: send signal to status when hiding or showing bar 2018-10-14 13:33:12 +01:00
Ian Fan f6f72cb949 swaybar: show hidden bar on urgency 2018-10-14 13:33:12 +01: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
Ian Fan bcc61e5147 swaybar: handle mode/hidden_state changes
As well as adding the hidden_state property to the bar config struct,
this commit handles barconfig_update events when the mode or
hidden_state changes, and uses a new function determine_bar_visibility
to hide or show the bar as required, using, respectively,
destroy_layer_surface, which is also newly added, and add_layer_surface,
which has been changed to allow dynamically adding the surface.
2018-10-14 13:33:12 +01:00
Ian Fan 55ca16f2d8 swaybar: streamline ipc handling
The received json is handled outside of the case statement, which will
allow better extensibility.
This commit also introduces the variable bar_is_dirty, the return value
signifying whether the bar requires rendering.
2018-10-14 13:33:12 +01:00
Ian Fan fed11d1c7b swaybar: move mode & mode_pango_markup to bar struct
This distinguishes the binding mode from the distinct config mode, as
well as removing mode_pango_markup from the config struct where it
should not be present.
2018-10-14 13:33:12 +01:00
Ian Fan a388ffa127 swaybar: only send initial workspace request if workspace buttons are enabled 2018-10-14 13:33:12 +01:00
Ian Fan 19f0bf3864 swaybar: add free_hotspots helper function 2018-10-14 13:33:12 +01:00
Ian Fan a67fa8a05d swaybar: only subscribe to required events
This adds barconfig_update to the list of subscribed events, as well as
checking when the other events need to be subscribed to.
2018-10-14 13:33:12 +01:00
Ian Fan 18eaf45224 swaybar: annotate wl_list properties in definitions 2018-10-14 13:33:12 +01:00
Ian Fan d0b54e932b swaybar: save id upon startup
This adds an id property to the bar, which will be used to filter
barconfig_update events
2018-10-14 13:33:12 +01:00
Ian Fan 1f90f92f45 commands: fix sending bar mode/hidden_state updates to all bars
Previously, if a change was sent to all bars, it would only actually
change the first bar it encountered, due to return value handling
2018-10-14 13:33:12 +01:00
Drew DeVault abde9d6627
Merge pull request #2808 from RedSoxFan/bar-subcommands
Fix bar subcommand handler structs and selection
2018-10-14 14:30:52 +02:00
Drew DeVault dbb169bf15
Merge pull request #2829 from espkk/master
Fix clear_password_buffer
2018-10-14 14:30:06 +02:00
espkk 42f72f8bb4 swaylock: fix clear_password_buffer 2018-10-14 07:40:33 +03:00
Drew DeVault 71aaa7e130 Remove unnecessary comment 2018-10-13 20:51:29 -04:00
Brian Ashworth 350f7d3460
Merge pull request #2823 from tarmack/fix_edge_gaps
Fix edge gaps
2018-10-13 18:49:31 -04:00
Brian Ashworth 02aeb0f0be
Merge branch 'master' into fix_edge_gaps 2018-10-13 18:08:23 -04:00
Brian Ashworth 2a0c7ebd43 cmd_bar: simplify logic 2018-10-13 17:56:11 -04:00
Brian Ashworth 84b28dc593 cmd_bar: fix bar id issues
Allows bar-subcommand to be a valid bar-ids
Destroys runtime created bar if trying to use a config only subcommand
Allow subcommands (except for id) to be ids
2018-10-13 17:55:49 -04: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
Brian Ashworth 2340b14eba bar_cmd_status_command: only reload current bar
Ideally, this will be replaced with an IPC barconfig_update event in the
near future
2018-10-13 08:00:01 -04:00
Brian Ashworth 00745d6280 Fix bar subcommand handler structs and selection 2018-10-13 08:00:01 -04:00
emersion 782a835175
Merge pull request #2828 from RyanDwyer/fix-locked-map-crash
Fix crash when view maps while locked
2018-10-13 13:22:35 +02:00
Ryan Dwyer 9190735947 Fix crash when view maps while locked
When locked, there is no active workspace so it must find the
focus_inactive workspace instead.

Additionally, this adds a check for if a view maps while there are no
outputs connected and handles it gracefully.
2018-10-13 19:15:04 +10:00
Drew DeVault b80cf982ae
Merge pull request #2825 from RyanDwyer/fractional-scale-pixel-leaks
Fix pixel leaks when using fractional scaling
2018-10-12 23:12:56 +02:00
Ryan Dwyer c699a86e47 Fix pixel leaks when using fractional scaling
The basic idea here is to apply rounding after scaling. It's not as
simple as this, though, and I've detailed it in the comments for a
function.

In order to fix some pixel leaks in the title bar, I found it easier to
change how we place rectangles to fill the area. Instead of placing two
rectangles across the full width above and below the title and having
shorter rectangles in the inner area, it's now pieced together in
vertical chunks. This method involves drawing two less rectangles per
container.
2018-10-12 22:36:11 +10:00
Ryan Dwyer f52af18e0d
Merge pull request #2821 from meakio/master
fix: cmd_sticky crash sway with empty container
2018-10-12 09:21:48 +10:00
Ryan Dwyer 27fb146121
Merge branch 'master' into master 2018-10-12 08:55:29 +10:00
meak 9e96ce4a46 fix: cmd_sticky crash sway with empty container 2018-10-11 22:29:41 +02:00
Drew DeVault e17a99287d
Merge pull request #2824 from chtison/master
Fix documentation of output
2018-10-11 22:26:34 +02:00
chtison 5ab7755649 Fix documentation of output 2018-10-11 22:14:56 +02:00
emersion 8dadfd42df
Merge pull request #2817 from trmendes/libinput-disable-touchscreen-support
Add libinput send_events config for touch
2018-10-10 23:52:29 +02:00
Thiago Mendes 8e147b3f1d
Add libinput send_events config for touch 2018-10-10 23:15:31 +02:00
Drew DeVault 5d19906556
Merge pull request #2806 from v-gu/add-libinput-support-for-keyboard
add libinput config for keyboard
2018-10-10 17:07:38 +02:00
Drew DeVault 0a36d14d7a
Merge pull request #2798 from RedSoxFan/bar-bindsym
Implement bar bindsym
2018-10-10 17:07:02 +02:00
Ian Fan cd6917d4a8
Merge branch 'master' into bar-bindsym 2018-10-10 12:23:04 +00:00
Drew DeVault 782ed19bc3
Merge pull request #2814 from Emantor/mouse-warping-container
Add mouse_warping container
2018-10-10 14:06:14 +02:00
Ryan Dwyer ed33d95b6a
Merge branch 'master' into mouse-warping-container 2018-10-10 21:50:29 +10:00
Drew DeVault 155e863ead
Merge pull request #2811 from RyanDwyer/fix-floating-click-events
Fix floating click events
2018-10-10 13:44:55 +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
emersion 87bc707e9b
Merge pull request #2812 from RyanDwyer/fix-version-messages
Fix program name in version strings
2018-10-10 10:57:45 +02:00
Ryan Dwyer fa8959532b Fix program name in version strings
When running swaymsg -v, the version returned is actually the version of
swaymsg itself, yet the message displayed was "sway version <version>".
This can create confusion if users update sway and swaymsg but don't
restart sway, then use swaymsg to check the version.

This patch changes the wording to be "swaymsg version <version>"
instead, and likewise for swaybar.

To get the version of a running sway instance, users should run swaymsg
-t get_version.
2018-10-10 18:34:50 +10:00
Ryan Dwyer 416bb7a214 Fix floating click events
* Set focus to a floating container when clicking its title bar.
* Raise floating when user clicks title bar or decorations (in the
seat_begin functions).
* In container_at, it only returned a floating container if the user had
clicked the surface. This makes it use floating_container_at instead.
2018-10-10 16:58:32 +10:00
Drew DeVault 2bd561d2b7
Merge pull request #2810 from RyanDwyer/fix-docs-backandforth
Fix back_and_forth documentation
2018-10-10 01:58:07 +02:00
Ryan Dwyer 8c98bde20d Fix back_and_forth documentation 2018-10-10 09:41:37 +10:00
Drew DeVault ab6423f9b9
Merge pull request #2809 from mwenzkowski/fix-view_autoconfigure
Fix undesirable height change of floating views
2018-10-10 00:46:15 +02:00
mwenzkowski fd645a2a88 Fix undesirable height change of floating views
In view_autoconfigure the height of the view is adjusted if the parent
container has a tabbed/stacked layout. Previously this height change
would also be applied to floating views, although it is not needed for
them.
2018-10-09 21:22:15 +02:00
Vincent Gu 073aa4149f add libinput config for keyboard
add send_events support
2018-10-09 22:03:27 +08:00
Drew DeVault 43875c437b
Merge pull request #2805 from RyanDwyer/fix-resize-return-value
resize: Determine if anything changed using before/after check
2018-10-09 15:42:43 +02:00
Drew DeVault 53164c4aa2
Merge pull request #2803 from RedSoxFan/fix-2802
Only consider tiling views for gaps outer
2018-10-09 15:37:42 +02:00
Ryan Dwyer 61699a1146 resize: Determine if anything changed using before/after check
Returning a boolean from container_resize_tiled and resize_tiled doesn't
work in all cases. This patch changes it back to void and does a
before/after check to see if the container was resized.
2018-10-09 22:25:21 +10: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
Drew DeVault e143c9613d
Merge pull request #2804 from Emantor/swaynag-double-free
config: remove double free of config->swaynag_command
2018-10-09 13:37:20 +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 5e9c61ac23 Only consider tiling views for gaps outer 2018-10-08 18:50:32 -04:00
Drew DeVault 4bebee620f
Merge pull request #2772 from RyanDwyer/improve-popup-damage
Only damage popups when popups have damage
2018-10-09 00:02:36 +02:00
Brian Ashworth a999269e1c
Merge pull request #2782 from RyanDwyer/popup-during-fullscreen
Implement popup_during_fullscreen
2018-10-08 15:28:09 -04:00
Brian Ashworth 3f328b6276
Merge branch 'master' into popup-during-fullscreen 2018-10-08 15:18:49 -04:00
emersion a03955f936
Merge pull request #2799 from ianyfan/commands
commands: when setting urgency, check container is not null
2018-10-08 19:17:40 +02:00
Ian Fan efb123899f commands: when setting urgency, check container is not null 2018-10-08 17:48:25 +01:00
emersion 16e727a654
Merge pull request #2795 from RedSoxFan/swaynag-disable
Allow swaynag to be disabled
2018-10-08 16:24:46 +02:00
Brian Ashworth 09c3c33081 Allow swaynag to be disabled 2018-10-08 09:59:38 -04:00
emersion 45f2cd0c73
Merge pull request #2793 from emersion/disable-swaybg
Allow swaybg to be disabled
2018-10-08 15:50:56 +02:00
Ryan Dwyer d21d2c8665 Remove duplicate code 2018-10-08 23:50:43 +10:00
emersion 1c1fbd49db
Merge pull request #2794 from johnae/fix-opacity-crashing-bug
Check if there is a current container before setting its opacity
2018-10-08 15:42:19 +02:00
Ryan Dwyer b8002fc0c4 Look for any ancestor when checking for fullscreen exit 2018-10-08 23:39:35 +10:00
Ryan Dwyer 88317b59ce Use current state when rendering transient containers 2018-10-08 23:27:19 +10:00
emersion ab3a397d58 Fix memory leak in status_command handler 2018-10-08 15:21:20 +02:00
John Axel Eriksson 08139daaa4
Check if there is a current container before setting it's opacity 2018-10-08 15:17:37 +02: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 f23588de3c Introduce container_is_transient_for 2018-10-08 23:00:36 +10: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
Drew DeVault 6cb0e58c6d
Merge pull request #2791 from RyanDwyer/status-command-optional
swaybar: allow null status_command
2018-10-08 14:42:48 +02:00
Ryan Dwyer 5e1983660d Allow status_command to be disabled via IPC 2018-10-08 22:23:55 +10:00
Ryan Dwyer 26bebb9266 Add example status_command to default config 2018-10-08 22:23:55 +10: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
Ian Fan b3b17280de
Merge pull request #2789 from RyanDwyer/reload-idle
Reload config using idle event
2018-10-08 12:05:18 +00:00
Ryan Dwyer e168e8f0ff Don't apply seat config when validating 2018-10-08 21:18:30 +10:00
Ryan Dwyer 88a5e26c6e Remove unneeded variable 2018-10-08 20:40:47 +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
Drew DeVault 89f4ebef06
Merge pull request #2786 from swaywm/no-op-client-commands
Shim client.background and client.placeholder
2018-10-07 23:30:05 +02:00
Drew DeVault 92e1fc00fd Shim client.background and client.placeholder
These are not supported by sway, but are valid i3 commands and should not
cause config errors.

Also includes a couple of minor touch-ups.
2018-10-07 14:44:37 -04:00
Drew DeVault 7252c7f715 swaynag: s/Toggle Details/Toggle details/ 2018-10-07 14:37:53 -04:00
emersion 06fade1c8b
Merge pull request #2783 from martinetd/swaynag_uaf
swaynag: fix use-after-free in wl_display_dispatch
2018-10-07 09:57:51 +02:00
Dominique Martinet e5ece5f8b3 swaynag: fix use-after-free in wl_display_dispatch
When destroying swaynag from within wl_display_dispatch, we cannot
disconnect the display as that will free the queue's event_list.
Free it after running the loop instead.

Fixes this use-after-free:
==7312==ERROR: AddressSanitizer: heap-use-after-free on address 0x612000000110 at pc 0x000000412a9f bp 0x7ffd4e811760 sp 0x7ffd4e811750
READ of size 8 at 0x612000000110 thread T0
    #0 0x412a9e in wl_list_empty ../common/list.c:206
    #1 0x7f5b58f0d42f in dispatch_queue src/wayland-client.c:1572
    #2 0x7f5b58f0d42f in wl_display_dispatch_queue_pending src/wayland-client.c:1815
    #3 0x40f465 in swaynag_run ../swaynag/swaynag.c:390
    #4 0x407576 in main ../swaynag/main.c:123
    #5 0x7f5b58bb9412 in __libc_start_main ../csu/libc-start.c:308
    #6 0x404a3d in _start (/opt/wayland/bin/swaynag+0x404a3d)

0x612000000110 is located 208 bytes inside of 320-byte region [0x612000000040,0x612000000180)
freed by thread T0 here:
    #0 0x7f5b594ab480 in free (/lib64/libasan.so.5+0xef480)
    #1 0x40faff in swaynag_destroy ../swaynag/swaynag.c:454
    #2 0x40cbb4 in layer_surface_closed ../swaynag/swaynag.c:82
    #3 0x7f5b583e1acd in ffi_call_unix64 (/lib64/libffi.so.6+0x6acd)

previously allocated by thread T0 here:
    #0 0x7f5b594aba50 in __interceptor_calloc (/lib64/libasan.so.5+0xefa50)
    #1 0x7f5b58f0c902 in wl_display_connect_to_fd src/wayland-private.h:236

(you need a wayland compiled with asan, my wl_list hack, or running
with valgrind to see this trace)
2018-10-07 16:35:10 +09:00
Ryan Dwyer caed15af82 Handle subsurfaces in view_child_damage 2018-10-07 11:07:29 +10:00
Ryan Dwyer 59ba528bd9 Use wlr_xdg_popup_get_toplevel_coords 2018-10-07 11:07:29 +10:00
Ryan Dwyer 1059e173f4 Only damage popups when popups have damage
The previous behaviour was to damage the entire view, which would
recurse into each popup. This patch makes it damage only the popup's
surface, and respect the surface damage given by the client.

This adds listeners to the popup's map and unmap events rather than
doing the damage in the create and destroy functions. To get the popup's
position relative to the view, a new child_impl function get_root_coords
has been introduced, which traverses up the parents.
2018-10-07 11:07:29 +10:00
Drew DeVault 8393266eb5
Merge pull request #2778 from emersion/swaybar-seat-pointer
swaybar: fix binding to wl_pointer multiple times
2018-10-06 20:10:09 +02:00
emersion f1d8ba69a6
Merge pull request #2779 from ianyfan/ipc
ipc: set "type" of floating containers to "floating_con"
2018-10-06 19:45:54 +02:00
emersion d50f54fa42 swaybar: fix binding to wl_pointer multiple times 2018-10-06 19:13:44 +02:00
Ian Fan 2cda0b1fe1 ipc: set "type" of floating containers to "floating_con" 2018-10-06 18:11:05 +01:00
emersion 176832fe30
Merge pull request #2776 from swaywm/swaylock-setuid
Fix swaylock w/shadow on glibc, improve security
2018-10-06 18:47:34 +02:00
Drew DeVault c89e00a97e Fix swaylock w/shadow on glibc, improve security
Today I learned that GNU flaunts the POSIX standard in yet another
creative way. Additionally, this adds some security improvements,
namely:

- Zeroing out password buffers in the privileged child process
- setuid/setgid after reading /etc/shadow
2018-10-06 12:20:12 -04:00
Drew DeVault 85961f63bf Update CONTRIBUTING.md 2018-10-06 11:52:28 -04:00
emersion 0f45aa4ea9
Merge pull request #2693 from RyanDwyer/move-sticky-in-seat
Move sticky containers when switching workspace via criteria
2018-10-06 14:53:09 +02:00
Ryan Dwyer c620f76bea Move sticky containers when switching workspace via criteria
* Create a view on workspace 1
* Switch to workspace 2 (on the same output) and create a floating
sticky view
* Use criteria to focus the view on workspace 1

Previously, we only moved the sticky containers when using
workspace_switch, but the above method of focusing doesn't call it. This
patch relocates the sticky-moving code into seat_set_focus_warp.

A side effect of this patch is that if you have a sticky container
focused and then switch workspaces, the sticky container will no longer
be focused. It would previously retain focus.

In seat_set_focus_warp, new_output_last_ws was only set when changing
outputs, but now it's always set. This means new_output_last_ws and
last_workspace might point to the same workspace, which means we have to
make sure we don't destroy it twice. It now checks to make sure they're
different, and to make this more obvious I've moved both calls to
workspace_consider_destroy to be next to each other.
2018-10-06 19:16:41 +10:00
Drew DeVault 5d21c33f13
Merge pull request #2771 from RyanDwyer/swaylock-seat-capabilities
swaylock: Support keyboard and pointer disconnects and reconnects
2018-10-06 01:51:35 +02:00
Ryan Dwyer b0393ae34b swaylock: Support keyboard and pointer disconnects and reconnects 2018-10-06 09:38:12 +10:00
emersion c1f09939ae
Merge pull request #2768 from RyanDwyer/fix-flatten-crash
Fix crash when flattening container after moving
2018-10-05 09:40:05 +02:00
Ryan Dwyer 44b550298e Fix crash when flattening container after moving
container_flatten removes the container from the tree (via
container_replace) before destroying it. When destroying, the recent
changes to handle_seat_node_destroy incorrectly assumes that the
container has a parent.

This adds a check for destroying a container which is no longer in the
tree. If this is the case, focus does not need to be changed.
2018-10-05 16:39:20 +10:00
emersion c8d1f376d3
Merge pull request #2764 from ianyfan/rm-base64
Remove obsolete base64.c file
2018-10-04 21:50:05 +02:00
Ian Fan e2dc6dfcd8 Remove obsolete base64.c file 2018-10-04 20:17:19 +01:00
Drew DeVault eecebcafc6 Fix #2763 2018-10-04 15:00:18 -04:00
emersion 0d5c2f75b5
Merge pull request #2760 from RyanDwyer/swaylock-handle-output-disconnect
Give focus to another swaylock surface when output is disconnected
2018-10-04 14:18:13 +02:00
emersion 192ec7d6c8
Merge pull request #2761 from RyanDwyer/seat-op-ignore-buttons
Ignore unrelated cursor buttons while doing seat operations
2018-10-04 13:29:09 +02:00
Ryan Dwyer 4feedbf7cf Ignore unrelated cursor buttons while doing seat operations
* Click and hold a scrollbar
* Drag the cursor onto another surface
* While still holding the original button, press and release another
cursor button
* Things get weird

There's two ways to fix this. Either cancel the seat operation and do
the other click, or continue the seat operation and ignore the other
click. I opted for the latter (ignoring the click) because it's easier
to implement, and I suspect a second click during a seat operation is
probably unintentional anyway.
2018-10-04 20:57:03 +10:00
Ryan Dwyer 32cb631143 Give focus to another swaylock surface when output is disconnected
* Have multiple outputs
* Launch swaylock
* Unplug an output (possibly has to be the last "connected" one)
* The swaylock surface on the remaining output would not respond to key
events

This was happening because when the output destroys, focus was not given
to the other swaylock surface.

This patch makes focus be transferred to another surface owned by the
same Wayland client, but only if input was inhibited by the surface
being destroyed, and only if it's in the overlay layer. I figure it's
best to be overly specific and relax the requirements later if needed.

This patch removes a check in seat_set_focus_surface which was
preventing focus from being passed from a layer surface to any other
surface. I don't know of a use case for this check, but it's possible
that this change could produce issues.
2018-10-04 19:36:19 +10:00
emersion 681ed1826d
Merge pull request #2759 from minus7/fix-view-container-null
Fix crash if view has no container
2018-10-03 21:22:25 +02:00
Drew DeVault 7fdc557f1e
Merge pull request #2709 from BuJo/feature/raise_floating
raise floating
2018-10-03 21:21:25 +02:00
minus 95d7d5f4ee Fix crash if view has no container 2018-10-03 21:01:34 +02:00
Jonathan Buch 426c33f4dc
Reenable popup-handling for determining focus
This reenables the popup-handling code before the floating-window
focus change.
2018-10-03 16:23:14 +02:00
Jonathan Buch 7e978d7a4c
Use "raycasting" for determining focus for floating windows
Floating containers and their surfaces are ordered in "raised last".
This is used to detect the topmost surface and thus the focus.
2018-10-03 16:23:14 +02:00
Jonathan Buch 7727d54faf
Fix focusing topmost floating windows
Re-focus on the container on which the cursor hovers over.  A
special case is, if there are menus or other subsurfaces open
in the focused container.  It will prefer the focused container
as long as there are subsurfaces.

This commit starts caching the previous node as well as the
previous x/y cursor position.  Re-calculating the previous
focused node by looking at the current state of the cursor
position does not work, if the environment changes.
2018-10-03 16:23:14 +02:00
Jonathan Buch 8bec0c90c7
Add manpage documentatioon for raise_floating 2018-10-03 16:23:14 +02:00
Jonathan Buch ec713125c6
Simplify raising a container in seat
* Factor out raising a floating window into s separate function to
  enable reuse.
2018-10-03 16:23:14 +02: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
emersion 01b8e171b8
Merge pull request #2757 from RyanDwyer/check-focus-stack-empty
Add sanity check for empty focus stack
2018-10-03 14:17:28 +02:00
Ryan Dwyer 5dd535b67a Add sanity check for empty focus stack 2018-10-03 22:09:20 +10:00
Drew DeVault 54a835e962 Remove HACKING.md
Half of this is outdated and the other half is questionable.
2018-10-03 08:02:46 -04:00
Drew DeVault e60ad3f677 Fix some missing commands in sway-input(5) 2018-10-03 07:50:37 -04:00
Drew DeVault 06c214a800
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
2018-10-03 13:03:06 +02:00
Drew DeVault f74829d390
Merge pull request #2755 from RyanDwyer/fix-tiling-criteria
Fix tiling criteria
2018-10-03 13:02:06 +02:00
Ryan Dwyer a519fb6fde Fix tiling criteria 2018-10-03 20:33:32 +10:00
Drew DeVault 4e4d0c5191
Merge pull request #2749 from ianyfan/swaybar
swaybar: add leading comma to click event JSON
2018-10-02 17:00:33 +02:00
Ian Fan 65593f49bc swaybar: add leading comma to click event JSON 2018-10-02 14:05:51 +01:00
Drew DeVault 90352986e0
Merge pull request #2745 from RyanDwyer/fix-focus-inactive-on-destroy
Set focus_inactive on a sibling when a container closes in an inactive workspace
2018-10-02 14:14:13 +02:00
Ryan Dwyer 677e112733 Set focus_inactive on a sibling when a container closes in an inactive workspace
To reproduce the problem, create layout
H[view V[view view view-focused]], then switch to another workspace and
have the previously focused view in the vsplit close (eg. using
criteria, or an mpv video finishing). Return to the workspace using
`$mod+<num>` and the entire vsplit would be focused. This happens
because handle_seat_node_destroy would only set a new focus if the
currently focused view or a parent was being destroyed. To fix it, it
needs to set a sibling of the destroying container to focus_inactive
regardless of the current focus, then restore current focus if needed.

This patch changes the function accordingly. Additionally:

* The function now makes an early return if the node being destroyed is
a workspace.
* set_focus has been renamed to needs_new_focus. This variable is true
if the head focus needs to be changed.
2018-10-02 15:45:20 +10:00
Ryan Dwyer 183a4b0d6b
Merge pull request #2740 from RedSoxFan/gap-borders
Handle gap borders
2018-10-02 11:37:33 +10: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 b542c5413e
Merge pull request #2739 from RedSoxFan/fix-2653
Fix smart gaps
2018-10-02 08:57:55 +10:00
Ryan Dwyer 82559c16c7
Merge branch 'master' into fix-2653 2018-10-02 08:14:01 +10:00
Drew DeVault 9956a1a9ab
Merge pull request #2735 from RedSoxFan/fix-quotes
Do not strip quotes for exec or bind commands
2018-10-01 20:18:54 +02:00
Brian Ashworth 742d1764a6 Fix smart gaps 2018-10-01 09:41:15 -04:00
Drew DeVault 51f68e10ad
Merge pull request #2737 from Ragnis/criteria-floating
Parse floating criteria
2018-09-30 19:29:26 +02:00
Ragnis Armus 1bd695ffd2 Parse floating criteria 2018-09-30 19:59:32 +03:00
Brian Ashworth a125575eb5 Do not strip quotes for cmd_set 2018-09-30 12:35:45 -04:00
Brian Ashworth 87a70b3591 Do not strip quotes for exec or bind commands
Leave quotes intact for cmd_exec, cmd_exec_always, cmd_bindcode,
and cmd_bindsym
2018-09-30 10:39:29 -04:00
emersion bebe7dea8c
Merge pull request #2734 from ivyl/use_rpath
Add support for installing binaries with DT_RPATH
2018-09-30 15:04:13 +02:00
Arkadiusz Hiler eed0bc3ebd Add support for installing binaries with DT_RPATH
It's better to use DT_RPATH dynamic section of the elf binary to store
the paths of libraries to load instead of overwriting LD_LIBRARY_PATH
for the whole environment, causing surprises. This solution is much more
transparent and perfectly suitable for running contained installations
of wayland/wlroots/sway.

The code unsetting the LD_LIBRARY_PATH/LD_PRELOAD was also deleted as
it's a placebo security at best - we should trust the execution path
that leads us to running sway, and it's way too late to care about those
variables since we already started executing our compositor, thus we
would be compromised anyway.
2018-09-30 15:37:01 +03:00
Drew DeVault f1dbdce0b2
Merge pull request #2726 from RyanDwyer/overhaul-gaps
Make gaps implementation consistent with i3-gaps
2018-09-30 13:47:35 +02:00
Drew DeVault e518c5dbaf
Merge pull request #2728 from RedSoxFan/move-sticky-on-evac
Move sticky containers in output_evacuate
2018-09-30 13:45:31 +02: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
Drew DeVault 7355959d7f
Merge pull request #2730 from ivyl/remove_cap_leftovers
Remove libcap/prctl artifacts
2018-09-30 13:41:36 +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
Arkadiusz Hiler d8200012fb Remove declarations that do no have definitions
There is a couple of leftover header files/declarations, which were
fronting implementations that are long gone.

Let's get rid of them.
2018-09-30 14:09:05 +03:00
Arkadiusz Hiler 00dfb76832 Remove libcap/prctl artifacts
They seem like relics of the pasts, from when we were retaining the
ptrace cap.

Some translations still may need updates.
2018-09-30 13:39:26 +03:00
emersion 98b524abd7
Merge pull request #2733 from ianyfan/swaybar
swaybar: synchronize rendering to output frames
2018-09-30 11:44:27 +02:00
Ian Fan 02dfeea54c swaybar: synchronize rendering to output frames 2018-09-30 10:07:33 +01:00
emersion 4eb3fe4830
Merge pull request #2732 from RyanDwyer/fix-zero-outputs
Fix hotplugging down to zero outputs
2018-09-30 10:03:59 +02:00
Ryan Dwyer 24bcb507ec Fix hotplugging down to zero outputs
When the last output is disconnected, output_disable is called like
usual and evacuates the output to the root->saved_workspaces list. It
then calls root_for_each_container to remove (untrack) the output from
each container's outputs list. However root_for_each_container did not
iterate the saved workspaces, so when the output gets freed the
containers would have a dangling pointer in their outputs list. Upon
reconnect, container_discover_outputs would attempt to use the dangling
pointer, causing a crash.

This makes root_for_each_container check the saved workspaces list,
which fixes the problem.
2018-09-30 11:58:56 +10:00
emersion a53171669a
Merge pull request #2698 from ianyfan/hide-cursor
Only show cursor if pointer configured
2018-09-29 14:32:05 +02:00
PP ae2b70f59e add tap-and-drag setting to sway-input 2018-09-29 11:49:41 +02:00
emersion 351e722b6e
Merge pull request #2729 from RyanDwyer/resize-return-false
Return an error when resizing is a no op
2018-09-29 11:24:54 +02:00
emersion 0f0d0c7f9b
Merge pull request #2635 from RedSoxFan/fix-bg-special
Handle shell special characters in bg file path
2018-09-29 11:23:38 +02:00
Ryan Dwyer 42f1fdf015 Return an error when resizing is a no op 2018-09-29 17:05:55 +10:00
Brian Ashworth 8f09ba7885 Move sticky containers in output_evacuate 2018-09-28 23:47:22 -04:00
Brian Ashworth 0a0cf4540a Fix quote handling for commands
Quotes are now stripped for all arguments and stripped before anything is unescaped
2018-09-28 23:12:24 -04: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
Ryan Dwyer 7661c71b33 Update gaps documentation 2018-09-29 12:59:02 +10:00
Ryan Dwyer bb708d0f82 Don't allow negative gaps 2018-09-29 12:58:54 +10:00
Ryan Dwyer 415a48ac63 Make gaps implementation consistent with i3-gaps
This changes our gaps implementation to behave like i3-gaps.

Our previous implementation allowed you to set gaps on a per container
basis. This isn't supported by i3-gaps and doesn't seem to have a
practical use case. The gaps_outer and gaps_inner properties on
containers are now removed as they just read the gaps_inner from the
workspace.

`gaps inner|outer <px>` no longer changes the gaps for all workspaces.
It only sets defaults for new workspaces.

`gaps inner|outer current|workspace|all set|plus|minus <px>` is now
runtime only, and the workspace option is now removed. `current` now
sets gaps for the current workspace as opposed to the current container.

`workspace <ws> gaps inner|outer <px>` is now implemented. This sets
defaults for a workspace.

This also fixes a bug where changing the layout of a split container
from linear to tabbed would cause gaps to not be applied to it until you
switch to another workspace and back.
2018-09-29 11:08:19 +10:00
Drew DeVault dc01e884f7
Merge pull request #2724 from RedSoxFan/update-man-pages
Update man pages - dynamic vars and generic blocks
2018-09-28 22:07:27 +02:00
Brian Ashworth a9d9944e76 sway{,bar,input}.5: changes for generic blocks 2018-09-28 13:30:54 -04:00
Brian Ashworth cc6544c538 sway.5: update set command information 2018-09-28 13:30:54 -04:00
Drew DeVault ca7084cb52
Merge pull request #2723 from ianyfan/swaybar
swaybar: small fixes and clean-ups
2018-09-28 16:44:35 +02:00
Ian Fan 25e1f32738 swaybar: trim function prototypes 2018-09-28 14:09:33 +01:00
Ian Fan 751bb4a376 swaybar: move i3bar definitions into separate file 2018-09-28 13:54:58 +01:00
Ian Fan bcd2a8fe12 swaybar: remove unused focused_output property 2018-09-28 13:54:58 +01:00
Ian Fan 98576b9dda swaybar: fix setting binding mode indicator 2018-09-28 13:48:59 +01:00
Ian Fan 312d009f65 swaybar: fail if bar id is invalid 2018-09-28 13:48:59 +01:00
emersion 02df1e2b1b
Merge pull request #2722 from RyanDwyer/workspace-configs
Rename workspace_outputs to workspace_configs and fix memory leak
2018-09-28 14:45:08 +02:00
Ryan Dwyer 56e9f31b2f Check for NULL output in workspace_valid_on_output 2018-09-28 22:35:38 +10: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
emersion 1698260533
Merge pull request #2720 from swaywm/swaylock-shadow
Add support for building swaylock without PAM
2018-09-28 14:17:37 +02:00
Drew DeVault c977349120 Add support for building swaylock without PAM
This involves setuid'ing swaylock, which then forks and drops perms on
the parent process. The child process remains root and listens on a pipe
for requests to validate passwords against /etc/shadow.
2018-09-28 13:53:01 +02:00
Drew DeVault 813de9f7ac
Merge pull request #2716 from sghctoma/fix-swaybar-freebsd
Replace getdelim to make swaybar work on FreeBSD
2018-09-28 04:22:18 -05:00
Ryan Dwyer 5104bd2c59
Merge pull request #2663 from ianyfan/fix-txn-state-leaks
Free transaction state upon destruction by removing pointer indirection
2018-09-28 18:27:01 +10:00
Ian Fan 0dfcadc1cf transaction: do not use pointers for state 2018-09-28 09:18:24 +01:00
Drew DeVault 0b2afee711
Merge pull request #2719 from RyanDwyer/fix-view-is-visible
Fix floating views in tabbed/stacked workspaces not getting frame events
2018-09-28 02:12:18 -05:00
Ryan Dwyer 22412f57b0 Fix floating views in tabbed/stacked workspaces not getting frame events
view_is_visible would return false, which meant the view wouldn't
receive a frame done event. view_is_visible needs to make an exception
for floating containers.

This also moves the workspace_is_visible check to an earlier location
for performance reasons.
2018-09-28 17:02:35 +10:00
Ryan Dwyer f16529e258 Remove server-decoration assumption if view supports xdg-decoration 2018-09-27 23:00:10 +10:00
Ryan Dwyer 21ff87d72b Improve CSD logic
This does the following:

* Removes the xdg-decoration surface_commit listener. I was under the
impression the client could ignore the server's preference and set
whatever decoration they like using this protocol, but I don't think
that's right.
* Adds a listener for the xdg-decoration request_mode signal. The
protocol states that the server should respond to this with its
preference. We'll always respond with SSD here.
* Makes it so tiled views which use CSD will still have sway decorations
rendered. To do this, using_csd had to be added back to the view struct,
and the border is changed when floating or unfloating a view.
2018-09-27 22:51:37 +10:00
Ryan Dwyer 6d0442c0c2 Rename view_set_csd_from_client to view_update_csd_from_client 2018-09-27 22:51:37 +10:00
Ryan Dwyer efcfe57b10 Remove CSD from toggle list if client doesn't support it 2018-09-27 22:51:37 +10:00
Ryan Dwyer 7b138e5ef0 Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also
removes sway_xdg_shell{_v6}_view.deco_mode and
view->has_client_side_decorations as we can now get these from the
border.

You can use `border toggle` to cycle through the modes including CSD, or
use `border csd` to set it directly. The client must support the
xdg-decoration protocol, and the only client I know of that does is the
example in wlroots.

If the client switches from SSD to CSD without us expecting it (via the
server-decoration protocol), we stash the previous border type into
view.saved_border so we can restore it if the client returns to SSD. I
haven't found a way to test this though.
2018-09-27 22:51:37 +10:00
Drew DeVault 58af001517
Merge pull request #2717 from ianyfan/tablet-config
input config: merge left_handed option
2018-09-27 04:17:53 -05:00
Ian Fan a6c5628fa7 input config: merge left_handed option 2018-09-27 09:25:43 +01:00
Drew DeVault 5912be46c3
Merge pull request #2704 from ianyfan/tablet-config
input: enable configuring tablets with libinput
2018-09-27 02:07:15 -05:00
Drew DeVault d00a581ae0
Merge pull request #2715 from sghctoma/add-c11_source
Use _C11_SOURCE feature test macro on FreeBSD (fixes #2616)
2018-09-26 16:37:23 -05:00
sghctoma 315b2bf100 Replace getdelim to make swaybar work on FreeBSD
This commit fixes a segfault in swaybar on FreeBSD that was caused by
using getdelim with EOF as delimiter on an infinite stream. The FreeBSD
implementation handles the "no more data, delimiter not found, and EOF
not reached" scenario as an error, so it can't be used to read the
output of status command. This commit replaces the getline/getdelim
calls with reading all available data from the stream in one go.
2018-09-26 20:38:16 +02:00
sghctoma 2f258eff6f Make sway/ipc-server.c POSIX 2001 compliant
This commit replaces the non-standard SOCK_NONBLOCK and SOCK_CLOEXEC
flags with two fcntl calls. This makes the file POSIX 2001 compliant,
thus it is no longer necessary to conditionally define, or use internal
(__BSD_VISIBLE) feature test macros.
2018-09-26 20:10:53 +02:00
sghctoma 3e924f2345 Add _C11_SOURCE feature test macro on FreeBSD
This will restrict the default namespace set on FreeBSD to the C11
standard (everything is visible by default), which will prevent possible
conflicts with symbols hidden behing __BSD_VISIBLE.
2018-09-26 20:05:45 +02:00
Drew DeVault a8a0014e0f Make libpam optional 2018-09-26 17:32:15 +02:00
Drew DeVault 1ef96f7fb7
Merge pull request #2713 from RyanDwyer/fix-remap-race
Fix race condition crash when view unmaps + maps quickly
2018-09-26 07:39:13 -05:00
Ryan Dwyer 4e4898e90f Fix race condition crash when view unmaps + maps quickly
When a view unmaps, we start a transaction to destroy the container,
then when the transaction completes we destroy the container and unset
the view's container pointer. But if the view has remapped in the
meantime, the view's container pointer will be pointing to a different
container which should not be cleared.

This adds a check to make sure the view is still pointing to the
container being destroyed before clearing the pointer. The freeing of
the title format is also removed as it is already freed when the view
destroys in view_destroy.
2018-09-26 21:33:54 +10:00
Brian Ashworth c43374cdf0
Merge pull request #2712 from alexbakker/fix-crash
Add a missing null check for moving tiling containers
2018-09-25 16:46:38 -04:00
Alexander Bakker d129108cdd Add a missing null check for moving tiling containers 2018-09-25 22:19:46 +02:00
emersion 08815f9cfb
Merge pull request #2708 from RyanDwyer/fix-output-disconnect-crash
Fix crash when disconnecting output
2018-09-25 09:36:25 +02:00
Ryan Dwyer b1a0e95e8e Fix crash when disconnecting output
If the output being disconnected contains views, and the views are being
relocated to another output of a different size, a transaction must
occur to reconfigure them. This means by the time
container_discover_outputs is called, the output is already disabled and
wlr_output is NULL.

I considered making it check output->wlr_output, but output->enabled
should work just as well and is more descriptive.
2018-09-25 08:21:22 +10:00
Ian Fan 6194a445d3 input: enable configuring tablets with libinput 2018-09-24 12:49:20 +01:00
Ian Fan a10fef9ae8 cursor: allow cursor_set_image to accept a NULL image to hide cursor 2018-09-24 12:34:09 +01:00
Ian Fan dafb0526d7 seat: only show cursor if pointer configured 2018-09-24 10:55:42 +01:00
emersion a032925ae7
Merge pull request #2701 from RedSoxFan/input-wildcard
Implement support for input wildcard
2018-09-24 10:43:18 +02:00
Brian Ashworth baeb28ea62 Implement support for input wildcard 2018-09-23 19:56:52 -04:00
emersion 4a4f07ac25
Merge pull request #2699 from RedSoxFan/fix-2667
swaybg: fix increasingly smaller bg on hotplug
2018-09-23 21:44:57 +02:00
Brian Ashworth 9ea99a5d36 swaybg: fix increasingly smaller bg on hotplug
render_background_image alters the scale that cairo uses. Depending on
the image mode, resolution, and image size, this may cause the surface
to be rendered increasingly smaller. By calling cairo_save and
cairo_restore, any changes to the cairo settings by the function are
not kept as a side effect.

The surface that swaybg uses is also now cleared before rendering a frame.
This is needed to avoid artifacts on resolution or scale changes with
certain combinations of image modes, resolutions, and image sizes. This
was also part of the increasingly smaller background visual since it
made it so it was not obvious the region being rendered to was smaller
and caused an increasing number of smaller images to be appear for each
hotplug.
2018-09-23 15:17:36 -04:00
Drew DeVault 0bc9dc192f
Merge pull request #2696 from RyanDwyer/fix-gtkmenubar
Fix GtkMenuBar always opening first item
2018-09-23 07:18:09 -05:00
Ryan Dwyer 271b24ddfb Fix GtkMenuBar always opening first item
It seems like advertising that we support touch when we don't, while
using SSD, makes GtkMenuBar misbehave. Please don't ask me why...
2018-09-23 22:00:18 +10:00
Drew DeVault c2c257b884
Merge pull request #2695 from RyanDwyer/remove-moveoutoftabsstacks
Remove move_out_of_tabs_stacks
2018-09-23 06:19:12 -05:00
emersion 4bc327a021
Merge pull request #2694 from RyanDwyer/fix-sticky-jumping-on-switch
Prevent sticky containers from jumping on workspace switch
2018-09-23 09:42:07 +02:00
emersion 1af4d314d1
Merge pull request #2686 from RyanDwyer/tab-scrolling
Implement tab cycling using mouse wheel
2018-09-23 09:39:53 +02:00
Ryan Dwyer 9753e52d6b Flatten container in workspace_rejigger 2018-09-23 14:32:26 +10:00
Ryan Dwyer 0b7fb6943e Fix some bugs as a result of removing move_out_of_tabs_stacks 2018-09-23 13:55:06 +10:00
Ryan Dwyer 93624599b3 Remove move_out_of_tabs_stacks
This fixes the following. Create these layouts and run move right:

(Initial layout -> expected result -> actual result)

* `H[S[unfocused focused] unfocused]` ->
`H[S[unfocused] focused unfocused]` ->
`H[H[S[unfocused] focused] unfocused]`
* `H[S[unfocused focused] V[unfocused]]` ->
`H[S[unfocused] V[unfocused focused]]` ->
`H[H[S[unfocused] focused] V[unfocused]]`

move_out_of_tabs_stacks was originally made to allow views to move out
of the tabbed/stacked container in the parallel direction, but at some
point this has started working using the regular logic.
2018-09-23 13:10:36 +10:00
Ryan Dwyer 64445f4214 Prevent sticky containers from jumping on workspace switch
If you have swaybar docked to the top, and you create a floating sticky
container and switch workspaces on the same output, the sticky container
would move down by the height of swaybar on each switch.

This happens because when creating the workspace we set the dimensions
to the same as the output, then the subsequent arrange corrects it.
During this arrange, floating containers are translated so they stay
relative to the workspace. This translation needs to not occur for the
initial arrange.

This patch makes workspaces have a zero width and height when first
created, so we can detect whether this is the initial arrange and avoid
translating the floating containers if so.
2018-09-23 11:36:16 +10:00
Drew DeVault 68395f34f6
Merge pull request #2688 from RyanDwyer/exec-commands-without-focus
Allow running commands on containers without focusing them
2018-09-22 19:51:02 -05:00
Ryan Dwyer ae2055dcf1
Merge pull request #2690 from ianyfan/commands
commands: remove obselete code for sticky windows when switching workspace
2018-09-23 09:52:38 +10:00
Ryan Dwyer 1b32eadbc1
Merge branch 'master' into commands 2018-09-23 09:44:30 +10:00
Drew DeVault 53b5c4791e Remove contrib/awesome.config
We deprecated the stuff necessary to make this work.
2018-09-22 19:39:56 -04:00
Drew DeVault c6bf0e8e98
Merge pull request #2691 from ggreer/pango-font-options
Call pango_cairo_context_set_font_options().
2018-09-22 18:28:31 -05:00
Ryan Dwyer cb66bbea42 Allow running commands on containers without focusing them
This adds a `con` argument to `execute_command` which allows you to
specify the container to execute the command on. In most cases it leaves
it as `NULL` which makes it use the focused node. We only set it when
executing `for_window` criteria such as when a view maps. This means we
don't send unnecessary IPC focus events, and fixes a crash when the
criteria command is `move scratchpad` (because we can't give focus to a
hidden scratchpad container).

Each of the shell map handlers now check to see if the view has a
workspace. It won't have a workspace if criteria has moved it to the
scratchpad.
2018-09-23 08:39:11 +10:00
Geoff Greer 987e0054ac Call pango_cairo_context_set_font_options().
Call pango_cairo_context_set_font_options() before pango_cairo_update_layout() and pango_cairo_show_layout(). By default, Pango "merges" the Cario font options with its own, which doesn't enable full hinting.
2018-09-22 15:33:03 -07:00
Ian Fan d101f3d357 commands: remove obselete code for sticky windows when switching workspace 2018-09-22 23:27:53 +01:00
Drew DeVault 082488a81c
Merge pull request #2677 from ggreer/pretty-fonts
Render fonts slightly nicer
2018-09-22 13:56:51 -05:00
Geoff Greer c495164f60 swaybar, swaylock, & tree/container: Set cairo font options to render text and lines with subpixel hinting (if available). 2018-09-22 11:34:21 -07:00
emersion eae42606e2
Merge pull request #2660 from RyanDwyer/fix-scratchpad-iteration
Fix double iteration of scratchpad containers
2018-09-22 13:40:01 +02:00
Ryan Dwyer 480bcda1ee
Merge pull request #2687 from ianyfan/swaybar
swaybar: explicitly check return value of getdelim
2018-09-22 20:10:58 +10:00
Ian Fan a4d346627c swaybar: explicitly check return value of getdelim
This prevents an signed-to-unsigned conversion error on buffer_index if
getdelim fails and returns -1, which caused swaybar to try to search the
header for the array and immediately failing
2018-09-22 11:02:47 +01:00
emersion b148da848a
Merge pull request #2679 from RyanDwyer/fix-pango-escaping
Fix pango escaping and refactor escape_markup_text
2018-09-22 11:25:07 +02:00
Ryan Dwyer 2f36502828 Use pango_layout_set_text instead of pango_layout_set_markup 2018-09-22 18:40:19 +10:00
Ryan Dwyer 10ef118e09 Fix pango escaping and refactor escape_markup_text
Fixes #2674.

The cause of the issue was in get_pango_layout. When we call
pango_parse_markup, `text` is the escaped string, and the unescaped
string is then computed and written to `buf`. We were then passing the
unescaped string to pango_layout_set_markup, but this function needs the
escaped string. `buf` is not needed and has been removed.

The other part of this PR refactors escape_markup_text to remove the
dest_length argument and removes the -1 return value on error. It now
assumes that you've allocated dest to the correct length.
2018-09-22 18:33:28 +10:00
emersion fe7e66407c
Merge pull request #2678 from RyanDwyer/reconfigure-on-reposition
Reconfigure xwayland views when repositioned
2018-09-22 10:09:55 +02:00
Ryan Dwyer bf5933c501 Implement tab cycling using mouse wheel
Firstly, a change had to be made to the container_at functions. If you
create layout `T[view H[view view]]` and hover the second tab, the
container_at functions would return the focus_inactive child. They now
return the split container itself. To compensate for this,
dispatch_cursor_button has been adjusted to find the focus_inactive
child before focusing it.

The actual implementation of wheel scrolling is pretty straightforward.
This uses handle_cursor_axis, so I took a similar approach to
handle_cursor_button (ie. creating a dispatch_cursor_axis function).
2018-09-22 10:42:59 +10:00
Brian Ashworth d2a0a3cc0a
Merge pull request #2666 from emersion/swaybar-hotplug
swaybar: handle hotplugging
2018-09-21 15:36:08 -04:00
Brian Ashworth 04862e2121
Merge branch 'master' into swaybar-hotplug 2018-09-21 15:28:53 -04:00
Drew DeVault e554274673
Merge pull request #2672 from ianyfan/swaybar
swaybar: fix parsing errors when json is sent in parts
2018-09-21 12:52:57 -05:00
Drew DeVault ff2659ece4
Merge pull request #2683 from ammgws/patch-1
stabilityに関する注記を更新
2018-09-21 09:46:30 -05:00
Jason cf370539e5
stabilityに関する注記を更新 2018-09-21 23:26:01 +09:00
Ian Fan a2326661e1 swaybar: log invalid i3bar json 2018-09-21 15:10:47 +01:00
Ian Fan ccdec2a329 swaybar: reset tokener if json is incomplete
If the tokener parses incomplete json, it sets its error value to
json_tokener_continue. This means that extra json should be provided,
but the code was providing the entire object again. In the interest of
simplicity, the tokener is reset so that buffer_pos always points to the
start of the current object.
2018-09-21 15:09:54 +01:00
Ian Fan dbda5d35eb swaybar: update buffer_pos when moving object to start of buffer 2018-09-21 14:33:49 +01:00
Ryan Dwyer ae2f53a477 Reconfigure xwayland views when repositioned
Fixes #2673.
2018-09-21 23:02:48 +10:00
Drew DeVault e6a52ae387 Update stability notice in README 2018-09-21 08:51:50 -04:00
emersion 65ab6b7eb4
Merge pull request #2680 from marienz/no-x11-backend
Fix compilation against wlroots without X11 backend
2018-09-21 14:50:02 +02:00
Marien Zwart 37e51a20cc Fix compilation against wlroots without X11 backend 2018-09-21 21:25:03 +10:00
Ryan Dwyer 057635f1a3
Merge pull request #2665 from emersion/render-output-segfault
Fix segfault in output_render
2018-09-21 20:15:27 +10:00
Ryan Dwyer 0798fadff2
Merge branch 'master' into render-output-segfault 2018-09-21 20:05:39 +10:00
emersion 8a5ff5a4db swaybar: don't wl_display_roundtrip on each frame
This was the source of numerous bugs, from hotplug events not being
received to segfaults because wl_display_roundtrip was making the
bar process unplug events while blocking in an iteration over all
outputs.
2018-09-20 19:31:03 +02:00
emersion 82f1393cbb swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
2018-09-20 18:37:51 +02:00
emersion fa4308c5ab
Merge pull request #2671 from emersion/output-execute-no-focus
Fix segfault when executing command without focus
2018-09-20 18:36:47 +02:00
Drew DeVault 6ec3626228
Merge pull request #2676 from ianyfan/ipc
ipc: add pid information for views in layout tree
2018-09-19 17:37:58 -04:00
Ian Fan 81f3fda6fa ipc: add pid information for views in layout tree 2018-09-19 22:21:09 +01:00
emersion efc08ec888 Fix segfault when executing command without focus 2018-09-19 15:50:42 +02:00
Drew DeVault f0fb27aba6
Merge pull request #2669 from RyanDwyer/create-output-command
Introduce create_output command (for developer use)
2018-09-19 09:24:15 -04:00
emersion a2090d4222
Merge branch 'master' into create-output-command 2018-09-19 14:19:22 +02:00
Drew DeVault a83773e5ca
Merge pull request #2670 from ianyfan/commands
config: free strings fields when freeing input config
2018-09-19 08:16:20 -04:00
Ian Fan 8e8a5ca217 config: free strings fields when freeing input config 2018-09-19 12:55:49 +01:00
Ryan Dwyer db28459634 Introduce create_output command (for developer use)
Should help with testing hotplugging.
2018-09-19 21:54:27 +10:00
emersion 4289343e17 Fix segfault in output_render 2018-09-19 11:03:25 +02:00
Drew DeVault cdce604d8e
Merge pull request #2640 from ianyfan/swaybar
Overhaul swaybar protocol handling (+fixes)
2018-09-18 22:52:36 -04:00
Ian Fan 47a66da5de swaybar: only free tokener when using i3bar protocol 2018-09-18 18:06:19 +01:00
Ian Fan 5912325d5c swaybar: add debugging statements for handling i3bar json 2018-09-18 16:10:34 +01:00
Ryan Dwyer c6ff1f67f1 Fix double iteration of scratchpad containers
root_for_each_container and root_find_container were using incorrect
logic to determine if a container was hidden in the scratchpad.
Containers will have a NULL parent if they are a direct child of a
workspace. Containers will have a NULL workspace if they are hidden in
the scratchpad.

The incorrect check meant that root_for_each_container would run the
callback on scratchpad containers twice. This meant that executing a
command such as `[class="$something"] scratchpad show` would cause the
command to run twice, resulting in the container being shown and hidden
again which is effectively a no op.

Fixes #2655.
2018-09-18 21:53:02 +10:00
Ian Fan 7882ac66ef swaybar: rewrite i3bar protocol handling
This now correctly handles an incoming json infinite array by shifting
most of the heavy listing to the json-c parser, as well as sending
multiple statuses at once. It also removes the struct
i3bar_protocol_state and moves its members into the status_line struct,
allowing the same buffer to be used for both protocols.
2018-09-18 11:36:33 +01:00
Ian Fan 8cbce77e1d swaybar: rewrite protocol determination
This now uses the getline function to receive the header, replacing
read_line_buffer, which has been deleted since it is otherwise unused.
Furthermore, once the protocol has been determined, the current status
is handled immediately to be shown (though this has not been added for
the i3bar protocol since it has not yet been rewritten to handle this).
2018-09-18 11:36:33 +01:00
Ian Fan 70245c2cd5 swaybar: rewrite text protocol handling
This now uses getline to correctly handle multiple or long statuses. It
also removes the struct text_protocol_state and moves its members into
the status_line struct.
2018-09-18 11:36:33 +01:00
Ian Fan babd9618b9 swaybar: only create i3bar block hotspot if click events are enabled 2018-09-18 11:36:33 +01:00
Ian Fan 87c93d6ad9 swaybar: send trailing comma with click event json 2018-09-18 11:36:33 +01:00
Ian Fan 9932c6a1f1 swaybar: fix empty function prototypes 2018-09-18 11:36:33 +01:00
Ian Fan 952453480f swaybar: invalidate file descriptors upon closing 2018-09-18 11:36:33 +01:00
Ian Fan 4cb28de89f swaybar: remove block links upon exit 2018-09-18 11:36:33 +01:00
Brian Ashworth 15dadaaa44
Merge pull request #2652 from emersion/swaybar-output-names
swaybar: use output names instead of output indexes
2018-09-17 13:38:56 -04:00
emersion 012df55be5 swaybar: use output names instead of output indexes 2018-09-17 16:04:09 +02:00
emersion 5abf832202
Merge pull request #2649 from wmww/fix-move-crash
Fix crash moving out of tab container
2018-09-17 10:52:14 +02:00
William Wold f48999dd24 Fix crash moving out of tab container 2018-09-17 01:20:45 -07:00
Drew DeVault 456b91600d
Merge pull request #2637 from RyanDwyer/fix-tabbed-workspace-shenanigans
Make seat_get_active_child ignore floating children
2018-09-16 10:22:01 -04:00
Drew DeVault 5192f74be1
Merge pull request #2641 from marienz/inhibit-crash
Fix crash when an idle-inhibiting client exits
2018-09-16 10:19:14 -04:00
Marien Zwart ffd1308bbc Fix crash when destroying an idle-inhibiting client
When destroying an idle-inhibiting client, idle_inhibit_v1_check_active can get
called from transaction_progress_queue on a view with a null container.
view_is_visible does not handle a view in this state.
2018-09-16 23:20:58 +10:00
Ryan Dwyer f6e218a643 Rename seat_get_active_child to seat_get_active_tiling_child
Also renames container to con in one function to prevent ugly line
wrapping.
2018-09-16 22:01:54 +10:00
Ryan Dwyer 48bc15e758 Make seat_get_active_child ignore floating children
seat_get_active_child is used to get the active tiling child in a few
places, such as outputs getting their active workspace and
tabbed/stacked containers getting their visible child. When a workspace
uses a tabbed or stacked layout and contains a focused floating view,
calling seat_get_active_child on the workspace would incorrectly return
the floating view. This changes it so it will return the tiling child.

This fixes the following bug:

* Create layout T[view view] then float one of the views
* Attempt to click the tiling view to give it focus - it wouldn't work
because seat_get_active_child would return the floating view
2018-09-16 21:57:19 +10:00
emersion 31c6b5814f
Merge pull request #2638 from RyanDwyer/fix-tab-unmap-crash
Fix crash when unmapping last child of a tabbed workspace
2018-09-16 10:44:39 +02:00
Ryan Dwyer 09733e233f Fix crash when unmapping last child of a tabbed workspace
* Create layout T[view view]
* Move the cursor into the title bar area
* Close both views

Sway would crash because container_at_tabbed would attempt to divide by
zero when there are no children.

The children check isn't needed for the stacked function because it
doesn't divide anything by the number of children.

Fixes #2636.
2018-09-16 14:18:13 +10:00
Drew DeVault 9f985f1f1c
Merge pull request #2634 from ianyfan/ipc
ipc: add focus information to root node
2018-09-15 11:15:09 -04:00
Ian Fan 34dbbb1314 ipc: handle NULL cases for node_get_output 2018-09-15 09:42:49 +01:00
Ian Fan 1c292fd43a ipc: add focus information to root node 2018-09-15 09:42:49 +01:00
Drew DeVault b47f4f5fd4
Merge pull request #2630 from emersion/wlroots-1243
Update for swaywm/wlroots#1243
2018-09-14 21:12:56 -04:00
Drew DeVault 64d567be9b
Merge branch 'master' into wlroots-1243 2018-09-14 21:03:59 -04:00
Drew DeVault 3b92d5bb6d Additional fix for xdg-output 2018-09-14 21:03:35 -04:00
Drew DeVault b4d60da856
Merge branch 'master' into wlroots-1243 2018-09-14 20:56:50 -04:00
Drew DeVault 73aab86b6d Postfix xdg-output headers
"Doesn't need an update" my ass...
2018-09-14 20:55:05 -04:00
Drew DeVault 5d104ae537
Merge pull request #2633 from ianyfan/view-recon-fix
Remove redundant container creation in view initialisation
2018-09-14 20:45:56 -04:00
Ian Fan 25ba80057d Remove redundant container creation in view initialization 2018-09-15 01:24:10 +01:00
emersion b842b4f32e
Merge pull request #2631 from ianyfan/swaybar
bar: remove i3bar_block_free in favour of i3bar_block_unref
2018-09-14 22:19:40 +02:00
Ian Fan e32e86b65d bar: remove i3bar_block_free in favour of i3bar_block_unref 2018-09-14 21:06:54 +01:00
Drew DeVault f5ecc89c68
Merge pull request #2629 from RedSoxFan/fix-654
Allow spaces in background file path
2018-09-14 15:57:53 -04:00
emersion 7699c5444c Update for swaywm/wlroots#1243 2018-09-14 19:21:44 +02:00
Brian Ashworth 17fe8924f2 Address ianyfan's comments
wordexp p is now initialized to {0} to prevent a segfault on wordfree
in the failure case.

File paths with single quotes and double quotes are now supported. The
quote can either be wrapped in the other quote or escaped with three
backslashes.

Additionally to make passing file paths with double quotes to swaybg
easier, instead of enclosing the path given to swaybg in quotes, all
spaces, single quotes, and double quotes in the resulting path are now
escaped with a single backslash.
2018-09-14 08:51:01 -04:00
Brian Ashworth 1cf737489d Escape spaces in background file path 2018-09-13 22:21:10 -04:00
Brian Ashworth 0b64cce733 Allow spaces in background file paths 2018-09-13 22:21:10 -04:00
emersion 5f9be1e1aa
Merge pull request #2628 from RyanDwyer/remove-rejigger-assertion
Remove bad assertion in workspace_rejigger
2018-09-13 09:38:28 +02:00
Ryan Dwyer 2f6935e00f Remove bad assertion in workspace_rejigger
The assertion can be (rightfully) triggered by creating layout
V[H[view view] view] and moving the top right view to the right.

After removing the assertion I found the container being moved needs its
size reset to prevent it from being sized wrongly after arranging.
2018-09-13 17:02:10 +10:00
Drew DeVault dbaafdfac9
Merge pull request #2622 from ianyfan/i3bar-block-ref
i3bar: count references to blocks
2018-09-12 12:28:14 -04:00
Ian Fan 2eaef80206 i3bar: count references to blocks
This prevents blocks from being destroyed before their hotspots are destroyed,
in case it is used for a pending click event that fires between the bar
receiving a new status, which destroys the block, and the bar rendering the new
status, which destroys the hotspot; this problem can be easily produced by
scrolling on a block that immediately causes a new status to be sent, with
multiple outputs
2018-09-12 08:28:28 +01:00
emersion af9e8f94cc
Merge pull request #2620 from ianyfan/commands
commands: when moving a container, restore focus properly
2018-09-12 09:20:47 +02:00
Drew DeVault 7a295e8932
Merge pull request #2624 from RedSoxFan/update-tex-in-cmd-client
Update textures for cmd_client_* commands
2018-09-11 19:55:23 -04:00
Drew DeVault d8a96c9e4d
Merge pull request #2621 from emersion/fix-unmap-segfault
Don't use handler_context in view_unmap
2018-09-11 19:50:00 -04:00
Brian Ashworth 0b7fe54f9e Update textures for cmd_client_* commands
Since the `client.{focused,focused_inactive,unfocused,urgent}` commands
change colors, the textures need to be updated otherwise the textures
and the rest of the title bar may utilize different colors.
2018-09-11 19:34:57 -04:00
Drew DeVault 4fbec701fc
Merge pull request #2618 from RyanDwyer/tiling-drag
Implement tiling drag
2018-09-11 19:19:17 -04: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
emersion 8b263429cf Don't use handler_context in view_unmap 2018-09-11 19:34:58 +02:00
Ian Fan ae535396b0 commands: when moving container, remove its gaps 2018-09-11 16:46:11 +01:00
Ian Fan c770949a9f commands: when moving container, restore focus properly 2018-09-11 16:46:07 +01:00
Ryan Dwyer df95c61044 Fix crash in workspace_wrap_children
When workspace_wrap_children is called on a workspace which has a
fullscreen child and the fullscreen child is a direct child of the
workspace, sway would crash.

The workspace's fullscreen pointer is unset when the fullscreen
container is detached and applied again when added to a parent, but in
this case the parent hadn't yet been added to the workspace which meant
con->workspace was NULL.

The fix makes container_handle_fullscreen_reparent return if there's no
workspace, and the fullscreen pointer is reapplied in
workspace_wrap_children.
2018-09-11 23:38:17 +10:00
Ryan Dwyer 403905c11b Fix line length 2018-09-11 23:24:57 +10:00
Ryan Dwyer eb74317c2d Fix dropzone box on scaled outputs 2018-09-11 22:26:39 +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 ec9c4de564 Introduce tiling_drag directive 2018-09-11 17:17:19 +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 822b45f483
Merge pull request #2617 from wmww/cursor-enter-on-focus-change
Give windows pointer focus immediately
2018-09-10 21:00:39 -04:00
William Wold 097ed03647 Minor fix 2018-09-10 17:52:42 -07:00
William Wold 22c5dd8a02 Minor fix 2018-09-10 10:18:12 -07:00
William Wold 9a08019267 Prevent stacked layout from crashing 2018-09-10 10:18:12 -07:00
William Wold e787a1581c Give windows pointer focus immediately when they are switched to
Fixes #2401 (aka #2558)

Previously, when switching windows, pointer focus was not changed until the pointer was moved. This makes the pointer enter happen immediately, without the side effects of other attempted fixes.
2018-09-10 10:18:12 -07:00
emersion 024b9d85ea
Merge pull request #2613 from apreiml/fix_no_last_focus_fail
handle_layer_shell_surface: Do not crash if seat doesn't have focus
2018-09-10 13:56:02 +02:00
Armin Preiml 47b6fea3fe handle_layer_shell_surface: Do not crash if seat doesn't have focus 2018-09-10 11:23:08 +02:00
Drew DeVault f7568e26e9
Merge pull request #2609 from ianyfan/commands
commands: prevent running empty seat command
2018-09-08 17:06:33 -04:00
Ian Fan 6cd92b193c commands: prevent running empty seat command 2018-09-08 19:53:27 +01:00
Drew DeVault 1376d36104
Merge pull request #2530 from apreiml/ipc_missing_get_tree
start adding missing ipc properties
2018-09-08 09:20:36 -04:00
Drew DeVault 3600b3db57
Merge pull request #2602 from RyanDwyer/fix-title-textures
Fix gaps in title textures and vertically center them
2018-09-08 09:19:47 -04:00
Armin Preiml 7919ae5e44 code style fixes 2018-09-08 13:24:01 +02:00
Armin Preiml 2dec0d894b get_tree: percent cast to double on division 2018-09-08 13:24:01 +02:00
Armin Preiml 79eaa26b3e get_tree: default values
Added default values for all nodes, because the i3 get_tree always returns
all fields inside the json objects.

Add geometry and window for views. Window is only availabel on
x11 windows otherwise it's NULL.

Calculate percent only if parent is not empty to avoid division by 0.
2018-09-08 13:24:01 +02:00
Armin Preiml 3d8c3e560b missing ipc stuff: rebase to typesafety 2018-09-08 13:24:01 +02: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 9226aad58c Fix gaps in title textures and vertically center them
There was code that attempted to fill in the gap below the title texture
when the texture isn't tall enough, but this only worked when the output
was positioned at 0,0. The reason is that render_rect expects a box
passed in a hybrid layout-local/output-buffer-local system, and we were
passing purely output-buffer-local. I've added a comment documenting
this.

By the way, we can't use layout-local coordinates for the rectangle box
because in some cases we set the box based on a texture size. Texture
sizes are buffer-local, and we'd have to divide them to bring it back to
layout-local which means losing precision. We could use
output-buffer-local coordinates for the box, but this would require
translating the coordinates from layout-local to output-buffer-local in
many places during rendering.

This patch also vertically centers the text inside the title bar.
2018-09-08 16:25:07 +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
Drew DeVault d86afdc6ed
Merge pull request #2600 from RyanDwyer/fix-workspace-switching
Fix workspace switching
2018-09-06 19:18:30 -04:00
Ryan Dwyer 763554e1be Fix workspace switching
The output also needs to be made dirty when focusing a new output.
2018-09-07 08:08:40 +10:00
emersion f3b96d4050
Merge pull request #2594 from RyanDwyer/fix-pinentry
Float views when min == max on either dimension
2018-09-06 21:28:51 +02:00
Drew DeVault ed9e7bb8f4
Merge pull request #2593 from RyanDwyer/dont-be-so-dirty
Don't dirty outputs unnecessarily
2018-09-06 10:08:57 -04:00
Ryan Dwyer cf32d5d776 Float views when min == max on either dimension
This fixes pinentry-gtk-2, but might make other views floating which
would otherwise be tiled. This patch is more of a trial which could end
up becoming a permanent fix.
2018-09-06 23:57:57 +10:00
Ryan Dwyer f30527e0cd Don't dirty outputs unnecessarily 2018-09-06 23:25:10 +10:00
emersion 4a3b705a12
Merge pull request #2592 from RyanDwyer/fix-fullscreen-unmap-focus
Second attempt at restoring focus when closing a fullscreen view
2018-09-06 14:59:01 +02:00
Ryan Dwyer 635ae9557c Second attempt at restoring focus when closing a fullscreen view
To reproduce the problem this is fixing, create H[view view view],
fullscreen one of the views and close it. The entire workspace will be
given focus rather than one of the siblings.

This happens because we emit the destroy event, so the seat code tries
to find a new focus, but the view it finds is still believed to be
hidden by the fullscreen view so it's discarded and the workspace is
used instead.

This clears the workspace's fullscreen pointer prior to emitting the
destroy event so that the seat code finds an appropriate new focus.
2018-09-06 22:34:09 +10:00
Brian Ashworth c26beebd88
Merge pull request #2591 from RyanDwyer/fix-workspace-switch
Make outputs dirty when changing focus
2018-09-06 07:24:08 -04:00
Ryan Dwyer 5896781df4 Make outputs dirty when changing focus
Fixes a workspace switch bug introduced by
5967ee1fbc.
2018-09-06 21:15:24 +10:00
emersion 8e2a2e5ca4
Merge pull request #2589 from RyanDwyer/seat-set-focus-type
Introduce seat_set_focus_container and seat_set_focus_workspace
2018-09-06 12:56:21 +02:00
Brian Ashworth 6ab38ba098
Merge pull request #2590 from RyanDwyer/fix-output-active-workspace
Fix crash when switching to new workspace during transaction
2018-09-06 06:30:21 -04:00
Ryan Dwyer 5967ee1fbc Fix crash when switching to new workspace during transaction
When rendering, the workspace for the output needs to be retrieved from
the output's `current` state. output_get_active_workspace returns the
pending workspace, which crashes if the pending workspace is new and
hasn't completed a transaction yet.
2018-09-06 20:20:29 +10: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
emersion bea9f9c63f
Merge pull request #2578 from RyanDwyer/fix-binding-reload
Fix management of bindings during reload
2018-09-06 10:41:49 +02:00
Brian Ashworth 63567f5ac6
Merge pull request #2587 from RyanDwyer/fix-layout-toggle-crash
Fix crash when running "layout toggle"
2018-09-06 00:42:47 -04:00
Ryan Dwyer 1f941163d3 Fix crash when running "layout toggle"
The argc and argv used in this function are the same ones used by the
layout command itself.
2018-09-06 14:29:26 +10:00
Drew DeVault c6a74cb4df
Merge pull request #2586 from RyanDwyer/fix-fullscreen-focus-crash
Fix crash when focusing from fullscreen in an invalid direction
2018-09-05 22:12:54 -04:00
Drew DeVault 2eec9740bd
Merge pull request #2585 from RyanDwyer/fix-move-across-outputs
Fix crash when moving view across outputs
2018-09-05 22:04:38 -04:00
Ryan Dwyer 8859da1dc3 Fix crash when focusing from fullscreen in an invalid direction
* Fullscreen a view
* Run `focus <direction>` where there is no output in that direction

The output returned was rightfully NULL, which needs to be handled.
2018-09-06 12:03:13 +10:00
Drew DeVault 7b79ab2577
Merge pull request #2583 from RyanDwyer/fix-null-surface-crash
Fix crash when views rapidly map and unmap
2018-09-05 21:59:13 -04:00
Ryan Dwyer 01117db6d9 Fix crash when moving view across outputs
It was incorrectly determining that the container being moved and the
destination had the same parent, which resulted in tree corruption. Both
parents can be NULL but the containers may belong to different
workspaces.

To reproduce, create layout H[V[view] view] in one workspace then move a
view left or right from another output into that workspace.
2018-09-06 11:53:55 +10:00
Drew DeVault 97474f12e3
Merge pull request #2582 from ascent12/func
Remove __PRETTY_FUNCTION__
2018-09-05 21:44:52 -04:00
Ryan Dwyer 9642b87b9e Fix crash when views rapidly map and unmap
Suppose the following:

* Transactions are already in progress - say transaction A.
* View A maps, which creates transaction B and appends it to the
transaction queue.
* View B maps, which creates transaction C and appends it to the queue.
* View A unmaps, which creates transaction D and appends it to the
queue.
* Transaction A completes, so transaction B attempts to save View A's
buffer, but this doesn't exist so it saves nothing.
* Rendering code attempts to render View A, but there is no saved buffer
nor live buffer that it can use.

Rather than implement an elaborate solution for a rare circumstance,
I've take the safe option of just not rendering anything for that view.
It means that if you reproduce the scenario above, you might get the
title and borders rendered but no surface.
2018-09-06 11:39:52 +10:00
Scott Anderson bcde223129 Remove __PRETTY_FUNCTION__
This is a non-standard extension as well as completely useless in C.
__func__ is the standard way of doing this.
2018-09-06 13:31:57 +12:00
Drew DeVault f255881134
Merge pull request #2579 from RyanDwyer/adjust-container-box
Adjust container box
2018-09-05 21:14:19 -04:00
Drew DeVault 85e95d5825
Merge pull request #2580 from RyanDwyer/fix-focus-after-fullscreen
Restore focus correctly when closing a fullscreen view
2018-09-05 20:39:13 -04:00
Ryan Dwyer 5cc70d1dfd Restore focus correctly when closing a fullscreen view
We weren't calling seat_send_focus. I think this was previously called
by seat_set_focus_warp.
2018-09-06 09:33:37 +10:00
Ryan Dwyer c6368febc8 Adjust container box
Prior to f5b9815128, children of tabbed
and stacked containers would have their container size and position set
to the same as the tabbed/stacked container. Normally this would be a
problem for a layout such as T[V[view]], but there was some code in the
arrange functions which would check if the grandparent of the view was a
tabbed or stacked container and would offset the view's Y accordingly.

Commit f5b9815128 changed the box to
exclude the titlebar for all tabbed/stacked children so that the
grandparent check could be removed. But this meant the title was not
covered in the container and wasn't damaged when the child changed its
title.

This patch changes it so that a child of a tabbed/stacked container will
have its box include the title bar if the child is a view, but not if
it's a layout container. This fixes the title damage issue while
avoiding the grandparent check in the arrange functions, and matches
what we see visually.
2018-09-06 09:13:36 +10:00
Ryan Dwyer 32c7386b0f Fix management of bindings during reload
seat_execute_command needs to check the flags on `binding_copy`, as
`binding` will be a dangling pointer after a reload command.

handle_keyboard_key needs to set the next_repeat_binding for
non-reloads prior to executing the command in case the binding is
freed by the reload command.
2018-09-06 08:33:00 +10:00
Drew DeVault 49c937fc87
Merge pull request #2572 from RedSoxFan/wlr-output-disabling
Call wlr_output_enable on enable/disable if needed
2018-09-05 14:55:13 -04:00
Brian Ashworth c246cf84c8 Call wlr_output_enable on enable/disable if needed 2018-09-05 14:00:00 -04:00
Drew DeVault 610eb94617
Merge pull request #2540 from RyanDwyer/typesafety
Implement type safe arguments and demote sway_container
2018-09-05 09:33:27 -04:00
emersion aa2bf98e04
Merge pull request #2574 from ammgws/block-bg-fix
Fix swaybar block background fill logic
2018-09-05 12:11:27 +02:00
Jason 13fbe5176b
Fix swaybar block background fill logic
Same as #2571 but for 1.0.
2018-09-05 18:48:31 +09:00
Ryan Dwyer dbf4aa3e33 Allow marked containers to be moved out of the scratchpad via move command 2018-09-05 18:01:43 +10:00
Ryan Dwyer 1f2e0ff54b Fix inversed condition in criteria 2018-09-05 18:01:43 +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 3cc7de3fb4 Fix crash when view in scratchpad becomes urgent 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 27d2d37d6e Fix crash when running layout toggle split 2018-09-05 18:01:43 +10:00
Ryan Dwyer c0da364865 Fix floating view moving to 0,0 when splitting 2018-09-05 18:01:43 +10:00
Ryan Dwyer 7263e39f64 Fix crash when using focus parent/child from an empty workspace 2018-09-05 18:01:43 +10:00
Ryan Dwyer 4e0452fce3 Fix scratchpad related crashes
* Was crashing when a view was moved to the scratchpad (prev focus had
no parent).
* Was crashing when a hidden scratchpad view unmaps because it has no
workspace.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 93ff7879f1 Fix output position issue
Looks like the output dimensions need to be set when arranging rather
than when a mode is set.

Fixes an issue with position of fullscreen views.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 7f40b928c7 Fix another focus bug when moving into output
Find the focused_inactive view rather than possibly selecting a parent.
2018-09-05 18:01:43 +10:00
Ryan Dwyer fb9b0f7a08 Fix focus bug
When changing focus from a view in one workspace to an empty workspace
using `focus <direction>`, the view in the previous workspace would keep
focused styling. This is because the check to unfocus it was only done
in the container case and not workspace case, so it's been moved out of
both.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 3133d0c03c Fix swaybars with no defined output 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 9d168a693d Fix moving workspace to output 2018-09-05 18:01:43 +10:00
Ryan Dwyer 0b23423c14 Update output propertes on mode change
This was previously done when arranging the output, but only needs to be
done on mode change.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 2aa6afae54 Fix mouse_warping 2018-09-05 18:01:43 +10:00
Ryan Dwyer 26204441b4 Apply default config to output
When starting without any output config, the default config was not
applying.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 06d9693829 Remove offset argument to container_add_sibling
I added this thinking that it might come in useful. Turns out it didn't.
2018-09-05 18:01:43 +10:00
Ryan Dwyer 0df04e27b6 Fix crash when focus hits edge of root 2018-09-05 18:01:43 +10:00
Ryan Dwyer acc2628c79 Don't use wlr_output properties
These properties are before rotation.
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
Drew DeVault 309fcf2300
Merge pull request #2569 from RyanDwyer/deny-reload-repeat
Deny repeating reload by holding key
2018-09-04 11:00:12 -04:00
Ryan Dwyer 7797490e9e Deny repeating reload by holding key
Fixes #2568

The binding that gets stored in the keyboard's `repeat_binding` would
get freed on reload, leaving a dangling pointer.

Rather than attempt to unset the keyboard's `repeat_binding` along with
the other bindings, I opted to just not set it for the reload command
because there's no point in reloading repeatedly by holding the binding.
This disables repeat bindings for the reload command.

As we now need to detect whether it's a reload command in two places,
I've added a binding flag to track whether it's a reload or not.
2018-09-04 20:00:04 +10:00
Drew DeVault 6dd3e0caf5
Merge pull request #2561 from RyanDwyer/window-role-criteria
Implement window_role criteria token
2018-09-03 21:49:41 -04:00
Ryan Dwyer 29f5cc7508 Implement window_role criteria token
Depends on https://github.com/swaywm/wlroots/pull/1226
2018-09-04 08:23:50 +10:00
Drew DeVault 0b61bae8fb
Merge pull request #2564 from ppascher/master
Fix window_type with disabled xwayland support
2018-09-03 11:04:03 -04:00
Drew DeVault e4afd33d47
Merge pull request #2542 from sghctoma/fix-freebsd-build
FreeBSD fixes
2018-09-03 10:59:18 -04:00
Drew DeVault 7d353813d5
Merge pull request #2563 from taiyu-len/fix/misaligned-pointer-access
fix misaligned integer stores/loads
2018-09-03 10:57:21 -04:00
emersion 15c57f476f
Merge pull request #2565 from ianyfan/fix-splashscreen-crash
Fix crash when a splash screen opens on an empty workspace
2018-09-03 16:32:35 +02:00
Ian Fan e6fde0739a Fix crash when a splash screen opens on an empty workspace 2018-09-03 14:03:49 +01:00
Pascal Pascher 93673095f0 move criteria "instance", "class" and "window_role" inside HAVE_XWAYLAND ifdefs" 2018-09-03 14:25:48 +02:00
Pascal Pascher f998601821 fix window_type with disabled xwayland support 2018-09-03 11:17:07 +02:00
Pascal Pascher 587e320cd8 Fixed window_type with disabled xwayland support. 2018-09-03 11:13:50 +02:00
sghctoma 073dcb3a86 Change _XOPEN_SOURCE defines to _POSIX_C_SOURCE 2018-09-03 09:08:49 +02:00
sghctoma df730a8891 Merge remote-tracking branch 'upstream/master' into fix-freebsd-build 2018-09-03 08:57:17 +02:00
Brian Ashworth c9276f04c9
Merge pull request #2553 from emersion/disabled-no-modeset
Do not modeset disabled outputs
2018-09-03 00:32:09 -04:00
Brian Ashworth afb6968874
Merge branch 'master' into disabled-no-modeset 2018-09-03 00:24:28 -04:00
taiyu d625d68d4a
prevent ub caused by misaligned stores/loads 2018-09-02 17:07:12 -07:00
emersion 3af9588eb4
Merge pull request #2562 from RyanDwyer/ld-library-path
Add meson option for LD_LIBRARY_PATH
2018-09-02 21:42:46 +02:00
emersion e438342157
Merge pull request #2560 from RyanDwyer/focus-on-window-activation
Implement focus_on_window_activation
2018-09-02 21:41:24 +02:00
Ryan Dwyer 4ece26e511 Add ld-library-path meson option 2018-09-02 23:07:47 +10:00
Ryan Dwyer 7795f733d8 Use dashes in meson option names 2018-09-02 22:58:15 +10:00
Ryan Dwyer 6fb03817c9 Rename fowa enum and use switch in view_request_activate 2018-09-02 18:25:45 +10:00
Ryan Dwyer f057a0195e Implement focus_on_window_activation
Depends on https://github.com/swaywm/wlroots/pull/1223
2018-09-02 18:20:34 +10:00
emersion 159edc6d13
Merge pull request #2559 from RyanDwyer/xwayland-check-modal
Check modal state when determining whether an xwayland view should float
2018-09-02 10:17:29 +02:00
Ryan Dwyer 69cd1dfaca Check modal state when determining whether an xwayland view should float
Depends on https://github.com/swaywm/wlroots/pull/1222.

I don't know of a program that sets the state to modal without setting
the window type, but I know the modal property works because logging the
property shows it's true for the Firefox Open File dialog.
2018-09-02 17:14:12 +10:00
emersion ca3be93757
Merge pull request #2554 from emersion/init-dmabuf-global-in-renderer
Update for swaywm/wlroots#1216
2018-09-02 08:51:07 +02:00
emersion 407c12fddd Update for swaywm/wlroots#1216 2018-09-01 19:33:24 +02:00
Drew DeVault 80270ba086
Merge pull request #2544 from RyanDwyer/fix-deferred-cmd-crash
Fix crash when running deferred commands
2018-09-01 13:00:26 -04:00
emersion 349d1f3be8 Do not modeset disabled outputs 2018-09-01 18:56:53 +02:00
Drew DeVault 89a045835f
Merge pull request #2547 from RyanDwyer/fix-reload-crash
Fix crash on reload
2018-09-01 10:39:36 -04:00
Drew DeVault 692dc55eca
Merge pull request #2549 from RyanDwyer/border-improvements
Implement deprecated new_window and new_float commands
2018-09-01 10:38:02 -04:00
Drew DeVault 4ac67d6408
Merge pull request #2550 from RyanDwyer/window-type-criteria
Implement window_type criteria token
2018-09-01 10:37:42 -04:00
Ryan Dwyer f4ec308376 Implement window_type criteria token 2018-09-01 23:04:49 +10:00
Ryan Dwyer 016d0455f8 Implement deprecated new_window and new_float commands
May as well make it as easy as possible for users who are coming from
i3.

This also changes the `border` command to accept a thickness when
setting the border to normal. This makes it work the same way as the
`default_border` command. Eg. `border normal 5`
2018-09-01 21:28:13 +10:00
Ryan Dwyer 7e81e58e7d Allow reload command to exist anywhere in the command string
This fixes a crash if you have commands where reload appears in the
middle or at the end, such as `bindsym r mode default, reload`.
2018-09-01 11:45:48 +10:00
Ryan Dwyer ebe65a4d48 Fix crash on reload
If sway is reloaded using a bindsym which has multiple commands, it
failed to detect the reload command, didn't create a duplicate of the
binding and would crash because the reload command frees the bindings.

For example:

    mode system {
        bindsym r reload, mode default
    }

In this example, the binding->command is "reload, mode default".

Fixes #2545
2018-09-01 11:17:15 +10:00
emersion 1f1b1b34d6
Merge pull request #2546 from RyanDwyer/fix-transaction-spamming
Don't send never-ending transactions when a focused layer surface commits
2018-08-31 14:05:19 +02:00
Ryan Dwyer dce549c537 Don't send never-ending transactions when a focused layer surface commits
This moves the arrange_windows call into the arrange_layers function,
where we know the output actually needs to be arranged.

Additionally, we shouldn't set focus to the parent of an unknown
container type, because the parent may be an output and this causes a
crash because outputs can't have direct focus.

Fixes #2543
2018-08-31 21:39:28 +10:00
Ryan Dwyer 1e0459f7f7 Fix crash when running deferred commands
Fixes #2541
2018-08-31 19:49:12 +10:00
sghctoma 67188b7cba Enable privilege dropping of FreeBSD
Privilege dropping works on FreeBSD too, so only the caps parts need to
be Linux-only.
2018-08-30 10:33:48 +02:00
sghctoma ac7a0aa038 Add missing destroy calls to server_fini
Rootston calls "wlr_xwayland_destroy" and "wl_display_destroy_clients"
on shutdown, but these were not called by Sway. Without them, Sway
crashes on exit before the display destroy event handler could be
called. This causes two problems:

 - The TTY is not reset, and it locks up after exiting Sway.
 - drmDropMaster is not called, and the implicit drop (that should
   occur when the DRM fd is closed) seems not to be working in some
   scenarios (e.g. if you have a tmux session running - maybe the fd
   is retained somehow by tmux?). In other words, it you exit Sway,
   you can't start it (or any other program that wants to be DRM
   master) again until you close all your tmux sessions.
2018-08-30 10:05:04 +02:00
sghctoma 6de777a986 Add FreeBSD-specific PAM configuration
The "login" PAM configuration means somathing entirely different on
FreeBSD than on Linux: if you try to authenticate as the calling user,
it OKs the request without prompting for password. The "passwd" config
implements the desired functionality, therefore it should be used by
swaylock.
2018-08-30 09:58:57 +02:00
sghctoma 6942f5b684 Fix SYSCONFDIR to include "prefix"
SYSCONFDIR is used to determine the path of the default configuration
file. 'sysconfdir' is set to 'prefix/sysconfdir' later (on line 139),
so configuration files are installed under 'prefix', but SYSCONFDIR did
not reflect it.
2018-08-30 09:44:24 +02:00
sghctoma 462e15d9a5 Make libcap an optional dependency
FreeBSD does not have libcap, so without "required: false" Sway fails
to build.
2018-08-30 09:40:35 +02:00
sghctoma cc16948c85 Fix feature macros for FreeBSD
On FreeBSD, snprintf and vsnprintf are visible only if
_XOPEN_SOURCE >= 600.
2018-08-30 09:34:26 +02:00
Drew DeVault de9e80459a
Merge pull request #2537 from ianyfan/commands
commands: fix exec quoting
2018-08-29 08:42:03 -04:00
Drew DeVault 3686724c9e
Merge pull request #2531 from RyanDwyer/maybe-fix-transaction-crash
Don't use bitfield to test for similar transactions
2018-08-29 08:40:13 -04:00
Ian Fan 79899064b6 commands: fix exec quoting 2018-08-29 10:55:12 +01:00
Brian Ashworth 5f6dcffe47
Merge pull request #2536 from RyanDwyer/fix-nested-tabs
Fix rendering of nested tabs
2018-08-29 00:47:46 -04:00
Ryan Dwyer 3c4196b986 Fix rendering of nested tabs
The C_CONTAINER check needs to apply to C_VIEW as well.
2018-08-29 14:38:51 +10:00
Drew DeVault ed775103c8
Merge pull request #2535 from RyanDwyer/fix-reap-crash
Fix crash when reaping a workspace
2018-08-28 21:00:56 -04:00
Ryan Dwyer 2438f5f050 Fix crash when reaping a workspace
It wasn't returning the surviving container.
2018-08-29 10:51:54 +10:00
Drew DeVault 095ca75769
Merge pull request #2533 from RyanDwyer/fix-workspace-tabs
Fix workspace tabs
2018-08-28 20:49:14 -04:00
Ryan Dwyer 53fe7b02e9 Fix workspace tabs
When collecting focus to save into the transaction state, the workspace
needs to look in the tiling list only.

As seat_get_focus_inactive_tiling returns any descendant, the list also
needs to be traversed back up to the direct child of the workspace.

Fixes #2532
2018-08-29 10:38:46 +10:00
Ryan Dwyer b12f7be907 Don't use bitfield to test for similar transactions
When there's multiple transactions in the queue, sway can take a
shortcut by checking if they all operate on the same set of containers.
If they do, it can skip all but the last transaction. The way we tested
for transactions which used the same containers was to exclusive-or
their con IDs together, but this has proved not only to be ineffective
but also has the potential to make sway crash.

This patch replaces the exclusive-or with a loop and container
comparison.
2018-08-29 08:29:11 +10:00
Brian Ashworth 602ccca1a8
Merge pull request #2526 from ianyfan/commands
Fix moving container to inactive workspace on different output
2018-08-28 12:41:18 -04:00
Brian Ashworth 876b5147cf
Merge branch 'master' into commands 2018-08-28 12:32:22 -04:00
Drew DeVault 6143a64cda
Merge pull request #2528 from fokditkak/add-bulgarian-readme
Add bulgarian readme
2018-08-28 10:58:37 -04:00
Martin Kalchev 5f2ebe0dd5 added ref to bulgarian translation 2018-08-28 17:12:38 +03:00
Ian Fan bc30f2d528 commands: fix moving container to different output
When moving a container to an inactive workspace on a different output, this will change the focus on the destination output back to its last active workspace
2018-08-28 15:08:46 +01:00
Martin Kalchev 15f709b155 spellcheck and help add. 2018-08-28 17:06:15 +03:00
Drew DeVault 83230435f7
Merge pull request #2511 from RyanDwyer/refactor-arrange
Prepare arrange code for type safe arguments
2018-08-28 10:03:52 -04:00
Ryan Dwyer 126a82f14f Fix gaps issues
* In layout command, arrange parent of parent - not sure why this is
needed but it is
* Remove gap adjustment when rendering
* Workspace should use outer gaps, not inner
* Add exceptions for tabbed and stacked containers
* Don't mess with gap state when splitting a container
2018-08-28 23:53:51 +10:00
Ryan Dwyer f5b9815128 Prepare arrange code for type safe arguments
This commit changes the arrange code in a way that will support type
safe arguments.

The arrange_output et al functions are now public, however I opted not
to use them directly yet. I've kept the generic arrange_windows there
for convenience until type safety is fully implemented. This means this
patch has much less risk of breaking things as it would otherwise.

To be type safe, arrange_children_of cannot exist in its previous form
because the thing passed to it could be either a workspace or a
container. So it's now renamed to arrange_children and accepts a list_t,
as well as the parent layout and parent's box.

There was some code which checked the grandparent's layout to see if it
was tabbed or stacked and adjusted the Y offset of the grandchild
accordingly. Accessing the grandparent layout isn't easy when using type
safe arguments, and it seemed odd to even need to do this. I determined
that this was needed because a child of a tabbed container would have a
swayc Y matching the top of the tab bar. I've changed this so a child of
a tabbed container will have a swayc Y matching the bottom of the tab
bar, which means we don't need to access the grandparent layout.  Some
tweaks to the rendering and autoconfigure code have been made to
implement this, and the container_at code appears to work without
needing any changes.

arrange_children_of (now arrange_children) would check if the parent had
gaps and would copy them to the child, effectively making the
workspace's gaps recurse into all children. We can't do this any more
without passing has_gaps, gaps_inner and gaps_outer as arguments to
arrange_children, so I've changed the add_gaps function to retrieve it
from the workspace directly.

apply_tabbed_or_stacked_layout has been split into two functions, as it
had different logic depending on the layout.

Lastly, arrange.h had an unnecessary include of transaction.h. I've
removed it, which means I've had to add it to several other files.
2018-08-28 23:50:41 +10:00
Martin Kalchev da0ffa3b20 initial commit 2018-08-28 16:16:37 +03:00
Drew DeVault 98ef29c228
Merge pull request #2523 from RedSoxFan/fix-floating-drag-outputs
Stop floaters from snapping on move to new output
2018-08-27 13:44:08 -04:00
Drew DeVault 82423b88b8
Merge pull request #2494 from RyanDwyer/fix-overflowing-subsurfaces
Allow subsurfaces which overflow the container to be interacted with
2018-08-27 12:41:39 -04:00
Drew DeVault 9d9de97c4c
Merge pull request #2520 from RedSoxFan/destroy-empty-ws-on-evac
Destroy empty workspaces in output_evacuate
2018-08-27 12:32:29 -04:00
Drew DeVault efcaee190e
Merge pull request #2519 from ianyfan/set-focus-cleanup
seat.c: clean-up seat_set_focus_warp function
2018-08-27 12:30:26 -04:00
Ian Fan 3bf849d993 seat.c: clean-up seat_set_focus_warp function 2018-08-27 13:25:01 +01:00
Drew DeVault fed6976840
Merge pull request #2522 from ascent12/build_fix
Build fix
2018-08-27 08:16:25 -04:00
Brian Ashworth 11c1619f30 Stop floaters from snapping on move to new output 2018-08-27 03:06:37 -04:00
Scott Anderson 31c3c8a365 Initialise variable properly 2018-08-27 18:01:17 +12:00
Scott Anderson ff86dc0c35 Hide deprecated wayland functions 2018-08-27 18:01:00 +12:00
Brian Ashworth 148b113b8d Destroy empty workspaces in output_evacuate 2018-08-27 00:18:20 -04:00
Brian Ashworth d6a5dfc913
Merge pull request #2518 from ianyfan/ipc
Emit window close event earlier, before destroying
2018-08-26 21:59:38 -04:00
Ian Fan 6ae2e3a4a8 ipc: clean-up container_create_notify function 2018-08-26 19:01:09 +01:00
Ian Fan e7c94708f2 ipc: emit window close event earlier, before destroying 2018-08-26 19:01:09 +01:00
Drew DeVault 6afc0590a1
Merge pull request #2517 from fokditkak/add_fish_completion
Add fish completion
2018-08-26 13:55:08 -04:00
Martin Kalchev f3c18336d2 added fish to meson.build 2018-08-26 19:27:18 +03:00
Martin Kalchev 4f57c3da0e added untested files 2018-08-26 18:53:51 +03: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
Drew DeVault df7083a2d0
Merge pull request #2515 from RyanDwyer/remove-layout-file
Remove layout.c
2018-08-26 10:49:49 -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
Drew DeVault 1a30c50ef4
Merge pull request #2488 from RyanDwyer/separate-gaps-functions
Make separate gaps functions per container type
2018-08-25 20:07:37 -04:00
Ryan Dwyer 8bed4be1f3 Make separate gaps functions per container type
In preparation for using type safety.
2018-08-26 09:52:12 +10:00
Brian Ashworth ed147aed30
Merge pull request #2512 from apreiml/workspace_move_wrap
Workspace move cycle
2018-08-25 11:19:17 -04:00
Armin Preiml 1a72149d88 Workspace move cycle
On move workspace to direction: Try the farthest on the opposite
direction if no workspace is found at given direction.
2018-08-25 17:10:41 +02:00
Ryan Dwyer 1e024b91fa Add comment for sway_root.all_outputs 2018-08-25 23:42:04 +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
Drew DeVault b945957b9b
Merge pull request #2510 from RyanDwyer/relocate-layout-functions
Relocate container_move, container_move_to and container_get_in_direction
2018-08-25 09:38:33 -04:00
Ryan Dwyer 33d1022650
Merge pull request #2495 from ianyfan/commands
commands: implement move absolute
2018-08-25 13:24:12 +10:00
Ryan Dwyer 4b9ad9c238
Merge branch 'master' into commands 2018-08-25 13:06:04 +10:00
Ryan Dwyer f4bc25bcc6 Relocate container_move, container_move_to and container_get_in_direction
* container_move is only called from the move command
* container_move_to was called from both the move command and the sticky
command, but the sticky command can easily not call it
* container_get_in_direction is only called from the focus command

Moving these functions to their respective commands gives better
separation of code and removes bloat from layout.c. These functions will
need to be refactored to take advantage of type safety, so separating
them will make this easier to refactor.

The following static functions have also been moved:

* is_parellel
* invert_movement
* move_offs
* container_limit
* workspace_rejigger
* move_out_of_tabs_stacks
* get_swayc_in_output_direction

They were all used by the move functions, except for the last one which
is used by focus.

Other changes:

* index_child has been renamed to container_sibling_index, moved to
container.c and made public
* sway_output_from_wlr has been renamed to output_from_wlr_output, moved
to output.c and made public
* container_handle_fullscreen_reparent has been made public
* sway_dir_to_wlr has been made public

No changes have been made to any of the moved functions, other than
updating calls to functions that have been renamed.
2018-08-25 12:09:42 +10:00
Drew DeVault e86d99acd6
Merge pull request #2499 from RyanDwyer/refactor-destroy-functions
Refactor destroy functions and save workspaces when there's no outputs
2018-08-24 08:27:05 -04: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
emersion f53c28d52a
Merge pull request #2470 from ianyfan/completions
[WIP?] Fix zsh completions
2018-08-22 09:35:17 +01:00
emersion a81c148e25
Merge pull request #2507 from RyanDwyer/move-workspace-translate-floating
Translate floating containers when a workspace is moved
2018-08-22 09:34:27 +01:00
emersion 8232cbf00f
Merge pull request #2506 from vilhalmer/ipc-get_tree-return-app_id-and-class
Add app_id and class to get_tree output
2018-08-22 09:32:12 +01:00
Ryan Dwyer e1d5dc0804 Translate floating containers when a workspace is moved
When a workspace is moved to another output, or the output it's on
changes its global layout position, the floating containers on that
workspace should be translated by the same amount as the workspace. This
keeps the floating containers in the same position relative to the
workspace.

A check is done to make sure the floating container's center point isn't
being moved off screen. If it is, it is centered within the workspace.

Fixes part of #2500.
2018-08-22 17:46:12 +10:00
vilhalmer 03718aaebb
Add app_id and class to get_tree output 2018-08-21 20:51:01 -04:00
Drew DeVault ce12d912dc
Merge pull request #2505 from RyanDwyer/fix-set-fullscreen
Fix sending fullscreen event to view
2018-08-21 18:46:23 -04:00
Ryan Dwyer e81c26fab9 Fix sending fullscreen event to view
Fixes #2504
2018-08-22 08:23:29 +10:00
Brian Ashworth 395ff7a541
Merge pull request #2503 from RyanDwyer/use-wlr-edges
Replace enum resize_edge with wlr_edges
2018-08-20 22:56:43 -04:00
Ryan Dwyer f129b1b89f Replace enum resize_edge with wlr_edges 2018-08-21 12:41:57 +10:00
Drew DeVault 389610795b
Merge pull request #2502 from minus7/workspace-names
Improve new workspace name selection
2018-08-20 19:22:44 -04:00
minus 471533be0a Improve new workspace name selection
Improves upon 18e425ed by using the first assigned workspace instead of
the last one. The order isn't explicitly guaranteed to be the same as in
the config, but in general works.
2018-08-20 23:17:07 +02:00
Drew DeVault 99631c5050
Merge pull request #2501 from RedSoxFan/fix-bad-free-swaynag
Fix bad-free in swaynag
2018-08-20 15:21:34 -04:00
Brian Ashworth f0d21c46dd Fix bad-free in swaynag 2018-08-20 15:06:12 -04:00
Ian Fan f51b9478f2 commands: implement move absolute 2018-08-20 10:17:32 +01:00
emersion 881f729af9
Merge pull request #2498 from RyanDwyer/fix-jumping-views
Fix jumping views
2018-08-20 08:17:16 +01:00
Ryan Dwyer 771ad7bffa Fix jumping views
Fixes #2490.

To be honest I'm not sure why this fixes the issue.

I observed that I could only make the view jump if I resized it to the
smallest possible size first. Then I had a suspicion that we were
accidentally factoring in the title and border sizes into the view size
when it uses CSD. So I changed that and it appears to have fixed the
jumping issue.

I guess when we factor the title and borders in, we send a configure to
the surface with a size smaller than the minimum, and it comes back with
a surface at the minimum size. We interpret this as an unexpected
resize, and this somehow makes it jump.
2018-08-20 13:24:57 +10:00
Drew DeVault 08a69f267a
Merge pull request #2483 from RyanDwyer/floating-emit-reparent
Send enter/leave events for floating views
2018-08-19 22:06:09 -04:00
Drew DeVault fdcf9275b1
Merge pull request #2496 from RyanDwyer/fix-transaction-crash
Fix crash when a view destroys with pending transactions
2018-08-19 22:03:57 -04:00
Ryan Dwyer e1955c5c08 Fix crash when adding output 2018-08-20 10:37:52 +10:00
Ryan Dwyer a49e4b13bf Clean up tracked outputs when an output is destroyed 2018-08-20 09:23:34 +10:00
Ryan Dwyer 0f6d212629 Send output enter/leave events correctly
Previously we used a reparent event to detect when a view changes
parent, then sent an output enter/leave to the surfaces if needed. This
worked for tiling views but not floating views, as floating views can
intersect another output without changing parent.

The solution implemented for floating views also applies cleanly to
tiling views, so the previous method has been completely replaced and
the reparent event has been removed.

This introduces a new function container_discover_outputs. This function
compares the container's `current` position to the outputs, sends enter
and leave events as needed, and keeps track of which outputs it's
intersecting in a new `container->outputs` list. If it has entered a new
output with a different scale then the title and marks textures will
also be recreated at the new scale.

The function is called when a transaction applies. This is convenient as
it means we don't have to call it from various places.

There is imperfect rendering when a floating view overlaps two outputs
with different scales. It renders correctly for the most recently
entered output, but there is only one title texture so it renders
incorrectly on the old output.

Fixes #2482
2018-08-20 09:23:24 +10:00
Ryan Dwyer b3e2c49774 Fix crash when a view destroys with pending transactions
We were removing the saved buffer when one transaction applies, then
didn't have a new buffer to save when the next transaction ran. This
made the rendering code crash as it had no surface to use.

This commit makes it continue to hold the buffer if the view is
destroying and has more transactions. Additionally, a check is added
when saving the buffer to make sure there's no one already there.
2018-08-20 09:04:04 +10:00
emersion 8db6c68db6
Merge pull request #2493 from RyanDwyer/fix-popup-position
Fix popup position when parent uses geometry
2018-08-19 21:51:53 +01:00
Drew DeVault 9f913614ca
Merge pull request #2478 from RyanDwyer/standardise-debug
Standardise debug variables
2018-08-19 10:29:29 -04:00
Ryan Dwyer 4afb2e3f24 Allow subsurfaces which overflow the container to be interacted with
Fixes #2492.
2018-08-19 21:50:33 +10:00
Ryan Dwyer 76bdb21ca9 Fix popup position when parent uses geometry
Fixes #2489.
2018-08-19 21:09:39 +10:00
emersion 2c91afbb34
Merge pull request #2487 from RyanDwyer/workspace-floating-list
Replace hacky L_FLOATING container with a list
2018-08-19 09:21:55 +01: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
Ryan Dwyer f9563d88f3 Use enum for damage debug options 2018-08-19 16:17:24 +10:00
Ryan Dwyer 8d1dd03823 Standardise debug variables
This makes all debug options stored in a single struct rather than in
various places, changes/fixes the behaviour of existing options, and
introduces some new options.

* Fixes damage issues with `-Drender-tree` texture (by removing scissor)
* Offsets the render tree overlay's `y` position for those who have
swaybar at the top
* Replaces `-Ddamage=rerender` with `-Dnodamage`
* Replaces `-Ddamage=highlight` with `-Dhighlight-damage`
* Replaces `-Dtxn-debug` with `-Dtxn-wait`
* Introduces `-Dnoatomic`
* Removes the `create_time` and `ms_arranging` figures from transactions
and the log message. Transactions are created after arranging and the
create time is of no significance.
* Fixes `-Dtxn-debug` (now `-Dtxn-wait`) not working.
2018-08-19 16:17:24 +10:00
Ryan Dwyer 389d159c81
Merge pull request #2453 from ianyfan/commands
More commands
2018-08-19 16:16:32 +10:00
Ryan Dwyer 7f22fab389
Merge branch 'master' into commands 2018-08-19 16:07:11 +10:00
Drew DeVault d0a24465d7
Merge pull request #2466 from RyanDwyer/geometry
Fix geometry
2018-08-18 19:26:36 -04:00
Ryan Dwyer 373f0254a8
Merge pull request #2484 from ianyfan/con-for-each-child-fix
Fix double iterating in container_for_each_child
2018-08-19 08:59:00 +10:00
Ian Fan 37e37627ca commands: move newly-stickied containers to focused workspace 2018-08-18 18:29:18 +01:00
Ian Fan 1be75fe740 Fix double iterating in container_for_each_child 2018-08-18 18:10:41 +01:00
Ian Fan b3f7801fca commands: prevent focusing mode with no containers
Explicitly fail when trying to focus tiling/floating when there are no tiling/floating containers.
2018-08-18 17:25:06 +01:00
Ian Fan 23601a8771 commands: complete assign command 2018-08-18 17:25:06 +01:00
Ian Fan e81cc8a575 commands: saner workspace number handling 2018-08-18 17:25:06 +01:00
Ian Fan 69e00151bb commands: handle quoted exec command 2018-08-18 15:50:26 +01:00
Ian Fan 453646b887 commands: fix documentation formatting mistakes for move command 2018-08-18 15:50:26 +01:00
Ian Fan 7717c2231a commands: require set variable to start with $ 2018-08-18 15:50:26 +01:00
Ian Fan c1af79532f commands: add nop 2018-08-18 15:50:26 +01:00
Drew DeVault 744724b3cb
Merge pull request #2473 from RyanDwyer/iterators-per-type
Implement iterators per container type
2018-08-18 10:29:46 -04: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
Drew DeVault d4a32800d5
Merge pull request #2460 from RyanDwyer/implement-mousedown
Implement mousedown operation
2018-08-18 09:32:04 -04:00
Drew DeVault 5c779c11f6
Merge pull request #2481 from RyanDwyer/rename-functions
Rename container_sort_workspaces and container_wrap_children
2018-08-18 09:30:13 -04:00
Ryan Dwyer 16c663ed49 Rename container_sort_workspaces and container_wrap_children
This commit renames container_sort_workspaces to output_sort_workspaces
and moves it to output.c.

This also renames container_wrap_children to workspace_wrap_children and
moves it to workspace.c. This function is only called with workspaces.
2018-08-18 22:02:03 +10:00
emersion cfe205b36f
Merge pull request #2480 from RyanDwyer/fix-mod-resize
Fix mod+resize
2018-08-18 09:15:30 +01: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 ce78f6770e Fix nitpick 2018-08-18 15:11:46 +10:00
Ryan Dwyer b0a5f3a25f Store geometry in the view and handle any floating view resizing 2018-08-18 15:10:06 +10:00
Ryan Dwyer 4e755c4b12 Set current size when a floating xwayland view resizes
This avoids sending an unnecessary configure.
2018-08-18 10:39:38 +10:00
Ryan Dwyer 8af4e2e3e6 Handle xwayland views sending new sizes in their commits 2018-08-18 10:39:38 +10:00
Ryan Dwyer 9ee89f11c4 Add get_geometry for xdg_shell_v6 2018-08-18 10:39:38 +10:00
Ryan Dwyer 8034c25426 Render saved buffer using saved geometry 2018-08-18 10:39:38 +10:00
Ryan Dwyer 982a2d0c99 Fix geometry 2018-08-18 10:39:38 +10:00
emersion b3ee9af0c8 Add view_get_geometry 2018-08-18 10:39:38 +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
Drew DeVault db4b4935b3
Merge pull request #2472 from RyanDwyer/refactor-seat-get-focus
Refactor seat_get_focus functions
2018-08-17 09:53:28 -04:00
emersion 754bbd03c0
Merge pull request #2471 from RyanDwyer/reap-when-floating
Attempt to reap old tiling parent when floating a container
2018-08-17 13:37:39 +01:00
emersion 782d0e087e
Merge pull request #2474 from RyanDwyer/transactionise-csd
Add using_csd variable to transaction state
2018-08-17 13:33:21 +01:00
Ryan Dwyer 1801b725e2 Add using_csd variable to transaction state
This fixes a race condition flicker when unfloating a view which uses
client side decorations.

When the view is floated it has using_csd = true, so the decorations are
not drawn. When unfloating it it changes to false, but this change
wasn't part of transactions so it could potentially render the
decorations around the view while it's waiting for the transaction to
apply.
2018-08-17 20:25:33 +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 6a26b499a4 Attempt to reap old tiling parent when floating a container 2018-08-17 16:23:37 +10:00
Ryan Dwyer 32193c7e4d
Merge pull request #2465 from DonnieWest/master
Default to the previous workspace if the current one has no focused windows
2018-08-17 10:04:03 +10:00
Donnie West a9433cbded
When the workspace is focused, return it instead of checking parent 2018-08-16 18:52:40 -05:00
Ian Fan 1fd62d3e0c Fix swaylock zsh completions 2018-08-16 23:21:30 +01:00
Drew DeVault 98ed05225e
Merge pull request #2458 from RyanDwyer/cleanup-transactions
Simplify transactions
2018-08-15 17:16:32 -04:00
emersion 647ace1d6d
Merge pull request #2459 from RyanDwyer/fix-workspace-prev-next
Use list_find in more places and refactor/fix workspace prev_next functions
2018-08-15 22:11:34 +01:00
Ryan Dwyer 701fcafc70 Use list_find in more places and refactor/fix workspace prev_next functions
The original purpose of this commit is to replace some for loops with
list_find. But while doing this I found the workspace_prev_next_impl
functions to be difficult to read and also contained a bug, so I
refactored them and fixed the bug.

To reproduce the bug:

* Have two outputs, where the left output has workspaces 1, 2, 3 and the
right output has workspaces 4, 5, 6. Make workspace 2 focused_inactive
and workspace 4 focused.
* Run `workspace prev`.
* Previously it would visit the left output, then apply `workspace prev`
to workspace 2, which focuses workspace 1.
* Now it will focus the rightmost workspace on the left output
(workspace 3).

The refactoring I made to the workspace functions are:

* Added the static keyword.
* They now accept an int dir rather than bool, to avoid an unnecessary
conversion.
* Rather than preparing start and end variables for the purpose of
iterating, just iterate everything.
* Replace for loops with list_find.
* Don't call workspace_output_prev_next_impl (this fixes the bug).
2018-08-15 15:14:35 +10:00
Ryan Dwyer c3ef36d6b5 Simplify transactions
Commit 4b8e3a885b makes it so only one
transaction is committed (ie. configures sent) at a time. This commit
removes the now-unnecessary code which was used to support concurrent
committed transactions.

* Instead of containers storing a list of instructions which they've
been sent, it now stores a single instruction.
* Containers now have an ntxnrefs property. Previously we knew how many
references there were by the length of the instruction list.
* Instructions no longer need a ready property. It was used to avoid
marking an instruction ready twice when they were in a list, but this is
now avoided because there is only one instruction and we nullify the
container->instruction pointer when it's ready.
* When a transaction applies, we no longer need to consider releasing
and resaving the surface, as we know there are no other committed
transactions.
* transaction_notify_view_ready has been renamed to
view_notify_view_ready_by_serial to make it consistent with
transaction_notify_view_ready_by_size.
* Out-of-memory checks have been added when creating transactions and
instructions.
2018-08-15 10:03:55 +10:00
Drew DeVault b4887ba154
Merge pull request #2445 from RyanDwyer/resize-tiling-via-cursor
Implement resizing tiled containers via cursor
2018-08-14 09:07:59 -04:00
emersion d0fb2d9a53
Merge pull request #2454 from minus7/workspace-names
Use assigned workspace name for output
2018-08-13 22:17:38 +01:00
minus 18e425eda6 Use assigned workspace name for output
Instead of relying on bindings being configured, primarily source
new workspace names from workspace-output assignments.

Fixes #2435
2018-08-12 14:41:41 +02:00
Ryan Dwyer 4b8e3a885b Don't commit multiple transactions at the same time 2018-08-12 10:45:54 +10:00
Ryan Dwyer e7a7306063 Don't progress transaction queue if any are partially complete
This fixes an issue where views might commit to a transaction ahead of
the first one, and applying the first transaction causes us to save a
buffer of the wrong size.
2018-08-12 10:45:54 +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
Drew DeVault 146cc0a441
Merge pull request #2452 from janza/position-command-fix-args
Man page: Correct argument format for output position config
2018-08-11 19:08:01 -04:00
Josip Janzic 5aca2b42e6
man: Correct format for output position config 2018-08-11 18:41:31 +02:00
Drew DeVault b6428f4751
Merge pull request #2451 from RyanDwyer/fix-ancestor-crash
Fix container_has_ancestor crash
2018-08-11 10:28:05 -04:00
Ryan Dwyer 5f3757c927 Fix container_has_ancestor crash
Fixes #2450
2018-08-12 00:14:52 +10:00
Drew DeVault 2aa6d98c5a
Merge pull request #2449 from RyanDwyer/remove-bfs
Remove container_for_each_descendant_bfs
2018-08-11 08:29:34 -04:00
emersion 9545c70928
Merge pull request #2448 from RyanDwyer/remove-container-has-child
Remove container_has_child
2018-08-11 08:44:11 +01:00
Ryan Dwyer 4ad1ccc9dc Remove container_for_each_descendant_bfs
The function was not used.

Also renames container_for_each_descendant_dfs to just
container_for_each_descendant.
2018-08-11 15:57:09 +10:00
Ryan Dwyer 31844bf42b Remove container_has_child
In all cases you can use container_has_ancestor with the arguments
swapped, which is faster than container_has_child.
2018-08-11 15:36:19 +10:00
emersion e474d87e42
Merge pull request #2447 from ianyfan/swaynag-leak
Fix memory leak in swaynag
2018-08-10 18:53:18 +01:00
Ian Fan 6e7052fc44 swaynag: destroy old cursor theme when updated 2018-08-10 18:34:23 +01:00
Drew DeVault c7e99ee0d4
Merge pull request #2446 from emersion/xwayland-unmanaged-order
xwayland: fix unmanaged surfaces order
2018-08-10 09:46:08 -04:00
emersion d1433c637a xwayland: fix unmanaged surfaces order 2018-08-10 12:47:24 +01:00
Brian Ashworth df1aeed6c2
Merge pull request #2441 from RyanDwyer/finish-resize-commands
Finish resize commands
2018-08-09 20:04:33 -04:00
Ryan Dwyer af693cba26 Update resize documentation 2018-08-10 08:50:38 +10:00
Ryan Dwyer 6c730a2cb2 Implement resize set <width> <height> for tiled containers
Unlike i3, this implementation allows px measurements.

Also fixes a sane size check.
2018-08-10 08:50:15 +10:00
Ryan Dwyer 9395d3c93c Implement resize grow|shrink <direction> <amount> for tiled containers 2018-08-10 08:50:15 +10:00
Drew DeVault db0fa066e5 Remove obsolete security sanity check 2018-08-09 08:45:32 -04:00
Drew DeVault 425ee270b4
Merge pull request #2440 from RedSoxFan/bg-swaynag-reading-only
Don't call swaynag_log for bg when not reading
2018-08-08 17:21:22 -04:00
Brian Ashworth b6f4623551 Don't call swaynag_log for bg when not reading 2018-08-08 17:04:12 -04:00
Drew DeVault 78c0f013dd
Merge pull request #2439 from RedSoxFan/fix-2434
Allow a fallback color to be specified for swaybg
2018-08-08 16:42:33 -04: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
Brian Ashworth fc039f0759
Merge pull request #2423 from manio/master
[RFC] Fix segv when sway is terminating
2018-08-08 15:36:17 -04:00
Brian Ashworth 3c26536267
Merge branch 'master' into master 2018-08-08 15:26:44 -04:00
Drew DeVault e28101e6e1 私の日本語が上手じゃないですね 2018-08-08 11:53:11 -04:00
Drew DeVault 1c7a6a49b6 Remove setcap instructions
These are obsolete, we don't require them anymore.
2018-08-08 11:40:33 -04:00
emersion 89e176d3fb
Merge pull request #2436 from RyanDwyer/fix-floating-deco-focus
Fix focus when clicking floating decorations
2018-08-08 13:49:00 +01: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 a0ece6f956 Rename container_at_view to surface_at_view and make it return void 2018-08-08 22:28:13 +10:00
Ryan Dwyer 1e984fec05 Fix focus when clicking floating decorations
It's not right for container_at_view to only return the swayc if a
surface was clicked.
2018-08-08 22:28:13 +10:00
Drew DeVault c8a8216629
Merge pull request #2420 from RyanDwyer/floating-move-to-workspace
Implement move to workspace on a floating container
2018-08-08 08:13:22 -04:00
Ryan Dwyer 5653fc754b Deny moving a sticky container to workspace if it's the same output
Rationale: Sticky containers are always assigned to the visible
workspace.

The basic idea here is to check the destination's output (move.c:190).
But if the command was `move container to workspace x` then a workspace
might have been created for it. We could destroy the workspace in this
case, but that results in unnecessary IPC events.

To avoid this, the logic for `move container to workspace x` has been
adjusted. It now delays creating the workspace until the end, and uses
`workspace_get_initial_output` to determine and check the output before
creating it.
2018-08-08 12:50:42 +10:00
Ryan Dwyer a0649190de Fix edge cases when moving floating container to new workspace
* Removes container_floating_move_to_container, instead opting to put
that logic in container_move_to
* In the seat code, focusing a floating view now updates the pending
state only and lets the next transaction carry it over to the current
state. This is required, otherwise it would crash.
* When unfullscreening a floating container, an output check is now done
to see if it should center it.
2018-08-08 08:48:20 +10:00
Ryan Dwyer 36281609ea Implement move to workspace on a floating container
Also adjusts container_floating_translate to not change the current
properties directly.
2018-08-08 08:48:20 +10:00
Drew DeVault 6f0bc469e9
Merge pull request #2432 from RyanDwyer/fix-move-crash
Fix crash when running `move container to workspace back_and_forth`
2018-08-07 10:27:45 -04:00
Drew DeVault 84845adb8e
Merge pull request #2433 from RyanDwyer/fix-sticky-infinite-loop
Fix infinite loop when focusing sticky containers via workspace command
2018-08-07 10:27:25 -04:00
Ryan Dwyer 50f3a7ff5c Fix infinite loop when focusing sticky containers via workspace command
In a multi-output setup, if a sticky container is on one output and
focus is on the other output, and you run (eg) `workspace 1` to focus
the workspace containing the sticky container, an infinite loop would
occur. It would loop infinitely because it would remove the sticky
container from the workspace, add it back to the same workspace, and
then decrement the iterator variable.

The fix just wraps the loop in a workspace comparison.
2018-08-07 23:32:25 +10:00
Ryan Dwyer 5ac6f2f429 Fix crash when running `move container to workspace back_and_forth`
The back_and_forth condition is intended to be handled in the else-if
block, but this was never reached because it remained in the first
block's conditions.
2018-08-07 23:04:21 +10:00
Drew DeVault 1818c58e40
Merge pull request #2430 from ianyfan/socketpath-leaks
Fix memory leaks in get_socketpath
2018-08-06 14:08:51 -04:00
Ian Fan baf4604629 ipc-client: fix memory leaks in get_socketpath 2018-08-06 17:30:24 +01:00
Brian Ashworth 17f557298e
Merge pull request #2428 from RyanDwyer/workspace-move-to-output
Move workspace moving code out of container_move_to
2018-08-06 11:55:08 -04:00
Brian Ashworth 639f3368e1
Merge branch 'master' into workspace-move-to-output 2018-08-06 11:47:00 -04:00
Drew DeVault d8b65193c4
Merge pull request #2268 from emersion/server-decoration-borders
Enable borders on floating SSD xdg-shell views
2018-08-06 11:32:17 -04:00
Drew DeVault 1a8bee68b4
Merge pull request #2392 from ianyfan/commands
Fix commands: criteria, layout, move, workspace
2018-08-06 11:30:14 -04:00
emersion d2ac48f920 Handle views created after decoration mode is sent for xdg-shell-v6 2018-08-06 15:28:33 +01:00
emersion 9d578e0a0f Handle views created after decoration mode is sent for xdg-shell 2018-08-06 15:20:30 +01:00
emersion 700941dde8 Listen to server-decoration mode changes 2018-08-06 15:20:30 +01:00
Ryan Dwyer f57a3919cf Move workspace moving code out of container_move_to
container_move_to handled moving containers to new parents, as well as
moving workspaces to new outputs.

This commit removes the workspace-moving code from this function and
introduces workspace_move_to_output. Moving workspaces using
container_move_to only happened from the move command, so it's been
implemented as a static function in that file.

Simplifying container_move_to makes it easier for me to fix some issues
in #2420.
2018-08-07 00:03:01 +10:00
Ian Fan f7c21451df commands: fix workspace edge cases 2018-08-06 14:17:58 +01:00
Ian Fan 667b8dcb67 commands: check for special workspaces in workspace & move commands 2018-08-06 14:17:58 +01:00
Ian Fan 3b1f58e135 commands: document <criteria> focus 2018-08-06 14:17:58 +01:00
Ian Fan dd48c8a579 commands: add optional flags to move 2018-08-06 14:17:58 +01:00
Ian Fan 85ae121caa commands: complete workspace implementation
Allow optional --no-auto-back-and-forth flag, as well as refactoring some logic
2018-08-06 14:17:58 +01:00
Ian Fan 356063b6c0 commands: fix layout implementation (also better name for previous split layout) 2018-08-06 14:17:58 +01:00
Ian Fan 3a980857cb commands: better type for con_id string length 2018-08-06 14:17:58 +01:00
Ian Fan 69e1a421fc commands: complete move implementation 2018-08-06 14:17:58 +01:00
Ian Fan be64c46624 commands: complete layout implementation 2018-08-06 14:17:58 +01:00
Ian Fan 11ac66d6fe commands: allow __focused__ for con_id criterion 2018-08-06 14:17:58 +01:00
Ian Fan 710f27d0d2 commands: allow "first", "last", "newest" and "recent" as values for urgent criteria 2018-08-06 14:17:45 +01:00
Mariusz Bialonczyk 776b9b7e1f Fix segv when sway is terminating
I've got the following SIGSEGV when terminating sway:
```
Program terminated with signal SIGSEGV, Segmentation fault.
0x00005607dc603af5 in view_unmap (view=0x5607dcb3d350) at ../sway/tree/view.c:599
599		if (surviving_ancestor->type >= C_WORKSPACE) {
```
surviving_ancestor was NULL at that time

This commit is trying to fix this problem.
2018-08-05 17:04:20 +02:00
417 changed files with 42997 additions and 21122 deletions

56
.builds/alpine.yml Normal file
View File

@ -0,0 +1,56 @@
image: alpine/edge
packages:
- cairo-dev
- eudev-dev
- gdk-pixbuf-dev
- json-c-dev
- lcms2-dev
- libdisplay-info-dev
- libevdev-dev
- libinput-dev
- libseat-dev
- libxcb-dev
- libxkbcommon-dev
- mesa-dev
- meson
- pango-dev
- pcre2-dev
- pixman-dev
- scdoc
- wayland-dev
- wayland-protocols
- xcb-util-image-dev
- xcb-util-wm-dev
- xwayland-dev
- hwdata-dev
sources:
- https://github.com/swaywm/sway
- https://gitlab.freedesktop.org/wlroots/wlroots.git
tasks:
- wlroots: |
cd wlroots
meson --prefix=/usr build -Dexamples=false
ninja -C build
sudo ninja -C build install
- setup: |
cd sway
meson build --fatal-meson-warnings -Dauto_features=enabled -Dtray=disabled
- build: |
cd sway
ninja -C build
- build-no-xwayland: |
cd wlroots
meson configure build -Dxwayland=disabled
ninja -C build
sudo ninja -C build install
cd ../sway
meson configure build --clearcache
ninja -C build
- build-static: |
cd sway
mkdir subprojects
ln -s ../../wlroots subprojects/wlroots
rm -rf build
meson build --fatal-meson-warnings --default-library=static --force-fallback-for=wlroots
ninja -C build

View File

@ -1,30 +1,37 @@
# vim: ft=yaml ts=2 sw=2 et :
image: archlinux
packages:
- meson
- xorg-server-xwayland
- xcb-util-image
- json-c
- pango
- cairo
- gdk-pixbuf2
- json-c
- lcms2
- libdisplay-info
- libegl
- libinput
- libxcb
- libxkbcommon
- meson
- pango
- pcre2
- scdoc
- wayland
- wayland-protocols
- gdk-pixbuf2
- libinput
- libxkbcommon
- scdoc
- xcb-util-image
- xcb-util-wm
- xorg-xwayland
- seatd
- hwdata
sources:
- https://github.com/swaywm/sway
- https://github.com/swaywm/wlroots
- https://gitlab.freedesktop.org/wlroots/wlroots.git
tasks:
- wlroots: |
cd wlroots
meson --prefix=/usr build
meson --prefix=/usr build -Dexamples=false
ninja -C build
sudo ninja -C build install
- setup: |
cd sway
meson build
meson build --fatal-meson-warnings -Dauto_features=enabled -Dsd-bus-provider=libsystemd
- build: |
cd sway
ninja -C build

45
.builds/freebsd.yml Normal file
View File

@ -0,0 +1,45 @@
image: freebsd/latest
packages:
- devel/basu
- devel/json-c
- devel/libevdev
- devel/meson
- devel/pcre2
- devel/pkgconf
- graphics/cairo
- graphics/gdk-pixbuf2
- graphics/lcms2
- graphics/wayland
- graphics/wayland-protocols
- textproc/scdoc
- x11-toolkits/pango
- x11/libxcb
- x11/libxkbcommon
# wlroots dependencies
- devel/evdev-proto
- devel/libepoll-shim
- devel/libudev-devd
- graphics/libdrm
- graphics/mesa-libs
- sysutils/libdisplay-info
- sysutils/seatd
- x11/libinput
- x11/libX11
- x11/pixman
- x11/xcb-util-wm
- x11-servers/xwayland-devel
- misc/hwdata
sources:
- https://github.com/swaywm/sway
- https://gitlab.freedesktop.org/wlroots/wlroots.git
tasks:
- setup: |
cd sway
mkdir subprojects
cd subprojects
ln -s ../../wlroots wlroots
cd ..
meson build --fatal-meson-warnings -Dtray=enabled -Dsd-bus-provider=basu
- build: |
cd sway
ninja -C build

View File

@ -1,16 +0,0 @@
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Always
BreakBeforeBraces: Attach
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
SortIncludes: false
ColumnLimit: 80
AlignAfterOpenBracket: DontAlign
BinPackParameters: false
BinPackArguments: false
ContinuationIndentWidth: 8
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortLoopsOnASingleLine: true
ReflowComments: false

35
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,35 @@
---
name: Bugs
about: Crashes and other bugs
labels: 'bug'
---
### Please read the following before submitting:
- Please do NOT submit bug reports for questions. Ask questions on IRC at #sway on Libera Chat.
- Proprietary graphics drivers, including nvidia, are not supported. Please use the open source equivalents, such as nouveau, if you would like to use Sway.
- Please do NOT submit issues for information from the github wiki. The github wiki is community maintained and therefore may contain outdated information, scripts that don't work or obsolete workarounds.
If you fix a script or find outdated information, don't hesitate to adjust the wiki page.
### Please fill out the following:
- **Sway Version:**
- `swaymsg -t get_version` or `sway -v`
- **Debug Log:**
- Run `sway -d 2> ~/sway.log` from a TTY and upload it to a pastebin, such as gist.github.com.
- This will record information about sway's activity. Please try to keep the reproduction as brief as possible and exit sway.
- Attach the **full** file, do not truncate it.
- **Configuration File:**
- Please try to produce with the default configuration.
- If you cannot reproduce with the default configuration, please try to find the minimal configuration to reproduce.
- Upload the config to a pastebin such as gist.github.com.
- **Stack Trace:**
- This is only needed if sway crashes.
- If you use systemd, you should be able to open the coredump of the most recent crash with gdb with
`coredumpctl gdb sway` and then `bt full` to obtain the stack trace.
- If the lines mentioning sway or wlroots have `??` for the location, your binaries were built without debug symbols. Please compile both sway and wlroots from source and try to reproduce.
- **Description:**
- The steps you took in plain English to reproduce the problem.

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Questions
url: "https://libera.chat"
about: "Please ask questions on IRC in #sway on Libera Chat"

13
.github/ISSUE_TEMPLATE/enhancement.md vendored Normal file
View File

@ -0,0 +1,13 @@
---
name: Enhancements
about: New functionality
labels: 'enhancement'
---
### Please read the following before submitting:
- We are not accepting any new window management features unless they get implemented by i3.
### Please fill out the following:
- **Description:**
Please describe in plain English what the enhancement is and what the use case is.

20
.github/ISSUE_TEMPLATE/i3_compat.md vendored Normal file
View File

@ -0,0 +1,20 @@
---
name: i3 Compatibility
about: Sway behaves differently from or lacks i3 functionality
labels: 'i3-compat'
---
### Please read the following before submitting:
- The following either do not make sense for Wayland or we have decided against supporting:
- `restart`
- `resource`
- saving and loading layouts
- the i3 sync protocol
### Please fill out the following:
- **i3 PR:**
- If this is new i3 functionality, please add a link to the i3 pull request.
- **Description:**
- Please describe in plain English how Sway and i3's behaviors differ or what functionality Sway is lacking.

2
.gitignore vendored
View File

@ -5,6 +5,8 @@ install_manifest.txt
bin/
test/
build/
build-*/
.cache/
.lvimrc
config-debug
wayland-*-protocol.*

1
.mailmap Normal file
View File

@ -0,0 +1 @@
Ronan Pigott <ronan@rjp.ie> <rpigott@berkeley.edu>

View File

@ -1,30 +1,20 @@
# Contributing to sway
Contributing just involves sending a pull request. You will probably be more
successful with your contribution if you visit the [IRC
channel](http://webchat.freenode.net/?channels=sway-devel&uio=d4) upfront and discuss
your plans.
successful with your contribution if you visit #sway-devel on Libera Chat
upfront and discuss your plans.
## Release Cycle
Note: rules are made to be broken. Adjust or ignore any/all of these as you see
fit, but be prepared to justify it to your peers.
The master branch of sway is always working towards becoming the next release.
That release will go through each of these three stages:
## Scope of future changes to sway
**In development**: during this time the release lives in the master branch and
is considered unstable. All pull requests merged during this time will land in
the release. Only developers are encouraged to run this version.
**Release candidate**: at some point (usually when development is fairly quiet),
SirCmpwn will announce an upcoming release candidate, often 2 weeks in
advance. When the two weeks are up, a branch is cut (i.e. 0.8-rc1) and from
that point only bugfixes land in this branch. Each week, if bugfixes landed
during the week, a new RC is cut. During the RC phase, more adventurous users
are encouraged to upgrade and start looking for and reporting bugs (especially
in new features).
**Stable release**: when no substantial changes are merged into an RC for one
week, it's released as a new stable version of sway. At this point, all users
are encouraged to upgrade.
**Important**: Sway has completed its core value proposition: it is a fully
featured Wayland-compatible replacement for i3. It is not our intention to
expand on the scope of what i3 aims to accomplish. Our priorities now are
increasing the stability, reliability, and performance of sway within its
current scope. For this reason, most new window management feature requests are
not accepted, even if accompanied by a patch.
## Pull Requests
@ -33,34 +23,44 @@ don't, however, allow me to make a suggestion: feature branches pulled from
upstream. Try this:
1. Fork sway
2. Clone your fork
3. git remote add upstream git://github.com/swaywm/sway.git
2. `git clone https://github.com/username/sway && cd sway`
3. `git remote add upstream https://github.com/swaywm/sway`
You only need to do this once. You're never going to use your fork's master
branch. Instead, when you start working on a feature, do this:
1. git fetch upstream
2. git checkout -b add-so-and-so-feature upstream/master
3. work
4. git push -u origin add-so-and-so-feature
5. Make pull request from your feature branch
1. `git fetch upstream`
2. `git checkout -b add-so-and-so-feature upstream/master`
3. Add and commit your changes
4. `git push -u origin add-so-and-so-feature`
5. Make a pull request from your feature branch
When you submit your pull request, your commit log should do most of the talking
when it comes to describing your changes and their motivation. In addition to
this, your pull request's comments will ideally include a test plan that the
reviewers can use to (1) demonstrate the problem on master, if applicable and
(2) verify that the problem no longer exists with your changes applied (or that
your new features work correctly). Document all of the edge cases you're aware
of so we can adequately test them - then verify the test plan yourself before
submitting.
## Commit Messages
Please strive to write good commit messages. Here's some guidelines to follow:
The first line should be limited to 50 characters and should be a sentence that
completes the thought [When applied, this commit will...] "Implement cmd_move"
or "Fix #742" or "Improve performance of arrange_windows on ARM" or similar.
completes the thought [When applied, this commit will...] *"Implement
cmd_move"* or *"Fix #742"* or *"Improve performance of arrange_windows on ARM"*
or similar.
The subsequent lines should be seperated from the subject line by a single
The subsequent lines should be separated from the subject line by a single
blank line, and include optional details. In this you can give justification
for the change, [reference Github
issues](https://help.github.com/articles/closing-issues-via-commit-messages/),
or explain some of the subtler details of your patch. This is important because
when someone finds a line of code they don't understand later, they can use the
`git blame` command to find out what the author was thinking when they wrote
it. It's also easier to review your pull requests if they're seperated into
it. It's also easier to review your pull requests if they're separated into
logical commits that have good commit messages and justify themselves in the
extended commit description.
@ -68,157 +68,178 @@ As a good rule of thumb, anything you might put into the pull request
description on Github is probably fair game for going into the extended commit
message as well.
## Coding Style
See [here](https://chris.beams.io/posts/git-commit/) for more details.
Sway is written in C. The style guidelines is [kernel
style](https://www.kernel.org/doc/Documentation/process/coding-style.rst), but all braces go
on the same line (*"but K&R says so!" is a silly way of justifying something*).
Some points to note:
## Code Review
* Do not use typedefs unless you have a good reason
* Do not use macros unless you have a *really* good reason
* Align `case` with `switch`
* Tabs, not spaces
* `char *pointer` - note position of `*`
* Use logging with reckless abandon
* Always include braces for if/for/while/etc, even for one-liners
When your changes are submitted for review, one or more core committers will
look over them. Smaller changes might be merged with little fanfare, but larger
changes will typically see review from several people. Be prepared to receive
some feedback - you may be asked to make changes to your work. Our code review
process is:
An example of well formatted code:
1. **Triage** the pull request. Do the commit messages make sense? Is a test
plan necessary and/or present? Add anyone as reviewers that you think should
be there (using the relevant GitHub feature, if you have the permissions, or
with an @mention if necessary).
2. **Review** the code. Look for code style violations, naming convention
violations, buffer overflows, memory leaks, logic errors, non-portable code
(including GNU-isms), etc. For significant changes to the public API, loop in
a couple more people for discussion.
3. **Execute** the test plan, if present.
4. **Merge** the pull request when all reviewers approve.
5. **File** follow-up tickets if appropriate.
```C
#include <stdio.h>
#include <stdlib.h>
#include "log.h"
#include "example.h"
## Style Reference
struct foobar {
char *foo;
int bar;
long baz;
}; // Do not typedef without a good reason
Sway is written in C with a style similar to the [kernel
style](https://www.kernel.org/doc/Documentation/process/coding-style.rst), but
with a few notable differences.
int main(int argc, const char **argv) {
if (argc != 4) {
sway_abort("Do not run this program manually. See man 5 sway and look for output options.");
Try to keep your code conforming to C11 and POSIX as much as possible, and do
not use GNU extensions.
### Brackets
Brackets always go on the same line, including in functions.
Always include brackets for if/while/for, even if it's a single statement.
```c
void function(void) {
if (condition1) {
do_thing1();
}
if (!registry->desktop_shell) {
sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
}
int desired_output = atoi(argv[1]);
sway_log(WLR_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
int i;
struct output_state *output = registry->outputs->items[desired_output];
struct window *window = window_setup(registry, 100, 100, false);
if (!window) {
sway_abort("Failed to create surfaces.");
}
window->width = output->width;
window->height = output->height;
desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
list_add(surfaces, window);
cairo_surface_t *image = cairo_image_surface_create_from_png(argv[2]);
double width = cairo_image_surface_get_width(image);
double height = cairo_image_surface_get_height(image);
const char *scaling_mode_str = argv[3];
enum scaling_mode scaling_mode;
if (strcmp(scaling_mode_str, "stretch") == 0) {
scaling_mode = SCALING_MODE_STRETCH;
} else if (strcmp(scaling_mode_str, "fill") == 0) {
scaling_mode = SCALING_MODE_FILL;
} else if (strcmp(scaling_mode_str, "fit") == 0) {
scaling_mode = SCALING_MODE_FIT;
} else if (strcmp(scaling_mode_str, "center") == 0) {
scaling_mode = SCALING_MODE_CENTER;
} else if (strcmp(scaling_mode_str, "tile") == 0) {
scaling_mode = SCALING_MODE_TILE;
if (condition2) {
do_thing2();
} else {
sway_abort("Unsupported scaling mode: %s", scaling_mode_str);
do_thing3();
}
}
```
for (i = 0; i < surfaces->length; ++i) {
struct window *window = surfaces->items[i];
if (window_prerender(window) && window->cairo) {
switch (scaling_mode) {
case SCALING_MODE_STRETCH:
cairo_scale(window->cairo,
(double) window->width / width,
(double) window->height / height);
cairo_set_source_surface(window->cairo, image, 0, 0);
break;
case SCALING_MODE_FILL:
{
double window_ratio = (double) window->width / window->height;
double bg_ratio = width / height;
### Indentation
if (window_ratio > bg_ratio) {
double scale = (double) window->width / width;
cairo_scale(window->cairo, scale, scale);
cairo_set_source_surface(window->cairo, image,
0,
(double) window->height/2 / scale - height/2);
} else {
double scale = (double) window->height / height;
cairo_scale(window->cairo, scale, scale);
cairo_set_source_surface(window->cairo, image,
(double) window->width/2 / scale - width/2,
0);
}
break;
}
case SCALING_MODE_FIT:
{
double window_ratio = (double) window->width / window->height;
double bg_ratio = width / height;
Indentations are a single tab.
if (window_ratio > bg_ratio) {
double scale = (double) window->height / height;
cairo_scale(window->cairo, scale, scale);
cairo_set_source_surface(window->cairo, image,
(double) window->width/2 / scale - width/2,
0);
} else {
double scale = (double) window->width / width;
cairo_scale(window->cairo, scale, scale);
cairo_set_source_surface(window->cairo, image,
0,
(double) window->height/2 / scale - height/2);
}
break;
}
case SCALING_MODE_CENTER:
cairo_set_source_surface(window->cairo, image,
(double) window->width/2 - width/2,
(double) window->height/2 - height/2);
break;
case SCALING_MODE_TILE:
{
cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image);
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source(window->cairo, pattern);
break;
}
default:
sway_abort("Scaling mode '%s' not implemented yet!", scaling_mode_str);
}
For long lines that need to be broken, the continuation line should be indented
with an additional tab.
cairo_paint(window->cairo);
If the line being broken is opening a new block (functions, if, while, etc.),
the continuation line should be indented with two tabs, so they can't be
misread as being part of the block.
window_render(window);
```c
really_long_function(argument1, argument2, ...,
argument3, argument4);
if (condition1 && condition2 && ...
condition3 && condition4) {
do_thing();
}
```
Try to break the line in the place which you think is the most appropriate to
balance the lines.
### Line Length
Try to keep your lines under 80 columns, assuming a tab width equal to 4 spaces,
but you can go up to 100 if it improves readability. Don't break lines
indiscriminately, try to find nice breaking points so your code is easy to read.
### Names
Global function and type names should be prefixed with `sway_submodule_` (e.g.
`struct sway_output`, `sway_output_destroy`). For static functions and
types local to a file, the names chosen aren't as important. Static functions
shouldn't have a `sway_` prefix.
For include guards, use the header's filename relative to include. Uppercase
all of the characters, and replace any invalid characters with an underscore.
### Construction/Destruction Functions
For functions that are responsible for constructing and destructing an object,
they should be written as a pair of one of two forms:
* `init`/`finish`: These initialize/deinitialize a type, but are **NOT**
responsible for allocating it. They should accept a pointer to some
pre-allocated memory (e.g. a member of a struct).
* `create`/`destroy`: These also initialize/deinitialize, but will return a
pointer to a `malloc`ed chunk of memory, and will `free` it in `destroy`.
A destruction function should always be able to accept a NULL pointer or a
zeroed value and exit cleanly; this simplifies error handling a lot.
### Error Codes
For functions not returning a value, they should return a (stdbool.h) bool to
indicated if they succeeded or not.
### Macros
Keep the use of macros to a minimum, especially if a function can do the job. If
you do need to use them, try to keep them close to where they're being used and
`#undef` them after.
### Example
```c
struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
struct wlr_backend *backend;
if (getenv("WAYLAND_DISPLAY") || getenv("_WAYLAND_DISPLAY")) {
backend = attempt_wl_backend(display);
if (backend) {
return backend;
}
}
while (wl_display_dispatch(registry->display) != -1);
for (i = 0; i < surfaces->length; ++i) {
struct window *window = surfaces->items[i];
window_teardown(window);
const char *x11_display = getenv("DISPLAY");
if (x11_display) {
return wlr_x11_backend_create(display, x11_display);
}
list_free(surfaces);
registry_teardown(registry);
return 0;
// Attempt DRM+libinput
struct wlr_session *session = wlr_session_create(display);
if (!session) {
wlr_log(WLR_ERROR, "Failed to start a DRM session");
return NULL;
}
int gpu = wlr_session_find_gpu(session);
if (gpu == -1) {
wlr_log(WLR_ERROR, "Failed to open DRM device");
goto error_session;
}
backend = wlr_multi_backend_create(session);
if (!backend) {
goto error_gpu;
}
struct wlr_backend *libinput = wlr_libinput_backend_create(display, session);
if (!libinput) {
goto error_multi;
}
struct wlr_backend *drm = wlr_drm_backend_create(display, session, gpu);
if (!drm) {
goto error_libinput;
}
wlr_multi_backend_add(backend, libinput);
wlr_multi_backend_add(backend, drm);
return backend;
error_libinput:
wlr_backend_destroy(libinput);
error_multi:
wlr_backend_destroy(backend);
error_gpu:
wlr_session_close_file(session, gpu);
error_session:
wlr_session_destroy(session);
return NULL;
}
```

View File

@ -1,24 +0,0 @@
## Logging
Use `sway_log(importance, fmt, ...)` to log. The following importances are
available:
* `WLR_DEBUG`: Debug messages, only shows with `sway -d`
* `WLR_INFO`: Informational messages
* `WLR_ERROR`: Error messages
`sway_log` is a macro that calls `_sway_log` with the current filename and line
number, which are written into the log with your message.
## Assertions
In the compositor, assertions *must not* be fatal. All error cases must be
handled as gracefully as possible - crashing the compositor will make the user
lose all of their work.
Use `sway_assert(condition, fmt, ...)` to perform an assertion. This returns
`condition`, which you must handle if false. An error will be logged if the
assertion fails.
Outside of the compositor (swaymsg, swaybar, etc), using `assert.h` is
permitted.

91
README.ar.md Normal file
View File

@ -0,0 +1,91 @@
# sway
sway
هو مدير للمجموعات المركبة لـ[Wayland] متوافق مع [i3] -
إقرأ [الأسئلة الشائعة](https://github.com/swaywm/sway/wiki)
انضم الى [قناة IRC](https://web.libera.chat/gamja/?channels=#sway)
## تواقيع الإصدار
تٌوقع الإصدارات بـواسطة [E88F5E48] و تُنشر على [GitHub](https://github.com/swaywm/sway/releases)
## التثبيت
### بإستخدام الحزم
يتوفر Sway للعديد من التوزيعات، حاول تثبيت حزمة "sway" لتوزيعتك
### التجميع من المصدر
إطلع على [صفحة الويكي هذه](https://github.com/swaywm/sway/wiki/Development-Setup) إذا أردت بناء الـHEAD من sway و wlroots لأغراض الفحص والتطوير
تثبيت اللوازم:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (optional: system tray)
* [scdoc] (optional: man pages) \*
* git (optional: version info) \*
_\* Compile-time dep_
نفذ هذه الأوامر:
meson build/
ninja -C build/
sudo ninja -C build/ install
## الإعدادات
إذا كنت بالفعل تستخدم i3، فعليك نسخ إعدادات i3 لديك إلى `~/.config/sway/config` وسوف تعمل تلقائياً.
و إلا عليك نسخ ملف الإعدادات النموذج إلى `config/sway/config` الموجود عادةً في `/etc/sway/config.`
## التشغيل
شغل `sway` بإستخدام أمر TTY.
قد يعمل بعض مدراء العرض مع أنهم غير مدعومون من sway
(gdm مثلاً يعمل بشكل جيد إلى حد ما)
[en]: https://github.com/swaywm/sway#readme
[ar]: README.ar.md
[cs]: README.cs.md
[de]: README.de.md
[dk]: README.dk.md
[es]: README.es.md
[fr]: README.fr.md
[ge]: README.ge.md
[gr]: README.gr.md
[hi]: README.hi.md
[hu]: README.hu.md
[ir]: README.ir.md
[it]: README.it.md
[ja]: README.ja.md
[ko]: README.ko.md
[nl]: README.nl.md
[no]: README.no.md
[pl]: README.pl.md
[pt]: README.pt.md
[ro]: README.ro.md
[ru]: README.ru.md
[sv]: README.sv.md
[tr]: README.tr.md
[uk]: README.uk.md
[zh-CN]: README.zh-CN.md
[zh-TW]: README.zh-TW.md
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

89
README.cs.md Normal file
View File

@ -0,0 +1,89 @@
# sway
[English][en] - **[Česky][cs]** - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [Svenska][sv] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]
sway je s [i3] kompatibilní [Wayland] kompozitor. Přečtěte si [FAQ]. Připojte se na
[IRC kanál][IRC channel] \(#sway na irc.libera.chat).
## Podpisy vydání
Vydání jsou podepsána [E88F5E48] a publikována [na GitHubu][GitHub releases].
## Instalace
### Z balíčků
Sway je dostupný ve spoustě distribucí. Zkuste nainstalovat balíček "sway" ve vaší
distribuci.
### Kompilace ze zdrojových kódů
Podívejte se na [tuto stránku wiki][Development setup], pokud chcete sestavit HEAD
sway a wlroots pro testování nebo vývoj.
Nainstalujte závislosti:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (volitelné: oznamovací oblast)
* [scdoc] (volitelné: manuálové stránky) \*
* git (volitelné: informace o verzi) \*
_\* Závislost pouze pro sestavení_
Spusťte tyto příkazy:
meson build/
ninja -C build/
sudo ninja -C build/ install
## Konfigurace
Pokud již používáte i3, zkopírujte svou konfiguraci i3 do `~/.config/sway/config`
a ta bude ihned fungovat. Jinak zkopírujte do `~/.config/sway/config` ukázkový
konfigurační soubor. Ten se obvykle nachází v `/etc/sway/config`.
Pro více informací o konfiguraci spusťte `man 5 sway`.
## Spuštění
Spusťte `sway` z TTY. Některé správce zobrazení mohou fungovat, ale nejsou
podporovány sway (je známo, že gdm funguje docela dobře).
[en]: https://github.com/swaywm/sway#readme
[cs]: README.cs.md
[de]: README.de.md
[dk]: README.dk.md
[es]: README.es.md
[fr]: README.fr.md
[sv]: README.sv.md
[gr]: README.gr.md
[hi]: README.hi.md
[hu]: README.hu.md
[ir]: README.ir.md
[it]: README.it.md
[ja]: README.ja.md
[ko]: README.ko.md
[nl]: README.nl.md
[pl]: README.pl.md
[pt]: README.pt.md
[ro]: README.ro.md
[ru]: README.ru.md
[tr]: README.tr.md
[uk]: README.uk.md
[zh-CN]: README.zh-CN.md
[zh-TW]: README.zh-TW.md
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

View File

@ -1,97 +1,43 @@
# sway
# Sway
Sway ist ein [i3](https://i3wm.org/)-kompatibler [Wayland](http://wayland.freedesktop.org/)-Compositor. Lies die [FAQ](https://github.com/swaywm/sway/wiki). Tritt dem [IRC Channel](https://web.libera.chat/gamja/?channels=#sway) bei (#sway on irc.libera.chat; Englisch).
Der Fortschritt dieser Übersetzung kann [hier](https://github.com/swaywm/sway/issues/1318)
eingesehen werden.
"**S**irCmpwn's **Way**land compositor" ist ein i3-kompatibler
[Wayland](http://wayland.freedesktop.org/)-Kompositor. Lies die
[FAQ](https://github.com/swaywm/sway/wiki#faq). Tritt dem
[IRC-Channel](http://webchat.freenode.net/?channels=sway&uio=d4) bei (#sway in irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
Falls du die Entwicklung von Sway unterstützen möchtest, kannst du das auf der
[Patreon-Seite](https://patreon.com/sircmpwn) tun, oder indem du zu
[Entwicklungsprämien](https://github.com/swaywm/sway/issues/986)
bestimmter Features beiträgst. Jeder ist dazu eingeladen, eine Prämie in Anspruch
zu nehmen oder für gewünschte Features bereitzustellen. Patreon ist eher dafür
gedacht, Sways Wartung und das Projekt generell zu unterstützen.
## Deutscher Support
refacto(UTC+2) bietet Support im IRC (unter dem Namen azarus) und auf Github an.
ParadoxSpiral(UTC+2) bietet Support im IRC und auf Github an.
## Releasesignaturen
Neue Versionen werden mit
[B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
signiert und [auf Github](https://github.com/swaywm/sway/releases) veröffentlicht.
## Status
- [i3-Features](https://github.com/swaywm/sway/issues/2)
- [IPC-Features](https://github.com/swaywm/sway/issues/98)
- [i3bar-Features](https://github.com/swaywm/sway/issues/343)
- [i3-gaps-Features](https://github.com/swaywm/sway/issues/307)
- [Sicherheitsfeatures](https://github.com/swaywm/sway/issues/984)
## Signaturen
Jedes Release wird mit dem PGP-Schlüssel [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48) signiert und [auf GitHub](https://github.com/swaywm/sway/releases) veröffentlicht.
## Installation
### Als Paket
### Über die Paketverwaltung
Sway ist in vielen Distributionen verfügbar: versuche einfach, das „sway“-Paket
zu installieren. Falls es nicht vorhanden ist, schaue dir
[diese Wikiseite](https://github.com/swaywm/sway/wiki/Unsupported-packages) für
distributionsspezifische Installationsinformationen an.
Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Versuche einfach das Packet "sway" zu installieren.
Wenn du Interesse hast, Sway für deine Distribution als Paket bereitzustellen,
schaue im IRC-Channel vorbei oder schreibe eine EMail an sir@cmpwn.com (nur englischsprachig).
### Quellcode selbst kompilieren
### Kompilieren des Quellcodes
sway benötigt die folgenden Pakete:
Abhängigkeiten:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* meson\*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols\*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (erforderlich für man pages)
* gdk-pixbuf2 (Optional, wird für das Benachrichtigungsfeld (System Tray) benötigt)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (Optional, wird für die Dokumentation (Man Pages) benötigt)\*
* git (Optional: Versionsinfo)\*
_\*Nur erforderlich für swaybar, swaybg, und swaylock_
_\*Werden nur während des Kompilierens benötigt_
_\*\*Nur erforderlich für swaylock_
Führe diese Befehle aus:
Führe die folgenden Befehle aus:
meson build
ninja -C build
sudo ninja -C build install
In Systemen mit logind musst du `sway` einige Capabilities geben:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
In Systemen ohne logind musst du `sway` das suid-Flag geben:
sudo chmod a+s /usr/local/bin/sway
## Konfiguration
Wenn du schon i3 benutzt, kopiere einfach deine i3 Konfiguration nach
`~/.config/sway/config`. Falls nicht, kannst du die Beispielkonfiguration
benutzen. Die befindet sich normalerweise unter `/etc/sway/config`.
Um mehr Informationen über die Konfiguration zu erhalten, führe `man 5 sway` aus.
Falls du von i3 migrierst, kannst du deine Konfigurationsdatei nach `~/.config/sway/config` kopieren und die Einstellungen sollten ohne Weiteres funktionieren. Ansonsten kannst du die Beispielkonfiguration, die normalerweise in `/etc/sway/config` liegt, nach `~/.config/sway/config` kopieren. Die Dokumentation zur Konfigurationsdatei findest du in `man 5 sway`.
## Verwendung
Führe `sway` von einem TTY aus. Manche Displaymanager könnten funktionieren, werden aber
nicht von Sway unterstützt (gdm scheint relativ gut zu funktionieren).
## Sway starten
Sway kann einfach mit dem Befehl `sway` vom TTY gestartet werden.
Display-Manager werden nicht offiziell unterstützt. Es gibt aber durchaus einige, die mit Sway funktionieren (z.B. gdm).

68
README.dk.md Normal file
View File

@ -0,0 +1,68 @@
# Sway
Sway er en [i3]-kompatibel [Wayland] compositor. Læs [Ofte stillede spørgsmål].
Deltag på [IRC kanalen][IRC kanal] \(#sway på irc.libera.chat).
## Udgivelses Signaturer
Udgivelser er signeret med [E88F5E48] og publiceret [på GitHub][GitHub
releases].
## Installation
### Fra pakker
Sway er tilgængelig i mange distributioner. Prøv at installere "sway" pakken
fra din.
Hvis du er interesseret i at pakke Sway til din distribution, kan du tage forbi
IRC kanalen eller sende en email til sir@cmpwn.com for rådgivning.
### Kompilering fra kildekode
Se [denne wiki-side][Opsætning til udvikling] hvis du vil bygge HEAD af sway og
wlroots til test eller udvikling.
Installationsafhængigheder:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (valgfrit: system tray)
* [scdoc] (valgfrit: man pages) \*
* git \*
_\*Kompileringsafhængighed_
Kør følgende kommandoer:
meson build
ninja -C build
sudo ninja -C build install
## Konfiguration
Hvis du allerede bruger i3 kan du bare kopiere din i3 konfiguration til
`~/.config/sway/config`. Ellers skal du kopiere eksempelkonfigurationsfilen til
`~/.config/sway/config`. Den er normalt placeret i `/etc/sway/config`. Kør
`man 5 sway` for at få oplysninger om konfigurationen.
## Eksekvering
Kør `sway` fra en TTY. Nogle display managers kan fungere, men Sway yder ikke
support til dem (gdm er kendt for at fungere temmelig godt).
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[Ofte stillede spørgsmål]: https://github.com/swaywm/sway/wiki
[IRC kanal]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Opsætning til udvikling]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

View File

@ -1,87 +0,0 @@
# sway
"Ο Sway (**S**irCmpwn's **Way**land) είναι ένας **υπό ανάπτυξη** [Wayland](http://wayland.freedesktop.org/) διαχειριστής παραθύρων συμβατός με τον αντίστοιχο διαχειριστή παραθύρων i3 για τον X11.
Διαβάστε τις [Συνήθεις Ερωτήσεις](https://github.com/swaywm/sway/wiki). Συνδεθείτε στο [κανάλι μας στο IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway στο
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
### Η ελληνική μετάφραση ενδέχεται να είναι ελλειπής!
Η τεκμηρίωση του Sway ξεκινάει πάντα από τα Αγγλικά και στη συνέχεια μεταφράζεται, γι' αυτό ενδέχεται τα ελληνικά κείμενα να μην είναι πάντα διαθέσιμα ή ενημερωμένα.
Μπορείτε πάντα να υποδεικνύετε σφάλματα και να κάνετε ερωτήσεις σχετικά με τις ελληνικές μεταφράσεις στο [IRC](http://webchat.freenode.net/?channels=sway&uio=d4).
To username μου στο Freenode είναι kon14 και θα με βρείτε στο IRC σε ώρες GMT+2.
Δείτε [εδώ](https://github.com/swaywm/sway/issues/1318) πως μπορείτε και οι ίδιοι να βοηθήσετε στη μετάφραση του Sway.
Αν θέλετε να υποστηρίξετε την ανάπτυξη του Sway, μπορείτε να συμβάλετε στη [σελίδα Patreon του SirCmpwn](https://patreon.com/sircmpwn)
ή να επιδοτήσετε τις [αμοιβές](https://github.com/swaywm/sway/issues/986) για υλοποίηση συγκεκριμένων δυνατοτήτων.
Ο καθένας μπορεί να διεκδικήσει μια αμοιβή και μπορείτε να προσθέσετε μια αμοιβή για οποιαδήποτε δυνατότητα θέλετε.
Προτιμήστε το Patreon αν θέλετε να υποστήριξετε την συνολική ανάπτυξη και διατήρηση του Sway.
## Υπογραφές Έκδοσης
Οι εκδόσεις υπογράφονται ως [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A) και δημοσιεύονται στο [GitHub](https://github.com/swaywm/sway/releases).
## Κατάσταση
- [Υποστήριξη δυνατοτήτων του i3](https://github.com/swaywm/sway/issues/2)
- [Υποστήριξη δυνατοτήτων IPC](https://github.com/swaywm/sway/issues/98)
- [Υποστήριξη δυνατοτήτων i3bar](https://github.com/swaywm/sway/issues/343)
- [Υποστήριξη δυνατοτήτων i3-gaps](https://github.com/swaywm/sway/issues/307)
- [Δυνατότητες Ασφαλείας](https://github.com/swaywm/sway/issues/984)
## Εγκατάσταση
### Από Πακέτα
Ο Sway είναι διαθέσιμος για εγκατάσταση μέσω του διαχειριστή πακέτων σε διάφορες διανομές.
Δοκιμάστε να εγκαταστήσετε το πακέτο ονομαζόμενο ως "sway" για τη δική σας.
Αν δεν είναι διαθέσιμο, μεταβείτε στη [σελίδα τεκμηρίωσης](https://github.com/swaywm/sway/wiki/Unsupported-packages) για πληροφορίες σχετικά με την εγκατάσταση για τη διανομή σας.
Αν ενδιαφέρεστε να δημιουργήσετε ένα πακέτο του Sway για τη διανομή σας, περάστε απο το κανάλι μας στο IRC ή στείλτε ένα email, στα **Αγγλικά**, στο sir@cmpwn.com για συμβουλές.
### Compile από Πηγαίο Κώδικα
Εγκατάσταση εξαρτήσεων:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
_\*Απαιτείται μόνο για swaybar, swaybg, and swaylock_
_\*\*Απαιτείται μόνο για swaylock_
Εκτελέστε αυτές τις εντολές:
meson build
ninja -C build
sudo ninja -C build install
Σε συστήματα με logind, χρειάζεται να ορίσετε μερικά δικαιώματα caps στο εκτελέσιμο αρχείο:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
Σε συστήματα χωρίς logind, χρειάζεται να θέσετε το suid bit στο εκτελέσιμο αρχείο:
sudo chmod a+s /usr/local/bin/sway
## Παραμετροποίηση
Αν είστε ήδη χρήστης του i3, τότε απλά αντιγράψτε το αρχείο ρυθμίσεων σας στο `~/.config/sway/config` και θα είναι όλα έτοιμα για χρήση.
Διαφορετικά, αντιγράψτε το συνοδευόμενο δείγμα ρυθμίσεων, το οποίο θα βρείτε τυπικά στο `/etc/sway/config`, και μεταφέρετε το στην τοποθεσία `~/.config/sway/config`. Εκτελέστε `man 5 sway` για πληροφορίες σχετικά με την παραμετροποίηση των ρυθμίσεων σας.
## Εκτέλεση
Εκτελέστε `sway` απο ένα TTY. Μερικοί γραφικοί διαχειριστές σύνδεσης ενδέχεται να δουλεύουν, αλλά δεν υποστηρίζονται επίσημα (ο GDM "προτείνεται" ως λειτουργικός).

57
README.es.md Normal file
View File

@ -0,0 +1,57 @@
# sway
sway es un compositor de [Wayland](http://wayland.freedesktop.org/) compatible con [i3](https://i3wm.org/).
Lea el [FAQ](https://github.com/swaywm/sway/wiki). Únase al [canal de IRC](https://web.libera.chat/gamja/?channels=#sway) (#sway on
irc.libera.chat).
## Firmas de las versiones
Las distintas versiones están firmadas con [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
y publicadas [en GitHub](https://github.com/swaywm/sway/releases).
## Instalación
### Usando paquetes
Sway está disponible en muchas distribuciones. Pruebe instalando el paquete "sway" desde la suya.
Si no está disponible, puede consultar [esta documentación](https://github.com/swaywm/sway/wiki/Unsupported-packages)
y así obtener información acerca de como instalarlo.
Si está interesado en crear un paquete para su distribución, únase al canal de IRC o
escriba un email a sir@cmpwn.com
### Compilando el código fuente
Instale las dependencias:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (optional: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (optional: man pages) \*
* git \*
_\*Compile-time dep_
Desde su consola, ejecute las órdenes:
meson build
ninja -C build
sudo ninja -C build install
## Configuración
Si ya utiliza i3, copie su archivo de configuración de i3 a `~/.config/sway/config` y
sway funcionará sin tener que configurar nada más. En otro caso, copie el archivo de
configuración básico a `~/.config/sway/config`, normalmente se encuentra en `/etc/sway/config`.
Ejecute `man 5 sway` para obtener información sobre la configuración.
## Ejecución
Ejecute `sway` desde su consola. Algunos gestores de pantalla pueden funcionar sin estar
soportados por `sway` (sabemos que gdm funciona bastante bien).

View File

@ -1,69 +1,49 @@
# sway
"**S**irCmpwn's **Way**land compositor" est un compositeur [Wayland](http://wayland.freedesktop.org/)
compatible avec i3, **en cours de développement**.
Lisez la [FAQ](https://github.com/swaywm/sway/wiki). Rejoignez le
[canal IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway sur
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
Si vous souhaitez soutenir le développement de Sway, vous pouvez contribuer à [ma page
Patreon](https://patreon.com/sircmpwn) ou aux [primes](https://github.com/swaywm/sway/issues/986)
pour des fonctionnalités spécifiques.
Tout le monde est invité à réclamer une prime et vous pouvez donner une prime pour n'importe quelle
fonctionnalité souhaitée. Patreon est plus utile pour supporter l'état général et la
maintenance de Sway.
Sway est un compositeur [Wayland] compatible avec [i3]. Lisez la
[FAQ]. Rejoignez le [canal IRC] (#sway sur irc.libera.chat).
## Aide en français
[abdelq](//github.com/abdelq) fournit du support en français sur IRC et Github, dans le fuseau horaire UTC-4 (EST).
[abdelq] fournit du support en français sur IRC et Github, dans le fuseau
horaire UTC-4 (EST).
## Signatures de nouvelles versions
Les nouvelles versions sont signées avec [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
et publiées [sur GitHub](https://github.com/swaywm/sway/releases).
## Statut
- [support des fonctionnalités d'i3](https://github.com/swaywm/sway/issues/2)
- [support des fonctionnalités d'IPC](https://github.com/swaywm/sway/issues/98)
- [support des fonctionnalités d'i3bar](https://github.com/swaywm/sway/issues/343)
- [support des fonctionnalités d'i3-gaps](https://github.com/swaywm/sway/issues/307)
- [fonctionnalités de sécurité](https://github.com/swaywm/sway/issues/984)
Les nouvelles versions sont signées avec [E88F5E48] et publiées
[sur GitHub][versions GitHub].
## Installation
### À partir de paquets
Sway est disponible sur plusieurs distributions. Essayez d'installer le paquet "sway" pour
la vôtre. Si ce n'est pas disponible, consultez [cette page wiki](https://github.com/swaywm/sway/wiki/Unsupported-packages)
pour de l'information sur l'installation pour vos distributions.
Sway est disponible sur beaucoup de distributions. Essayez d'installer le
paquet "sway" pour la vôtre.
Si vous êtes intéressé à maintenir Sway pour votre distribution, passez par le canal
IRC ou envoyez un e-mail à sir@cmpwn.com (en anglais seulement) pour des conseils.
Si vous êtes intéressé à maintenir Sway pour votre distribution, passez sur le
canal IRC ou envoyez un e-mail à sir@cmpwn.com (en anglais seulement) pour des
conseils.
### Compilation depuis la source
### Compilation depuis les sources
Consultez [cette page wiki][Configuration de développement] si vous souhaitez
compiler la révision HEAD de sway et wlroots pour tester ou développer.
Installez les dépendances :
* meson
* [wlc](https://github.com/Cloudef/wlc)
* meson \*
* [wlroots]
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (requis pour les pages man)
* gdk-pixbuf2 (optionnel : system tray)
* [scdoc] (optionnel : requis pour les pages man) \*
* git (optionnel : information de version) \*
_\*Uniquement requis pour swaybar, swaybg, and swaylock_
_\*\*Uniquement requis pour swaylock_
_\* Requis uniquement pour la compilation_
Exécutez ces commandes :
@ -71,26 +51,27 @@ Exécutez ces commandes :
ninja -C build
sudo ninja -C build install
Sur les systèmes avec logind, vous devez définir quelques caps sur le binaire :
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
Sur les systèmes sans logind, vous devez suid le binaire de sway :
sudo chmod a+s /usr/local/bin/sway
## Configuration
Si vous utilisez déjà i3, copiez votre configuration i3 à `~/.config/sway/config` et
cela va fonctionner. Sinon, copiez l'exemple de fichier de configuration à
`~/.config/sway/config`. Il se trouve généralement dans `/etc/sway/config`.
Exécutez `man 5 sway` pour l'information sur la configuration.
Mes propres dotfiles sont disponibles [ici](https://git.sr.ht/~sircmpwn/dotfiles) si
vous voulez un peu d'inspiration. Je vous recommande aussi de consulter le
[wiki](https://github.com/swaywm/sway/wiki).
Si vous utilisez déjà i3, copiez votre configuration i3 vers
`~/.config/sway/config` et sway fonctionnera directement. Sinon, copiez
l'exemple de fichier de configuration vers `~/.config/sway/config`. Il se
trouve généralement dans `/etc/sway/config`. Exécutez `man 5 sway` pour lire la
documentation pour la configuration de sway.
## Exécution
Exécutez `sway` à partir d'un TTY. Certains gestionnaires d'affichage peuvent fonctionner,
mais ne sont pas supportés par Sway (gdm est réputé pour assez bien fonctionner).
Exécutez `sway` à partir d'un TTY. Certains gestionnaires d'affichage peuvent
fonctionner, mais ne sont pas supportés par Sway (gdm est réputé pour assez
bien fonctionner).
[Wayland]: http://wayland.freedesktop.org/
[i3]: https://i3wm.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[canal IRC]: https://web.libera.chat/gamja/?channels=#sway
[abdelq]: https://github.com/abdelq
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[versions GitHub]: https://github.com/swaywm/sway/releases
[Configuration de développement]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

61
README.ge.md Normal file
View File

@ -0,0 +1,61 @@
# sway
sway არის [i3]-თავსებადი [Wayland]-ის კომპოზიტორი. მეტი ინფორმაციისთვის იხილეთ
[FAQ]. დაუკავშირდით [IRC არხს][IRC channel] \(#sway irc.libera.chat-ზე).
## გამოშვების ხელმოწერები
გამოშვებები ხელმოწერილია [E88F5E48]-ით და გამოქვეყნებულია [GitHub-ზე][GitHub releases].
## ინსტალაცია
### რეპოზიტორიიდან
Sway არის ხელმისაწვდომი ბევრი დისტრიბუტაციისთვის. ცადეთ "sway" პაკეტის ინსტალაცია თქვენთვის.
### კოდის კომპილაცია
იხილეთ [ეს ვიკი გვერდი][Development setup] თუ გინდათ რომ ააწყოთ sway და wlroots სატესტოდ ან დეველოპმენტისთვის.
დააინსტალირეთ დამოკიდებულებები:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (ასევე არჩევითია: system tray)
* [scdoc] (ასევე არჩევითია: man pages) \*
* git (ასევე არჩევითია: version info) \*
_\* Compile-time dep_
გაუშვით ეს ბრძანებები:
meson build/
ninja -C build/
sudo ninja -C build/ install
## კონფიგურაცია
თუ უკვე იყენებთ i3-ს, მაშინ დააკოპირე i3 კონფიგურაცია და ჩასვი `~/.config/sway/config`
და უპრობლემოდ იმუშავებს პირდაპირ. წინააღმდეგ შემთხვევაში კონფიგურაციის ნიმუში ჩააკოპირეთ აქ: `~/.config/sway/config`. კომპიგურაციის ნიმუში ხშირ შემთხვევაში არის `/etc/sway/config`.
გაუშვი `man 5 sway` კონპიგურაციაზე ინფორმაციის მისაღებად.
## გაშვება
გაუშვი `sway` TTY-ისთვის. ზოგიერთმა ლოგინ მენეჯერმა შეიძლება იმუშავოს, მაგრამ არ
არის მხარდაჭერილი sway-სგან (როგორც წესი კარგად მუშაობს gdm).
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

67
README.gr.md Normal file
View File

@ -0,0 +1,67 @@
# Sway
Το sway ένα [i3]-συμβατό [Wayland] compositor. Διαβάστε το [FAQ]. Μπείτε στο
[IRC channel] \(#sway on irc.libera.chat).
## Υπογραφές δημοσιεύσεων
Οι εκδόσεις είναι υπογεραμμένες με [E88F5E48] και δημοσιευμένες [στο GitHub][GitHub releases].
## Εγκατάσταση
### Από πακέτα
Το Sway είναι διαθέσιμο σε πολλά distributions. Δοκιμάστε εγκαταστώντας το "sway" package για
το δικό σας.
Εάν ενδιαφέρεστε για packaging του sway για το distribution σας, να πάτε στο IRC
channel ή στείλτε ένα email στο sir@cmpwn.com για συμβουλές.
### Compiling από πηγή
Τσεκάρετε [αυτό το wiki page][Development setup] εάμα θέλετε να κάνετε build το HEAD του
sway και wlroots γιά τεστάρισμα ή development.
Εγκατάσταση των dependencies:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (προαιρετικό: system tray)
* [scdoc] (προαιρετικό: man pages) \*
* git (προαιρετικό: πληροφορίες εκδώσεων) \*
_\*Compile-time dep_
Τρέξτε αυτά τα commands:
meson build/
ninja -C build/
sudo ninja -C build/ install
## Configuration
Εάν ήδη χρησιμοποιήτε το i3, αντιγράψτε το i3 config σας στο `~/.config/sway/config` και
θα δουλέψει out of the box. Αλλιώς, αντιγράψτε το sample configuration αρχείο στο
`~/.config/sway/config`. Το οποίο συνήθως βρίσκεται στο `/etc/sway/config`.
Κάντε run `man 5 sway` για πληροφορίες τού configuration.
## Τρέχοντας
Τρέξτε `sway` από ένα TTY. Μερίκα display managers μπορεί να δουλέψουν αλλά δέν είναι συμβατά με
το sway (το gdm γνωρίζεται να δουλέβει σχετικά καλά).
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

63
README.hi.md Normal file
View File

@ -0,0 +1,63 @@
# sway
sway एक [i3](https://i3wm.org/)-अनुकूल
[Wayland](https://wayland.freedesktop.org/) Compositor है।
[FAQ](https://github.com/swaywm/sway/wiki) पढिये। [IRC
Channel](https://web.libera.chat/gamja/?channels=#sway)
(irc.libera.chat पर #sway) में भी जुडिये।
## रिलीज हस्ताक्षर
रिलीजें
[E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
से साइन होतें हैं और [Github पर](https://github.com/swaywm/sway/releases) प्रकाशित होते हैं।
## इंस्टौलेशन
### पैकेजों के द्वारा
Sway कई distributions में उप्लब्ध है। आप अपने में "sway" नामक पैकेज इंस्टौल करके देख
सकते हैं।
### Source से compile करके
यदि आप परीक्षण और विकास के लिए sway और wlroots के नवीनतम संस्करण बनाना
चाहते हैं, तो [यह विकी
पृष्ठ](https://github.com/swaywm/sway/wiki/Development-Setup) देखें।
निर्भरताएं:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf (वैकल्पिक: system tray के लिये)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (वैकल्पिक: man पृष्ठों के लिये)
\*
* git (वैकल्पिक: संस्करण जानने के लिये)
_\* Compilation के समय आवश्यक_
ये commands चलाएं:
meson build/
ninja -C build/
sudo ninja -C build/ install
## Configuration
अगर आप पहले से ही i3 का उपयोग करते हैं तो अपने i3 config को
`~/.config/sway/config` में copy कर लीजिये और वह बिना किसी परिवर्तन के काम
करेगा। अन्यथा, नमूने configuration file को `~/.config/sway/config` में copy
कर लीजिये। यह सामान्यतः `/etc/sway/config` में पाया जाता है। `man 5
sway` से आप configuration के बारे में जानकारी प्राप्त कर सकते हैं।
## चलाना
आप एक tty से `sway` को चला सकते हैं। कुछ display managers काम करते हैं परन्तु ये
sway के द्वारा समर्थित नहीं है (gdm के बारे में जाना गया है कि वह सही काम करता
है)।

70
README.hu.md Normal file
View File

@ -0,0 +1,70 @@
# sway
A Sway egy [i3]-kompatibilis [Wayland] kompozitor. Olvasd el a [Gyarkan Ismételt Kérdéseket][FAQ]. Csatlakozz az [IRC csatornához][IRC channel] \(`#sway` az `irc.libera.chat`-en).
## Csomag aláírások
A kiadott csomagok az [E88F5E48] kulccsal vannak aláírva és [GitHub-on][GitHub releases] publikálva.
## Telepítés
### Csomagból
A Sway sok disztribúció csomagkezelőjéből elérhető, próbáld meg a "sway"
csomagot telepíteni az általad használt eszközzel.
Ha szeretnél csomagot készíteni a saját disztribúciódhoz, ugorj be az IRC
csatornára, vagy küldj levelet a sir@cmpwn.com címre tanácsokért.
### Fordítás forráskódból
Olvasd el [ezt a wiki oldalt][Development setup], ha szeretnéd tesztelési vagy
fejlesztési célokból lefordítani az aktuális (HEAD) állapotát a `sway`-nek és a
`wlroots`-nak.
Telepítsd a függőségeket:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (opcionális: system tray)
* [scdoc] (opcionális: man pages) \*
* git (opcionális: version info) \*
_\*Fordításidejű függőség_
Futtasd ezeket a parancsokat:
meson build
ninja -C build
sudo ninja -C build install
## Konfiguráció
Ha előzőleg i3-mat használtál, akkor átmásolhatod az i3 beállításaidat a
`~/.config/sway/config` file-ba és ugyanúgy működni fognak. Egyéb esetben másold
le kiindulási alapnak a mintát, ami általában az `etc/sway/config` elérési
útvonalon található.
Futtasd a `man 5 sway` parancsot további információért a konfigurációval
kapcsolatban.
## Futtatás
Futtasd a `sway` parancsot egy TTY felületről. Néhány bejelentkezéskezelő
(display manager) működhet, de alapvetően nem támogatottak a sway által. (A
gdm-ről ismeretes, hogy egész jól működik.)
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

54
README.ir.md Normal file
View File

@ -0,0 +1,54 @@
# sway
&rlm;sway یک کامپوزیتور الهام گرفته از [i3](https://i3wm.org/) بر روی [Wayland](http://wayland.freedesktop.org/) است. [سوال‌های متداول](https://github.com/swaywm/sway/wiki) را بخوانید. در [کانال
IRC](http://web.libera.chat/gamja/?channels=sway&uio=d4) عضو شوید (&lrm;#sway&rlm; در
irc.libera.chat).
برای حمایت از تیم توسعه sway به [صفحه
Patreon با نام کاربری SirCmpwn](https://patreon.com/sircmpwn) مراجعه کنید.
## امضای نسخه‌ها
امضای نسخه‌ها با [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A) در [GitHub](https://github.com/swaywm/sway/releases) منتشر می‌شود.
## شیوه نصب
### از بسته‌های رسمی
&rlm;sway در بسته‌های رسمی توزیع‌های مختلف وجود دارد. بسته «sway» را نصب کنید. در صورتی که بسته رسمی وجود نداشت، برای آگاهی بیشتر درباره نصب روی توزیعتان به این [صفحه راهنما](https://github.com/swaywm/sway/wiki/Unsupported-packages) مراجعه کنید.
اگر به ایجاد بسته sway برای توزیعتان علاقه‌مند هستید، از کانال IRC استفاده کنید یا به sir@cmpwn.com ایمیل بزنید.
### کامپایل کردن کد
چنانچه می‌خواهید آخرین نسخه کد sway و wlroots را برای آزمایش یا توسعه بسازید به این [صفحه راهنما](https://github.com/swaywm/sway/wiki/Development-Setup) مراجعه کنید.
بسته‌های مورد نیاز:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (انتخابی: برای system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (انتخابی: برای صفحه‌های راهنما) \*
* git (انتخابی: برای اطلاع در خصوص نسخه‌ها) \*
_\*نیازمندی‌های زمان کامپایل برنامه_
این فرمان‌ها را اجرا کنید:
meson build
ninja -C build
sudo ninja -C build install
### شخصی سازی و تنظیمات
اگر در حال حاضر از i3 استفاده می‌کنید، تنظیمات i3 خودتان را در فایل `~/.config/sway/config` کپی کنید و بدون نیاز به تغییر کار خواهد کرد. در غیر این‌صورت، فایل نمونه تنظیمات را استفاده کنید. این فایل عموما در `/etc/sway/config` قرار دارد. برای آگاهی بیشتر `man 5 sway` را اجرا کنید.
## اجرا
در محیط TTY کافیست `sway` را اجرا کنید. ممکن است ابزارهای مدیریت نمایشگری نیز برای این کار وجود داشته باشند اما از طرف sway پشتیبانی نمی‌شوند (gdm عملکرد خوبی در این زمینه دارد).

View File

@ -1,94 +1,66 @@
# sway
"**S**irCmpwn's **Way**land compositor" è un compositor
[Wayland](http://wayland.freedesktop.org/) **in via di sviluppo**
compatibile con i3.
Leggi le [FAQ (in Inglese)](https://github.com/swaywm/sway/wiki). Unisciti al
[canale IRC (in Inglese)](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on
irc.freenode.net).
sway è un compositore di [Wayland] compatibile con [i3]. Leggi le [FAQ].
Unisciti al [canale di IRC] \(#sway su irc.libera.chat).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
## Firma delle versioni
Se vuoi supportare lo sviluppo di Sway, puoi contribuire dalla
[pagina Patreon di SirCmpwn's](https://patreon.com/sircmpwn) o con dei
[premi](https://github.com/swaywm/sway/issues/986) per finanziare lo sviluppo
di funzionalità specifiche.
Chiunque è libero di reclamare un premio o crearne uno per qualsiasi funzionalità.
Patreon è più utile al supporto e alla manutenzione generale di Sway.
## Supporto italiano
syknro offre supporto in Italiano su GitHub nel fuso orario UTC+2.
Questa traduzione non è ancora completa. [Clicca qui per maggiori informazioni](https://github.com/swaywm/sway/issues/1318)
## Firme digitali
Le release sono firmate con [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
e pubblicate [su GitHub](https://github.com/swaywm/sway/releases).
## Status
- [supporto funzionalità i3](https://github.com/swaywm/sway/issues/2)
- [supporto funzionalità IPC](https://github.com/swaywm/sway/issues/98)
- [supporto funzionalità i3bar](https://github.com/swaywm/sway/issues/343)
- [supporto funzionalità i3-gaps](https://github.com/swaywm/sway/issues/307)
- [sicurezza](https://github.com/swaywm/sway/issues/984)
Le versioni sono firmate con la chiave [E88F5E48] e sono pubblicate
[su GitHub][GitHub releases].
## Installazione
### Dai pacchetti
### Da un pacchetto
Sway è disponibile in molte distribuzioni. Prova a installare il pacchetto "sway" per la tua.
Se non funziona, controlla [questa pagina (in Inglese)](https://github.com/swaywm/sway/wiki/Unsupported-packages)
per informazioni sull'installazione per le tue distribuzioni.
Sway è disponibile in molte distribuzioni, prova a installare il pacchetto
"sway" per la tua.
Se vuoi creare un pacchetto per la tua distribuzione, passa dall'IRC o manda un email (in Inglese)
a sir@cmpwn.com.
### Compilazione dei sorgenti
### Compilando il codice sorgente
Consulta [questa pagina del wiki][Development setup] se vuoi compilare l'HEAD
di sway e wlroots per testarli o contribuire allo sviluppo.
Installa queste dipendenze:
Installa le dipendenze:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* meson \*
* [wlroots]
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* wayland-protocols \*
* pcre
* json-c >= 0.13
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (rrichiesto per man pages)
* gdk-pixbuf2 (opzionale: area di notifica)
* [scdoc] (opzionale: pagine del manuale) \*
* git (opzionale: informazioni sulla versione) \*
_\*Richiesto solo per swaybar, swaybg, e swaylock_
_\*\*Richiesto solo per swaylock_
_\* Dipendenza necessaria per la compilazione_
Esegui questi comandi:
meson build
ninja -C build
sudo ninja -C build install
Per i sistemi con logind, devi impostare un paio di caps sull'eseguibile:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
Per i sistemi senza logind, devi cambiare i permessi (suid):
sudo chmod a+s /usr/local/bin/sway
meson build/
ninja -C build/
sudo ninja -C build/ install
## Configurazione
Se usi i3, copia la tua configurazione in `~/.config/sway/config` e
funzionerà direttamente.
Altrimenti copia in `~/.config/sway/config` la configurazione di esempio,
solitamente si trova in `/etc/sway/config`.
Esegui `man 5 sway` per informazioni sulla configurazione.
Se hai già usato i3, copia il tuo file di configurazione in
`~/.config/sway/config` e sway funzionerà immediatamente. Altrimenti, copia il
file d'esempio in `~/.config/sway/config`, generalmente è situato in
`/etc/sway/config`. Consulta `man 5 sway` per ulteriori informazioni sulla
configurazione.
## Esecuzione
Esegui `sway` da un TTY. Qualche display manager potrebbe funzionare ma non sono
ufficialmente supportati da Sway (gdm è risaputo funzionare abbastanza bene).
Lancia `sway` da un TTY. Alcuni gestori d'accesso potrebbero funzionare ma non
sono supportati da sway (gdm funziona abbastanza bene).
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[canale di IRC]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

View File

@ -1,30 +1,18 @@
# sway
"**S**irCmpwn's **Way**land compositor"は**開発中**の
i3互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。
Swayは[i3](https://i3wm.org/)互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。
[FAQ](https://github.com/swaywm/sway/wiki)も合わせてご覧ください。
[IRC チャンネル](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on irc.freenode.net)もあります。
**注意**: Swayは現在*凍結中*であり、Swayとwlrootsの統合が完了するまで、新たな機能は追加されません。バグフィックスは行われます。詳しくは[この記事](https://drewdevault.com/2017/10/09/Future-of-sway.html)をご覧ください。wlrootsとの統合状況については、[このチケット](https://github.com/swaywm/sway/issues/1390)をご覧ください。
[IRC チャンネル](https://web.libera.chat/gamja/?channels=#sway) (irc.libera.chatの#sway)もあります。
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
Swayの開発を支援したい場合は、[SirCmpwnのPatreon](https://patreon.com/sircmpwn)や、特定の機能に対する[報奨金のページ](https://github.com/swaywm/sway/issues/986)から寄付ができます。誰でも報奨金を請求できますし、自分の欲しい機能に報奨金を懸ける事も出来ます。またSwayのメンテナンスを支援するには、Patreonがより有用です。
## 日本語サポート
SirCmpwnは、日本語でのサポートをIRCとGitHubで行います。タイムゾーンはUTC-4です。
## リリースの署名
Swayのリリースは[B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)で署名され、[GitHub](https://github.com/swaywm/sway/releases)で公開されています。
## 開発状況
- [i3の機能のサポート](https://github.com/swaywm/sway/issues/2)
- [IPCの機能のサポート](https://github.com/swaywm/sway/issues/98)
- [i3barの機能のサポート](https://github.com/swaywm/sway/issues/343)
- [i3-gapsの機能のサポート](https://github.com/swaywm/sway/issues/307)
- [セキュリティ機能](https://github.com/swaywm/sway/issues/984)
Swayのリリースは[E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)で署名され、[GitHub](https://github.com/swaywm/sway/releases)で公開されています。
## インストール
@ -38,23 +26,19 @@ Swayは沢山のディストリビューションで提供されています。"
次の依存パッケージをインストールしてください:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (manで必要です)
* gdk-pixbuf2 (任意: システムイコンで必要です)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (任意: manで必要です) \*
* git (任意: バージョン情報で必要です) \*
_\*swaybar,swaybg,swaylockでのみ必要です_
_\*\*swaylockでのみ必要です_
_\*コンパイル時の依存_
次のコマンドを実行してください:
@ -62,14 +46,6 @@ _\*\*swaylockでのみ必要です_
ninja -C build
sudo ninja -C build install
logindを使用しているシステムでは、バイナリにいくつかのケーパビリティを設定する必要があります:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
logindを使用していないシステムでは、バイナリにsuidを設定する必要があります:
sudo chmod a+s /usr/local/bin/sway
## 設定
既にi3を使用している場合は、i3の設定ファイルを`~/.config/sway/config`にコピーすれば動きます。そうでない場合は、サンプルの設定ファイルを`~/.config/sway/config`にコピーしてください。サンプルの設定ファイルは、通常`/etc/sway/config`にあります。`man 5 sway`を実行することで、設定に関する情報を見ることができます。

55
README.ko.md Normal file
View File

@ -0,0 +1,55 @@
# sway
sway는 [i3](https://i3wm.org/)-호환 [Wayland](http://wayland.freedesktop.org/) 컴포지터입니다.
[FAQ](https://github.com/swaywm/sway/wiki)를 읽어보세요. [IRC 채널](https://web.libera.chat/gamja/?channels=#sway) (#sway on irc.libera.chat)도 있습니다.
## 릴리즈 서명
릴리즈는 [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)에서 서명되고,
[GitHub에서](https://github.com/swaywm/sway/releases) 공개되고 있습니다.
## 설치
### 패키지를 통한 설치
Sway는 많은 배포판에서 이용할 수 있습니다. "sway" 패키지를 설치해 보세요.
만약 없다면, [위키 페이지](https://github.com/swaywm/sway/wiki/Unsupported-packages)를 확인하세요.
해당 배포판에 대한 설치 정보를 확인할 수 있습니다.
당신의 배포판에 sway 패키지를 제공하고 싶다면,
IRC 채널을 방문하거나 sir@cmpwn.com으로 이메일을 보내 상담 받으세요.
### 소스를 통한 컴파일
다음 의존 패키지들을 설치해 주세요:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (선택: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (선택: man pages) \*
* git \*
_\*컴파일 떄 필요_
다음 명령을 실행하세요:
meson build
ninja -C build
sudo ninja -C build install
## 설정
i3를 이미 사용 중이라면, i3 config을 `~/.config/sway/config`로 복사하세요.
아니면, 샘플 구성 파일을 '~/.config/sway/config'에 복사할 수도 있습니다.
일반적으로 "/etc/sway/config"에 위치해 있습니다.
설정에 대한 정보를 보려면 "man 5 sway"를 실행하세요.
## 실행
TTY에서 `sway`를 실행하세요. 일부 display manager는 작동하지만, sway로 부터 지원되지 않습니다(gdm은 상당히 잘 작동한다고 알려져 있습니다).

115
README.md
View File

@ -1,84 +1,48 @@
# sway
[**English**](https://github.com/swaywm/sway/blob/master/README.md#sway--) - [日本語](https://github.com/swaywm/sway/blob/master/README.ja.md#sway--) - [Deutsch](https://github.com/swaywm/sway/blob/master/README.de.md#sway--) - [Ελληνικά](https://github.com/swaywm/sway/blob/master/README.el.md#sway--) - [Français](https://github.com/swaywm/sway/blob/master/README.fr.md#sway--) - [Українська](https://github.com/swaywm/sway/blob/master/README.uk.md#sway--) - [Italiano](https://github.com/swaywm/sway/blob/master/README.it.md#sway--) - [Português](https://github.com/swaywm/sway/blob/master/README.pt.md#sway--) -
[Русский](https://github.com/swaywm/sway/blob/master/README.ru.md#sway--)
**[English][en]** - [عربي][ar] - [Česky][cs] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [ქართული][ge] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Norsk][no] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Svenska][sv] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]
"**S**irCmpwn's **Way**land compositor" is a **work in progress**
i3-compatible [Wayland](http://wayland.freedesktop.org/) compositor.
Read the [FAQ](https://github.com/swaywm/sway/wiki). Join the
[IRC channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on
irc.freenode.net).
**Notice**: You are viewing the **unstable** and **unsupported** master branch
of sway, where work is ongoing to port it to
[wlroots](https://github.com/swaywm/wlroots). The supported branch is the 0.15
branch, and end users are encouraged to use the stable releases cut from it.
If you'd like to support sway development, please contribute to [SirCmpwn's
Patreon page](https://patreon.com/sircmpwn).
sway is an [i3]-compatible [Wayland] compositor. Read the [FAQ]. Join the
[IRC channel] \(#sway on irc.libera.chat).
## Release Signatures
Releases are signed with [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
and published [on GitHub](https://github.com/swaywm/sway/releases).
## Status
- [i3 feature support](https://github.com/swaywm/sway/issues/2)
- [IPC feature support](https://github.com/swaywm/sway/issues/98)
- [i3bar feature support](https://github.com/swaywm/sway/issues/343)
- [i3-gaps feature support](https://github.com/swaywm/sway/issues/307)
- [security features](https://github.com/swaywm/sway/issues/984)
Releases are signed with [E88F5E48] and published [on GitHub][GitHub releases].
## Installation
### From Packages
Sway is available in many distributions. Try installing the "sway" package for
yours. If it's not available, check out [this wiki page](https://github.com/swaywm/sway/wiki/Unsupported-packages)
for information on installation for your distributions.
If you're interested in packaging sway for your distribution, stop by the IRC
channel or shoot an email to sir@cmpwn.com for advice.
yours.
### Compiling from Source
Check out [this wiki page][Development setup] if you want to build the HEAD of
sway and wlroots for testing or development.
Install dependencies:
* meson
* [wlroots](https://github.com/swaywm/wlroots)
* meson \*
* [wlroots]
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* dbus >= 1.10 ***
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
* gdk-pixbuf2 (optional: additional image formats for system tray)
* [swaybg] (optional: wallpaper)
* [scdoc] (optional: man pages) \*
* git (optional: version info) \*
_\*Only required for swaybar, swaybg, and swaylock_
_\*\*Only required for swaylock_
_\*\*\*Only required for tray support_
_\* Compile-time dep_
Run these commands:
meson build
ninja -C build
sudo ninja -C build install
On systems with logind, you need to set a few caps on the binary:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
On systems without logind, you need to suid the sway binary:
sudo chmod a+s /usr/local/bin/sway
meson build/
ninja -C build/
sudo ninja -C build/ install
## Configuration
@ -91,3 +55,40 @@ Run `man 5 sway` for information on the configuration.
Run `sway` from a TTY. Some display managers may work but are not supported by
sway (gdm is known to work fairly well).
[en]: https://github.com/swaywm/sway#readme
[ar]: README.ar.md
[cs]: README.cs.md
[de]: README.de.md
[dk]: README.dk.md
[es]: README.es.md
[fr]: README.fr.md
[ge]: README.ge.md
[gr]: README.gr.md
[hi]: README.hi.md
[hu]: README.hu.md
[ir]: README.ir.md
[it]: README.it.md
[ja]: README.ja.md
[ko]: README.ko.md
[nl]: README.nl.md
[no]: README.no.md
[pl]: README.pl.md
[pt]: README.pt.md
[ro]: README.ro.md
[ru]: README.ru.md
[sv]: README.sv.md
[tr]: README.tr.md
[uk]: README.uk.md
[zh-CN]: README.zh-CN.md
[zh-TW]: README.zh-TW.md
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[swaybg]: https://github.com/swaywm/swaybg/
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

57
README.nl.md Normal file
View File

@ -0,0 +1,57 @@
# sway
Sway is een [i3](https://i3wm.org/)-compatibele [Wayland](http://wayland.freedesktop.org/) compositor.
Lees de [FAQ](https://github.com/swaywm/sway/wiki). Word lid van het [IRC
kanaal](https://web.libera.chat/gamja/?channels=#sway) (#sway op
irc.libera.chat).
## Releasehandtekeningen
Releases worden ondertekend met [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
en gepubliceerd [op GitHub](https://github.com/swaywm/sway/releases).
## Installatie
### Via een pakket
Sway is beschikbaar in vele distributies. Probeer het "sway"-pakket te installeren met jouw pakketbeheerapplicatie. Als het niet beschikbaar is, bekijk dan [deze wikipagina](https://github.com/swaywm/sway/wiki/Unsupported-packages)
voor informatie over installatie in jouw distributie.
Als je geïnteresseerd bent in het maken van pakketten voor je distributie, stuur een bericht in het IRC-
kanaal of stuur een e-mail naar sir@cmpwn.com voor advies.
### Compilatie vanuit broncode
Afhankelijkheden installeren:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (optioneel: systeemtray)
* [scdoc](https://git.sr.ht/~ircmpwn/scdoc) (optioneel: manpagina's) \*
* git \*
_\* Compileerafhankelijkheden_
Voer deze opdrachten uit:
meson build
ninja -C build
sudo ninja -C build install
## Configuratie
Als je al i3 gebruikt, kopieer dan je i3-configuratie naar `~/.config/sway/config` en
het zal zonder verdere configuratie werken. Kopieer anders het voorbeeldconfiguratiebestand naar
`~/.config/sway/config`. Dit is meestal het bestand: `/etc/sway/config`.
Voer `man 5 sway` uit voor informatie over het configureren van sway.
## Uitvoeren
Voer `sway` vanaf een TTY uit. Sommige display-managers kunnen werken, maar worden niet ondersteund door
sway (van gdm is bekend dat het redelijk goed werkt).

68
README.no.md Normal file
View File

@ -0,0 +1,68 @@
# Sway
Sway er en [i3]-kompatibel [Wayland] compositor. Les [Ofte stilte spørsmål].
Delta på [IRC kanalen][IRC kanal] \(#sway på irc.libera.chat).
## Utgivelses Signaturer
Utgivelser er signert med [E88F5E48] og publisert [på GitHub][GitHub
releases].
## Installasjon
### Fra system pakker
Sway er tilgjengelig i mange distribusjoner. Prøv å installere "sway" pakken
fra din distro sine repoer.
Er du interessert i å pakke Sway for din distribusjon kan du ta turen innom
IRC-kanalen eller send en e-post til sir@cmpwn.com for råd.
### Kompilering fra kildekode
Se [denne wiki-siden][Oppsetting for utvikling] hvis du vil bygge fra HEAD grenen av sway og
wlroots for testing eller utvikling.
Installasjonsavhengigheter:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (valgfritt: system tray)
* [scdoc] (valgfritt: man pages) \*
* git \*
_\*Kompileringsavhengigheter_
Kjør følgende kommandoer:
meson build
ninja -C build
sudo ninja -C build install
## Konfigurasjon
Hvis du allerede bruker i3 kan du bare kopiere din i3 konfigurasjon til
`~/.config/sway/config`. Ellers skal du kopiere eksempel konfigurasjonsfilen til
`~/.config/sway/config`. Eksempel filen er normalt plasert i `/etc/sway/config`. Kjør
`man 5 sway` for å få oplysninger om konfigurasjonen.
## Utførelse
Kjør `sway` fra en TTY. Noen display managers kan fungere, men Sway har ikke
støtte for dem (gdm er kjent for å fungere ganske bra).
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[Ofte stilte spørsmål]: https://github.com/swaywm/sway/wiki
[IRC kanal]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Oppsetting for utvikling]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

57
README.pl.md Normal file
View File

@ -0,0 +1,57 @@
# sway
sway jest kompozytorem [Wayland](http://wayland.freedesktop.org/) kompatybilnym z [i3](https://i3wm.org/).
Przeczytaj [FAQ](https://github.com/swaywm/sway/wiki). Dołącz do [kanału IRC](https://web.libera.chat/gamja/?channels=#sway)
(#sway na irc.libera.chat).
## Podpisy cyfrowe wydań
Wydania są podpisywane przy pomocy klucza [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
i publikowane [na GitHubie](https://github.com/swaywm/sway/releases).
## Instalacja
### Z pakietów
Sway jest dostępny w wielu dystybucjach. Spróbuj zainstalować pakiet "sway" w swoim
menedżerze pakietów. Jeśli nie jest dostępny, sprawdź [tę stronę wiki](https://github.com/swaywm/sway/wiki/Unsupported-packages)
aby uzyskać informacje dotyczące instalacji w swojej dystrybucji.
Jeśli chciałbyś stworzyć pakiet sway dla swojej dystrybucji, odwiedź kanał IRC lub wyślij email na
adres sir@cmpwn.com w celu uzyskania wskazówek.
### Kompilacja ze Źródła
Zainstaluj zależności:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (opcjonalnie: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (opcjonalnie: strony pomocy man) \*
* git \*
_\*zależności kompilacji_
Wykonaj następujące polecenia:
meson build
ninja -C build
sudo ninja -C build install
## Konfiguracja
Jeśli już korzystasz z i3, skopiuj swoją konfigurację i3 do katalogu `~/.config/sway/config` i
zadziała od ręki. W przeciwnym razie skopiuj przykładowy plik konfiguracyjny do folderu
`~/.config/sway/config`; zazwyczaj znajduje się w `/etc/sway/config`.
Wykonaj polecenie `man 5 sway` aby uzyskać informacje dotyczące konfiguracji.
## Uruchamianie
Wykonaj polecenie `sway` z poziomu TTY. Niektóre menedżery wyświetlania mogą umożliwiać rozruch z ich
poziomu, ale nie jest to wspierane przez sway (w gdm podobno działa to całkiem nieźle).

View File

@ -1,101 +1,59 @@
# sway
"**S**irCmpwn's **Way**land compositor" é um compositor [Wayland](http://wayland.freedesktop.org/)
compatível com o i3. Leia o [FAQ](https://github.com/swaywm/sway/wiki). Participe do
[canal IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway no
irc.freenode.net).
O sway é um compositor do [Wayland](http://wayland.freedesktop.org/) compatível com o [i3](https://i3wm.org/).
Leia o [FAQ](https://github.com/swaywm/sway/wiki). Junte-se ao [canal do
IRC](https://web.libera.chat/gamja/?channels=#sway) (#sway em
irc.libera.chat).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
## Assinatura das versões
Se você deseja apoiar o desenvolvimento do Sway, você pode contribuir com o
SirCmpwn em sua [página no Patreon](https://patreon.com/sircmpwn) ou você
pode colaborar com [premiações](https://github.com/swaywm/sway/issues/986)
para recursos específicos. Qualquer um pode requerer uma premiação ao implementar
o recurso especificado, e você pode criar uma premiação para qualquer recurso que desejar.
O Patreon é melhor direcionado para a manutenção a longo prazo do Sway.
## Ajuda em português
No momento, o suporte em português no canal do IRC **não está ativo**. Em caso de problemas,
use as [*issues*](https://github.com/swaywm/sway/issues/) do Github (*em inglês*).
A tradução para português é um *trabalho em progresso*, no momento. Caso encontre algum erro
ou queira colaborar com a tradução, visite
[essa *issue*](https://github.com/swaywm/sway/issues/1318) para mais informações e não
exite em enviar quaisquer correções necessárias.
## Assinaturas dos *Releases*
*Releases* são assinadas com a chave
[B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
As versões são assinadas com [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
e publicadas [no GitHub](https://github.com/swaywm/sway/releases).
## Status
- [Suporte aos recursos do i3](https://github.com/swaywm/sway/issues/2)
- [Suporte aos recursos IPC](https://github.com/swaywm/sway/issues/98)
- [Suporte aos recursos do i3bar](https://github.com/swaywm/sway/issues/343)
- [Suporte aos recursos do i3-gaps](https://github.com/swaywm/sway/issues/307)
- [Recursos de segurança](https://github.com/swaywm/sway/issues/984)
## Instalação
### A partir de pacotes
O Sway está disponível em várias distribuições. Tente instalar o pacote "sway"
na sua. Caso não esteja disponível, verifique [esta wiki](https://github.com/swaywm/sway/wiki/Unsupported-packages)
para se informar a sobre a instalação para sua distribuição.
Sway está disponível em várias distribuições. Verifique se o pacote "sway" está
disponível a partir do gerenciador de pacotes da sua distribuição. Caso não esteja,
procure por informações sobre como instalar o Sway na sua distribuição
[aqui](https://github.com/swaywm/sway/wiki/Unsupported-packages).
Se você está interessado em criar um pacote do sway para a sua distribuição, verifique canal do IRC
ou mande um email para sir@cmpwn.com para obter informações.
Se você está interessado em manter um pacote do Sway para a sua distribuição,
visite o canal no IRC ou mande um email para sir@cmpwn.com (*em inglês*).
### Compilando a partir do código-fonte
### A partir do código-fonte
Verifique [essa página da wiki](https://github.com/swaywm/sway/wiki/Development-Setup) se você quer compilar o HEAD do sway e o wlroots para testes ou desenvolvimento.
Antes de iniciar a compilação, instale as dependências:
Instale as dependências:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (man pages)
* gdk-pixbuf2 (opcional: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (opcional: man pages) \*
* git (opcional: informações de versão) \*
_\*Dependência apenas de swaybar, swaybg, e swaylock_
_\*Dependência de tempo de compilação_
_\*\*Dependência apenas de swaylock_
Para compilar, execute estes comandos:
Execute esses comandos:
meson build
ninja -C build
sudo ninja -C build install
Em sistemas com logind, configure as seguintes capacidades para o arquivo binário:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
Em sistemas sem logind, ative a *flag* de *suid* do arquivo binário:
sudo chmod a+s /usr/local/bin/sway
## Configuração
Se você já usa o i3, copie o arquivo de configuração do i3 para `~/.config/sway/config`;
o Sway lerá o arquivo normalmente. Senão, copie o arquivo de configuração de exemplo
para `~/.config/sway/config`. É comum esse arquivo estar localizado em
`/etc/sway/config`. Veja `man 5 sway` para informações sobre configuração.
Se você já utiliza o i3, então copie os seus arquivos de configuração para `~/.config/sway/config` e
tudo funcionará normalmente. Caso contrário, copie o arquivo de configuração de exemplo para
`~/.config/sway/config`. Normalmente, este arquivo está localizado em `/etc/sway/config`.
Execute `man 5 sway` para se informar sobre a configuração.
## Executando
Execute `sway` a partir de um terminal do Linux. Alguns gerenciadores de *display*
podem funcionar, porém o Sway não procura manter compatibilidade com esses (segundo
relatos, o gdm funciona bem com o Sway).
## Execução
Execute o comando `sway` de um TTY. Alguns gerenciadores de display (ou gerenciadores de login) podem funcionar mas alguns não são suportados
pelo sway (o gdm é conhecido por funcionar bem).

53
README.ro.md Normal file
View File

@ -0,0 +1,53 @@
# sway
sway este un compositor pentru [Wayland](http://wayland.freedesktop.org/) compatibil cu [i3](https://i3wm.org/).
Citiți [FAQ](https://github.com/swaywm/sway/wiki)-ul. Connectați-vă la canalul nostru [IRC](https://web.libera.chat/gamja/?channels=#sway) (#sway pe irc.libera.chat).
## Semnarea digitală
Noile versiuni sunt semnate cu [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
și postate [pe GitHub](https://github.com/swaywm/sway/releases).
## Instalare
### Din pachete (packages)
sway este disponibil în multe distribuții. Încercați să instalați pachetul "sway" pe distribuția voastră. Dacă nu este disponibil, uitați-vă în [această pagină wiki](https://github.com/swaywm/sway/wiki/Unsupported-packages)
pentru informații a cum puteți să instalați pentru distribuția voastră.
Dacă sunteți interesați in a crea pachete pentru distribuția voastră, informați-ne prin IRC sau contactați prin email pe sir@cmpwn.com pentru ajutor.
### Compilare din sursă
Dependențe pentru instalare:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (opțional, dacă doriți să aveți system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (opțional, pentru paginile man) \*
* git (opțional, pentru informații de versiune) \*
*Dependențe doar pentru compilare*
Rulați aceste comenzi:
```
meson build
ninja -C build
sudo ninja -C build install
```
## Configurare
Dacă folosiți deja i3, copiați fișierul de configurare din i3 în `~/.config/sway/config`, și va funcționa fără a necesita nici o modificare. In caz contrar, copiați exemplul de configurare (disponibil de obicei în `/etc/sway/config`) în `~/.config/sway/config`.
Folosiți comanda `man 5 sway` pentru informații despre configurare.
## Lansare
Folosiți comanda `sway` într-un TTY. Managerii de display nu sunt suportați de către Sway, dar unii pot functiona (se știe că gdm functioneazâ destul de bine).

View File

@ -1,95 +1,68 @@
# sway
"**S**irCmpwn's **Way**land compositor" на данный момент **(в разработке)**
i3-совместимый [Wayland](http://wayland.freedesktop.org/) композитор.
Прочитайте [FAQ](https://github.com/swaywm/sway/wiki). Присоединяйтесь к
[IRC каналу](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на
irc.freenode.net).
sway - это [i3]-совместимый композитор [Wayland].
Больше информации в [FAQ]. Присоединяйтесь к
[IRC-каналу][IRC channel] (#sway на
irc.libera.chat).
**Внимание**: на данный момент ведется активная интеграция wlroots, в связи с чем разработка sway приостановлена, однако патчи продолжают приниматься.
## Подписи релизов
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
При желании поддержать разработку Sway вы можете пожертвовать [автору
на его Patreon странице](https://patreon.com/sircmpwn) или взяться
за разработку определённых целей в обмен на [награду](https://github.com/swaywm/sway/issues/986).
Вы также можете объявить свою награду за определённую цель и больше всего для этого подходит Patreon.
## Помощь
DarkReef оказывает поддержку на русском языке в IRC канале и на GitHub в часовом поясе UTC +05:00.
Если у вас есть желание помочь с переводом на русский язык, то, пожалуйста, ознакомьтесь с [подсказками для переводчиков](https://github.com/swaywm/sway/issues/1318). На этой же странице можно узнать [статус перевода](https://github.com/swaywm/sway/issues/1318#issuecomment-326913020).
## Подпись версий
Версии подписаны ключом [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
и опубликованы [на GitHub'е](https://github.com/swaywm/sway/releases).
## Статус
- [Поддержка i3](https://github.com/swaywm/sway/issues/2)
- [Поддержка i3-bar](https://github.com/swaywm/sway/issues/343)
- [Поддержка i3-gaps](https://github.com/swaywm/sway/issues/307)
- [Поддержка IPC](https://github.com/swaywm/sway/issues/98)
- [Безопасность](https://github.com/swaywm/sway/issues/984)
Релизы подписываются ключом [E88F5E48] и публикуются [на GitHub][GitHub releases].
## Установка
### Из пакета
### Из репозиториев
Sway доступен во многих дистрибутивах и находится в официальных репозиториях. Попробуйте установить "sway" через ваш пакетный менеджер.
В случае, если это не представляется возможным, то обратитесь к [этой странице](https://github.com/swaywm/sway/wiki/Unsupported-packages)
для получения инструкций по установке для вашего дистрибутива.
Sway доступен во многих дистрибутивах. Попробуйте установить пакет "sway".
Если вы заинтересованы в создании пакета "sway" в вашем дистрибутиве, то сообщите об этом в IRC
канале или отправьте письмо [sir@cmpwn.com](mailto:sir@cmpwn.com).
Если вас интересует создание пакета sway для вашего дистрибутива, зайдите на [IRC-канал][IRC channel]
или отправьте письмо на sir@cmpwn.com за советом.
### Сборка из исходников
Установите следующие пакеты:
Посетите [эту страницу на вики][Development setup], если вы хотите построить последнюю версию
sway и wlroots для тестирования или разработки.
* meson
* [wlc](https://github.com/Cloudef/wlc)
Установите зависимости:
* meson \*
* [wlroots]
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* dbus >= 1.10 ***
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
* gdk-pixbuf2 (опционально: для работы трея)
* [scdoc] (опционально: для man-страниц) \*
* git (опционально: для информации о версии) \*
_\*Требуется только для swaybar, swaybg и swaylock_
_\*Зависимости для сборки_
_\*\*Требуется только для swaylock_
_\*\*\*Требуется только для tray_
Выполните следующие команды:
Выполните эти команды:
meson build
ninja -C build
sudo ninja -C build install
Если у вас logind:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
Иначе:
sudo chmod a+s /usr/local/bin/sway
## Настройка
Если вы уже используете i3, тогда просто скопируйте ваш конфиг в `~/.config/sway/config`.
В любом другом случае, скопируйте `/etc/sway/config` в `~/.config/sway/config`.
Для более детальной информации о настройке: `man 5 sway`.
Если вы уже используете i3, скопируйте ваш конфигурационный файл i3 в `~/.config/sway/config`, и
он сразу же заработает. В противном случае, скопируйте образец конфигурационного файла в
`~/.config/sway/config`. Обычно он располагается в `/etc/sway/config`.
Запустите `man 5 sway` для изучения информации о настройке.
## Запуск
Выполните 'sway' в терминале. **Некоторые** менеджеры сессий могут работать, но не поддерживаются sway (к примеру, gdm работает со sway без проблем).
Выполните команду `sway` прямо из TTY. Некоторые дисплейные менеджеры могут работать, но они не поддерживаются со стороны
sway (gdm работает довольно неплохо).
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

83
README.sv.md Normal file
View File

@ -0,0 +1,83 @@
# sway
[English][en] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - **[Svenska][sv]** - [Ελληνικά][gr] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]
sway är en [i3]-kompatibel [Wayland] compositor. Läs våran [FAQ]-sida. Gå med i vår
[IRC-kanal] \(#sway på irc.libera.chat).
## Utgåvosignaturer
Utgåvor är signerade med [E88F5E48] och publicerade på [GitHub][GitHub releases].
## Installering
### Med pakethanterare
Sway är tillgänglig i många distributioner. Prova att installera "sway" med din distributions pakethanterare.
### Genom att kompilera från källkod
Kolla in [denna wiki-sida][Development setup] om du vill bygga sway och wlroots HEAD för testning eller utveckling.
Installera paket som sway behöver:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (valbar: systembricka)
* [scdoc] (valbar: manualer) \*
* git (valbar: versioninfo) \*
_\* Krav för kompilering_
Kör dessa kommandon:
meson build/
ninja -C build/
sudo ninja -C build/ install
## Konfiguration
Ifall du redan använder i3 så kan du kopiera din konfigurationsfil till `~/.config/sway/config` och det kommer då att fungera som det ska.
Kopiera annars exemplarkonfigurationsfilen till `~/.config/sway/config`. Den ligger oftast i `/etc/sway/config`.
Kör `man 5 sway` för mer information kring konfigurationen.
## Att köra sway
Kör `sway` från en TTY. Vissa inloggningahanterare kan fungera men inte vara stödda av sway (gdm ska fungera hyfsat bra).
[en]: https://github.com/swaywm/sway#readme
[de]: README.de.md
[dk]: README.dk.md
[es]: README.es.md
[fr]: README.fr.md
[sv]: README.sv.md
[gr]: README.gr.md
[hu]: README.hu.md
[ir]: README.ir.md
[it]: README.it.md
[ja]: README.ja.md
[ko]: README.ko.md
[nl]: README.nl.md
[pl]: README.pl.md
[pt]: README.pt.md
[ro]: README.ro.md
[ru]: README.ru.md
[tr]: README.tr.md
[uk]: README.uk.md
[zh-CN]: README.zh-CN.md
[zh-TW]: README.zh-TW.md
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC-kanal]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

62
README.tr.md Normal file
View File

@ -0,0 +1,62 @@
# sway
Sway, [i3]-uyumlu bir [Wayland] dizgicisidir. [SSS][FAQ]'yi okuyun.
[IRC kanalı][IRC channel]na katılın \(irc.libera.chat'te #sway (İngilizce)).
## Sürüm imzaları
Sürümler [E88F5E48] ile imzalandı ve [GitHub][GitHub releases]'da yayınlandı.
## Kurulum
### Paketler ile
Sway birçok dağıtımda mevcuttur. Sizinki için "sway" paketini yüklemeyi deneyin.
Dağıtımınız için sway'i paketlemekle ilgileniyorsanız, IRC kanalına uğrayın veya tavsiye için sir@cmpwn.com adresine bir e-posta gönderin.
### Kaynak koddan derleme
Test veya geliştirme için sway ve wlroots'un HEAD'ini oluşturmak istiyorsanız [bu wiki sayfası][Development setup]na göz atın.
Aşağıdaki bağımlılıkları yükleyin:
* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (isteğe bağlı: system tray)
* [scdoc] (isteğe bağlı: man pages) \*
* git (isteğe bağlı: version info) \*
_\*Derleme-anı bağımlılıkları_
Şu komutları çalıştırın:
meson build
ninja -C build
sudo ninja -C build install
## Yapılandırma
Zaten i3 kullanıyorsanız, i3 yapılandırmanızı `~/.config/sway/config` konumuna kopyalayın ve kutudan çıktığı gibi çalışacaktır. Aksi takdirde, örnek yapılandırma dosyasını `~/.config/sway/config` konumuna kopyalayın. Genellikle `/etc/sway/config` konumunda bulunur.
Yapılandırma hakkında bilgi almak için `man 5 sway` komutunu çalıştırın.
## Çalıştırma
TTY'den `sway` çalıştırın. Bazı görüntü yöneticileriyle(display manager) çalışabilir ama Sway tarafından desteklenmez. (gdm'nin oldukça iyi çalıştığı bilinmektedir.)
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc

View File

@ -1,20 +1,9 @@
# sway
**Sway** ("**S**irCmpwn's **Way**land compositor") це сумісний з i3 композитор
[Wayland](http://wayland.freedesktop.org/) (**у стані розробки**).
Ознайомтесь з [ЧаПами](https://github.com/swaywm/sway/wiki).
Приєднуйтесь до [спільноти в IRC](http://webchat.freenode.net/?channels=sway&uio=d4)
(#sway на irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
Якщо ви хочете підтримати розробку Sway, ви можете зробити свій внесок у
[SirCmpwn'ову сторінку Patreon](https://patreon.com/sircmpwn) або до
[фонду винагород](https://github.com/swaywm/sway/issues/986) за реалізацію
певного функціоналу.
Кожен може виставити винагороду за реалізацію довільної функції
(і, відповідно, забрати її собі, виконавши це завдання);
кошти від сторінки Patreon підтримують загальну розробку та підтримку Sway.
Sway це сумісний з [i3](https://i3wm.org/) композитор [Wayland](http://wayland.freedesktop.org/).
Ознайомтесь з [ЧаПами](https://github.com/swaywm/sway/wiki). Приєднуйтесь до [спільноти в
IRC](https://web.libera.chat/gamja/?channels=#sway) (#sway на
irc.libera.chat).
## Підтримка українською мовою
@ -26,17 +15,9 @@ Hummer12007 у IRC-спільноті. Будьте терплячі, вам о
## Підписи випусків
Випуски підписані ключем [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
Випуски підписані ключем [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)
та публікуються на сторінці [GitHub](https://github.com/swaywm/sway/releases).
## Стан розробки
- [Підтримка функцій i3](https://github.com/swaywm/sway/issues/2)
- [Реалізація IPC-протоколу i3](https://github.com/swaywm/sway/issues/98)
- [Підтримка функцій i3bar](https://github.com/swaywm/sway/issues/343)
- [Підтримка функцій i3-gaps](https://github.com/swaywm/sway/issues/307)
- [Функції безпеки](https://github.com/swaywm/sway/issues/984)
## Встановлення
### З пакунків
@ -47,30 +28,26 @@ Sway доступний у багатьох дистрибутивах Linux (а
для інформації щодо встановлення на вашому дистрибутиві.
Якщо ви готові та зацікавлені запакувати і підтримувати Sway у вашому
дистрибутиві, будемо раді вас бачити у нашому каналі IRC. Ви також можете
спитати порад за адресою sir@cmpwn.com.
дистрибутиві, звертайтесь за порадами до нашого каналу в IRC або
пишіть на електронну пошту [sir@cmpwn.com](mailto:sir@cmpwn.com).
### З вихідного коду
Встановіть залежності:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 *
* pam **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
* gdk-pixbuf2 (optional: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (необов'язково, необхідно для сторінок man) \*
* git \*
_\*Лише для swaybar, swaybg та swaylock_
_\*\*Лише для swaylock_
_\*Лише для компіляції_
Виконайте ці команди:
@ -78,15 +55,6 @@ _\*\*Лише для swaylock_
ninja -C build
sudo ninja -C build install
На системах **з** logind, варто встановити декілька можливостей (caps)
на виконуваний файл sway:
sudo setcap "cap_sys_ptrace,cap_sys_tty_config=eip" /usr/local/bin/sway
На системах **без** logind, необхідно встановити біт SUID на виконуваний файл sway:
sudo chmod a+s /usr/local/bin/sway
## Налаштування
Якщо ви вже використовуєте i3, скопіюйте свій файл налаштувань

50
README.zh-CN.md Normal file
View File

@ -0,0 +1,50 @@
# sway
sway 是和 [i3](https://i3wm.org/) 兼容的 [Wayland](http://wayland.freedesktop.org/) compositor。
[查看FAQ](https://github.com/swaywm/sway/wiki)/ [加入IRC频道](https://web.libera.chat/gamja/?channels=#sway) (#sway on irc.libera.chat)
## 发行签名
每个发行版都以 [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48) 的密钥签名并发布在 [GitHub](https://github.com/swaywm/sway/releases)上。
## 安装
### 从包管理器安装
Sway 在很多发行版中可用。请尝试在你的发行版中安装 `sway`
### 从源码编译
如果想要构建最新版sway和wlroots用以测试和开发请查看 [此wiki页面](https://github.com/swaywm/sway/wiki/Development-Setup)
安装如下依赖:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (可选的: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (可选: man pages) \*
* git \*
_\*编译时依赖_
运行如下命令:
meson build/
ninja -C build/
sudo ninja -C build/ install
## 配置
如果你已经在使用i3直接复制i3配置文件到 `~/.config/sway/config`,这是开箱即用的。或者,你可以复制配置样例到`~/.config/sway/config`。它通常位于 `/etc/sway/config`
运行 `man 5 sway` 获取关于配置的更多信息。
## 运行
从 TTY 中运行 `sway`。 某些显示管理器Display Manager也许可以工作但不被 sway 支持。
(已知 gdm 工作得非常好)。

55
README.zh-TW.md Normal file
View File

@ -0,0 +1,55 @@
# sway
sway 是一個與 [i3](https://i3wm.org/) 相容的 [Wayland](http://wayland.freedesktop.org/) compositor。
閱讀 [FAQ](https://github.com/swaywm/sway/wiki)。 加入 [IRC
頻道](https://web.libera.chat/gamja/?channels=#sway) (#sway on
irc.libera.chat)
## 發行簽章
所有發行的版本都會以 [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48) 簽署
並發佈於 [GitHub](https://github.com/swaywm/sway/releases)
## 安裝
### 從套件安裝
Sway 在許多發行版都有提供。請自己嘗試於你的發行版安裝 「sway」這個套件。
如果無法取得,請查看 [這個 wiki 頁面](https://github.com/swaywm/sway/wiki/Unsupported-packages)
以取得更多關於如何於你使用的發行版上安裝的資訊。
如果你想要為你使用的發行版包裝 sway請到 IRC 頻道或是直接寄封信到 sir@cmpwn.com 來取得一些建議。
### 從原始碼編譯
相依套件:
* meson \*
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (選擇性: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (選擇性: man pages) \*
* git \*
_\*編譯時相依_
執行這些指令:
meson build
ninja -C build
sudo ninja -C build install
## 設定檔
如果你已經在使用 i3你可以直接將你的 i3 設定檔複製到 `~/.config/sway/config` 然後就能直接使用。
或者你也可以把範例設定檔複製到 `~/.config/sway/config`。 它通常會在 `/etc/sway/config`
執行 `man 5 sway` 來取得更多關於設定檔的資訊。
## 執行
在 TTY 執行 `sway`。有些 display manager 可能可以運作但 sway 不提供支援 (已知 gdm 運作的很好)

121
assets/LICENSE Normal file
View File

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

View File

@ -5,11 +5,9 @@ lib_sway_client = static_library(
),
dependencies: [
cairo,
gdk_pixbuf,
pango,
pangocairo,
wlroots,
wayland_client,
wayland_client
],
link_with: [lib_sway_common],
include_directories: sway_inc

View File

@ -1,62 +1,42 @@
#define _XOPEN_SOURCE 500
#include <assert.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <errno.h>
#include <fcntl.h>
#include <pango/pangocairo.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
#include <wayland-client.h>
#include "config.h"
#include "pool-buffer.h"
#include "util.h"
static bool set_cloexec(int fd) {
long flags = fcntl(fd, F_GETFD);
if (flags == -1) {
return false;
}
static int anonymous_shm_open(void) {
int retries = 100;
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
return false;
}
do {
// try a probably-unique name
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
pid_t pid = getpid();
char name[50];
snprintf(name, sizeof(name), "/sway-%x-%x",
(unsigned int)pid, (unsigned int)ts.tv_nsec);
return true;
}
// shm_open guarantees that O_CLOEXEC is set
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (fd >= 0) {
shm_unlink(name);
return fd;
}
static int create_pool_file(size_t size, char **name) {
static const char template[] = "sway-client-XXXXXX";
const char *path = getenv("XDG_RUNTIME_DIR");
if (path == NULL) {
fprintf(stderr, "XDG_RUNTIME_DIR is not set\n");
return -1;
}
--retries;
} while (retries > 0 && errno == EEXIST);
size_t name_size = strlen(template) + 1 + strlen(path) + 1;
*name = malloc(name_size);
if (*name == NULL) {
fprintf(stderr, "allocation failed\n");
return -1;
}
snprintf(*name, name_size, "%s/%s", path, template);
int fd = mkstemp(*name);
if (fd < 0) {
return -1;
}
if (!set_cloexec(fd)) {
close(fd);
return -1;
}
if (ftruncate(fd, size) < 0) {
close(fd);
return -1;
}
return fd;
return -1;
}
static void buffer_release(void *data, struct wl_buffer *wl_buffer) {
@ -74,18 +54,20 @@ static struct pool_buffer *create_buffer(struct wl_shm *shm,
uint32_t stride = width * 4;
size_t size = stride * height;
char *name;
int fd = create_pool_file(size, &name);
assert(fd != -1);
int fd = anonymous_shm_open();
if (fd == -1) {
return NULL;
}
if (ftruncate(fd, size) < 0) {
close(fd);
return NULL;
}
void *data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
struct wl_shm_pool *pool = wl_shm_create_pool(shm, fd, size);
buf->buffer = wl_shm_pool_create_buffer(pool, 0,
width, height, stride, format);
wl_shm_pool_destroy(pool);
close(fd);
unlink(name);
free(name);
fd = -1;
buf->size = size;
buf->width = width;

View File

@ -1,119 +0,0 @@
#include <assert.h>
#include <stdbool.h>
#include <wlr/util/log.h>
#include "background-image.h"
#include "cairo.h"
enum background_mode parse_background_mode(const char *mode) {
if (strcmp(mode, "stretch") == 0) {
return BACKGROUND_MODE_STRETCH;
} else if (strcmp(mode, "fill") == 0) {
return BACKGROUND_MODE_FILL;
} else if (strcmp(mode, "fit") == 0) {
return BACKGROUND_MODE_FIT;
} else if (strcmp(mode, "center") == 0) {
return BACKGROUND_MODE_CENTER;
} else if (strcmp(mode, "tile") == 0) {
return BACKGROUND_MODE_TILE;
} else if (strcmp(mode, "solid_color") == 0) {
return BACKGROUND_MODE_SOLID_COLOR;
}
wlr_log(WLR_ERROR, "Unsupported background mode: %s", mode);
return BACKGROUND_MODE_INVALID;
}
cairo_surface_t *load_background_image(const char *path) {
cairo_surface_t *image;
#ifdef HAVE_GDK_PIXBUF
GError *err = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
if (!pixbuf) {
wlr_log(WLR_ERROR, "Failed to load background image (%s).",
err->message);
return false;
}
image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
#else
image = cairo_image_surface_create_from_png(path);
#endif //HAVE_GDK_PIXBUF
if (!image) {
wlr_log(WLR_ERROR, "Failed to read background image.");
return NULL;
}
if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
wlr_log(WLR_ERROR, "Failed to read background image: %s."
#ifndef HAVE_GDK_PIXBUF
"\nSway was compiled without gdk_pixbuf support, so only"
"\nPNG images can be loaded. This is the likely cause."
#endif //HAVE_GDK_PIXBUF
, cairo_status_to_string(cairo_surface_status(image)));
return NULL;
}
return image;
}
void render_background_image(cairo_t *cairo, cairo_surface_t *image,
enum background_mode mode, int buffer_width, int buffer_height) {
double width = cairo_image_surface_get_width(image);
double height = cairo_image_surface_get_height(image);
switch (mode) {
case BACKGROUND_MODE_STRETCH:
cairo_scale(cairo,
(double)buffer_width / width,
(double)buffer_height / height);
cairo_set_source_surface(cairo, image, 0, 0);
break;
case BACKGROUND_MODE_FILL: {
double window_ratio = (double)buffer_width / buffer_height;
double bg_ratio = width / height;
if (window_ratio > bg_ratio) {
double scale = (double)buffer_width / width;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
0, (double)buffer_height / 2 / scale - height / 2);
} else {
double scale = (double)buffer_height / height;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 / scale - width / 2, 0);
}
break;
}
case BACKGROUND_MODE_FIT: {
double window_ratio = (double)buffer_width / buffer_height;
double bg_ratio = width / height;
if (window_ratio > bg_ratio) {
double scale = (double)buffer_height / height;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 / scale - width / 2, 0);
} else {
double scale = (double)buffer_width / width;
cairo_scale(cairo, scale, scale);
cairo_set_source_surface(cairo, image,
0, (double)buffer_height / 2 / scale - height / 2);
}
break;
}
case BACKGROUND_MODE_CENTER:
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 - width / 2,
(double)buffer_height / 2 - height / 2);
break;
case BACKGROUND_MODE_TILE: {
cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image);
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source(cairo, pattern);
break;
}
case BACKGROUND_MODE_SOLID_COLOR:
case BACKGROUND_MODE_INVALID:
assert(0);
break;
}
cairo_paint(cairo);
}

View File

@ -1,9 +1,6 @@
#include <stdint.h>
#include <cairo/cairo.h>
#include "cairo.h"
#ifdef HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif
#include <cairo.h>
#include "cairo_util.h"
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
cairo_set_source_rgba(cairo,
@ -13,6 +10,22 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
(color >> (0*8) & 0xFF) / 255.0);
}
cairo_subpixel_order_t to_cairo_subpixel_order(enum wl_output_subpixel subpixel) {
switch (subpixel) {
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB:
return CAIRO_SUBPIXEL_ORDER_RGB;
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR:
return CAIRO_SUBPIXEL_ORDER_BGR;
case WL_OUTPUT_SUBPIXEL_VERTICAL_RGB:
return CAIRO_SUBPIXEL_ORDER_VRGB;
case WL_OUTPUT_SUBPIXEL_VERTICAL_BGR:
return CAIRO_SUBPIXEL_ORDER_VBGR;
default:
return CAIRO_SUBPIXEL_ORDER_DEFAULT;
}
return CAIRO_SUBPIXEL_ORDER_DEFAULT;
}
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
int width, int height) {
int image_width = cairo_image_surface_get_width(image);
@ -29,99 +42,3 @@ cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
cairo_destroy(cairo);
return new;
}
#ifdef HAVE_GDK_PIXBUF
cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf) {
int chan = gdk_pixbuf_get_n_channels(gdkbuf);
if (chan < 3) {
return NULL;
}
const guint8* gdkpix = gdk_pixbuf_read_pixels(gdkbuf);
if (!gdkpix) {
return NULL;
}
gint w = gdk_pixbuf_get_width(gdkbuf);
gint h = gdk_pixbuf_get_height(gdkbuf);
int stride = gdk_pixbuf_get_rowstride(gdkbuf);
cairo_format_t fmt = (chan == 3) ? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_ARGB32;
cairo_surface_t * cs = cairo_image_surface_create (fmt, w, h);
cairo_surface_flush (cs);
if ( !cs || cairo_surface_status(cs) != CAIRO_STATUS_SUCCESS) {
return NULL;
}
int cstride = cairo_image_surface_get_stride(cs);
unsigned char * cpix = cairo_image_surface_get_data(cs);
if (chan == 3) {
int i;
for (i = h; i; --i) {
const guint8 *gp = gdkpix;
unsigned char *cp = cpix;
const guint8* end = gp + 3*w;
while (gp < end) {
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
cp[0] = gp[2];
cp[1] = gp[1];
cp[2] = gp[0];
#else
cp[1] = gp[0];
cp[2] = gp[1];
cp[3] = gp[2];
#endif
gp += 3;
cp += 4;
}
gdkpix += stride;
cpix += cstride;
}
} else {
/* premul-color = alpha/255 * color/255 * 255 = (alpha*color)/255
* (z/255) = z/256 * 256/255 = z/256 (1 + 1/255)
* = z/256 + (z/256)/255 = (z + z/255)/256
* # recurse once
* = (z + (z + z/255)/256)/256
* = (z + z/256 + z/256/255) / 256
* # only use 16bit uint operations, loose some precision,
* # result is floored.
* -> (z + z>>8)>>8
* # add 0x80/255 = 0.5 to convert floor to round
* => (z+0x80 + (z+0x80)>>8 ) >> 8
* ------
* tested as equal to lround(z/255.0) for uint z in [0..0xfe02]
*/
#define PREMUL_ALPHA(x,a,b,z) \
G_STMT_START { z = a * b + 0x80; x = (z + (z >> 8)) >> 8; } \
G_STMT_END
int i;
for (i = h; i; --i) {
const guint8 *gp = gdkpix;
unsigned char *cp = cpix;
const guint8* end = gp + 4*w;
guint z1, z2, z3;
while (gp < end) {
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
PREMUL_ALPHA(cp[0], gp[2], gp[3], z1);
PREMUL_ALPHA(cp[1], gp[1], gp[3], z2);
PREMUL_ALPHA(cp[2], gp[0], gp[3], z3);
cp[3] = gp[3];
#else
PREMUL_ALPHA(cp[1], gp[0], gp[3], z1);
PREMUL_ALPHA(cp[2], gp[1], gp[3], z2);
PREMUL_ALPHA(cp[3], gp[2], gp[3], z3);
cp[0] = gp[3];
#endif
gp += 4;
cp += 4;
}
gdkpix += stride;
cpix += cstride;
}
#undef PREMUL_ALPHA
}
cairo_surface_mark_dirty(cs);
return cs;
}
#endif //HAVE_GDK_PIXBUF

332
common/gesture.c Normal file
View File

@ -0,0 +1,332 @@
#include "gesture.h"
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "list.h"
#include "log.h"
#include "stringop.h"
const uint8_t GESTURE_FINGERS_ANY = 0;
char *gesture_parse(const char *input, struct gesture *output) {
// Clear output in case of failure
output->type = GESTURE_TYPE_NONE;
output->fingers = GESTURE_FINGERS_ANY;
output->directions = GESTURE_DIRECTION_NONE;
// Split input type, fingers and directions
list_t *split = split_string(input, ":");
if (split->length < 1 || split->length > 3) {
return format_str(
"expected <gesture>[:<fingers>][:direction], got %s",
input);
}
// Parse gesture type
if (strcmp(split->items[0], "hold") == 0) {
output->type = GESTURE_TYPE_HOLD;
} else if (strcmp(split->items[0], "pinch") == 0) {
output->type = GESTURE_TYPE_PINCH;
} else if (strcmp(split->items[0], "swipe") == 0) {
output->type = GESTURE_TYPE_SWIPE;
} else {
return format_str("expected hold|pinch|swipe, got %s",
(const char *)split->items[0]);
}
// Parse optional arguments
if (split->length > 1) {
char *next = split->items[1];
// Try to parse as finger count (1-9)
if (strlen(next) == 1 && '1' <= next[0] && next[0] <= '9') {
output->fingers = atoi(next);
// Move to next if available
next = split->length == 3 ? split->items[2] : NULL;
} else if (split->length == 3) {
// Fail here if argument can only be finger count
return format_str("expected 1-9, got %s", next);
}
// If there is an argument left, try to parse as direction
if (next) {
list_t *directions = split_string(next, "+");
for (int i = 0; i < directions->length; ++i) {
const char *item = directions->items[i];
if (strcmp(item, "any") == 0) {
continue;
} else if (strcmp(item, "up") == 0) {
output->directions |= GESTURE_DIRECTION_UP;
} else if (strcmp(item, "down") == 0) {
output->directions |= GESTURE_DIRECTION_DOWN;
} else if (strcmp(item, "left") == 0) {
output->directions |= GESTURE_DIRECTION_LEFT;
} else if (strcmp(item, "right") == 0) {
output->directions |= GESTURE_DIRECTION_RIGHT;
} else if (strcmp(item, "inward") == 0) {
output->directions |= GESTURE_DIRECTION_INWARD;
} else if (strcmp(item, "outward") == 0) {
output->directions |= GESTURE_DIRECTION_OUTWARD;
} else if (strcmp(item, "clockwise") == 0) {
output->directions |= GESTURE_DIRECTION_CLOCKWISE;
} else if (strcmp(item, "counterclockwise") == 0) {
output->directions |= GESTURE_DIRECTION_COUNTERCLOCKWISE;
} else {
return format_str("expected direction, got %s", item);
}
}
list_free_items_and_destroy(directions);
}
} // if optional args
list_free_items_and_destroy(split);
return NULL;
}
const char *gesture_type_string(enum gesture_type type) {
switch (type) {
case GESTURE_TYPE_NONE:
return "none";
case GESTURE_TYPE_HOLD:
return "hold";
case GESTURE_TYPE_PINCH:
return "pinch";
case GESTURE_TYPE_SWIPE:
return "swipe";
}
return NULL;
}
const char *gesture_direction_string(enum gesture_direction direction) {
switch (direction) {
case GESTURE_DIRECTION_NONE:
return "none";
case GESTURE_DIRECTION_UP:
return "up";
case GESTURE_DIRECTION_DOWN:
return "down";
case GESTURE_DIRECTION_LEFT:
return "left";
case GESTURE_DIRECTION_RIGHT:
return "right";
case GESTURE_DIRECTION_INWARD:
return "inward";
case GESTURE_DIRECTION_OUTWARD:
return "outward";
case GESTURE_DIRECTION_CLOCKWISE:
return "clockwise";
case GESTURE_DIRECTION_COUNTERCLOCKWISE:
return "counterclockwise";
}
return NULL;
}
// Helper to turn combination of directions flags into string representation.
static char *gesture_directions_to_string(uint32_t directions) {
char *result = NULL;
for (uint8_t bit = 0; bit < 32; bit++) {
uint32_t masked = directions & (1 << bit);
if (masked) {
const char *name = gesture_direction_string(masked);
if (!name) {
name = "unknown";
}
if (!result) {
result = strdup(name);
} else {
char *new = format_str("%s+%s", result, name);
free(result);
result = new;
}
}
}
if(!result) {
return strdup("any");
}
return result;
}
char *gesture_to_string(struct gesture *gesture) {
char *directions = gesture_directions_to_string(gesture->directions);
char *result = format_str("%s:%u:%s",
gesture_type_string(gesture->type),
gesture->fingers, directions);
free(directions);
return result;
}
bool gesture_check(struct gesture *target, enum gesture_type type, uint8_t fingers) {
// Check that gesture type matches
if (target->type != type) {
return false;
}
// Check that finger count matches
if (target->fingers != GESTURE_FINGERS_ANY && target->fingers != fingers) {
return false;
}
return true;
}
bool gesture_match(struct gesture *target, struct gesture *to_match, bool exact) {
// Check type and fingers
if (!gesture_check(target, to_match->type, to_match->fingers)) {
return false;
}
// Enforce exact matches ...
if (exact && target->directions != to_match->directions) {
return false;
}
// ... or ensure all target directions are matched
return (target->directions & to_match->directions) == target->directions;
}
bool gesture_equal(struct gesture *a, struct gesture *b) {
return a->type == b->type
&& a->fingers == b->fingers
&& a->directions == b->directions;
}
// Return count of set bits in directions bit field.
static uint8_t gesture_directions_count(uint32_t directions) {
uint8_t count = 0;
for (; directions; directions >>= 1) {
count += directions & 1;
}
return count;
}
// Compare direction bit count of two direction.
static int8_t gesture_directions_compare(uint32_t a, uint32_t b) {
return gesture_directions_count(a) - gesture_directions_count(b);
}
// Compare two direction based on their direction bit count
int8_t gesture_compare(struct gesture *a, struct gesture *b) {
return gesture_directions_compare(a->directions, b->directions);
}
void gesture_tracker_begin(struct gesture_tracker *tracker,
enum gesture_type type, uint8_t fingers) {
tracker->type = type;
tracker->fingers = fingers;
tracker->dx = 0.0;
tracker->dy = 0.0;
tracker->scale = 1.0;
tracker->rotation = 0.0;
sway_log(SWAY_DEBUG, "begin tracking %s:%u:? gesture",
gesture_type_string(type), fingers);
}
bool gesture_tracker_check(struct gesture_tracker *tracker, enum gesture_type type) {
return tracker->type == type;
}
void gesture_tracker_update(struct gesture_tracker *tracker,
double dx, double dy, double scale, double rotation) {
if (tracker->type == GESTURE_TYPE_HOLD) {
sway_assert(false, "hold does not update.");
return;
}
tracker->dx += dx;
tracker->dy += dy;
if (tracker->type == GESTURE_TYPE_PINCH) {
tracker->scale = scale;
tracker->rotation += rotation;
}
sway_log(SWAY_DEBUG, "update tracking %s:%u:? gesture: %f %f %f %f",
gesture_type_string(tracker->type),
tracker->fingers,
tracker->dx, tracker->dy,
tracker->scale, tracker->rotation);
}
void gesture_tracker_cancel(struct gesture_tracker *tracker) {
sway_log(SWAY_DEBUG, "cancel tracking %s:%u:? gesture",
gesture_type_string(tracker->type), tracker->fingers);
tracker->type = GESTURE_TYPE_NONE;
}
struct gesture *gesture_tracker_end(struct gesture_tracker *tracker) {
struct gesture *result = calloc(1, sizeof(struct gesture));
// Ignore gesture under some threshold
// TODO: Make configurable
const double min_rotation = 5;
const double min_scale_delta = 0.1;
// Determine direction
switch(tracker->type) {
// Gestures with scale and rotation
case GESTURE_TYPE_PINCH:
if (tracker->rotation > min_rotation) {
result->directions |= GESTURE_DIRECTION_CLOCKWISE;
}
if (tracker->rotation < -min_rotation) {
result->directions |= GESTURE_DIRECTION_COUNTERCLOCKWISE;
}
if (tracker->scale > (1.0 + min_scale_delta)) {
result->directions |= GESTURE_DIRECTION_OUTWARD;
}
if (tracker->scale < (1.0 - min_scale_delta)) {
result->directions |= GESTURE_DIRECTION_INWARD;
}
__attribute__ ((fallthrough));
// Gestures with dx and dy
case GESTURE_TYPE_SWIPE:
if (fabs(tracker->dx) > fabs(tracker->dy)) {
if (tracker->dx > 0) {
result->directions |= GESTURE_DIRECTION_RIGHT;
} else {
result->directions |= GESTURE_DIRECTION_LEFT;
}
} else {
if (tracker->dy > 0) {
result->directions |= GESTURE_DIRECTION_DOWN;
} else {
result->directions |= GESTURE_DIRECTION_UP;
}
}
// Gesture without any direction
case GESTURE_TYPE_HOLD:
break;
// Not tracking any gesture
case GESTURE_TYPE_NONE:
sway_assert(false, "Not tracking any gesture.");
return result;
}
result->type = tracker->type;
result->fingers = tracker->fingers;
char *description = gesture_to_string(result);
sway_log(SWAY_DEBUG, "end tracking gesture: %s", description);
free(description);
tracker->type = GESTURE_TYPE_NONE;
return result;
}

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -7,37 +6,49 @@
#include <sys/un.h>
#include <unistd.h>
#include "ipc-client.h"
#include "readline.h"
#include "log.h"
static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'};
static const size_t ipc_header_size = sizeof(ipc_magic)+8;
#define IPC_HEADER_SIZE (sizeof(ipc_magic) + 8)
char *get_socketpath(void) {
const char *swaysock = getenv("SWAYSOCK");
if (swaysock) {
return strdup(swaysock);
}
char *line = NULL;
size_t line_size = 0;
FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r");
if (fp) {
char *line = read_line(fp);
ssize_t nret = getline(&line, &line_size, fp);
pclose(fp);
if (line && *line) {
if (nret > 0) {
// remove trailing newline, if there is one
if (line[nret - 1] == '\n') {
line[nret - 1] = '\0';
}
return line;
}
}
const char *i3sock = getenv("I3SOCK");
if (i3sock) {
free(line);
return strdup(i3sock);
}
fp = popen("i3 --get-socketpath 2>/dev/null", "r");
if (fp) {
char *line = read_line(fp);
ssize_t nret = getline(&line, &line_size, fp);
pclose(fp);
if (line && *line) {
if (nret > 0) {
// remove trailing newline, if there is one
if (line[nret - 1] == '\n') {
line[nret - 1] = '\0';
}
return line;
}
}
free(line);
return NULL;
}
@ -57,13 +68,20 @@ int ipc_open_socket(const char *socket_path) {
return socketfd;
}
bool ipc_set_recv_timeout(int socketfd, struct timeval tv) {
if (setsockopt(socketfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
sway_log_errno(SWAY_ERROR, "Failed to set ipc recv timeout");
return false;
}
return true;
}
struct ipc_response *ipc_recv_response(int socketfd) {
char data[ipc_header_size];
uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic));
char data[IPC_HEADER_SIZE];
size_t total = 0;
while (total < ipc_header_size) {
ssize_t received = recv(socketfd, data + total, ipc_header_size - total, 0);
while (total < IPC_HEADER_SIZE) {
ssize_t received = recv(socketfd, data + total, IPC_HEADER_SIZE - total, 0);
if (received <= 0) {
sway_abort("Unable to receive IPC response");
}
@ -75,14 +93,15 @@ struct ipc_response *ipc_recv_response(int socketfd) {
goto error_1;
}
total = 0;
response->size = data32[0];
response->type = data32[1];
memcpy(&response->size, data + sizeof(ipc_magic), sizeof(uint32_t));
memcpy(&response->type, data + sizeof(ipc_magic) + sizeof(uint32_t), sizeof(uint32_t));
char *payload = malloc(response->size + 1);
if (!payload) {
goto error_2;
}
total = 0;
while (total < response->size) {
ssize_t received = recv(socketfd, payload + total, response->size - total, 0);
if (received < 0) {
@ -97,7 +116,7 @@ struct ipc_response *ipc_recv_response(int socketfd) {
error_2:
free(response);
error_1:
wlr_log(WLR_ERROR, "Unable to allocate memory for IPC response");
sway_log(SWAY_ERROR, "Unable to allocate memory for IPC response");
return NULL;
}
@ -107,13 +126,12 @@ void free_ipc_response(struct ipc_response *response) {
}
char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint32_t *len) {
char data[ipc_header_size];
uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic));
char data[IPC_HEADER_SIZE];
memcpy(data, ipc_magic, sizeof(ipc_magic));
data32[0] = *len;
data32[1] = type;
memcpy(data + sizeof(ipc_magic), len, sizeof(*len));
memcpy(data + sizeof(ipc_magic) + sizeof(*len), &type, sizeof(type));
if (write(socketfd, data, ipc_header_size) == -1) {
if (write(socketfd, data, IPC_HEADER_SIZE) == -1) {
sway_abort("Unable to send IPC header");
}

View File

@ -17,7 +17,7 @@ list_t *create_list(void) {
static void list_resize(list_t *list) {
if (list->length == list->capacity) {
list->capacity += 10;
list->capacity *= 2;
list->items = realloc(list->items, sizeof(void*) * list->capacity);
}
}
@ -30,15 +30,6 @@ void list_free(list_t *list) {
free(list);
}
void list_foreach(list_t *list, void (*callback)(void *item)) {
if (list == NULL || callback == NULL) {
return;
}
for (int i = 0; i < list->length; i++) {
callback(list->items[i]);
}
}
void list_add(list_t *list, void *item) {
list_resize(list);
list->items[list->length++] = item;
@ -57,8 +48,7 @@ void list_del(list_t *list, int index) {
}
void list_cat(list_t *list, list_t *source) {
int i;
for (i = 0; i < source->length; ++i) {
for (int i = 0; i < source->length; ++i) {
list_add(list, source->items[i]);
}
}
@ -77,6 +67,15 @@ int list_seq_find(list_t *list, int compare(const void *item, const void *data),
return -1;
}
int list_find(list_t *list, const void *item) {
for (int i = 0; i < list->length; i++) {
if (list->items[i] == item) {
return i;
}
}
return -1;
}
void list_swap(list_t *list, int src, int dest) {
void *tmp = list->items[src];
list->items[src] = list->items[dest];
@ -147,3 +146,15 @@ void list_stable_sort(list_t *list, int compare(const void *a, const void *b)) {
list_inplace_sort(list, 0, list->length - 1, compare);
}
}
void list_free_items_and_destroy(list_t *list) {
if (!list) {
return;
}
for (int i = 0; i < list->length; ++i) {
free(list->items[i]);
}
list_free(list);
}

View File

@ -1,16 +1,19 @@
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "log.h"
void sway_terminate(int code);
static terminate_callback_t log_terminate = exit;
void _sway_abort(const char *format, ...) {
va_list args;
va_start(args, format);
_wlr_vlog(WLR_ERROR, format, args);
_sway_vlog(SWAY_ERROR, format, args);
va_end(args);
sway_terminate(EXIT_FAILURE);
log_terminate(EXIT_FAILURE);
}
bool _sway_assert(bool condition, const char *format, ...) {
@ -20,7 +23,7 @@ bool _sway_assert(bool condition, const char *format, ...) {
va_list args;
va_start(args, format);
_wlr_vlog(WLR_ERROR, format, args);
_sway_vlog(SWAY_ERROR, format, args);
va_end(args);
#ifndef NDEBUG
@ -29,3 +32,94 @@ bool _sway_assert(bool condition, const char *format, ...) {
return false;
}
static bool colored = true;
static sway_log_importance_t log_importance = SWAY_ERROR;
static struct timespec start_time = {-1, -1};
static const char *verbosity_colors[] = {
[SWAY_SILENT] = "",
[SWAY_ERROR ] = "\x1B[1;31m",
[SWAY_INFO ] = "\x1B[1;34m",
[SWAY_DEBUG ] = "\x1B[1;90m",
};
static const char *verbosity_headers[] = {
[SWAY_SILENT] = "",
[SWAY_ERROR] = "[ERROR]",
[SWAY_INFO] = "[INFO]",
[SWAY_DEBUG] = "[DEBUG]",
};
static void timespec_sub(struct timespec *r, const struct timespec *a,
const struct timespec *b) {
const long NSEC_PER_SEC = 1000000000;
r->tv_sec = a->tv_sec - b->tv_sec;
r->tv_nsec = a->tv_nsec - b->tv_nsec;
if (r->tv_nsec < 0) {
r->tv_sec--;
r->tv_nsec += NSEC_PER_SEC;
}
}
static void init_start_time(void) {
if (start_time.tv_sec >= 0) {
return;
}
clock_gettime(CLOCK_MONOTONIC, &start_time);
}
static void sway_log_stderr(sway_log_importance_t verbosity, const char *fmt,
va_list args) {
init_start_time();
if (verbosity > log_importance) {
return;
}
struct timespec ts = {0};
clock_gettime(CLOCK_MONOTONIC, &ts);
timespec_sub(&ts, &ts, &start_time);
fprintf(stderr, "%02d:%02d:%02d.%03ld ", (int)(ts.tv_sec / 60 / 60),
(int)(ts.tv_sec / 60 % 60), (int)(ts.tv_sec % 60),
ts.tv_nsec / 1000000);
unsigned c = (verbosity < SWAY_LOG_IMPORTANCE_LAST) ? verbosity :
SWAY_LOG_IMPORTANCE_LAST - 1;
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "%s", verbosity_colors[c]);
} else {
fprintf(stderr, "%s ", verbosity_headers[c]);
}
vfprintf(stderr, fmt, args);
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "\x1B[0m");
}
fprintf(stderr, "\n");
}
void sway_log_init(sway_log_importance_t verbosity, terminate_callback_t callback) {
init_start_time();
if (verbosity < SWAY_LOG_IMPORTANCE_LAST) {
log_importance = verbosity;
}
if (callback) {
log_terminate = callback;
}
}
void _sway_vlog(sway_log_importance_t verbosity, const char *fmt, va_list args) {
sway_log_stderr(verbosity, fmt, args);
}
void _sway_log(sway_log_importance_t verbosity, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
sway_log_stderr(verbosity, fmt, args);
va_end(args);
}

183
common/loop.c Normal file
View File

@ -0,0 +1,183 @@
#include <limits.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <poll.h>
#include <time.h>
#include <unistd.h>
#include "list.h"
#include "log.h"
#include "loop.h"
struct loop_fd_event {
void (*callback)(int fd, short mask, void *data);
void *data;
};
struct loop_timer {
void (*callback)(void *data);
void *data;
struct timespec expiry;
};
struct loop {
struct pollfd *fds;
int fd_length;
int fd_capacity;
list_t *fd_events; // struct loop_fd_event
list_t *timers; // struct loop_timer
};
struct loop *loop_create(void) {
struct loop *loop = calloc(1, sizeof(struct loop));
if (!loop) {
sway_log(SWAY_ERROR, "Unable to allocate memory for loop");
return NULL;
}
loop->fd_capacity = 10;
loop->fds = malloc(sizeof(struct pollfd) * loop->fd_capacity);
loop->fd_events = create_list();
loop->timers = create_list();
return loop;
}
void loop_destroy(struct loop *loop) {
list_free_items_and_destroy(loop->fd_events);
list_free_items_and_destroy(loop->timers);
free(loop->fds);
free(loop);
}
void loop_poll(struct loop *loop) {
// Calculate next timer in ms
int ms = INT_MAX;
if (loop->timers->length) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
for (int i = 0; i < loop->timers->length; ++i) {
struct loop_timer *timer = loop->timers->items[i];
int timer_ms = (timer->expiry.tv_sec - now.tv_sec) * 1000;
timer_ms += (timer->expiry.tv_nsec - now.tv_nsec) / 1000000;
if (timer_ms < ms) {
ms = timer_ms;
}
}
}
if (ms < 0) {
ms = 0;
}
poll(loop->fds, loop->fd_length, ms);
// Dispatch fds
for (int i = 0; i < loop->fd_length; ++i) {
struct pollfd pfd = loop->fds[i];
struct loop_fd_event *event = loop->fd_events->items[i];
// Always send these events
unsigned events = pfd.events | POLLHUP | POLLERR;
if (pfd.revents & events) {
event->callback(pfd.fd, pfd.revents, event->data);
}
}
// Dispatch timers
if (loop->timers->length) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
for (int i = 0; i < loop->timers->length; ++i) {
struct loop_timer *timer = loop->timers->items[i];
bool expired = timer->expiry.tv_sec < now.tv_sec ||
(timer->expiry.tv_sec == now.tv_sec &&
timer->expiry.tv_nsec < now.tv_nsec);
if (expired) {
timer->callback(timer->data);
loop_remove_timer(loop, timer);
--i;
}
}
}
}
void loop_add_fd(struct loop *loop, int fd, short mask,
void (*callback)(int fd, short mask, void *data), void *data) {
struct loop_fd_event *event = calloc(1, sizeof(struct loop_fd_event));
if (!event) {
sway_log(SWAY_ERROR, "Unable to allocate memory for event");
return;
}
event->callback = callback;
event->data = data;
list_add(loop->fd_events, event);
struct pollfd pfd = {fd, mask, 0};
if (loop->fd_length == loop->fd_capacity) {
int capacity = loop->fd_capacity + 10;
struct pollfd *tmp = realloc(loop->fds,
sizeof(struct pollfd) * capacity);
if (!tmp) {
sway_log(SWAY_ERROR, "Unable to allocate memory for pollfd");
return;
}
loop->fds = tmp;
loop->fd_capacity = capacity;
}
loop->fds[loop->fd_length++] = pfd;
}
struct loop_timer *loop_add_timer(struct loop *loop, int ms,
void (*callback)(void *data), void *data) {
struct loop_timer *timer = calloc(1, sizeof(struct loop_timer));
if (!timer) {
sway_log(SWAY_ERROR, "Unable to allocate memory for timer");
return NULL;
}
timer->callback = callback;
timer->data = data;
clock_gettime(CLOCK_MONOTONIC, &timer->expiry);
timer->expiry.tv_sec += ms / 1000;
long int nsec = (ms % 1000) * 1000000;
if (timer->expiry.tv_nsec + nsec >= 1000000000) {
timer->expiry.tv_sec++;
nsec -= 1000000000;
}
timer->expiry.tv_nsec += nsec;
list_add(loop->timers, timer);
return timer;
}
bool loop_remove_fd(struct loop *loop, int fd) {
for (int i = 0; i < loop->fd_length; ++i) {
if (loop->fds[i].fd == fd) {
free(loop->fd_events->items[i]);
list_del(loop->fd_events, i);
loop->fd_length--;
memmove(&loop->fds[i], &loop->fds[i + 1],
sizeof(struct pollfd) * (loop->fd_length - i));
return true;
}
}
return false;
}
bool loop_remove_timer(struct loop *loop, struct loop_timer *timer) {
for (int i = 0; i < loop->timers->length; ++i) {
if (loop->timers->items[i] == timer) {
list_del(loop->timers, i);
free(timer);
return true;
}
}
return false;
}

View File

@ -1,23 +1,21 @@
lib_sway_common = static_library(
'sway-common',
files(
'background-image.c',
'cairo.c',
'gesture.c',
'ipc-client.c',
'log.c',
'loop.c',
'list.c',
'pango.c',
'readline.c',
'stringop.c',
'unicode.c',
'util.c'
),
dependencies: [
cairo,
gdk_pixbuf,
pango,
pangocairo,
wlroots
wayland_client.partial_dependency(compile_args: true)
],
include_directories: sway_inc
)

View File

@ -1,4 +1,4 @@
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
#include <stdarg.h>
#include <stdbool.h>
@ -6,71 +6,51 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cairo_util.h"
#include "log.h"
#include "stringop.h"
int escape_markup_text(const char *src, char *dest, int dest_length) {
int length = 0;
size_t escape_markup_text(const char *src, char *dest) {
size_t length = 0;
if (dest) {
dest[0] = '\0';
}
while (src[0]) {
switch (src[0]) {
case '&':
length += 5;
if (dest && dest_length - length >= 0) {
dest += sprintf(dest, "%s", "&amp;");
} else {
dest_length = -1;
}
lenient_strcat(dest, "&amp;");
break;
case '<':
length += 4;
if (dest && dest_length - length >= 0) {
dest += sprintf(dest, "%s", "&lt;");
} else {
dest_length = -1;
}
lenient_strcat(dest, "&lt;");
break;
case '>':
length += 4;
if (dest && dest_length - length >= 0) {
dest += sprintf(dest, "%s", "&gt;");
} else {
dest_length = -1;
}
lenient_strcat(dest, "&gt;");
break;
case '\'':
length += 6;
if (dest && dest_length - length >= 0) {
dest += sprintf(dest, "%s", "&apos;");
} else {
dest_length = -1;
}
lenient_strcat(dest, "&apos;");
break;
case '"':
length += 6;
if (dest && dest_length - length >= 0) {
dest += sprintf(dest, "%s", "&quot;");
} else {
dest_length = -1;
}
lenient_strcat(dest, "&quot;");
break;
default:
length += 1;
if (dest && dest_length - length >= 0) {
*(dest++) = *src;
} else {
dest_length = -1;
if (dest) {
dest[length] = *src;
dest[length + 1] = '\0';
}
length += 1;
}
src++;
}
// if we could not fit the escaped string in dest, return -1
if (dest && dest_length == -1) {
return -1;
}
return length;
}
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc,
const char *text, double scale, bool markup) {
PangoLayout *layout = pango_cairo_create_layout(cairo);
PangoAttrList *attrs;
@ -78,10 +58,10 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
char *buf;
GError *error = NULL;
if (pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, &error)) {
pango_layout_set_markup(layout, buf, -1);
pango_layout_set_text(layout, buf, -1);
free(buf);
} else {
wlr_log(WLR_ERROR, "pango_parse_markup '%s' -> error %s", text,
sway_log(SWAY_ERROR, "pango_parse_markup '%s' -> error %s", text,
error->message);
g_error_free(error);
markup = false; // fallback to plain text
@ -93,45 +73,66 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
}
pango_attr_list_insert(attrs, pango_attr_scale_new(scale));
PangoFontDescription *desc = pango_font_description_from_string(font);
pango_layout_set_font_description(layout, desc);
pango_layout_set_single_paragraph_mode(layout, 1);
pango_layout_set_attributes(layout, attrs);
pango_attr_list_unref(attrs);
pango_font_description_free(desc);
return layout;
}
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
double scale, bool markup, const char *fmt, ...) {
static char buf[2048];
void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
if (vsnprintf(buf, 2048, fmt, args) >= 2048) {
strcpy(buf, "[buffer overflow]");
}
char *buf = vformat_str(fmt, args);
va_end(args);
if (buf == NULL) {
return;
}
PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup);
PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup);
pango_cairo_update_layout(cairo, layout);
pango_layout_get_pixel_size(layout, width, height);
if (baseline) {
*baseline = pango_layout_get_baseline(layout) / PANGO_SCALE;
}
g_object_unref(layout);
free(buf);
}
void pango_printf(cairo_t *cairo, const char *font,
double scale, bool markup, const char *fmt, ...) {
static char buf[2048];
void get_text_metrics(const PangoFontDescription *description, int *height, int *baseline) {
cairo_t *cairo = cairo_create(NULL);
PangoContext *pango = pango_cairo_create_context(cairo);
// When passing NULL as a language, pango uses the current locale.
PangoFontMetrics *metrics = pango_context_get_metrics(pango, description, NULL);
*baseline = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
*height = *baseline + pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
pango_font_metrics_unref(metrics);
g_object_unref(pango);
cairo_destroy(cairo);
}
void render_text(cairo_t *cairo, const PangoFontDescription *desc,
double scale, bool markup, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
if (vsnprintf(buf, 2048, fmt, args) >= 2048) {
strcpy(buf, "[buffer overflow]");
}
char *buf = vformat_str(fmt, args);
va_end(args);
if (buf == NULL) {
return;
}
PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup);
PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup);
cairo_font_options_t *fo = cairo_font_options_create();
cairo_get_font_options(cairo, fo);
pango_cairo_context_set_font_options(pango_layout_get_context(layout), fo);
cairo_font_options_destroy(fo);
pango_cairo_update_layout(cairo, layout);
pango_cairo_show_layout(cairo, layout);
g_object_unref(layout);
free(buf);
}

View File

@ -1,97 +0,0 @@
#define _POSIX_C_SOURCE 200809L
#include "readline.h"
#include "log.h"
#include <stdlib.h>
#include <stdio.h>
char *read_line(FILE *file) {
size_t length = 0, size = 128;
char *string = malloc(size);
char lastChar = '\0';
if (!string) {
wlr_log(WLR_ERROR, "Unable to allocate memory for read_line");
return NULL;
}
while (1) {
int c = getc(file);
if (c == '\n' && lastChar == '\\'){
--length; // Ignore last character.
lastChar = '\0';
continue;
}
if (c == EOF || c == '\n' || c == '\0') {
break;
}
if (c == '\r') {
continue;
}
lastChar = c;
if (length == size) {
char *new_string = realloc(string, size *= 2);
if (!new_string) {
free(string);
wlr_log(WLR_ERROR, "Unable to allocate memory for read_line");
return NULL;
}
string = new_string;
}
string[length++] = c;
}
if (length + 1 == size) {
char *new_string = realloc(string, length + 1);
if (!new_string) {
free(string);
return NULL;
}
string = new_string;
}
string[length] = '\0';
return string;
}
char *peek_line(FILE *file, int line_offset, long *position) {
long pos = ftell(file);
size_t length = 0;
char *line = NULL;
for (int i = 0; i <= line_offset; i++) {
ssize_t read = getline(&line, &length, file);
if (read < 0) {
free(line);
line = NULL;
break;
}
if (read > 0 && line[read - 1] == '\n') {
line[read - 1] = '\0';
}
}
if (position) {
*position = ftell(file);
}
fseek(file, pos, SEEK_SET);
return line;
}
char *read_line_buffer(FILE *file, char *string, size_t string_len) {
size_t length = 0;
if (!string) {
return NULL;
}
while (1) {
int c = getc(file);
if (c == EOF || c == '\n' || c == '\0') {
break;
}
if (c == '\r') {
continue;
}
string[length++] = c;
if (string_len <= length) {
return NULL;
}
}
if (length + 1 == string_len) {
return NULL;
}
string[length] = '\0';
return string;
}

View File

@ -1,32 +1,26 @@
#define _XOPEN_SOURCE 700
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include "stringop.h"
#include "log.h"
#include "string.h"
#include <wordexp.h>
#include "list.h"
#include "log.h"
#include "stringop.h"
const char whitespace[] = " \f\n\r\t\v";
static const char whitespace[] = " \f\n\r\t\v";
char *strip_whitespace(char *_str) {
if (*_str == '\0')
return _str;
char *strold = _str;
while (*_str == ' ' || *_str == '\t') {
_str++;
void strip_whitespace(char *str) {
size_t len = strlen(str);
size_t start = strspn(str, whitespace);
memmove(str, &str[start], len + 1 - start);
if (*str) {
for (len -= start + 1; isspace(str[len]); --len) {}
str[len + 1] = '\0';
}
char *str = strdup(_str);
free(strold);
int i;
for (i = 0; str[i] != '\0'; ++i);
do {
i--;
} while (i >= 0 && (str[i] == ' ' || str[i] == '\t'));
str[i + 1] = '\0';
return str;
}
void strip_quotes(char *str) {
@ -70,7 +64,7 @@ char *lenient_strncat(char *dest, const char *src, size_t len) {
}
// strcmp that also handles null pointers.
int lenient_strcmp(char *a, char *b) {
int lenient_strcmp(const char *a, const char *b) {
if (a == b) {
return 0;
} else if (!a) {
@ -85,26 +79,16 @@ int lenient_strcmp(char *a, char *b) {
list_t *split_string(const char *str, const char *delims) {
list_t *res = create_list();
char *copy = strdup(str);
char *token;
token = strtok(copy, delims);
while(token) {
token = strdup(token);
list_add(res, token);
char *token = strtok(copy, delims);
while (token) {
list_add(res, strdup(token));
token = strtok(NULL, delims);
}
free(copy);
return res;
}
void free_flat_list(list_t *list) {
int i;
for (i = 0; i < list->length; ++i) {
free(list->items[i]);
}
list_free(list);
}
char **split_args(const char *start, int *argc) {
*argc = 0;
int alloc = 2;
@ -112,7 +96,7 @@ char **split_args(const char *start, int *argc) {
bool in_token = false;
bool in_string = false;
bool in_char = false;
bool in_brackets = false; // brackets are used for critera
bool in_brackets = false; // brackets are used for criteria
bool escaped = false;
const char *end = start;
if (start) {
@ -165,29 +149,6 @@ void free_argv(int argc, char **argv) {
free(argv);
}
char *code_strstr(const char *haystack, const char *needle) {
/* TODO */
return strstr(haystack, needle);
}
char *code_strchr(const char *str, char delimiter) {
int in_string = 0, in_character = 0;
int i = 0;
while (str[i] != '\0') {
if (str[i] == '"' && !in_character) {
in_string = !in_string;
} else if (str[i] == '\'' && !in_string) {
in_character = !in_character;
} else if (!in_character && !in_string) {
if (str[i] == delimiter) {
return (char *)str + i;
}
}
++i;
}
return NULL;
}
int unescape_string(char *string) {
/* TODO: More C string escapes */
int len = strlen(string);
@ -273,6 +234,9 @@ int unescape_string(char *string) {
}
char *join_args(char **argv, int argc) {
if (!sway_assert(argc > 0, "argc should be positive")) {
return NULL;
}
int len = 0, i;
for (i = 0; i < argc; ++i) {
len += strlen(argv[i]) + 1;
@ -288,116 +252,111 @@ char *join_args(char **argv, int argc) {
return res;
}
static bool has_whitespace(const char *str) {
while (*str) {
if (isspace(*str)) {
return true;
}
++str;
static inline char *argsep_next_interesting(const char *src, const char *delim) {
char *special = strpbrk(src, "\"'\\");
char *next_delim = strpbrk(src, delim);
if (!special) {
return next_delim;
}
return false;
if (!next_delim) {
return special;
}
return (next_delim < special) ? next_delim : special;
}
/**
* Add quotes around any argv with whitespaces.
*/
void add_quotes(char **argv, int argc) {
int i;
for (i = 0; i < argc; ++i) {
if (has_whitespace(argv[i])) {
int len = strlen(argv[i]) + 3;
char *tmp = argv[i];
argv[i] = malloc(len * sizeof(char));
snprintf(argv[i], len, "\"%s\"", tmp);
free(tmp);
}
}
}
/*
* Join a list of strings, adding separator in between. Separator can be NULL.
*/
char *join_list(list_t *list, char *separator) {
if (!sway_assert(list != NULL, "list != NULL") || list->length == 0) {
return NULL;
}
size_t len = 1; // NULL terminator
size_t sep_len = 0;
if (separator != NULL) {
sep_len = strlen(separator);
len += (list->length - 1) * sep_len;
}
for (int i = 0; i < list->length; i++) {
len += strlen(list->items[i]);
}
char *res = malloc(len);
char *p = res + strlen(list->items[0]);
strcpy(res, list->items[0]);
for (int i = 1; i < list->length; i++) {
if (sep_len) {
memcpy(p, separator, sep_len);
p += sep_len;
}
strcpy(p, list->items[i]);
p += strlen(list->items[i]);
}
*p = '\0';
return res;
}
char *cmdsep(char **stringp, const char *delim) {
// skip over leading delims
char *head = *stringp + strspn(*stringp, delim);
// Find end token
char *tail = *stringp += strcspn(*stringp, delim);
// Set stringp to beginning of next token
*stringp += strspn(*stringp, delim);
// Set stringp to null if last token
if (!**stringp) *stringp = NULL;
// Nullify end of first token
*tail = 0;
return head;
}
char *argsep(char **stringp, const char *delim) {
char *argsep(char **stringp, const char *delim, char *matched) {
char *start = *stringp;
char *end = start;
bool in_string = false;
bool in_char = false;
bool escaped = false;
while (1) {
if (*end == '"' && !in_char && !escaped) {
in_string = !in_string;
} else if (*end == '\'' && !in_string && !escaped) {
in_char = !in_char;
} else if (*end == '\\') {
escaped = !escaped;
} else if (*end == '\0') {
*stringp = NULL;
goto found;
} else if (!in_string && !in_char && !escaped && strchr(delim, *end)) {
if (end - start) {
*(end++) = 0;
*stringp = end + strspn(end, delim);;
if (!**stringp) *stringp = NULL;
goto found;
} else {
++start;
end = start;
}
}
if (*end != '\\') {
char *interesting = NULL;
while ((interesting = argsep_next_interesting(end, delim))) {
if (escaped && interesting != end) {
escaped = false;
}
++end;
if (*interesting == '"' && !in_char && !escaped) {
in_string = !in_string;
end = interesting + 1;
} else if (*interesting == '\'' && !in_string && !escaped) {
in_char = !in_char;
end = interesting + 1;
} else if (*interesting == '\\') {
escaped = !escaped;
end = interesting + 1;
} else if (!in_string && !in_char && !escaped) {
// We must have matched a separator
end = interesting;
if (matched) {
*matched = *end;
}
if (end - start) {
*(end++) = 0;
*stringp = end;
break;
} else {
end = ++start;
}
} else {
end++;
}
}
if (!interesting) {
*stringp = NULL;
if (matched) {
*matched = '\0';
}
}
found:
return start;
}
bool expand_path(char **path) {
wordexp_t p = {0};
while (strstr(*path, " ")) {
*path = realloc(*path, strlen(*path) + 2);
char *ptr = strstr(*path, " ") + 1;
memmove(ptr + 1, ptr, strlen(ptr) + 1);
*ptr = '\\';
}
if (wordexp(*path, &p, 0) != 0 || p.we_wordv[0] == NULL) {
wordfree(&p);
return false;
}
free(*path);
*path = join_args(p.we_wordv, p.we_wordc);
wordfree(&p);
return true;
}
char *vformat_str(const char *fmt, va_list args) {
char *str = NULL;
va_list args_copy;
va_copy(args_copy, args);
int len = vsnprintf(NULL, 0, fmt, args);
if (len < 0) {
sway_log_errno(SWAY_ERROR, "vsnprintf(\"%s\") failed", fmt);
goto out;
}
str = malloc(len + 1);
if (str == NULL) {
sway_log_errno(SWAY_ERROR, "malloc() failed");
goto out;
}
vsnprintf(str, len + 1, fmt, args_copy);
out:
va_end(args_copy);
return str;
}
char *format_str(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
char *str = vformat_str(fmt, args);
va_end(args);
return str;
}

View File

@ -1,101 +0,0 @@
#include <stdint.h>
#include <stddef.h>
#include "unicode.h"
size_t utf8_chsize(uint32_t ch) {
if (ch < 0x80) {
return 1;
} else if (ch < 0x800) {
return 2;
} else if (ch < 0x10000) {
return 3;
}
return 4;
}
static const uint8_t masks[] = {
0x7F,
0x1F,
0x0F,
0x07,
0x03,
0x01
};
uint32_t utf8_decode(const char **char_str) {
uint8_t **s = (uint8_t **)char_str;
uint32_t cp = 0;
if (**s < 128) {
// shortcut
cp = **s;
++*s;
return cp;
}
int size = utf8_size((char *)*s);
if (size == -1) {
++*s;
return UTF8_INVALID;
}
uint8_t mask = masks[size - 1];
cp = **s & mask;
++*s;
while (--size) {
cp <<= 6;
cp |= **s & 0x3f;
++*s;
}
return cp;
}
size_t utf8_encode(char *str, uint32_t ch) {
size_t len = 0;
uint8_t first;
if (ch < 0x80) {
first = 0;
len = 1;
} else if (ch < 0x800) {
first = 0xc0;
len = 2;
} else if (ch < 0x10000) {
first = 0xe0;
len = 3;
} else {
first = 0xf0;
len = 4;
}
for (size_t i = len - 1; i > 0; --i) {
str[i] = (ch & 0x3f) | 0x80;
ch >>= 6;
}
str[0] = ch | first;
return len;
}
static const struct {
uint8_t mask;
uint8_t result;
int octets;
} sizes[] = {
{ 0x80, 0x00, 1 },
{ 0xE0, 0xC0, 2 },
{ 0xF0, 0xE0, 3 },
{ 0xF8, 0xF0, 4 },
{ 0xFC, 0xF8, 5 },
{ 0xFE, 0xF8, 6 },
{ 0x80, 0x80, -1 },
};
int utf8_size(const char *s) {
uint8_t c = (uint8_t)*s;
for (size_t i = 0; i < sizeof(sizes) / sizeof(*sizes); ++i) {
if ((c & sizes[i].mask) == sizes[i].result) {
return sizes[i].octets;
}
}
return -1;
}

View File

@ -1,126 +1,40 @@
#define _XOPEN_SOURCE 700
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <xkbcommon/xkbcommon-names.h>
#include <wlr/types/wlr_keyboard.h>
#include <wayland-server-protocol.h>
#include "log.h"
#include "readline.h"
#include "util.h"
int wrap(int i, int max) {
return ((i % max) + max) % max;
}
int numlen(int n) {
if (n == 0) {
return 1;
}
return log10(n) + 1;
}
static struct modifier_key {
char *name;
uint32_t mod;
} modifiers[] = {
{ XKB_MOD_NAME_SHIFT, WLR_MODIFIER_SHIFT },
{ XKB_MOD_NAME_CAPS, WLR_MODIFIER_CAPS },
{ XKB_MOD_NAME_CTRL, WLR_MODIFIER_CTRL },
{ "Ctrl", WLR_MODIFIER_CTRL },
{ XKB_MOD_NAME_ALT, WLR_MODIFIER_ALT },
{ "Alt", WLR_MODIFIER_ALT },
{ XKB_MOD_NAME_NUM, WLR_MODIFIER_MOD2 },
{ "Mod3", WLR_MODIFIER_MOD3 },
{ XKB_MOD_NAME_LOGO, WLR_MODIFIER_LOGO },
{ "Mod5", WLR_MODIFIER_MOD5 },
};
uint32_t get_modifier_mask_by_name(const char *name) {
int i;
for (i = 0; i < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++i) {
if (strcasecmp(modifiers[i].name, name) == 0) {
return modifiers[i].mod;
}
}
return 0;
}
const char *get_modifier_name_by_mask(uint32_t modifier) {
int i;
for (i = 0; i < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++i) {
if (modifiers[i].mod == modifier) {
return modifiers[i].name;
}
}
return NULL;
}
int get_modifier_names(const char **names, uint32_t modifier_masks) {
int length = 0;
int i;
for (i = 0; i < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++i) {
if ((modifier_masks & modifiers[i].mod) != 0) {
names[length] = modifiers[i].name;
++length;
modifier_masks ^= modifiers[i].mod;
}
}
return length;
}
pid_t get_parent_pid(pid_t child) {
pid_t parent = -1;
char file_name[100];
char *buffer = NULL;
char *token = NULL;
const char *sep = " ";
FILE *stat = NULL;
sprintf(file_name, "/proc/%d/stat", child);
if ((stat = fopen(file_name, "r"))) {
if ((buffer = read_line(stat))) {
token = strtok(buffer, sep); // pid
token = strtok(NULL, sep); // executable name
token = strtok(NULL, sep); // state
token = strtok(NULL, sep); // parent pid
parent = strtol(token, NULL, 10);
}
free(buffer);
fclose(stat);
}
if (parent) {
return (parent == child) ? -1 : parent;
}
return -1;
}
uint32_t parse_color(const char *color) {
bool parse_color(const char *color, uint32_t *result) {
if (color[0] == '#') {
++color;
}
int len = strlen(color);
if (len != 6 && len != 8) {
wlr_log(WLR_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
return 0xFFFFFFFF;
if ((len != 6 && len != 8) || !isxdigit(color[0]) || !isxdigit(color[1])) {
return false;
}
uint32_t res = (uint32_t)strtoul(color, NULL, 16);
if (strlen(color) == 6) {
res = (res << 8) | 0xFF;
char *ptr;
uint32_t parsed = strtoul(color, &ptr, 16);
if (*ptr != '\0') {
return false;
}
return res;
*result = len == 6 ? ((parsed << 8) | 0xFF) : parsed;
return true;
}
void color_to_rgba(float dest[static 4], uint32_t color) {
dest[0] = ((color >> 24) & 0xff) / 255.0;
dest[1] = ((color >> 16) & 0xff) / 255.0;
dest[2] = ((color >> 8) & 0xff) / 255.0;
dest[3] = (color & 0xff) / 255.0;
}
bool parse_boolean(const char *boolean, bool current) {
@ -139,39 +53,91 @@ bool parse_boolean(const char *boolean, bool current) {
return false;
}
char* resolve_path(const char* path) {
struct stat sb;
ssize_t r;
int i;
char *current = NULL;
char *resolved = NULL;
if(!(current = strdup(path))) {
return NULL;
float parse_float(const char *value) {
errno = 0;
char *end;
float flt = strtof(value, &end);
if (*end || errno) {
sway_log(SWAY_DEBUG, "Invalid float value '%s', defaulting to NAN", value);
return NAN;
}
for (i = 0; i < 16; ++i) {
if (lstat(current, &sb) == -1) {
goto failed;
}
if((sb.st_mode & S_IFMT) != S_IFLNK) {
return current;
}
if (!(resolved = malloc(sb.st_size + 1))) {
goto failed;
}
r = readlink(current, resolved, sb.st_size);
if (r == -1 || r > sb.st_size) {
goto failed;
}
resolved[r] = '\0';
free(current);
current = strdup(resolved);
free(resolved);
resolved = NULL;
return flt;
}
enum movement_unit parse_movement_unit(const char *unit) {
if (strcasecmp(unit, "px") == 0) {
return MOVEMENT_UNIT_PX;
}
if (strcasecmp(unit, "ppt") == 0) {
return MOVEMENT_UNIT_PPT;
}
if (strcasecmp(unit, "default") == 0) {
return MOVEMENT_UNIT_DEFAULT;
}
return MOVEMENT_UNIT_INVALID;
}
int parse_movement_amount(int argc, char **argv,
struct movement_amount *amount) {
if (!sway_assert(argc > 0, "Expected args in parse_movement_amount")) {
amount->amount = 0;
amount->unit = MOVEMENT_UNIT_INVALID;
return 0;
}
failed:
free(resolved);
free(current);
char *err;
amount->amount = (int)strtol(argv[0], &err, 10);
if (*err) {
// e.g. 10px
amount->unit = parse_movement_unit(err);
return 1;
}
if (argc == 1) {
amount->unit = MOVEMENT_UNIT_DEFAULT;
return 1;
}
// Try the second argument
amount->unit = parse_movement_unit(argv[1]);
if (amount->unit == MOVEMENT_UNIT_INVALID) {
amount->unit = MOVEMENT_UNIT_DEFAULT;
return 1;
}
return 2;
}
const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel) {
switch (subpixel) {
case WL_OUTPUT_SUBPIXEL_UNKNOWN:
return "unknown";
case WL_OUTPUT_SUBPIXEL_NONE:
return "none";
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB:
return "rgb";
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR:
return "bgr";
case WL_OUTPUT_SUBPIXEL_VERTICAL_RGB:
return "vrgb";
case WL_OUTPUT_SUBPIXEL_VERTICAL_BGR:
return "vbgr";
}
sway_assert(false, "Unknown value for wl_output_subpixel.");
return NULL;
}
bool sway_set_cloexec(int fd, bool cloexec) {
int flags = fcntl(fd, F_GETFD);
if (flags == -1) {
sway_log_errno(SWAY_ERROR, "fcntl failed");
return false;
}
if (cloexec) {
flags = flags | FD_CLOEXEC;
} else {
flags = flags & ~FD_CLOEXEC;
}
if (fcntl(fd, F_SETFD, flags) == -1) {
sway_log_errno(SWAY_ERROR, "fcntl failed");
return false;
}
return true;
}

View File

@ -2,7 +2,7 @@
_sway()
{
local cur prev
local cur prev short long
_get_comp_words_by_ref cur prev
short=(

44
completions/bash/swaybar Normal file
View File

@ -0,0 +1,44 @@
# swaybar(1) completion
_swaybar()
{
local cur prev short long
_get_comp_words_by_ref cur prev
short=(
-h
-v
-s
-b
-d
)
long=(
--help
--version
--socket
--bar_id
--debug
)
case $prev in
-s|--socket)
_filedir
return
;;
-b|--bar_id)
bars=($(swaymsg -t get_bar_config | jq -r '.[]'))
COMPREPLY=($(compgen -W "${bars[*]}" -- "$cur"))
return
;;
esac
if [[ $cur == --* ]]; then
COMPREPLY=($(compgen -W "${long[*]}" -- "$cur"))
else
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
fi
} &&
complete -F _swaybar swaybar

View File

@ -1,48 +0,0 @@
# swaymsg(1) completion
_swayidle()
{
local cur prev
_get_comp_words_by_ref -n : cur prev
local prev2=${COMP_WORDS[COMP_CWORD-2]}
local prev3=${COMP_WORDS[COMP_CWORD-3]}
events=(
'timeout'
'before-sleep'
)
short=(
-h
-d
)
if [ "$prev" = timeout ]; then
# timeout <timeout>
return
elif [ "$prev2" = timeout ]; then
# timeout <timeout> <timeout command>
COMPREPLY=($(compgen -c -- "$cur"))
return
elif [ "$prev3" = timeout ]; then
# timeout <timeout> <timeout command> [resume <resume command>]
COMPREPLY=(resume)
# optional argument; no return here as user may skip 'resume'
fi
case "$prev" in
resume)
COMPREPLY=($(compgen -c -- "$cur"))
return
;;
before-sleep)
COMPREPLY=($(compgen -c -- "$cur"))
return
;;
esac
COMPREPLY+=($(compgen -W "${events[*]}" -- "$cur"))
COMPREPLY+=($(compgen -W "${short[*]}" -- "$cur"))
} &&
complete -F _swayidle swayidle

View File

@ -1,66 +0,0 @@
# swaylock(1) completion
_swaylock()
{
local cur prev
_get_comp_words_by_ref -n : cur prev
short=(
-h
-c
-s
-t
-v
-i
-u
-f
)
long=(
--help
--color
--scaling
--tiling
--version
--image
--no-unlock-indicator
--daemonize
)
scaling=(
'stretch'
'fill'
'fit'
'center'
'tile'
)
case $prev in
-c|--color)
return
;;
--scaling)
COMPREPLY=($(compgen -W "${scaling[*]}" -- "$cur"))
return
;;
-i|--image)
if grep -q : <<< "$cur"; then
output="${cur%%:*}:"
cur="${cur#*:}"
else
output=
fi
COMPREPLY=($(compgen -f -- "$cur"))
return
;;
esac
if [[ $cur == --* ]]; then
COMPREPLY=($(compgen -W "${long[*]}" -- "$cur"))
else
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
fi
} &&
complete -F _swaylock swaylock

View File

@ -2,7 +2,7 @@
_swaymsg()
{
local cur prev
local cur prev types short long
_get_comp_words_by_ref cur prev
types=(
@ -15,12 +15,16 @@ _swaymsg()
'get_bar_config'
'get_version'
'get_binding_modes'
'get_binding_state'
'get_config'
'send_tick'
'subscribe'
)
short=(
-h
-m
-p
-q
-r
-s
@ -30,11 +34,13 @@ _swaymsg()
long=(
--help
--monitor
--pretty
--quiet
--raw
--socket
--type
--verbose
--version
)
case $prev in

View File

@ -0,0 +1,11 @@
# sway(1) completion
complete -f -c sway
complete -c sway -s h -l help --description "Show help message and quit."
complete -c sway -s c -l config --description "Specifies a config file." -r
complete -c sway -s C -l validate --description "Check the validity of the config file, then exit."
complete -c sway -s d -l debug --description "Enables full logging, including debug information."
complete -c sway -s v -l version --description "Show the version number and quit."
complete -c sway -s V -l verbose --description "Enables more verbose logging."
complete -c sway -l get-socketpath --description "Gets the IPC socket path and prints it, then exits."

View File

@ -0,0 +1,25 @@
# swaymsg(1) completion
complete -f -c swaymsg
complete -c swaymsg -s h -l help --description "Show help message and quit."
complete -c swaymsg -s m -l monitor --description "Monitor subscribed events until killed."
complete -c swaymsg -s p -l pretty --description "Use pretty output even when not using a tty."
complete -c swaymsg -s q -l quiet --description "Sends the IPC message but does not print the response from sway."
complete -c swaymsg -s r -l raw --description "Use raw output even if using tty."
complete -c swaymsg -s s -l socket -r --description "Use the specified socket path. Otherwise, swaymsg will ask where the socket is (which is the value of $SWAYSOCK, then of $I3SOCK)."
complete -c swaymsg -s v -l version --description "Print the version (of swaymsg) and quit."
complete -c swaymsg -s t -l type -fr --description "Specify the type of IPC message."
complete -c swaymsg -s t -l type -fra 'get_workspaces' --description "Gets a JSON-encoded list of workspaces and their status."
complete -c swaymsg -s t -l type -fra 'get_inputs' --description "Gets a JSON-encoded list of current inputs."
complete -c swaymsg -s t -l type -fra 'get_outputs' --description "Gets a JSON-encoded list of current outputs."
complete -c swaymsg -s t -l type -fra 'get_tree' --description "Gets a JSON-encoded layout tree of all open windows, containers, outputs, workspaces, and so on."
complete -c swaymsg -s t -l type -fra 'get_marks' --description "Get a JSON-encoded list of marks."
complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar."
complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway."
complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes."
complete -c swaymsg -s t -l type -fra 'get_binding_state' --description "Get JSON-encoded info about the current binding state."
complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration."
complete -c swaymsg -s t -l type -fra 'get_seats' --description "Gets a JSON-encoded list of all seats, its properties and all assigned devices."
complete -c swaymsg -s t -l type -fra 'send_tick' --description "Sends a tick event to all subscribed clients."
complete -c swaymsg -s t -l type -fra 'subscribe' --description "Subscribe to a list of event types."

View File

@ -0,0 +1,30 @@
# swaynag
complete -f -c swaynag
complete -c swaynag -s C -l config -r --description 'The config file to use. Default: $HOME/.swaynag/config, $XDG_CONFIG_HOME/swaynag/config, and SYSCONFDIR/swaynag/config.'
complete -c swaynag -s d -l debug --description 'Enable debugging.'
complete -c swaynag -s e -l edge -fr --description 'Set the edge to use: top or bottom'
complete -c swaynag -s f -l font -r --description 'Set the font to use.'
complete -c swaynag -s h -l help --description 'Show help message and quit.'
complete -c swaynag -s b -l button -fr --description 'Create a button with a text and an action which is executed when pressed. Multiple buttons can be defined by providing the flag multiple times.'
complete -c swaynag -s l -l detailed-message --description 'Read a detailed message from stdin. A button to toggle details will be added. Details are shown in a scrollable multi-line text area.'
complete -c swaynag -s L -l detailed-button -fr --description 'Set the text for the button that toggles details. This has no effect if there is not a detailed message. The default is "Toggle details".'
complete -c swaynag -s m -l message -fr --description 'Set the message text.'
complete -c swaynag -s o -l output -fr --description 'Set the output to use.'
complete -c swaynag -s s -l dismiss-button -fr --description 'Sets the text for the dismiss nagbar button. The default is "X".'
complete -c swaynag -s t -l type -fr --description 'Set the message type. Two types are created by default "error" and "warning". Custom types can be defined in the config file.'
complete -c swaynag -s v -l version --description 'Show the version number and quit.'
# Appearance
complete -c swaynag -l background -fr --description 'Set the color of the background.'
complete -c swaynag -l border -fr --description 'Set the color of the border.'
complete -c swaynag -l border-bottom -fr --description 'Set the color of the bottom border.'
complete -c swaynag -l button-background -fr --description 'Set the color for the background for buttons.'
complete -c swaynag -l text -fr --description 'Set the text color.'
complete -c swaynag -l border-bottom-size -fr --description 'Set the thickness of the bottom border.'
complete -c swaynag -l message-padding -fr --description 'Set the padding for the message.'
complete -c swaynag -l details-border-size -fr --description 'Set the thickness for the details border.'
complete -c swaynag -l button-border-size -fr --description 'Set the thickness for the button border.'
complete -c swaynag -l button-gap -fr --description 'Set the size of the gap between buttons.'
complete -c swaynag -l button-dismiss-gap -fr --description 'Set the size of the gap between the dismiss button and another button.'
complete -c swaynag -l button-margin-right -fr --description 'Set the margin from the right of the dismiss button to edge.'
complete -c swaynag -l button-padding -fr --description 'Set the padding for the button text.'

57
completions/meson.build Normal file
View File

@ -0,0 +1,57 @@
if get_option('zsh-completions')
zsh_files = files(
'zsh/_sway',
'zsh/_swaymsg',
)
zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')
install_data(zsh_files, install_dir: zsh_install_dir)
endif
if get_option('bash-completions')
bash_comp = dependency('bash-completion', required: false)
bash_files = files(
'bash/sway',
'bash/swaymsg',
)
if get_option('swaybar')
bash_files += files('bash/swaybar')
endif
if bash_comp.found()
bash_install_dir = bash_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
endif
install_data(bash_files, install_dir: bash_install_dir)
endif
if get_option('fish-completions')
fish_comp = dependency('fish', required: false)
fish_files = files(
'fish/sway.fish',
'fish/swaymsg.fish',
)
if get_option('swaynag')
fish_files += files('fish/swaynag.fish')
endif
if fish_comp.found()
fish_install_dir = fish_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
fish_install_dir = join_paths(datadir, 'fish', 'vendor_completions.d')
endif
install_data(fish_files, install_dir: fish_install_dir)
endif

View File

@ -13,8 +13,8 @@
#
# -------------------------------
_arguments -s \
'(-v --version)'{-v,--version}'[shows version]' \
'(-h --help)'{-h,--help}'[shows help message]' \
'(-v --version)'{-v,--version}'[Show the version number and quit]' \
'(-h --help)'{-h,--help}'[Show help message and quit]' \
'(-c --config)'{-c,--config}'[Specify a config file]:files:_files' \
'(-C --validate)'{-C,--validate}'[Check validity of the config file, then exit]' \
'(-d --debug)'{-d,--debug}'[Enables full logging, including debug information]' \

13
completions/zsh/_swaybar Normal file
View File

@ -0,0 +1,13 @@
#compdef swaybar
#
# Completion script for swaybar
#
local bars=($(swaymsg -t get_bar_config | jq -r '.[]'))
_arguments -s \
'(-h --help)'{-h,--help}'[Show help message and quit]' \
'(-v --version)'{-v,--version}'[Show version and quit]' \
'(-s --socket)'{-s,--socket}'[Connect to sway via socket]:filename:_files' \
'(-b --bar_id)'{-b,--bar-id}'[Bar ID for which to get the configuration]:filename:($bars)'\
'(-d --debug)'{-d,--debug}'[Enable debugging]'

View File

@ -1,14 +0,0 @@
#compdef swaylock
#
# Completion script for swaylock
#
_arguments -s \
'(-v --version)'{-v,--version}'[Show the version number and quit]' \
'(-h --help)'{-h,--help}'[Show help message and quit]' \
'(-f --daemonize)'{-f, --daemonize}'[Detach from the controlling terminal]'\
'(-c --color)'{-c,--color}'[Specify a color (rrggbb)]' \
'(-i --image)'{-i,--image}'[Display an image]:files:_files' \
'(-s --scaling)'{-s,--scaling}'[Scaling mode]:mode:(stretch fill fit center tile)' \
'(-u --no-unlock-indicator)'{-u,--no-unlock-indicator}'[Disable the unlock indicator]'
'(--socket)'{--socket}'[Use the specified socket path.]:files:_files' \

View File

@ -23,13 +23,18 @@ types=(
'get_bar_config'
'get_version'
'get_binding_modes'
'get_binding_state'
'get_config'
'send_tick'
'subscribe'
)
_arguments -s \
'(-v --version)'{-v,--version}'[Print the version (of swaymsg) and quit]' \
'(-h --help)'{-h,--help}'[Shows help message]' \
'(-q --quiet)'{-q,--quiet}'[Sends the IPC message but does not print the response from sway]' \
'(-s --socket)'{-s,--socket}'[Use the specified socket path.]:files:_files' \
'(-t --type)'{-t,--type}'[Specify the type of IPC message.]:type:{_describe "type" types}'
'(-h --help)'{-h,--help}'[Show help message and quit]' \
'(-m --monitor)'{-m,--monitor}'[Monitor until killed (-t SUBSCRIBE only)]' \
'(-p --pretty)'{-p,--pretty}'[Use pretty output even when not using a tty]' \
'(-q --quiet)'{-q,--quiet}'[Be quiet]' \
'(-r --raw)'{-r,--raw}'[Use raw output even if using a tty]' \
'(-s --socket)'{-s,--socket}'[Use the specified socket path]:files:_files' \
'(-t --type)'{-t,--type}'[Specify the message type]:type:{_describe "type" types}' \
'(-v --version)'{-v,--version}'[Show the version number and quit]'

View File

@ -14,14 +14,15 @@ set $down j
set $up k
set $right l
# Your preferred terminal emulator
set $term urxvt
set $term foot
# Your preferred application launcher
# Note: it's recommended that you pass the final command to sway
set $menu dmenu_path | dmenu | xargs swaymsg exec
# Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on.
set $menu dmenu_path | wmenu | xargs swaymsg exec --
### Output configuration
#
# Default wallpaper (more resolutions are available in __DATADIR__/backgrounds/sway/)
# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# Example configuration:
@ -34,14 +35,13 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# Example configuration:
#
#exec swayidle \
# timeout 300 'swaylock -c 000000' \
# timeout 600 'swaymsg "output * dpms off"' \
# resume 'swaymsg "output * dpms on"' \
# before-sleep 'swaylock -c 000000'
# exec swayidle -w \
# timeout 300 'swaylock -f -c 000000' \
# timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
# before-sleep 'swaylock -f -c 000000'
#
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 600 seconds, and turn your screens back on when
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.
### Input configuration
@ -62,13 +62,13 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# Basics:
#
# start a terminal
# Start a terminal
bindsym $mod+Return exec $term
# kill focused window
# Kill focused window
bindsym $mod+Shift+q kill
# start your launcher
# Start your launcher
bindsym $mod+d exec $menu
# Drag floating windows by holding down $mod and left mouse button.
@ -78,11 +78,11 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
# mouse button for dragging.
floating_modifier $mod normal
# reload the configuration file
# Reload the configuration file
bindsym $mod+Shift+c reload
# exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'
# Exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'
#
# Moving around:
#
@ -91,18 +91,18 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
# or use $mod+[up|down|left|right]
# Or use $mod+[up|down|left|right]
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# _move_ the focused window with the same, but add Shift
# Move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
# ditto, with arrow keys
# Ditto, with arrow keys
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
@ -110,28 +110,28 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# Workspaces:
#
# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10
# Switch to workspace
bindsym $mod+1 workspace number 1
bindsym $mod+2 workspace number 2
bindsym $mod+3 workspace number 3
bindsym $mod+4 workspace number 4
bindsym $mod+5 workspace number 5
bindsym $mod+6 workspace number 6
bindsym $mod+7 workspace number 7
bindsym $mod+8 workspace number 8
bindsym $mod+9 workspace number 9
bindsym $mod+0 workspace number 10
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number 1
bindsym $mod+Shift+2 move container to workspace number 2
bindsym $mod+Shift+3 move container to workspace number 3
bindsym $mod+Shift+4 move container to workspace number 4
bindsym $mod+Shift+5 move container to workspace number 5
bindsym $mod+Shift+6 move container to workspace number 6
bindsym $mod+Shift+7 move container to workspace number 7
bindsym $mod+Shift+8 move container to workspace number 8
bindsym $mod+Shift+9 move container to workspace number 9
bindsym $mod+Shift+0 move container to workspace number 10
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.
#
@ -157,7 +157,7 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
# Swap focus between the tiling area and the floating area
bindsym $mod+space focus mode_toggle
# move focus to the parent container
# Move focus to the parent container
bindsym $mod+a focus parent
#
# Scratchpad:
@ -184,13 +184,13 @@ mode "resize" {
bindsym $up resize shrink height 10px
bindsym $right resize grow width 10px
# ditto, with arrow keys
# Ditto, with arrow keys
bindsym Left resize shrink width 10px
bindsym Down resize grow height 10px
bindsym Up resize shrink height 10px
bindsym Right resize grow width 10px
# return to default mode
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
@ -202,6 +202,11 @@ bindsym $mod+r mode "resize"
# Read `man 5 sway-bar` for more information about this section.
bar {
position top
# When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time.
status_command while date +'%Y-%m-%d %X'; do sleep 1; done
colors {
statusline #ffffff
background #323232

View File

@ -1,63 +0,0 @@
#
# Replicate some of Awesome's default layout manipulation configuration for Sway
#
# Differences:
# - Layout switching doesn't use the spacebar (i.e. i3/Sway behavior to switch to/from floating windows)
# and uses the 'A' key instead (as in auto)
# - Resizing windows uses i3/Sway's more versatile Mod4+r
# - no tags
# - no Maximize/Minize, alternatives to Maximize would be to switch to Stacked/Tabbed layouts
# via Mod4+w or Mod4+s.
# - kill focused client is available on Mod4+Shift+q (instead of Mod4+Shift+c, which maps to Sway's
# config reload)
# - probably many more ...
# Awesome-style container traversal using Vim-like binding
set $next j
set $prev k
#
# Moving around:
#
# Move your focus around
bindsym $mod+$next focus next
bindsym $mod+$prev focus prev
# _move_ the focused window with the same, but add Shift
bindsym $mod+Shift+$next move next
bindsym $mod+Shift+$prev move prev
#
# Layout:
#
workspace_layout auto left
# This is usually bound to $mod+space, but this works well in practice by keeping
# all the layout switching keys grouped together.
bindsym $mod+a layout auto next
bindsym $mod+Shift+a layout auto prev
# Promote a child to master position in an auto layout
bindsym $mod+Control+Return move first
# Increase/decrease number of master elements in auto layout
bindsym $mod+Shift+h layout auto master inc 1
bindsym $mod+Shift+l layout auto master inc -1
# Increase/decrease number of slave element groups in auto layout
bindsym $mod+Control+h layout auto ncol inc 1
bindsym $mod+Control+l layout auto ncol inc -1
#
# Resizing containers:
# Again, not really the way Awesome works well, but in spirit with i3/Sway and it works well.
#
mode "resize" {
bindsym Left resize shrink width 20 px
bindsym Down resize grow height 20 px
bindsym Up resize shrink height 20 px
bindsym Right resize grow width 20 px
}
bindsym $mod+r mode "resize"
new_window pixel 1

View File

@ -1,20 +0,0 @@
#ifndef _SWAY_BACKGROUND_IMAGE_H
#define _SWAY_BACKGROUND_IMAGE_H
#include "cairo.h"
enum background_mode {
BACKGROUND_MODE_STRETCH,
BACKGROUND_MODE_FILL,
BACKGROUND_MODE_FIT,
BACKGROUND_MODE_CENTER,
BACKGROUND_MODE_TILE,
BACKGROUND_MODE_SOLID_COLOR,
BACKGROUND_MODE_INVALID,
};
enum background_mode parse_background_mode(const char *mode);
cairo_surface_t *load_background_image(const char *path);
void render_background_image(cairo_t *cairo, cairo_surface_t *image,
enum background_mode mode, int buffer_width, int buffer_height);
#endif

View File

@ -1,19 +0,0 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
#include <stdint.h>
#include <cairo/cairo.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
int width, int height);
#include "config.h"
#ifdef HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(
const GdkPixbuf *gdkbuf);
#endif //WITH_GDK_PIXBUF
#endif

14
include/cairo_util.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef _SWAY_CAIRO_UTIL_H
#define _SWAY_CAIRO_UTIL_H
#include "config.h"
#include <stdint.h>
#include <cairo.h>
#include <wayland-client-protocol.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
cairo_subpixel_order_t to_cairo_subpixel_order(enum wl_output_subpixel subpixel);
cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
int width, int height);
#endif

104
include/gesture.h Normal file
View File

@ -0,0 +1,104 @@
#ifndef _SWAY_GESTURE_H
#define _SWAY_GESTURE_H
#include <stdbool.h>
#include <stdint.h>
/**
* A gesture type used in binding.
*/
enum gesture_type {
GESTURE_TYPE_NONE = 0,
GESTURE_TYPE_HOLD,
GESTURE_TYPE_PINCH,
GESTURE_TYPE_SWIPE,
};
// Turns single type enum value to constant string representation.
const char *gesture_type_string(enum gesture_type direction);
// Value to use to accept any finger count
extern const uint8_t GESTURE_FINGERS_ANY;
/**
* A gesture direction used in binding.
*/
enum gesture_direction {
GESTURE_DIRECTION_NONE = 0,
// Directions based on delta x and y
GESTURE_DIRECTION_UP = 1 << 0,
GESTURE_DIRECTION_DOWN = 1 << 1,
GESTURE_DIRECTION_LEFT = 1 << 2,
GESTURE_DIRECTION_RIGHT = 1 << 3,
// Directions based on scale
GESTURE_DIRECTION_INWARD = 1 << 4,
GESTURE_DIRECTION_OUTWARD = 1 << 5,
// Directions based on rotation
GESTURE_DIRECTION_CLOCKWISE = 1 << 6,
GESTURE_DIRECTION_COUNTERCLOCKWISE = 1 << 7,
};
// Turns single direction enum value to constant string representation.
const char *gesture_direction_string(enum gesture_direction direction);
/**
* Struct representing a pointer gesture
*/
struct gesture {
enum gesture_type type;
uint8_t fingers;
uint32_t directions;
};
/**
* Parses gesture from <gesture>[:<fingers>][:<directions>] string.
*
* Return NULL on success, otherwise error message string
*/
char *gesture_parse(const char *input, struct gesture *output);
// Turns gesture into string representation
char *gesture_to_string(struct gesture *gesture);
// Check if gesture is of certain type and finger count.
bool gesture_check(struct gesture *target,
enum gesture_type type, uint8_t fingers);
// Check if a gesture target/binding is match by other gesture/input
bool gesture_match(struct gesture *target,
struct gesture *to_match, bool exact);
// Returns true if gesture are exactly the same
bool gesture_equal(struct gesture *a, struct gesture *b);
// Compare distance between two matched target gestures.
int8_t gesture_compare(struct gesture *a, struct gesture *b);
// Small helper struct to track gestures over time
struct gesture_tracker {
enum gesture_type type;
uint8_t fingers;
double dx, dy;
double scale;
double rotation;
};
// Begin gesture tracking
void gesture_tracker_begin(struct gesture_tracker *tracker,
enum gesture_type type, uint8_t fingers);
// Check if the provides type is currently being tracked
bool gesture_tracker_check(struct gesture_tracker *tracker,
enum gesture_type type);
// Update gesture track with new data point
void gesture_tracker_update(struct gesture_tracker *tracker, double dx,
double dy, double scale, double rotation);
// Reset tracker
void gesture_tracker_cancel(struct gesture_tracker *tracker);
// Reset tracker and return gesture tracked
struct gesture *gesture_tracker_end(struct gesture_tracker *tracker);
#endif

View File

@ -1,7 +1,12 @@
#ifndef _SWAY_IPC_CLIENT_H
#define _SWAY_IPC_CLIENT_H
// arbitrary number, it's probably sufficient, higher number = more memory usage
#define JSON_MAX_DEPTH 512
#include <stdbool.h>
#include <stdint.h>
#include <sys/time.h>
#include "ipc.h"
@ -36,5 +41,9 @@ struct ipc_response *ipc_recv_response(int socketfd);
* Free ipc_response struct
*/
void free_ipc_response(struct ipc_response *response);
/**
* Sets the receive timeout for the IPC socket
*/
bool ipc_set_recv_timeout(int socketfd, struct timeval tv);
#endif

View File

@ -16,6 +16,8 @@ enum ipc_command_type {
IPC_GET_BINDING_MODES = 8,
IPC_GET_CONFIG = 9,
IPC_SEND_TICK = 10,
IPC_SYNC = 11,
IPC_GET_BINDING_STATE = 12,
// sway-specific command types
IPC_GET_INPUTS = 100,
@ -30,6 +32,10 @@ enum ipc_command_type {
IPC_EVENT_BINDING = ((1<<31) | 5),
IPC_EVENT_SHUTDOWN = ((1<<31) | 6),
IPC_EVENT_TICK = ((1<<31) | 7),
// sway-specific event types
IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20),
IPC_EVENT_INPUT = ((1<<31) | 21),
};
#endif

View File

@ -9,7 +9,6 @@ typedef struct {
list_t *create_list(void);
void list_free(list_t *list);
void list_foreach(list_t *list, void (*callback)(void* item));
void list_add(list_t *list, void *item);
void list_insert(list_t *list, int index, void *item);
void list_del(list_t *list, int index);
@ -20,10 +19,17 @@ void list_qsort(list_t *list, int compare(const void *left, const void *right));
// Return index for first item in list that returns 0 for given compare
// function or -1 if none matches.
int list_seq_find(list_t *list, int compare(const void *item, const void *cmp_to), const void *cmp_to);
int list_find(list_t *list, const void *item);
// stable sort since qsort is not guaranteed to be stable
void list_stable_sort(list_t *list, int compare(const void *a, const void *b));
// swap two elements in a list
void list_swap(list_t *list, int src, int dest);
// move item to end of list
void list_move_to_end(list_t *list, void *item);
/* Calls `free` for each item in the list, then frees the list.
* Do not use this to free lists of primitives or items that require more
* complicated deallocation code.
*/
void list_free_items_and_destroy(list_t *list);
#endif

View File

@ -1,7 +1,18 @@
#ifndef _SWAY_LOG_H
#define _SWAY_LOG_H
#include <stdbool.h>
#include <wlr/util/log.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
typedef enum {
SWAY_SILENT = 0,
SWAY_ERROR = 1,
SWAY_INFO = 2,
SWAY_DEBUG = 3,
SWAY_LOG_IMPORTANCE_LAST,
} sway_log_importance_t;
#ifdef __GNUC__
#define ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
@ -9,14 +20,39 @@
#define ATTRIB_PRINTF(start, end)
#endif
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
#define sway_abort(FMT, ...) \
_sway_abort("[%s:%d] " FMT, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
#define sway_assert(COND, FMT, ...) \
_sway_assert(COND, "[%s:%d] %s:" FMT, _wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
void error_handler(int sig);
typedef void (*terminate_callback_t)(int exit_code);
// Will log all messages less than or equal to `verbosity`
// The `terminate` callback is called by `sway_abort`
void sway_log_init(sway_log_importance_t verbosity, terminate_callback_t terminate);
void _sway_log(sway_log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
void _sway_vlog(sway_log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
#ifdef SWAY_REL_SRC_DIR
// strip prefix from __FILE__, leaving the path relative to the project root
#define _SWAY_FILENAME ((const char *)__FILE__ + sizeof(SWAY_REL_SRC_DIR) - 1)
#else
#define _SWAY_FILENAME __FILE__
#endif
#define sway_log(verb, fmt, ...) \
_sway_log(verb, "[%s:%d] " fmt, _SWAY_FILENAME, __LINE__, ##__VA_ARGS__)
#define sway_vlog(verb, fmt, args) \
_sway_vlog(verb, "[%s:%d] " fmt, _SWAY_FILENAME, __LINE__, args)
#define sway_log_errno(verb, fmt, ...) \
sway_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno))
#define sway_abort(FMT, ...) \
_sway_abort("[%s:%d] " FMT, _SWAY_FILENAME, __LINE__, ##__VA_ARGS__)
#define sway_assert(COND, FMT, ...) \
_sway_assert(COND, "[%s:%d] %s:" FMT, _SWAY_FILENAME, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
#endif

54
include/loop.h Normal file
View File

@ -0,0 +1,54 @@
#ifndef _SWAY_LOOP_H
#define _SWAY_LOOP_H
#include <stdbool.h>
/**
* This is an event loop system designed for sway clients, not sway itself.
*
* The loop consists of file descriptors and timers. Typically the Wayland
* display's file descriptor will be one of the fds in the loop.
*/
struct loop;
struct loop_timer;
/**
* Create an event loop.
*/
struct loop *loop_create(void);
/**
* Destroy the event loop (eg. on program termination).
*/
void loop_destroy(struct loop *loop);
/**
* Poll the event loop. This will block until one of the fds has data.
*/
void loop_poll(struct loop *loop);
/**
* Add a file descriptor to the loop.
*/
void loop_add_fd(struct loop *loop, int fd, short mask,
void (*func)(int fd, short mask, void *data), void *data);
/**
* Add a timer to the loop.
*
* When the timer expires, the timer will be removed from the loop and freed.
*/
struct loop_timer *loop_add_timer(struct loop *loop, int ms,
void (*callback)(void *data), void *data);
/**
* Remove a file descriptor from the loop.
*/
bool loop_remove_fd(struct loop *loop, int fd);
/**
* Remove a timer from the loop.
*/
bool loop_remove_timer(struct loop *loop, struct loop_timer *timer);
#endif

View File

@ -3,25 +3,23 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
#include "stringop.h"
/* Utility function which escape characters a & < > ' ".
/**
* Utility function which escape characters a & < > ' ".
*
* If the dest parameter is NULL, then the function returns the length of
* of the escaped src string. The dest_length doesn't matter.
*
* If the dest parameter is not NULL then the fuction escapes the src string
* an puts the escaped string in dest and returns the lenght of the escaped string.
* The dest_length parameter is the size of dest array. If the size of dest is not
* enough, then the function returns -1.
* The function returns the length of the escaped string, optionally writing the
* escaped string to dest if provided.
*/
int escape_markup_text(const char *src, char *dest, int dest_length);
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
size_t escape_markup_text(const char *src, char *dest);
PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc,
const char *text, double scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
double scale, bool markup, const char *fmt, ...);
void pango_printf(cairo_t *cairo, const char *font,
double scale, bool markup, const char *fmt, ...);
void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(8, 9);
void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline);
void render_text(cairo_t *cairo, PangoFontDescription *desc,
double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(5, 6);
#endif

View File

@ -1,6 +1,6 @@
#ifndef _SWAY_BUFFERS_H
#define _SWAY_BUFFERS_H
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
#include <stdbool.h>
#include <stdint.h>

View File

@ -1,10 +0,0 @@
#ifndef _SWAY_READLINE_H
#define _SWAY_READLINE_H
#include <stdio.h>
char *read_line(FILE *file);
char *peek_line(FILE *file, int line_offset, long *position);
char *read_line_buffer(FILE *file, char *string, size_t string_len);
#endif

View File

@ -1,18 +1,17 @@
#ifndef _SWAY_STRINGOP_H
#define _SWAY_STRINGOP_H
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#include "list.h"
#if !HAVE_DECL_SETENV
// Not sure why we need to provide this
extern int setenv(const char *, const char *, int);
#ifdef __GNUC__
#define _SWAY_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
#else
#define _SWAY_ATTRIB_PRINTF(start, end)
#endif
// array of whitespace characters to use for delims
extern const char whitespace[];
char *strip_whitespace(char *str);
char *strip_comments(char *str);
void strip_whitespace(char *str);
void strip_quotes(char *str);
// strcat that does nothing if dest or src is NULL
@ -20,30 +19,25 @@ char *lenient_strcat(char *dest, const char *src);
char *lenient_strncat(char *dest, const char *src, size_t len);
// strcmp that also handles null pointers.
int lenient_strcmp(char *a, char *b);
int lenient_strcmp(const char *a, const char *b);
// Simply split a string with delims, free with `free_flat_list`
// Simply split a string with delims, free with `list_free_items_and_destroy`
list_t *split_string(const char *str, const char *delims);
void free_flat_list(list_t *list);
// Splits an argument string, keeping quotes intact
char **split_args(const char *str, int *argc);
void free_argv(int argc, char **argv);
char *code_strchr(const char *string, char delimiter);
char *code_strstr(const char *haystack, const char *needle);
int unescape_string(char *string);
char *join_args(char **argv, int argc);
char *join_list(list_t *list, char *separator);
/**
* Add quotes around any argv with whitespaces.
*/
void add_quotes(char **argv, int argc);
// split string into 2 by delim.
char *cmdsep(char **stringp, const char *delim);
// Split string into 2 by delim, handle quotes
char *argsep(char **stringp, const char *delim);
char *argsep(char **stringp, const char *delim, char *matched_delim);
// Expand a path using shell replacements such as $HOME and ~
bool expand_path(char **path);
char *vformat_str(const char *fmt, va_list args) _SWAY_ATTRIB_PRINTF(1, 0);
char *format_str(const char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2);
#endif

View File

@ -1,12 +1,16 @@
#ifndef _SWAY_COMMANDS_H
#define _SWAY_COMMANDS_H
#include <wlr/util/edges.h>
#include "config.h"
#include "stringop.h"
struct sway_container;
typedef struct cmd_results *sway_cmd(int argc, char **argv);
struct cmd_handler {
char *command;
const char *command;
sway_cmd *handle;
};
@ -28,7 +32,6 @@ enum cmd_status {
*/
struct cmd_results {
enum cmd_status status;
char *input;
/**
* Human friendly error message, or NULL on success
*/
@ -36,32 +39,37 @@ struct cmd_results {
};
enum expected_args {
EXPECTED_MORE_THAN,
EXPECTED_AT_LEAST,
EXPECTED_LESS_THAN,
EXPECTED_AT_MOST,
EXPECTED_EQUAL_TO
};
struct cmd_results *checkarg(int argc, const char *name,
enum expected_args type, int val);
struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
int handlers_size);
const struct cmd_handler *find_handler(const char *line,
const struct cmd_handler *cmd_handlers, size_t handlers_size);
/**
* Parse and executes a command.
*
* If the command string contains criteria then the command will be executed on
* all matching containers. Otherwise, it'll run on the `con` container. If
* `con` is NULL then it'll run on the currently focused container.
*/
struct cmd_results *execute_command(char *command, struct sway_seat *seat);
list_t *execute_command(char *command, struct sway_seat *seat,
struct sway_container *con);
/**
* Parse and handles a command during config file loading.
*
* Do not use this under normal conditions.
*/
struct cmd_results *config_command(char *command);
struct cmd_results *config_command(char *command, char **new_block);
/**
* Parse and handle a sub command
*/
struct cmd_results *config_subcommand(char **argv, int argc,
struct cmd_handler *handlers, size_t handlers_size);
const struct cmd_handler *handlers, size_t handlers_size);
/*
* Parses a command policy rule.
*/
@ -69,34 +77,50 @@ struct cmd_results *config_commands_command(char *exec);
/**
* Allocates a cmd_results object.
*/
struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...) _SWAY_ATTRIB_PRINTF(2, 3);
/**
* Frees a cmd_results object.
*/
void free_cmd_results(struct cmd_results *results);
/**
* Serializes cmd_results to a JSON string.
* Serializes a list of cmd_results to a JSON string.
*
* Free the JSON string later on.
*/
char *cmd_results_to_json(struct cmd_results *results);
char *cmd_results_to_json(list_t *res_list);
struct cmd_results *add_color(const char *name,
char *buffer, const char *color);
/**
* TODO: Move this function and its dependent functions to container.c.
*/
void container_resize_tiled(struct sway_container *parent, uint32_t axis,
int amount);
struct sway_container *container_find_resize_parent(struct sway_container *con,
uint32_t edge);
/**
* Handlers shared by exec and exec_always.
*/
sway_cmd cmd_exec_validate;
sway_cmd cmd_exec_process;
sway_cmd cmd_assign;
sway_cmd cmd_bar;
sway_cmd cmd_bindcode;
sway_cmd cmd_bindgesture;
sway_cmd cmd_bindswitch;
sway_cmd cmd_bindsym;
sway_cmd cmd_border;
sway_cmd cmd_client_noop;
sway_cmd cmd_client_focused;
sway_cmd cmd_client_focused_inactive;
sway_cmd cmd_client_focused_tab_title;
sway_cmd cmd_client_unfocused;
sway_cmd cmd_client_urgent;
sway_cmd cmd_client_placeholder;
sway_cmd cmd_client_background;
sway_cmd cmd_commands;
sway_cmd cmd_debuglog;
sway_cmd cmd_create_output;
sway_cmd cmd_default_border;
sway_cmd cmd_default_floating_border;
sway_cmd cmd_default_orientation;
@ -110,6 +134,7 @@ sway_cmd cmd_floating_modifier;
sway_cmd cmd_floating_scroll;
sway_cmd cmd_focus;
sway_cmd cmd_focus_follows_mouse;
sway_cmd cmd_focus_on_window_activation;
sway_cmd cmd_focus_wrapping;
sway_cmd cmd_font;
sway_cmd cmd_for_window;
@ -119,6 +144,7 @@ sway_cmd cmd_fullscreen;
sway_cmd cmd_gaps;
sway_cmd cmd_hide_edge_borders;
sway_cmd cmd_include;
sway_cmd cmd_inhibit_idle;
sway_cmd cmd_input;
sway_cmd cmd_seat;
sway_cmd cmd_ipc;
@ -126,15 +152,19 @@ sway_cmd cmd_kill;
sway_cmd cmd_layout;
sway_cmd cmd_log_colors;
sway_cmd cmd_mark;
sway_cmd cmd_max_render_time;
sway_cmd cmd_mode;
sway_cmd cmd_mouse_warping;
sway_cmd cmd_move;
sway_cmd cmd_opacity;
sway_cmd cmd_new_float;
sway_cmd cmd_new_window;
sway_cmd cmd_nop;
sway_cmd cmd_opacity;
sway_cmd cmd_no_focus;
sway_cmd cmd_output;
sway_cmd cmd_permit;
sway_cmd cmd_popup_during_fullscreen;
sway_cmd cmd_primary_selection;
sway_cmd cmd_reject;
sway_cmd cmd_reload;
sway_cmd cmd_rename;
@ -142,7 +172,9 @@ sway_cmd cmd_resize;
sway_cmd cmd_scratchpad;
sway_cmd cmd_seamless_mouse;
sway_cmd cmd_set;
sway_cmd cmd_shortcuts_inhibitor;
sway_cmd cmd_show_marks;
sway_cmd cmd_smart_borders;
sway_cmd cmd_smart_gaps;
sway_cmd cmd_split;
sway_cmd cmd_splith;
@ -152,19 +184,29 @@ sway_cmd cmd_sticky;
sway_cmd cmd_swaybg_command;
sway_cmd cmd_swaynag_command;
sway_cmd cmd_swap;
sway_cmd cmd_tiling_drag;
sway_cmd cmd_tiling_drag_threshold;
sway_cmd cmd_title_align;
sway_cmd cmd_title_format;
sway_cmd cmd_titlebar_border_thickness;
sway_cmd cmd_titlebar_padding;
sway_cmd cmd_unbindcode;
sway_cmd cmd_unbindswitch;
sway_cmd cmd_unbindgesture;
sway_cmd cmd_unbindsym;
sway_cmd cmd_unmark;
sway_cmd cmd_urgent;
sway_cmd cmd_workspace;
sway_cmd cmd_ws_auto_back_and_forth;
sway_cmd cmd_workspace_layout;
sway_cmd cmd_ws_auto_back_and_forth;
sway_cmd cmd_xwayland;
sway_cmd bar_cmd_activate_button;
sway_cmd bar_cmd_bindcode;
sway_cmd bar_cmd_binding_mode_indicator;
sway_cmd bar_cmd_bindsym;
sway_cmd bar_cmd_colors;
sway_cmd bar_cmd_context_button;
sway_cmd bar_cmd_font;
sway_cmd bar_cmd_gaps;
sway_cmd bar_cmd_mode;
sway_cmd bar_cmd_modifier;
sway_cmd bar_cmd_output;
@ -173,16 +215,23 @@ sway_cmd bar_cmd_hidden_state;
sway_cmd bar_cmd_icon_theme;
sway_cmd bar_cmd_id;
sway_cmd bar_cmd_position;
sway_cmd bar_cmd_secondary_button;
sway_cmd bar_cmd_separator_symbol;
sway_cmd bar_cmd_status_command;
sway_cmd bar_cmd_status_edge_padding;
sway_cmd bar_cmd_status_padding;
sway_cmd bar_cmd_pango_markup;
sway_cmd bar_cmd_strip_workspace_numbers;
sway_cmd bar_cmd_strip_workspace_name;
sway_cmd bar_cmd_swaybar_command;
sway_cmd bar_cmd_tray_bindcode;
sway_cmd bar_cmd_tray_bindsym;
sway_cmd bar_cmd_tray_output;
sway_cmd bar_cmd_tray_padding;
sway_cmd bar_cmd_unbindcode;
sway_cmd bar_cmd_unbindsym;
sway_cmd bar_cmd_wrap_scroll;
sway_cmd bar_cmd_workspace_buttons;
sway_cmd bar_cmd_workspace_min_width;
sway_cmd bar_colors_cmd_active_workspace;
sway_cmd bar_colors_cmd_background;
@ -198,42 +247,69 @@ sway_cmd bar_colors_cmd_urgent_workspace;
sway_cmd input_cmd_seat;
sway_cmd input_cmd_accel_profile;
sway_cmd input_cmd_calibration_matrix;
sway_cmd input_cmd_click_method;
sway_cmd input_cmd_drag;
sway_cmd input_cmd_drag_lock;
sway_cmd input_cmd_dwt;
sway_cmd input_cmd_dwtp;
sway_cmd input_cmd_events;
sway_cmd input_cmd_left_handed;
sway_cmd input_cmd_map_from_region;
sway_cmd input_cmd_map_to_output;
sway_cmd input_cmd_map_to_region;
sway_cmd input_cmd_middle_emulation;
sway_cmd input_cmd_natural_scroll;
sway_cmd input_cmd_pointer_accel;
sway_cmd input_cmd_rotation_angle;
sway_cmd input_cmd_scroll_factor;
sway_cmd input_cmd_repeat_delay;
sway_cmd input_cmd_repeat_rate;
sway_cmd input_cmd_scroll_button;
sway_cmd input_cmd_scroll_button_lock;
sway_cmd input_cmd_scroll_method;
sway_cmd input_cmd_tap;
sway_cmd input_cmd_tap_button_map;
sway_cmd input_cmd_tool_mode;
sway_cmd input_cmd_xkb_capslock;
sway_cmd input_cmd_xkb_file;
sway_cmd input_cmd_xkb_layout;
sway_cmd input_cmd_xkb_model;
sway_cmd input_cmd_xkb_numlock;
sway_cmd input_cmd_xkb_options;
sway_cmd input_cmd_xkb_rules;
sway_cmd input_cmd_xkb_switch_layout;
sway_cmd input_cmd_xkb_variant;
sway_cmd output_cmd_adaptive_sync;
sway_cmd output_cmd_background;
sway_cmd output_cmd_color_profile;
sway_cmd output_cmd_disable;
sway_cmd output_cmd_dpms;
sway_cmd output_cmd_enable;
sway_cmd output_cmd_max_render_time;
sway_cmd output_cmd_mode;
sway_cmd output_cmd_modeline;
sway_cmd output_cmd_position;
sway_cmd output_cmd_power;
sway_cmd output_cmd_render_bit_depth;
sway_cmd output_cmd_scale;
sway_cmd output_cmd_scale_filter;
sway_cmd output_cmd_subpixel;
sway_cmd output_cmd_toggle;
sway_cmd output_cmd_transform;
sway_cmd output_cmd_unplug;
sway_cmd seat_cmd_attach;
sway_cmd seat_cmd_fallback;
sway_cmd seat_cmd_cursor;
sway_cmd seat_cmd_fallback;
sway_cmd seat_cmd_hide_cursor;
sway_cmd seat_cmd_idle_inhibit;
sway_cmd seat_cmd_idle_wake;
sway_cmd seat_cmd_keyboard_grouping;
sway_cmd seat_cmd_pointer_constraint;
sway_cmd seat_cmd_shortcuts_inhibitor;
sway_cmd seat_cmd_xcursor_theme;
sway_cmd cmd_ipc_cmd;
sway_cmd cmd_ipc_events;

View File

@ -4,13 +4,22 @@
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <wlr/types/wlr_box.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/util/box.h>
#include <wlr/render/color.h>
#include <xkbcommon/xkbcommon.h>
#include <xf86drmMode.h>
#include "../include/config.h"
#include "gesture.h"
#include "list.h"
#include "stringop.h"
#include "swaynag.h"
#include "tree/layout.h"
#include "tree/container.h"
#include "sway/input/tablet.h"
#include "sway/tree/root.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
#include <pango/pangocairo.h>
// TODO: Refactor this shit
@ -22,41 +31,79 @@ struct sway_variable {
char *value;
};
enum binding_input_type {
BINDING_KEYCODE,
BINDING_KEYSYM,
BINDING_MOUSE,
BINDING_MOUSECODE,
BINDING_MOUSESYM,
BINDING_SWITCH, // dummy, only used to call seat_execute_command
BINDING_GESTURE // dummy, only used to call seat_execute_command
};
enum binding_flags {
BINDING_RELEASE=1,
BINDING_LOCKED=2, // keyboard only
BINDING_BORDER=4, // mouse only; trigger on container border
BINDING_CONTENTS=8, // mouse only; trigger on container contents
BINDING_TITLEBAR=16 // mouse only; trigger on container titlebar
BINDING_RELEASE = 1 << 0,
BINDING_LOCKED = 1 << 1, // keyboard only
BINDING_BORDER = 1 << 2, // mouse only; trigger on container border
BINDING_CONTENTS = 1 << 3, // mouse only; trigger on container contents
BINDING_TITLEBAR = 1 << 4, // mouse only; trigger on container titlebar
BINDING_CODE = 1 << 5, // keyboard only; convert keysyms into keycodes
BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload
BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor
BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key
BINDING_EXACT = 1 << 9, // gesture only; only trigger on exact match
};
/**
* A key binding and an associated command.
* A key (or mouse) binding and an associated command.
*/
struct sway_binding {
enum binding_input_type type;
int order;
char *input;
uint32_t flags;
list_t *keys; // sorted in ascending order
list_t *syms; // sorted in ascending order; NULL if BINDING_CODE is not set
uint32_t modifiers;
xkb_layout_index_t group;
char *command;
};
enum sway_switch_trigger {
SWAY_SWITCH_TRIGGER_OFF,
SWAY_SWITCH_TRIGGER_ON,
SWAY_SWITCH_TRIGGER_TOGGLE,
};
/**
* A laptop switch binding and an associated command.
*/
struct sway_switch_binding {
enum wlr_switch_type type;
enum sway_switch_trigger trigger;
uint32_t flags;
char *command;
};
/**
* A mouse binding and an associated command.
* A gesture binding and an associated command.
*/
struct sway_mouse_binding {
uint32_t button;
struct sway_gesture_binding {
char *input;
uint32_t flags;
struct gesture gesture;
char *command;
};
/**
* Focus on window activation.
*/
enum sway_fowa {
FOWA_SMART,
FOWA_URGENT,
FOWA_FOCUS,
FOWA_NONE,
};
/**
* A "mode" of keybindings created via the `mode` command.
*/
@ -65,6 +112,8 @@ struct sway_mode {
list_t *keysym_bindings;
list_t *keycode_bindings;
list_t *mouse_bindings;
list_t *switch_bindings;
list_t *gesture_bindings;
bool pango;
};
@ -74,23 +123,46 @@ struct input_config_mapped_from_region {
bool mm;
};
struct calibration_matrix {
bool configured;
float matrix[6];
};
enum input_config_mapped_to {
MAPPED_TO_DEFAULT,
MAPPED_TO_OUTPUT,
MAPPED_TO_REGION,
};
struct input_config_tool {
enum wlr_tablet_tool_type type;
enum sway_tablet_tool_mode mode;
};
/**
* options for input devices
*/
struct input_config {
char *identifier;
const char *input_type;
int accel_profile;
struct calibration_matrix calibration_matrix;
int click_method;
int drag;
int drag_lock;
int dwt;
int dwtp;
int left_handed;
int middle_emulation;
int natural_scroll;
float pointer_accel;
float rotation_angle;
float scroll_factor;
int repeat_delay;
int repeat_rate;
int scroll_button;
int scroll_button_lock;
int scroll_method;
int send_events;
int tap;
@ -101,12 +173,20 @@ struct input_config {
char *xkb_options;
char *xkb_rules;
char *xkb_variant;
char *xkb_file;
bool xkb_file_is_set;
int xkb_numlock;
int xkb_capslock;
struct input_config_mapped_from_region *mapped_from_region;
enum input_config_mapped_to mapped_to;
char *mapped_to_output;
struct wlr_box *mapped_to_region;
list_t *tools;
bool capturable;
struct wlr_box region;
@ -120,6 +200,39 @@ struct seat_attachment_config {
// TODO other things are configured here for some reason
};
enum seat_config_hide_cursor_when_typing {
HIDE_WHEN_TYPING_DEFAULT, // the default is currently disabled
HIDE_WHEN_TYPING_ENABLE,
HIDE_WHEN_TYPING_DISABLE,
};
enum seat_config_allow_constrain {
CONSTRAIN_DEFAULT, // the default is currently enabled
CONSTRAIN_ENABLE,
CONSTRAIN_DISABLE,
};
enum seat_config_shortcuts_inhibit {
SHORTCUTS_INHIBIT_DEFAULT, // the default is currently enabled
SHORTCUTS_INHIBIT_ENABLE,
SHORTCUTS_INHIBIT_DISABLE,
};
enum seat_keyboard_grouping {
KEYBOARD_GROUP_DEFAULT, // the default is currently smart
KEYBOARD_GROUP_NONE,
KEYBOARD_GROUP_SMART, // keymap and repeat info
};
enum sway_input_idle_source {
IDLE_SOURCE_KEYBOARD = 1 << 0,
IDLE_SOURCE_POINTER = 1 << 1,
IDLE_SOURCE_TOUCH = 1 << 2,
IDLE_SOURCE_TABLET_PAD = 1 << 3,
IDLE_SOURCE_TABLET_TOOL = 1 << 4,
IDLE_SOURCE_SWITCH = 1 << 5,
};
/**
* Options for multiseat and other misc device configurations
*/
@ -127,12 +240,29 @@ struct seat_config {
char *name;
int fallback; // -1 means not set
list_t *attachments; // list of seat_attachment configs
int hide_cursor_timeout;
enum seat_config_hide_cursor_when_typing hide_cursor_when_typing;
enum seat_config_allow_constrain allow_constrain;
enum seat_config_shortcuts_inhibit shortcuts_inhibit;
enum seat_keyboard_grouping keyboard_grouping;
uint32_t idle_inhibit_sources, idle_wake_sources;
struct {
char *name;
int size;
} xcursor_theme;
};
enum config_dpms {
DPMS_IGNORE,
DPMS_ON,
DPMS_OFF
enum scale_filter_mode {
SCALE_FILTER_DEFAULT, // the default is currently smart
SCALE_FILTER_LINEAR,
SCALE_FILTER_NEAREST,
SCALE_FILTER_SMART,
};
enum render_bit_depth {
RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8
RENDER_BIT_DEPTH_8,
RENDER_BIT_DEPTH_10,
};
/**
@ -143,28 +273,73 @@ enum config_dpms {
struct output_config {
char *name;
int enabled;
int power;
int width, height;
float refresh_rate;
int custom_mode;
drmModeModeInfo drm_mode;
int x, y;
float scale;
enum scale_filter_mode scale_filter;
int32_t transform;
enum wl_output_subpixel subpixel;
int max_render_time; // In milliseconds
int adaptive_sync;
enum render_bit_depth render_bit_depth;
bool set_color_transform;
struct wlr_color_transform *color_transform;
char *background;
char *background_option;
enum config_dpms dpms_state;
char *background_fallback;
};
/**
* Maps a workspace name to an output name.
*
* Set via `workspace <x> output <y>`
* An output config pre-matched to an output
*/
struct workspace_output {
char *output;
struct matched_output_config {
struct sway_output *output;
struct output_config *config;
};
/**
* Stores size of gaps for each side
*/
struct side_gaps {
int top;
int right;
int bottom;
int left;
};
enum smart_gaps_mode {
SMART_GAPS_OFF,
SMART_GAPS_ON,
SMART_GAPS_INVERSE_OUTER,
};
/**
* Stores configuration for a workspace, regardless of whether the workspace
* exists.
*/
struct workspace_config {
char *workspace;
list_t *outputs;
int gaps_inner;
struct side_gaps gaps_outer;
};
enum pango_markup_config {
PANGO_MARKUP_DISABLED = false,
PANGO_MARKUP_ENABLED = true,
PANGO_MARKUP_DEFAULT // The default is font dependent ("pango:" prefix)
};
struct bar_config {
char *swaybar_command;
struct wl_client *client;
struct wl_listener client_destroy;
/**
* One of "dock", "hide", "invisible"
*
@ -178,6 +353,7 @@ struct bar_config {
* In "show" mode, it will always be shown on top of the active workspace.
*/
char *hidden_state;
bool visible_by_modifier; // only relevant in "hide" mode
/**
* Id name used to identify the bar through IPC.
*
@ -190,17 +366,20 @@ struct bar_config {
char *position;
list_t *bindings;
char *status_command;
bool pango_markup;
char *swaybar_command;
enum pango_markup_config pango_markup;
char *font;
int height; // -1 not defined
bool workspace_buttons;
bool wrap_scroll;
char *separator_symbol;
bool strip_workspace_numbers;
bool strip_workspace_name;
bool binding_mode_indicator;
bool verbose;
pid_t pid;
struct side_gaps gaps;
int status_padding;
int status_edge_padding;
uint32_t workspace_min_width;
struct {
char *background;
char *statusline;
@ -224,8 +403,29 @@ struct bar_config {
char *binding_mode_bg;
char *binding_mode_text;
} colors;
#if HAVE_TRAY
char *icon_theme;
struct wl_list tray_bindings; // struct tray_binding::link
list_t *tray_outputs; // char *
int tray_padding;
#endif
};
struct bar_binding {
uint32_t button;
bool release;
char *command;
};
#if HAVE_TRAY
struct tray_binding {
uint32_t button;
const char *command;
struct wl_list link; // struct tray_binding::link
};
#endif
struct border_colors {
float border[4];
float background[4];
@ -235,74 +435,53 @@ struct border_colors {
};
enum edge_border_types {
E_NONE, /**< Don't hide edge borders */
E_VERTICAL, /**< hide vertical edge borders */
E_HORIZONTAL, /**< hide horizontal edge borders */
E_BOTH, /**< hide vertical and horizontal edge borders */
E_SMART /**< hide both if precisely one window is present in workspace */
E_NONE, /**< Don't hide edge borders */
E_VERTICAL, /**< hide vertical edge borders */
E_HORIZONTAL, /**< hide horizontal edge borders */
E_BOTH, /**< hide vertical and horizontal edge borders */
};
enum command_context {
CONTEXT_CONFIG = 1,
CONTEXT_BINDING = 2,
CONTEXT_IPC = 4,
CONTEXT_CRITERIA = 8,
CONTEXT_ALL = 0xFFFFFFFF,
enum edge_border_smart_types {
ESMART_OFF,
ESMART_ON, /**< hide edges if precisely one window is present in workspace */
ESMART_NO_GAPS, /**< hide edges if one window and gaps to edge is zero */
};
struct command_policy {
char *command;
uint32_t context;
enum sway_popup_during_fullscreen {
POPUP_SMART,
POPUP_IGNORE,
POPUP_LEAVE,
};
enum secure_feature {
FEATURE_LOCK = 1,
FEATURE_PANEL = 2,
FEATURE_BACKGROUND = 4,
FEATURE_SCREENSHOT = 8,
FEATURE_FULLSCREEN = 16,
FEATURE_KEYBOARD = 32,
FEATURE_MOUSE = 64,
};
struct feature_policy {
char *program;
uint32_t features;
};
enum ipc_feature {
IPC_FEATURE_COMMAND = 1,
IPC_FEATURE_GET_WORKSPACES = 2,
IPC_FEATURE_GET_OUTPUTS = 4,
IPC_FEATURE_GET_TREE = 8,
IPC_FEATURE_GET_MARKS = 16,
IPC_FEATURE_GET_BAR_CONFIG = 32,
IPC_FEATURE_GET_VERSION = 64,
IPC_FEATURE_GET_INPUTS = 128,
IPC_FEATURE_EVENT_WORKSPACE = 256,
IPC_FEATURE_EVENT_OUTPUT = 512,
IPC_FEATURE_EVENT_MODE = 1024,
IPC_FEATURE_EVENT_WINDOW = 2048,
IPC_FEATURE_EVENT_BINDING = 4096,
IPC_FEATURE_EVENT_INPUT = 8192,
IPC_FEATURE_GET_SEATS = 16384,
IPC_FEATURE_ALL_COMMANDS =
1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 16384,
IPC_FEATURE_ALL_EVENTS = 256 | 512 | 1024 | 2048 | 4096 | 8192,
IPC_FEATURE_ALL = IPC_FEATURE_ALL_COMMANDS | IPC_FEATURE_ALL_EVENTS,
};
struct ipc_policy {
char *program;
uint32_t features;
enum focus_follows_mouse_mode {
FOLLOWS_NO,
FOLLOWS_YES,
FOLLOWS_ALWAYS,
};
enum focus_wrapping_mode {
WRAP_NO,
WRAP_YES,
WRAP_FORCE
WRAP_FORCE,
WRAP_WORKSPACE,
};
enum mouse_warping_mode {
WARP_NO,
WARP_OUTPUT,
WARP_CONTAINER,
};
enum alignment {
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT,
};
enum xwayland_mode {
XWAYLAND_MODE_DISABLED,
XWAYLAND_MODE_LAZY,
XWAYLAND_MODE_IMMEDIATE,
};
/**
@ -315,16 +494,16 @@ struct sway_config {
list_t *modes;
list_t *bars;
list_t *cmd_queue;
list_t *workspace_outputs;
list_t *workspace_configs;
list_t *output_configs;
list_t *input_configs;
list_t *input_type_configs;
list_t *seat_configs;
list_t *criteria;
list_t *no_focus;
list_t *active_bar_modifiers;
struct sway_mode *current_mode;
struct bar_config *current_bar;
char *swaybg_command;
uint32_t floating_mod;
bool floating_mod_inverse;
uint32_t dragging_key;
@ -335,14 +514,27 @@ struct sway_config {
char *floating_scroll_right_cmd;
enum sway_container_layout default_orientation;
enum sway_container_layout default_layout;
char *font;
size_t font_height;
char *font; // Used for IPC.
PangoFontDescription *font_description; // Used internally for rendering and validating.
int font_height;
int font_baseline;
bool pango_markup;
int titlebar_border_thickness;
int titlebar_h_padding;
int titlebar_v_padding;
size_t urgent_timeout;
enum sway_fowa focus_on_window_activation;
enum sway_popup_during_fullscreen popup_during_fullscreen;
enum xwayland_mode xwayland;
// swaybg
char *swaybg_command;
struct wl_client *swaybg_client;
struct wl_listener swaybg_client_destroy;
// Flags
bool focus_follows_mouse;
bool mouse_warping;
enum focus_follows_mouse_mode focus_follows_mouse;
enum mouse_warping_mode mouse_warping;
enum focus_wrapping_mode focus_wrapping;
bool active;
bool failed;
@ -351,42 +543,52 @@ struct sway_config {
bool validating;
bool auto_back_and_forth;
bool show_marks;
enum alignment title_align;
bool primary_selection;
bool edge_gaps;
bool smart_gaps;
bool tiling_drag;
int tiling_drag_threshold;
enum smart_gaps_mode smart_gaps;
int gaps_inner;
int gaps_outer;
struct side_gaps gaps_outer;
list_t *config_chain;
bool user_config_path;
const char *current_config_path;
const char *current_config;
int current_config_line_number;
char *current_config_line;
enum sway_container_border border;
enum sway_container_border floating_border;
int border_thickness;
int floating_border_thickness;
enum edge_border_types hide_edge_borders;
enum edge_border_smart_types hide_edge_borders_smart;
bool hide_lone_tab;
// border colors
struct {
struct border_colors focused;
struct border_colors focused_inactive;
struct border_colors focused_tab_title;
struct border_colors unfocused;
struct border_colors urgent;
struct border_colors placeholder;
float background[4];
} border_colors;
bool has_focused_tab_title;
// floating view
int32_t floating_maximum_width;
int32_t floating_maximum_height;
int32_t floating_minimum_width;
int32_t floating_minimum_height;
// Security
list_t *command_policies;
list_t *feature_policies;
list_t *ipc_policies;
// The keysym to keycode translation
struct xkb_state *keysym_translation_state;
// Context for command handlers
struct {
@ -394,8 +596,10 @@ struct sway_config {
struct output_config *output_config;
struct seat_config *seat_config;
struct sway_seat *seat;
struct sway_container *current_container;
bool using_criteria;
struct sway_node *node;
struct sway_container *container;
struct sway_workspace *workspace;
bool node_overridden; // True if the node is selected by means other than focus
struct {
int argc;
char **argv;
@ -412,7 +616,7 @@ bool load_main_config(const char *path, bool is_active, bool validating);
/**
* Loads an included config. Can only be used after load_main_config.
*/
bool load_include_configs(const char *path, struct sway_config *config,
void load_include_configs(const char *path, struct sway_config *config,
struct swaynag_instance *swaynag);
/**
@ -421,6 +625,21 @@ bool load_include_configs(const char *path, struct sway_config *config,
bool read_config(FILE *file, struct sway_config *config,
struct swaynag_instance *swaynag);
/**
* Run the commands that were deferred when reading the config file.
*/
void run_deferred_commands(void);
/**
* Run the binding commands that were deferred when initializing the inputs
*/
void run_deferred_bindings(void);
/**
* Adds a warning entry to the swaynag instance used for errors.
*/
void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2);
/**
* Free config struct
*/
@ -433,20 +652,19 @@ void free_sway_variable(struct sway_variable *var);
*/
char *do_var_replacement(char *str);
struct cmd_results *check_security_config();
int input_identifier_cmp(const void *item, const void *data);
struct input_config *new_input_config(const char* identifier);
void merge_input_config(struct input_config *dst, struct input_config *src);
struct input_config *copy_input_config(struct input_config *ic);
struct input_config *store_input_config(struct input_config *ic, char **error);
void input_config_fill_rule_names(struct input_config *ic,
struct xkb_rule_names *rules);
void free_input_config(struct input_config *ic);
void apply_input_config(struct input_config *input);
int seat_name_cmp(const void *item, const void *data);
struct seat_config *new_seat_config(const char* name);
@ -457,64 +675,85 @@ struct seat_config *copy_seat_config(struct seat_config *seat);
void free_seat_config(struct seat_config *ic);
struct seat_attachment_config *seat_attachment_config_new();
struct seat_attachment_config *seat_attachment_config_new(void);
struct seat_attachment_config *seat_config_get_attachment(
struct seat_config *seat_config, char *identifier);
void apply_seat_config(struct seat_config *seat);
struct seat_config *store_seat_config(struct seat_config *seat);
int output_name_cmp(const void *item, const void *data);
void output_get_identifier(char *identifier, size_t len,
struct sway_output *output);
const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filter);
struct output_config *new_output_config(const char *name);
void merge_output_config(struct output_config *dst, struct output_config *src);
bool apply_output_configs(struct matched_output_config *configs,
size_t configs_len, bool test_only, bool degrade_to_off);
void apply_output_config(struct output_config *oc,
struct sway_container *output);
void apply_all_output_configs(void);
struct output_config *store_output_config(struct output_config *oc);
void sort_output_configs_by_priority(struct matched_output_config *configs,
size_t configs_len);
void apply_output_config_to_outputs(struct output_config *oc);
/**
* store_output_config stores a new output config. An output may be matched by
* three different config types, in order of precedence: Identifier, name and
* wildcard. When storing a config type of lower precedence, assume that the
* user wants the config to take immediate effect by superseding (clearing) the
* same values from higher presedence configuration.
*/
void store_output_config(struct output_config *oc);
struct output_config *find_output_config(struct sway_output *output);
void free_output_config(struct output_config *oc);
void create_default_output_configs(void);
bool spawn_swaybg(void);
int workspace_output_cmp_workspace(const void *a, const void *b);
int sway_binding_cmp(const void *a, const void *b);
int sway_binding_cmp_qsort(const void *a, const void *b);
int sway_binding_cmp_keys(const void *a, const void *b);
void free_sway_binding(struct sway_binding *sb);
void free_switch_binding(struct sway_switch_binding *binding);
void free_gesture_binding(struct sway_gesture_binding *binding);
void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
void load_swaybars();
void load_swaybar(struct bar_config *bar);
void invoke_swaybar(struct bar_config *bar);
void terminate_swaybg(pid_t pid);
void load_swaybars(void);
struct bar_config *default_bar_config(void);
void free_bar_config(struct bar_config *bar);
void free_bar_binding(struct bar_binding *binding);
void free_workspace_config(struct workspace_config *wsc);
/**
* Updates the value of config->font_height based on the max title height
* reported by each container. If recalculate is true, the containers will
* recalculate their heights before reporting.
* Updates the value of config->font_height based on the metrics for title's
* font as reported by pango.
*
* If the height has changed, all containers will be rearranged to take on the
* new size.
*/
void config_update_font_height(bool recalculate);
void config_update_font_height(void);
/**
* Convert bindsym into bindcode using the first configured layout.
* Return false in case the conversion is unsuccessful.
*/
bool translate_binding(struct sway_binding *binding);
void translate_keysyms(struct input_config *input_config);
void binding_add_translated(struct sway_binding *binding, list_t *bindings);
/* Global config singleton. */
extern struct sway_config *config;

View File

@ -1,16 +1,32 @@
#ifndef _SWAY_CRITERIA_H
#define _SWAY_CRITERIA_H
#include <pcre.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#include "config.h"
#include "list.h"
#include "tree/view.h"
#if WLR_HAS_XWAYLAND
#include "sway/xwayland.h"
#endif
enum criteria_type {
CT_COMMAND = 1 << 0,
CT_ASSIGN_OUTPUT = 1 << 1,
CT_ASSIGN_WORKSPACE = 1 << 2,
CT_NO_FOCUS = 1 << 3,
CT_COMMAND = 1 << 0,
CT_ASSIGN_OUTPUT = 1 << 1,
CT_ASSIGN_WORKSPACE = 1 << 2,
CT_ASSIGN_WORKSPACE_NUMBER = 1 << 3,
CT_NO_FOCUS = 1 << 4,
};
enum pattern_type {
PATTERN_PCRE2,
PATTERN_FOCUSED,
};
struct pattern {
enum pattern_type match_type;
pcre2_code *regex;
};
struct criteria {
@ -19,25 +35,30 @@ struct criteria {
char *cmdlist;
char *target; // workspace or output name for `assign` criteria
pcre *title;
pcre *shell;
pcre *app_id;
pcre *class;
pcre *instance;
pcre *con_mark;
struct pattern *title;
struct pattern *shell;
struct pattern *app_id;
struct pattern *con_mark;
uint32_t con_id; // internal ID
#ifdef HAVE_XWAYLAND
#if WLR_HAS_XWAYLAND
struct pattern *class;
uint32_t id; // X11 window ID
struct pattern *instance;
struct pattern *window_role;
enum atom_name window_type;
#endif
pcre *window_role;
uint32_t window_type;
bool all;
bool floating;
bool tiling;
char urgent; // 'l' for latest or 'o' for oldest
char *workspace;
struct pattern *workspace;
pid_t pid;
};
bool criteria_is_empty(struct criteria *criteria);
bool criteria_is_equal(struct criteria *left, struct criteria *right);
bool criteria_already_exists(struct criteria *criteria);
void criteria_destroy(struct criteria *criteria);
@ -59,8 +80,8 @@ struct criteria *criteria_parse(char *raw, char **error);
list_t *criteria_for_view(struct sway_view *view, enum criteria_type types);
/**
* Compile a list of views matching the given criteria.
* Compile a list of containers matching the given criteria.
*/
list_t *criteria_get_views(struct criteria *criteria);
list_t *criteria_get_containers(struct criteria *criteria);
#endif

View File

@ -1,15 +0,0 @@
#ifndef SWAY_DEBUG_H
#define SWAY_DEBUG_H
// Tree
extern bool enable_debug_tree;
void update_debug_tree();
// Damage
extern const char *damage_debug;
// Transactions
extern int txn_timeout_ms;
extern bool txn_debug;
#endif

17
include/sway/decoration.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _SWAY_DECORATION_H
#define _SWAY_DECORATION_H
#include <wlr/types/wlr_server_decoration.h>
struct sway_server_decoration {
struct wlr_server_decoration *wlr_server_decoration;
struct wl_list link;
struct wl_listener destroy;
struct wl_listener mode;
};
struct sway_server_decoration *decoration_from_surface(
struct wlr_surface *surface);
#endif

View File

@ -1,8 +0,0 @@
#include <wlr/types/wlr_surface.h>
struct sway_container;
void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole);
void desktop_damage_whole_container(struct sway_container *con);

View File

@ -1,28 +1,47 @@
#ifndef _SWAY_DESKTOP_IDLE_INHIBIT_V1_H
#define _SWAY_DESKTOP_IDLE_INHIBIT_V1_H
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle.h>
#include "sway/server.h"
enum sway_idle_inhibit_mode {
INHIBIT_IDLE_APPLICATION, // Application set inhibitor (when visible)
INHIBIT_IDLE_FOCUS, // User set inhibitor when focused
INHIBIT_IDLE_FULLSCREEN, // User set inhibitor when fullscreen + visible
INHIBIT_IDLE_OPEN, // User set inhibitor while open
INHIBIT_IDLE_VISIBLE // User set inhibitor when visible
};
struct sway_idle_inhibit_manager_v1 {
struct wlr_idle_inhibit_manager_v1 *wlr_manager;
struct wl_listener new_idle_inhibitor_v1;
struct wl_list inhibitors;
struct wlr_idle *idle;
};
struct sway_idle_inhibitor_v1 {
struct sway_idle_inhibit_manager_v1 *manager;
struct wlr_idle_inhibitor_v1 *wlr_inhibitor;
struct sway_view *view;
enum sway_idle_inhibit_mode mode;
struct wl_list link;
struct wl_listener destroy;
};
void idle_inhibit_v1_check_active(
struct sway_idle_inhibit_manager_v1 *manager);
bool sway_idle_inhibit_v1_is_active(
struct sway_idle_inhibitor_v1 *inhibitor);
void sway_idle_inhibit_v1_check_active(void);
void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view,
enum sway_idle_inhibit_mode mode);
struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_user_inhibitor_for_view(
struct sway_view *view);
struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_application_inhibitor_for_view(
struct sway_view *view);
void sway_idle_inhibit_v1_user_inhibitor_destroy(
struct sway_idle_inhibitor_v1 *inhibitor);
bool sway_idle_inhibit_manager_v1_init(void);
struct sway_idle_inhibit_manager_v1 *sway_idle_inhibit_manager_v1_create(
struct wl_display *wl_display, struct wlr_idle *idle);
#endif

View File

@ -0,0 +1,40 @@
#ifndef _SWAY_LAUNCHER_H
#define _SWAY_LAUNCHER_H
#include <stdlib.h>
#include <wayland-server-core.h>
#include "sway/input/seat.h"
struct launcher_ctx {
pid_t pid;
char *fallback_name;
struct wlr_xdg_activation_token_v1 *token;
struct wl_listener token_destroy;
struct sway_seat *seat;
struct wl_listener seat_destroy;
bool activated;
bool had_focused_surface;
struct sway_node *node;
struct wl_listener node_destroy;
struct wl_list link; // sway_server::pending_launcher_ctxs
};
struct launcher_ctx *launcher_ctx_find_pid(pid_t pid);
struct sway_workspace *launcher_ctx_get_workspace(struct launcher_ctx *ctx);
void launcher_ctx_consume(struct launcher_ctx *ctx);
void launcher_ctx_destroy(struct launcher_ctx *ctx);
struct launcher_ctx *launcher_ctx_create_internal(void);
struct launcher_ctx *launcher_ctx_create(
struct wlr_xdg_activation_token_v1 *token, struct sway_node *node);
const char *launcher_ctx_get_token_name(struct launcher_ctx *ctx);
#endif

View File

@ -1,7 +1,8 @@
#ifndef _SWAY_TRANSACTION_H
#define _SWAY_TRANSACTION_H
#include <wlr/render/wlr_texture.h>
#include "sway/tree/container.h"
#include <stdint.h>
#include <stdbool.h>
#include <wlr/types/wlr_scene.h>
/**
* Transactions enable us to perform atomic layout updates.
@ -20,26 +21,44 @@
* create and commits a transaction from the dirty containers.
*/
struct sway_transaction_instruction;
struct sway_view;
/**
* Find all dirty containers, create and commit a transaction containing them,
* and unmark them as dirty.
*/
void transaction_commit_dirty(void);
/*
* Same as transaction_commit_dirty, but signalling that this is a
* client-initiated change has already taken effect.
*/
void transaction_commit_dirty_client(void);
/**
* Notify the transaction system that a view is ready for the new layout.
*
* When all views in the transaction are ready, the layout will be applied.
*
* A success boolean is returned denoting that this part of the transaction is
* ready.
*/
void transaction_notify_view_ready(struct sway_view *view, uint32_t serial);
bool transaction_notify_view_ready_by_serial(struct sway_view *view,
uint32_t serial);
/**
* Notify the transaction system that a view is ready for the new layout, but
* identifying the instruction by width and height rather than by serial.
* identifying the instruction by geometry rather than by serial.
*
* This is used by xwayland views, as they don't have serials.
*
* A success boolean is returned denoting that this part of the transaction is
* ready.
*/
void transaction_notify_view_ready_by_size(struct sway_view *view,
int width, int height);
bool transaction_notify_view_ready_by_geometry(struct sway_view *view,
double x, double y, int width, int height);
void arrange_popups(struct wlr_scene_tree *popups);
#endif

View File

@ -1,50 +1,150 @@
#ifndef _SWAY_INPUT_CURSOR_H
#define _SWAY_INPUT_CURSOR_H
#include <stdbool.h>
#include <stdint.h>
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_compositor.h>
#include "sway/input/seat.h"
#include "config.h"
#define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32
#define SWAY_SCROLL_UP KEY_MAX + 1
#define SWAY_SCROLL_DOWN KEY_MAX + 2
#define SWAY_SCROLL_LEFT KEY_MAX + 3
#define SWAY_SCROLL_RIGHT KEY_MAX + 4
struct sway_cursor {
struct sway_seat *seat;
struct wlr_cursor *cursor;
struct {
double x, y;
struct sway_node *node;
} previous;
struct wlr_xcursor_manager *xcursor_manager;
struct wl_list tablets;
struct wl_list tablet_pads;
const char *image;
struct wl_client *image_client;
struct wlr_surface *image_surface;
int hotspot_x, hotspot_y;
struct wlr_pointer_constraint_v1 *active_constraint;
pixman_region32_t confine; // invalid if active_constraint == NULL
bool active_confine_requires_warp;
struct wl_listener hold_begin;
struct wl_listener hold_end;
struct wl_listener pinch_begin;
struct wl_listener pinch_update;
struct wl_listener pinch_end;
struct wl_listener swipe_begin;
struct wl_listener swipe_update;
struct wl_listener swipe_end;
struct wl_listener motion;
struct wl_listener motion_absolute;
struct wl_listener button;
struct wl_listener axis;
struct wl_listener frame;
struct wl_listener touch_down;
struct wl_listener touch_up;
struct wl_listener touch_cancel;
struct wl_listener touch_motion;
struct wl_listener touch_frame;
bool simulating_pointer_from_touch;
bool pointer_touch_up;
int32_t pointer_touch_id;
struct wl_listener tool_axis;
struct wl_listener tool_tip;
struct wl_listener tool_proximity;
struct wl_listener tool_button;
bool simulating_pointer_from_tool_tip;
bool simulating_pointer_from_tool_button;
uint32_t tool_buttons;
struct wl_listener request_set_cursor;
struct wl_listener image_surface_destroy;
struct wl_listener constraint_commit;
struct wl_event_source *hide_source;
bool hidden;
// This field is just a cache of the field in seat_config in order to avoid
// costly seat_config lookups on every keypress. HIDE_WHEN_TYPING_DEFAULT
// indicates that there is no cached value.
enum seat_config_hide_cursor_when_typing hide_when_typing;
// Mouse binding state
uint32_t pressed_buttons[SWAY_CURSOR_PRESSED_BUTTONS_CAP];
size_t pressed_button_count;
};
struct sway_node;
struct sway_node *node_at_coords(
struct sway_seat *seat, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy);
void sway_cursor_destroy(struct sway_cursor *cursor);
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
bool allow_refocusing);
void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
uint32_t button, enum wlr_button_state state);
/**
* "Rebase" a cursor on top of whatever view is underneath it.
*
* This chooses a cursor icon and sends a motion event to the surface.
*/
void cursor_rebase(struct sway_cursor *cursor);
void cursor_rebase_all(void);
void cursor_update_image(struct sway_cursor *cursor, struct sway_node *node);
void cursor_handle_activity_from_idle_source(struct sway_cursor *cursor,
enum sway_input_idle_source idle_source);
void cursor_handle_activity_from_device(struct sway_cursor *cursor,
struct wlr_input_device *device);
void cursor_unhide(struct sway_cursor *cursor);
int cursor_get_timeout(struct sway_cursor *cursor);
void cursor_notify_key_press(struct sway_cursor *cursor);
void pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
struct wlr_input_device *device, double dx, double dy,
double dx_unaccel, double dy_unaccel);
void dispatch_cursor_button(struct sway_cursor *cursor,
struct wlr_input_device *device, uint32_t time_msec, uint32_t button,
enum wl_pointer_button_state state);
void dispatch_cursor_axis(struct sway_cursor *cursor,
struct wlr_pointer_axis_event *event);
void cursor_set_image(struct sway_cursor *cursor, const char *image,
struct wl_client *client);
void cursor_set_image_surface(struct sway_cursor *cursor,
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y,
struct wl_client *client);
void cursor_warp_to_container(struct sway_cursor *cursor,
struct sway_container *container, bool force);
void cursor_warp_to_workspace(struct sway_cursor *cursor,
struct sway_workspace *workspace);
void sway_cursor_constrain(struct sway_cursor *cursor,
struct wlr_pointer_constraint_v1 *constraint);
uint32_t get_mouse_bindsym(const char *name, char **error);
uint32_t get_mouse_bindcode(const char *name, char **error);
// Considers both bindsym and bindcode
uint32_t get_mouse_button(const char *name, char **error);
const char *get_mouse_button_name(uint32_t button);
void handle_request_set_cursor_shape(struct wl_listener *listener, void *data);
#endif

View File

@ -1,67 +1,79 @@
#ifndef _SWAY_INPUT_INPUT_MANAGER_H
#define _SWAY_INPUT_INPUT_MANAGER_H
#include <libinput.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include "sway/server.h"
#include <wlr/types/wlr_virtual_pointer_v1.h>
#include <wlr/types/wlr_transient_seat_v1.h>
#include "sway/config.h"
#include "list.h"
/**
* The global singleton input manager
* TODO: make me not a global
*/
extern struct sway_input_manager *input_manager;
struct sway_server;
struct sway_input_device {
char *identifier;
struct wlr_input_device *wlr_device;
struct wl_list link;
struct wl_listener device_destroy;
bool is_virtual;
};
struct sway_input_manager {
struct sway_server *server;
struct wl_list devices;
struct wl_list seats;
struct wlr_input_inhibit_manager *inhibit;
struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit;
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
struct wlr_virtual_pointer_manager_v1 *virtual_pointer;
struct wlr_pointer_gestures_v1 *pointer_gestures;
struct wlr_transient_seat_manager_v1 *transient_seat_manager;
struct wl_listener new_input;
struct wl_listener inhibit_activate;
struct wl_listener inhibit_deactivate;
struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor;
struct wl_listener virtual_keyboard_new;
struct wl_listener virtual_pointer_new;
struct wl_listener transient_seat_create;
};
struct sway_input_manager *input_manager_create(struct sway_server *server);
bool input_manager_has_focus(struct sway_input_manager *input,
struct sway_container *container);
bool input_manager_has_focus(struct sway_node *node);
void input_manager_set_focus(struct sway_input_manager *input,
struct sway_container *container);
void input_manager_set_focus(struct sway_node *node);
void input_manager_configure_xcursor(struct sway_input_manager *input);
void input_manager_configure_xcursor(void);
void input_manager_apply_input_config(struct sway_input_manager *input,
struct input_config *input_config);
void input_manager_apply_input_config(struct input_config *input_config);
void input_manager_apply_seat_config(struct sway_input_manager *input,
struct seat_config *seat_config);
void input_manager_configure_all_input_mappings(void);
struct sway_seat *input_manager_get_default_seat(
struct sway_input_manager *input);
void input_manager_reset_input(struct sway_input_device *input_device);
struct sway_seat *input_manager_get_seat(struct sway_input_manager *input,
const char *seat_name);
void input_manager_reset_all_inputs(void);
void input_manager_apply_seat_config(struct seat_config *seat_config);
struct sway_seat *input_manager_get_default_seat(void);
struct sway_seat *input_manager_get_seat(const char *seat_name, bool create);
/**
* If none of the seat configs have a fallback setting (either true or false),
* create the default seat (if needed) and set it as the fallback
*/
void input_manager_verify_fallback_seat(void);
/**
* Gets the last seat the user interacted with
*/
struct sway_seat *input_manager_current_seat(struct sway_input_manager *input);
struct sway_seat *input_manager_current_seat(void);
struct input_config *input_device_get_config(struct sway_input_device *device);
char *input_device_get_identifier(struct wlr_input_device *device);
const char *input_device_get_type(struct sway_input_device *device);
#endif

View File

@ -5,6 +5,27 @@
#define SWAY_KEYBOARD_PRESSED_KEYS_CAP 32
/**
* Get modifier mask from modifier name.
*
* Returns the modifier mask or 0 if the name isn't found.
*/
uint32_t get_modifier_mask_by_name(const char *name);
/**
* Get modifier name from modifier mask.
*
* Returns the modifier name or NULL if it isn't found.
*/
const char *get_modifier_name_by_mask(uint32_t modifier);
/**
* Get an array of modifier names from modifier_masks
*
* Populates the names array and return the number of names added.
*/
int get_modifier_names(const char **names, uint32_t modifier_masks);
struct sway_shortcut_state {
/**
* A list of pressed key ids (either keysyms or keycodes),
@ -24,12 +45,18 @@ struct sway_shortcut_state {
uint32_t last_keycode;
uint32_t last_raw_modifiers;
size_t npressed;
uint32_t current_key;
};
struct sway_keyboard {
struct sway_seat_device *seat_device;
struct wlr_keyboard *wlr;
struct xkb_keymap *keymap;
xkb_layout_index_t effective_layout;
int32_t repeat_rate;
int32_t repeat_delay;
struct wl_listener keyboard_key;
struct wl_listener keyboard_modifiers;
@ -37,12 +64,26 @@ struct sway_keyboard {
struct sway_shortcut_state state_keysyms_translated;
struct sway_shortcut_state state_keysyms_raw;
struct sway_shortcut_state state_keycodes;
struct sway_shortcut_state state_pressed_sent;
struct sway_binding *held_binding;
struct wl_event_source *key_repeat_source;
struct sway_binding *repeat_binding;
};
struct sway_keyboard_group {
struct wlr_keyboard_group *wlr_group;
struct sway_seat_device *seat_device;
struct wl_listener keyboard_key;
struct wl_listener keyboard_modifiers;
struct wl_listener enter;
struct wl_listener leave;
struct wl_list link; // sway_seat::keyboard_groups
};
struct xkb_keymap *sway_keyboard_compile_keymap(struct input_config *ic,
char **error);
struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
struct sway_seat_device *device);
@ -50,4 +91,5 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard);
void sway_keyboard_destroy(struct sway_keyboard *keyboard);
void sway_keyboard_disarm_key_repeat(struct sway_keyboard *keyboard);
#endif

View File

@ -0,0 +1,14 @@
#ifndef _SWAY_INPUT_LIBINPUT_H
#define _SWAY_INPUT_LIBINPUT_H
#include "sway/input/input-manager.h"
bool sway_input_configure_libinput_device(struct sway_input_device *device);
void sway_input_configure_libinput_device_send_events(
struct sway_input_device *device);
void sway_input_reset_libinput_device(struct sway_input_device *device);
bool sway_libinput_device_is_builtin(struct sway_input_device *device);
#endif

View File

@ -1,87 +1,156 @@
#ifndef _SWAY_INPUT_SEAT_H
#define _SWAY_INPUT_SEAT_H
#include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/util/edges.h>
#include "sway/config.h"
#include "sway/input/input-manager.h"
#include "sway/input/tablet.h"
#include "sway/input/text_input.h"
struct sway_seat;
struct sway_seatop_impl {
void (*button)(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button,
enum wl_pointer_button_state state);
void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec);
void (*pointer_axis)(struct sway_seat *seat,
struct wlr_pointer_axis_event *event);
void (*hold_begin)(struct sway_seat *seat,
struct wlr_pointer_hold_begin_event *event);
void (*hold_end)(struct sway_seat *seat,
struct wlr_pointer_hold_end_event *event);
void (*pinch_begin)(struct sway_seat *seat,
struct wlr_pointer_pinch_begin_event *event);
void (*pinch_update)(struct sway_seat *seat,
struct wlr_pointer_pinch_update_event *event);
void (*pinch_end)(struct sway_seat *seat,
struct wlr_pointer_pinch_end_event *event);
void (*swipe_begin)(struct sway_seat *seat,
struct wlr_pointer_swipe_begin_event *event);
void (*swipe_update)(struct sway_seat *seat,
struct wlr_pointer_swipe_update_event *event);
void (*swipe_end)(struct sway_seat *seat,
struct wlr_pointer_swipe_end_event *event);
void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
void (*touch_motion)(struct sway_seat *seat,
struct wlr_touch_motion_event *event, double lx, double ly);
void (*touch_up)(struct sway_seat *seat,
struct wlr_touch_up_event *event);
void (*touch_down)(struct sway_seat *seat,
struct wlr_touch_down_event *event, double lx, double ly);
void (*touch_cancel)(struct sway_seat *seat,
struct wlr_touch_cancel_event *event);
void (*tablet_tool_motion)(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec);
void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool,
uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
void (*end)(struct sway_seat *seat);
void (*unref)(struct sway_seat *seat, struct sway_container *con);
bool allow_set_cursor;
};
struct sway_seat_device {
struct sway_seat *sway_seat;
struct sway_input_device *input_device;
struct sway_keyboard *keyboard;
struct sway_switch *switch_device;
struct sway_tablet *tablet;
struct sway_tablet_pad *tablet_pad;
struct wl_list link; // sway_seat::devices
};
struct sway_seat_container {
struct sway_seat_node {
struct sway_seat *seat;
struct sway_container *container;
struct sway_node *node;
struct wl_list link; // sway_seat::focus_stack
struct wl_listener destroy;
};
struct sway_drag_icon {
struct sway_drag {
struct sway_seat *seat;
struct wlr_drag_icon *wlr_drag_icon;
struct wl_list link; // sway_root::drag_icons
double x, y; // in layout-local coordinates
struct wl_listener surface_commit;
struct wl_listener map;
struct wl_listener unmap;
struct wlr_drag *wlr_drag;
struct wl_listener destroy;
};
struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;
struct sway_input_manager *input;
// Seat scene tree structure
// - scene_tree
// - drag icons
// - drag icon 1
// - drag icon 2
// - seatop specific stuff
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *drag_icons;
bool has_focus;
struct wl_list focus_stack; // list of containers in focus order
struct sway_workspace *workspace;
char *prev_workspace_name; // for workspace back_and_forth
// If the focused layer is set, views cannot receive keyboard focus
struct wlr_layer_surface *focused_layer;
// If exclusive_client is set, no other clients will receive input events
struct wl_client *exclusive_client;
struct wlr_layer_surface_v1 *focused_layer;
// If the exclusive layer is set, views cannot receive keyboard focus
bool has_exclusive_layer;
// Last touch point
int32_t touch_id;
double touch_x, touch_y;
// Operations (drag and resize)
enum {
OP_NONE,
OP_MOVE,
OP_RESIZE,
} operation;
// Seat operations (drag and resize)
const struct sway_seatop_impl *seatop_impl;
void *seatop_data;
struct sway_container *op_container;
enum wlr_edges op_resize_edge;
uint32_t op_button;
bool op_resize_preserve_ratio;
double op_ref_lx, op_ref_ly; // cursor's x/y at start of op
double op_ref_width, op_ref_height; // container's size at start of op
double op_ref_con_lx, op_ref_con_ly; // container's x/y at start of op
uint32_t last_button;
uint32_t last_button_serial;
uint32_t idle_inhibit_sources, idle_wake_sources;
list_t *deferred_bindings; // struct sway_binding
struct sway_input_method_relay im_relay;
struct wl_listener focus_destroy;
struct wl_listener new_container;
struct wl_listener new_drag_icon;
struct wl_listener new_node;
struct wl_listener request_start_drag;
struct wl_listener start_drag;
struct wl_listener request_set_selection;
struct wl_listener request_set_primary_selection;
struct wl_listener destroy;
struct wl_list devices; // sway_seat_device::link
struct wl_list keyboard_groups; // sway_keyboard_group::link
struct wl_list keyboard_shortcuts_inhibitors;
// sway_keyboard_shortcuts_inhibitor::link
struct wl_list link; // input_manager::seats
};
struct sway_seat *seat_create(struct sway_input_manager *input,
const char *seat_name);
struct sway_pointer_constraint {
struct sway_cursor *cursor;
struct wlr_pointer_constraint_v1 *constraint;
struct wl_listener set_region;
struct wl_listener destroy;
};
struct sway_keyboard_shortcuts_inhibitor {
struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor;
struct wl_listener destroy;
struct wl_list link; // sway_seat::keyboard_shortcuts_inhibitors
};
struct sway_seat *seat_create(const char *seat_name);
void seat_destroy(struct sway_seat *seat);
@ -91,26 +160,51 @@ void seat_add_device(struct sway_seat *seat,
void seat_configure_device(struct sway_seat *seat,
struct sway_input_device *device);
void seat_configure_device_mapping(struct sway_seat *seat,
struct sway_input_device *input_device);
void seat_reset_device(struct sway_seat *seat,
struct sway_input_device *input_device);
void seat_remove_device(struct sway_seat *seat,
struct sway_input_device *device);
void seat_configure_xcursor(struct sway_seat *seat);
void seat_set_focus(struct sway_seat *seat, struct sway_container *container);
void seat_set_focus(struct sway_seat *seat, struct sway_node *node);
void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp, bool notify);
void seat_set_focus_container(struct sway_seat *seat,
struct sway_container *con);
void seat_set_focus_workspace(struct sway_seat *seat,
struct sway_workspace *ws);
/**
* Manipulate the focus stack without triggering any other behaviour.
*
* This can be used to set focus_inactive by calling the function a second time
* with the real focus.
*/
void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node);
void seat_set_focus_surface(struct sway_seat *seat,
struct wlr_surface *surface, bool unfocus);
void seat_set_focus_layer(struct sway_seat *seat,
struct wlr_layer_surface *layer);
struct wlr_layer_surface_v1 *layer);
void seat_set_exclusive_client(struct sway_seat *seat,
struct wl_client *client);
void seat_unfocus_unless_client(struct sway_seat *seat, struct wl_client *client);
struct sway_container *seat_get_focus(struct sway_seat *seat);
struct sway_node *seat_get_focus(struct sway_seat *seat);
struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat);
// If a scratchpad container is fullscreen global, this can be used to try to
// determine the last focused workspace. Otherwise, this should yield the same
// results as seat_get_focused_workspace.
struct sway_workspace *seat_get_last_known_workspace(struct sway_seat *seat);
struct sway_container *seat_get_focused_container(struct sway_seat *seat);
/**
* Return the last container to be focused for the seat (or the most recently
@ -121,50 +215,158 @@ struct sway_container *seat_get_focus(struct sway_seat *seat);
* is destroyed, or focus moves to a container with children and we need to
* descend into the next leaf in focus order.
*/
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *container);
struct sway_node *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_node *node);
struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
struct sway_container *container);
struct sway_workspace *workspace);
/**
* Descend into the focus stack to find the focus-inactive view. Useful for
* container placement when they change position in the tree.
*/
struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
struct sway_container *container);
struct sway_node *ancestor);
/**
* Return the immediate child of container which was most recently focused.
*/
struct sway_container *seat_get_active_child(struct sway_seat *seat,
struct sway_container *container);
struct sway_node *seat_get_active_tiling_child(struct sway_seat *seat,
struct sway_node *parent);
/**
* Iterate over the focus-inactive children of the container calling the
* function on each.
*/
void seat_focus_inactive_children_for_each(struct sway_seat *seat,
struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
void seat_for_each_node(struct sway_seat *seat,
void (*f)(struct sway_node *node, void *data), void *data);
void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
struct seat_config *seat_get_config(struct sway_seat *seat);
struct seat_config *seat_get_config_by_name(const char *name);
void seat_idle_notify_activity(struct sway_seat *seat,
enum sway_input_idle_source source);
bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
void drag_icon_update_position(struct sway_drag_icon *icon);
void drag_icons_update_position(struct sway_seat *seat);
void seat_begin_move(struct sway_seat *seat, struct sway_container *con,
uint32_t button);
enum wlr_edges find_resize_edge(struct sway_container *cont,
struct wlr_surface *surface, struct sway_cursor *cursor);
void seat_begin_resize(struct sway_seat *seat, struct sway_container *con,
uint32_t button, enum wlr_edges edge);
void seatop_begin_default(struct sway_seat *seat);
void seat_end_mouse_operation(struct sway_seat *seat);
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
double sx, double sy);
void seatop_begin_down_on_surface(struct sway_seat *seat,
struct wlr_surface *surface, double sx, double sy);
void seatop_begin_touch_down(struct sway_seat *seat, struct wlr_surface *surface,
struct wlr_touch_down_event *event, double sx, double sy, double lx, double ly);
void seatop_begin_move_floating(struct sway_seat *seat,
struct sway_container *con);
void seatop_begin_move_tiling_threshold(struct sway_seat *seat,
struct sway_container *con);
void seatop_begin_move_tiling(struct sway_seat *seat,
struct sway_container *con);
void seatop_begin_resize_floating(struct sway_seat *seat,
struct sway_container *con, enum wlr_edges edge);
void seatop_begin_resize_tiling(struct sway_seat *seat,
struct sway_container *con, enum wlr_edges edge);
struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
struct sway_workspace *workspace);
void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
uint32_t button, enum wlr_button_state state);
uint32_t button, enum wl_pointer_button_state state);
void seat_consider_warp_to_focus(struct sway_seat *seat);
void seatop_button(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button,
enum wl_pointer_button_state state);
void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec);
void seatop_pointer_axis(struct sway_seat *seat,
struct wlr_pointer_axis_event *event);
void seatop_tablet_tool_tip(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec,
enum wlr_tablet_tool_tip_state state);
void seatop_tablet_tool_motion(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec);
void seatop_hold_begin(struct sway_seat *seat,
struct wlr_pointer_hold_begin_event *event);
void seatop_hold_end(struct sway_seat *seat,
struct wlr_pointer_hold_end_event *event);
void seatop_pinch_begin(struct sway_seat *seat,
struct wlr_pointer_pinch_begin_event *event);
void seatop_pinch_update(struct sway_seat *seat,
struct wlr_pointer_pinch_update_event *event);
void seatop_pinch_end(struct sway_seat *seat,
struct wlr_pointer_pinch_end_event *event);
void seatop_swipe_begin(struct sway_seat *seat,
struct wlr_pointer_swipe_begin_event *event);
void seatop_swipe_update(struct sway_seat *seat,
struct wlr_pointer_swipe_update_event *event);
void seatop_swipe_end(struct sway_seat *seat,
struct wlr_pointer_swipe_end_event *event);
void seatop_touch_motion(struct sway_seat *seat,
struct wlr_touch_motion_event *event, double lx, double ly);
void seatop_touch_up(struct sway_seat *seat,
struct wlr_touch_up_event *event);
void seatop_touch_down(struct sway_seat *seat,
struct wlr_touch_down_event *event, double lx, double ly);
void seatop_touch_cancel(struct sway_seat *seat,
struct wlr_touch_cancel_event *event);
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
/**
* End a seatop (ie. free any seatop specific resources).
*/
void seatop_end(struct sway_seat *seat);
/**
* Instructs the seatop implementation to drop any references to the given
* container (eg. because the container is destroying).
* The seatop may choose to abort itself in response to this.
*/
void seatop_unref(struct sway_seat *seat, struct sway_container *con);
bool seatop_allows_set_cursor(struct sway_seat *seat);
/**
* Returns the keyboard shortcuts inhibitor that applies to the given surface
* or NULL if none exists.
*/
struct sway_keyboard_shortcuts_inhibitor *
keyboard_shortcuts_inhibitor_get_for_surface(const struct sway_seat *seat,
const struct wlr_surface *surface);
/**
* Returns the keyboard shortcuts inhibitor that applies to the currently
* focused surface of a seat or NULL if none exists.
*/
struct sway_keyboard_shortcuts_inhibitor *
keyboard_shortcuts_inhibitor_get_for_focused_surface(const struct sway_seat *seat);
#endif

View File

@ -0,0 +1,24 @@
#ifndef _SWAY_INPUT_SWITCH_H
#define _SWAY_INPUT_SWITCH_H
#include "sway/input/seat.h"
struct sway_switch {
struct sway_seat_device *seat_device;
struct wlr_switch *wlr;
enum wlr_switch_state state;
enum wlr_switch_type type;
struct wl_listener switch_toggle;
};
struct sway_switch *sway_switch_create(struct sway_seat *seat,
struct sway_seat_device *device);
void sway_switch_configure(struct sway_switch *sway_switch);
void sway_switch_destroy(struct sway_switch *sway_switch);
void sway_switch_retrigger_bindings_for_all(void);
#endif

View File

@ -0,0 +1,69 @@
#ifndef _SWAY_INPUT_TABLET_H
#define _SWAY_INPUT_TABLET_H
#include <wlr/types/wlr_layer_shell_v1.h>
struct sway_seat;
struct wlr_tablet_tool;
struct sway_tablet {
struct wl_list link;
struct sway_seat_device *seat_device;
struct wlr_tablet_v2_tablet *tablet_v2;
};
enum sway_tablet_tool_mode {
SWAY_TABLET_TOOL_MODE_ABSOLUTE,
SWAY_TABLET_TOOL_MODE_RELATIVE,
};
struct sway_tablet_tool {
struct sway_seat *seat;
struct sway_tablet *tablet;
struct wlr_tablet_v2_tablet_tool *tablet_v2_tool;
enum sway_tablet_tool_mode mode;
double tilt_x, tilt_y;
struct wl_listener set_cursor;
struct wl_listener tool_destroy;
};
struct sway_tablet_pad {
struct wl_list link;
struct sway_seat_device *seat_device;
struct sway_tablet *tablet;
struct wlr_tablet_pad *wlr;
struct wlr_tablet_v2_tablet_pad *tablet_v2_pad;
struct wl_listener attach;
struct wl_listener button;
struct wl_listener ring;
struct wl_listener strip;
struct wlr_surface *current_surface;
struct wl_listener surface_destroy;
struct wl_listener tablet_destroy;
};
struct sway_tablet *sway_tablet_create(struct sway_seat *seat,
struct sway_seat_device *device);
void sway_configure_tablet(struct sway_tablet *tablet);
void sway_tablet_destroy(struct sway_tablet *tablet);
void sway_tablet_tool_configure(struct sway_tablet *tablet,
struct wlr_tablet_tool *wlr_tool);
struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat,
struct sway_seat_device *device);
void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad);
void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad);
void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
struct wlr_surface *surface);
#endif

View File

@ -0,0 +1,71 @@
#ifndef _SWAY_INPUT_TEXT_INPUT_H
#define _SWAY_INPUT_TEXT_INPUT_H
#include <wlr/types/wlr_text_input_v3.h>
#include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_compositor.h>
/**
* The relay structure manages the relationship between text-input and
* input_method interfaces on a given seat. Multiple text-input interfaces may
* be bound to a relay, but at most one will be focused (receiving events) at
* a time. At most one input-method interface may be bound to the seat. The
* relay manages life cycle of both sides. When both sides are present and
* focused, the relay passes messages between them.
*
* Text input focus is a subset of keyboard focus - if the text-input is
* in the focused state, wl_keyboard sent an enter as well. However, having
* wl_keyboard focused doesn't mean that text-input will be focused.
*/
struct sway_input_method_relay {
struct sway_seat *seat;
struct wl_list text_inputs; // sway_text_input::link
struct wl_list input_popups; // sway_input_popup::link
struct wlr_input_method_v2 *input_method; // doesn't have to be present
struct wl_listener text_input_new;
struct wl_listener input_method_new;
struct wl_listener input_method_commit;
struct wl_listener input_method_new_popup_surface;
struct wl_listener input_method_grab_keyboard;
struct wl_listener input_method_destroy;
struct wl_listener input_method_keyboard_grab_destroy;
};
struct sway_text_input {
struct sway_input_method_relay *relay;
struct wlr_text_input_v3 *input;
// The surface getting seat's focus. Stored for when text-input cannot
// be sent an enter event immediately after getting focus, e.g. when
// there's no input method available. Cleared once text-input is entered.
struct wlr_surface *pending_focused_surface;
struct wl_list link;
struct wl_listener pending_focused_surface_destroy;
struct wl_listener text_input_enable;
struct wl_listener text_input_commit;
struct wl_listener text_input_disable;
struct wl_listener text_input_destroy;
};
void sway_input_method_relay_init(struct sway_seat *seat,
struct sway_input_method_relay *relay);
void sway_input_method_relay_finish(struct sway_input_method_relay *relay);
// Updates currently focused surface. Surface must belong to the same seat.
void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay,
struct wlr_surface *surface);
struct sway_text_input *sway_text_input_create(
struct sway_input_method_relay *relay,
struct wlr_text_input_v3 *text_input);
#endif

Some files were not shown because too many files have changed in this diff Show More