aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
Commit message (Collapse)AuthorAge
* view: handle case where map_ws is NULLLibravatar Rouven Czerwinski2021-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a criteria places the view into the scratchpad, map_ws is NULL and trying to access map_ws->fullscreen will result in SIGSEGFAULT with: #0 0x0000000000455327 in should_focus (view=0x15a6a70) at ../sway/tree/view.c:604 prev_con = 0x0 len = <optimized out> seat = 0x12233c0 prev_ws = 0x1264c80 map_ws = 0x0 criterias = <optimized out> seat = <optimized out> prev_con = <optimized out> prev_ws = <optimized out> map_ws = <optimized out> criterias = <optimized out> len = <optimized out> num_children = <optimized out> #1 view_map (view=view@entry=0x15a6a70, wlr_surface=0x15a5cb0, fullscreen=<optimized out>, fullscreen_output=<optimized out>, decoration=<optimized out>) at ../sway/tree/view.c:809 __PRETTY_FUNCTION__ = "view_map" ws = <optimized out> seat = <optimized out> node = <optimized out> target_sibling = <optimized out> container = 0x1625400 set_focus = <optimized out> app_id = <optimized out> class = <optimized out> #2 0x0000000000423a7e in handle_map (listener=0x15a6c78, data=<optimized out>) at ../sway/desktop/xdg_shell.c:454 xdg_shell_view = 0x15a6a70 view = 0x15a6a70 xdg_surface = 0x15a6620 csd = <optimized out> #3 0x00007f508bd3674c in wlr_signal_emit_safe (signal=signal@entry=0x15a6718, data=data@entry=0x15a6620) at ../subprojects/wlroots/util/signal.c:29 pos = 0x15a6c78 l = 0x15a6c78 cursor = {link = {prev = 0x15a6c78, next = 0x7fff53d58190}, notify = 0x7f508bd366c0 <handle_noop>} end = {link = {prev = 0x7fff53d58170, next = 0x15a6718}, notify = 0x7f508bd366c0 <handle_noop>} #4 0x00007f508bd15b29 in handle_xdg_surface_commit (wlr_surface=<optimized out>) at ../subprojects/wlroots/types/xdg_shell/wlr_xdg_surface.c:384 surface = 0x15a6620 #5 0x00007f508bd2e981 in surface_commit_state (surface=surface@entry=0x15a5cb0, next=next@entry=0x15a5e18) at ../subprojects/wlroots/types/wlr_surface.c:455 __PRETTY_FUNCTION__ = "surface_commit_state" invalid_buffer = <optimized out> subsurface = 0x15a6038 #6 0x00007f508bd2f53b in surface_commit_pending (surface=0x15a5cb0) at ../subprojects/wlroots/types/wlr_surface.c:474 next_seq = 3 next_seq = <optimized out> #7 surface_commit (client=<optimized out>, resource=<optimized out>) at ../subprojects/wlroots/types/wlr_surface.c:542 surface = 0x15a5cb0 subsurface = <optimized out> If map_ws is NULL we assume the view is places into the scratchpad and return false as well.
* tree/view: don't give focus to views mapped under fullscreen viewsLibravatar Tudor Brindus2021-04-25
| | | | Fixes #6211.
* view_destroy: fix use-after-free with subsurface_destroyLibravatar Dominique Martinet2021-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove view from its own unmap event listener so when subsurfaces link try to remove themselves they won't run into it. This fixes the following ASAN use-after-free error on a build slightly modified to instrument wl_list operations: ==71705==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000829a0 at pc 0x000000508eb7 bp 0x7ffec8fd8030 sp 0x7ffec8fd8028 WRITE of size 8 at 0x6160000829a0 thread T0 #0 0x508eb6 in wl_list_remove ../common/list.c:181 #1 0x4f4998 in view_child_destroy ../sway/tree/view.c:1131 #2 0x4f38fa in subsurface_handle_destroy ../sway/tree/view.c:946 #3 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #4 0x7fda5072f0dd in subsurface_destroy ../types/wlr_surface.c:649 #5 0x7fda507312c4 in subsurface_handle_surface_destroy ../types/wlr_surface.c:1094 #6 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #7 0x7fda5072f305 in surface_handle_resource_destroy ../types/wlr_surface.c:677 #8 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce) #9 0x7fda508187f2 in wl_client_destroy (/lib64/libwayland-server.so.0+0xc7f2) #10 0x7fda50818e5f in wl_client_connection_data (/lib64/libwayland-server.so.0+0xce5f) #11 0x7fda50818219 in wl_event_loop_dispatch (/lib64/libwayland-server.so.0+0xc219) #12 0x7fda50818984 in wl_display_run (/lib64/libwayland-server.so.0+0xc984) #13 0x43122c in server_run ../sway/server.c:254 #14 0x42f47c in main ../sway/main.c:433 #15 0x7fda503cab74 in __libc_start_main (/lib64/libc.so.6+0x27b74) #16 0x40f6fd in _start (/opt/wayland/bin/sway+0x40f6fd) 0x6160000829a0 is located 288 bytes inside of 592-byte region [0x616000082880,0x616000082ad0) freed by thread T0 here: #0 0x7fda50f01a27 in free (/lib64/libasan.so.6+0xaea27) #1 0x4532d8 in destroy ../sway/desktop/xdg_shell.c:262 #2 0x4ed17b in view_destroy ../sway/tree/view.c:67 #3 0x4ed300 in view_begin_destroy ../sway/tree/view.c:83 #4 0x454a3f in handle_destroy ../sway/desktop/xdg_shell.c:507 #5 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #6 0x7fda506e2c87 in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:481 #7 0x7fda506e3018 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:516 #8 0x7fda506dfbe5 in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71 #9 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce) previously allocated by thread T0 here: #0 0x7fda50f01ed7 in calloc (/lib64/libasan.so.6+0xaeed7) #1 0x454bc8 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:528 #2 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #3 0x7fda506e2363 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:378 #4 0x7fda5072e368 in surface_commit_state ../types/wlr_surface.c:455 #5 0x7fda5072e51d in surface_commit_pending ../types/wlr_surface.c:474 #6 0x7fda5072ea58 in surface_commit ../types/wlr_surface.c:542 #7 0x7fda4fb3ac03 in ffi_call_unix64 (/lib64/libffi.so.6+0x6c03) Fixes #5168
* view: subsurface NULL check in view_from_wlr_surfaceLibravatar Kenny Levinsen2021-03-24
| | | | | Necessary NULL checks had been added to xdg_shell and xwayland surfaces, but subsurfaces had been missed.
* view: Handle NULL role object when role is setLibravatar Kenny Levinsen2021-03-21
| | | | | wlr_(xdg|xwayland)_surface_from_wlr_surface can return NULL even though wlr_surface_is_(xdg|xwayland)_surface returned true.
* view: Set parent for view_child subsurfaces on initLibravatar Kenny Levinsen2021-02-23
| | | | | | | | | | | | view_child_init was calling view_init_subsurfaces, which did not set the parent attribute for the subchildren. This lead to the subchildren acting as standalone children. If the parent was an xdg_popup, this would make the subchild unaware of the popup position. Introduce view_child_init_subsurfaces for view_child_init to use instead. Closes: https://github.com/swaywm/sway/issues/6038
* view: Mark subchildren as unmapped in view_child_destroyLibravatar Kenny Levinsen2021-02-23
| | | | | | | The subchildren lose their parent association at this point, so they will not be able to see that the parent is unmapped. Instead, just set the subchildren to be unmapped directly.
* view: Recursively check mapped of view_child treeLibravatar Kenny Levinsen2021-02-23
| | | | A subsurface may be set to mapped without its parent.
* container: Move pending state to state structLibravatar Kenny Levinsen2021-02-16
| | | | | | | | | Pending state is currently inlined directly in the container struct, while the current state is in a state struct. A side-effect of this is that it is not immediately obvious that pending double-buffered state is accessed, nor is it obvious what state is double-buffered. Instead, use the state struct for both current and pending.
* view: Read geometry directly in view_update_sizeLibravatar Kenny Levinsen2021-02-09
|
* shells: Only center tiled views on size changeLibravatar Kenny Levinsen2021-02-09
| | | | | | | The size of a tiled container cannot change in response to new buffer sizes, so there is no need to commit a new transaction. Instead, simply recenter the view with the new geometry, leaving the full transaction flow for floating containers.
* transaction: Move centering to view_center_surfaceLibravatar Kenny Levinsen2021-02-09
| | | | This will allow us to reuse it for centering elsewhere.
* view: Save surface x and y on saved buffersLibravatar Kenny Levinsen2021-02-09
| | | | | | | | | We need to use surface_x and surface_y when rendering and damaging saved buffers as these compensate for views that have been centered due to being smaller than their container. Add them to the surface positions on the saved buffer so we have the values from the time the buffer was saved.
* Implement foreign toplevel fullscreen output hintsLibravatar fwsmit2021-01-25
|
* Adhere to ICCCM focus specificationLibravatar BrassyPanache2021-01-20
| | | | | | | | For certain applications (e.g. JetBrains) the parent window controls input. We need to adhere to the ICCCM input focus specification to properly handle these cases. Relates to swaywm/wlroots#2604
* Switch to wlr_xdg_surface_for_each_popup_surfaceLibravatar Simon Ser2021-01-12
| | | | | | | | Instead of calling wlr_xdg_surface_for_each_popup and then wlr_surface_for_each_surface, use the new for_each_popup_surface helper introduced in [1] that does it in one go. [1]: https://github.com/swaywm/wlroots/pull/2609
* Change workspace_layout to match i3 behaviorLibravatar Ronan Pigott2020-12-20
| | | | | | | In i3, the workspace_layout command does not affect the workspace layout. Instead, new workspace level containers are wrapped in the desired layout and the workspace layout always defaults to the output orientation.
* tree/container: introduce `container_is_sticky[_or_child]` functionsLibravatar Tudor Brindus2020-11-11
| | | | | | | | | | To query whether a container is sticky, checking `con->is_sticky` is insufficient. `container_is_floating_or_child` must also return true; this led to a lot of repetition. This commit introduces `container_is_sticky[_or_child]` functions, and switches all stickiness checks to use them. (Including ones where the container is already known to be floating, for consistency.)
* Smart borders fix: always show borders for floating containersLibravatar Dimitris Triantafyllidis2020-10-25
| | | | | | | | | | | | | | Currently, in view_autoconfigure, the only condition for show_border is !view_is_only_visible. view_is_only_visible does not cross the boundary between the workspace's tiling and floating lists and does not differentiate between them. The result is, that in a workspace with zero or more tiling containers and a single floating container, the floating container will lose its borders as soon as it is split, provided that a only one view is visible within the floating container. Fixed by adjusting the condition for show_borders.
* view: remove foreign toplevel listeners on destroyLibravatar Ronan Pigott2020-08-05
|
* view: implement foreign toplevel fullscreen requestLibravatar Ronan Pigott2020-08-05
|
* view: display scratchpad hidden containers when activated by ftmLibravatar Ronan Pigott2020-07-25
|
* tree/view: fix segfault in view_update_titleLibravatar Simon Ser2020-07-03
| | | | | | | | xdg-shell doesn't allow clients to set the title to NULL, so we shouldn't need to call wlr_foreign_toplevel_handle_v1_set_title with an empty string to reset the old one. Closes: https://github.com/swaywm/sway/issues/5488
* tree/view: Make foreign-toplevel app_id fallback to classLibravatar Johan Bjäreholt2020-07-01
| | | | | | | | | | | | | | | It is not a part of the foreign-toplevel-management protocol to get the class of a toplevel, only for getting the app_id. For xwayland clients this is an issue because that means that you cannot identify what application the toplevel refers to which is the point of the app_id property. By falling back to class when an app_id does not exist solves this problem. Phoc also uses app_id and class interchangeably in their implementation of foreign-toplevel-management, in fact they always do that and not only for just this protocol. https://source.puri.sm/Librem5/phoc/-/blob/c8d8a4c5440a6c1647b09dbd3bba7999f9cd433c/src/xwayland.c#L236
* tree/view: fix smart borders with tabbed/stacked ancestorLibravatar Tudor Brindus2020-06-27
| | | | Fixes #5484.
* Implement wlr-foreign-toplevel-management-v1Libravatar Drew DeVault2020-06-23
|
* Add support for viewporterLibravatar Simon Ser2020-06-17
| | | | | | Depends on [1]. [1]: https://github.com/swaywm/wlroots/pull/2092
* Remove view child surface_{map,unmap} listeners on destroyLibravatar Simon Ser2020-06-12
|
* view: fix surface_new_subsurface use-after-freeLibravatar Ronan Pigott2020-06-13
|
* tree/view: fix smart gaps when ancestor container is tabbed or stackedLibravatar Tudor Brindus2020-06-08
| | | | Fixes #5406.
* Save transform during transactionLibravatar Kalyan Sriram2020-06-05
| | | Closes: https://github.com/swaywm/sway/issues/5412
* container: Remove useless surface dimensionsLibravatar Kenny Levinsen2020-06-03
| | | | The adjustments to resize logic left them unnecessary.
* view: update_size should only update pending sizeLibravatar Kenny Levinsen2020-06-03
| | | | | Updating the current size outside transactions lead to rendering glitches during resizes.
* view: Save all buffers associated with viewLibravatar Kenny Levinsen2020-06-03
| | | | | | | | | | | | During the execution of a resize transaction, the buffer associated with a view's surface is saved and reused until the client acknowledges the resulting configure event. However, only one the main buffer of the main surface was stored and rendered, meaning that subsurfaces disappear during resize. Iterate over all, store and render buffers from all surfaces in the view to ensure that correct rendering is preserved.
* Add views idle inhibition status in get_tree outputLibravatar Damien Tardy-Panis2020-05-29
| | | | Fixes #5286
* commands: Add per-view shortcuts_inhibitor commandLibravatar Michael Weiser2020-05-13
| | | | | | | | | | | | | | | | | | | | | Add a separate per-view shortcuts_inhibitor command that can be used with criteria to override the per-seat defaults. This allows to e.g. disable shortcuts inhibiting globally but enable it for specific, known-good virtualization and remote desktop software or, alternatively, to blacklist that one slightly broken piece of software that just doesn't seem to get it right but insists on trying. Add a flag to sway_view and handling logic in the input manager that respects that flag if configured but falls back to per-seat config otherwise. Add the actual command but with just enable and disable subcommands since there's no value in duplicating the per-seat activate/deactivate/toggle logic here. Split the inhibitor retrieval helper in two so we can use the backend half in the command to retrieve inhibitors for a specific surface and not just the currently focused one. Extend the manual page with documentation of the command and references to its per-seat sibling and usefulness with criteria. Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
* Update for new wlr_buffer APILibravatar Simon Ser2020-04-02
| | | | | | Update for [1]. [1]: https://github.com/swaywm/wlroots/pull/2044
* Use wlr_client_bufferLibravatar Simon Ser2020-03-06
| | | | | | Update for breaking changes in [1]. [1]: https://github.com/swaywm/wlroots/pull/2043
* tree/view: do not attempt enter on hidden childLibravatar Brian Ashworth2020-02-18
| | | | | | | | If a subsurface is created for a surface that is associated with a scratchpad hidden view, do not attempt to send an enter to it. The subsurface is not on any output and since there is no workspace associated with the view, attempting to get the output for the NULL workspace will result in a SIGSEGV.
* view: remove workspace pid mapping for assignsLibravatar Brian Ashworth2020-01-09
| | | | | | If a view is mapped to a workspace using an assign, the pid should still be removed from the pid mapping list. This prevents child processes from matching against it and mapping a view to a likely undesired workspace.
* smart_borders: separate smartness from edge typesLibravatar Ronan Pigott2019-11-04
|
* view: create container before selecting workspaceLibravatar Ronan Pigott2019-09-22
|
* view: always populate pidLibravatar Brian Ashworth2019-09-20
| | | | | | | If the view was mapped as fullscreen or the view was assigned either a workspace or output, the pid was not being populated since it was occurring as part of the pid mapping check in select_workspace. This extracts the pid population and makes it so it is always executed
* Remove xdg-shell v6 supportLibravatar Simon Ser2019-08-20
| | | | | | All major toolkits and apps have gained xdg-shell stable support. Closes: https://github.com/swaywm/sway/issues/3690
* view_update_size: fix surface_width/height mismatchLibravatar Antonin Décimo2019-08-12
|
* Remove all wayland-server.h includesLibravatar Simon Ser2019-07-27
| | | | | | | | | | | | | | | The documentation for wayland-server.h says: > Use of this header file is discouraged. Prefer including > wayland-server-core.h instead, which does not include the server protocol > header and as such only defines the library PI, excluding the deprecated API > below. Replacing wayland-server.h with wayland-server-core.h allows us to drop the WL_HIDE_DEPRECATED declaration. This commit si similar to wlroots' ca45f4490ccc ("Remove all wayland-server.h includes").
* Rework gaps code to be simpler and correctLibravatar Pedro Côrte-Real2019-07-15
| | | | | | | | | | | | | Instead of tracking gaps per child apply gaps in two logical places: 1. In tiled containers use the layout code to add the gaps between windows. This is much simpler and guarantees that the sizing of children is correct. 2. In the workspace itself apply all the gaps around the edge. Here we're in the correct position to size inner and outer gaps correctly and decide on smart gaps in a single location. Fixes #4296
* tree: set correct border value before creating floaterLibravatar random human2019-06-27
|
* Use parent get_root_coords in subsurfacesLibravatar Kenny Levinsen2019-05-30
| | | | | | | | Subsurfaces need access to the parent get_root_coords impl for positioning in popups. To do this, we store a reference to the parent view_child where applicable. Fixes #4191.
* Don't apply hide_edge_borders to floating windowsLibravatar mwenzkowski2019-04-16
| | | | This change matches i3's behavior.