aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
Commit message (Collapse)AuthorAge
* Remove support for arbitrary rotationsLibravatar Simon Ser2021-04-26
| | | | | | | There was some unused code-paths for rendering surfaces with an arbitrary rotation applied. This was imported from rootston. Since we don't have plans to make use of this, remove it.
* Remove usage of surface->sx|syLibravatar Kenny Levinsen2021-04-26
| | | | | | | | | | | | | | | These coordinates contain the all-time accumulated buffer attach point, which is a way to perform incremental client-side initiated movement of windows, intended as a way to maintain logical window positioning while compensating for layout changes such as folding in a left side panel. This value is not useful for implementing this feature, and break things if they ever become non-zero. Their inclusion in calculations also tend to cause confusion. Remove usage of these coordinates, removing the ability for clients to move themselves. This may again be supported if a better API is made available from wlroots.
* output: damage whole output when exiting scanoutLibravatar Ronan Pigott2021-04-01
|
* output: simplify layer surface iterationLibravatar Vyivel2021-03-11
|
* Fix #5643, #5064: rounding issues in floating-point -> integer conversionsLibravatar Dimitris Triantafyllidis2021-02-22
| | | | | | | | | | | | | Currently, various floating-point expressions involving the coordinates of borders, titlebars and content surfaces are directly assigned to integers, and so they are rounded towards zero. This results in off-by-one distances between these elements when the signs of their coordinates differ. Fixed by wrapping these expressions with a call to floor before the assignment.
* desktop/output: Disable head if mode is NULLLibravatar Kenny Levinsen2021-01-26
| | | | | | | | | | wlr_output_configuration_head_v1_create normally fills out the head "enabled" field to match the wlr_output state. We overwrite this to also set the head as enabled if it is only turned off with DPMS. However, in some cases we may not have a mode for this display, in which case setting it as enabled will lead to a segfault later on. Therefore, enabled conditional on the presence of a mode.
* Rename output_layer_for_each_surface_{toplevel,popup}Libravatar Simon Ser2021-01-12
| | | | Swap the "surface" part for consistency with wlroots' naming.
* 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
* Test output before direct scan-outLibravatar Simon Ser2020-12-20
| | | | | | | | | | | This avoids some log spam. Eventually when we wire up the atomic test commit this will take care of the other log spam referenced below. References: https://github.com/swaywm/sway/pull/5010 References: https://github.com/swaywm/wlroots/issues/2181 Closes: https://github.com/swaywm/wlroots/issues/2532
* Log which output is using direct scan-outLibravatar Simon Ser2020-11-16
|
* Use wlr_output_event_commitLibravatar Simon Ser2020-08-27
| | | | | | | | | | | | | Instead of listening to both transform and scale events, we can listen to the commit event and use the new wlr_output_event_commit struct to decide what to do. This de-duplicates some of the work we were doing twice when an output was re-configured. Depends on [1]. [1]: https://github.com/swaywm/wlroots/pull/2315
* desktop: output: Scale custom output refresh rateLibravatar Andri Yngvason2020-07-18
| | | | | This fixes an issue with wlr-output-management causing the frame rate to jump to 60000 Hz when setting a custom mode.
* config/output: don't change output state before commitLibravatar Simon Ser2020-07-10
| | | | | | | | | | | | | | | | | | | | | | | Previously, we called output_disable prior to wlr_output_commit. This mutates Sway's output state before the output commit actually succeeds. This results in Sway's state getting out-of-sync with wlroots'. An alternative fix [1] was to revert the changes made by output_disable in case of failure. This is a little complicated. Instead, this patch makes it so Sway's internal state is never changed before a successful wlr_output commit. We had two output flags: enabled and configured. However enabled was set prior to the output becoming enabled, and was used to prevent the output event handlers (specifically, the mode handler) from calling apply_output_config again (infinite loop). Rename enabled to enabling and use it exclusively for this purpose. Rename configure to enabled, because that's what it really means. [1]: https://github.com/swaywm/sway/pull/5521 Closes: https://github.com/swaywm/sway/issues/5483
* output: simplify loop over layer surfacesLibravatar Isaac Freund2020-06-30
|
* container: Remove useless surface dimensionsLibravatar Kenny Levinsen2020-06-03
| | | | The adjustments to resize logic left them unnecessary.
* 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.
* Render layer shell popups over the top layerLibravatar David962020-04-10
|
* output: remove damage listeners in damage destroyLibravatar Rouven Czerwinski2020-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of removing the destroy listeners in the output destroy, remove them in the damage destroy handler. Fixes the following use after free: ==646625==ERROR: AddressSanitizer: heap-use-after-free on address 0x61200017cab8 at pc 0x0000004f8f29 bp 0x7ffdf465ad30 sp 0x7ffdf465ad20 WRITE of size 8 at 0x61200017cab8 thread T0 #0 0x4f8f28 in wl_list_remove ../common/list.c:181 #1 0x43dd24 in handle_destroy ../sway/desktop/output.c:790 (`wl_list_remove(&output->damage_destroy.link);` here, 214e3030e1dce master branch) #2 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29 #3 0x7f0e57390954 in wlr_output_destroy ../types/wlr_output.c:365 #4 0x7f0e5735e37f in backend_destroy ../backend/x11/backend.c:128 #5 0x7f0e57348147 in wlr_backend_destroy ../backend/backend.c:47 #6 0x7f0e57356f75 in multi_backend_destroy ../backend/multi/backend.c:54 #7 0x7f0e5735710e in handle_display_destroy ../backend/multi/backend.c:107 #8 0x7f0e573f23e4 in wl_display_destroy (/lib64/libwayland-server.so.0+0x93e4) #9 0x42f0b2 in server_fini ../sway/server.c:177 #10 0x42dd01 in main ../sway/main.c:414 #11 0x7f0e570f7041 in __libc_start_main (/lib64/libc.so.6+0x27041) #12 0x40e3bd in _start (/opt/wayland/bin/sway+0x40e3bd) 0x61200017cab8 is located 120 bytes inside of 320-byte region [0x61200017ca40,0x61200017cb80) freed by thread T0 here: #0 0x7f0e57aa9357 in __interceptor_free (/lib64/libasan.so.6+0xb0357) #1 0x7f0e5738b877 in wlr_output_damage_destroy ../types/wlr_output_damage.c:143 #2 0x7f0e5738b2b9 in output_handle_destroy ../types/wlr_output_damage.c:13 #3 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29 #4 0x7f0e57390954 in wlr_output_destroy ../types/wlr_output.c:365 #5 0x7f0e5735e37f in backend_destroy ../backend/x11/backend.c:128 #6 0x7f0e57348147 in wlr_backend_destroy ../backend/backend.c:47 #7 0x7f0e57356f75 in multi_backend_destroy ../backend/multi/backend.c:54 #8 0x7f0e5735710e in handle_display_destroy ../backend/multi/backend.c:107 #9 0x7f0e573f23e4 in wl_display_destroy (/lib64/libwayland-server.so.0+0x93e4) previously allocated by thread T0 here: #0 0x7f0e57aa9887 in __interceptor_calloc (/lib64/libasan.so.6+0xb0887) #1 0x7f0e5738b532 in wlr_output_damage_create ../types/wlr_output_damage.c:91 #2 0x43e4a7 in handle_new_output ../sway/desktop/output.c:875 #3 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29 #4 0x7f0e57357261 in new_output_reemit ../backend/multi/backend.c:143 #5 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29 #6 0x7f0e5736030a in wlr_x11_output_create ../backend/x11/output.c:253 #7 0x7f0e5735e309 in backend_start ../backend/x11/backend.c:113 #8 0x7f0e573480fb in wlr_backend_start ../backend/backend.c:36 #9 0x7f0e57356e61 in multi_backend_start ../backend/multi/backend.c:31 #10 0x7f0e573480fb in wlr_backend_start ../backend/backend.c:36 #11 0x42f4ba in server_start ../sway/server.c:205 #12 0x42dbd7 in main ../sway/main.c:394 #13 0x7f0e570f7041 in __libc_start_main (/lib64/libc.so.6+0x27041) Fixes #5158
* Add test-only support to wlr-output-management-unstable-v1Libravatar Simon Ser2020-04-08
| | | | | Use the new test_output_config function to implement wlr-output-management-unstable-v1's test request.
* Stop checking wlr_output_attach_buffer return valueLibravatar Simon Ser2020-04-08
| | | | | | Update for [1]. Everything is now checked at commit-time. [1]: https://github.com/swaywm/wlroots/pull/2097
* Null check sway_layer_surface when checking damageLibravatar Tadeo Kondrak2020-03-10
| | | | | Before this change, an overlay layer-shell surface without a buffer attached would segfault the compositor on screen damage.
* Use wlr_client_bufferLibravatar Simon Ser2020-03-06
| | | | | | Update for breaking changes in [1]. [1]: https://github.com/swaywm/wlroots/pull/2043
* Drop sway_output.surface_needs_frameLibravatar Simon Ser2020-03-06
| | | | | | | wlr_output_schedule_frame now sets output->needs_frame [1], so this isn't needed anymore. [1]: https://github.com/swaywm/wlroots/pull/2053
* Only schedule a frame if client has requested a frame callbackLibravatar Simon Ser2020-03-06
| | | | | When a client hasn't damaged its surface, we only need to schedule an output frame if the client has requested a frame callback.
* Make handle_destroy and output_repaint_timer_handler staticLibravatar Simon Ser2020-03-04
|
* Add support for wlr-output-power-management-unstable-v1Libravatar Simon Ser2020-02-26
|
* Call apply_output_config instead of output_enableLibravatar Simon Ser2020-02-11
| | | | | | | apply_output_config will call output_enable if necessary. This fixes a lone wlr_output_enable call (without a matching wlr_output_commit call) which was a no-op.
* desktop/output: fix mem leak in handle_new_outputLibravatar Brian Ashworth2020-01-16
| | | | | | This fixes a memory leak of oc (the output config) in handle_new_output. Output configs returned from find_output_config are not stored and need to be freed after use.
* Re-add support for wlr_output's atomic APILibravatar Simon Ser2019-12-30
| | | | | | | | | | | | | This reverts commit 724926ea6ae119956dc7b1e39c2e30c1e3657676 and re-applies commit 6e0565e9de4247bbf0ca662565c58e0a54258d6e. Outputs now need to be explicitly enabled when performing a modeset. We need to roll back wlr_output_attach_render when we decide not to render. See also: https://github.com/swaywm/wlroots/pull/1797 (wlroots PR) See also: https://github.com/swaywm/sway/pull/4355 (Original sway PR) See also: https://github.com/swaywm/sway/pull/4434 (Revert sway PR)
* output: Restore previous max_render_time behaviorLibravatar Kenny Levinsen2019-12-01
|
* output: Schedule idle frames if we do not renderLibravatar Kenny Levinsen2019-12-01
| | | | | | | | | | | | | | | | | | | | Repaint scheduling delays output render and frame done events from output frame events, and block idle frame events from being scheduled in between output frame done and output render in this period of time. If a surface is committed after its frame done event, but before output render, idle frame requests will be blocked, and the surface relies on the upcoming render to schedule a frame. If when the repaint timer expires, output render is deemed unnecessary, no frame will be scheduled. This can lead to surfaces never having their frame callbacks fire. To fix this, we store that a surface has requested a frame in surface_needs_frame. When the repaint expires, if no render is deemed necessary, we check this flag and schedule an idle frame. Fixes #4768
* output: Replace block_idle_frame with frame_pendingLibravatar Kenny Levinsen2019-12-01
|
* output: Ensure that frame_done is delayed on max_render_timeLibravatar Kenny Levinsen2019-11-28
| | | | | | | | | | | | | | | | | | | max_render_time can be set on output, view, or both. However, if only applied to the output, send_frame_done_iterator would erroneously send frame_done immediately, ignoring the output max_render_time. As damage_handle_frame processed max_render_time correctly, idle frames would be blocked in anticipation of the delay that was meant to happen. Without the delay, frame events would be dispatched during the idle frame block, and some clients would never receive the frame done events they had requested, at least not until something else actively drove another render. Respecting both view and output max_render_time in send_frame_done_iterator ensures that the frame events are always correctly delayed. Fixes #4756
* Amend typosLibravatar Jason2019-11-23
|
* Use new presentation-time helperLibravatar Simon Ser2019-11-21
| | | | | This has the advantage to (1) reduce boilerplate and (2) make us correctly handle wlr_output_event_present.commit_seq.
* output: check wlr_output in repaint handlerLibravatar Ivan Molodetskikh2019-11-17
| | | | | | It's possible for the output to be disconnected in just the right moment for wlr_output to be NULL in the repaint handler, causing a crash. This check fixes that crash.
* view: add max_render_timeLibravatar Ivan Molodetskikh2019-11-17
|
* output: add max_render_timeLibravatar Ivan Molodetskikh2019-11-17
|
* Fix presentation feedback when scanning out fullscreen viewLibravatar Simon Ser2019-10-27
| | | | Closes: https://github.com/swaywm/sway/issues/4663
* Fix segfault in wlr_output_manager_v1_set_configurationLibravatar Simon Ser2019-10-27
| | | | | | | | | | | | | | Calling wlr_output_manager_v1_set_configuration with an enabled output and a NULL mode is incorrect if the output doesn't support modes. When DPMS'ing an output, wlr_output_enable(output, false) is called. This de-allocates the CRTC and sets wlr_output.current_mode to NULL. Because we mark DPMS'ed outputs as enabled, we also need to provide a correct output mode. Add a field to sway_output to hold the current mode. Closes: https://github.com/swaywm/wlroots/issues/1867
* Fix refresh rate scale of outputLibravatar Danilo Spinella2019-10-21
| | | | | | | | When applying config, value mode->refresh is mHz; convert it to Hz before assigning it to the temporary output config. oc->refresh_rate will be converted back to mHz in set_mode function. Fix debug log printing GHz instead of Hz.
* Updates per wlroots layer shell changesLibravatar Drew DeVault2019-10-16
|
* Fix direct scan-out flickeringLibravatar Simon Ser2019-09-26
| | | | | | | | | | | | | | | | | | | Sometimes when using direct scan-out, some flickering between the fullscreen app and the regular desktop could be seen. This happened because we called wlr_output_attach_render and then wlr_output_attach_buffer for direct scan-out. wlr_output_attach_render makes the OpenGL context current but also attaches the OpenGL buffer to the primary plane apparently (all of this happens inside eglMakeCurrent). This patch moves the scan-out logic outside of output_render, before wlr_output_attach_render. This lines it up with rootston's implementation. This also makes more sense since no rendering is involved when using direct scan-out. Sorry about that, I should've tested this with more clients. The new code has been tested with mpv and a GLFW demo.
* properly check pixman_region32_contains_rectangle returnLibravatar Ilia Bozhinov2019-08-19
| | | | | pixman_region32_contains_rectangle() returns pixman_region_intersection_t not a bool.
* layer-shell: add support for popupsLibravatar Drew DeVault2019-08-14
|
* 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").
* Update output manager on layout changeLibravatar Josef Gajdusek2019-07-17
| | | | | The output manager config was not properly updated if the position of the output got changed.
* use surface coordinates for damaging buffersLibravatar murray2019-06-22
|
* desktop: output: fix use-after-free in destroyLibravatar Rouven Czerwinski2019-06-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | handle_destroy would mark the output es being destroyed and commit the transaction. Committing the transaction results in the output being freed, the output manager can not retrieve the server reference afterwards, resulting in the following use-after-free: ==22746==ERROR: AddressSanitizer: heap-use-after-free on address 0x614000017088 at pc 0x560c1ac17136 bp 0x7ffeab146f20 sp 0x7ffeab146f10 READ of size 8 at 0x614000017088 thread T0 #0 0x560c1ac17135 in handle_destroy ../sway/desktop/output.c:566 #1 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #2 0x7f38af5d3dfc in drm_connector_cleanup ../subprojects/wlroots/backend/drm/drm.c:1448 #3 0x7f38af5d2058 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1240 #4 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135 #5 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #6 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52 #7 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1) #8 0x7f38aef5c39b in wl_display_run (/usr/lib/libwayland-server.so.0+0x939b) #9 0x560c1ac0afbe in server_run ../sway/server.c:225 #10 0x560c1ac09382 in main ../sway/main.c:397 #11 0x7f38aed35ce2 in __libc_start_main (/usr/lib/libc.so.6+0x23ce2) #12 0x560c1abea10d in _start (/usr/local/bin/sway+0x3910d) 0x614000017088 is located 72 bytes inside of 432-byte region [0x614000017040,0x6140000171f0) freed by thread T0 here: #0 0x7f38af82df89 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66 #1 0x560c1acbd1ed in output_destroy ../sway/tree/output.c:243 #2 0x560c1ac23ce5 in transaction_destroy ../sway/desktop/transaction.c:66 #3 0x560c1ac26b71 in transaction_progress_queue ../sway/desktop/transaction.c:348 #4 0x560c1ac284ca in transaction_commit_dirty ../sway/desktop/transaction.c:539 #5 0x560c1ac17110 in handle_destroy ../sway/desktop/output.c:564 #6 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #7 0x7f38af5d3dfc in drm_connector_cleanup ../subprojects/wlroots/backend/drm/drm.c:1448 #8 0x7f38af5d2058 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1240 #9 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135 #10 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #11 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52 #12 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1) previously allocated by thread T0 here: #0 0x7f38af82e5a1 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:95 #1 0x560c1acbc228 in output_create ../sway/tree/output.c:91 #2 0x560c1ac17ba2 in handle_new_output ../sway/desktop/output.c:656 #3 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #4 0x7f38af5e4ce8 in new_output_reemit ../subprojects/wlroots/backend/multi/backend.c:143 #5 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #6 0x7f38af5d26d4 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1294 #7 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135 #8 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29 #9 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52 #10 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1) SUMMARY: AddressSanitizer: heap-use-after-free ../sway/desktop/output.c:566 in handle_destroy Shadow bytes around the buggy address: 0x0c287fffadc0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd 0x0c287fffadd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c287fffade0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c287fffadf0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c287fffae00: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd =>0x0c287fffae10: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c287fffae20: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c287fffae30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa 0x0c287fffae40: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 0x0c287fffae50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c287fffae60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Retrieve the reference before the output is destroyed and update the output_management state with the saved reference.
* Update output manager config on all output eventsLibravatar Josef Gajdusek2019-05-24
| | | | | The output manager config was not properly updated when output configuration was changed through some other means (such as a command).