Compare commits

...

141 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
167 changed files with 4405 additions and 5472 deletions

View File

@ -38,9 +38,14 @@ tasks:
cd sway cd sway
ninja -C build ninja -C build
- build-no-xwayland: | - build-no-xwayland: |
cd sway cd wlroots
meson configure build -Dxwayland=disabled meson configure build -Dxwayland=disabled
ninja -C build ninja -C build
sudo ninja -C build install
cd ../sway
meson configure build --clearcache
ninja -C build
- build-static: | - build-static: |
cd sway cd sway
mkdir subprojects mkdir subprojects

View File

@ -2,13 +2,13 @@
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). 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).
## Signaturen ## Signaturen
Jedes Release wird mit dem PGP-Schlüssel [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48) signiert und auf GitHub veröffentlicht. 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 ## Installation
### Mit der Paketverwaltung
Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Das Paket sollte "sway" heißen. Falls es kein solches Paket gibt, kannst du im [Wiki](https://github.com/swaywm/sway/wiki/Unsupported-packages) (englisch) nach mehr Informationen bezüglich deiner Distribution suchen.
Falls du sway für deine eigene Distribution als Paket bereitstellen möchtest, solltest du die Entwickler per IRC oder E-Mail (sir@cmpwn.com) kontaktieren. ### Über die Paketverwaltung
Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Versuche einfach das Packet "sway" zu installieren.
### Quellcode selbst kompilieren ### Quellcode selbst kompilieren
@ -23,8 +23,8 @@ sway benötigt die folgenden Pakete:
* pango * pango
* cairo * cairo
* gdk-pixbuf2 (Optional, wird für das Benachrichtigungsfeld (System Tray) benötigt) * 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) * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (Optional, wird für die Dokumentation (Man Pages) benötigt)\*
* git\* * git (Optional: Versionsinfo)\*
_\*Werden nur während des Kompilierens benötigt_ _\*Werden nur während des Kompilierens benötigt_

View File

@ -31,7 +31,8 @@ Install dependencies:
* json-c * json-c
* pango * pango
* cairo * cairo
* gdk-pixbuf2 (optional: system tray) * gdk-pixbuf2 (optional: additional image formats for system tray)
* [swaybg] (optional: wallpaper)
* [scdoc] (optional: man pages) \* * [scdoc] (optional: man pages) \*
* git (optional: version info) \* * git (optional: version info) \*
@ -89,4 +90,5 @@ sway (gdm is known to work fairly well).
[GitHub releases]: https://github.com/swaywm/sway/releases [GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup [Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots [wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[swaybg]: https://github.com/swaywm/swaybg/
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc [scdoc]: https://git.sr.ht/~sircmpwn/scdoc

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809
#include <assert.h> #include <assert.h>
#include <cairo.h> #include <cairo.h>
#include <errno.h> #include <errno.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "gesture.h" #include "gesture.h"
#include <math.h> #include <math.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200112L
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200112L
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>

View File

@ -1,7 +1,6 @@
lib_sway_common = static_library( lib_sway_common = static_library(
'sway-common', 'sway-common',
files( files(
'background-image.c',
'cairo.c', 'cairo.c',
'gesture.c', 'gesture.c',
'ipc-client.c', 'ipc-client.c',
@ -14,7 +13,6 @@ lib_sway_common = static_library(
), ),
dependencies: [ dependencies: [
cairo, cairo,
gdk_pixbuf,
pango, pango,
pangocairo, pangocairo,
wayland_client.partial_dependency(compile_args: true) wayland_client.partial_dependency(compile_args: true)

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <ctype.h> #include <ctype.h>
#include <fcntl.h> #include <fcntl.h>
#include <math.h> #include <math.h>

View File

@ -1,20 +0,0 @@
#ifndef _SWAY_BACKGROUND_IMAGE_H
#define _SWAY_BACKGROUND_IMAGE_H
#include "cairo_util.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

@ -291,6 +291,14 @@ struct output_config {
char *background_fallback; char *background_fallback;
}; };
/**
* An output config pre-matched to an output
*/
struct matched_output_config {
struct sway_output *output;
struct output_config *config;
};
/** /**
* Stores size of gaps for each side * Stores size of gaps for each side
*/ */
@ -680,20 +688,25 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt
struct output_config *new_output_config(const char *name); 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);
bool test_output_config(struct output_config *oc, struct sway_output *output); void sort_output_configs_by_priority(struct matched_output_config *configs,
size_t configs_len);
struct output_config *store_output_config(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); struct output_config *find_output_config(struct sway_output *output);
void apply_output_config_to_outputs(struct output_config *oc);
void reset_outputs(void);
void free_output_config(struct output_config *oc); void free_output_config(struct output_config *oc);
bool spawn_swaybg(void); bool spawn_swaybg(void);

View File

@ -7,6 +7,10 @@
#include "list.h" #include "list.h"
#include "tree/view.h" #include "tree/view.h"
#if WLR_HAS_XWAYLAND
#include "sway/xwayland.h"
#endif
enum criteria_type { enum criteria_type {
CT_COMMAND = 1 << 0, CT_COMMAND = 1 << 0,
CT_ASSIGN_OUTPUT = 1 << 1, CT_ASSIGN_OUTPUT = 1 << 1,
@ -36,7 +40,7 @@ struct criteria {
struct pattern *app_id; struct pattern *app_id;
struct pattern *con_mark; struct pattern *con_mark;
uint32_t con_id; // internal ID uint32_t con_id; // internal ID
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
struct pattern *class; struct pattern *class;
uint32_t id; // X11 window ID uint32_t id; // X11 window ID
struct pattern *instance; struct pattern *instance;

View File

@ -1,13 +0,0 @@
#include <wlr/types/wlr_compositor.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

@ -3,14 +3,18 @@
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include "sway/input/seat.h"
struct launcher_ctx { struct launcher_ctx {
pid_t pid; pid_t pid;
char *fallback_name; char *fallback_name;
struct wlr_xdg_activation_token_v1 *token; struct wlr_xdg_activation_token_v1 *token;
struct wl_listener token_destroy; struct wl_listener token_destroy;
struct sway_seat *seat;
struct wl_listener seat_destroy;
bool activated; bool activated;
bool had_focused_surface;
struct sway_node *node; struct sway_node *node;
struct wl_listener node_destroy; struct wl_listener node_destroy;

View File

@ -1,6 +1,8 @@
#ifndef _SWAY_TRANSACTION_H #ifndef _SWAY_TRANSACTION_H
#define _SWAY_TRANSACTION_H #define _SWAY_TRANSACTION_H
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#include <wlr/types/wlr_scene.h>
/** /**
* Transactions enable us to perform atomic layout updates. * Transactions enable us to perform atomic layout updates.
@ -38,8 +40,11 @@ void transaction_commit_dirty_client(void);
* Notify the transaction system that a view is ready for the new layout. * 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. * 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); uint32_t serial);
/** /**
@ -47,8 +52,13 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view,
* identifying the instruction by geometry 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. * 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_geometry(struct sway_view *view, bool transaction_notify_view_ready_by_geometry(struct sway_view *view,
double x, double y, int width, int height); double x, double y, int width, int height);
void arrange_popups(struct wlr_scene_tree *popups);
#endif #endif

View File

@ -114,7 +114,7 @@ void pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
void dispatch_cursor_button(struct sway_cursor *cursor, void dispatch_cursor_button(struct sway_cursor *cursor,
struct wlr_input_device *device, uint32_t time_msec, uint32_t button, 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, void dispatch_cursor_axis(struct sway_cursor *cursor,
struct wlr_pointer_axis_event *event); struct wlr_pointer_axis_event *event);

View File

@ -1,14 +1,15 @@
#ifndef _SWAY_INPUT_INPUT_MANAGER_H #ifndef _SWAY_INPUT_INPUT_MANAGER_H
#define _SWAY_INPUT_INPUT_MANAGER_H #define _SWAY_INPUT_INPUT_MANAGER_H
#include <libinput.h> #include <libinput.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h> #include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h> #include <wlr/types/wlr_virtual_pointer_v1.h>
#include "sway/server.h" #include <wlr/types/wlr_transient_seat_v1.h>
#include "sway/config.h" #include "sway/config.h"
#include "list.h" #include "list.h"
struct sway_server;
struct sway_input_device { struct sway_input_device {
char *identifier; char *identifier;
struct wlr_input_device *wlr_device; struct wlr_input_device *wlr_device;
@ -21,11 +22,11 @@ struct sway_input_manager {
struct wl_list devices; struct wl_list devices;
struct wl_list seats; struct wl_list seats;
struct wlr_input_inhibit_manager *inhibit;
struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit; struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit;
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
struct wlr_virtual_pointer_manager_v1 *virtual_pointer; struct wlr_virtual_pointer_manager_v1 *virtual_pointer;
struct wlr_pointer_gestures_v1 *pointer_gestures; struct wlr_pointer_gestures_v1 *pointer_gestures;
struct wlr_transient_seat_manager_v1 *transient_seat_manager;
struct wl_listener new_input; struct wl_listener new_input;
struct wl_listener inhibit_activate; struct wl_listener inhibit_activate;
@ -33,6 +34,7 @@ struct sway_input_manager {
struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor; struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor;
struct wl_listener virtual_keyboard_new; struct wl_listener virtual_keyboard_new;
struct wl_listener virtual_pointer_new; struct wl_listener virtual_pointer_new;
struct wl_listener transient_seat_create;
}; };
struct sway_input_manager *input_manager_create(struct sway_server *server); struct sway_input_manager *input_manager_create(struct sway_server *server);

View File

@ -4,6 +4,9 @@
bool sway_input_configure_libinput_device(struct sway_input_device *device); 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); void sway_input_reset_libinput_device(struct sway_input_device *device);
bool sway_libinput_device_is_builtin(struct sway_input_device *device); bool sway_libinput_device_is_builtin(struct sway_input_device *device);

View File

@ -3,6 +3,7 @@
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_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_seat.h>
#include <wlr/types/wlr_touch.h> #include <wlr/types/wlr_touch.h>
#include <wlr/util/edges.h> #include <wlr/util/edges.h>
@ -12,12 +13,11 @@
#include "sway/input/text_input.h" #include "sway/input/text_input.h"
struct sway_seat; struct sway_seat;
struct render_context;
struct sway_seatop_impl { struct sway_seatop_impl {
void (*button)(struct sway_seat *seat, uint32_t time_msec, void (*button)(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button, struct wlr_input_device *device, uint32_t button,
enum wlr_button_state state); enum wl_pointer_button_state state);
void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec);
void (*pointer_axis)(struct sway_seat *seat, void (*pointer_axis)(struct sway_seat *seat,
struct wlr_pointer_axis_event *event); struct wlr_pointer_axis_event *event);
@ -52,7 +52,6 @@ struct sway_seatop_impl {
uint32_t time_msec, enum wlr_tablet_tool_tip_state state); uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
void (*end)(struct sway_seat *seat); void (*end)(struct sway_seat *seat);
void (*unref)(struct sway_seat *seat, struct sway_container *con); void (*unref)(struct sway_seat *seat, struct sway_container *con);
void (*render)(struct sway_seat *seat, struct render_context *ctx);
bool allow_set_cursor; bool allow_set_cursor;
}; };
@ -75,20 +74,6 @@ struct sway_seat_node {
struct wl_listener destroy; struct wl_listener destroy;
}; };
struct sway_drag_icon {
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
int dx, dy; // offset in surface-local coordinates
struct wl_listener surface_commit;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
};
struct sway_drag { struct sway_drag {
struct sway_seat *seat; struct sway_seat *seat;
struct wlr_drag *wlr_drag; struct wlr_drag *wlr_drag;
@ -99,6 +84,15 @@ struct sway_seat {
struct wlr_seat *wlr_seat; struct wlr_seat *wlr_seat;
struct sway_cursor *cursor; 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; bool has_focus;
struct wl_list focus_stack; // list of containers in focus order struct wl_list focus_stack; // list of containers in focus order
struct sway_workspace *workspace; struct sway_workspace *workspace;
@ -108,9 +102,6 @@ struct sway_seat {
// If the exclusive layer is set, views cannot receive keyboard focus // If the exclusive layer is set, views cannot receive keyboard focus
bool has_exclusive_layer; bool has_exclusive_layer;
// If exclusive_client is set, no other clients will receive input events
struct wl_client *exclusive_client;
// Last touch point // Last touch point
int32_t touch_id; int32_t touch_id;
double touch_x, touch_y; double touch_x, touch_y;
@ -133,6 +124,7 @@ struct sway_seat {
struct wl_listener start_drag; struct wl_listener start_drag;
struct wl_listener request_set_selection; struct wl_listener request_set_selection;
struct wl_listener request_set_primary_selection; struct wl_listener request_set_primary_selection;
struct wl_listener destroy;
struct wl_list devices; // sway_seat_device::link struct wl_list devices; // sway_seat_device::link
struct wl_list keyboard_groups; // sway_keyboard_group::link struct wl_list keyboard_groups; // sway_keyboard_group::link
@ -201,8 +193,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
void seat_set_focus_layer(struct sway_seat *seat, void seat_set_focus_layer(struct sway_seat *seat,
struct wlr_layer_surface_v1 *layer); struct wlr_layer_surface_v1 *layer);
void seat_set_exclusive_client(struct sway_seat *seat, void seat_unfocus_unless_client(struct sway_seat *seat, struct wl_client *client);
struct wl_client *client);
struct sway_node *seat_get_focus(struct sway_seat *seat); struct sway_node *seat_get_focus(struct sway_seat *seat);
@ -261,7 +252,7 @@ void seat_idle_notify_activity(struct sway_seat *seat,
bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); 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);
enum wlr_edges find_resize_edge(struct sway_container *cont, enum wlr_edges find_resize_edge(struct sway_container *cont,
struct wlr_surface *surface, struct sway_cursor *cursor); struct wlr_surface *surface, struct sway_cursor *cursor);
@ -296,13 +287,13 @@ struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
struct sway_workspace *workspace); struct sway_workspace *workspace);
void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
uint32_t button, enum wlr_button_state state); uint32_t button, enum wl_pointer_button_state state);
void seat_consider_warp_to_focus(struct sway_seat *seat); void seat_consider_warp_to_focus(struct sway_seat *seat);
void seatop_button(struct sway_seat *seat, uint32_t time_msec, void seatop_button(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button, struct wlr_input_device *device, uint32_t button,
enum wlr_button_state state); enum wl_pointer_button_state state);
void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec);
@ -361,12 +352,6 @@ void seatop_end(struct sway_seat *seat);
*/ */
void seatop_unref(struct sway_seat *seat, struct sway_container *con); 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 render_context *ctx);
bool seatop_allows_set_cursor(struct sway_seat *seat); bool seatop_allows_set_cursor(struct sway_seat *seat);
/** /**

View File

@ -21,18 +21,21 @@ struct sway_input_method_relay {
struct sway_seat *seat; struct sway_seat *seat;
struct wl_list text_inputs; // sway_text_input::link 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 wlr_input_method_v2 *input_method; // doesn't have to be present
struct wl_listener text_input_new; struct wl_listener text_input_new;
struct wl_listener input_method_new; struct wl_listener input_method_new;
struct wl_listener input_method_commit; 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_grab_keyboard;
struct wl_listener input_method_destroy; struct wl_listener input_method_destroy;
struct wl_listener input_method_keyboard_grab_destroy; struct wl_listener input_method_keyboard_grab_destroy;
}; };
struct sway_text_input { struct sway_text_input {
struct sway_input_method_relay *relay; struct sway_input_method_relay *relay;

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

@ -3,54 +3,34 @@
#include <stdbool.h> #include <stdbool.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
#include "sway/tree/view.h"
enum layer_parent {
LAYER_PARENT_LAYER,
LAYER_PARENT_POPUP,
};
struct sway_layer_surface { 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 map;
struct wl_listener unmap; struct wl_listener unmap;
struct wl_listener surface_commit; struct wl_listener surface_commit;
struct wl_listener output_destroy; struct wl_listener output_destroy;
struct wl_listener node_destroy;
struct wl_listener new_popup; struct wl_listener new_popup;
struct wl_listener new_subsurface;
struct wlr_box geo;
bool mapped; bool mapped;
struct wlr_box extent;
enum zwlr_layer_shell_v1_layer layer;
struct wl_list subsurfaces; 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 sway_layer_popup {
struct wlr_xdg_popup *wlr_popup; struct wlr_xdg_popup *wlr_popup;
enum layer_parent parent_type; struct wlr_scene_tree *scene;
union { struct sway_layer_surface *toplevel;
struct sway_layer_surface *parent_layer;
struct sway_layer_popup *parent_popup;
};
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener commit;
struct wl_listener new_popup; struct wl_listener new_popup;
};
struct sway_layer_subsurface {
struct wlr_subsurface *wlr_subsurface;
struct sway_layer_surface *layer_surface;
struct wl_list link;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener commit; struct wl_listener commit;
}; };
@ -61,7 +41,4 @@ struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface(
void arrange_layers(struct sway_output *output); 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 #endif

View File

@ -5,6 +5,7 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_damage_ring.h> #include <wlr/types/wlr_damage_ring.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_scene.h>
#include "config.h" #include "config.h"
#include "sway/tree/node.h" #include "sway/tree/node.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
@ -19,32 +20,46 @@ struct sway_output_state {
struct sway_output { struct sway_output {
struct sway_node node; struct sway_node node;
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_output *wlr_output;
struct wlr_scene_output *scene_output;
struct sway_server *server; struct sway_server *server;
struct wl_list link; struct wl_list link;
struct wl_list layers[4]; // sway_layer_surface::link
struct wlr_box usable_area; struct wlr_box usable_area;
struct timespec last_frame;
struct wlr_damage_ring damage_ring;
int lx, ly; // layout coords int lx, ly; // layout coords
int width, height; // transformed buffer size int width, height; // transformed buffer size
enum wl_output_subpixel detected_subpixel; enum wl_output_subpixel detected_subpixel;
enum scale_filter_mode scale_filter; enum scale_filter_mode scale_filter;
bool enabling, enabled; bool enabled;
list_t *workspaces; list_t *workspaces;
struct sway_output_state current; struct sway_output_state current;
struct wl_listener layout_destroy;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener commit; struct wl_listener commit;
struct wl_listener present; struct wl_listener present;
struct wl_listener damage;
struct wl_listener frame; struct wl_listener frame;
struct wl_listener needs_frame;
struct wl_listener request_state; struct wl_listener request_state;
struct { struct {
@ -64,14 +79,6 @@ struct sway_output_non_desktop {
struct wl_listener destroy; struct wl_listener destroy;
}; };
struct render_context {
struct sway_output *output;
struct wlr_renderer *renderer;
const pixman_region32_t *output_damage;
struct wlr_render_pass *pass;
};
struct sway_output *output_create(struct wlr_output *wlr_output); struct sway_output *output_create(struct wlr_output *wlr_output);
void output_destroy(struct sway_output *output); void output_destroy(struct sway_output *output);
@ -90,19 +97,6 @@ typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box, struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
void *user_data); 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, bool output_match_name_or_id(struct sway_output *output,
const char *name_or_id); const char *name_or_id);
@ -118,46 +112,8 @@ void output_enable(struct sway_output *output);
void output_disable(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); struct sway_workspace *output_get_active_workspace(struct sway_output *output);
void output_render(struct render_context *ctx);
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_surface(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);
void output_layer_for_each_toplevel_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);
void output_layer_for_each_popup_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 output_for_each_workspace(struct sway_output *output,
void (*f)(struct sway_workspace *ws, void *data), void *data); void (*f)(struct sway_workspace *ws, void *data), void *data);
@ -175,13 +131,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
enum sway_container_layout output_get_default_layout( enum sway_container_layout output_get_default_layout(
struct sway_output *output); struct sway_output *output);
void render_rect(struct render_context *ctx, 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); enum wlr_direction opposite_direction(enum wlr_direction d);
void handle_output_layout_change(struct wl_listener *listener, void *data); void handle_output_layout_change(struct wl_listener *listener, void *data);

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

@ -2,32 +2,28 @@
#define _SWAY_SERVER_H #define _SWAY_SERVER_H
#include <stdbool.h> #include <stdbool.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output_management_v1.h>
#include <wlr/types/wlr_output_power_management_v1.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_text_input_v3.h>
#include <wlr/types/wlr_xdg_shell.h>
#include "config.h" #include "config.h"
#include "list.h" #include "list.h"
#include "sway/desktop/idle_inhibit_v1.h" #include "sway/desktop/idle_inhibit_v1.h"
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
#include "sway/xwayland.h" #include "sway/xwayland.h"
#endif #endif
struct sway_transaction; 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 sway_server {
struct wl_display *wl_display; struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop; struct wl_event_loop *wl_event_loop;
@ -41,7 +37,6 @@ struct sway_server {
struct wlr_allocator *allocator; struct wlr_allocator *allocator;
struct wlr_compositor *compositor; struct wlr_compositor *compositor;
struct wl_listener compositor_new_surface;
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1; struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;
@ -51,6 +46,7 @@ struct sway_server {
struct wl_listener new_output; struct wl_listener new_output;
struct wl_listener output_layout_change; struct wl_listener output_layout_change;
struct wl_listener renderer_lost;
struct wlr_idle_notifier_v1 *idle_notifier_v1; struct wlr_idle_notifier_v1 *idle_notifier_v1;
struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1; struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1;
@ -59,11 +55,11 @@ struct sway_server {
struct wl_listener layer_shell_surface; struct wl_listener layer_shell_surface;
struct wlr_xdg_shell *xdg_shell; struct wlr_xdg_shell *xdg_shell;
struct wl_listener xdg_shell_surface; struct wl_listener xdg_shell_toplevel;
struct wlr_tablet_manager_v2 *tablet_v2; struct wlr_tablet_manager_v2 *tablet_v2;
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
struct sway_xwayland xwayland; struct sway_xwayland xwayland;
struct wl_listener xwayland_surface; struct wl_listener xwayland_surface;
struct wl_listener xwayland_ready; struct wl_listener xwayland_ready;
@ -82,11 +78,11 @@ struct sway_server {
struct wlr_drm_lease_v1_manager *drm_lease_manager; struct wlr_drm_lease_v1_manager *drm_lease_manager;
struct wl_listener drm_lease_request; struct wl_listener drm_lease_request;
struct wlr_presentation *presentation;
struct wlr_pointer_constraints_v1 *pointer_constraints; struct wlr_pointer_constraints_v1 *pointer_constraints;
struct wl_listener pointer_constraint; struct wl_listener pointer_constraint;
struct wlr_xdg_output_manager_v1 *xdg_output_manager_v1;
struct wlr_output_manager_v1 *output_manager_v1; struct wlr_output_manager_v1 *output_manager_v1;
struct wl_listener output_manager_apply; struct wl_listener output_manager_apply;
struct wl_listener output_manager_test; struct wl_listener output_manager_test;
@ -95,15 +91,9 @@ struct sway_server {
struct wl_listener gamma_control_set_gamma; struct wl_listener gamma_control_set_gamma;
struct { struct {
bool locked; struct sway_session_lock *lock;
struct wlr_session_lock_manager_v1 *manager; struct wlr_session_lock_manager_v1 *manager;
struct wlr_session_lock_v1 *lock;
struct wlr_surface *focused;
struct wl_listener lock_new_surface;
struct wl_listener lock_unlock;
struct wl_listener lock_destroy;
struct wl_listener new_lock; struct wl_listener new_lock;
struct wl_listener manager_destroy; struct wl_listener manager_destroy;
} session_lock; } session_lock;
@ -112,6 +102,7 @@ struct sway_server {
struct wl_listener output_power_manager_set_mode; struct wl_listener output_power_manager_set_mode;
struct wlr_input_method_manager_v2 *input_method; struct wlr_input_method_manager_v2 *input_method;
struct wlr_text_input_manager_v3 *text_input; 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_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
struct wlr_content_type_manager_v1 *content_type_manager_v1; struct wlr_content_type_manager_v1 *content_type_manager_v1;
struct wlr_data_control_manager_v1 *data_control_manager_v1; struct wlr_data_control_manager_v1 *data_control_manager_v1;
@ -152,17 +143,13 @@ struct sway_debug {
bool noatomic; // Ignore atomic layout updates bool noatomic; // Ignore atomic layout updates
bool txn_timings; // Log verbose messages about transactions bool txn_timings; // Log verbose messages about transactions
bool txn_wait; // Always wait for the timeout before applying bool txn_wait; // Always wait for the timeout before applying
bool noscanout; // Disable direct scan-out bool legacy_wl_drm; // Enable the legacy wl_drm interface
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; extern struct sway_debug debug;
extern bool allow_unsupported_gpu;
bool server_init(struct sway_server *server); bool server_init(struct sway_server *server);
void server_fini(struct sway_server *server); void server_fini(struct sway_server *server);
bool server_start(struct sway_server *server); bool server_start(struct sway_server *server);
@ -170,14 +157,17 @@ void server_run(struct sway_server *server);
void restore_nofile_limit(void); void restore_nofile_limit(void);
void handle_compositor_new_surface(struct wl_listener *listener, void *data);
void handle_new_output(struct wl_listener *listener, void *data); void handle_new_output(struct wl_listener *listener, void *data);
void handle_idle_inhibitor_v1(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_layer_shell_surface(struct wl_listener *listener, void *data);
void sway_session_lock_init(void); void sway_session_lock_init(void);
void handle_xdg_shell_surface(struct wl_listener *listener, void *data); void sway_session_lock_add_output(struct sway_session_lock *lock,
#if HAVE_XWAYLAND 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); void handle_xwayland_surface(struct wl_listener *listener, void *data);
#endif #endif
void handle_server_decoration(struct wl_listener *listener, void *data); void handle_server_decoration(struct wl_listener *listener, void *data);

View File

@ -1,24 +0,0 @@
#ifndef _SWAY_SURFACE_H
#define _SWAY_SURFACE_H
#include <wlr/types/wlr_compositor.h>
struct sway_surface {
struct wlr_surface *wlr_surface;
struct wl_listener destroy;
/**
* This timer can be used for issuing delayed frame done callbacks (for
* example, to improve presentation latency). Its handler is set to a
* function that issues a frame done callback to this surface.
*/
struct wl_event_source *frame_done_timer;
};
void surface_update_outputs(struct wlr_surface *surface);
void surface_enter_output(struct wlr_surface *surface,
struct sway_output *output);
void surface_leave_output(struct wlr_surface *surface,
struct sway_output *output);
#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

@ -3,6 +3,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_scene.h>
#include "list.h" #include "list.h"
#include "sway/tree/node.h" #include "sway/tree/node.h"
@ -68,11 +69,39 @@ struct sway_container {
struct sway_node node; struct sway_node node;
struct sway_view *view; struct sway_view *view;
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 current;
struct sway_container_state pending; struct sway_container_state pending;
char *title; // The view's title (unformatted) char *title; // The view's title (unformatted)
char *formatted_title; // The title displayed in the title bar char *formatted_title; // The title displayed in the title bar
int title_width;
enum sway_container_layout prev_split_layout; enum sway_container_layout prev_split_layout;
@ -100,14 +129,6 @@ struct sway_container {
double child_total_width; double child_total_width;
double child_total_height; double child_total_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;
// Outputs currently being intersected
list_t *outputs; // struct sway_output
// Indicates that the container is a scratchpad container. // Indicates that the container is a scratchpad container.
// Both hidden and visible scratchpad containers have scratchpad=true. // Both hidden and visible scratchpad containers have scratchpad=true.
// Hidden scratchpad containers have a NULL parent. // Hidden scratchpad containers have a NULL parent.
@ -120,18 +141,7 @@ struct sway_container {
float alpha; float alpha;
struct wlr_texture *title_focused;
struct wlr_texture *title_focused_inactive;
struct wlr_texture *title_focused_tab_title;
struct wlr_texture *title_unfocused;
struct wlr_texture *title_urgent;
list_t *marks; // char * list_t *marks; // char *
struct wlr_texture *marks_focused;
struct wlr_texture *marks_focused_inactive;
struct wlr_texture *marks_focused_tab_title;
struct wlr_texture *marks_unfocused;
struct wlr_texture *marks_urgent;
struct { struct {
struct wl_signal destroy; struct wl_signal destroy;
@ -151,19 +161,6 @@ void container_begin_destroy(struct sway_container *con);
struct sway_container *container_find_child(struct sway_container *container, struct sway_container *container_find_child(struct sway_container *container,
bool (*test)(struct sway_container *view, void *data), void *data); bool (*test)(struct sway_container *view, void *data), void *data);
/**
* Find a container at the given coordinates. Returns 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 container_for_each_child(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data); void (*f)(struct sway_container *container, void *data), void *data);
@ -180,13 +177,13 @@ bool container_has_ancestor(struct sway_container *container,
void container_update_textures_recursive(struct sway_container *con); 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); void container_reap_empty(struct sway_container *con);
struct sway_container *container_flatten(struct sway_container *container); 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);
void container_update_marks(struct sway_container *container);
size_t container_build_representation(enum sway_container_layout layout, size_t container_build_representation(enum sway_container_layout layout,
list_t *children, char *buffer); list_t *children, char *buffer);
@ -222,11 +219,6 @@ void container_set_geometry_from_content(struct sway_container *con);
*/ */
bool container_is_floating(struct sway_container *container); bool container_is_floating(struct sway_container *container);
/**
* Same as above, but for current container state.
*/
bool container_is_current_floating(struct sway_container *container);
/** /**
* Get a container's box in layout coordinates. * Get a container's box in layout coordinates.
*/ */
@ -289,26 +281,12 @@ bool container_is_floating_or_child(struct sway_container *container);
*/ */
bool container_is_fullscreen_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.
* If the container is not on any output, return NULL.
*/
struct sway_output *container_get_effective_output(struct sway_container *con);
void container_discover_outputs(struct sway_container *con);
enum sway_container_layout container_parent_layout(struct sway_container *con); 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); list_t *container_get_siblings(struct sway_container *container);
int container_sibling_index(struct sway_container *child); 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_handle_fullscreen_reparent(struct sway_container *con);
void container_add_child(struct sway_container *parent, void container_add_child(struct sway_container *parent,
@ -356,8 +334,6 @@ bool container_has_mark(struct sway_container *container, char *mark);
void container_add_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); void container_raise_floating(struct sway_container *con);
bool container_is_scratchpad_hidden(struct sway_container *con); bool container_is_scratchpad_hidden(struct sway_container *con);
@ -381,4 +357,10 @@ bool container_is_sticky_or_child(struct sway_container *con);
*/ */
int container_squash(struct sway_container *con); 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 #endif

View File

@ -2,6 +2,7 @@
#define _SWAY_NODE_H #define _SWAY_NODE_H
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <stdbool.h> #include <stdbool.h>
#include <wlr/types/wlr_scene.h>
#include "list.h" #include "list.h"
#define MIN_SANE_W 100 #define MIN_SANE_W 100
@ -75,4 +76,15 @@ list_t *node_get_children(struct sway_node *node);
bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); 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 #endif

View File

@ -2,11 +2,12 @@
#define _SWAY_ROOT_H #define _SWAY_ROOT_H
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/config.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/node.h" #include "sway/tree/node.h"
#include "config.h"
#include "list.h" #include "list.h"
extern struct sway_root *root; extern struct sway_root *root;
@ -16,10 +17,44 @@ struct sway_root {
struct wlr_output_layout *output_layout; struct wlr_output_layout *output_layout;
struct wl_listener output_layout_change; struct wl_listener output_layout_change;
#if HAVE_XWAYLAND
struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link // scene node layout:
// - root
// - staging
// - layer shell stuff
// - tiling
// - floating
// - fullscreen stuff
// - seat stuff
// - ext_session_lock
struct wlr_scene *root_scene;
// since wlr_scene nodes can't be orphaned and must always
// have a parent, use this staging scene_tree so that a
// node always have a valid parent. Nothing in this
// staging node will be visible.
struct wlr_scene_tree *staging;
// tree containing all layers the compositor will render. Cursor handling
// will end up iterating this tree.
struct wlr_scene_tree *layer_tree;
struct {
struct wlr_scene_tree *shell_background;
struct wlr_scene_tree *shell_bottom;
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *floating;
struct wlr_scene_tree *shell_top;
struct wlr_scene_tree *fullscreen;
struct wlr_scene_tree *fullscreen_global;
#if WLR_HAS_XWAYLAND
struct wlr_scene_tree *unmanaged;
#endif #endif
struct wl_list drag_icons; // sway_drag_icon::link struct wlr_scene_tree *shell_overlay;
struct wlr_scene_tree *popup;
struct wlr_scene_tree *seat;
struct wlr_scene_tree *session_lock;
} layers;
// Includes disabled outputs // Includes disabled outputs
struct wl_list all_outputs; // sway_output::link struct wl_list all_outputs; // sway_output::link
@ -41,7 +76,7 @@ struct sway_root {
} events; } events;
}; };
struct sway_root *root_create(void); struct sway_root *root_create(struct wl_display *display);
void root_destroy(struct sway_root *root); void root_destroy(struct sway_root *root);

View File

@ -1,9 +1,11 @@
#ifndef _SWAY_VIEW_H #ifndef _SWAY_VIEW_H
#define _SWAY_VIEW_H #define _SWAY_VIEW_H
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/config.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_scene.h>
#include "sway/config.h" #include "sway/config.h"
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
#include <wlr/xwayland.h> #include <wlr/xwayland.h>
#endif #endif
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
@ -14,7 +16,7 @@ struct sway_xdg_decoration;
enum sway_view_type { enum sway_view_type {
SWAY_VIEW_XDG_SHELL, SWAY_VIEW_XDG_SHELL,
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
SWAY_VIEW_XWAYLAND, SWAY_VIEW_XWAYLAND,
#endif #endif
}; };
@ -26,7 +28,7 @@ enum sway_view_prop {
VIEW_PROP_INSTANCE, VIEW_PROP_INSTANCE,
VIEW_PROP_WINDOW_TYPE, VIEW_PROP_WINDOW_TYPE,
VIEW_PROP_WINDOW_ROLE, VIEW_PROP_WINDOW_ROLE,
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
VIEW_PROP_X11_WINDOW_ID, VIEW_PROP_X11_WINDOW_ID,
VIEW_PROP_X11_PARENT_ID, VIEW_PROP_X11_PARENT_ID,
#endif #endif
@ -45,10 +47,6 @@ struct sway_view_impl {
void (*set_fullscreen)(struct sway_view *view, bool fullscreen); void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
void (*set_resizing)(struct sway_view *view, bool resizing); void (*set_resizing)(struct sway_view *view, bool resizing);
bool (*wants_floating)(struct sway_view *view); bool (*wants_floating)(struct sway_view *view);
void (*for_each_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
void (*for_each_popup_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
bool (*is_transient_for)(struct sway_view *child, bool (*is_transient_for)(struct sway_view *child,
struct sway_view *ancestor); struct sway_view *ancestor);
void (*close)(struct sway_view *view); void (*close)(struct sway_view *view);
@ -56,19 +54,14 @@ struct sway_view_impl {
void (*destroy)(struct sway_view *view); void (*destroy)(struct sway_view *view);
}; };
struct sway_saved_buffer {
struct wlr_client_buffer *buffer;
int x, y;
int width, height;
enum wl_output_transform transform;
struct wlr_fbox source_box;
struct wl_list link; // sway_view::saved_buffers
};
struct sway_view { struct sway_view {
enum sway_view_type type; enum sway_view_type type;
const struct sway_view_impl *impl; const struct sway_view_impl *impl;
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *content_tree;
struct wlr_scene_tree *saved_surface_tree;
struct sway_container *container; // NULL if unmapped and transactions finished struct sway_container *container; // NULL if unmapped and transactions finished
struct wlr_surface *surface; // NULL for unmapped views struct wlr_surface *surface; // NULL for unmapped views
struct sway_xdg_decoration *xdg_decoration; struct sway_xdg_decoration *xdg_decoration;
@ -88,15 +81,11 @@ struct sway_view {
bool allow_request_urgent; bool allow_request_urgent;
struct wl_event_source *urgent_timer; struct wl_event_source *urgent_timer;
struct wl_list saved_buffers; // sway_saved_buffer::link
// The geometry for whatever the client is committing, regardless of // The geometry for whatever the client is committing, regardless of
// transaction state. Updated on every commit. // transaction state. Updated on every commit.
struct wlr_box geometry; struct wlr_box geometry;
// The "old" geometry during a transaction. Used to damage the old location struct wlr_ext_foreign_toplevel_handle_v1 *ext_foreign_toplevel;
// when a transaction is applied.
struct wlr_box saved_geometry;
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
struct wl_listener foreign_activate_request; struct wl_listener foreign_activate_request;
@ -110,7 +99,7 @@ struct sway_view {
union { union {
struct wlr_xdg_toplevel *wlr_xdg_toplevel; struct wlr_xdg_toplevel *wlr_xdg_toplevel;
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
struct wlr_xwayland_surface *wlr_xwayland_surface; struct wlr_xwayland_surface *wlr_xwayland_surface;
#endif #endif
}; };
@ -119,8 +108,6 @@ struct sway_view {
struct wl_signal unmap; struct wl_signal unmap;
} events; } events;
struct wl_listener surface_new_subsurface;
int max_render_time; // In milliseconds int max_render_time; // In milliseconds
enum seat_config_shortcuts_inhibit shortcuts_inhibit; enum seat_config_shortcuts_inhibit shortcuts_inhibit;
@ -141,10 +128,12 @@ struct sway_xdg_shell_view {
struct wl_listener unmap; struct wl_listener unmap;
struct wl_listener destroy; struct wl_listener destroy;
}; };
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
struct sway_xwayland_view { struct sway_xwayland_view {
struct sway_view view; struct sway_view view;
struct wlr_scene_tree *surface_tree;
struct wl_listener commit; struct wl_listener commit;
struct wl_listener request_move; struct wl_listener request_move;
struct wl_listener request_resize; struct wl_listener request_resize;
@ -166,18 +155,18 @@ struct sway_xwayland_view {
struct wl_listener unmap; struct wl_listener unmap;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener override_redirect; struct wl_listener override_redirect;
struct wl_listener surface_tree_destroy;
}; };
struct sway_xwayland_unmanaged { struct sway_xwayland_unmanaged {
struct wlr_xwayland_surface *wlr_xwayland_surface; struct wlr_xwayland_surface *wlr_xwayland_surface;
struct wl_list link;
int lx, ly; struct wlr_scene_surface *surface_scene;
struct wl_listener request_activate; struct wl_listener request_activate;
struct wl_listener request_configure; struct wl_listener request_configure;
struct wl_listener request_fullscreen; struct wl_listener request_fullscreen;
struct wl_listener commit;
struct wl_listener set_geometry; struct wl_listener set_geometry;
struct wl_listener associate; struct wl_listener associate;
struct wl_listener dissociate; struct wl_listener dissociate;
@ -187,46 +176,24 @@ struct sway_xwayland_unmanaged {
struct wl_listener override_redirect; struct wl_listener override_redirect;
}; };
#endif #endif
struct sway_view_child;
struct sway_view_child_impl {
void (*get_view_coords)(struct sway_view_child *child, int *sx, int *sy);
void (*destroy)(struct sway_view_child *child);
};
/**
* A view child is a surface in the view tree, such as a subsurface or a popup.
*/
struct sway_view_child {
const struct sway_view_child_impl *impl;
struct wl_list link;
struct sway_popup_desc {
struct wlr_scene_node *relative;
struct sway_view *view; struct sway_view *view;
struct sway_view_child *parent;
struct wl_list children; // sway_view_child::link
struct wlr_surface *surface;
bool mapped;
struct wl_listener surface_commit;
struct wl_listener surface_new_subsurface;
struct wl_listener surface_map;
struct wl_listener surface_unmap;
struct wl_listener surface_destroy;
struct wl_listener view_unmap;
};
struct sway_subsurface {
struct sway_view_child child;
struct wl_listener destroy;
}; };
struct sway_xdg_popup { struct sway_xdg_popup {
struct sway_view_child child; struct sway_view *view;
struct wlr_scene_tree *scene_tree;
struct wlr_scene_tree *xdg_surface_tree;
struct wlr_xdg_popup *wlr_xdg_popup; struct wlr_xdg_popup *wlr_xdg_popup;
struct sway_popup_desc desc;
struct wl_listener surface_commit;
struct wl_listener new_popup; struct wl_listener new_popup;
struct wl_listener reposition;
struct wl_listener destroy; struct wl_listener destroy;
}; };
@ -277,6 +244,11 @@ void view_set_activated(struct sway_view *view, bool activated);
*/ */
void view_request_activate(struct sway_view *view, struct sway_seat *seat); void view_request_activate(struct sway_view *view, struct sway_seat *seat);
/*
* Called when the view requests urgent state
*/
void view_request_urgent(struct sway_view *view);
/** /**
* If possible, instructs the client to change their decoration mode. * If possible, instructs the client to change their decoration mode.
*/ */
@ -294,23 +266,9 @@ void view_close(struct sway_view *view);
void view_close_popups(struct sway_view *view); void view_close_popups(struct sway_view *view);
void view_damage_from(struct sway_view *view);
/**
* Iterate all surfaces of a view (toplevels + popups).
*/
void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Iterate all popup surfaces of a view.
*/
void view_for_each_popup_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
// view implementation // view implementation
void view_init(struct sway_view *view, enum sway_view_type type, bool view_init(struct sway_view *view, enum sway_view_type type,
const struct sway_view_impl *impl); const struct sway_view_impl *impl);
void view_destroy(struct sway_view *view); void view_destroy(struct sway_view *view);
@ -332,23 +290,18 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
void view_unmap(struct sway_view *view); void view_unmap(struct sway_view *view);
void view_update_size(struct sway_view *view); void view_update_size(struct sway_view *view);
void view_center_surface(struct sway_view *view); void view_center_and_clip_surface(struct sway_view *view);
void view_child_init(struct sway_view_child *child,
const struct sway_view_child_impl *impl, struct sway_view *view,
struct wlr_surface *surface);
void view_child_destroy(struct sway_view_child *child);
struct sway_view *view_from_wlr_xdg_surface( struct sway_view *view_from_wlr_xdg_surface(
struct wlr_xdg_surface *xdg_surface); struct wlr_xdg_surface *xdg_surface);
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
struct sway_view *view_from_wlr_xwayland_surface( struct sway_view *view_from_wlr_xwayland_surface(
struct wlr_xwayland_surface *xsurface); struct wlr_xwayland_surface *xsurface);
#endif #endif
struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
void view_update_app_id(struct sway_view *view);
/** /**
* Re-read the view's title property and update any relevant title bars. * Re-read the view's title property and update any relevant title bars.
* The force argument makes it recreate the title bars even if the title hasn't * The force argument makes it recreate the title bars even if the title hasn't
@ -380,4 +333,6 @@ bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor);
void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx); void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx);
void view_send_frame_done(struct sway_view *view);
#endif #endif

View File

@ -2,6 +2,7 @@
#define _SWAY_WORKSPACE_H #define _SWAY_WORKSPACE_H
#include <stdbool.h> #include <stdbool.h>
#include <wlr/types/wlr_scene.h>
#include "sway/config.h" #include "sway/config.h"
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/node.h" #include "sway/tree/node.h"
@ -23,6 +24,12 @@ struct sway_workspace_state {
struct sway_workspace { struct sway_workspace {
struct sway_node node; struct sway_node node;
struct {
struct wlr_scene_tree *tiling;
struct wlr_scene_tree *fullscreen;
} layers;
struct sway_container *fullscreen; struct sway_container *fullscreen;
char *name; char *name;

View File

@ -16,4 +16,6 @@ struct sway_xdg_decoration {
struct sway_xdg_decoration *xdg_decoration_from_surface( struct sway_xdg_decoration *xdg_decoration_from_surface(
struct wlr_surface *surface); struct wlr_surface *surface);
void set_xdg_decoration_mode(struct sway_xdg_decoration *deco);
#endif #endif

7
include/swaybar/image.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef _SWAYBAR_IMAGE_H
#define _SWAYBAR_IMAGE_H
#include <cairo.h>
cairo_surface_t *load_image(const char *path);
#endif

View File

@ -1,7 +1,7 @@
project( project(
'sway', 'sway',
'c', 'c',
version: '1.9-dev', version: '1.10-dev',
license: 'MIT', license: 'MIT',
meson_version: '>=0.60.0', meson_version: '>=0.60.0',
default_options: [ default_options: [
@ -14,6 +14,7 @@ project(
add_project_arguments( add_project_arguments(
[ [
'-DWLR_USE_UNSTABLE', '-DWLR_USE_UNSTABLE',
'-D_POSIX_C_SOURCE=200809L',
'-Wno-unused-parameter', '-Wno-unused-parameter',
'-Wno-unused-result', '-Wno-unused-result',
@ -37,14 +38,14 @@ if is_freebsd
endif endif
# Execute the wlroots subproject, if any # Execute the wlroots subproject, if any
wlroots_version = ['>=0.17.0', '<0.18.0'] wlroots_version = ['>=0.18.0', '<0.19.0']
subproject( subproject(
'wlroots', 'wlroots',
default_options: ['examples=false'], default_options: ['examples=false'],
required: false, required: false,
version: wlroots_version, version: wlroots_version,
) )
wlroots = dependency('wlroots', version: wlroots_version) wlroots = dependency('wlroots-0.18', version: wlroots_version, fallback: 'wlroots')
wlroots_features = { wlroots_features = {
'xwayland': false, 'xwayland': false,
'libinput_backend': false, 'libinput_backend': false,
@ -56,10 +57,6 @@ foreach name, _ : wlroots_features
wlroots_features += { name: have } wlroots_features += { name: have }
endforeach endforeach
if get_option('xwayland').enabled() and not wlroots_features['xwayland']
error('Cannot enable Xwayland in sway: wlroots has been built without Xwayland support')
endif
null_dep = dependency('', required: false) null_dep = dependency('', required: false)
jsonc = dependency('json-c', version: '>=0.13') jsonc = dependency('json-c', version: '>=0.13')
@ -67,7 +64,7 @@ pcre2 = dependency('libpcre2-8')
wayland_server = dependency('wayland-server', version: '>=1.21.0') wayland_server = dependency('wayland-server', version: '>=1.21.0')
wayland_client = dependency('wayland-client') wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor') wayland_cursor = dependency('wayland-cursor')
wayland_protos = dependency('wayland-protocols', version: '>=1.24') wayland_protos = dependency('wayland-protocols', version: '>=1.24', default_options: ['tests=false'])
xkbcommon = dependency('xkbcommon', version: '>=1.5.0') xkbcommon = dependency('xkbcommon', version: '>=1.5.0')
cairo = dependency('cairo') cairo = dependency('cairo')
pango = dependency('pango') pango = dependency('pango')
@ -76,17 +73,14 @@ gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
libevdev = dependency('libevdev') libevdev = dependency('libevdev')
libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
xcb = dependency('xcb', required: get_option('xwayland')) xcb = wlroots_features['xwayland'] ? dependency('xcb') : null_dep
drm_full = dependency('libdrm') # only needed for drm_fourcc.h drm = dependency('libdrm')
drm = drm_full.partial_dependency(compile_args: true, includes: true)
libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep
math = cc.find_library('m') math = cc.find_library('m')
rt = cc.find_library('rt') rt = cc.find_library('rt')
xcb_icccm = dependency('xcb-icccm', required: get_option('xwayland')) xcb_icccm = wlroots_features['xwayland'] ? dependency('xcb-icccm') : null_dep
threads = dependency('threads') # for pthread_setschedparam threads = dependency('threads') # for pthread_setschedparam
have_xwayland = xcb.found() and xcb_icccm.found() and wlroots_features['xwayland']
if get_option('sd-bus-provider') == 'auto' if get_option('sd-bus-provider') == 'auto'
if not get_option('tray').disabled() if not get_option('tray').disabled()
assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto') assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
@ -110,7 +104,6 @@ have_tray = (not get_option('tray').disabled()) and tray_deps_found
conf_data = configuration_data() conf_data = configuration_data()
conf_data.set10('HAVE_XWAYLAND', have_xwayland)
conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found()) conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd') conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd')
conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind') conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind')
@ -271,7 +264,6 @@ endif
subdir('completions') subdir('completions')
summary({ summary({
'xwayland': have_xwayland,
'gdk-pixbuf': gdk_pixbuf.found(), 'gdk-pixbuf': gdk_pixbuf.found(),
'tray': have_tray, 'tray': have_tray,
'man-pages': scdoc.found(), 'man-pages': scdoc.found(),

View File

@ -4,8 +4,7 @@ option('bash-completions', type: 'boolean', value: true, description: 'Install b
option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.') option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.')
option('swaybar', type: 'boolean', value: true, description: 'Enable support for swaybar') option('swaybar', type: 'boolean', value: true, description: 'Enable support for swaybar')
option('swaynag', type: 'boolean', value: true, description: 'Enable support for swaynag') option('swaynag', type: 'boolean', value: true, description: 'Enable support for swaynag')
option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')
option('tray', type: 'feature', value: 'auto', description: 'Enable support for swaybar tray') option('tray', type: 'feature', value: 'auto', description: 'Enable support for swaybar tray')
option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybg') option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybar tray')
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library') option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library')

View File

@ -16,7 +16,6 @@ protocols = [
wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml', wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml',
'wlr-layer-shell-unstable-v1.xml', 'wlr-layer-shell-unstable-v1.xml',
'idle.xml', 'idle.xml',
'wlr-input-inhibitor-unstable-v1.xml',
'wlr-output-power-management-unstable-v1.xml', 'wlr-output-power-management-unstable-v1.xml',
] ]

View File

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_input_inhibit_unstable_v1">
<copyright>
Copyright © 2018 Drew DeVault
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<interface name="zwlr_input_inhibit_manager_v1" version="1">
<description summary="inhibits input events to other clients">
Clients can use this interface to prevent input events from being sent to
any surfaces but its own, which is useful for example in lock screen
software. It is assumed that access to this interface will be locked down
to whitelisted clients by the compositor.
</description>
<request name="get_inhibitor">
<description summary="inhibit input to other clients">
Activates the input inhibitor. As long as the inhibitor is active, the
compositor will not send input events to other clients.
</description>
<arg name="id" type="new_id" interface="zwlr_input_inhibitor_v1"/>
</request>
<enum name="error">
<entry name="already_inhibited" value="0" summary="an input inhibitor is already in use on the compositor"/>
</enum>
</interface>
<interface name="zwlr_input_inhibitor_v1" version="1">
<description summary="inhibits input to other clients">
While this resource exists, input to clients other than the owner of the
inhibitor resource will not receive input events. The client that owns
this resource will receive all input events normally. The compositor will
also disable all of its own input processing (such as keyboard shortcuts)
while the inhibitor is active.
The compositor may continue to send input events to selected clients,
such as an on-screen keyboard (via the input-method protocol).
</description>
<request name="destroy" type="destructor">
<description summary="destroy the input inhibitor object">
Destroy the inhibitor and allow other clients to receive input.
</description>
</request>
</interface>
</protocol>

31
release.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh -eu
prev=$(git describe --tags --abbrev=0)
next=$(meson rewrite kwargs info project / 2>&1 >/dev/null | jq -r '.kwargs["project#/"].version')
case "$next" in
*-dev)
echo "This is a development version"
exit 1
;;
esac
if [ "$prev" = "$next" ]; then
echo "Version not bumped in meson.build"
exit 1
fi
if ! git diff-index --quiet HEAD -- meson.build; then
echo "meson.build not committed"
exit 1
fi
shortlog="$(git shortlog --no-merges "$prev..")"
(echo "sway $next"; echo ""; echo "$shortlog") | git tag "$next" -ase -F -
prefix=sway-$next
archive=$prefix.tar.gz
git archive --prefix="$prefix/" -o "$archive" "$next"
gpg --output "$archive".sig --detach-sig "$archive"
gh release create "sway $next" -t "$next" -n "" -d "$archive" "$archive.sig"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
@ -82,7 +81,6 @@ static const struct cmd_handler handlers[] = {
{ "no_focus", cmd_no_focus }, { "no_focus", cmd_no_focus },
{ "output", cmd_output }, { "output", cmd_output },
{ "popup_during_fullscreen", cmd_popup_during_fullscreen }, { "popup_during_fullscreen", cmd_popup_during_fullscreen },
{ "primary_selection", cmd_primary_selection },
{ "seat", cmd_seat }, { "seat", cmd_seat },
{ "set", cmd_set }, { "set", cmd_set },
{ "show_marks", cmd_show_marks }, { "show_marks", cmd_show_marks },
@ -105,6 +103,7 @@ static const struct cmd_handler handlers[] = {
static const struct cmd_handler config_handlers[] = { static const struct cmd_handler config_handlers[] = {
{ "default_orientation", cmd_default_orientation }, { "default_orientation", cmd_default_orientation },
{ "include", cmd_include }, { "include", cmd_include },
{ "primary_selection", cmd_primary_selection },
{ "swaybg_command", cmd_swaybg_command }, { "swaybg_command", cmd_swaybg_command },
{ "swaynag_command", cmd_swaynag_command }, { "swaynag_command", cmd_swaynag_command },
{ "workspace_layout", cmd_workspace_layout }, { "workspace_layout", cmd_workspace_layout },

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "config.h" #include "config.h"
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "config.h" #include "config.h"
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <libevdev/libevdev.h> #include <libevdev/libevdev.h>
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#include <string.h> #include <string.h>

View File

@ -5,9 +5,8 @@
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "util.h" #include "util.h"
static void rebuild_textures_iterator(struct sway_container *con, void *data) { static void container_update_iterator(struct sway_container *con, void *data) {
container_update_marks_textures(con); container_update(con);
container_update_title_textures(con);
} }
static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
@ -51,12 +50,7 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
memcpy(class, &colors, sizeof(struct border_colors)); memcpy(class, &colors, sizeof(struct border_colors));
if (config->active) { if (config->active) {
root_for_each_container(rebuild_textures_iterator, NULL); root_for_each_container(container_update_iterator, NULL);
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
}
} }
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "gesture.h" #include "gesture.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "sway/config.h" #include "sway/config.h"

View File

@ -5,6 +5,7 @@
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/server.h"
#include "log.h" #include "log.h"
#if WLR_HAS_LIBINPUT_BACKEND #if WLR_HAS_LIBINPUT_BACKEND

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "sway/config.h" #include "sway/config.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include "sway/config.h" #include "sway/config.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "util.h" #include "util.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,9 +1,9 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h> #include <assert.h>
#include <wlr/interfaces/wlr_keyboard.h> #include <wlr/interfaces/wlr_keyboard.h>
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/server.h"
#include "log.h" #include "log.h"
struct xkb_switch_layout_action { struct xkb_switch_layout_action {

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include "sway/config.h" #include "sway/config.h"
#include "sway/commands.h" #include "sway/commands.h"
#include "log.h" #include "log.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
@ -59,7 +58,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
} }
free(mark); free(mark);
container_update_marks_textures(container); container_update_marks(container);
if (container->view) { if (container->view) {
view_execute_criteria(container->view); view_execute_criteria(container->view);
} }

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#include <stdbool.h> #include <stdbool.h>
@ -12,6 +11,7 @@
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/ipc-server.h" #include "sway/ipc-server.h"
#include "sway/output.h" #include "sway/output.h"
#include "sway/server.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/root.h" #include "sway/tree/root.h"
@ -770,15 +770,6 @@ static struct cmd_results *cmd_move_in_direction(
ipc_event_window(container, "move"); ipc_event_window(container, "move");
} }
// Hack to re-focus container
seat_set_raw_focus(config->handler_context.seat, &new_ws->node);
seat_set_focus_container(config->handler_context.seat, container);
if (old_ws != new_ws) {
ipc_event_workspace(old_ws, new_ws, "focus");
workspace_detect_urgent(old_ws);
workspace_detect_urgent(new_ws);
}
container_end_mouse_operation(container); container_end_mouse_operation(container);
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View File

@ -37,6 +37,7 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
} }
con->alpha = val; con->alpha = val;
container_damage_whole(con); container_update(con);
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
} }

View File

@ -103,15 +103,18 @@ struct cmd_results *cmd_output(int argc, char **argv) {
bool background = output->background; bool background = output->background;
output = store_output_config(output); store_output_config(output);
// If reloading, the output configs will be applied after reading the // If reloading, the output configs will be applied after reading the
// entire config and before the deferred commands so that an auto generated // entire config and before the deferred commands so that an auto generated
// workspace name is not given to re-enabled outputs. // workspace name is not given to re-enabled outputs.
if (!config->reloading && !config->validating) { if (!config->reloading && !config->validating) {
apply_output_config_to_outputs(output); apply_all_output_configs();
if (background) { if (background) {
spawn_swaybg(); if (!spawn_swaybg()) {
return cmd_results_new(CMD_FAILURE,
"Failed to apply background configuration");
}
} }
} }

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <libgen.h> #include <libgen.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -123,7 +122,10 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
src); src);
config_add_swaynag_warning("Unable to access background file '%s'", config_add_swaynag_warning("Unable to access background file '%s'",
src); src);
struct cmd_results *result = cmd_results_new(CMD_FAILURE,
"unable to access background file '%s'", src);
free(src); free(src);
return result;
} else { } else {
output->background = src; output->background = src;
output->background_option = strdup(mode); output->background_option = strdup(mode);

View File

@ -29,7 +29,7 @@ struct cmd_results *output_cmd_toggle(int argc, char **argv) {
config->handler_context.output_config->enabled = 1; config->handler_context.output_config->enabled = 1;
} }
free(oc); free_output_config(oc);
config->handler_context.leftovers.argc = argc; config->handler_context.leftovers.argc = argc;
config->handler_context.leftovers.argv = argv; config->handler_context.leftovers.argv = argv;
return NULL; return NULL;

View File

@ -1,4 +1,5 @@
#include <string.h> #include <string.h>
#include <wlr/util/transform.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "log.h" #include "log.h"

View File

@ -12,12 +12,14 @@ struct cmd_results *cmd_primary_selection(int argc, char **argv) {
bool primary_selection = parse_boolean(argv[0], true); bool primary_selection = parse_boolean(argv[0], true);
// config->primary_selection is reset to the previous value on reload in
// load_main_config()
if (config->reloading && config->primary_selection != primary_selection) { if (config->reloading && config->primary_selection != primary_selection) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"primary_selection can only be enabled/disabled at launch"); "primary_selection can only be enabled/disabled at launch");
} }
config->primary_selection = parse_boolean(argv[0], true); config->primary_selection = primary_selection;
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
} }

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
@ -9,9 +8,8 @@
#include "list.h" #include "list.h"
#include "log.h" #include "log.h"
static void rebuild_textures_iterator(struct sway_container *con, void *data) { static void title_bar_update_iterator(struct sway_container *con, void *data) {
container_update_marks_textures(con); container_update_title_bar(con);
container_update_title_textures(con);
} }
static void do_reload(void *data) { static void do_reload(void *data) {
@ -48,7 +46,7 @@ static void do_reload(void *data) {
} }
list_free_items_and_destroy(bar_ids); list_free_items_and_destroy(bar_ids);
root_for_each_container(rebuild_textures_iterator, NULL); root_for_each_container(title_bar_update_iterator, NULL);
arrange_root(); arrange_root();
} }

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#include <strings.h> #include <strings.h>
@ -6,6 +5,7 @@
#include <wlr/types/wlr_pointer.h> #include <wlr/types/wlr_pointer.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/input/cursor.h" #include "sway/input/cursor.h"
#include "sway/server.h"
static struct cmd_results *press_or_release(struct sway_cursor *cursor, static struct cmd_results *press_or_release(struct sway_cursor *cursor,
char *action, char *button_str); char *action, char *button_str);
@ -85,12 +85,12 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
static struct cmd_results *press_or_release(struct sway_cursor *cursor, static struct cmd_results *press_or_release(struct sway_cursor *cursor,
char *action, char *button_str) { char *action, char *button_str) {
enum wlr_button_state state; enum wl_pointer_button_state state;
uint32_t button; uint32_t button;
if (strcasecmp(action, "press") == 0) { if (strcasecmp(action, "press") == 0) {
state = WLR_BUTTON_PRESSED; state = WL_POINTER_BUTTON_STATE_PRESSED;
} else if (strcasecmp(action, "release") == 0) { } else if (strcasecmp(action, "release") == 0) {
state = WLR_BUTTON_RELEASED; state = WL_POINTER_BUTTON_STATE_RELEASED;
} else { } else {
return cmd_results_new(CMD_INVALID, "%s", expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
@ -105,16 +105,16 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
} else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
|| button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) { || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) {
// Dispatch axis event // Dispatch axis event
enum wlr_axis_orientation orientation = enum wl_pointer_axis orientation =
(button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN) (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN)
? WLR_AXIS_ORIENTATION_VERTICAL ? WL_POINTER_AXIS_VERTICAL_SCROLL
: WLR_AXIS_ORIENTATION_HORIZONTAL; : WL_POINTER_AXIS_HORIZONTAL_SCROLL;
double delta = (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_LEFT) double delta = (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_LEFT)
? -1 : 1; ? -1 : 1;
struct wlr_pointer_axis_event event = { struct wlr_pointer_axis_event event = {
.pointer = NULL, .pointer = NULL,
.time_msec = 0, .time_msec = 0,
.source = WLR_AXIS_SOURCE_WHEEL, .source = WL_POINTER_AXIS_SOURCE_WHEEL,
.orientation = orientation, .orientation = orientation,
.delta = delta * 15, .delta = delta * 15,
.delta_discrete = delta .delta_discrete = delta

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>

View File

@ -4,6 +4,7 @@
#include "sway/config.h" #include "sway/config.h"
#include "sway/input/cursor.h" #include "sway/input/cursor.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/server.h"
enum operation { enum operation {
OP_ENABLE, OP_ENABLE,

View File

@ -2,6 +2,7 @@
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/server.h"
#include "util.h" #include "util.h"
static struct cmd_results *handle_action(struct seat_config *sc, static struct cmd_results *handle_action(struct seat_config *sc,

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>

View File

@ -3,6 +3,7 @@
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/server.h"
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
@ -10,8 +9,8 @@
#include "stringop.h" #include "stringop.h"
#include "util.h" #include "util.h"
static void rebuild_marks_iterator(struct sway_container *con, void *data) { static void title_bar_update_iterator(struct sway_container *con, void *data) {
container_update_marks_textures(con); container_update_marks(con);
} }
struct cmd_results *cmd_show_marks(int argc, char **argv) { struct cmd_results *cmd_show_marks(int argc, char **argv) {
@ -23,12 +22,7 @@ struct cmd_results *cmd_show_marks(int argc, char **argv) {
config->show_marks = parse_boolean(argv[0], config->show_marks); config->show_marks = parse_boolean(argv[0], config->show_marks);
if (config->show_marks) { if (config->show_marks) {
root_for_each_container(rebuild_marks_iterator, NULL); root_for_each_container(title_bar_update_iterator, NULL);
}
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
} }
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <strings.h> #include <strings.h>
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
@ -19,7 +18,7 @@ static bool test_con_id(struct sway_container *container, void *data) {
return container->node.id == *con_id; return container->node.id == *con_id;
} }
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
static bool test_id(struct sway_container *container, void *data) { static bool test_id(struct sway_container *container, void *data) {
xcb_window_t *wid = data; xcb_window_t *wid = data;
return (container->view && container->view->type == SWAY_VIEW_XWAYLAND return (container->view && container->view->type == SWAY_VIEW_XWAYLAND
@ -54,7 +53,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
char *value = join_args(argv + 3, argc - 3); char *value = join_args(argv + 3, argc - 3);
if (strcasecmp(argv[2], "id") == 0) { if (strcasecmp(argv[2], "id") == 0) {
#if HAVE_XWAYLAND #if WLR_HAS_XWAYLAND
xcb_window_t id = strtol(value, NULL, 0); xcb_window_t id = strtol(value, NULL, 0);
other = root_find_container(test_id, &id); other = root_find_container(test_id, &id);
#endif #endif

View File

@ -4,6 +4,10 @@
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/root.h" #include "sway/tree/root.h"
static void arrange_title_bar_iterator(struct sway_container *con, void *data) {
container_arrange_title_bar(con);
}
struct cmd_results *cmd_title_align(int argc, char **argv) { struct cmd_results *cmd_title_align(int argc, char **argv) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = checkarg(argc, "title_align", EXPECTED_AT_LEAST, 1))) { if ((error = checkarg(argc, "title_align", EXPECTED_AT_LEAST, 1))) {
@ -21,10 +25,7 @@ struct cmd_results *cmd_title_align(int argc, char **argv) {
"Expected 'title_align left|center|right'"); "Expected 'title_align left|center|right'");
} }
for (int i = 0; i < root->outputs->length; ++i) { root_for_each_container(arrange_title_bar_iterator, NULL);
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
}
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
} }

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"

View File

@ -27,7 +27,6 @@ struct cmd_results *cmd_titlebar_border_thickness(int argc, char **argv) {
"Expected output to have a workspace"); "Expected output to have a workspace");
} }
arrange_workspace(ws); arrange_workspace(ws);
output_damage_whole(output);
} }
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View File

@ -33,7 +33,6 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) {
for (int i = 0; i < root->outputs->length; ++i) { for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i]; struct sway_output *output = root->outputs->items[i];
arrange_workspace(output_get_active_workspace(output)); arrange_workspace(output_get_active_workspace(output));
output_damage_whole(output);
} }
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
@ -8,9 +7,13 @@
#include "log.h" #include "log.h"
#include "stringop.h" #include "stringop.h"
static void remove_all_marks_iterator(struct sway_container *con, void *data) { static void remove_mark(struct sway_container *con) {
container_clear_marks(con); container_clear_marks(con);
container_update_marks_textures(con); container_update_marks(con);
}
static void remove_all_marks_iterator(struct sway_container *con, void *data) {
remove_mark(con);
} }
// unmark Remove all marks from all views // unmark Remove all marks from all views
@ -38,8 +41,7 @@ struct cmd_results *cmd_unmark(int argc, char **argv) {
} }
} else if (con && !mark) { } else if (con && !mark) {
// Clear all marks from the given container // Clear all marks from the given container
container_clear_marks(con); remove_mark(con);
container_update_marks_textures(con);
} else if (!con && mark) { } else if (!con && mark) {
// Remove mark from whichever container has it // Remove mark from whichever container has it
container_find_and_unmark(mark); container_find_and_unmark(mark);

View File

@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200809L
#include <ctype.h> #include <ctype.h>
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>

View File

@ -10,7 +10,7 @@ struct cmd_results *cmd_xwayland(int argc, char **argv) {
return error; return error;
} }
#ifdef HAVE_XWAYLAND #ifdef WLR_HAS_XWAYLAND
enum xwayland_mode xwayland; enum xwayland_mode xwayland;
if (strcmp(argv[0], "force") == 0) { if (strcmp(argv[0], "force") == 0) {
xwayland = XWAYLAND_MODE_IMMEDIATE; xwayland = XWAYLAND_MODE_IMMEDIATE;
@ -20,6 +20,8 @@ struct cmd_results *cmd_xwayland(int argc, char **argv) {
xwayland = XWAYLAND_MODE_DISABLED; xwayland = XWAYLAND_MODE_DISABLED;
} }
// config->xwayland is reset to the previous value on reload in
// load_main_config()
if (config->reloading && config->xwayland != xwayland) { if (config->reloading && config->xwayland != xwayland) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"xwayland can only be enabled/disabled at launch"); "xwayland can only be enabled/disabled at launch");

View File

@ -1,3 +1,4 @@
#undef _POSIX_C_SOURCE
#define _XOPEN_SOURCE 700 // for realpath #define _XOPEN_SOURCE 700 // for realpath
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
@ -22,6 +23,7 @@
#include "sway/config.h" #include "sway/config.h"
#include "sway/criteria.h" #include "sway/criteria.h"
#include "sway/desktop/transaction.h" #include "sway/desktop/transaction.h"
#include "sway/server.h"
#include "sway/swaynag.h" #include "sway/swaynag.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/root.h" #include "sway/tree/root.h"
@ -36,19 +38,26 @@
struct sway_config *config = NULL; struct sway_config *config = NULL;
static struct xkb_state *keysym_translation_state_create( static struct xkb_state *keysym_translation_state_create(
struct xkb_rule_names rules) { struct xkb_rule_names rules, uint32_t context_flags) {
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_SECURE_GETENV); struct xkb_context *context = xkb_context_new(context_flags | XKB_CONTEXT_NO_SECURE_GETENV);
struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_names( struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_names(
context, context,
&rules, &rules,
XKB_KEYMAP_COMPILE_NO_FLAGS); XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_context_unref(context); xkb_context_unref(context);
if (xkb_keymap == NULL) {
sway_log(SWAY_ERROR, "Failed to compile keysym translation XKB keymap");
return NULL;
}
return xkb_state_new(xkb_keymap); return xkb_state_new(xkb_keymap);
} }
static void keysym_translation_state_destroy( static void keysym_translation_state_destroy(
struct xkb_state *state) { struct xkb_state *state) {
if (state == NULL) {
return;
}
xkb_keymap_unref(xkb_state_get_keymap(state)); xkb_keymap_unref(xkb_state_get_keymap(state));
xkb_state_unref(state); xkb_state_unref(state);
} }
@ -336,8 +345,14 @@ static void config_defaults(struct sway_config *config) {
// The keysym to keycode translation // The keysym to keycode translation
struct xkb_rule_names rules = {0}; struct xkb_rule_names rules = {0};
config->keysym_translation_state = config->keysym_translation_state = keysym_translation_state_create(rules, 0);
keysym_translation_state_create(rules); if (config->keysym_translation_state == NULL) {
config->keysym_translation_state = keysym_translation_state_create(rules,
XKB_CONTEXT_NO_ENVIRONMENT_NAMES);
}
if (config->keysym_translation_state == NULL) {
goto cleanup;
}
return; return;
cleanup: cleanup:
@ -352,13 +367,7 @@ static char *config_path(const char *prefix, const char *config_folder) {
if (!prefix || !prefix[0] || !config_folder || !config_folder[0]) { if (!prefix || !prefix[0] || !config_folder || !config_folder[0]) {
return NULL; return NULL;
} }
return format_str("%s/%s/config", prefix, config_folder);
const char *filename = "config";
size_t size = 3 + strlen(prefix) + strlen(config_folder) + strlen(filename);
char *path = calloc(size, sizeof(char));
snprintf(path, size, "%s/%s/%s", prefix, config_folder, filename);
return path;
} }
static char *get_config_path(void) { static char *get_config_path(void) {
@ -368,10 +377,7 @@ static char *get_config_path(void) {
const char *config_home = getenv("XDG_CONFIG_HOME"); const char *config_home = getenv("XDG_CONFIG_HOME");
if ((config_home == NULL || config_home[0] == '\0') && home != NULL) { if ((config_home == NULL || config_home[0] == '\0') && home != NULL) {
size_t size_fallback = 1 + strlen(home) + strlen("/.config"); config_home_fallback = format_str("%s/.config", home);
config_home_fallback = calloc(size_fallback, sizeof(char));
if (config_home_fallback != NULL)
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
config_home = config_home_fallback; config_home = config_home_fallback;
} }
@ -475,6 +481,11 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
old_config->xwayland ? "enabled" : "disabled"); old_config->xwayland ? "enabled" : "disabled");
config->xwayland = old_config->xwayland; config->xwayland = old_config->xwayland;
// primary_selection can only be enabled/disabled at launch
sway_log(SWAY_DEBUG, "primary_selection will remain %s",
old_config->primary_selection ? "enabled" : "disabled");
config->primary_selection = old_config->primary_selection;
if (!config->validating) { if (!config->validating) {
if (old_config->swaybg_client != NULL) { if (old_config->swaybg_client != NULL) {
wl_client_destroy(old_config->swaybg_client); wl_client_destroy(old_config->swaybg_client);
@ -494,56 +505,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
config->reading = true; config->reading = true;
// Read security configs bool success = load_config(path, config, &config->swaynag_config_errors);
// TODO: Security
bool success = true;
/*
DIR *dir = opendir(SYSCONFDIR "/sway/security.d");
if (!dir) {
sway_log(SWAY_ERROR,
"%s does not exist, sway will have no security configuration"
" and will probably be broken", SYSCONFDIR "/sway/security.d");
} else {
list_t *secconfigs = create_list();
char *base = SYSCONFDIR "/sway/security.d/";
struct dirent *ent = readdir(dir);
struct stat s;
while (ent != NULL) {
char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1);
strcpy(_path, base);
strcat(_path, ent->d_name);
lstat(_path, &s);
if (S_ISREG(s.st_mode) && ent->d_name[0] != '.') {
list_add(secconfigs, _path);
}
else {
free(_path);
}
ent = readdir(dir);
}
closedir(dir);
list_qsort(secconfigs, qstrcmp);
for (int i = 0; i < secconfigs->length; ++i) {
char *_path = secconfigs->items[i];
if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 ||
(((s.st_mode & 0777) != 0644) &&
(s.st_mode & 0777) != 0444)) {
sway_log(SWAY_ERROR,
"Refusing to load %s - it must be owned by root "
"and mode 644 or 444", _path);
success = false;
} else {
success = success && load_config(_path, config);
}
}
list_free_items_and_destroy(secconfigs);
}
*/
success = success && load_config(path, config,
&config->swaynag_config_errors);
if (validating) { if (validating) {
free_config(config); free_config(config);
@ -571,7 +533,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
} }
sway_switch_retrigger_bindings_for_all(); sway_switch_retrigger_bindings_for_all();
reset_outputs(); apply_all_output_configs();
spawn_swaybg(); spawn_swaybg();
config->reloading = false; config->reloading = false;
@ -975,7 +937,7 @@ char *do_var_replacement(char *str) {
int offset = find - str; int offset = find - str;
strncpy(newptr, str, offset); strncpy(newptr, str, offset);
newptr += offset; newptr += offset;
strncpy(newptr, var->value, vvlen); memcpy(newptr, var->value, vvlen);
newptr += vvlen; newptr += vvlen;
strcpy(newptr, find + vnlen); strcpy(newptr, find + vnlen);
free(str); free(str);
@ -1037,8 +999,12 @@ void translate_keysyms(struct input_config *input_config) {
struct xkb_rule_names rules = {0}; struct xkb_rule_names rules = {0};
input_config_fill_rule_names(input_config, &rules); input_config_fill_rule_names(input_config, &rules);
config->keysym_translation_state = config->keysym_translation_state = keysym_translation_state_create(rules, 0);
keysym_translation_state_create(rules); if (config->keysym_translation_state == NULL) {
sway_log(SWAY_ERROR, "Failed to create keysym translation XKB state "
"for device '%s'", input_config->identifier);
return;
}
for (int i = 0; i < config->modes->length; ++i) { for (int i = 0; i < config->modes->length; ++i) {
struct sway_mode *mode = config->modes->items[i]; struct sway_mode *mode = config->modes->items[i];

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