Commit graph

2490 commits

Author SHA1 Message Date
Ryan Dwyer a120d4c79f Make focus part of transactions
Rather than maintain copies of the entire focus stack, this PR
transactionises the focus by introducing two new properties to the
container state and using those when rendering.

* `bool focused` means this container has actual focus. Only one
container should have this equalling true in its current state.
* `struct sway_container *focus_inactive_child` points to the immediate
child that was most recently focused (eg. for tabbed and stacked
containers).
2018-07-15 22:08:26 +10:00
Drew DeVault 53e3f35ba3
Merge pull request #2272 from RyanDwyer/simplify-transactions
Simplify transactions by using a dirty flag on containers
2018-07-15 05:01:25 -07:00
Drew DeVault 806c06fdfb
Merge pull request #2266 from emersion/remove-orbital-screenshooter
Remove orbital screenshooter
2018-07-15 05:00:38 -07:00
Drew DeVault b1afcc69fa Add extended debugging flags
We currently have several ways of setting debug flags, including command
line arguments, environment variables, and compile-time macros. This
replaces the lot with command line flags.
2018-07-14 20:44:32 -04:00
Ryan Dwyer 6b2dc7e63b Set signature to void 2018-07-15 10:41:10 +10:00
Ryan Dwyer 2032f85d94 Simplify transactions by utilising a dirty flag on containers
This PR changes the way we handle transactions to a more simple method.
The new method is to mark containers as dirty from low level code
(eg. arranging, or container_destroy, and eventually seat_set_focus),
then call transaction_commit_dirty which picks up those containers and
runs them through a transaction. The old methods of using transactions
(arrange_and_commit, or creating one manually) are now no longer
possible.

The highest-level code (execute_command and view implementation
handlers) will call transaction_commit_dirty, so most other code just
needs to set containers as dirty. This is done by arranging, but can
also be done by calling container_set_dirty.
2018-07-14 23:14:55 +10:00
Brian Ashworth 13c6627ddb Implement tap_button_map for input devices 2018-07-14 01:01:47 -04:00
Ryan Dwyer 0584ecec0a Force min/max size when resizing floating containers 2018-07-14 10:00:39 +10:00
Ryan Dwyer 5940682f40 Implement resize grow|shrink <direction> <amount> or <amount> 2018-07-14 10:00:39 +10:00
Ryan Dwyer 558ca9fc28 Implement resize command for floating views
Implements the following for floating views:

* resize set <width> <height>
* resize <grow|shrink> <width|height|up|down|left|right> <amount>
2018-07-14 10:00:39 +10:00
emersion efda33b285 Simplify popup_unconstrain
Just use the parent output.
2018-07-13 21:17:31 +01:00
emersion 82c978d34b Remove orbital screenshooter 2018-07-13 19:29:44 +01:00
emersion d88f1d2196 Fix output_has_opaque_lockscreen 2018-07-13 12:26:20 +01:00
Drew DeVault bcdf04d79c
Merge pull request #2252 from rkubosz/scroll-button-option
feature: scroll button option for input devices
2018-07-13 04:07:11 -07:00
Robert Kubosz f8bc928b2d
add error handling for scroll button out of range
user will be informed if the scroll button indentifier values causes
underflow or overflow.
2018-07-13 11:39:39 +02:00
Ryan Dwyer 53133fdefb
Merge branch 'master' into xwayland-floating-borders 2018-07-13 08:17:45 +10:00
Robert Kubosz 89db5b5716
expanded error detection for scroll button option
Now the scroll_button will not accept:
  - letters on string beginning;
  - negative numbers.

What is tolerated:
  - letters after number;
  - rational numbers: the fraction after dot will be omitted.
2018-07-12 23:50:34 +02:00
Drew DeVault da8149c066
Merge pull request #2253 from Hello71/issue2249
config.c: fix current_config uninit warning (#2249)
2018-07-12 12:49:11 -07:00
emersion a96f1c22fe Add xdg-positioner support 2018-07-12 20:31:55 +01:00
emersion 9b16227ec3 Don't disable borders for xwayland floating views 2018-07-12 20:01:33 +01:00
Alex Xu fbecfc2d35 config.c: fix current_config uninit warning (#2249) 2018-07-12 13:00:57 -04:00
Robert Kubosz 094edcbea2
rm constraint for max value of button identifier
updated error message to be more adequate for current contraint
2018-07-12 15:50:42 +02:00
Robert Kubosz 20d6c7c2e4
add paragraph to sway-input man page
The added paragraph describes how to get button identifier and set it in
config.
2018-07-12 15:35:14 +02:00
Robert Kubosz 08edaf4e76
increase maximum value of button identifier
and also cleanup spaces
2018-07-12 12:08:53 +02:00
Ryan Dwyer ee0e1b170e Fix crash in seat code
Container will be NULL if launching swaylock.
2018-07-12 14:43:08 +10:00
emersion 60fdb71a1f Updates for swaywm/wlroots#1116 2018-07-11 18:37:17 -04:00
Drew DeVault 2bc18d8cf7
Merge pull request #2248 from Dudemanguy911/fix_crash_on_floating_windows
fix crash on floating windows
2018-07-11 15:26:47 -07:00
Robert Kubosz 41b80c28df
add scroll button option
This commit introduces a scroll_button option, which is intended to be
used with scroll_method. Now user can edit his sway config and add an
scroll_button option to device section.
2018-07-11 22:03:06 +02:00
dudemanguy 600c126150 fix crash on floating windows 2018-07-11 12:24:06 -05:00
Ryan Dwyer f2d1cf3ceb Implement floating_minimum_size and floating_maximum_size 2018-07-11 22:16:48 +10:00
emersion 73084c5fa6
Merge pull request #2243 from RyanDwyer/use-fullscreen-saved-buffer
Use saved buffer when fullscreen view is in a transaction
2018-07-11 13:04:06 +01:00
Ryan Dwyer 3b50a2a3af Use saved buffer when fullscreen view is in a transaction
Fixes #2237.
2018-07-11 20:33:36 +10:00
Ryan Dwyer 15dc5286e2 Move floating windows to front when focused 2018-07-11 19:50:02 +10:00
russ morris 6ae1004cd1 removed unnecessary parens 2018-07-10 20:57:05 -07:00
russ morris c06266e12d fix line lengths 2018-07-10 20:34:51 -07:00
russ morris b9d8ecc548 tabs instead of spaces 2018-07-10 20:24:57 -07:00
russ morris 89c25dd149 fix tabbed titlebar widths 2018-07-10 17:59:00 -07:00
Ian Fan 23c1c26c3f Add get_config message type to ipc 2018-07-10 12:37:37 +01:00
Ian Fan 5fd36164a0 Add get_binding_modes message type to ipc 2018-07-10 12:03:46 +01:00
Ryan Dwyer 56ad148403
Merge branch 'master' into fix-stacked-layout 2018-07-10 20:41:02 +10:00
Drew DeVault 6fd9a2bfd6
Merge branch 'master' into focus-mode-toggle 2018-07-09 16:28:37 -07:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Konstantin Pospelov 9dd54f934e Fix titlebar rendering for nested stacked containers 2018-07-10 00:33:13 +03:00
emersion b755639ca8
Document focus floating|tiling 2018-07-09 22:22:23 +01:00
emersion 48c98b676f
Implement focus mode_toggle 2018-07-09 22:22:17 +01:00
emersion ebcdce457a
Merge pull request #2223 from RyanDwyer/floating-move
Implement some floating move commands
2018-07-09 19:04:45 +01:00
Ryan Dwyer b0fc7e9850 Remove duplicate function declaration and add assertion 2018-07-09 23:41:00 +10:00
Ryan Dwyer ab8a86369c Implement some floating move commands
This implements the following for floating containers:

* move <direction> <amount>
* move [absolute] position <x> <y>
* move [absolute] position mouse
2018-07-09 23:38:29 +10:00
vilhalmer 4e7ef1dd39
No need to walk to workspace, recursive will 2018-07-09 08:26:39 -04:00
vilhalmer 47c20f8ea4
Regroup signal 2018-07-09 08:25:32 -04:00
vilhalmer ce626a0708
Replace empty workspace with moved workspace 2018-07-08 22:55:50 -04:00
vilhalmer 621d2666b1
Destroy empty workspace when destroying its output 2018-07-08 21:55:24 -04:00
emersion f9625d1d56
Split renderer 2018-07-07 10:30:52 +01:00
Ryan Dwyer 0046eed969 Fix titles when container titles contain UTF-8 characters
The title and marks textures would have their height set from the
config's computed max font height, but the textures were not regenerated
when the config's max font height changed which made a gap appear.
Rather than making it regenerate the title textures every time the
config font height was changed, I've changed it to just make the
textures the height of the title itself and fill any gap when rendering.

Also, the title_width and marks_width variables have been renamed to
make it more obvious that they are in output-buffer-local coordinates.

Fixes #1936.
2018-07-07 15:49:51 +10:00
emersion 9a9d9116be
Make view_update_* update live props as well 2018-07-06 19:33:10 +01:00
emersion 47d56306c3
Fix xwayland floating views unclickable
Some xwayland views are first configured with a 1x1 size, and then
resized. Since the view size isn't updated, they are unclickable.

Fixes #2195
2018-07-06 19:31:44 +01:00
Drew DeVault 817e847749
Merge pull request #2206 from martinetd/leaks
Fix a bunch of leaks
2018-07-06 08:43:33 -07:00
emersion b3c55dd909
Merge branch 'master' into leaks 2018-07-06 16:22:13 +01:00
Ryan Dwyer 464d4d5889 Translate surface by its geo when doing opaque box check 2018-07-07 01:18:54 +10:00
Ryan Dwyer 9480781229 Don't clear when using opaque lockscreen 2018-07-07 00:21:39 +10:00
Ryan Dwyer 3b842f4eed Detect opaque lockscreen when using a solid color 2018-07-07 00:17:08 +10:00
Ryan Dwyer f1fadef923 Use pixman_region32_contains_rectangle 2018-07-07 00:03:49 +10:00
Ryan Dwyer 839c3a5500 Use opaque region to determine if frame done should be sent 2018-07-07 00:03:49 +10:00
Ryan Dwyer 58befcf2cd Don't send frame done to surfaces behind lockscreen
Also, when rendering, don't descend into the tree if the lockscreen is
active. Just render the lockscreen's surfaces.
2018-07-07 00:03:49 +10:00
Drew DeVault 3d2595b102
Merge branch 'master' into remove-input-fix 2018-07-06 06:28:01 -07:00
Ian Fan f63b209d51 Attach destroy handler earlier
This prevents it from being bypassed when the device has no seat configuration
2018-07-06 14:13:45 +01:00
Drew DeVault a06d45a14d
Merge pull request #2217 from RedSoxFan/fix-663
Implement mode --pango_markup
2018-07-06 04:57:46 -07:00
Brian Ashworth c833ae64bc Fix pointer button events for layer surfaces 2018-07-05 23:01:35 -04:00
Brian Ashworth 78c08fb0a2 Implement mode --pango_markup 2018-07-05 18:12:14 -04:00
emersion 84109431f7
Merge pull request #2185 from swaywm/update-wlroots-1076
Updates per wlroots#1076
2018-07-05 22:23:15 +01:00
Thomas Plaçais ab5c8c31a0 Escape underscore in sway-input(5) man page to avoid invalid colors 2018-07-05 14:31:52 +02:00
Dominique Martinet 7ef08ffbe6 pango/cairo: set default font map to NULL to free it 2018-07-05 13:11:06 +09:00
Dominique Martinet fe72e3b349 cmd_results_to_json: return copied string and properly free the json
The only user of this function would copy the string right away
to get rid of the const flag anyway, and freeing a const string
afterwards might work but is not meant to be done according to the
json-c API.
2018-07-05 13:11:02 +09:00
emersion 51b215ad5c
Use wlr_surface.buffer_damage 2018-07-05 00:26:39 +01:00
Drew DeVault d43500831a
Updates per wlroots#1076 2018-07-05 00:26:35 +01:00
Dominique Martinet 9314c45c41 workspace_next_name: free targets later than these already found in order 2018-07-05 08:13:10 +09:00
Dominique Martinet 785ed4383b view_map: free criterias as the list it is 2018-07-05 08:13:10 +09:00
Dominique Martinet ffbe91c245 container_free: free formatted title 2018-07-05 08:13:10 +09:00
Dominique Martinet ffe9de6e24 ipc-server: free clients at destroy 2018-07-05 08:13:10 +09:00
Dominique Martinet 9f5d539657 config: add a couple of forgotten frees 2018-07-05 08:13:10 +09:00
Dominique Martinet 8a771785ad keyboard: free xkb keymap on destroy 2018-07-05 08:13:10 +09:00
Ryan Dwyer fc826b921f Call view_set_tiled for mapping non-floating views
Fixes #2209.
2018-07-05 09:04:15 +10:00
Drew DeVault eed0b5614f
Merge pull request #2205 from RyanDwyer/fix-border-weirdness
Fix border weirdness
2018-07-04 06:45:12 -07:00
Ryan Dwyer 50b401677b Fix use after free in transaction code
If we set an instruction as ready twice, it decreases the transaction's
num_waiting a second time and applies the transaction earlier than it
should. This no doubt has undesired effects, probably resulting in a use
after free.

Hopefully fixes the first part of #2207.
2018-07-04 22:58:17 +10:00
Ryan Dwyer 4cb6c368a7 Fix boolean 2018-07-04 20:33:38 +10:00
Ryan Dwyer f156a25e64 Only call view_set_tiled when switching floating mode
Otherwise it repeatedly sets the view's border to the config's default.
2018-07-04 20:10:47 +10:00
Dominique Martinet b0918b1058 ipc-server: add display destroy listener and remove ipc_terminate
wl_event_source_remove() is illegal after display has been destroyed,
so just destroy everything when we still can.

==20392==ERROR: AddressSanitizer: heap-use-after-free on address 0x607000001240 at pc 0x00000048e86e bp 0x7ffe4b557e00 sp 0x7ffe4b557df0
READ of size 8 at 0x607000001240 thread T0
    #0 0x48e86d in wl_list_insert ../common/list.c:149
    #1 0x7fdf673d4d7d in wl_event_source_remove src/event-loop.c:487
    #2 0x41b742 in ipc_terminate ../sway/ipc-server.c:94
    #3 0x40b1ad in main ../sway/main.c:440
    #4 0x7fdf6664c18a in __libc_start_main ../csu/libc-start.c:308
    #5 0x409359 in _start (/opt/wayland/bin/sway+0x409359)

0x607000001240 is located 48 bytes inside of 72-byte region [0x607000001210,0x607000001258)
freed by thread T0 here:
    #0 0x7fdf692c4880 in __interceptor_free (/lib64/libasan.so.5+0xee880)
    #1 0x7fdf673d371a in wl_display_destroy src/wayland-server.c:1097

previously allocated by thread T0 here:
    #0 0x7fdf692c4c48 in malloc (/lib64/libasan.so.5+0xeec48)
    #1 0x7fdf673d4d9e in wl_event_loop_create src/event-loop.c:522
    #2 0x40acb2 in main ../sway/main.c:363
    #3 0x7fdf6664c18a in __libc_start_main ../csu/libc-start.c:308
2018-07-04 18:47:11 +09:00
emersion 4afa18a0c0
Merge pull request #2202 from RyanDwyer/fix-focus-damage
Fix focus related damage
2018-07-04 09:23:07 +01:00
Ryan Dwyer 0bd41a0dae Fix focus related damage
When you have an unfocused container (so one view is focused_inactive),
and you focus any other view in that container, the view with
focused_inactive was not damaged. This is because we damaged the
previous focus and new focus, but needed to damage the parent of the new
focus.
2018-07-04 15:38:08 +10:00
Dominique Martinet c092f1fe6a startup: move setenv WAYLAND_DISPLAY before config execs
We would previously run all config commands without the environment,
which would appear to work as our socket name is the default one, but
wayland clients would start up in the wrong sway session.

(This explains why 'sometimes' my swayidle processes wouldn't die with
sway, as they weren't listening to the correct socket)
2018-07-04 13:52:26 +09:00
emersion 8cc26130a6
Merge pull request #2194 from RyanDwyer/fix-incorrect-render
Don't return pending children in seat_get_active_current_child
2018-07-02 13:29:25 +01:00
Ryan Dwyer 1e4807efa0 Don't return pending children in seat_get_active_current_child
Fixes #2192.

seat_get_active_current_child is intended to return a child of the given
container which has finished its mapping transaction and is able to be
rendered on screen. The previous implementation was capable of returning
a pending child, which caused a child of a tabbed or stacked view to be
rendered prematurely while it was mapping.
2018-07-02 22:16:20 +10:00
Ryan Dwyer d467452e5e Fix damage on swaybar when view requests to exit fullscreen
Fixes #2191
2018-07-02 21:58:21 +10:00
emersion f611a4f9b1
Merge pull request #2187 from martinetd/idle-inhibit
Idle inhibit
2018-07-02 09:06:23 +01:00
Dominique Martinet 71224781c4 idle_inhibit: move server data to its own struct 2018-07-02 09:29:16 +09:00
Dominique Martinet 072b334abc idle_inhibit: stop inhibitor when views become invisible 2018-07-02 09:29:16 +09:00
Dominique Martinet e4bfb3bc98 Add idle inhibit unstable v1 support 2018-07-02 09:29:16 +09:00
Dominique Martinet 4eeca10a8a load_config: move NULL path check before first use
Found through static analysis
2018-07-02 08:03:41 +09:00
Dominique Martinet 8c526bbb03 config include: fix leak on relative include path
Found through static analysis
2018-07-02 08:03:41 +09:00
Dominique Martinet 248ea93c1a bar config: fix uninitialized accesses on init error
If init fails halfway through it will call the destroy function,
which needs some coherent stuff filled.
Allocate with calloc and fill in what cannot fail first

Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet e67c8cf1cb cmd_assign: fix leak on error
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet c73c552cae bar_cmd_modifier: fix use-after-free on error
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 6d2b82253a bar_cmd_font: fix leak of font
join_args is a freshly allocated string and can be used as is.

Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 0c6149171b read_config: fix leak on error
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet a2354d5992 cmd_background: fix leak on error
Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet df494a7e51 transaction_apply: use float for quotient
Pre-dividing 1000/60 would lose 2/3 due to round-up

Found through static analysis
2018-07-02 08:03:41 +09:00
Dominique Martinet c78ab67877 workspace_next_name: fix string length for ws_num >= 100
The check didn't include && ws_num < 100 so l would always be 1 or 2
Instead of fixing logic it's simpler to just call snprintf twice to get
length and use that.

Also change malloc failure check to sway_assert because both callers of
this function do not do null check and would segfault...

Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 9c9ee3e4ef find prev/next output/workspace: add NULL check
These could be called with NULL if there is no focus

Found through static analysis.
2018-07-02 08:03:41 +09:00
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 7abb4d63e2
Init screencopy manager 2018-07-01 22:55:25 +01: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
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
Dominique Martinet 9ea4cc13a0 sway views: add helpers to get view and layer from wlr_surface 2018-06-30 22:31:14 +09:00
Ryan Dwyer e396af853b Merge remote-tracking branch 'upstream/master' into atomic 2018-06-30 22:46:25 +10: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
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
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
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 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
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