Commit graph

5342 commits

Author SHA1 Message Date
Dominique Martinet ab18740529 output commands: move !argc checks after argc gets decremented
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 557a14a6fe config_commands_command: make alloc failure check more permanent
policy is accessed again later

Found through static analysis
2018-07-02 08:03:41 +09:00
Dominique Martinet 5690bea227 input_config: free new_input_config on error
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet ebe69583c7 ipc-server: fix more use-after-frees on ipc_send_reply error
Since ipc_send_reply frees the client on error, we need to check the
return value properly as we access client later on

Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 0ab04b7434 ipc-server: minor code cleanup
No logic change here, this one is mostly to please static analyzer:
 - client->fd can never be -1 (and if it could, close() a few lines below
would have needed the same check)
 - we never send permission denied error (dead code)
2018-07-02 08:03:41 +09:00
Dominique Martinet 546ddbcd5b ipc-server: fix double-free on send error in ipc_send_event
ipc_send_reply already does client disconnect on error, so we shouldn't
do it again.
We also need to process current index again as disconnect removes client
from the list we currently are processing (this is an indexed "list")

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

Found through static analysis
2018-07-02 08:03:41 +09:00
Dominique Martinet 1b7f554474 log_kernel: s/fclose/pclose/ (for popen'd FILE)
With recent glibc the functions are strictly identical, but this might
not be true for all libc implementations

Found through static analysis.
2018-07-02 08:03:41 +09:00
emersion 649e084f41
Merge pull request #2190 from emersion/screencopy
Init screencopy manager
2018-07-01 23:05:28 +01:00
emersion 7abb4d63e2
Init screencopy manager 2018-07-01 22:55:25 +01:00
Drew DeVault 7a76ebee88
Merge pull request #2188 from martinetd/exec-always-cmd
exec_always: fix leaks
2018-07-01 10:14:57 -07:00
Dominique Martinet ce17788533 exec_always: fix leaks
- child would leak in the workspace_record_pid path
 - removing malloc lets us get rid of That Comment nobody seems
to remember what it was about
 - we would leak pipe fds on first fork failling
 - we didn't return an error if second fork failed
 - the final executed process still had both pipe fds
(would show up in /proc/23560/fd in launched programs)
 - we would write twice to the pipe if execl failed for some reason
(e.g. if /bin/sh doesn't exist?!)
2018-07-02 00:09:56 +09:00
Drew DeVault acd79e1505 Implement pid->workspace tracking
When you spawn a process with the exec command, sway now notes the
workspace you had focused and the pid of the child process, then assigns
that workspace to the child when its window appears.

Some of this is carried over from sway 0.15, but with some major
refactoring and centralization of state.
2018-07-01 09:58:18 -04:00
Ryan Dwyer 62a7b762ac
Merge pull request #2180 from martinetd/xdg_fullscreen
xdg_shell: listen to fullscreen request on map
2018-06-30 23:51:21 +10:00
Dominique Martinet bc1e99305a xdg_shell: listen to fullscreen request on map
That event comes from the toplevel and not the surface, so would cause
a use-after-free on destroy if the toplevel got destroyed first:

==5454==ERROR: AddressSanitizer: heap-use-after-free on address 0x6110001ed198 at pc 0x000000472d10 bp 0x7ffc19070a80 sp 0x7ffc19070a70
WRITE of size 8 at 0x6110001ed198 thread T0
    #0 0x472d0f in wl_list_remove ../common/list.c:157
    #1 0x42e159 in handle_destroy ../sway/desktop/xdg_shell_v6.c:243
    #2 0x7fa9e5b28ce8 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7fa9e5afd6b1 in destroy_xdg_surface_v6 ../types/xdg_shell_v6/wlr_xdg_surface_v6.c:101
    #4 0x7fa9e5d98025 in destroy_resource src/wayland-server.c:688
    #5 0x7fa9e5d98091 in wl_resource_destroy src/wayland-server.c:705
    #6 0x7fa9e27f103d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)
    #7 0x7fa9e27f09fe in ffi_call (/lib64/libffi.so.6+0x59fe)
    #8 0x7fa9e5d9bf2c  (/lib64/libwayland-server.so.0+0xbf2c)
    #9 0x7fa9e5d983de in wl_client_connection_data src/wayland-server.c:420
    #10 0x7fa9e5d99f01 in wl_event_loop_dispatch src/event-loop.c:641
    #11 0x7fa9e5d98601 in wl_display_run src/wayland-server.c:1260
    #12 0x40a2f4 in main ../sway/main.c:433
    #13 0x7fa9e527318a in __libc_start_main ../csu/libc-start.c:308
    #14 0x40b749 in _start (/opt/wayland/bin/sway+0x40b749)

0x6110001ed198 is located 152 bytes inside of 240-byte region [0x6110001ed100,0x6110001ed1f0)
freed by thread T0 here:
    #0 0x7fa9e7c89880 in __interceptor_free (/lib64/libasan.so.5+0xee880)
    #1 0x7fa9e5affce9 in destroy_xdg_toplevel_v6 ../types/xdg_shell_v6/wlr_xdg_toplevel_v6.c:23
    #2 0x7fa9e5d98025 in destroy_resource src/wayland-server.c:688

previously allocated by thread T0 here:
    #0 0x7fa9e7c89e50 in calloc (/lib64/libasan.so.5+0xeee50)
    #1 0x7fa9e5b00eea in create_xdg_toplevel_v6 ../types/xdg_shell_v6/wlr_xdg_toplevel_v6.c:427
    #2 0x7fa9e27f103d in ffi_call_unix64 (/lib64/libffi.so.6+0x603d)

The toplevel only notifies the compositor on destroy if it was mapped,
so only listen to events at map time.
2018-06-30 22:42:24 +09:00
Drew DeVault 792eb6ad40
Merge pull request #2174 from martinetd/view-from-surface
sway views: add helpers to get view and layer from wlr_surface
2018-06-30 06:41:33 -07:00
Dominique Martinet 9ea4cc13a0 sway views: add helpers to get view and layer from wlr_surface 2018-06-30 22:31:14 +09:00
Drew DeVault d8c61c9763
Merge pull request #2072 from RyanDwyer/atomic
Atomic layout updates
2018-06-30 06:27:39 -07:00
Ryan Dwyer e396af853b Merge remote-tracking branch 'upstream/master' into atomic 2018-06-30 22:46:25 +10:00
emersion 9ba72433b6
Merge pull request #2179 from atomnuker/master
Fix crash with stacking layout after f42bf0ad4
2018-06-30 13:23:27 +01:00
Rostislav Pehlivanov 0cc24dd9c8 Fix crash with stacking layout after f42bf0ad4
The "simple" rendering function only applies to tiled views.
2018-06-30 12:45:49 +01:00
emersion 09fdcfe7df
Merge pull request #2175 from apreiml/fix-swaymsg-error-output
fix swaymsg: errors are displayed again
2018-06-30 12:28:17 +01:00
emersion d17ca5d15b
Merge pull request #2171 from atomnuker/master
Revert "Don't unmaximize floating views"
2018-06-30 12:28:02 +01:00
Ryan Dwyer fc6fde7d90 Fix compile error 2018-06-30 21:07:54 +10:00
Rostislav Pehlivanov f42bf0ad4a container_at_view: don't offset the view by the window geometry
Fixes floating window input offsets. As discussed on IRC with emersion,
this shouldn't have been done in the first place.
2018-06-30 11:11:06 +01:00
Rostislav Pehlivanov e0d0e8f840 Revert "Don't unmaximize floating views"
This reverts commit 97672295ed.
2018-06-30 11:10:47 +01:00
Ryan Dwyer 53c4467573
Merge pull request #2173 from emersion/fix-floating-no-frame-event
Fix floating views not receiving frame events
2018-06-30 18:57:04 +10:00
emersion 4de28bba68
Fix floating views not receiving frame events
That happened when they were in tabbed or stacked containers.

Fixes #2161
2018-06-30 09:49:51 +01:00
Armin Preiml 354648cc07 refactor success_object 2018-06-30 10:38:16 +02:00
Armin Preiml 659871de1e fix swaymsg: errors are displayed again
Command errors didn't get displayed, because the success function didn't
accept objects
2018-06-30 10:29:32 +02:00
Ryan Dwyer 96c8c02483 Fix flash of background when xwayland views are mapped
A flash of background was happening for two reasons:

1) We were using the xsurface's dimensions to check if the surface is
ready, but these are pending dimensions.
2) In my particular setup, the default geometry of the xsurface does not
intersect any output, which prevented it from receiving a frame done
event. This made the transaction time out and the client would only
redraw once it's been rendered.
2018-06-30 14:30:14 +10:00
Ryan Dwyer 3a6ed5110c Render saved buffers with the surface's dimensions 2018-06-29 21:13:22 +10:00
Ryan Dwyer a2fbb20a61 Merge remote-tracking branch 'upstream/master' into atomic 2018-06-29 20:04:24 +10:00
Ryan Dwyer 3c81a900b7 Add comment about usage to arrange_windows declaration 2018-06-29 19:52:31 +10:00
Ryan Dwyer d7169ee7ff Replace list_empty with a simple alternative 2018-06-29 19:44:54 +10:00
Ryan Dwyer e8fb6b3325 Fix crash when moving last child of a container to workspace or output
We were arranging a parent which may have been deleted by the reaper,
which meant the `current` children list of the surviving parent had a
dangling pointer.

Instead, we now reap the workspace.
2018-06-29 19:36:22 +10:00
Drew DeVault d3ea07f828
Merge pull request #2172 from apreiml/fix-keybinding-modifier-handling
fix handling key modifiers if not pressed at first
2018-06-28 16:16:31 -07:00
Armin Preiml 1eede432fc fix handling key modifiers if not pressed at first
fixes #2169
2018-06-28 15:23:26 +02:00
emersion 92e81df470
Merge pull request #2170 from apreiml/master
fix accidently removing borders on XCB_CONFIGURE_REQUEST
2018-06-27 17:11:35 +01: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
emersion 1579fc1d91
Merge pull request #2168 from BlueGone/input-cmd-arg-nb
Check if command input has at least 2 arguments
2018-06-27 15:13:14 +01: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
Drew DeVault 152ccd7fb1
Merge pull request #2145 from emersion/xwayland-wants-float
Automatically float xwayland windows
2018-06-26 20:31:32 -07:00
Ryan Dwyer bf38081382
Merge branch 'master' into xwayland-wants-float 2018-06-27 13:21:00 +10:00
Drew DeVault f0f50c31d5
Merge pull request #2162 from martinetd/float_xdg_shell
xdg_shell: make view floating if a parent has been set
2018-06-26 07:26:07 -07:00