Compare commits

...

1719 Commits

Author SHA1 Message Date
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
331 changed files with 29429 additions and 13770 deletions

55
.builds/alpine.yml Normal file
View File

@ -0,0 +1,55 @@
image: alpine/edge
packages:
- cairo-dev
- eudev-dev
- gdk-pixbuf-dev
- json-c-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,36 @@
# 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
- 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

44
.builds/freebsd.yml Normal file
View File

@ -0,0 +1,44 @@
image: freebsd/latest
packages:
- devel/basu
- devel/json-c
- devel/libevdev
- devel/meson
- devel/pcre2
- devel/pkgconf
- graphics/cairo
- graphics/gdk-pixbuf2
- 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.

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ 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,13 +1,21 @@
# Contributing to sway
Contributing just involves sending a pull request. You will probably be more
successful with your contribution if you visit
[#sway-devel](https://webchat.freenode.net/?channels=sway-devel) on
irc.freenode.net upfront and discuss your plans.
successful with your contribution if you visit #sway-devel on Libera Chat
upfront and discuss your plans.
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.
## Scope of future changes to sway
**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
If you already have your own pull request habits, feel free to use them. If you

View File

@ -1,42 +0,0 @@
If you are using the nvidia proprietary driver for any reason, you have two choices:
1. Uninstall it and use nouveau instead
2. Use X11+i3 and close your browser tab
If `lsmod | grep nvidia | wc -l` shows anything other than zero, your bug report is not welcome here.
Otherwise, please include the following four components in your bug report: sway version, debug log, configuration (if applicable), and an explanation of steps taken to reproduce the issue. If sway crashes, also include a stack trace.
Obtain your version like so:
swaymsg -t get_version
If this doesn't work, use:
sway -v
* Sway Version:
Obtain a debug log like so:
sway -d 2> ~/sway.log
This will record information about sway's activity when it's running. Briefly reproduce your problem and exit sway. When preparing a debug log, brevity is important - start up sway, do the minimum work necessary to reproduce the error, then close sway.
Upload the debug log to a pastebin service such as [gist.github.com](https://gist.github.com), and link to it below.
* Debug Log:
You should try to reproduce the issue with the default configuration. If you cannot, please reproduce with a minimal configuration, upload the config to a pastebin service, and link to it below.
* Configuration File:
Finally, explain the steps you took in plain English to reproduce the problem below.
* Stack Trace, if sway crashes:
If you use systemd, you should be able to open the coredump of the most recent crash with GDB like so:
coredumpctl gdb sway
And then type `bt full` to obtain the stack trace.

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

View File

@ -1,78 +0,0 @@
# sway
Sway е в процес на разработка, съвместим с 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).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
Ако желаете, може да дарите на [Patreon страницата на автора](https://patreon.com/sircmpwn), което ще помогне за цялостното здраве и развитие на проекта.
## Помощ
Ако имате нужда от помощ - влезте в IRC канала. Ако не ви отговорят в IRC или желаете кореспонденция по и-мейл - [fokditkak](mailto:martin.kalchev@mail.ru)
може да отговаря на основни въпроси на български език.
## Подпис
Версии подписани с ключ [B22DA89A](http://pgp.mit.edu/pks/lookup?op=vindex&search=0x52CB6609B22DA89A)
и публикувани в [GitHub](https://github.com/swaywm/sway/releases).
## Инсталация
### От пакети
Sway съществува в репотата (хранилищата) на много дистрибуции. Пробвайте да го инсталирате със съответния пакетен мениджър на вашата дистрибуция.
В случай, че имате проблем погледнете [тази страница](https://github.com/swaywm/sway/wiki/Unsupported-packages) за помощ.
Ако желаете да пакетирате Sway за вашата дистрибуция влезте в IRC канала
или пратете и-мейл на [sir@cmpwn.com](mailto:sir@cmpwn.com) за съвет как да го направите.
### Компилиране от сорс-код
Инсталирайте следните пакети:
* meson
* [wlc](https://github.com/Cloudef/wlc)
* wayland
* xwayland
* libinput >= 1.6.0
* libcap
* pcre
* json-c >= 0.13
* pango
* cairo
* gdk-pixbuf2 *
* dbus >= 1.10 **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (Нужен за man страници)
* git
_\*Нужен само за swaybar, swaybg_
_\*\*Нужен само за 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
## Настройка
Ако имте съшествуващa конфигурация от i3, просто я копирайте в `/.config/sway/config` и би трябвало безпроблемно да работи.
В противен случай, поставете примерната конфигурация, която би трябвало да се намиреа в `/etc/sway/config`.
Напишете `man 5 sway` за повече информация.
## Пускане
Напишете 'sway' в терминала (TTY). Някои дисплей мениджъри (display managers) може и да работят, но като цяло не са поддържани от Sway.

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,84 +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.
Sway 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.
## 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 *
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (erforderlich für man pages)
* git
* 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_
_\*Werden nur während des Kompilierens benötigt_
Führe diese Befehle aus:
Führe die folgenden Befehle aus:
meson build
ninja -C build
sudo ninja -C build install
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,73 +0,0 @@
# sway
Sway είναι ένας **υπό ανάπτυξη** [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).
## Εγκατάσταση
### Από Πακέτα
Ο 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 *
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
* git
_\*Απαιτείται μόνο για swaybar, swaybg_
Εκτελέστε αυτές τις εντολές:
meson build
ninja -C build
sudo ninja -C build install
Σε συστήματα χωρίς 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,59 +1,49 @@
# sway
Sway 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).
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 *
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (requis pour les pages man)
* git
* gdk-pixbuf2 (optionnel : system tray)
* [scdoc] (optionnel : requis pour les pages man) \*
* git (optionnel : information de version) \*
_\*Uniquement requis pour swaybar, swaybg_
_\* Requis uniquement pour la compilation_
Exécutez ces commandes :
@ -61,22 +51,27 @@ Exécutez ces commandes :
ninja -C build
sudo ninja -C build install
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,79 +1,66 @@
# sway
Sway è 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).
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 *
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (rrichiesto per man pages)
* git
* gdk-pixbuf2 (opzionale: area di notifica)
* [scdoc] (opzionale: pagine del manuale) \*
* git (opzionale: informazioni sulla versione) \*
_\*Richiesto solo per swaybar, swaybg_
_\* Dipendenza necessaria per la compilazione_
Esegui questi comandi:
meson build
ninja -C build
sudo ninja -C build install
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,20 +1,18 @@
# sway
Swayは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)もあります。
[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)で公開されています。
Swayのリリースは[E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48)で署名され、[GitHub](https://github.com/swaywm/sway/releases)で公開されています。
## インストール
@ -29,20 +27,18 @@ Swayは沢山のディストリビューションで提供されています。"
次の依存パッケージをインストールしてください:
* meson \*
* [wlroots](https://github.com/swaywm/wlroots)
* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
* wayland
* wayland-protocols \*
* pcre
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 \*\*
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (manで必要です) \*
* git \*
* gdk-pixbuf2 (任意: システムイコンで必要です)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (任意: manで必要です) \*
* git (任意: バージョン情報で必要です) \*
_\*コンパイルの時_
_\*\*オプション: swaybgでのみ必要です_
_\*コンパイル時の依存_
次のコマンドを実行してください:
@ -50,12 +46,6 @@ _\*\*オプション: swaybgでのみ必要です_
ninja -C build
sudo ninja -C build install
logindを使用していないシステムでは、バイナリにsuidを設定する必要があります:
sudo chmod a+s /usr/local/bin/sway
swayは起動後、すぐにroot許可を落とします。
## 設定
既に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은 상당히 잘 작동한다고 알려져 있습니다).

View File

@ -1,63 +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--) - [Български](https://github.com/swaywm/sway/blob/master/README.bg.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]
sway is an 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).
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).
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)
* [wlroots]
* wayland
* wayland-protocols \*
* pcre
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 \*\*
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) >= 1.8.1 (optional: man pages) \*
* git \*
* gdk-pixbuf2 (optional: additional image formats for system tray)
* [swaybg] (optional: wallpaper)
* [scdoc] (optional: man pages) \*
* git (optional: version info) \*
_\*Compile-time dep_
_\*\*optional: required for swaybg_
_\* Compile-time dep_
Run these commands:
meson build
ninja -C build
sudo ninja -C build install
On systems without logind, you need to suid the sway binary:
sudo chmod a+s /usr/local/bin/sway
Sway will drop root permissions shortly after startup.
meson build/
ninja -C build/
sudo ninja -C build/ install
## Configuration
@ -70,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,91 +1,59 @@
# sway
Sway é 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).
## 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 *
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (man pages)
* git
* 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_
_\*Dependência de tempo de compilação_
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,83 +1,68 @@
# sway
Sway на данный момент **(в разработке)** 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).
[![](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).
Релизы подписываются ключом [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 *
* dbus >= 1.10 **
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
* git
* gdk-pixbuf2 (опционально: для работы трея)
* [scdoc] (опционально: для man-страниц) \*
* git (опционально: для информации о версии) \*
_\*Требуется только для swaybar, swaybg_
_\*Зависимости для сборки_
_\*\*Требуется только для 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** це сумісний з 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,7 +15,7 @@ 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).
## Встановлення
@ -39,28 +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 *
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages)
* git
* gdk-pixbuf2 (optional: system tray)
* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (необов'язково, необхідно для сторінок man) \*
* git \*
_\*Лише для swaybar, swaybg_
_\*Лише для компіляції_
Виконайте ці команди:
@ -68,15 +55,6 @@ _\*Лише для swaybar, swaybg_
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,7 +5,6 @@ lib_sway_client = static_library(
),
dependencies: [
cairo,
gdk_pixbuf,
pango,
pangocairo,
wayland_client

View File

@ -1,62 +1,42 @@
#define _POSIX_C_SOURCE 200809
#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,17 +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);
buf->size = size;
buf->width = width;

View File

@ -1,120 +0,0 @@
#include <assert.h>
#include "background-image.h"
#include "cairo.h"
#include "log.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;
}
sway_log(SWAY_ERROR, "Unsupported background mode: %s", mode);
return BACKGROUND_MODE_INVALID;
}
cairo_surface_t *load_background_image(const char *path) {
cairo_surface_t *image;
#if HAVE_GDK_PIXBUF
GError *err = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
if (!pixbuf) {
sway_log(SWAY_ERROR, "Failed to load background image (%s).",
err->message);
return NULL;
}
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) {
sway_log(SWAY_ERROR, "Failed to read background image.");
return NULL;
}
if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
sway_log(SWAY_ERROR, "Failed to read background image: %s."
#if !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);
cairo_save(cairo);
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);
cairo_restore(cairo);
}

View File

@ -1,9 +1,6 @@
#include <stdint.h>
#include <cairo/cairo.h>
#include "cairo.h"
#if 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,
@ -45,99 +42,3 @@ cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
cairo_destroy(cairo);
return new;
}
#if 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>
@ -69,9 +68,16 @@ 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));
size_t total = 0;
while (total < IPC_HEADER_SIZE) {
@ -87,15 +93,15 @@ struct ipc_response *ipc_recv_response(int socketfd) {
goto error_1;
}
total = 0;
memcpy(&response->size, &data32[0], sizeof(data32[0]));
memcpy(&response->type, &data32[1], sizeof(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) {
@ -109,7 +115,6 @@ struct ipc_response *ipc_recv_response(int socketfd) {
return response;
error_2:
free(response);
free(payload);
error_1:
sway_log(SWAY_ERROR, "Unable to allocate memory for IPC response");
return NULL;
@ -122,10 +127,9 @@ 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));
memcpy(data, ipc_magic, sizeof(ipc_magic));
memcpy(&data32[0], len, sizeof(*len));
memcpy(&data32[1], &type, sizeof(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) {
sway_abort("Unable to send IPC header");

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 199506L
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
@ -36,34 +35,63 @@ bool _sway_assert(bool condition, const char *format, ...) {
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;30m",
[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;
}
// prefix the time to the log message
struct tm result;
time_t t = time(NULL);
struct tm *tm_info = localtime_r(&t, &result);
char buffer[26];
// generate time prefix
strftime(buffer, sizeof(buffer), "%F %T - ", tm_info);
fprintf(stderr, "%s", buffer);
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);
@ -75,6 +103,8 @@ static void sway_log_stderr(sway_log_importance_t verbosity, const char *fmt,
}
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;
}
@ -93,20 +123,3 @@ void _sway_log(sway_log_importance_t verbosity, const char *fmt, ...) {
sway_log_stderr(verbosity, fmt, args);
va_end(args);
}
// strips the path prefix from filepath
// will try to strip SWAY_SRC_DIR as well as a relative src dir
// e.g. '/src/build/sway/util/log.c' and
// '../util/log.c' will both be stripped to
// 'util/log.c'
const char *_sway_strip_path(const char *filepath) {
static int srclen = sizeof(SWAY_SRC_DIR);
if (strstr(filepath, SWAY_SRC_DIR) == filepath) {
filepath += srclen;
} else if (*filepath == '.') {
while (*filepath == '.' || *filepath == '/') {
++filepath;
}
}
return filepath;
}

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200112L
#include <limits.h>
#include <string.h>
#include <stdbool.h>
@ -117,9 +116,15 @@ void loop_add_fd(struct loop *loop, int fd, short mask,
struct pollfd pfd = {fd, mask, 0};
if (loop->fd_length == loop->fd_capacity) {
loop->fd_capacity += 10;
loop->fds = realloc(loop->fds,
sizeof(struct pollfd) * 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;

View File

@ -1,8 +1,8 @@
lib_sway_common = static_library(
'sway-common',
files(
'background-image.c',
'cairo.c',
'gesture.c',
'ipc-client.c',
'log.c',
'loop.c',
@ -13,9 +13,9 @@ lib_sway_common = static_library(
),
dependencies: [
cairo,
gdk_pixbuf,
pango,
pangocairo
pangocairo,
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,7 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cairo.h"
#include "cairo_util.h"
#include "log.h"
#include "stringop.h"
@ -50,7 +50,7 @@ size_t escape_markup_text(const char *src, char *dest) {
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;
@ -73,60 +73,59 @@ 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,
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);
// Add one since vsnprintf excludes null terminator.
int length = vsnprintf(NULL, 0, fmt, args) + 1;
char *buf = vformat_str(fmt, args);
va_end(args);
char *buf = malloc(length);
if (buf == NULL) {
sway_log(SWAY_ERROR, "Failed to allocate memory");
return;
}
va_start(args, fmt);
vsnprintf(buf, length, fmt, args);
va_end(args);
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,
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);
// Add one since vsnprintf excludes null terminator.
int length = vsnprintf(NULL, 0, fmt, args) + 1;
char *buf = vformat_str(fmt, args);
va_end(args);
char *buf = malloc(length);
if (buf == NULL) {
sway_log(SWAY_ERROR, "Failed to allocate memory");
return;
}
va_start(args, fmt);
vsnprintf(buf, length, fmt, args);
va_end(args);
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);
@ -134,5 +133,6 @@ void pango_printf(cairo_t *cairo, const char *font,
pango_cairo_update_layout(cairo, layout);
pango_cairo_show_layout(cairo, layout);
g_object_unref(layout);
free(buf);
}

View File

@ -1,13 +1,14 @@
#define _POSIX_C_SOURCE 200809L
#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"
static const char whitespace[] = " \f\n\r\t\v";
@ -63,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) {
@ -78,12 +79,10 @@ 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);
@ -97,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) {
@ -150,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);
@ -258,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;
@ -273,130 +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;
}
const char *strcasestr(const char *haystack, const char *needle) {
size_t needle_len = strlen(needle);
const char *pos = haystack;
const char *end = pos + strlen(haystack) - needle_len;
while (pos <= end) {
if (strncasecmp(pos, needle, needle_len) == 0) {
return pos;
}
++pos;
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 = '\\';
}
return NULL;
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,9 +1,11 @@
#define _POSIX_C_SOURCE 200809L
#include <float.h>
#include <ctype.h>
#include <fcntl.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <wayland-server-protocol.h>
#include "log.h"
#include "util.h"
@ -11,21 +13,28 @@ int wrap(int i, int max) {
return ((i % max) + max) % max;
}
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) {
sway_log(SWAY_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) {
@ -54,3 +63,81 @@ float parse_float(const char *value) {
}
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;
}
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=(

View File

@ -2,7 +2,7 @@
_swaybar()
{
local cur prev
local cur prev short long
_get_comp_words_by_ref cur prev
short=(

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

@ -1,7 +1,8 @@
# 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."
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."

View File

@ -1,10 +1,13 @@
# 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 v -l version --description "Print the version (of swaymsg) and quit."
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."
@ -15,6 +18,8 @@ complete -c swaymsg -s t -l type -fra 'get_marks' --description "Get a JSON-enco
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

@ -1,29 +1,30 @@
# swaynag
complete -c swaynag -s C -l config --description 'The config file to use. Default: $HOME/.swaylock/config, $XDG_CONFIG_HOME/swaylock/config, and SYSCONFDIR/swaylock/config.'
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 --description 'Set the edge to use: top or bottom'
complete -c swaynag -s f -l font --description 'Set the font to use.'
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 --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 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 --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 --description 'Set the message text.'
complete -c swaynag -s o -l output --description 'Set the output to use.'
complete -c swaynag -s s -l dismiss-button --description 'Sets the text for the dismiss nagbar button. The default is "X".'
complete -c swaynag -s t -l type --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 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 --description 'Set the color of the background.'
complete -c swaynag -l border --description 'Set the color of the border.'
complete -c swaynag -l border-bottom --description 'Set the color of the bottom border.'
complete -c swaynag -l button-background --description 'Set the color for the background for buttons.'
complete -c swaynag -l text --description 'Set the text color.'
complete -c swaynag -l border-bottom-size --description 'Set the thickness of the bottom border.'
complete -c swaynag -l message-padding --description 'Set the padding for the message.'
complete -c swaynag -l details-border-size --description 'Set the thickness for the details border.'
complete -c swaynag -l button-border-size --description 'Set the thickness for the button border.'
complete -c swaynag -l button-gap --description 'Set the size of the gap between buttons.'
complete -c swaynag -l button-dismiss-gap --description 'Set the size of the gap between the dismiss button and another button.'
complete -c swaynag -l button-margin-right --description 'Set the margin from the right of the dismiss button to edge.'
complete -c swaynag -l button-padding --description 'Set the padding for the button text.'
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

@ -23,15 +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}'[Show the version number and quit]' \
'(-m --monitor)'{-m,--monitor}'[Monitor until killed (-t SUBSCRIBE only)]' \
'(-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}'
'(-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,10 +14,11 @@ 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
#
@ -36,8 +37,7 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# exec swayidle -w \
# timeout 300 'swaylock -f -c 000000' \
# timeout 600 'swaymsg "output * dpms off"' \
# resume 'swaymsg "output * dpms on"' \
# 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
@ -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"
}
@ -205,7 +205,7 @@ bar {
# 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 %l:%M:%S %p'; do sleep 1; done
status_command while date +'%Y-%m-%d %X'; do sleep 1; done
colors {
statusline #ffffff

View File

@ -1,28 +0,0 @@
#!/usr/bin/python
# This script requires i3ipc-python package (install it from a system package manager
# or pip).
# It makes inactive windows transparent. Use `transparency_val` variable to control
# transparency strength in range of 0…1.
import i3ipc
transparency_val = '0.8';
ipc = i3ipc.Connection()
prev_focused = None
for window in ipc.get_tree():
if window.focused:
prev_focused = window
else:
window.command('opacity ' + transparency_val)
def on_window_focus(ipc, focused):
global prev_focused
if focused.container.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
focused.container.command('opacity 1')
prev_focused.command('opacity ' + transparency_val)
prev_focused = focused.container
ipc.on("window::focus", on_window_focus)
ipc.main()

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,13 +1,9 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
#ifndef _SWAY_CAIRO_UTIL_H
#define _SWAY_CAIRO_UTIL_H
#include "config.h"
#include <stdint.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <wayland-client-protocol.h>
#if HAVE_GDK_PIXBUF
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
cairo_subpixel_order_t to_cairo_subpixel_order(enum wl_output_subpixel subpixel);
@ -15,11 +11,4 @@ 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);
#if HAVE_GDK_PIXBUF
cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(
const GdkPixbuf *gdkbuf);
#endif // HAVE_GDK_PIXBUF
#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

@ -17,6 +17,7 @@ enum ipc_command_type {
IPC_GET_CONFIG = 9,
IPC_SEND_TICK = 10,
IPC_SYNC = 11,
IPC_GET_BINDING_STATE = 12,
// sway-specific command types
IPC_GET_INPUTS = 100,
@ -34,6 +35,7 @@ enum ipc_command_type {
// sway-specific event types
IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20),
IPC_EVENT_INPUT = ((1<<31) | 21),
};
#endif

View File

@ -33,22 +33,26 @@ void _sway_vlog(sway_log_importance_t verbosity, const char *format, va_list arg
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
// TODO: get meson to precompute this, for better reproducibility/less overhead
const char *_sway_strip_path(const char *filepath);
#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_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
_sway_log(verb, "[%s:%d] " fmt, _SWAY_FILENAME, __LINE__, ##__VA_ARGS__)
#define sway_vlog(verb, fmt, args) \
_sway_vlog(verb, "[%s:%d] " fmt, _sway_strip_path(__FILE__), __LINE__, 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_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
_sway_abort("[%s:%d] " FMT, _SWAY_FILENAME, __LINE__, ##__VA_ARGS__)
#define sway_assert(COND, FMT, ...) \
_sway_assert(COND, "[%s:%d] %s:" FMT, _sway_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
_sway_assert(COND, "[%s:%d] %s:" FMT, _SWAY_FILENAME, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
#endif

View File

@ -3,8 +3,9 @@
#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 & < > ' ".
@ -13,11 +14,12 @@
* escaped string to dest if provided.
*/
size_t escape_markup_text(const char *src, char *dest);
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);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int *baseline, 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 +1,17 @@
#ifndef _SWAY_STRINGOP_H
#define _SWAY_STRINGOP_H
#include <stdbool.h>
#include <stddef.h>
#include "list.h"
#ifdef __GNUC__
#define _SWAY_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
#else
#define _SWAY_ATTRIB_PRINTF(start, end)
#endif
void strip_whitespace(char *str);
char *strip_comments(char *str);
void strip_quotes(char *str);
// strcat that does nothing if dest or src is NULL
@ -12,7 +19,7 @@ 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 `list_free_items_and_destroy`
list_t *split_string(const char *str, const char *delims);
@ -21,22 +28,16 @@ list_t *split_string(const char *str, const char *delims);
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);
const char *strcasestr(const char *haystack, const char *needle);
// 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

@ -3,13 +3,14 @@
#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;
};
@ -46,8 +47,9 @@ enum expected_args {
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.
*
@ -67,7 +69,7 @@ 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.
*/
@ -75,7 +77,7 @@ 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 *error, ...);
struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...) _SWAY_ATTRIB_PRINTF(2, 3);
/**
* Frees a cmd_results object.
*/
@ -87,8 +89,6 @@ void free_cmd_results(struct cmd_results *results);
*/
char *cmd_results_to_json(list_t *res_list);
struct cmd_results *add_color(char *buffer, const char *color);
/**
* TODO: Move this function and its dependent functions to container.c.
*/
@ -98,21 +98,29 @@ void container_resize_tiled(struct sway_container *parent, uint32_t axis,
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_create_output;
sway_cmd cmd_debuglog;
sway_cmd cmd_default_border;
sway_cmd cmd_default_floating_border;
sway_cmd cmd_default_orientation;
@ -136,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;
@ -143,17 +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_nop;
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;
@ -161,6 +172,7 @@ 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;
@ -178,6 +190,10 @@ 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;
@ -211,8 +227,11 @@ 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;
@ -228,46 +247,68 @@ 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_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_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,14 +4,21 @@
#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 <xkbcommon/xkbcommon.h>
#include <xf86drmMode.h>
#include "../include/config.h"
#include "gesture.h"
#include "list.h"
#include "stringop.h"
#include "swaynag.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
@ -23,24 +30,30 @@ struct sway_variable {
char *value;
};
enum binding_input_type {
BINDING_KEYCODE,
BINDING_KEYSYM,
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;
@ -48,15 +61,35 @@ struct sway_binding {
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;
};
@ -78,6 +111,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;
};
@ -87,25 +122,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;
@ -116,12 +172,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;
@ -135,10 +199,37 @@ 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_DEFAULT, // the default is currently enabled
CONSTRAIN_ENABLE,
CONSTRAIN_DISABLE
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,
};
/**
@ -149,13 +240,28 @@ struct seat_config {
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,
};
/**
@ -166,16 +272,31 @@ 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;
char *background;
char *background_option;
char *background_fallback;
enum config_dpms dpms_state;
};
/**
* An output config pre-matched to an output
*/
struct matched_output_config {
struct sway_output *output;
struct output_config *config;
};
/**
@ -188,6 +309,12 @@ struct side_gaps {
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.
@ -199,7 +326,17 @@ struct workspace_config {
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"
*
@ -226,8 +363,7 @@ 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;
@ -238,9 +374,9 @@ struct bar_config {
bool binding_mode_indicator;
bool verbose;
struct side_gaps gaps;
pid_t pid;
int status_padding;
int status_edge_padding;
uint32_t workspace_min_width;
struct {
char *background;
char *statusline;
@ -296,12 +432,16 @@ 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_SMART_NO_GAPS, /**< hide both if one window and gaps to edge is zero */
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 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 */
};
enum sway_popup_during_fullscreen {
@ -310,85 +450,35 @@ enum sway_popup_during_fullscreen {
POPUP_LEAVE,
};
enum command_context {
CONTEXT_CONFIG = 1,
CONTEXT_BINDING = 2,
CONTEXT_IPC = 4,
CONTEXT_CRITERIA = 8,
CONTEXT_ALL = 0xFFFFFFFF,
};
struct command_policy {
char *command;
uint32_t context;
};
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
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
WARP_CONTAINER,
};
enum alignment {
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT
ALIGN_RIGHT,
};
enum xwayland_mode {
XWAYLAND_MODE_DISABLED,
XWAYLAND_MODE_LAZY,
XWAYLAND_MODE_IMMEDIATE,
};
/**
@ -404,13 +494,13 @@ struct sway_config {
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;
@ -421,9 +511,10 @@ 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;
size_t font_baseline;
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;
@ -431,7 +522,12 @@ struct sway_config {
size_t urgent_timeout;
enum sway_fowa focus_on_window_activation;
enum sway_popup_during_fullscreen popup_during_fullscreen;
bool xwayland;
enum xwayland_mode xwayland;
// swaybg
char *swaybg_command;
struct wl_client *swaybg_client;
struct wl_listener swaybg_client_destroy;
// Flags
enum focus_follows_mouse_mode focus_follows_mouse;
@ -445,15 +541,17 @@ struct sway_config {
bool auto_back_and_forth;
bool show_marks;
enum alignment title_align;
bool primary_selection;
bool tiling_drag;
int tiling_drag_threshold;
bool smart_gaps;
enum smart_gaps_mode smart_gaps;
int gaps_inner;
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;
@ -464,28 +562,30 @@ struct sway_config {
int border_thickness;
int floating_border_thickness;
enum edge_border_types hide_edge_borders;
enum edge_border_types saved_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 {
@ -496,7 +596,7 @@ struct sway_config {
struct sway_node *node;
struct sway_container *container;
struct sway_workspace *workspace;
bool using_criteria;
bool node_overridden; // True if the node is selected by means other than focus
struct {
int argc;
char **argv;
@ -513,7 +613,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);
/**
@ -527,10 +627,15 @@ bool read_config(FILE *file, struct sway_config *config,
*/
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, ...);
void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2);
/**
* Free config struct
@ -550,7 +655,10 @@ struct input_config *new_input_config(const char* identifier);
void merge_input_config(struct input_config *dst, struct input_config *src);
struct input_config *store_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);
@ -576,36 +684,47 @@ 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);
bool apply_output_config(struct output_config *oc, struct sway_output *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);
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_swaybar(struct bar_config *bar);
void load_swaybars(void);
void terminate_swaybg(pid_t pid);
struct bar_config *default_bar_config(void);
void free_bar_config(struct bar_config *bar);
@ -615,14 +734,23 @@ 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,11 +1,16 @@
#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,
@ -14,31 +19,46 @@ enum criteria_type {
CT_NO_FOCUS = 1 << 4,
};
enum pattern_type {
PATTERN_PCRE2,
PATTERN_FOCUSED,
};
struct pattern {
enum pattern_type match_type;
pcre2_code *regex;
};
struct criteria {
enum criteria_type type;
char *raw; // entire criteria string (for logging)
char *cmdlist;
char *target; // workspace or output name for `assign` criteria
pcre *title;
pcre *shell;
pcre *app_id;
pcre *con_mark;
struct pattern *title;
struct pattern *shell;
struct pattern *app_id;
struct pattern *con_mark;
uint32_t con_id; // internal ID
#if HAVE_XWAYLAND
pcre *class;
#if WLR_HAS_XWAYLAND
struct pattern *class;
uint32_t id; // X11 window ID
pcre *instance;
pcre *window_role;
struct pattern *instance;
struct pattern *window_role;
enum atom_name window_type;
#endif
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);
@ -60,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,22 +0,0 @@
#ifndef SWAY_DEBUG_H
#define SWAY_DEBUG_H
#include <stdbool.h>
struct sway_debug {
bool noatomic; // Ignore atomic layout updates
bool render_tree; // Render the tree overlay
bool txn_timings; // Log verbose messages about transactions
bool txn_wait; // Always wait for the timeout before applying
enum {
DAMAGE_DEFAULT, // Default behaviour
DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged
DAMAGE_RERENDER, // Render the full output when any damage occurs
} damage;
};
extern struct sway_debug debug;
void update_debug_tree(void);
#endif

View File

@ -1,13 +0,0 @@
#include <wlr/types/wlr_surface.h>
struct sway_container;
struct sway_view;
void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole);
void desktop_damage_whole_container(struct sway_container *con);
void desktop_damage_box(struct wlr_box *box);
void desktop_damage_view(struct sway_view *view);

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,6 +1,8 @@
#ifndef _SWAY_TRANSACTION_H
#define _SWAY_TRANSACTION_H
#include <stdint.h>
#include <stdbool.h>
#include <wlr/types/wlr_scene.h>
/**
* Transactions enable us to perform atomic layout updates.
@ -28,21 +30,35 @@ struct sway_view;
*/
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_by_serial(struct sway_view *view,
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

@ -3,8 +3,10 @@
#include <stdbool.h>
#include <stdint.h>
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_surface.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
@ -21,6 +23,8 @@ struct sway_cursor {
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;
@ -29,6 +33,16 @@ struct sway_cursor {
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;
@ -38,22 +52,33 @@ struct sway_cursor {
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;
};
@ -72,24 +97,27 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
* 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(struct sway_cursor *cursor);
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);
/**
* Like cursor_rebase, but also allows focus to change when the cursor enters a
* new container.
*/
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
struct sway_node *node, struct wlr_surface *surface, double sx, double sy);
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 wlr_button_state state);
enum wl_pointer_button_state state);
void dispatch_cursor_axis(struct sway_cursor *cursor,
struct wlr_event_pointer_axis *event);
struct wlr_pointer_axis_event *event);
void cursor_set_image(struct sway_cursor *cursor, const char *image,
struct wl_client *client);
@ -99,7 +127,7 @@ void cursor_set_image_surface(struct sway_cursor *cursor,
struct wl_client *client);
void cursor_warp_to_container(struct sway_cursor *cursor,
struct sway_container *container);
struct sway_container *container, bool force);
void cursor_warp_to_workspace(struct sway_cursor *cursor,
struct sway_workspace *workspace);
@ -117,4 +145,6 @@ 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,30 +1,40 @@
#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"
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 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);
@ -37,15 +47,17 @@ void input_manager_configure_xcursor(void);
void input_manager_apply_input_config(struct input_config *input_config);
void input_manager_configure_all_input_mappings(void);
void input_manager_reset_input(struct sway_input_device *input_device);
void input_manager_reset_all_inputs();
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);
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),
@ -62,4 +74,6 @@ 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

@ -8,7 +8,7 @@
/**
* Get modifier mask from modifier name.
*
* Returns the modifer mask or 0 if the name isn't found.
* Returns the modifier mask or 0 if the name isn't found.
*/
uint32_t get_modifier_mask_by_name(const char *name);
@ -50,8 +50,13 @@ struct sway_shortcut_state {
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;
@ -59,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);

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,26 +1,67 @@
#ifndef _SWAY_INPUT_SEAT_H
#define _SWAY_INPUT_SEAT_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 (*motion)(struct sway_seat *seat, uint32_t time_msec);
void (*finish)(struct sway_seat *seat);
void (*abort)(struct sway_seat *seat);
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);
void (*render)(struct sway_seat *seat, struct sway_output *output,
pixman_region32_t *damage);
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
};
@ -33,16 +74,9 @@ struct sway_seat_node {
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;
};
@ -50,16 +84,23 @@ struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;
// 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_v1 *focused_layer;
// If exclusive_client is set, no other clients will receive input events
struct wl_client *exclusive_client;
// If the exclusive layer is set, views cannot receive keyboard focus
bool has_exclusive_layer;
// Last touch point
int32_t touch_id;
@ -68,28 +109,47 @@ struct sway_seat {
// Seat operations (drag and resize)
const struct sway_seatop_impl *seatop_impl;
void *seatop_data;
uint32_t seatop_button;
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_node;
struct wl_listener new_drag_icon;
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_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);
@ -100,6 +160,9 @@ 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);
@ -130,13 +193,17 @@ void seat_set_focus_surface(struct sway_seat *seat,
void seat_set_focus_layer(struct sway_seat *seat,
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_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);
/**
@ -180,49 +247,103 @@ 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 seatop_begin_down(struct sway_seat *seat,
struct sway_container *con, uint32_t button, int sx, int sy);
enum wlr_edges find_resize_edge(struct sway_container *cont,
struct wlr_surface *surface, struct sway_cursor *cursor);
void seatop_begin_default(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, uint32_t button);
struct sway_container *con);
void seatop_begin_move_tiling_threshold(struct sway_seat *seat,
struct sway_container *con, uint32_t button);
struct sway_container *con);
void seatop_begin_move_tiling(struct sway_seat *seat,
struct sway_container *con, uint32_t button);
struct sway_container *con);
void seatop_begin_resize_floating(struct sway_seat *seat,
struct sway_container *con, uint32_t button, enum wlr_edges edge);
struct sway_container *con, enum wlr_edges edge);
void seatop_begin_resize_tiling(struct sway_seat *seat,
struct sway_container *con, uint32_t button, enum wlr_edges edge);
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);
bool seat_doing_seatop(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_motion(struct sway_seat *seat, uint32_t time_msec);
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 and apply the affects.
* End a seatop (ie. free any seatop specific resources).
*/
void seatop_finish(struct sway_seat *seat);
/**
* End a seatop without applying the affects.
*/
void seatop_abort(struct sway_seat *seat);
void seatop_end(struct sway_seat *seat);
/**
* Instructs the seatop implementation to drop any references to the given
@ -231,12 +352,21 @@ void seatop_abort(struct sway_seat *seat);
*/
void seatop_unref(struct sway_seat *seat, struct sway_container *con);
/**
* Instructs a seatop to render anything that it needs to render
* (eg. dropzone for move-tiling)
*/
void seatop_render(struct sway_seat *seat, struct sway_output *output,
pixman_region32_t *damage);
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

View File

@ -0,0 +1,20 @@
#ifndef _SWAY_INPUT_TEXT_INPUT_POPUP_H
#define _SWAY_INPUT_TEXT_INPUT_POPUP_H
#include "sway/tree/view.h"
struct sway_input_popup {
struct sway_input_method_relay *relay;
struct wlr_scene_tree *scene_tree;
struct sway_popup_desc desc;
struct wlr_input_popup_surface_v2 *popup_surface;
struct wl_list link;
struct wl_listener popup_destroy;
struct wl_listener popup_surface_commit;
struct wl_listener focused_surface_unmap;
};
#endif

View File

@ -1,12 +1,16 @@
#ifndef _SWAY_IPC_JSON_H
#define _SWAY_IPC_JSON_H
#include <json.h>
#include "sway/output.h"
#include "sway/tree/container.h"
#include "sway/input/input-manager.h"
json_object *ipc_json_get_version(void);
json_object *ipc_json_get_binding_mode(void);
json_object *ipc_json_describe_disabled_output(struct sway_output *o);
json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *o);
json_object *ipc_json_describe_node(struct sway_node *node);
json_object *ipc_json_describe_node_recursive(struct sway_node *node);
json_object *ipc_json_describe_input(struct sway_input_device *device);

View File

@ -2,6 +2,7 @@
#define _SWAY_IPC_SERVER_H
#include <sys/socket.h>
#include "sway/config.h"
#include "sway/input/input-manager.h"
#include "sway/tree/container.h"
#include "ipc.h"
@ -19,5 +20,7 @@ void ipc_event_bar_state_update(struct bar_config *bar);
void ipc_event_mode(const char *mode, bool pango);
void ipc_event_shutdown(const char *reason);
void ipc_event_binding(struct sway_binding *binding);
void ipc_event_input(const char *change, struct sway_input_device *device);
void ipc_event_output(void);
#endif

View File

@ -1,28 +1,44 @@
#ifndef _SWAY_LAYERS_H
#define _SWAY_LAYERS_H
#include <stdbool.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include "sway/tree/view.h"
struct sway_layer_surface {
struct wlr_layer_surface_v1 *layer_surface;
struct wl_list link;
struct wl_listener destroy;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener surface_commit;
struct wl_listener output_destroy;
struct wl_listener node_destroy;
struct wl_listener new_popup;
bool configured;
struct wlr_box geo;
bool mapped;
struct wlr_scene_tree *popups;
struct sway_popup_desc desc;
struct sway_output *output;
struct wlr_scene_layer_surface_v1 *scene;
struct wlr_scene_tree *tree;
struct wlr_layer_surface_v1 *layer_surface;
};
struct sway_layer_popup {
struct wlr_xdg_popup *wlr_popup;
struct wlr_scene_tree *scene;
struct sway_layer_surface *toplevel;
struct wl_listener destroy;
struct wl_listener new_popup;
struct wl_listener commit;
};
struct sway_output;
struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface(
struct wlr_surface *surface);
void arrange_layers(struct sway_output *output);
struct sway_layer_surface *layer_from_wlr_layer_surface_v1(
struct wlr_layer_surface_v1 *layer_surface);
#endif

View File

@ -2,9 +2,10 @@
#define _SWAY_OUTPUT_H
#include <time.h>
#include <unistd.h>
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_damage_ring.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_scene.h>
#include "config.h"
#include "sway/tree/node.h"
#include "sway/tree/view.h"
@ -19,38 +20,63 @@ struct sway_output_state {
struct sway_output {
struct sway_node node;
struct wlr_output *wlr_output;
struct sway_server *server;
struct wl_list layers[4]; // sway_layer_surface::link
struct {
struct wlr_scene_tree *shell_background;
struct wlr_scene_tree *shell_bottom;
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *fullscreen;
struct wlr_scene_tree *shell_top;
struct wlr_scene_tree *shell_overlay;
struct wlr_scene_tree *session_lock;
} layers;
// when a container is fullscreen, in case the fullscreen surface is
// translucent (can see behind) we must make sure that the background is a
// solid color in order to conform to the wayland protocol. This rect
// ensures that when looking through a surface, all that will be seen
// is black.
struct wlr_scene_rect *fullscreen_background;
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct sway_server *server;
struct wl_list link;
struct wlr_box usable_area;
struct timespec last_frame;
struct wlr_output_damage *damage;
int lx, ly; // layout coords
int width, height; // transformed buffer size
enum wl_output_subpixel detected_subpixel;
enum scale_filter_mode scale_filter;
int lx, ly;
int width, height;
bool enabled, configured;
bool enabled;
list_t *workspaces;
struct sway_output_state current;
struct wl_listener layout_destroy;
struct wl_listener destroy;
struct wl_listener mode;
struct wl_listener transform;
struct wl_listener scale;
struct wl_listener commit;
struct wl_listener present;
struct wl_listener damage_destroy;
struct wl_listener damage_frame;
struct wl_list link;
pid_t bg_pid;
struct wl_listener frame;
struct wl_listener request_state;
struct {
struct wl_signal destroy;
struct wl_signal disable;
} events;
struct timespec last_presentation;
uint32_t refresh_nsec;
int max_render_time; // In milliseconds
struct wl_event_source *repaint_timer;
bool gamma_lut_changed;
};
struct sway_output_non_desktop {
struct wlr_output *wlr_output;
struct wl_listener destroy;
};
struct sway_output *output_create(struct wlr_output *wlr_output);
@ -68,65 +94,26 @@ void output_add_workspace(struct sway_output *output,
struct sway_workspace *workspace);
typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *box, float rotation,
struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
void *user_data);
void output_damage_whole(struct sway_output *output);
void output_damage_surface(struct sway_output *output, double ox, double oy,
struct wlr_surface *surface, bool whole);
void output_damage_from_view(struct sway_output *output,
struct sway_view *view);
void output_damage_box(struct sway_output *output, struct wlr_box *box);
void output_damage_whole_container(struct sway_output *output,
struct sway_container *con);
bool output_match_name_or_id(struct sway_output *output,
const char *name_or_id);
// this ONLY includes the enabled outputs
struct sway_output *output_by_name_or_id(const char *name_or_id);
// this includes all the outputs, including disabled ones
struct sway_output *all_output_by_name_or_id(const char *name_or_id);
void output_sort_workspaces(struct sway_output *output);
struct output_config *output_find_config(struct sway_output *output);
void output_enable(struct sway_output *output, struct output_config *oc);
void output_enable(struct sway_output *output);
void output_disable(struct sway_output *output);
bool output_has_opaque_overlay_layer_surface(struct sway_output *output);
struct sway_workspace *output_get_active_workspace(struct sway_output *output);
void output_render(struct sway_output *output, struct timespec *when,
pixman_region32_t *damage);
void output_surface_for_each_surface(struct sway_output *output,
struct wlr_surface *surface, double ox, double oy,
sway_surface_iterator_func_t iterator, void *user_data);
void output_view_for_each_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);
void output_view_for_each_popup(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);
void output_layer_for_each_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);
#if HAVE_XWAYLAND
void output_unmanaged_for_each_surface(struct sway_output *output,
struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
void *user_data);
#endif
void output_drag_icons_for_each_surface(struct sway_output *output,
struct wl_list *drag_icons, sway_surface_iterator_func_t iterator,
void *user_data);
void output_for_each_workspace(struct sway_output *output,
void (*f)(struct sway_workspace *ws, void *data), void *data);
@ -144,14 +131,19 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
enum sway_container_layout output_get_default_layout(
struct sway_output *output);
void render_rect(struct wlr_output *wlr_output,
pixman_region32_t *output_damage, const struct wlr_box *_box,
float color[static 4]);
void premultiply_alpha(float color[4], float opacity);
void scale_box(struct wlr_box *box, float scale);
enum wlr_direction opposite_direction(enum wlr_direction d);
void handle_output_layout_change(struct wl_listener *listener, void *data);
void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data);
void handle_output_manager_apply(struct wl_listener *listener, void *data);
void handle_output_manager_test(struct wl_listener *listener, void *data);
void handle_output_power_manager_set_mode(struct wl_listener *listener,
void *data);
struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr_output);
#endif

View File

@ -0,0 +1,33 @@
/**
* 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.
*/
#ifndef _SWAY_SCENE_DESCRIPTOR_H
#define _SWAY_SCENE_DESCRIPTOR_H
#include <wlr/types/wlr_scene.h>
enum sway_scene_descriptor_type {
SWAY_SCENE_DESC_BUFFER_TIMER,
SWAY_SCENE_DESC_NON_INTERACTIVE,
SWAY_SCENE_DESC_CONTAINER,
SWAY_SCENE_DESC_VIEW,
SWAY_SCENE_DESC_LAYER_SHELL,
SWAY_SCENE_DESC_XWAYLAND_UNMANAGED,
SWAY_SCENE_DESC_POPUP,
SWAY_SCENE_DESC_DRAG_ICON,
};
bool scene_descriptor_assign(struct wlr_scene_node *node,
enum sway_scene_descriptor_type type, void *data);
void *scene_descriptor_try_get(struct wlr_scene_node *node,
enum sway_scene_descriptor_type type);
void scene_descriptor_destroy(struct wlr_scene_node *node,
enum sway_scene_descriptor_type type);
#endif

View File

@ -1,18 +0,0 @@
#ifndef _SWAY_SECURITY_H
#define _SWAY_SECURITY_H
#include <unistd.h>
#include "sway/config.h"
uint32_t get_feature_policy_mask(pid_t pid);
uint32_t get_ipc_policy_mask(pid_t pid);
uint32_t get_command_policy_mask(const char *cmd);
struct feature_policy *get_feature_policy(const char *name);
const char *command_policy_str(enum command_context context);
struct feature_policy *alloc_feature_policy(const char *program);
struct ipc_policy *alloc_ipc_policy(const char *program);
struct command_policy *alloc_command_policy(const char *command);
#endif

View File

@ -1,52 +1,65 @@
#ifndef _SWAY_SERVER_H
#define _SWAY_SERVER_H
#include <stdbool.h>
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wayland-server-core.h>
#include "config.h"
#include "list.h"
#if HAVE_XWAYLAND
#include "sway/desktop/idle_inhibit_v1.h"
#if WLR_HAS_XWAYLAND
#include "sway/xwayland.h"
#endif
struct sway_transaction;
struct sway_session_lock {
struct wlr_session_lock_v1 *lock;
struct wlr_surface *focused;
bool abandoned;
struct wl_list outputs; // struct sway_session_lock_output
// invalid if the session is abandoned
struct wl_listener new_surface;
struct wl_listener unlock;
struct wl_listener destroy;
};
struct sway_server {
struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop;
const char *socket;
struct wlr_backend *backend;
struct wlr_backend *noop_backend;
struct wlr_session *session;
// secondary headless backend used for creating virtual outputs on-the-fly
struct wlr_backend *headless_backend;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
struct wlr_compositor *compositor;
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;
struct wlr_data_device_manager *data_device_manager;
struct sway_input_manager *input;
struct wl_listener new_output;
struct wl_listener output_layout_change;
struct wl_listener renderer_lost;
struct wlr_idle *idle;
struct sway_idle_inhibit_manager_v1 *idle_inhibit_manager_v1;
struct wlr_idle_notifier_v1 *idle_notifier_v1;
struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1;
struct wlr_layer_shell_v1 *layer_shell;
struct wl_listener layer_shell_surface;
struct wlr_xdg_shell_v6 *xdg_shell_v6;
struct wl_listener xdg_shell_v6_surface;
struct wlr_xdg_shell *xdg_shell;
struct wl_listener xdg_shell_surface;
struct wl_listener xdg_shell_toplevel;
#if HAVE_XWAYLAND
struct wlr_tablet_manager_v2 *tablet_v2;
#if WLR_HAS_XWAYLAND
struct sway_xwayland xwayland;
struct wl_listener xwayland_surface;
struct wl_listener xwayland_ready;
@ -62,36 +75,109 @@ struct sway_server {
struct wl_listener xdg_decoration;
struct wl_list xdg_decorations; // sway_xdg_decoration::link
struct wlr_presentation *presentation;
struct wlr_drm_lease_v1_manager *drm_lease_manager;
struct wl_listener drm_lease_request;
struct wlr_pointer_constraints_v1 *pointer_constraints;
struct wl_listener pointer_constraint;
struct wlr_xdg_output_manager_v1 *xdg_output_manager_v1;
struct wlr_output_manager_v1 *output_manager_v1;
struct wl_listener output_manager_apply;
struct wl_listener output_manager_test;
struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
struct wl_listener gamma_control_set_gamma;
struct {
struct sway_session_lock *lock;
struct wlr_session_lock_manager_v1 *manager;
struct wl_listener new_lock;
struct wl_listener manager_destroy;
} session_lock;
struct wlr_output_power_manager_v1 *output_power_manager_v1;
struct wl_listener output_power_manager_set_mode;
struct wlr_input_method_manager_v2 *input_method;
struct wlr_text_input_manager_v3 *text_input;
struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
struct wlr_content_type_manager_v1 *content_type_manager_v1;
struct wlr_data_control_manager_v1 *data_control_manager_v1;
struct wlr_screencopy_manager_v1 *screencopy_manager_v1;
struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1;
struct wlr_security_context_manager_v1 *security_context_manager_v1;
struct wlr_xdg_activation_v1 *xdg_activation_v1;
struct wl_listener xdg_activation_v1_request_activate;
struct wl_listener xdg_activation_v1_new_token;
struct wl_listener request_set_cursor_shape;
struct wl_list pending_launcher_ctxs; // launcher_ctx::link
// The timeout for transactions, after which a transaction is applied
// regardless of readiness.
size_t txn_timeout_ms;
list_t *transactions;
// Stores a transaction after it has been committed, but is waiting for
// views to ack the new dimensions before being applied. A queued
// transaction is frozen and must not have new instructions added to it.
struct sway_transaction *queued_transaction;
// Stores a pending transaction that will be committed once the existing
// queued transaction is applied and freed. The pending transaction can be
// updated with new instructions as needed.
struct sway_transaction *pending_transaction;
// Stores the nodes that have been marked as "dirty" and will be put into
// the pending transaction.
list_t *dirty_nodes;
};
struct sway_server server;
extern struct sway_server server;
struct sway_debug {
bool noatomic; // Ignore atomic layout updates
bool txn_timings; // Log verbose messages about transactions
bool txn_wait; // Always wait for the timeout before applying
bool legacy_wl_drm; // Enable the legacy wl_drm interface
};
extern struct sway_debug debug;
extern bool allow_unsupported_gpu;
/* Prepares an unprivileged server_init by performing all privileged operations in advance */
bool server_privileged_prepare(struct sway_server *server);
bool server_init(struct sway_server *server);
void server_fini(struct sway_server *server);
bool server_start(struct sway_server *server);
void server_run(struct sway_server *server);
void restore_nofile_limit(void);
void handle_new_output(struct wl_listener *listener, void *data);
void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data);
void handle_layer_shell_surface(struct wl_listener *listener, void *data);
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
#if HAVE_XWAYLAND
void sway_session_lock_init(void);
void sway_session_lock_add_output(struct sway_session_lock *lock,
struct sway_output *output);
bool sway_session_lock_has_surface(struct sway_session_lock *lock,
struct wlr_surface *surface);
void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data);
#if WLR_HAS_XWAYLAND
void handle_xwayland_surface(struct wl_listener *listener, void *data);
#endif
void handle_server_decoration(struct wl_listener *listener, void *data);
void handle_xdg_decoration(struct wl_listener *listener, void *data);
void handle_pointer_constraint(struct wl_listener *listener, void *data);
void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
void *data);
void xdg_activation_v1_handle_new_token(struct wl_listener *listener,
void *data);
void set_rr_scheduling(void);
#endif

View File

@ -0,0 +1,28 @@
#ifndef _SWAY_BUFFER_H
#define _SWAY_BUFFER_H
#include <wlr/types/wlr_scene.h>
struct sway_text_node {
int width;
int max_width;
int height;
int baseline;
bool pango_markup;
float color[4];
float background[4];
struct wlr_scene_node *node;
};
struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
char *text, float color[4], bool pango_markup);
void sway_text_node_set_color(struct sway_text_node *node, float color[4]);
void sway_text_node_set_text(struct sway_text_node *node, char *text);
void sway_text_node_set_max_width(struct sway_text_node *node, int max_width);
void sway_text_node_set_background(struct sway_text_node *node, float background[4]);
#endif

View File

@ -1,9 +1,13 @@
#ifndef _SWAY_SWAYNAG_H
#define _SWAY_SWAYNAG_H
#include <wayland-server-core.h>
#include "stringop.h"
struct swaynag_instance {
struct wl_client *client;
struct wl_listener client_destroy;
const char *args;
pid_t pid;
int fd[2];
bool detailed;
};
@ -15,13 +19,10 @@ struct swaynag_instance {
bool swaynag_spawn(const char *swaynag_command,
struct swaynag_instance *swaynag);
// Kill the swaynag instance
void swaynag_kill(struct swaynag_instance *swaynag);
// Write a log message to swaynag->fd[1]. This will fail when swaynag->detailed
// is false.
void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
const char *fmt, ...);
const char *fmt, ...) _SWAY_ATTRIB_PRINTF(3, 4);
// If swaynag->detailed, close swaynag->fd[1] so swaynag displays
void swaynag_show(struct swaynag_instance *swaynag);

View File

@ -2,8 +2,8 @@
#define _SWAY_CONTAINER_H
#include <stdint.h>
#include <sys/types.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_scene.h>
#include "list.h"
#include "sway/tree/node.h"
@ -46,9 +46,9 @@ struct sway_container_state {
enum sway_fullscreen_mode fullscreen_mode;
struct sway_workspace *workspace;
struct sway_container *parent;
list_t *children;
struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; // NULL if container in root of workspace
list_t *children; // struct sway_container
struct sway_container *focused_inactive_child;
bool focused;
@ -60,6 +60,7 @@ struct sway_container_state {
bool border_left;
bool border_right;
// These are in layout coordinates.
double content_x, content_y;
double content_width, content_height;
};
@ -68,84 +69,79 @@ struct sway_container {
struct sway_node node;
struct sway_view *view;
// The pending state is the main container properties, and the current state is in the below struct.
// This means most places of the code can refer to the main variables (pending state) and it'll just work.
struct wlr_scene_tree *scene_tree;
struct {
struct wlr_scene_tree *tree;
struct wlr_scene_tree *border;
struct wlr_scene_tree *background;
struct sway_text_node *title_text;
struct sway_text_node *marks_text;
} title_bar;
struct {
struct wlr_scene_tree *tree;
struct wlr_scene_rect *top;
struct wlr_scene_rect *bottom;
struct wlr_scene_rect *left;
struct wlr_scene_rect *right;
} border;
struct wlr_scene_tree *content_tree;
struct wlr_scene_buffer *output_handler;
struct wl_listener output_enter;
struct wl_listener output_leave;
struct sway_container_state current;
struct sway_container_state pending;
char *title; // The view's title (unformatted)
char *formatted_title; // The title displayed in the title bar
int title_width;
enum sway_container_layout layout;
enum sway_container_layout prev_split_layout;
// Whether stickiness has been enabled on this container. Use
// `container_is_sticky_[or_child]` rather than accessing this field
// directly; it'll also check that the container is floating.
bool is_sticky;
// For C_ROOT, this has no meaning
// For other types, this is the position in layout coordinates
// Includes borders
double x, y;
double width, height;
double saved_x, saved_y;
double saved_width, saved_height;
// These are in layout coordinates.
double content_x, content_y;
int content_width, content_height;
// In most cases this is the same as the content x and y, but if the view
// refuses to resize to the content dimensions then it can be smaller.
// These are in layout coordinates.
double surface_x, surface_y;
double surface_width, surface_height;
enum sway_fullscreen_mode fullscreen_mode;
enum sway_container_border border;
// Used when the view changes to CSD unexpectedly. This will be a non-B_CSD
// border which we use to restore when the view returns to SSD.
enum sway_container_border saved_border;
int border_thickness;
bool border_top;
bool border_bottom;
bool border_left;
bool border_right;
// The share of the space of parent container this container occupies
double width_fraction;
double height_fraction;
// The gaps currently applied to the container.
struct {
int top;
int right;
int bottom;
int left;
} current_gaps;
struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; // NULL if container in root of workspace
list_t *children; // struct sway_container
// Outputs currently being intersected
list_t *outputs; // struct sway_output
// The share of space of the parent container that all children occupy
// Used for doing the resize calculations
double child_total_width;
double child_total_height;
// Indicates that the container is a scratchpad container.
// Both hidden and visible scratchpad containers have scratchpad=true.
// Hidden scratchpad containers have a NULL parent.
bool scratchpad;
// Stores last output size and position for adjusting coordinates of
// scratchpad windows.
// Unused for non-scratchpad windows.
struct wlr_box transform;
float alpha;
struct wlr_texture *title_focused;
struct wlr_texture *title_focused_inactive;
struct wlr_texture *title_unfocused;
struct wlr_texture *title_urgent;
size_t title_height;
size_t title_baseline;
list_t *marks; // char *
struct wlr_texture *marks_focused;
struct wlr_texture *marks_focused_inactive;
struct wlr_texture *marks_unfocused;
struct wlr_texture *marks_urgent;
struct {
struct wl_signal destroy;
@ -165,22 +161,14 @@ void container_begin_destroy(struct sway_container *con);
struct sway_container *container_find_child(struct sway_container *container,
bool (*test)(struct sway_container *view, void *data), void *data);
/**
* Find a container at the given coordinates. Returns the the surface and
* surface-local coordinates of the given layout coordinates if the container
* is a view and the view contains a surface at those coordinates.
*/
struct sway_container *container_at(struct sway_workspace *workspace,
double lx, double ly, struct wlr_surface **surface,
double *sx, double *sy);
struct sway_container *tiling_container_at(
struct sway_node *parent, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy);
void container_for_each_child(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
/**
* Returns the fullscreen container obstructing this container if it exists.
*/
struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container);
/**
* Returns true if the given container is an ancestor of this container.
*/
@ -189,18 +177,13 @@ bool container_has_ancestor(struct sway_container *container,
void container_update_textures_recursive(struct sway_container *con);
void container_damage_whole(struct sway_container *container);
void container_reap_empty(struct sway_container *con);
struct sway_container *container_flatten(struct sway_container *container);
void container_update_title_textures(struct sway_container *container);
void container_update_title_bar(struct sway_container *container);
/**
* Calculate the container's title_height property.
*/
void container_calculate_title_height(struct sway_container *container);
void container_update_marks(struct sway_container *container);
size_t container_build_representation(enum sway_container_layout layout,
list_t *children, char *buffer);
@ -212,10 +195,17 @@ void container_update_representation(struct sway_container *container);
*/
size_t container_titlebar_height(void);
/**
* Resize and center the container in its workspace.
*/
void container_init_floating(struct sway_container *container);
void floating_calculate_constraints(int *min_width, int *max_width,
int *min_height, int *max_height);
void floating_fix_coordinates(struct sway_container *con,
struct wlr_box *old, struct wlr_box *new);
void container_floating_resize_and_center(struct sway_container *con);
void container_floating_set_default_size(struct sway_container *con);
void container_set_resizing(struct sway_container *con, bool resizing);
void container_set_floating(struct sway_container *container, bool enable);
@ -224,6 +214,8 @@ void container_set_geometry_from_content(struct sway_container *con);
/**
* Determine if the given container is itself floating.
* This will return false for any descendants of a floating container.
*
* Uses pending container state.
*/
bool container_is_floating(struct sway_container *container);
@ -270,6 +262,13 @@ void container_set_fullscreen(struct sway_container *con,
*/
void container_fullscreen_disable(struct sway_container *con);
/**
* Walk up the container tree branch starting at the given container, and return
* its earliest ancestor.
*/
struct sway_container *container_toplevel_ancestor(
struct sway_container *container);
/**
* Return true if the container is floating, or a child of a floating split
* container.
@ -282,29 +281,12 @@ bool container_is_floating_or_child(struct sway_container *container);
*/
bool container_is_fullscreen_or_child(struct sway_container *container);
/**
* Return the output which will be used for scale purposes.
* This is the most recently entered output.
*/
struct sway_output *container_get_effective_output(struct sway_container *con);
void container_discover_outputs(struct sway_container *con);
void container_remove_gaps(struct sway_container *container);
void container_add_gaps(struct sway_container *container);
enum sway_container_layout container_parent_layout(struct sway_container *con);
enum sway_container_layout container_current_parent_layout(
struct sway_container *con);
list_t *container_get_siblings(struct sway_container *container);
int container_sibling_index(struct sway_container *child);
list_t *container_get_current_siblings(struct sway_container *container);
void container_handle_fullscreen_reparent(struct sway_container *con);
void container_add_child(struct sway_container *parent,
@ -324,6 +306,8 @@ void container_detach(struct sway_container *child);
void container_replace(struct sway_container *container,
struct sway_container *replacement);
void container_swap(struct sway_container *con1, struct sway_container *con2);
struct sway_container *container_split(struct sway_container *child,
enum sway_container_layout layout);
@ -350,10 +334,33 @@ bool container_has_mark(struct sway_container *container, char *mark);
void container_add_mark(struct sway_container *container, char *mark);
void container_update_marks_textures(struct sway_container *container);
void container_raise_floating(struct sway_container *con);
bool container_is_scratchpad_hidden(struct sway_container *con);
bool container_is_scratchpad_hidden_or_child(struct sway_container *con);
bool container_is_sticky(struct sway_container *con);
bool container_is_sticky_or_child(struct sway_container *con);
/**
* This will destroy pairs of redundant H/V splits
* e.g. H[V[H[app app]] app] -> H[app app app]
* The middle "V[H[" are eliminated by a call to container_squash
* on the V[ con. It's grandchildren are added to its parent.
*
* This function is roughly equivalent to i3's tree_flatten here:
* https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651
*
* Returns the number of new containers added to the parent
*/
int container_squash(struct sway_container *con);
void container_arrange_title_bar(struct sway_container *con);
void container_update(struct sway_container *con);
void container_update_itself_and_parents(struct sway_container *con);
#endif

View File

@ -1,8 +1,13 @@
#ifndef _SWAY_NODE_H
#define _SWAY_NODE_H
#include <wayland-server-core.h>
#include <stdbool.h>
#include <wlr/types/wlr_scene.h>
#include "list.h"
#define MIN_SANE_W 100
#define MIN_SANE_H 60
struct sway_root;
struct sway_output;
struct sway_workspace;
@ -71,4 +76,15 @@ list_t *node_get_children(struct sway_node *node);
bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor);
// when destroying a sway tree, it's not known which order the tree will be
// destroyed. To prevent freeing of scene_nodes recursing up the tree,
// let's use this helper function to disown them to the staging node.
void scene_node_disown_children(struct wlr_scene_tree *tree);
// a helper function used to allocate tree nodes. If an allocation failure
// occurs a flag is flipped that can be checked later to destroy a parent
// of this scene node preventing memory leaks.
struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent,
bool *failed);
#endif

Some files were not shown because too many files have changed in this diff Show More