.gitignore | 5 Makefile.am | 199 + clients/desktop-shell.c | 167 + clients/editor.c | 145 + clients/nested-client.c | 4 clients/scaler.c | 10 clients/simple-dmabuf-drm-data.h | 3074 ++++++++++++++++++++++++++++++ clients/simple-dmabuf-drm.c | 907 ++++++++ clients/simple-dmabuf-intel.c | 621 ------ clients/simple-dmabuf-v4l.c | 37 clients/simple-egl.c | 51 clients/simple-im.c | 524 +++++ clients/stacking.c | 7 clients/subsurfaces.c | 3 clients/terminal.c | 41 clients/weston-info.c | 29 clients/weston-simple-im.c | 524 ----- clients/window.c | 117 - clients/window.h | 5 compositor/cms-colord.c | 5 compositor/cms-static.c | 4 compositor/main.c | 876 +++++--- compositor/screen-share.c | 11 compositor/systemd-notify.c | 7 compositor/text-backend.c | 1 compositor/weston-screenshooter.c | 2 compositor/weston.desktop | 2 compositor/weston.h | 24 configure.ac | 120 - desktop-shell/input-panel.c | 8 desktop-shell/shell.c | 359 ++- desktop-shell/shell.h | 14 fullscreen-shell/fullscreen-shell.c | 13 ivi-shell/hmi-controller.c | 4 ivi-shell/input-panel-ivi.c | 8 ivi-shell/ivi-layout-export.h | 36 ivi-shell/ivi-layout-private.h | 23 ivi-shell/ivi-layout-transition.c | 4 ivi-shell/ivi-layout.c | 234 -- ivi-shell/ivi-shell.c | 6 libweston-desktop/internal.h | 5 libweston-desktop/libweston-desktop.c | 10 libweston-desktop/libweston-desktop.h | 33 libweston-desktop/surface.c | 8 libweston-desktop/wl-shell.c | 28 libweston-desktop/xdg-shell-v5.c | 219 +- libweston-desktop/xdg-shell-v6.c | 295 ++ libweston-desktop/xwayland.c | 46 libweston/animation.c | 35 libweston/compositor-drm.c | 1708 ++++++++++------ libweston/compositor-drm.h | 58 libweston/compositor-fbdev.c | 99 libweston/compositor-fbdev.h | 4 libweston/compositor-headless.c | 159 + libweston/compositor-headless.h | 8 libweston/compositor-rdp.c | 159 + libweston/compositor-rdp.h | 26 libweston/compositor-wayland.c | 713 ++++-- libweston/compositor-wayland.h | 18 libweston/compositor-x11.c | 349 +-- libweston/compositor-x11.h | 13 libweston/compositor.c | 859 ++++++-- libweston/compositor.h | 235 +- libweston/gl-renderer.c | 473 +++- libweston/gl-renderer.h | 25 libweston/input.c | 141 - libweston/launcher-direct.c | 64 libweston/launcher-impl.h | 45 libweston/launcher-logind.c | 24 libweston/launcher-util.c | 13 libweston/launcher-weston-launch.c | 66 libweston/libinput-device.c | 2 libweston/libinput-seat.c | 11 libweston/linux-dmabuf.c | 138 + libweston/linux-dmabuf.h | 38 libweston/pixel-formats.c | 430 ++++ libweston/pixel-formats.h | 194 + libweston/weston-egl-ext.h | 156 - libweston/weston-launch.c | 3 libweston/windowed-output-api.h | 92 man/weston.ini.man | 26 man/weston.man | 7 notes.txt | 2 protocol/ivi-hmi-controller.xml | 2 protocol/weston-test.xml | 7 releasing.txt | 26 shared/cairo-util.h | 10 shared/config-parser.c | 1 shared/frame.c | 12 shared/helpers.h | 2 shared/option-parser.c | 32 shared/os-compatibility.c | 10 shared/platform.h | 16 shared/string-helpers.h | 1 shared/timespec-util.h | 72 shared/weston-egl-ext.h | 188 + tests/buffer-count-test.c | 158 - tests/ivi_layout-internal-test.c | 117 - tests/ivi_layout-test-plugin.c | 83 tests/ivi_layout-test.c | 3 tests/plugin-registry-test.c | 4 tests/reference/subsurface_z_order-00.png |binary tests/reference/subsurface_z_order-01.png |binary tests/reference/subsurface_z_order-02.png |binary tests/reference/subsurface_z_order-03.png |binary tests/reference/subsurface_z_order-04.png |binary tests/string-test.c | 1 tests/subsurface-shot-test.c | 263 ++ tests/subsurface-test.c | 195 + tests/surface-global-test.c | 4 tests/surface-screenshot.c | 5 tests/surface-test.c | 4 tests/timespec-test.c | 166 + tests/weston-test-client-helper.c | 25 tests/weston-test-client-helper.h | 3 tests/weston-test-desktop-shell.c | 234 ++ tests/weston-test-runner.c | 27 tests/weston-test-runner.h | 12 tests/weston-test.c | 51 tests/weston-tests-env | 7 tests/xwayland-test.c | 3 tools/zunitc/src/zuc_collector.h | 2 tools/zunitc/src/zuc_junit_reporter.c | 10 wcap/README | 2 wcap/wcap-decode.c | 2 weston.ini.in | 6 xwayland/dnd.c | 72 xwayland/launcher.c | 20 xwayland/selection.c | 6 xwayland/window-manager.c | 437 +++- xwayland/xwayland-internal-interface.h | 2 xwayland/xwayland.h | 1 132 files changed, 12835 insertions(+), 4737 deletions(-)
New commits: commit 2a528187b2cc33414611a28d9baf1125f7cd4607 Author: Bryce Harrington <br...@osg.samsung.com> Date: Tue Aug 8 11:46:14 2017 -0700 configure.ac: bump to version 3.0.0 for the official release diff --git a/configure.ac b/configure.ac index 61d7f37..0961ca8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ -m4_define([weston_major_version], [2]) -m4_define([weston_minor_version], [99]) -m4_define([weston_micro_version], [93]) +m4_define([weston_major_version], [3]) +m4_define([weston_minor_version], [0]) +m4_define([weston_micro_version], [0]) m4_define([weston_version], [weston_major_version.weston_minor_version.weston_micro_version]) m4_define([libweston_major_version], [3]) commit 3000a1c7c40bb4410146b6c68217e7028a1c5c97 Author: Arnaud Vrac <raw...@gmail.com> Date: Sat Aug 5 13:59:01 2017 +0200 libweston-desktop/xdg-shell-v5: initialize configure list Without this weston crashes when a client using xdg-shell-v5 is run. Signed-off-by: Arnaud Vrac <raw...@gmail.com> Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net> diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c index dd36086..ebe7940 100644 --- a/libweston-desktop/xdg-shell-v5.c +++ b/libweston-desktop/xdg-shell-v5.c @@ -745,6 +745,8 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct wl_client *wl_client, wl_event_loop_add_idle(loop, weston_desktop_xdg_surface_add_idle_callback, surface); + + wl_list_init(&surface->configure_list); } static void commit 18e77af67c0e5de775c6ecd479514d0419ddd8a1 Author: Bryce Harrington <br...@osg.samsung.com> Date: Tue Aug 1 11:19:30 2017 -0700 configure.ac: bump to version 2.99.93 for the RC1 release diff --git a/configure.ac b/configure.ac index bb8ae1b..61d7f37 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([weston_major_version], [2]) m4_define([weston_minor_version], [99]) -m4_define([weston_micro_version], [92]) +m4_define([weston_micro_version], [93]) m4_define([weston_version], [weston_major_version.weston_minor_version.weston_micro_version]) m4_define([libweston_major_version], [3]) commit c5f124169514e709699aedc97108837424af5682 Author: Philipp Kerling <pkerl...@casix.org> Date: Fri Jul 28 14:11:58 2017 +0200 desktop-shell: Set surface resizing state during interactive resize xdg_shell requires this information to be shared with the client in order to conform with the specification. The code to forward this to the client by way of a configure() event is already in place and works fine, it was just never being used until now. Signed-off-by: Philipp Kerling <pkerl...@casix.org> Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 4608cf2..415da19 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1635,9 +1635,12 @@ resize_grab_button(struct weston_pointer_grab *grab, struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; struct weston_pointer *pointer = grab->pointer; enum wl_pointer_button_state state = state_w; + struct weston_desktop_surface *desktop_surface = + resize->base.shsurf->desktop_surface; if (pointer->button_count == 0 && state == WL_POINTER_BUTTON_STATE_RELEASED) { + weston_desktop_surface_set_resizing(desktop_surface, false); shell_grab_end(&resize->base); free(grab); } @@ -1647,7 +1650,10 @@ static void resize_grab_cancel(struct weston_pointer_grab *grab) { struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; + struct weston_desktop_surface *desktop_surface = + resize->base.shsurf->desktop_surface; + weston_desktop_surface_set_resizing(desktop_surface, false); shell_grab_end(&resize->base); free(grab); } @@ -1731,6 +1737,7 @@ surface_resize(struct shell_surface *shsurf, resize->height = geometry.height; shsurf->resize_edges = edges; + weston_desktop_surface_set_resizing(shsurf->desktop_surface, true); shell_grab_start(&resize->base, &resize_grab_interface, shsurf, pointer, edges); commit e3715527b99dd7ccf30d06002555b8102a02d7d1 Author: Derek Foreman <der...@osg.samsung.com> Date: Wed Jul 26 14:35:58 2017 -0500 libweston-desktop/xdg-shell: Properly properly handle ack_configure commit 749637a8a306588964885fe6b25fda6087a84ccd introduced this feature, but the break is outside of any conditional so only the first item in the list is ever tested. If a client skips a few configures and then acks the most recent it's still operating within spec, so the break should only occur when a match is found. This version also adds a break after we miss the target, as a tiny optimization (the list will be cleaned up on disconnect anyway), as it makes the code no more difficult to read or maintain. Signed-off-by: Derek Foreman <der...@osg.samsung.com> Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net> diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c index 77d004e..dd36086 100644 --- a/libweston-desktop/xdg-shell-v5.c +++ b/libweston-desktop/xdg-shell-v5.c @@ -481,8 +481,10 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct wl_client *wl_client, } else if (configure->serial == serial) { wl_list_remove(&configure->link); found = true; + break; + } else { + break; } - break; } if (!found) { struct weston_desktop_client *client = diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c index 1344dda..10274e0 100644 --- a/libweston-desktop/xdg-shell-v6.c +++ b/libweston-desktop/xdg-shell-v6.c @@ -1106,8 +1106,10 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct wl_client *wl_client, } else if (configure->serial == serial) { wl_list_remove(&configure->link); found = true; + break; + } else { + break; } - break; } if (!found) { struct weston_desktop_client *client = commit 0e4e570caee9f857d13e35a9f4c78d52343872d7 Author: Derek Foreman <der...@osg.samsung.com> Date: Tue Jul 25 16:39:20 2017 -0500 input: Stop leaking libinput event source on session deactivation This is easily noticed as a leaked fd on every VC switch. Signed-off-by: Derek Foreman <der...@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> Tested-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> diff --git a/libweston/libinput-seat.c b/libweston/libinput-seat.c index 8cf5666..953f620 100644 --- a/libweston/libinput-seat.c +++ b/libweston/libinput-seat.c @@ -134,6 +134,8 @@ udev_input_disable(struct udev_input *input) if (input->suspended) return; + wl_event_source_remove(input->libinput_source); + input->libinput_source = NULL; libinput_suspend(input->libinput); process_events(input); input->suspended = 1; @@ -337,7 +339,8 @@ udev_input_destroy(struct udev_input *input) { struct udev_seat *seat, *next; - wl_event_source_remove(input->libinput_source); + if (input->libinput_source) + wl_event_source_remove(input->libinput_source); wl_list_for_each_safe(seat, next, &input->compositor->seat_list, base.link) udev_seat_destroy(seat); libinput_unref(input->libinput); commit 6b65d8f12021d8fff0db37fd10b9a469769178b2 Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Thu Jul 27 13:44:32 2017 +0300 compositor-drm: reset KMS state on VT-switch in Fix a regression with VT-switching away from Weston and then back causing drmModePageFlip() to fail with ENOSPC or EINVAL, leaving one or more outputs not updated. The regression appeared in 47224cc9312fef05c1a523ea0da0a1aae66f100d: compositor-drm: Delete drm_backend_set_modes Fix it by forcing a drmModeSetCrtc() on all outputs both initially created and after VT-switch in. Cc: Daniel Stone <dani...@collabora.com> Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> v2: moved state_invalid=true from create_output_for_connector() to drm_output_enable() Reviewed-by: Daniel Stone <dani...@collabora.com> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index c51d24b..8e1e788 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -220,6 +220,8 @@ struct drm_output { enum dpms_enum dpms; struct backlight *backlight; + bool state_invalid; + int vblank_pending; int page_flip_pending; int destroy_pending; @@ -880,7 +882,7 @@ drm_output_repaint(struct weston_output *output_base, return -1; mode = container_of(output->base.current_mode, struct drm_mode, base); - if (!output->fb_current || + if (output->state_invalid || !output->fb_current || output->fb_current->stride != output->fb_pending->stride) { ret = drmModeSetCrtc(backend->drm.fd, output->crtc_id, output->fb_pending->fb_id, 0, 0, @@ -891,6 +893,8 @@ drm_output_repaint(struct weston_output *output_base, goto err_pageflip; } output_base->set_dpms(output_base, WESTON_DPMS_ON); + + output->state_invalid = false; } if (drmModePageFlip(backend->drm.fd, output->crtc_id, @@ -999,6 +1003,12 @@ drm_output_start_repaint_loop(struct weston_output *output_base) goto finish_frame; } + /* Need to smash all state in from scratch; current timings might not + * be what we want, page flip might not work, etc. + */ + if (output->state_invalid) + goto finish_frame; + /* Try to get current msc and timestamp via instant query */ vbl.request.type |= drm_waitvblank_pipe(output); ret = drmWaitVBlank(backend->drm.fd, &vbl); @@ -2675,6 +2685,8 @@ drm_output_enable(struct weston_output *base) output->connector->count_modes == 0 ? ", built-in" : ""); + output->state_invalid = true; + return 0; err_free: @@ -3130,6 +3142,10 @@ session_notify(struct wl_listener *listener, void *data) weston_log("activating session\n"); weston_compositor_wake(compositor); weston_compositor_damage_all(compositor); + + wl_list_for_each(output, &compositor->output_list, base.link) + output->state_invalid = true; + udev_input_enable(&b->input); } else { weston_log("deactivating session\n"); commit f981d69553f52ca50aaf864bf821bb022ab7da82 Author: Derek Foreman <der...@osg.samsung.com> Date: Tue Jul 25 16:17:36 2017 -0500 logind: actually close fd in launcher_logind_close We still need to close fds passed to us - or we leak quite a few fds on VC switch. Regression, originally fixed in 8f5acc2f3a29c3831af4ddd6bed57f703c98dc77 and re-broken in commit 72dea06d7952e3ce8dd8057f7106186da4fa2678 but only for the logind launcher. Signed-off-by: Derek Foreman <der...@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c index f10a283..a069bd4 100644 --- a/libweston/launcher-logind.c +++ b/libweston/launcher-logind.c @@ -216,6 +216,7 @@ launcher_logind_close(struct weston_launcher *launcher, int fd) int r; r = fstat(fd, &st); + close(fd); if (r < 0) { weston_log("logind: cannot fstat fd: %m\n"); return; commit c623902ecaa191c7eccfcb7c212313407da82c56 Author: Philipp Kerling <pkerl...@casix.org> Date: Wed Jul 26 14:02:21 2017 +0200 libweston-desktop/xdg-shell: Check window geometry instead of surface size against configured size Shell surfaces may have a geometry that is different to the size of their main surface, e.g. due to subcompositing. In states where size is strictly enforced (fullscreen and maximized), the size that the compositor wants must be checked against the window geometry and not just the main surface size. Fix by calling weston_desktop_surface_get_geometry and using that size instead of main surface size. Signed-off-by: Philipp Kerling <pkerl...@casix.org> Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net> diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c index d7c49b1..77d004e 100644 --- a/libweston-desktop/xdg-shell-v5.c +++ b/libweston-desktop/xdg-shell-v5.c @@ -264,6 +264,10 @@ weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface, weston_desktop_surface_get_surface(surface->surface); bool reconfigure = false; + /* TODO: use the window geometry and not the surface size here + * We need to check the next geometry if there is one, but not accept it + * until we checked it, maybe. + */ if (surface->next.state.maximized || surface->next.state.fullscreen) reconfigure = surface->next.size.width != wsurface->width || surface->next.size.height != wsurface->height; diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c index dda0bf9..1344dda 100644 --- a/libweston-desktop/xdg-shell-v6.c +++ b/libweston-desktop/xdg-shell-v6.c @@ -644,9 +644,12 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev if (!wsurface->buffer_ref.buffer) return; + struct weston_geometry geometry = + weston_desktop_surface_get_geometry(toplevel->base.desktop_surface); + if ((toplevel->next.state.maximized || toplevel->next.state.fullscreen) && - (toplevel->next.size.width != wsurface->width || - toplevel->next.size.height != wsurface->height)) { + (toplevel->next.size.width != geometry.width || + toplevel->next.size.height != geometry.height)) { struct weston_desktop_client *client = weston_desktop_surface_get_client(toplevel->base.desktop_surface); struct wl_resource *client_resource = commit ba8a0d041ed83ebe18b919d8b2c8a02849ca1c7e Author: Philipp Kerling <pkerl...@casix.org> Date: Wed Jul 26 12:02:15 2017 +0200 desktop-shell: Track focused shell surface by main surface The focused surface is used for determining whether shell surfaces are activated. They should also be considered activated when a subsurface has focus. Inserting a call to weston_surface_get_main_surface fixes this. seat->focused_surface is only used for shell_surface keyboard focus tracking. Signed-off-by: Philipp Kerling <pkerl...@casix.org> Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 832a7b7..4608cf2 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -1852,7 +1852,7 @@ handle_keyboard_focus(struct wl_listener *listener, void *data) shell_surface_lose_keyboard_focus(shsurf); } - seat->focused_surface = keyboard->focus; + seat->focused_surface = weston_surface_get_main_surface(keyboard->focus); if (seat->focused_surface) { struct shell_surface *shsurf = get_shell_surface(seat->focused_surface); commit 4c4b9cfb1a55ee864beaf25286bfe4364036f0df Author: Bryce Harrington <br...@osg.samsung.com> Date: Tue Jul 25 16:32:20 2017 -0700 configure.ac: bump to version 2.99.92 for the beta release diff --git a/configure.ac b/configure.ac index 67fd9c9..bb8ae1b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([weston_major_version], [2]) m4_define([weston_minor_version], [99]) -m4_define([weston_micro_version], [91]) +m4_define([weston_micro_version], [92]) m4_define([weston_version], [weston_major_version.weston_minor_version.weston_micro_version]) m4_define([libweston_major_version], [3]) commit 9ffb25009cbf2996f53b4ceb39cb9a7af1508ebf Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Mon Mar 27 15:14:32 2017 +0300 libweston: introduce weston_output_from_resource() This is a simple wrapper for casting the user data of a wl_resource into a struct weston_output pointer. Using the wrapper clearly marks all the places where a wl_output protocol object is used. Replace ALL wl_output related calls to wl_resource_get_user_data() with a call to weston_output_from_resource(). v2: add type assert in weston_output_from_resource(). Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> Reviewed-by: Armin Krezović <krezovic.ar...@gmail.com> diff --git a/compositor/weston-screenshooter.c b/compositor/weston-screenshooter.c index 9999909..f874c3e 100644 --- a/compositor/weston-screenshooter.c +++ b/compositor/weston-screenshooter.c @@ -66,7 +66,7 @@ screenshooter_shoot(struct wl_client *client, struct wl_resource *buffer_resource) { struct weston_output *output = - wl_resource_get_user_data(output_resource); + weston_output_from_resource(output_resource); struct weston_buffer *buffer = weston_buffer_from_resource(buffer_resource); diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c index 40a4092..e6b1541 100644 --- a/desktop-shell/input-panel.c +++ b/desktop-shell/input-panel.c @@ -274,7 +274,7 @@ input_panel_surface_set_toplevel(struct wl_client *client, wl_list_insert(&shell->input_panel.surfaces, &input_panel_surface->link); - input_panel_surface->output = wl_resource_get_user_data(output_resource); + input_panel_surface->output = weston_output_from_resource(output_resource); input_panel_surface->panel = 0; } diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index f1577c1..832a7b7 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2941,7 +2941,7 @@ desktop_shell_set_background(struct wl_client *client, surface->committed = background_committed; surface->committed_private = shell; weston_surface_set_label_func(surface, background_get_label); - surface->output = wl_resource_get_user_data(output_resource); + surface->output = weston_output_from_resource(output_resource); view->output = surface->output; weston_desktop_shell_send_configure(resource, 0, surface_resource, @@ -3026,7 +3026,7 @@ desktop_shell_set_panel(struct wl_client *client, surface->committed = panel_committed; surface->committed_private = shell; weston_surface_set_label_func(surface, panel_get_label); - surface->output = wl_resource_get_user_data(output_resource); + surface->output = weston_output_from_resource(output_resource); view->output = surface->output; weston_desktop_shell_send_configure(resource, 0, surface_resource, diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c index 7368cb4..6f4565a 100644 --- a/fullscreen-shell/fullscreen-shell.c +++ b/fullscreen-shell/fullscreen-shell.c @@ -769,7 +769,7 @@ fullscreen_shell_present_surface(struct wl_client *client, } if (output_res) { - output = wl_resource_get_user_data(output_res); + output = weston_output_from_resource(output_res); fsout = fs_output_for_output(output); fs_output_set_surface(fsout, surface, method, 0, 0); } else { @@ -813,7 +813,7 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client, struct weston_seat *seat; struct fs_output *fsout; - output = wl_resource_get_user_data(output_res); + output = weston_output_from_resource(output_res); fsout = fs_output_for_output(output); if (surface_res == NULL) { diff --git a/ivi-shell/input-panel-ivi.c b/ivi-shell/input-panel-ivi.c index 57d1cb2..0008a52 100644 --- a/ivi-shell/input-panel-ivi.c +++ b/ivi-shell/input-panel-ivi.c @@ -275,7 +275,7 @@ input_panel_surface_set_toplevel(struct wl_client *client, wl_list_insert(&shell->input_panel.surfaces, &input_panel_surface->link); - input_panel_surface->output = wl_resource_get_user_data(output_resource); + input_panel_surface->output = weston_output_from_resource(output_resource); input_panel_surface->panel = 0; } diff --git a/libweston-desktop/wl-shell.c b/libweston-desktop/wl-shell.c index 399139c..66553f4 100644 --- a/libweston-desktop/wl-shell.c +++ b/libweston-desktop/wl-shell.c @@ -302,7 +302,7 @@ weston_desktop_wl_shell_surface_protocol_set_fullscreen(struct wl_client *wl_cli struct weston_output *output = NULL; if (output_resource != NULL) - output = wl_resource_get_user_data(output_resource); + output = weston_output_from_resource(output_resource); weston_desktop_wl_shell_change_state(surface, FULLSCREEN, NULL, 0, 0); weston_desktop_api_fullscreen_requested(surface->desktop, dsurface, diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c index c91c259..d7c49b1 100644 --- a/libweston-desktop/xdg-shell-v5.c +++ b/libweston-desktop/xdg-shell-v5.c @@ -553,7 +553,7 @@ weston_desktop_xdg_surface_protocol_set_fullscreen(struct wl_client *wl_client, struct weston_output *output = NULL; if (output_resource != NULL) - output = wl_resource_get_user_data(output_resource); + output = weston_output_from_resource(output_resource); weston_desktop_xdg_surface_ensure_added(surface); weston_desktop_api_fullscreen_requested(surface->desktop, dsurface, diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c index de5d3e0..dda0bf9 100644 --- a/libweston-desktop/xdg-shell-v6.c +++ b/libweston-desktop/xdg-shell-v6.c @@ -507,7 +507,7 @@ weston_desktop_xdg_toplevel_protocol_set_fullscreen(struct wl_client *wl_client, struct weston_output *output = NULL; if (output_resource != NULL) - output = wl_resource_get_user_data(output_resource); + output = weston_output_from_resource(output_resource); weston_desktop_xdg_toplevel_ensure_added(toplevel); weston_desktop_api_fullscreen_requested(toplevel->base.desktop, dsurface, diff --git a/libweston/compositor.c b/libweston/compositor.c index 296b02e..813b663 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4323,6 +4323,22 @@ bind_output(struct wl_client *client, wl_output_send_done(resource); } +/** Get the backing object of wl_output + * + * \param resource A wl_output protocol object. + * \return The backing object (user data) of a wl_resource representing a + * wl_output protocol object. + */ +WL_EXPORT struct weston_output * +weston_output_from_resource(struct wl_resource *resource) +{ + assert(wl_resource_instance_of(resource, &wl_output_interface, + &output_interface)); + + return wl_resource_get_user_data(resource); +} + + /* Move other outputs when one is resized so the space remains contiguous. */ static void weston_compositor_reflow_outputs(struct weston_compositor *compositor, diff --git a/libweston/compositor.h b/libweston/compositor.h index 442d046..769203a 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -1941,6 +1941,9 @@ weston_output_disable(struct weston_output *output); void weston_pending_output_coldplug(struct weston_compositor *compositor); +struct weston_output * +weston_output_from_resource(struct wl_resource *resource); + #ifdef __cplusplus } #endif diff --git a/tests/weston-test.c b/tests/weston-test.c index 0123e99..189fcc1 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -473,7 +473,7 @@ capture_screenshot(struct wl_client *client, struct wl_resource *buffer_resource) { struct weston_output *output = - wl_resource_get_user_data(output_resource); + weston_output_from_resource(output_resource); struct weston_buffer *buffer = weston_buffer_from_resource(buffer_resource); commit 0079a949e09816a7ae1ea0de69196c2a0e0875e7 Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Fri Mar 24 15:46:23 2017 +0200 libweston: make weston_output::connection_internal a bool It really is a boolean. Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> Reviewed-by: Armin Krezović <krezovic.ar...@gmail.com> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 10adb46..c51d24b 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -2653,7 +2653,7 @@ drm_output_enable(struct weston_output *base) find_and_parse_output_edid(b, output, output->connector); if (output->connector->connector_type == DRM_MODE_CONNECTOR_LVDS || output->connector->connector_type == DRM_MODE_CONNECTOR_eDP) - output->base.connection_internal = 1; + output->base.connection_internal = true; weston_plane_init(&output->cursor_plane, b->compositor, INT32_MIN, INT32_MIN); diff --git a/libweston/compositor.h b/libweston/compositor.h index 0be9157..442d046 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -223,7 +223,7 @@ struct weston_output { void (*set_backlight)(struct weston_output *output, uint32_t value); void (*set_dpms)(struct weston_output *output, enum dpms_enum level); - int connection_internal; + bool connection_internal; uint16_t gamma_size; void (*set_gamma)(struct weston_output *output, uint16_t size, commit 4b582c7cc088a1a363cde3f01ac2b268f9efb8d0 Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Thu Mar 30 16:04:58 2017 +0300 libweston: extend output->region lifetime It's a little awkward to try to keep the weston_output::region and weston_output::previous_damage allocate exactly only when the output is enabled. There was also a leak: weston_output_move() was calling weston_output_init_geometry() on an already allocated regions without fini in between. Fix both issues by allocating the regions in weston_output_init(), always fini/init'ing them in weston_output_init_geometry(), and fini'ing for good in weston_output_destroy(). This nicely gets rid of weston_output_enable_undo() so I do not need to try to figure out what to do with it later. Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> Reviewed-by: Armin Krezović <krezovic.ar...@gmail.com> diff --git a/libweston/compositor.c b/libweston/compositor.c index eda0434..296b02e 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4426,7 +4426,10 @@ weston_output_init_geometry(struct weston_output *output, int x, int y) output->x = x; output->y = y; + pixman_region32_fini(&output->previous_damage); pixman_region32_init(&output->previous_damage); + + pixman_region32_fini(&output->region); pixman_region32_init_rect(&output->region, x, y, output->width, output->height); @@ -4543,20 +4546,6 @@ weston_output_transform_coordinate(struct weston_output *output, *y = p.f[1] / p.f[3]; } -/** Undoes changes to an output done by weston_output_enable() - * - * \param output The weston_output object that needs the changes undone. - * - * Removes the repaint timer. - * Destroys pixman regions allocated to the output. - */ -static void -weston_output_enable_undo(struct weston_output *output) -{ - pixman_region32_fini(&output->region); - pixman_region32_fini(&output->previous_damage); -} - /** Removes output from compositor's list of enabled outputs * * \param output The weston_output object that is being removed. @@ -4703,6 +4692,9 @@ weston_output_init(struct weston_output *output, output->scale = 0; /* Can't use -1 on uint32_t and 0 is valid enum value */ output->transform = UINT32_MAX; + + pixman_region32_init(&output->previous_damage); + pixman_region32_init(&output->region); } /** Adds weston_output object to pending output list. @@ -4811,8 +4803,6 @@ weston_output_enable(struct weston_output *output) */ if (output->enable(output) < 0) { weston_log("Enabling output \"%s\" failed.\n", output->name); - - weston_output_enable_undo(output); return -1; } @@ -4864,10 +4854,8 @@ weston_output_disable(struct weston_output *output) if (output->disable(output) < 0) return; - if (output->enabled) { + if (output->enabled) weston_compositor_remove_output(output); - weston_output_enable_undo(output); - } output->destroying = 0; } @@ -4902,11 +4890,11 @@ weston_output_destroy(struct weston_output *output) { output->destroying = 1; - if (output->enabled) { + if (output->enabled) weston_compositor_remove_output(output); - weston_output_enable_undo(output); - } + pixman_region32_fini(&output->region); + pixman_region32_fini(&output->previous_damage); wl_list_remove(&output->link); free(output->name); } commit 2210ad006cb2c4851ce768f99c8a4816214fea0c Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Thu Mar 30 15:48:06 2017 +0300 libweston: move globals to weston_compositor_add_output() Move the wl_output global management into weston_compositor_add_output() and weston_compositor_remove_output(). If weston_output_enable() fails, there is no need to clean up the global and the clients will not see a wl_output come and go. Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> Reviewed-by: Armin Krezović <krezovic.ar...@gmail.com> diff --git a/libweston/compositor.c b/libweston/compositor.c index 3c6d6db..eda0434 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4472,7 +4472,8 @@ weston_output_move(struct weston_output *output, int x, int y) * Removes the output from the pending list and adds it to the compositor's * list of enabled outputs. The output created signal is emitted. * - * The output gets an internal ID assigned. + * The output gets an internal ID assigned, and the wl_output global is + * created. * * \param compositor The compositor instance. * \param output The output to be added. @@ -4501,6 +4502,10 @@ weston_compositor_add_output(struct weston_compositor *compositor, wl_list_insert(compositor->output_list.prev, &output->link); output->enabled = true; + output->global = wl_global_create(compositor->wl_display, + &wl_output_interface, 3, + output, bind_output); + wl_signal_emit(&compositor->output_created_signal, output); wl_list_for_each_safe(view, next, &compositor->view_list, link) @@ -4543,14 +4548,11 @@ weston_output_transform_coordinate(struct weston_output *output, * \param output The weston_output object that needs the changes undone. * * Removes the repaint timer. - * Destroys the Wayland global assigned to the output. * Destroys pixman regions allocated to the output. */ static void weston_output_enable_undo(struct weston_output *output) { - wl_global_destroy(output->global); - pixman_region32_fini(&output->region); pixman_region32_fini(&output->previous_damage); } @@ -4575,7 +4577,7 @@ weston_output_enable_undo(struct weston_output *output) * object that the output is being destroyed. * * - wl_output protocol objects referencing this weston_output - * are made inert. + * are made inert, and the wl_output global is removed. * * - The output's internal ID is released. * @@ -4608,6 +4610,8 @@ weston_compositor_remove_output(struct weston_output *output) wl_signal_emit(&compositor->output_destroyed_signal, output); wl_signal_emit(&output->destroy_signal, output); + wl_global_destroy(output->global); + output->global = NULL; wl_resource_for_each(resource, &output->resource_list) { wl_resource_set_destructor(resource, NULL); } @@ -4801,10 +4805,6 @@ weston_output_enable(struct weston_output *output) wl_list_init(&output->resource_list); wl_list_init(&output->feedback_list); - output->global = - wl_global_create(c->wl_display, &wl_output_interface, 3, - output, bind_output); - /* Enable the output (set up the crtc or create a * window representing the output, set up the * renderer, etc) commit 3d2d49723bda7e3e088f4dba39d59e19fb0d820d Author: Pekka Paalanen <pekka.paala...@collabora.co.uk> Date: Thu Mar 30 15:19:45 2017 +0300 libweston: move output id into add/remove_output() Move the output id management into weston_compositor_add_output() and weston_compositor_remove_output(). This is a more logical place, and works towards assimilating weston_output_enable_undo(). The output id is no longer available to the backend enable() vfuncs, but it was not used there to begin with.