From 9e20730e044532bf3f870944fb4b70d3eac570dd Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 8 Mar 2021 23:48:43 +0200 Subject: [PATCH] screen-share: Start screen sharing even if no pointer is found With commit e825fe38, we no longer display the pointer if no movement is detected, which will cause screen share to fail to start if that is the case. There could be also legitimate cases where there's no pointer, so let's allow screen share to function in those cases as well. Makes uses of previous helper methods to find a proper output to share in case we don't have an pointer. Re-uses the shell utils functions. Signed-off-by: Marius Vlad --- compositor/meson.build | 1 + compositor/screen-share.c | 18 +++++++++++------- meson.build | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/compositor/meson.build b/compositor/meson.build index 8a54ea99..427167e7 100644 --- a/compositor/meson.build +++ b/compositor/meson.build @@ -78,6 +78,7 @@ if get_option('screenshare') deps_screenshare = [ dep_libexec_weston, dep_libshared, + dep_shell_utils, dep_libweston_public, dep_libweston_private_h, # XXX: https://gitlab.freedesktop.org/wayland/weston/issues/292 dep_wayland_client, diff --git a/compositor/screen-share.c b/compositor/screen-share.c index 0c2f413d..c79bc3c4 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -47,6 +47,7 @@ #include "shared/helpers.h" #include "shared/os-compatibility.h" #include "shared/timespec-util.h" +#include "shell-utils/shell-utils.h" #include "fullscreen-shell-unstable-v1-client-protocol.h" struct shared_output { @@ -1144,16 +1145,19 @@ share_output_binding(struct weston_keyboard *keyboard, struct screen_share *ss = data; pointer = weston_seat_get_pointer(keyboard->seat); - if (!pointer) { - weston_log("Cannot pick output: Seat does not have pointer\n"); - return; + if (pointer) { + output = weston_output_find(pointer->seat->compositor, + wl_fixed_to_int(pointer->x), + wl_fixed_to_int(pointer->y)); + } else { + output = get_focused_output(keyboard->seat->compositor); + if (!output) + output = get_default_output(keyboard->seat->compositor); } - output = weston_output_find(pointer->seat->compositor, - wl_fixed_to_int(pointer->x), - wl_fixed_to_int(pointer->y)); if (!output) { - weston_log("Cannot pick output: Pointer not on any output\n"); + weston_log("Cannot pick output: Pointer not on any output, " + "or no focused/default output found\n"); return; } diff --git a/meson.build b/meson.build index 67917dea..82796740 100644 --- a/meson.build +++ b/meson.build @@ -170,8 +170,8 @@ subdir('shared') subdir('libweston') subdir('libweston-desktop') subdir('xwayland') -subdir('compositor') subdir('shell-utils') +subdir('compositor') subdir('desktop-shell') subdir('fullscreen-shell') subdir('ivi-shell')