Commit graph

2258 commits

Author SHA1 Message Date
Armin Preiml 1eede432fc fix handling key modifiers if not pressed at first
fixes #2169
2018-06-28 15:23:26 +02:00
Armin Preiml c4b900c1e0 fix accidently removing borders on XCB_CONFIGURE_REQUEST
The view was configured with the container coordinates.
Although they were right on the first configure, they
changed after a XCB_CONFIGURE_REQUEST, when the
border was already drawn.
2018-06-27 17:56:53 +02:00
Thomas Plaçais 9a3c6d2dbe Check if command input has at least 2 arguments 2018-06-27 15:58:53 +02:00
Ryan Dwyer 9652529cc1 Allow views to skip configures
To do this properly, the transaction queue will only be processed if it
can be completely processed.
2018-06-27 19:07:48 +10:00
Ryan Dwyer e6829c5991 Move unsetting of view->surface into view_unmap 2018-06-27 17:54:57 +10:00
Ryan Dwyer 8773ed3970 Fix memleak in container_get_box
Rather than allocate a structure and expect callers to free it, take a
pointer to an existing struct as an argument.

This function is no longer called anywhere though.
2018-06-27 17:47:41 +10:00
Ryan Dwyer be86d3aba6 Remove transaction_add_damage
Instead, damage each container when applying the transaction.
2018-06-27 17:46:03 +10:00
Ryan Dwyer 61c1187685 Fix nitpicks 2018-06-27 17:23:44 +10:00
Ryan Dwyer bf38081382
Merge branch 'master' into xwayland-wants-float 2018-06-27 13:21:00 +10:00
emersion ecd748d240
Merge branch 'master' into float_xdg_shell 2018-06-26 15:13:03 +01:00
ael-code a4578815f1
cleanup output-background subcommand handling
- fixes a double-free error when access() failed.

- refactor code to make memory managment (alloc/free) more straightforward
   - do not bring the temporary wordexp_t struct around
   - do not postpone errors handling
2018-06-26 15:40:32 +02:00
ael-code 4550cb2b3e
fix memleak on background cmd error
- src must be free after join_args()
- wordfree must bee used after wordexp
2018-06-26 15:37:39 +02:00
Dominique Martinet 6856866a61 layer_shell: order destroying before sway_output
Both sway_output and sway_layer_shell listen to wlr's output destroy event,
but sway_layer_shell needs to access into sway_output's data strucure and needs
to be destroyed first.

Resolve this by making sway_layer_shell listen to a new event that happens at
start of sway_output's destroy handler
2018-06-26 21:20:56 +09:00
Dominique Martinet 08800c8ee2 layer_shell: cleanup output link on output destroy
Fixes this kind of use-after-free:
==1795==ERROR: AddressSanitizer: heap-use-after-free on address 0x612000191ef0 at pc 0x00000048c388 bp 0x7ffe308f0410 sp 0x7ffe308f0400
WRITE of size 8 at 0x612000191ef0 thread T0
    #0 0x48c387 in wl_list_remove ../common/list.c:157
    #1 0x42196b in handle_destroy ../sway/desktop/layer_shell.c:275
    #2 0x7f55cc2549fa in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7f55cc22cf68 in layer_surface_destroy ../types/wlr_layer_shell.c:182
    #4 0x7f55cc22d084 in layer_surface_resource_destroy ../types/wlr_layer_shell.c:196
    #5 0x7f55cc4ca025 in destroy_resource src/wayland-server.c:688
    #6 0x7f55cc4ca091 in wl_resource_destroy src/wayland-server.c:705
    #7 0x7f55cc22c3a2 in resource_handle_destroy ../types/wlr_layer_shell.c:18
    #8 0x7f55c8ef103d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)
    #9 0x7f55c8ef09fe in ffi_call (/lib64/libffi.so.6+0x59fe)
    #10 0x7f55cc4cdf2c  (/lib64/libwayland-server.so.0+0xbf2c)
    #11 0x7f55cc4ca3de in wl_client_connection_data src/wayland-server.c:420
    #12 0x7f55cc4cbf01 in wl_event_loop_dispatch src/event-loop.c:641
    #13 0x7f55cc4ca601 in wl_display_run src/wayland-server.c:1260
    #14 0x40bb1e in server_run ../sway/server.c:141
    #15 0x40ab2f in main ../sway/main.c:432
    #16 0x7f55cb97318a in __libc_start_main ../csu/libc-start.c:308
    #17 0x408d29 in _start (/opt/wayland/bin/sway+0x408d29)

0x612000191ef0 is located 48 bytes inside of 312-byte region [0x612000191ec0,0x612000191ff8)
freed by thread T0 here:
    #0 0x7f55ce3bb880 in __interceptor_free (/lib64/libasan.so.5+0xee880)
    #1 0x42f1db in handle_destroy ../sway/desktop/output.c:1275
    #2 0x7f55cc2549fa in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7f55cc23b4c2 in wlr_output_destroy ../types/wlr_output.c:284
    #4 0x7f55cc1ddc20 in xdg_toplevel_handle_close ../backend/wayland/output.c:235
    #5 0x7f55c8ef103d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)

previously allocated by thread T0 here:
    #0 0x7f55ce3bbe50 in calloc (/lib64/libasan.so.5+0xeee50)
    #1 0x42f401 in handle_new_output ../sway/desktop/output.c:1308
    #2 0x7f55cc2549fa in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7f55cc1d6cbf in new_output_reemit ../backend/multi/backend.c:113
    #4 0x7f55cc2549fa in wlr_signal_emit_safe ../util/signal.c:29
    #5 0x7f55cc1deac7 in wlr_wl_output_create ../backend/wayland/output.c:327
    #6 0x7f55cc1db353 in backend_start ../backend/wayland/backend.c:55
    #7 0x7f55cc1bad55 in wlr_backend_start ../backend/backend.c:35
    #8 0x7f55cc1d67a0 in multi_backend_start ../backend/multi/backend.c:24
    #9 0x7f55cc1bad55 in wlr_backend_start ../backend/backend.c:35
    #10 0x40ba8a in server_run ../sway/server.c:136
    #11 0x40ab2f in main ../sway/main.c:432
    #12 0x7f55cb97318a in __libc_start_main ../csu/libc-start.c:308
2018-06-26 21:20:56 +09:00
Ryan Dwyer a7b3f29292 Remove incorrect assertion and supporting code
Children can exist when destroying a container, such as when destroying
the last output. Sway is not terminating in that case.
2018-06-26 20:18:57 +10:00
Ryan Dwyer 93696b78ec Fix crash when closing output window from outer session
Emitting the close event needs to happen before
container_output_destroy, because container_output_destroy sets the
sway_output to NULL and sway_output is used in IPC.
2018-06-26 20:14:58 +10:00
Ryan Dwyer 834805f5e2 Fix crash when disconnecting output
We were freeing the sway_output immediately upon disconnect which left
a dangling pointer in the output's container. It then tried to use the
pointer when the container is freed.

We don't need to store the sway_output in an output's container which is
destroying, so the fix is to set the pointer to NULL and remove the use
in container_free.

Also added an arrange when the output is disconnected for good measure.
2018-06-26 19:40:42 +10:00
Ryan Dwyer 0085f64ac0 Remove timer when transaction destroys 2018-06-26 18:51:37 +10:00
Ryan Dwyer e8001e6fbe Damage output when views toggle fullscreen
Also add workspace to the transaction when a view maps in fullscreen
mode.
2018-06-26 14:24:15 +10:00
Ryan Dwyer 50190bc760 Rename view's free callback to destroy 2018-06-26 13:18:33 +10:00
Ryan Dwyer 7a922c65aa Damage output when a fullscreen view unmaps
Also moved the arranging into view_unmap to avoid excessive code
duplication.
2018-06-26 13:15:45 +10:00
Dominique Martinet c9be014557 xdg_shell: make view floating if a parent has been set
Prompts e.g. authentication request from firefox-wayland ought to be
floating.

This is a bit coarse but just fixed size is not enough, here is what
firefox does:
[1285461.363]  -> xdg_wm_base@18.get_xdg_surface(new id xdg_surface@68, wl_surface@71)
[1285461.508]  -> xdg_surface@68.get_toplevel(new id xdg_toplevel@67)
[1285461.571]  -> xdg_toplevel@67.set_parent(xdg_toplevel@37)
[1285461.630]  -> xdg_toplevel@67.set_title("Authentication Required")
[1285461.736]  -> xdg_toplevel@67.set_app_id("firefox")
...
[1285476.549] xdg_toplevel@67.configure(0, 0, array)
...
[1285502.080]  -> xdg_toplevel@67.set_min_size(299, 187)
[1285502.140]  -> xdg_toplevel@67.set_max_size(1920, 32767)

This can also be observed with e.g. the open window of gedit
(gedit->open->other documents)
2018-06-26 12:02:50 +09:00
Ryan Dwyer beacd4d9f9 Rename progress_queue to transaction_progress_queue 2018-06-25 16:50:01 +10:00
Ryan Dwyer 9b15e81cff Fix potential crash when fullscreen view unmaps
It happened when a view is a grandchild or deeper of the workspace, is
fullscreen, and unmaps. The workspace would not be included in the
transaction and its pointer to the fullscreen view was left dangling.
2018-06-25 16:41:31 +10:00
Tony Crisci e9ad10c2d6 dont focus-follow-mouse when keyboard grab 2018-06-24 20:30:43 -04:00
Ryan Dwyer c371ff3de8 Implement per-configure debug timings 2018-06-25 09:25:51 +10:00
Ryan Dwyer 289d696adc Implement transaction timings debug
Launch sway with SWAY_DEBUG=txn_timings to enable it.
2018-06-25 09:09:43 +10:00
emersion eeb38d65cb
xwayland: accept configure requests from floating views 2018-06-24 19:21:02 +01:00
Ryan Dwyer a3976e2659 Fix another crash when moving out of stacks or tabs 2018-06-24 23:07:52 +10:00
Ryan Dwyer 1549fb719a Implement atomic layout updates for xwayland views 2018-06-24 23:01:09 +10:00
Ryan Dwyer b6a238c7b7 Fix crash when running move <direction> in an empty workspace 2018-06-24 16:03:24 +10:00
Ryan Dwyer b864ac0149 Fix crash when unmapping a view with reapable parents
container_destroy was calling container_reap_empty, which calls
container_destroy and so on. Eventually the original container_destroy
would return a NULL pointer to the caller which caused a crash.

This also fixes an arrange on the wrong container when moving views in
and out of stacks.
2018-06-24 15:50:53 +10:00
Ryan Dwyer 33e03cb277 Fix crash related to stacks and tabs 2018-06-24 13:08:47 +10:00
Ryan Dwyer f08a30d6d0 Force transactions to complete in order
This forces transactions to complete in order by using a singly linked
list stored in the sway server.
2018-06-24 12:33:23 +10:00
Ryan Dwyer 32b865e610 Fix crash when deleting last child in a tabbed or stacked container
There was no `current` child because the container was destroyed. This
makes it fall back to looking in the parent's current children list.
2018-06-23 17:47:28 +10:00
Ryan Dwyer b11c9199a6 Merge remote-tracking branch 'upstream/master' into atomic 2018-06-23 16:26:20 +10:00
Ryan Dwyer 38398e2d77 Implement atomic layout updates for tree operations
This implements atomic layout updates for when views map, reparent or
unmap.
2018-06-23 16:24:11 +10:00
Drew DeVault 5222e14555
Merge pull request #2155 from ael-code/fix_output_command_failure
bugfix: avoid access after free
2018-06-22 06:53:17 -07:00
ael-code ad085c1332
bugfix: avoid access after free
if src is NULL due to a previous error we cannot use it in the command
result string.

Moreover if `src` points to `p.we_wordv[0]` we cannot use it after
`wordfree(&p)` in the command result string.

Bonus feature: If there was an error accessing the file, the string
rapresentation of the error is now included in the command result
string.
2018-06-22 15:41:44 +02:00
Drew DeVault e8fbda4d21
Merge pull request #2146 from tobiasblass/prepare_server_before_dropping_privileges
Perform (partial) server initialization before dropping privileges.
2018-06-22 06:41:34 -07:00
Rostislav Pehlivanov aa9f058e3e Init the dmabuf exporting protocol in wlroots
Allows desktop capture via the dmabuf-capture wlroots example client.
2018-06-22 13:45:32 +01:00
Tobias Blass a5c091e302 Perform (partial) server initialization before dropping privileges.
Some operations during backend creation (e.g. becoming DRM master)
require CAP_SYS_ADMIN privileges. At this point, sway has dropped them
already, though. This patch splits the privileged part of server_init
into its own function and calls it before dropping its privileges.
This fixes the bug with minimal security implications.
2018-06-19 00:19:57 +02:00
emersion cda66e9a26
Automatically float xwayland windows 2018-06-18 22:52:10 +01:00
Ryan Dwyer 1c89f32533 Preserve buffers during transactions
* Also fix parts of the rendering where it was rendering the pending
state instead of current.
2018-06-18 20:42:12 +10:00
Ryan Dwyer 645bf446fa Merge remote-tracking branch 'upstream/master' into atomic 2018-06-18 15:58:48 +10:00
emersion 088cae45c8 Update for swaywm/wlroots#1060 2018-06-16 13:32:23 -04:00
frsfnrrg ca061ba8bf Fix keyboard shortcut handling inconsistencies
* Ensure that modifier keys are identified even when the next key does
  not produce a keysym. This requires that modifier change tracking
  be done for each sway_shortcut_state.

* Permit regular and --release shortcuts on the same key combination.
  Distinct bindings are identified for press and release cases; note
  that the release binding needs to be identified for both key press
  and key release events.

* Maintain ascending sort order for the shortcut state list, and keep
  track of the number of pressed key ids, for simpler (and hence
  faster) searching of the list of key bindings.

* Move binding duplicate detection into get_active_binding to avoid
  duplicating error messages.
2018-06-12 20:26:57 -04:00
frsfnrrg b23cd827cf Sort binding key lists
Sort the list comprising the set of keys for the binding in ascending
order. (Keyboard shortcuts depend only on the set of simultaneously
pressed keys, not their order, so this change should have no external
effect.) This simplifies comparisons between bindings.
2018-06-12 11:26:24 -04:00
Ryan Dwyer 9e96cfd310 Merge remote-tracking branch 'upstream/master' into atomic 2018-06-11 11:03:43 +10:00
Drew DeVault 867fb6aedb
Merge pull request #2124 from emersion/drag-icons
Render drag icons
2018-06-09 10:50:34 -07:00
Nate Symer 6a910b9ba5 Implement gaps (PR #2047) 2018-06-09 09:34:56 -04:00
emersion cfd02918c0
Render drag icons 2018-06-09 13:26:03 +01:00
emersion 88cd7616db
Fix compilation errors related to disabled outputs 2018-06-09 11:38:16 +01:00
Ryan Dwyer bb66e6d578 Refactor everything that needs to arrange windows
* The arrange_foo functions are now replaced with arrange_and_commit, or
with manually created transactions and arrange_windows x2.
* The arrange functions are now only called from the highest level
functions rather than from both high level and low level functions.
* Due to the previous point, view_set_fullscreen_raw and
view_set_fullscreen are both merged into one function again.
* Floating and fullscreen are now working with transactions.
2018-06-09 10:11:25 +10:00
Ryan Dwyer f9e6d703d2 Make main properties be the pending state 2018-06-09 10:08:43 +10:00
Ryan Dwyer 59c9488701 WIP: Atomic layout updates ground work 2018-06-09 10:08:43 +10:00
Brian Ashworth e2b2fb0a0e Switch restore workspaces to a nested for-loop 2018-06-08 13:08:00 -04:00
Brian Ashworth 5c9a917df9 Restore workspaces to outputs based on priority 2018-06-08 13:08:00 -04:00
emersion acf71fe805
Merge pull request #2119 from martinetd/gcc-strtruncation
sway/criteria: gcc string truncation warning fix
2018-06-08 14:41:33 +01:00
Dominique Martinet 720313e185 sway/criteria: gcc string truncation warning fix 2018-06-08 22:30:13 +09:00
Dominique Martinet d26a0a1a6e sway exec command: use waitpid instead of wait 2018-06-08 22:28:28 +09:00
Brian Ashworth 212e4ef395 Remove strip quoting and fix strncpy-overlap 2018-06-07 20:37:08 -04:00
emersion 07bee8cffe
Merge pull request #2084 from RedSoxFan/runtime-var-expansion
Runtime variable expansion
2018-06-07 19:29:26 +01:00
Brian Ashworth e072fbc6d9 Switch output storing from list_t to wl_list 2018-06-06 20:11:24 -04:00
Brian Ashworth a0bbe67076 Address emersions comments on output re-enabling 2018-06-06 20:11:24 -04:00
Brian Ashworth a1b5b93d29 Store sway_outputs so that they can be reenabled 2018-06-06 20:11:24 -04:00
Brian Ashworth 82b3b587dd Remove tab/stack check for focusing after a split 2018-06-06 19:38:38 -04:00
Brian Ashworth e7261e2917 Fix focusing after splitting tabs/stacks 2018-06-06 16:41:19 -04:00
Scott Leggett 609c420501 Initialise previous cursor position.
Fix the problem with focus jumping to the container under the cursor
when first starting sway.
2018-06-06 20:45:02 +10:00
Tobias Blass d6d292897f Remove suspicious unconditional return
This return effectively disables the log_kernel function
2018-06-05 23:27:35 +02:00
Brian Ashworth f4870d5432 Fix logic issue in do_var_replacement 2018-06-05 10:08:00 -04:00
Brian Ashworth 067fe9d047 Support runtime var expansion and set at runtime 2018-06-05 10:08:00 -04:00
emersion 0f71547032
Merge pull request #2095 from emersion/fullscreen-damage-only-visible
Only send frame to visible surfaces when fullscreened
2018-06-05 11:18:52 +01:00
emersion 6b9ffbad20
Merge pull request #2103 from RyanDwyer/focus-fixes
Focus fixes
2018-06-05 08:44:53 +01:00
Brian Ashworth 9aaac8b8c8 Fix movement crashes/issues 2018-06-05 01:13:27 -04:00
Ryan Dwyer 1206a60977 Don't restore focus if unmapping surface wasn't focused 2018-06-04 13:31:09 +10:00
Ryan Dwyer bcdb676abb Don't set focus to NULL when clicking a surface which has no container 2018-06-04 11:31:25 +10:00
Ryan Dwyer 9253278328 Restore focus when unmapping layer shell surfaces 2018-06-04 11:31:07 +10:00
Ryan Dwyer 74799937cf Restore focus when unmapping unmanaged xwayland surfaces 2018-06-04 11:30:26 +10:00
emersion 0549fd027b
Merge pull request #2087 from RedSoxFan/output-subcommand
Refactor cmd_output to use config_subcommand
2018-06-03 18:48:00 +01:00
emersion 6d0ad6a1ed
Merge pull request #2099 from RyanDwyer/fix-seat-get-active-child
Fix seat_get_active_child
2018-06-03 18:46:48 +01:00
Brian Ashworth 51fa988be9 Address review comments for output subcommands 2018-06-03 10:29:00 -04:00
Brian Ashworth 5ea4a4d3ee Refactor cmd_output to use config_subcommand 2018-06-03 10:26:06 -04:00
Ryan Dwyer d02e9aa4bc Fix initial workspace orientation on a rotated output 2018-06-03 23:39:09 +10:00
Ryan Dwyer 57e78414fa Fix seat_get_active_child
seat_get_active_child is used for tabbed and stacked containers to get
the active child. The previous implementation used seat_get_focus_inactive
then ascended the tree to the child of the tabbed/stacked container, but
this fails when the workspace itself is stacked or tabbed and the most
recently active child is floating.

The new implementation takes a more simple approach, where it directly
scans the focus stack for the first immediate child which isn't the
floating container.

Fixes #2098.
2018-06-03 22:31:54 +10:00
emersion ebe0b668c9
Merge pull request #2093 from emersion/damage-debug
Add SWAY_DAMAGE_DEBUG
2018-06-03 10:31:19 +01:00
emersion 8e3d19aad2
Merge pull request #2096 from kupospelov/fix-title-update
Fix view title update order
2018-06-03 09:20:57 +01:00
Ryan Dwyer 8289e30308 Fix potential crash when destroying workspace
`_container_destroy` emits a destroy event, and any listener for this
event should have access to the full container, not a half destroyed
one.

`_container_destroy` also destroys the swayc, so we have to grab a
reference to the sway_workspace so we can free it afterwards.

This also fixes a memory leak where the floating container wasn't freed.

Fixes #2092.
2018-06-03 10:28:24 +10:00
Konstantin Pospelov e6baac4297 Fix view title update order
This commit fixes the function call order to make sure that the title
texture is updated using the relevant global font size.
2018-06-03 00:32:18 +03:00
emersion 55b855d867
Add SWAY_DAMAGE_DEBUG
Setting it to "rerender" will always re-render everything
regardless of the damaged region. Setting it to "highlight" will
clear the screen and render only damaged regions.
2018-06-02 21:57:34 +01:00
emersion 34bdf25bb5
Only send frame to visible surfaces when fullscreened 2018-06-02 20:56:33 +01:00
emersion 51eee3aecc
Schedule a frame even if damage is empty 2018-06-02 20:42:26 +01:00
Dominique Martinet 71ab13f1eb sway/config: fix use-after-free for end of block
Introduced in 7c810dc344
2018-06-03 00:31:51 +09:00
Drew DeVault df204b65d8
Merge pull request #2089 from emersion/send-frame-done-visible
Only send frame done to visible views
2018-06-02 08:13:01 -07:00
emersion 65845be802
Only send frame done to visible views
Also don't accumulate empty damage
2018-06-02 15:19:03 +01:00
Brian Ashworth 8bfa2def88 Address first round of review for generic blocks 2018-06-02 08:07:44 -04:00
Brian Ashworth 51bb9d8573 Support braces on next line for config blocks 2018-06-02 08:07:44 -04:00
Brian Ashworth 7c810dc344 Make command block implementation generic 2018-06-02 08:07:44 -04:00
emersion 2d480e754e
Merge pull request #2080 from frsfnrrg/keyboard-remodeling
Reduce work duplication in keyboard and binding code
2018-06-02 09:18:07 +01:00
Ryan Dwyer 3f1cfd547e Fix top border when a view is initially floating
Fixes #2085.
2018-06-02 11:45:16 +10:00