kiosk-shell is fullscreen shell for apps that use the xdg-shell protocol. The goal is to make life easier for people shipping embedded devices with simple fullscreen shell requirements, and reduce the proliferation of desktop-shell hacks. Top level surfaces are made fullscreen, whereas dialogs are placed on top in the center of the output and retain their natural sizes. Dialogs can be moved and (un)maximized, but resizing is currently not supported. An app can be directed to a particular output by populating the "app-ids" field with the app's XDG app id, in the relevant "[output]" section in the weston config file. Fixes: #277 Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>dev
parent
ea4d13b3e3
commit
87c1679a0a
@ -0,0 +1,17 @@ |
|||||||
|
Weston kiosk-shell |
||||||
|
================== |
||||||
|
|
||||||
|
Weston's kiosk-shell is a simple shell targeted at single-app/kiosk use cases. |
||||||
|
It makes all top-level application windows fullscreen, and supports defining |
||||||
|
which applications to place on particular outputs. This is achieved with the |
||||||
|
``app-ids=`` field in the corresponding output section in weston.ini. For |
||||||
|
example: |
||||||
|
|
||||||
|
.. code-block:: ini |
||||||
|
|
||||||
|
[output] |
||||||
|
name=screen0 |
||||||
|
app-ids=org.domain.app1,com.domain.app2 |
||||||
|
|
||||||
|
To run weston with kiosk-shell set ``shell=kiosk-shell.so`` in weston.ini, or |
||||||
|
use the ``--shell=kiosk-shell.so`` command-line option. |
@ -0,0 +1,314 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 Intel Corporation |
||||||
|
* Copyright 2013 Raspberry Pi Foundation |
||||||
|
* Copyright 2011-2012,2020 Collabora, Ltd. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the "Software"), |
||||||
|
* to deal in the Software without restriction, including without limitation |
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the |
||||||
|
* Software is furnished to do so, subject to the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the next |
||||||
|
* paragraph) shall be included in all copies or substantial portions of the |
||||||
|
* Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||||
|
* DEALINGS IN THE SOFTWARE. |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "kiosk-shell-grab.h" |
||||||
|
#include "shared/helpers.h" |
||||||
|
|
||||||
|
struct kiosk_shell_grab { |
||||||
|
struct kiosk_shell_surface *shsurf; |
||||||
|
struct wl_listener shsurf_destroy_listener; |
||||||
|
|
||||||
|
struct weston_pointer_grab pointer_grab; |
||||||
|
struct weston_touch_grab touch_grab; |
||||||
|
wl_fixed_t dx, dy; |
||||||
|
bool active; |
||||||
|
}; |
||||||
|
|
||||||
|
static void |
||||||
|
kiosk_shell_grab_destroy(struct kiosk_shell_grab *shgrab); |
||||||
|
|
||||||
|
/*
|
||||||
|
* pointer_move_grab_interface |
||||||
|
*/ |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_focus(struct weston_pointer_grab *grab) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_axis(struct weston_pointer_grab *grab, |
||||||
|
const struct timespec *time, |
||||||
|
struct weston_pointer_axis_event *event) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_axis_source(struct weston_pointer_grab *grab, |
||||||
|
uint32_t source) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_frame(struct weston_pointer_grab *grab) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab, |
||||||
|
const struct timespec *time, |
||||||
|
struct weston_pointer_motion_event *event) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(pointer_grab, struct kiosk_shell_grab, pointer_grab); |
||||||
|
struct weston_pointer *pointer = pointer_grab->pointer; |
||||||
|
struct kiosk_shell_surface *shsurf = shgrab->shsurf; |
||||||
|
struct weston_surface *surface; |
||||||
|
int dx, dy; |
||||||
|
|
||||||
|
weston_pointer_move(pointer, event); |
||||||
|
|
||||||
|
if (!shsurf) |
||||||
|
return; |
||||||
|
|
||||||
|
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface); |
||||||
|
|
||||||
|
dx = wl_fixed_to_int(pointer->x + shgrab->dx); |
||||||
|
dy = wl_fixed_to_int(pointer->y + shgrab->dy); |
||||||
|
|
||||||
|
weston_view_set_position(shsurf->view, dx, dy); |
||||||
|
|
||||||
|
weston_compositor_schedule_repaint(surface->compositor); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_button(struct weston_pointer_grab *pointer_grab, |
||||||
|
const struct timespec *time, |
||||||
|
uint32_t button, uint32_t state_w) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(pointer_grab, struct kiosk_shell_grab, pointer_grab); |
||||||
|
struct weston_pointer *pointer = pointer_grab->pointer; |
||||||
|
enum wl_pointer_button_state state = state_w; |
||||||
|
|
||||||
|
if (pointer->button_count == 0 && |
||||||
|
state == WL_POINTER_BUTTON_STATE_RELEASED) |
||||||
|
kiosk_shell_grab_destroy(shgrab); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
pointer_move_grab_cancel(struct weston_pointer_grab *pointer_grab) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(pointer_grab, struct kiosk_shell_grab, pointer_grab); |
||||||
|
|
||||||
|
kiosk_shell_grab_destroy(shgrab); |
||||||
|
} |
||||||
|
|
||||||
|
static const struct weston_pointer_grab_interface pointer_move_grab_interface = { |
||||||
|
pointer_move_grab_focus, |
||||||
|
pointer_move_grab_motion, |
||||||
|
pointer_move_grab_button, |
||||||
|
pointer_move_grab_axis, |
||||||
|
pointer_move_grab_axis_source, |
||||||
|
pointer_move_grab_frame, |
||||||
|
pointer_move_grab_cancel, |
||||||
|
}; |
||||||
|
|
||||||
|
/*
|
||||||
|
* touch_move_grab_interface |
||||||
|
*/ |
||||||
|
|
||||||
|
static void |
||||||
|
touch_move_grab_down(struct weston_touch_grab *grab, |
||||||
|
const struct timespec *time, |
||||||
|
int touch_id, wl_fixed_t x, wl_fixed_t y) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
touch_move_grab_up(struct weston_touch_grab *touch_grab, |
||||||
|
const struct timespec *time, int touch_id) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(touch_grab, struct kiosk_shell_grab, touch_grab); |
||||||
|
|
||||||
|
if (touch_id == 0) |
||||||
|
shgrab->active = false; |
||||||
|
|
||||||
|
if (touch_grab->touch->num_tp == 0) |
||||||
|
kiosk_shell_grab_destroy(shgrab); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
touch_move_grab_motion(struct weston_touch_grab *touch_grab, |
||||||
|
const struct timespec *time, int touch_id, |
||||||
|
wl_fixed_t x, wl_fixed_t y) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(touch_grab, struct kiosk_shell_grab, touch_grab); |
||||||
|
struct weston_touch *touch = touch_grab->touch; |
||||||
|
struct kiosk_shell_surface *shsurf = shgrab->shsurf; |
||||||
|
struct weston_surface *surface; |
||||||
|
int dx, dy; |
||||||
|
|
||||||
|
if (!shsurf || !shgrab->active) |
||||||
|
return; |
||||||
|
|
||||||
|
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface); |
||||||
|
|
||||||
|
dx = wl_fixed_to_int(touch->grab_x + shgrab->dx); |
||||||
|
dy = wl_fixed_to_int(touch->grab_y + shgrab->dy); |
||||||
|
|
||||||
|
weston_view_set_position(shsurf->view, dx, dy); |
||||||
|
|
||||||
|
weston_compositor_schedule_repaint(surface->compositor); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
touch_move_grab_frame(struct weston_touch_grab *grab) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
touch_move_grab_cancel(struct weston_touch_grab *touch_grab) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(touch_grab, struct kiosk_shell_grab, touch_grab); |
||||||
|
|
||||||
|
kiosk_shell_grab_destroy(shgrab); |
||||||
|
} |
||||||
|
|
||||||
|
static const struct weston_touch_grab_interface touch_move_grab_interface = { |
||||||
|
touch_move_grab_down, |
||||||
|
touch_move_grab_up, |
||||||
|
touch_move_grab_motion, |
||||||
|
touch_move_grab_frame, |
||||||
|
touch_move_grab_cancel, |
||||||
|
}; |
||||||
|
|
||||||
|
/*
|
||||||
|
* kiosk_shell_grab |
||||||
|
*/ |
||||||
|
|
||||||
|
static void |
||||||
|
kiosk_shell_grab_handle_shsurf_destroy(struct wl_listener *listener, void *data) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab = |
||||||
|
container_of(listener, struct kiosk_shell_grab, |
||||||
|
shsurf_destroy_listener); |
||||||
|
|
||||||
|
shgrab->shsurf = NULL; |
||||||
|
} |
||||||
|
|
||||||
|
static struct kiosk_shell_grab * |
||||||
|
kiosk_shell_grab_create(struct kiosk_shell_surface *shsurf) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab; |
||||||
|
|
||||||
|
shgrab = zalloc(sizeof *shgrab); |
||||||
|
if (!shgrab) |
||||||
|
return NULL; |
||||||
|
|
||||||
|
shgrab->shsurf = shsurf; |
||||||
|
shgrab->shsurf_destroy_listener.notify = |
||||||
|
kiosk_shell_grab_handle_shsurf_destroy; |
||||||
|
wl_signal_add(&shsurf->destroy_signal, |
||||||
|
&shgrab->shsurf_destroy_listener); |
||||||
|
|
||||||
|
shsurf->grabbed = true; |
||||||
|
|
||||||
|
return shgrab; |
||||||
|
} |
||||||
|
|
||||||
|
enum kiosk_shell_grab_result |
||||||
|
kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf, |
||||||
|
struct weston_pointer *pointer) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab; |
||||||
|
|
||||||
|
if (!shsurf) |
||||||
|
return KIOSK_SHELL_GRAB_RESULT_ERROR; |
||||||
|
|
||||||
|
if (shsurf->grabbed || |
||||||
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) || |
||||||
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface)) |
||||||
|
return KIOSK_SHELL_GRAB_RESULT_IGNORED; |
||||||
|
|
||||||
|
shgrab = kiosk_shell_grab_create(shsurf); |
||||||
|
if (!shgrab) |
||||||
|
return KIOSK_SHELL_GRAB_RESULT_ERROR; |
||||||
|
|
||||||
|
shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.x) - |
||||||
|
pointer->grab_x; |
||||||
|
shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.y) - |
||||||
|
pointer->grab_y; |
||||||
|
shgrab->active = true; |
||||||
|
|
||||||
|
weston_seat_break_desktop_grabs(pointer->seat); |
||||||
|
|
||||||
|
shgrab->pointer_grab.interface = &pointer_move_grab_interface; |
||||||
|
weston_pointer_start_grab(pointer, &shgrab->pointer_grab); |
||||||
|
|
||||||
|
return KIOSK_SHELL_GRAB_RESULT_OK; |
||||||
|
} |
||||||
|
|
||||||
|
enum kiosk_shell_grab_result |
||||||
|
kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf, |
||||||
|
struct weston_touch *touch) |
||||||
|
{ |
||||||
|
struct kiosk_shell_grab *shgrab; |
||||||
|
|
||||||
|
if (!shsurf) |
||||||
|
return KIOSK_SHELL_GRAB_RESULT_ERROR; |
||||||
|
|
||||||
|
if (shsurf->grabbed || |
||||||
|
weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) || |
||||||
|
weston_desktop_surface_get_maximized(shsurf->desktop_surface)) |
||||||
|
return KIOSK_SHELL_GRAB_RESULT_IGNORED; |
||||||
|
|
||||||
|
shgrab = kiosk_shell_grab_create(shsurf); |
||||||
|
if (!shgrab) |
||||||
|
return KIOSK_SHELL_GRAB_RESULT_ERROR; |
||||||
|
|
||||||
|
shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.x) - |
||||||
|
touch->grab_x; |
||||||
|
shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.y) - |
||||||
|
touch->grab_y; |
||||||
|
shgrab->active = true; |
||||||
|
|
||||||
|
weston_seat_break_desktop_grabs(touch->seat); |
||||||
|
|
||||||
|
shgrab->touch_grab.interface = &touch_move_grab_interface; |
||||||
|
weston_touch_start_grab(touch, &shgrab->touch_grab); |
||||||
|
|
||||||
|
return KIOSK_SHELL_GRAB_RESULT_OK; |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
kiosk_shell_grab_destroy(struct kiosk_shell_grab *shgrab) |
||||||
|
{ |
||||||
|
if (shgrab->shsurf) { |
||||||
|
wl_list_remove(&shgrab->shsurf_destroy_listener.link); |
||||||
|
shgrab->shsurf->grabbed = false; |
||||||
|
} |
||||||
|
|
||||||
|
if (shgrab->pointer_grab.pointer) |
||||||
|
weston_pointer_end_grab(shgrab->pointer_grab.pointer); |
||||||
|
else if (shgrab->touch_grab.touch) |
||||||
|
weston_touch_end_grab(shgrab->touch_grab.touch); |
||||||
|
|
||||||
|
free(shgrab); |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
/*
|
||||||
|
* Copyright © 2020 Collabora, Ltd. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the "Software"), |
||||||
|
* to deal in the Software without restriction, including without limitation |
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the |
||||||
|
* Software is furnished to do so, subject to the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the next |
||||||
|
* paragraph) shall be included in all copies or substantial portions of the |
||||||
|
* Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||||
|
* DEALINGS IN THE SOFTWARE. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef WESTON_KIOSK_SHELL_GRAB_H |
||||||
|
#define WESTON_KIOSK_SHELL_GRAB_H |
||||||
|
|
||||||
|
#include "kiosk-shell.h" |
||||||
|
|
||||||
|
enum kiosk_shell_grab_result { |
||||||
|
KIOSK_SHELL_GRAB_RESULT_OK, |
||||||
|
KIOSK_SHELL_GRAB_RESULT_IGNORED, |
||||||
|
KIOSK_SHELL_GRAB_RESULT_ERROR, |
||||||
|
}; |
||||||
|
|
||||||
|
enum kiosk_shell_grab_result |
||||||
|
kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf, |
||||||
|
struct weston_pointer *pointer); |
||||||
|
|
||||||
|
enum kiosk_shell_grab_result |
||||||
|
kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf, |
||||||
|
struct weston_touch *touch); |
||||||
|
|
||||||
|
#endif /* WESTON_KIOSK_SHELL_GRAB_H */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,91 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2020 Collabora, Ltd. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the "Software"), |
||||||
|
* to deal in the Software without restriction, including without limitation |
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the |
||||||
|
* Software is furnished to do so, subject to the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the next |
||||||
|
* paragraph) shall be included in all copies or substantial portions of the |
||||||
|
* Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||||
|
* DEALINGS IN THE SOFTWARE. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef WESTON_KIOSK_SHELL_H |
||||||
|
#define WESTON_KIOSK_SHELL_H |
||||||
|
|
||||||
|
#include <libweston-desktop/libweston-desktop.h> |
||||||
|
#include <libweston/libweston.h> |
||||||
|
|
||||||
|
struct kiosk_shell { |
||||||
|
struct weston_compositor *compositor; |
||||||
|
struct weston_desktop *desktop; |
||||||
|
|
||||||
|
struct wl_listener destroy_listener; |
||||||
|
struct wl_listener output_created_listener; |
||||||
|
struct wl_listener output_resized_listener; |
||||||
|
struct wl_listener output_moved_listener; |
||||||
|
struct wl_listener seat_created_listener; |
||||||
|
|
||||||
|
struct weston_layer background_layer; |
||||||
|
struct weston_layer normal_layer; |
||||||
|
|
||||||
|
struct wl_list output_list; |
||||||
|
}; |
||||||
|
|
||||||
|
struct kiosk_shell_surface { |
||||||
|
struct weston_desktop_surface *desktop_surface; |
||||||
|
struct weston_view *view; |
||||||
|
|
||||||
|
struct kiosk_shell *shell; |
||||||
|
|
||||||
|
struct weston_output *output; |
||||||
|
struct wl_listener output_destroy_listener; |
||||||
|
|
||||||
|
struct wl_signal destroy_signal; |
||||||
|
struct wl_listener parent_destroy_listener; |
||||||
|
struct kiosk_shell_surface *parent; |
||||||
|
|
||||||
|
int focus_count; |
||||||
|
|
||||||
|
int32_t last_width, last_height; |
||||||
|
bool grabbed; |
||||||
|
|
||||||
|
struct { |
||||||
|
bool is_set; |
||||||
|
int32_t x; |
||||||
|
int32_t y; |
||||||
|
} xwayland; |
||||||
|
}; |
||||||
|
|
||||||
|
struct kiosk_shell_seat { |
||||||
|
struct weston_seat *seat; |
||||||
|
struct wl_listener seat_destroy_listener; |
||||||
|
struct weston_surface *focused_surface; |
||||||
|
|
||||||
|
struct wl_listener caps_changed_listener; |
||||||
|
struct wl_listener keyboard_focus_listener; |
||||||
|
}; |
||||||
|
|
||||||
|
struct kiosk_shell_output { |
||||||
|
struct weston_output *output; |
||||||
|
struct wl_listener output_destroy_listener; |
||||||
|
struct weston_view *background_view; |
||||||
|
|
||||||
|
struct kiosk_shell *shell; |
||||||
|
struct wl_list link; |
||||||
|
|
||||||
|
char *app_ids; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif /* WESTON_KIOSK_SHELL_H */ |
@ -0,0 +1,29 @@ |
|||||||
|
if get_option('shell-kiosk') |
||||||
|
srcs_shell_kiosk = [ |
||||||
|
'kiosk-shell.c', |
||||||
|
'kiosk-shell-grab.c', |
||||||
|
'util.c', |
||||||
|
weston_desktop_shell_server_protocol_h, |
||||||
|
weston_desktop_shell_protocol_c, |
||||||
|
input_method_unstable_v1_server_protocol_h, |
||||||
|
input_method_unstable_v1_protocol_c, |
||||||
|
] |
||||||
|
deps_shell_kiosk = [ |
||||||
|
dep_libm, |
||||||
|
dep_libexec_weston, |
||||||
|
dep_libshared, |
||||||
|
dep_lib_desktop, |
||||||
|
dep_libweston_public, |
||||||
|
] |
||||||
|
plugin_shell_kiosk = shared_library( |
||||||
|
'kiosk-shell', |
||||||
|
srcs_shell_kiosk, |
||||||
|
include_directories: common_inc, |
||||||
|
dependencies: deps_shell_kiosk, |
||||||
|
name_prefix: '', |
||||||
|
install: true, |
||||||
|
install_dir: dir_module_weston, |
||||||
|
install_rpath: '$ORIGIN' |
||||||
|
) |
||||||
|
env_modmap += 'kiosk-shell.so=@0@;'.format(plugin_shell_kiosk.full_path()) |
||||||
|
endif |
@ -0,0 +1,168 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 Intel Corporation |
||||||
|
* Copyright 2013 Raspberry Pi Foundation |
||||||
|
* Copyright 2011-2012,2020 Collabora, Ltd. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the "Software"), |
||||||
|
* to deal in the Software without restriction, including without limitation |
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the |
||||||
|
* Software is furnished to do so, subject to the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the next |
||||||
|
* paragraph) shall be included in all copies or substantial portions of the |
||||||
|
* Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||||
|
* DEALINGS IN THE SOFTWARE. |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Helper functions for kiosk-shell */ |
||||||
|
|
||||||
|
/* TODO: These functions are useful to many shells, and, in fact,
|
||||||
|
* much of content in this file was copied from desktop-shell. We should |
||||||
|
* create a shared shell utility collection to deduplicate this code. */ |
||||||
|
|
||||||
|
#include "util.h" |
||||||
|
#include "shared/helpers.h" |
||||||
|
#include <libweston/libweston.h> |
||||||
|
|
||||||
|
struct weston_output * |
||||||
|
get_default_output(struct weston_compositor *compositor) |
||||||
|
{ |
||||||
|
if (wl_list_empty(&compositor->output_list)) |
||||||
|
return NULL; |
||||||
|
|
||||||
|
return container_of(compositor->output_list.next, |
||||||
|
struct weston_output, link); |
||||||
|
} |
||||||
|
|
||||||
|
struct weston_output * |
||||||
|
get_focused_output(struct weston_compositor *compositor) |
||||||
|
{ |
||||||
|
struct weston_seat *seat; |
||||||
|
struct weston_output *output = NULL; |
||||||
|
|
||||||
|
wl_list_for_each(seat, &compositor->seat_list, link) { |
||||||
|
struct weston_touch *touch = weston_seat_get_touch(seat); |
||||||
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat); |
||||||
|
struct weston_keyboard *keyboard = |
||||||
|
weston_seat_get_keyboard(seat); |
||||||
|
|
||||||
|
/* Priority has touch focus, then pointer and
|
||||||
|
* then keyboard focus. We should probably have |
||||||
|
* three for loops and check first for touch, |
||||||
|
* then for pointer, etc. but unless somebody has some |
||||||
|
* objections, I think this is sufficient. */ |
||||||
|
if (touch && touch->focus) |
||||||
|
output = touch->focus->output; |
||||||
|
else if (pointer && pointer->focus) |
||||||
|
output = pointer->focus->output; |
||||||
|
else if (keyboard && keyboard->focus) |
||||||
|
output = keyboard->focus->output; |
||||||
|
|
||||||
|
if (output) |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
return output; |
||||||
|
} |
||||||
|
|
||||||
|
/* This is a copy of the same function from desktop-shell.
|
||||||
|
* TODO: Fix this function to take into account nested subsurfaces. */ |
||||||
|
static void |
||||||
|
surface_subsurfaces_boundingbox(struct weston_surface *surface, int32_t *x, |
||||||
|
int32_t *y, int32_t *w, int32_t *h) { |
||||||
|
pixman_region32_t region; |
||||||
|
pixman_box32_t *box; |
||||||
|
struct weston_subsurface *subsurface; |
||||||
|
|
||||||
|
pixman_region32_init_rect(®ion, 0, 0, |
||||||
|
surface->width, |
||||||
|
surface->height); |
||||||
|
|
||||||
|
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) { |
||||||
|
pixman_region32_union_rect(®ion, ®ion, |
||||||
|
subsurface->position.x, |
||||||
|
subsurface->position.y, |
||||||
|
subsurface->surface->width, |
||||||
|
subsurface->surface->height); |
||||||
|
} |
||||||
|
|
||||||
|
box = pixman_region32_extents(®ion); |
||||||
|
if (x) |
||||||
|
*x = box->x1; |
||||||
|
if (y) |
||||||
|
*y = box->y1; |
||||||
|
if (w) |
||||||
|
*w = box->x2 - box->x1; |
||||||
|
if (h) |
||||||
|
*h = box->y2 - box->y1; |
||||||
|
|
||||||
|
pixman_region32_fini(®ion); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
center_on_output(struct weston_view *view, struct weston_output *output) |
||||||
|
{ |
||||||
|
int32_t surf_x, surf_y, width, height; |
||||||
|
float x, y; |
||||||
|
|
||||||
|
if (!output) { |
||||||
|
weston_view_set_position(view, 0, 0); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
surface_subsurfaces_boundingbox(view->surface, &surf_x, &surf_y, &width, &height); |
||||||
|
|
||||||
|
x = output->x + (output->width - width) / 2 - surf_x / 2; |
||||||
|
y = output->y + (output->height - height) / 2 - surf_y / 2; |
||||||
|
|
||||||
|
weston_view_set_position(view, x, y); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
colored_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
struct weston_view * |
||||||
|
create_colored_surface(struct weston_compositor *compositor, |
||||||
|
float r, float g, float b, |
||||||
|
float x, float y, int w, int h) |
||||||
|
{ |
||||||
|
struct weston_surface *surface = NULL; |
||||||
|
struct weston_view *view; |
||||||
|
|
||||||
|
surface = weston_surface_create(compositor); |
||||||
|
if (surface == NULL) { |
||||||
|
weston_log("no memory\n"); |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
view = weston_view_create(surface); |
||||||
|
if (surface == NULL) { |
||||||
|
weston_log("no memory\n"); |
||||||
|
weston_surface_destroy(surface); |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
surface->committed = colored_surface_committed; |
||||||
|
surface->committed_private = NULL; |
||||||
|
|
||||||
|
weston_surface_set_color(surface, r, g, b, 1.0); |
||||||
|
pixman_region32_fini(&surface->opaque); |
||||||
|
pixman_region32_init_rect(&surface->opaque, 0, 0, w, h); |
||||||
|
pixman_region32_fini(&surface->input); |
||||||
|
pixman_region32_init_rect(&surface->input, 0, 0, w, h); |
||||||
|
|
||||||
|
weston_surface_set_size(surface, w, h); |
||||||
|
weston_view_set_position(view, x, y); |
||||||
|
|
||||||
|
return view; |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 Intel Corporation |
||||||
|
* Copyright 2013 Raspberry Pi Foundation |
||||||
|
* Copyright 2011-2012,2020 Collabora, Ltd. |
||||||
|
* |
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a |
||||||
|
* copy of this software and associated documentation files (the "Software"), |
||||||
|
* to deal in the Software without restriction, including without limitation |
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the |
||||||
|
* Software is furnished to do so, subject to the following conditions: |
||||||
|
* |
||||||
|
* The above copyright notice and this permission notice (including the next |
||||||
|
* paragraph) shall be included in all copies or substantial portions of the |
||||||
|
* Software. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||||
|
* DEALINGS IN THE SOFTWARE. |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Helper functions adapted from desktop-shell */ |
||||||
|
|
||||||
|
#include <stdint.h> |
||||||
|
|
||||||
|
struct weston_compositor; |
||||||
|
struct weston_layer; |
||||||
|
struct weston_output; |
||||||
|
struct weston_surface; |
||||||
|
struct weston_view; |
||||||
|
|
||||||
|
struct weston_output * |
||||||
|
get_default_output(struct weston_compositor *compositor); |
||||||
|
|
||||||
|
struct weston_output * |
||||||
|
get_focused_output(struct weston_compositor *compositor); |
||||||
|
|
||||||
|
void |
||||||
|
center_on_output(struct weston_view *view, struct weston_output *output); |
||||||
|
|
||||||
|
struct weston_view * |
||||||
|
create_colored_surface(struct weston_compositor *compositor, |
||||||
|
float r, float g, float b, |
||||||
|
float x, float y, int w, int h); |
Loading…
Reference in new issue