2014-10-12 01:24:25 +04:00
|
|
|
/*
|
|
|
|
* Copyright © 2010-2011 Intel Corporation
|
|
|
|
* Copyright © 2008-2011 Kristian Høgsberg
|
2022-03-16 14:25:13 +03:00
|
|
|
* Copyright © 2012-2018,2022 Collabora, Ltd.
|
2016-05-10 23:47:49 +03:00
|
|
|
* Copyright © 2010-2011 Benjamin Franzke
|
|
|
|
* Copyright © 2013 Jason Ekstrand
|
2018-04-19 14:20:01 +03:00
|
|
|
* Copyright © 2017, 2018 General Electric Company
|
2014-10-12 01:24:25 +04:00
|
|
|
*
|
|
|
|
* 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 "config.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dlfcn.h>
|
2016-07-19 14:16:27 +03:00
|
|
|
#include <stdint.h>
|
2014-10-12 01:24:25 +04:00
|
|
|
#include <string.h>
|
2022-03-16 14:25:13 +03:00
|
|
|
#include <strings.h>
|
2014-10-12 01:24:25 +04:00
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
2016-06-02 21:48:10 +03:00
|
|
|
#include <sys/socket.h>
|
2016-06-02 21:48:12 +03:00
|
|
|
#include <libinput.h>
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
#include <libevdev/libevdev.h>
|
2019-06-10 13:02:03 +03:00
|
|
|
#include <linux/input.h>
|
2016-06-02 21:48:13 +03:00
|
|
|
#include <sys/time.h>
|
2016-06-02 21:48:14 +03:00
|
|
|
#include <linux/limits.h>
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2016-06-02 21:48:14 +03:00
|
|
|
#include "weston.h"
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
2019-04-05 16:09:45 +03:00
|
|
|
#include "shared/os-compatibility.h"
|
|
|
|
#include "shared/helpers.h"
|
2022-07-12 19:19:28 +03:00
|
|
|
#include "shared/process-util.h"
|
2019-04-05 16:09:45 +03:00
|
|
|
#include "shared/string-helpers.h"
|
2023-05-01 17:31:56 +03:00
|
|
|
#include "shared/xalloc.h"
|
2014-10-12 01:24:25 +04:00
|
|
|
#include "git-version.h"
|
2019-04-04 15:41:02 +03:00
|
|
|
#include <libweston/version.h>
|
2016-06-02 21:48:10 +03:00
|
|
|
#include "weston.h"
|
2022-03-16 14:25:13 +03:00
|
|
|
#include "weston-private.h"
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2019-03-29 17:39:12 +03:00
|
|
|
#include <libweston/backend-drm.h>
|
|
|
|
#include <libweston/backend-headless.h>
|
2021-05-09 17:52:36 +03:00
|
|
|
#include <libweston/backend-pipewire.h>
|
2019-03-29 17:39:12 +03:00
|
|
|
#include <libweston/backend-rdp.h>
|
2019-09-22 20:40:04 +03:00
|
|
|
#include <libweston/backend-vnc.h>
|
2019-03-29 17:39:12 +03:00
|
|
|
#include <libweston/backend-x11.h>
|
|
|
|
#include <libweston/backend-wayland.h>
|
2019-03-29 18:14:29 +03:00
|
|
|
#include <libweston/windowed-output-api.h>
|
2019-06-21 22:49:18 +03:00
|
|
|
#include <libweston/weston-log.h>
|
2020-08-28 16:59:36 +03:00
|
|
|
#include <libweston/remoting-plugin.h>
|
|
|
|
#include <libweston/pipewire-plugin.h>
|
2016-05-10 23:47:49 +03:00
|
|
|
|
|
|
|
#define WINDOW_TITLE "Weston Compositor"
|
2019-06-24 13:27:44 +03:00
|
|
|
/* flight recorder size (in bytes) */
|
|
|
|
#define DEFAULT_FLIGHT_REC_SIZE (5 * 1024 * 1024)
|
2021-09-23 22:06:57 +03:00
|
|
|
#define DEFAULT_FLIGHT_REC_SCOPES "log,drm-backend"
|
2016-04-16 06:28:32 +03:00
|
|
|
|
2016-09-30 15:11:04 +03:00
|
|
|
struct wet_output_config {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int32_t scale;
|
|
|
|
uint32_t transform;
|
|
|
|
};
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
struct wet_compositor;
|
2017-11-03 10:56:05 +03:00
|
|
|
struct wet_layoutput;
|
2017-08-17 13:10:28 +03:00
|
|
|
|
|
|
|
struct wet_head_tracker {
|
|
|
|
struct wl_listener head_destroy_listener;
|
|
|
|
};
|
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
/** User data for each weston_output */
|
|
|
|
struct wet_output {
|
|
|
|
struct weston_output *output;
|
|
|
|
struct wl_listener output_destroy_listener;
|
|
|
|
struct wet_layoutput *layoutput;
|
|
|
|
struct wl_list link; /**< in wet_layoutput::output_list */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_CLONE_HEADS 16
|
|
|
|
|
|
|
|
struct wet_head_array {
|
|
|
|
struct weston_head *heads[MAX_CLONE_HEADS]; /**< heads to add */
|
|
|
|
unsigned n; /**< the number of heads */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** A layout output
|
|
|
|
*
|
|
|
|
* Contains wet_outputs that are all clones (independent CRTCs).
|
|
|
|
* Stores output layout information in the future.
|
|
|
|
*/
|
|
|
|
struct wet_layoutput {
|
|
|
|
struct wet_compositor *compositor;
|
|
|
|
struct wl_list compositor_link; /**< in wet_compositor::layoutput_list */
|
|
|
|
struct wl_list output_list; /**< wet_output::link */
|
|
|
|
char *name;
|
|
|
|
struct weston_config_section *section;
|
|
|
|
struct wet_head_array add; /**< tmp: heads to add as clones */
|
|
|
|
};
|
|
|
|
|
2023-05-31 15:09:48 +03:00
|
|
|
enum require_outputs {
|
|
|
|
REQUIRE_OUTPUTS_ALL_FOUND,
|
|
|
|
REQUIRE_OUTPUTS_ANY,
|
|
|
|
REQUIRE_OUTPUTS_NONE,
|
|
|
|
};
|
|
|
|
|
2016-08-01 19:51:46 +03:00
|
|
|
struct wet_compositor {
|
2017-11-02 16:38:24 +03:00
|
|
|
struct weston_compositor *compositor;
|
2016-08-01 19:51:46 +03:00
|
|
|
struct weston_config *config;
|
2016-09-30 15:11:04 +03:00
|
|
|
struct wet_output_config *parsed_options;
|
2016-10-10 00:48:17 +03:00
|
|
|
bool drm_use_current_mode;
|
2017-08-17 13:10:28 +03:00
|
|
|
struct wl_listener heads_changed_listener;
|
|
|
|
int (*simple_output_configure)(struct weston_output *output);
|
|
|
|
bool init_failed;
|
2017-11-03 10:56:05 +03:00
|
|
|
struct wl_list layoutput_list; /**< wet_layoutput::compositor_link */
|
2021-06-29 20:33:04 +03:00
|
|
|
struct wl_list child_process_list;
|
2021-06-24 06:50:53 +03:00
|
|
|
pid_t autolaunch_pid;
|
|
|
|
bool autolaunch_watch;
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
bool use_color_manager;
|
2022-09-30 17:02:02 +03:00
|
|
|
struct wl_listener screenshot_auth;
|
2023-05-31 15:09:48 +03:00
|
|
|
enum require_outputs require_outputs;
|
2016-08-01 19:51:46 +03:00
|
|
|
};
|
|
|
|
|
2016-06-02 21:48:13 +03:00
|
|
|
static FILE *weston_logfile = NULL;
|
2019-04-17 13:05:38 +03:00
|
|
|
static struct weston_log_scope *log_scope;
|
|
|
|
static struct weston_log_scope *protocol_scope;
|
2016-06-02 21:48:13 +03:00
|
|
|
static int cached_tm_mday = -1;
|
|
|
|
|
|
|
|
static void
|
|
|
|
custom_handler(const char *fmt, va_list arg)
|
|
|
|
{
|
compositor: Fix some warning when passing debugoptimized to meson
Increase the buf size such it can accomodate sufficiently large local
buffers. Spotted whilst looking for something else.
../compositor/main.c:157:22: warning: ‘%s’ directive output may be
truncated writing up to 511 bytes into a region of size 128
[-Wformat-truncation=]
157 | snprintf(buf, len, "%s[%s.%03li]", datestr,
| ^~ ~~~~~~~
../compositor/main.c:157:21: note: directive argument in the range
[-9223372036854775, 9223372036854775]
157 | snprintf(buf, len, "%s[%s.%03li]", datestr,
| ^~~~~~~~~~~~~~
../compositor/main.c:157:2: note: ‘snprintf’ output between 7 and 659
bytes into a destination of size 128
157 | snprintf(buf, len, "%s[%s.%03li]", datestr,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158 | timestr, (tv.tv_usec / 1000));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-13 12:40:26 +03:00
|
|
|
char timestr[512];
|
2017-10-12 14:18:11 +03:00
|
|
|
|
2019-04-17 13:47:06 +03:00
|
|
|
weston_log_scope_printf(log_scope, "%s libwayland: ",
|
2019-08-06 11:52:57 +03:00
|
|
|
weston_log_timestamp(timestr,
|
2022-03-09 02:29:55 +03:00
|
|
|
sizeof(timestr), &cached_tm_mday));
|
2019-04-17 13:47:06 +03:00
|
|
|
weston_log_scope_vprintf(log_scope, fmt, arg);
|
2016-06-02 21:48:13 +03:00
|
|
|
}
|
|
|
|
|
2020-05-28 18:45:57 +03:00
|
|
|
static bool
|
2016-06-02 21:48:13 +03:00
|
|
|
weston_log_file_open(const char *filename)
|
|
|
|
{
|
|
|
|
wl_log_set_handler_server(custom_handler);
|
|
|
|
|
|
|
|
if (filename != NULL) {
|
|
|
|
weston_logfile = fopen(filename, "a");
|
2020-05-28 18:45:57 +03:00
|
|
|
if (weston_logfile) {
|
2016-06-02 21:48:13 +03:00
|
|
|
os_fd_set_cloexec(fileno(weston_logfile));
|
2020-05-28 18:45:57 +03:00
|
|
|
} else {
|
2020-05-28 17:28:08 +03:00
|
|
|
fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
|
2020-05-28 18:45:57 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-06-02 21:48:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_logfile == NULL)
|
|
|
|
weston_logfile = stderr;
|
|
|
|
else
|
|
|
|
setvbuf(weston_logfile, NULL, _IOLBF, 256);
|
2020-05-28 18:45:57 +03:00
|
|
|
|
|
|
|
return true;
|
2016-06-02 21:48:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_log_file_close(void)
|
|
|
|
{
|
|
|
|
if ((weston_logfile != stderr) && (weston_logfile != NULL))
|
|
|
|
fclose(weston_logfile);
|
|
|
|
weston_logfile = stderr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vlog(const char *fmt, va_list ap)
|
|
|
|
{
|
2019-11-01 15:28:22 +03:00
|
|
|
const char *oom = "Out of memory";
|
2017-10-12 14:18:11 +03:00
|
|
|
char timestr[128];
|
2019-08-06 17:38:40 +03:00
|
|
|
int len = 0;
|
2019-11-01 15:28:22 +03:00
|
|
|
char *str;
|
2017-10-12 14:18:11 +03:00
|
|
|
|
2019-04-17 13:47:06 +03:00
|
|
|
if (weston_log_scope_is_enabled(log_scope)) {
|
2019-11-01 15:28:22 +03:00
|
|
|
int len_va;
|
|
|
|
char *log_timestamp = weston_log_timestamp(timestr,
|
2022-03-09 02:29:55 +03:00
|
|
|
sizeof(timestr),
|
|
|
|
&cached_tm_mday);
|
2019-11-01 15:28:22 +03:00
|
|
|
len_va = vasprintf(&str, fmt, ap);
|
|
|
|
if (len_va >= 0) {
|
|
|
|
len = weston_log_scope_printf(log_scope, "%s %s",
|
|
|
|
log_timestamp, str);
|
|
|
|
free(str);
|
|
|
|
} else {
|
|
|
|
len = weston_log_scope_printf(log_scope, "%s %s",
|
|
|
|
log_timestamp, oom);
|
|
|
|
}
|
2017-10-12 14:18:11 +03:00
|
|
|
}
|
2016-06-02 21:48:13 +03:00
|
|
|
|
2019-08-06 17:38:40 +03:00
|
|
|
return len;
|
2016-06-02 21:48:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vlog_continue(const char *fmt, va_list argp)
|
|
|
|
{
|
2019-08-06 17:38:40 +03:00
|
|
|
return weston_log_scope_vprintf(log_scope, fmt, argp);
|
2016-06-02 21:48:13 +03:00
|
|
|
}
|
|
|
|
|
2017-10-12 14:18:15 +03:00
|
|
|
static const char *
|
|
|
|
get_next_argument(const char *signature, char* type)
|
|
|
|
{
|
|
|
|
for(; *signature; ++signature) {
|
|
|
|
switch(*signature) {
|
|
|
|
case 'i':
|
|
|
|
case 'u':
|
|
|
|
case 'f':
|
|
|
|
case 's':
|
|
|
|
case 'o':
|
|
|
|
case 'n':
|
|
|
|
case 'a':
|
|
|
|
case 'h':
|
|
|
|
*type = *signature;
|
|
|
|
return signature + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*type = '\0';
|
|
|
|
return signature;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
protocol_log_fn(void *user_data,
|
|
|
|
enum wl_protocol_logger_type direction,
|
|
|
|
const struct wl_protocol_logger_message *message)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
char *logstr;
|
|
|
|
size_t logsize;
|
|
|
|
char timestr[128];
|
|
|
|
struct wl_resource *res = message->resource;
|
2022-02-07 12:26:03 +03:00
|
|
|
struct wl_client *client = wl_resource_get_client(res);
|
|
|
|
pid_t pid = 0;
|
2017-10-12 14:18:15 +03:00
|
|
|
const char *signature = message->message->signature;
|
|
|
|
int i;
|
|
|
|
char type;
|
|
|
|
|
2019-04-17 13:47:06 +03:00
|
|
|
if (!weston_log_scope_is_enabled(protocol_scope))
|
2017-10-12 14:18:15 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
fp = open_memstream(&logstr, &logsize);
|
|
|
|
if (!fp)
|
|
|
|
return;
|
|
|
|
|
2022-02-07 12:26:03 +03:00
|
|
|
wl_client_get_credentials(client, &pid, NULL, NULL);
|
|
|
|
|
2019-04-17 13:47:06 +03:00
|
|
|
weston_log_scope_timestamp(protocol_scope,
|
2017-10-12 14:18:15 +03:00
|
|
|
timestr, sizeof timestr);
|
|
|
|
fprintf(fp, "%s ", timestr);
|
2022-02-07 12:26:03 +03:00
|
|
|
fprintf(fp, "client %p (PID %d) %s ", client, pid,
|
2017-10-12 14:18:15 +03:00
|
|
|
direction == WL_PROTOCOL_LOGGER_REQUEST ? "rq" : "ev");
|
|
|
|
fprintf(fp, "%s@%u.%s(",
|
|
|
|
wl_resource_get_class(res),
|
|
|
|
wl_resource_get_id(res),
|
|
|
|
message->message->name);
|
|
|
|
|
|
|
|
for (i = 0; i < message->arguments_count; i++) {
|
|
|
|
signature = get_next_argument(signature, &type);
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case 'u':
|
|
|
|
fprintf(fp, "%u", message->arguments[i].u);
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
fprintf(fp, "%d", message->arguments[i].i);
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
fprintf(fp, "%f",
|
|
|
|
wl_fixed_to_double(message->arguments[i].f));
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
fprintf(fp, "\"%s\"", message->arguments[i].s);
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
if (message->arguments[i].o) {
|
|
|
|
struct wl_resource* resource;
|
|
|
|
resource = (struct wl_resource*) message->arguments[i].o;
|
|
|
|
fprintf(fp, "%s@%u",
|
|
|
|
wl_resource_get_class(resource),
|
|
|
|
wl_resource_get_id(resource));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf(fp, "nil");
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
fprintf(fp, "new id %s@",
|
|
|
|
(message->message->types[i]) ?
|
|
|
|
message->message->types[i]->name :
|
|
|
|
"[unknown]");
|
|
|
|
if (message->arguments[i].n != 0)
|
|
|
|
fprintf(fp, "%u", message->arguments[i].n);
|
|
|
|
else
|
|
|
|
fprintf(fp, "nil");
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
fprintf(fp, "array");
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
fprintf(fp, "fd %d", message->arguments[i].h);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, ")\n");
|
|
|
|
|
|
|
|
if (fclose(fp) == 0)
|
2019-04-17 13:47:06 +03:00
|
|
|
weston_log_scope_write(protocol_scope, logstr, logsize);
|
2017-10-12 14:18:15 +03:00
|
|
|
|
|
|
|
free(logstr);
|
|
|
|
}
|
|
|
|
|
2021-06-29 20:33:04 +03:00
|
|
|
static struct wet_compositor *
|
|
|
|
to_wet_compositor(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
return weston_compositor_get_user_data(compositor);
|
|
|
|
}
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2023-05-01 20:50:31 +03:00
|
|
|
WL_EXPORT void
|
|
|
|
wet_process_destroy(struct wet_process *process, int status, bool call_cleanup)
|
|
|
|
{
|
|
|
|
wl_list_remove(&process->link);
|
|
|
|
if (call_cleanup && process->cleanup)
|
|
|
|
process->cleanup(process, status, process->cleanup_data);
|
|
|
|
free(process->path);
|
|
|
|
free(process);
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
static int
|
|
|
|
sigchld_handler(int signal_number, void *data)
|
|
|
|
{
|
2023-04-18 15:29:44 +03:00
|
|
|
struct wet_process *p;
|
2021-06-29 20:33:04 +03:00
|
|
|
struct wet_compositor *wet = data;
|
2014-10-12 01:24:25 +04:00
|
|
|
int status;
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
|
2021-06-24 06:50:53 +03:00
|
|
|
if (wet->autolaunch_pid != -1 && wet->autolaunch_pid == pid) {
|
|
|
|
if (wet->autolaunch_watch)
|
|
|
|
wl_display_terminate(wet->compositor->wl_display);
|
|
|
|
wet->autolaunch_pid = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-06-29 20:33:04 +03:00
|
|
|
wl_list_for_each(p, &wet->child_process_list, link) {
|
2014-10-12 01:24:25 +04:00
|
|
|
if (p->pid == pid)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-07-21 18:02:38 +03:00
|
|
|
/* An unknown child process exited. Oh well. */
|
|
|
|
if (&p->link == &wet->child_process_list)
|
2014-10-12 01:24:25 +04:00
|
|
|
continue;
|
|
|
|
|
2023-05-01 17:36:06 +03:00
|
|
|
if (WIFEXITED(status)) {
|
|
|
|
weston_log("%s exited with status %d\n", p->path,
|
|
|
|
WEXITSTATUS(status));
|
|
|
|
} else if (WIFSIGNALED(status)) {
|
|
|
|
weston_log("%s died on signal %d\n", p->path,
|
|
|
|
WTERMSIG(status));
|
|
|
|
} else {
|
|
|
|
weston_log("%s disappeared\n", p->path);
|
|
|
|
}
|
|
|
|
|
2023-05-01 20:50:31 +03:00
|
|
|
wet_process_destroy(p, status, true);
|
2014-10-12 01:24:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pid < 0 && errno != ECHILD)
|
2019-04-27 00:57:31 +03:00
|
|
|
weston_log("waitpid error %s\n", strerror(errno));
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-12-08 16:53:24 +03:00
|
|
|
static void
|
|
|
|
cleanup_for_child_process() {
|
|
|
|
sigset_t allsigs;
|
|
|
|
|
|
|
|
/* Put the client in a new session so it won't catch signals
|
|
|
|
* intended for the parent. Sharing a session can be
|
|
|
|
* confusing when launching weston under gdb, as the ctrl-c
|
|
|
|
* intended for gdb will pass to the child, and weston
|
|
|
|
* will cleanly shut down when the child exits.
|
|
|
|
*/
|
|
|
|
setsid();
|
|
|
|
|
|
|
|
/* do not give our signal mask to the new process */
|
|
|
|
sigfillset(&allsigs);
|
|
|
|
sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
|
|
|
|
}
|
|
|
|
|
2023-05-01 17:31:56 +03:00
|
|
|
WL_EXPORT struct wet_process *
|
|
|
|
wet_client_launch(struct weston_compositor *compositor,
|
|
|
|
struct custom_env *child_env,
|
|
|
|
int *no_cloexec_fds,
|
|
|
|
size_t num_no_cloexec_fds,
|
|
|
|
wet_process_cleanup_func_t cleanup,
|
|
|
|
void *cleanup_data)
|
2016-06-02 21:48:10 +03:00
|
|
|
{
|
2023-04-18 15:32:39 +03:00
|
|
|
struct wet_compositor *wet = to_wet_compositor(compositor);
|
2023-05-01 17:31:56 +03:00
|
|
|
struct wet_process *proc = NULL;
|
2022-07-21 18:46:07 +03:00
|
|
|
const char *fail_cloexec = "Couldn't unset CLOEXEC on child FDs";
|
2022-07-12 19:51:49 +03:00
|
|
|
const char *fail_seteuid = "Couldn't call seteuid";
|
|
|
|
char *fail_exec;
|
2022-07-12 19:45:05 +03:00
|
|
|
char * const *argp;
|
|
|
|
char * const *envp;
|
2022-07-12 19:19:28 +03:00
|
|
|
pid_t pid;
|
2022-07-21 18:46:07 +03:00
|
|
|
int err;
|
|
|
|
size_t i;
|
2022-09-21 11:00:21 +03:00
|
|
|
size_t written __attribute__((unused));
|
2016-06-02 21:48:10 +03:00
|
|
|
|
2022-07-21 19:04:49 +03:00
|
|
|
argp = custom_env_get_argp(child_env);
|
|
|
|
envp = custom_env_get_envp(child_env);
|
2016-06-02 21:48:10 +03:00
|
|
|
|
2022-07-21 19:04:49 +03:00
|
|
|
weston_log("launching '%s'\n", argp[0]);
|
|
|
|
str_printf(&fail_exec, "Error: Couldn't launch client '%s'\n", argp[0]);
|
2022-07-21 18:46:07 +03:00
|
|
|
|
2016-06-02 21:48:10 +03:00
|
|
|
pid = fork();
|
2022-07-12 19:29:29 +03:00
|
|
|
switch (pid) {
|
|
|
|
case 0:
|
2022-12-08 16:53:24 +03:00
|
|
|
cleanup_for_child_process();
|
2022-07-12 19:40:23 +03:00
|
|
|
|
|
|
|
/* Launch clients as the user. Do not launch clients with wrong euid. */
|
|
|
|
if (seteuid(getuid()) == -1) {
|
2022-09-21 11:00:21 +03:00
|
|
|
written = write(STDERR_FILENO, fail_seteuid,
|
|
|
|
strlen(fail_seteuid));
|
2022-07-12 19:40:23 +03:00
|
|
|
_exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2022-07-21 18:46:07 +03:00
|
|
|
for (i = 0; i < num_no_cloexec_fds; i++) {
|
|
|
|
err = os_fd_clear_cloexec(no_cloexec_fds[i]);
|
|
|
|
if (err < 0) {
|
|
|
|
written = write(STDERR_FILENO, fail_cloexec,
|
|
|
|
strlen(fail_cloexec));
|
|
|
|
_exit(EXIT_FAILURE);
|
|
|
|
}
|
2022-07-12 19:19:28 +03:00
|
|
|
}
|
|
|
|
|
2022-07-12 19:51:49 +03:00
|
|
|
execve(argp[0], argp, envp);
|
2022-07-12 19:40:23 +03:00
|
|
|
|
2022-07-12 19:51:49 +03:00
|
|
|
if (fail_exec)
|
2022-09-21 11:00:21 +03:00
|
|
|
written = write(STDERR_FILENO, fail_exec,
|
|
|
|
strlen(fail_exec));
|
2022-07-12 19:40:23 +03:00
|
|
|
_exit(EXIT_FAILURE);
|
2016-06-02 21:48:10 +03:00
|
|
|
|
2022-07-12 19:29:29 +03:00
|
|
|
default:
|
2023-05-01 17:31:56 +03:00
|
|
|
proc = xzalloc(sizeof(*proc));
|
2022-07-12 19:29:29 +03:00
|
|
|
proc->pid = pid;
|
|
|
|
proc->cleanup = cleanup;
|
2023-05-01 17:14:51 +03:00
|
|
|
proc->cleanup_data = cleanup_data;
|
2023-04-18 15:25:13 +03:00
|
|
|
proc->path = strdup(argp[0]);
|
2023-04-18 15:32:39 +03:00
|
|
|
wl_list_insert(&wet->child_process_list, &proc->link);
|
2022-07-12 19:29:29 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case -1:
|
2016-06-02 21:48:10 +03:00
|
|
|
weston_log("weston_client_launch: "
|
2022-07-21 19:04:49 +03:00
|
|
|
"fork failed while launching '%s': %s\n", argp[0],
|
2022-07-12 19:29:29 +03:00
|
|
|
strerror(errno));
|
|
|
|
break;
|
2016-06-02 21:48:10 +03:00
|
|
|
}
|
|
|
|
|
2022-07-21 19:04:49 +03:00
|
|
|
custom_env_fini(child_env);
|
2022-07-12 19:51:49 +03:00
|
|
|
free(fail_exec);
|
2023-05-01 17:31:56 +03:00
|
|
|
return proc;
|
2016-06-02 21:48:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT struct wl_client *
|
2023-04-18 15:36:20 +03:00
|
|
|
wet_client_start(struct weston_compositor *compositor, const char *path)
|
2016-06-02 21:48:10 +03:00
|
|
|
{
|
2023-04-18 15:29:44 +03:00
|
|
|
struct wet_process *proc;
|
2016-06-02 21:48:10 +03:00
|
|
|
struct wl_client *client;
|
2022-07-21 19:04:49 +03:00
|
|
|
struct custom_env child_env;
|
|
|
|
struct fdstr wayland_socket = FDSTR_INIT;
|
|
|
|
int no_cloexec_fds[1];
|
|
|
|
size_t num_no_cloexec_fds = 0;
|
2016-06-02 21:48:10 +03:00
|
|
|
|
2022-07-21 19:04:49 +03:00
|
|
|
if (os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0,
|
|
|
|
wayland_socket.fds) < 0) {
|
2023-04-18 15:36:20 +03:00
|
|
|
weston_log("wet_client_start: "
|
2022-07-21 19:04:49 +03:00
|
|
|
"socketpair failed while launching '%s': %s\n",
|
|
|
|
path, strerror(errno));
|
2023-05-01 17:31:56 +03:00
|
|
|
return NULL;
|
2022-07-21 19:04:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
custom_env_init_from_environ(&child_env);
|
|
|
|
custom_env_add_from_exec_string(&child_env, path);
|
|
|
|
|
|
|
|
fdstr_update_str1(&wayland_socket);
|
|
|
|
no_cloexec_fds[num_no_cloexec_fds++] = wayland_socket.fds[1];
|
|
|
|
custom_env_set_env_var(&child_env, "WAYLAND_SOCKET",
|
|
|
|
wayland_socket.str1);
|
|
|
|
|
|
|
|
assert(num_no_cloexec_fds <= ARRAY_LENGTH(no_cloexec_fds));
|
|
|
|
|
2023-05-01 17:31:56 +03:00
|
|
|
proc = wet_client_launch(compositor, &child_env,
|
|
|
|
no_cloexec_fds, num_no_cloexec_fds,
|
2023-05-01 17:36:06 +03:00
|
|
|
NULL, NULL);
|
2023-05-01 17:31:56 +03:00
|
|
|
if (!proc)
|
|
|
|
return NULL;
|
2022-07-21 19:04:49 +03:00
|
|
|
|
|
|
|
client = wl_client_create(compositor->wl_display,
|
|
|
|
wayland_socket.fds[0]);
|
|
|
|
if (!client) {
|
2023-04-18 15:36:20 +03:00
|
|
|
weston_log("wet_client_start: "
|
|
|
|
"wl_client_create failed while launching '%s'.\n",
|
|
|
|
path);
|
2022-07-21 19:04:49 +03:00
|
|
|
/* We have no way of killing the process, so leave it hanging */
|
|
|
|
goto out_sock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the child end of our socket which we no longer need */
|
|
|
|
close(wayland_socket.fds[1]);
|
2016-06-02 21:48:10 +03:00
|
|
|
|
2023-05-01 17:31:56 +03:00
|
|
|
/* proc is now owned by the compositor's process list */
|
|
|
|
|
2016-06-02 21:48:10 +03:00
|
|
|
return client;
|
|
|
|
|
2022-07-21 19:04:49 +03:00
|
|
|
out_sock:
|
|
|
|
fdstr_close_all(&wayland_socket);
|
2016-06-02 21:48:10 +03:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
static void
|
|
|
|
log_uname(void)
|
|
|
|
{
|
|
|
|
struct utsname usys;
|
|
|
|
|
|
|
|
uname(&usys);
|
|
|
|
|
|
|
|
weston_log("OS: %s, %s, %s, %s\n", usys.sysname, usys.release,
|
|
|
|
usys.version, usys.machine);
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:04 +03:00
|
|
|
static struct wet_output_config *
|
|
|
|
wet_init_parsed_options(struct weston_compositor *ec)
|
|
|
|
{
|
|
|
|
struct wet_compositor *compositor = to_wet_compositor(ec);
|
|
|
|
struct wet_output_config *config;
|
|
|
|
|
|
|
|
config = zalloc(sizeof *config);
|
|
|
|
|
|
|
|
if (!config) {
|
|
|
|
perror("out of memory");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
config->width = 0;
|
|
|
|
config->height = 0;
|
|
|
|
config->scale = 0;
|
|
|
|
config->transform = UINT32_MAX;
|
|
|
|
|
|
|
|
compositor->parsed_options = config;
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2016-08-01 19:51:46 +03:00
|
|
|
WL_EXPORT struct weston_config *
|
|
|
|
wet_get_config(struct weston_compositor *ec)
|
|
|
|
{
|
|
|
|
struct wet_compositor *compositor = to_wet_compositor(ec);
|
|
|
|
|
|
|
|
return compositor->config;
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
static const char xdg_error_message[] =
|
|
|
|
"fatal: environment variable XDG_RUNTIME_DIR is not set.\n";
|
|
|
|
|
|
|
|
static const char xdg_wrong_message[] =
|
|
|
|
"fatal: environment variable XDG_RUNTIME_DIR\n"
|
|
|
|
"is set to \"%s\", which is not a directory.\n";
|
|
|
|
|
|
|
|
static const char xdg_wrong_mode_message[] =
|
|
|
|
"warning: XDG_RUNTIME_DIR \"%s\" is not configured\n"
|
2021-05-14 15:55:05 +03:00
|
|
|
"correctly. Unix access mode must be 0700 (current mode is %04o),\n"
|
|
|
|
"and must be owned by the user UID %d (current owner is UID %d).\n";
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
static const char xdg_detail_message[] =
|
|
|
|
"Refer to your distribution on how to get it, or\n"
|
|
|
|
"http://www.freedesktop.org/wiki/Specifications/basedir-spec\n"
|
|
|
|
"on how to implement it.\n";
|
|
|
|
|
|
|
|
static void
|
|
|
|
verify_xdg_runtime_dir(void)
|
|
|
|
{
|
|
|
|
char *dir = getenv("XDG_RUNTIME_DIR");
|
|
|
|
struct stat s;
|
|
|
|
|
|
|
|
if (!dir) {
|
|
|
|
weston_log(xdg_error_message);
|
|
|
|
weston_log_continue(xdg_detail_message);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat(dir, &s) || !S_ISDIR(s.st_mode)) {
|
|
|
|
weston_log(xdg_wrong_message, dir);
|
|
|
|
weston_log_continue(xdg_detail_message);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((s.st_mode & 0777) != 0700 || s.st_uid != getuid()) {
|
|
|
|
weston_log(xdg_wrong_mode_message,
|
2021-05-14 15:55:05 +03:00
|
|
|
dir, s.st_mode & 0777, getuid(), s.st_uid);
|
2014-10-12 01:24:25 +04:00
|
|
|
weston_log_continue(xdg_detail_message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
usage(int error_code)
|
|
|
|
{
|
2018-06-12 03:42:18 +03:00
|
|
|
FILE *out = error_code == EXIT_SUCCESS ? stdout : stderr;
|
|
|
|
|
|
|
|
fprintf(out,
|
2014-10-12 01:24:25 +04:00
|
|
|
"Usage: weston [OPTIONS]\n\n"
|
|
|
|
"This is weston version " VERSION ", the Wayland reference compositor.\n"
|
|
|
|
"Weston supports multiple backends, and depending on which backend is in use\n"
|
|
|
|
"different options will be accepted.\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
"Core options:\n\n"
|
|
|
|
" --version\t\tPrint weston version\n"
|
2022-12-05 19:28:23 +03:00
|
|
|
" -B, --backend=BACKEND\tBackend module, one of\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
#if defined(BUILD_DRM_COMPOSITOR)
|
2022-12-05 19:28:23 +03:00
|
|
|
"\t\t\t\tdrm\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
2015-07-31 23:39:00 +03:00
|
|
|
#if defined(BUILD_HEADLESS_COMPOSITOR)
|
2022-12-05 19:28:23 +03:00
|
|
|
"\t\t\t\theadless\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
2021-05-09 17:52:36 +03:00
|
|
|
#if defined(BUILD_PIPEWIRE_COMPOSITOR)
|
|
|
|
"\t\t\t\tpipewire\n"
|
|
|
|
#endif
|
2014-10-12 01:24:25 +04:00
|
|
|
#if defined(BUILD_RDP_COMPOSITOR)
|
2022-12-05 19:28:23 +03:00
|
|
|
"\t\t\t\trdp\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
2019-09-22 20:40:04 +03:00
|
|
|
#if defined(BUILD_VNC_COMPOSITOR)
|
2022-12-05 19:28:23 +03:00
|
|
|
"\t\t\t\tvnc\n"
|
2019-09-22 20:40:04 +03:00
|
|
|
#endif
|
2015-07-31 23:39:00 +03:00
|
|
|
#if defined(BUILD_WAYLAND_COMPOSITOR)
|
2022-12-05 19:28:23 +03:00
|
|
|
"\t\t\t\twayland\n"
|
2015-07-31 23:39:00 +03:00
|
|
|
#endif
|
|
|
|
#if defined(BUILD_X11_COMPOSITOR)
|
2022-12-05 19:28:23 +03:00
|
|
|
"\t\t\t\tx11\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
2022-12-30 00:12:24 +03:00
|
|
|
" --renderer=NAME\tRenderer to use, one of\n"
|
|
|
|
"\t\t\t\tauto\tAutomatic selection of one of the below renderers\n"
|
|
|
|
#if defined(ENABLE_EGL)
|
|
|
|
"\t\t\t\tgl\tOpenGL ES\n"
|
|
|
|
#endif
|
|
|
|
"\t\t\t\tnoop\tNo-op renderer for testing only\n"
|
|
|
|
"\t\t\t\tpixman\tPixman software renderer\n"
|
2022-12-29 18:38:37 +03:00
|
|
|
" --shell=NAME\tShell to load, defaults to desktop\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
" -S, --socket=NAME\tName of socket to listen on\n"
|
|
|
|
" -i, --idle-time=SECS\tIdle time in seconds\n"
|
2019-02-13 17:59:59 +03:00
|
|
|
#if defined(BUILD_XWAYLAND)
|
2018-03-16 07:16:29 +03:00
|
|
|
" --xwayland\t\tLoad the xwayland module\n"
|
2019-02-13 17:59:59 +03:00
|
|
|
#endif
|
2014-10-12 01:24:25 +04:00
|
|
|
" --modules\t\tLoad the comma-separated list of modules\n"
|
|
|
|
" --log=FILE\t\tLog to the given file\n"
|
|
|
|
" -c, --config=FILE\tConfig file to load, defaults to weston.ini\n"
|
|
|
|
" --no-config\t\tDo not read weston.ini\n"
|
2017-11-01 11:26:46 +03:00
|
|
|
" --wait-for-debugger\tRaise SIGSTOP on start-up\n"
|
2017-10-12 14:13:43 +03:00
|
|
|
" --debug\t\tEnable debug extension\n"
|
2019-06-22 23:39:19 +03:00
|
|
|
" -l, --logger-scopes=SCOPE\n\t\t\tSpecify log scopes to "
|
|
|
|
"subscribe to.\n\t\t\tCan specify multiple scopes, "
|
|
|
|
"each followed by comma\n"
|
2019-06-24 13:27:44 +03:00
|
|
|
" -f, --flight-rec-scopes=SCOPE\n\t\t\tSpecify log scopes to "
|
|
|
|
"subscribe to.\n\t\t\tCan specify multiple scopes, "
|
|
|
|
"each followed by comma\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
" -h, --help\t\tThis help message\n\n");
|
|
|
|
|
|
|
|
#if defined(BUILD_DRM_COMPOSITOR)
|
2018-06-12 03:42:18 +03:00
|
|
|
fprintf(out,
|
2022-12-05 19:28:23 +03:00
|
|
|
"Options for drm:\n\n"
|
2018-06-29 15:17:46 +03:00
|
|
|
" --seat=SEAT\t\tThe seat that weston should run on, instead of the seat defined in XDG_SEAT\n"
|
2017-03-28 18:14:37 +03:00
|
|
|
" --drm-device=CARD\tThe DRM device to use, e.g. \"card0\".\n"
|
2022-12-30 00:12:24 +03:00
|
|
|
" --use-pixman\t\tUse the pixman (CPU) renderer (deprecated alias for --renderer=pixman)\n"
|
2020-05-07 00:10:19 +03:00
|
|
|
" --current-mode\tPrefer current KMS mode over EDID preferred mode\n"
|
|
|
|
" --continue-without-input\tAllow the compositor to start without input devices\n\n");
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
|
|
|
|
2015-07-31 23:39:00 +03:00
|
|
|
#if defined(BUILD_HEADLESS_COMPOSITOR)
|
2018-06-12 03:42:18 +03:00
|
|
|
fprintf(out,
|
2022-12-05 19:28:23 +03:00
|
|
|
"Options for headless:\n\n"
|
2015-07-31 23:39:00 +03:00
|
|
|
" --width=WIDTH\t\tWidth of memory surface\n"
|
|
|
|
" --height=HEIGHT\tHeight of memory surface\n"
|
2020-01-22 12:33:34 +03:00
|
|
|
" --scale=SCALE\t\tScale factor of output\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
" --transform=TR\tThe output transformation, TR is one of:\n"
|
|
|
|
"\tnormal 90 180 270 flipped flipped-90 flipped-180 flipped-270\n"
|
2022-12-30 00:12:24 +03:00
|
|
|
" --use-pixman\t\tUse the pixman (CPU) renderer (deprecated alias for --renderer=pixman)\n"
|
|
|
|
" --use-gl\t\tUse the GL renderer (deprecated alias for --renderer=gl)\n"
|
2016-06-23 12:59:29 +03:00
|
|
|
" --no-outputs\t\tDo not create any virtual outputs\n"
|
|
|
|
"\n");
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
|
|
|
|
2021-05-09 17:52:36 +03:00
|
|
|
#if defined(BUILD_PIPEWIRE_COMPOSITOR)
|
|
|
|
fprintf(out,
|
|
|
|
"Options for pipewire\n\n"
|
|
|
|
" --width=WIDTH\t\tWidth of desktop\n"
|
|
|
|
" --height=HEIGHT\tHeight of desktop\n"
|
|
|
|
"\n");
|
|
|
|
#endif
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
#if defined(BUILD_RDP_COMPOSITOR)
|
2018-06-12 03:42:18 +03:00
|
|
|
fprintf(out,
|
2022-12-05 19:28:23 +03:00
|
|
|
"Options for rdp:\n\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
" --width=WIDTH\t\tWidth of desktop\n"
|
|
|
|
" --height=HEIGHT\tHeight of desktop\n"
|
2015-07-31 20:49:57 +03:00
|
|
|
" --env-socket\t\tUse socket defined in RDP_FD env variable as peer connection\n"
|
2022-03-15 20:24:42 +03:00
|
|
|
" --external-listener-fd=FD\tUse socket as listener connection\n"
|
2014-10-12 01:24:25 +04:00
|
|
|
" --address=ADDR\tThe address to bind\n"
|
|
|
|
" --port=PORT\t\tThe port to listen on\n"
|
|
|
|
" --no-clients-resize\tThe RDP peers will be forced to the size of the desktop\n"
|
|
|
|
" --rdp4-key=FILE\tThe file containing the key for RDP4 encryption\n"
|
|
|
|
" --rdp-tls-cert=FILE\tThe file containing the certificate for TLS encryption\n"
|
|
|
|
" --rdp-tls-key=FILE\tThe file containing the private key for TLS encryption\n"
|
|
|
|
"\n");
|
|
|
|
#endif
|
|
|
|
|
2019-09-22 20:40:04 +03:00
|
|
|
#if defined(BUILD_VNC_COMPOSITOR)
|
|
|
|
fprintf(out,
|
2022-12-05 19:28:23 +03:00
|
|
|
"Options for vnc:\n\n"
|
2019-09-22 20:40:04 +03:00
|
|
|
" --width=WIDTH\t\tWidth of desktop\n"
|
|
|
|
" --height=HEIGHT\tHeight of desktop\n"
|
|
|
|
" --port=PORT\t\tThe port to listen on\n"
|
2022-10-06 13:18:04 +03:00
|
|
|
" --vnc-tls-cert=FILE\tThe file containing the certificate for TLS encryption\n"
|
|
|
|
" --vnc-tls-key=FILE\tThe file containing the private key for TLS encryption\n"
|
2019-09-22 20:40:04 +03:00
|
|
|
"\n");
|
|
|
|
#endif
|
|
|
|
|
2015-07-31 23:39:00 +03:00
|
|
|
#if defined(BUILD_WAYLAND_COMPOSITOR)
|
2018-06-12 03:42:18 +03:00
|
|
|
fprintf(out,
|
2022-12-05 19:28:23 +03:00
|
|
|
"Options for wayland:\n\n"
|
2015-07-31 23:39:00 +03:00
|
|
|
" --width=WIDTH\t\tWidth of Wayland surface\n"
|
|
|
|
" --height=HEIGHT\tHeight of Wayland surface\n"
|
|
|
|
" --scale=SCALE\t\tScale factor of output\n"
|
|
|
|
" --fullscreen\t\tRun in fullscreen mode\n"
|
2022-12-30 00:12:24 +03:00
|
|
|
" --use-pixman\t\tUse the pixman (CPU) renderer (deprecated alias for --renderer=pixman)\n"
|
2015-07-31 23:39:00 +03:00
|
|
|
" --output-count=COUNT\tCreate multiple outputs\n"
|
|
|
|
" --sprawl\t\tCreate one fullscreen output for every parent output\n"
|
|
|
|
" --display=DISPLAY\tWayland display to connect to\n\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(BUILD_X11_COMPOSITOR)
|
2018-06-12 03:42:18 +03:00
|
|
|
fprintf(out,
|
2022-12-05 19:28:23 +03:00
|
|
|
"Options for x11:\n\n"
|
2015-07-31 23:39:00 +03:00
|
|
|
" --width=WIDTH\t\tWidth of X window\n"
|
|
|
|
" --height=HEIGHT\tHeight of X window\n"
|
|
|
|
" --scale=SCALE\t\tScale factor of output\n"
|
|
|
|
" --fullscreen\t\tRun in fullscreen mode\n"
|
2022-12-30 00:12:24 +03:00
|
|
|
" --use-pixman\t\tUse the pixman (CPU) renderer (deprecated alias for --renderer=pixman)\n"
|
2015-07-31 23:39:00 +03:00
|
|
|
" --output-count=COUNT\tCreate multiple outputs\n"
|
|
|
|
" --no-input\t\tDont create input devices\n\n");
|
2014-10-12 01:24:25 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
exit(error_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int on_term_signal(int signal_number, void *data)
|
|
|
|
{
|
|
|
|
struct wl_display *display = data;
|
|
|
|
|
|
|
|
weston_log("caught signal %d\n", signal_number);
|
|
|
|
wl_display_terminate(display);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
clock_name(clockid_t clk_id)
|
|
|
|
{
|
|
|
|
static const char *names[] = {
|
|
|
|
[CLOCK_REALTIME] = "CLOCK_REALTIME",
|
|
|
|
[CLOCK_MONOTONIC] = "CLOCK_MONOTONIC",
|
|
|
|
[CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW",
|
|
|
|
[CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE",
|
|
|
|
[CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE",
|
2015-06-29 21:20:34 +03:00
|
|
|
#ifdef CLOCK_BOOTTIME
|
2014-10-12 01:24:25 +04:00
|
|
|
[CLOCK_BOOTTIME] = "CLOCK_BOOTTIME",
|
2015-06-29 21:20:34 +03:00
|
|
|
#endif
|
2014-10-12 01:24:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (clk_id < 0 || (unsigned)clk_id >= ARRAY_LENGTH(names))
|
|
|
|
return "unknown";
|
|
|
|
|
|
|
|
return names[clk_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
uint32_t bit; /* enum weston_capability */
|
|
|
|
const char *desc;
|
|
|
|
} capability_strings[] = {
|
2021-03-01 12:05:22 +03:00
|
|
|
{ WESTON_CAP_ROTATION_ANY, "arbitrary surface rotation" },
|
|
|
|
{ WESTON_CAP_CAPTURE_YFLIP, "screen capture uses y-flip" },
|
2021-03-01 12:15:21 +03:00
|
|
|
{ WESTON_CAP_CURSOR_PLANE, "cursor planes" },
|
|
|
|
{ WESTON_CAP_ARBITRARY_MODES, "arbitrary resolutions" },
|
|
|
|
{ WESTON_CAP_VIEW_CLIP_MASK, "view mask clipping" },
|
|
|
|
{ WESTON_CAP_EXPLICIT_SYNC, "explicit sync" },
|
2021-03-01 12:05:22 +03:00
|
|
|
{ WESTON_CAP_COLOR_OPS, "color operations" },
|
2014-10-12 01:24:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_compositor_log_capabilities(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
int yes;
|
2016-04-18 15:53:38 +03:00
|
|
|
struct timespec res;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
weston_log("Compositor capabilities:\n");
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(capability_strings); i++) {
|
|
|
|
yes = compositor->capabilities & capability_strings[i].bit;
|
2021-03-01 12:05:22 +03:00
|
|
|
weston_log_continue(STAMP_SPACE "%s: %s\n",
|
2014-10-12 01:24:25 +04:00
|
|
|
capability_strings[i].desc,
|
|
|
|
yes ? "yes" : "no");
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_log_continue(STAMP_SPACE "presentation clock: %s, id %d\n",
|
|
|
|
clock_name(compositor->presentation_clock),
|
|
|
|
compositor->presentation_clock);
|
2016-04-18 15:53:38 +03:00
|
|
|
|
|
|
|
if (clock_getres(compositor->presentation_clock, &res) == 0)
|
|
|
|
weston_log_continue(STAMP_SPACE
|
|
|
|
"presentation clock resolution: %d.%09ld s\n",
|
|
|
|
(int)res.tv_sec, res.tv_nsec);
|
|
|
|
else
|
|
|
|
weston_log_continue(STAMP_SPACE
|
|
|
|
"presentation clock resolution: N/A\n");
|
2014-10-12 01:24:25 +04:00
|
|
|
}
|
|
|
|
|
2021-03-01 12:24:59 +03:00
|
|
|
static bool
|
|
|
|
check_compositor_capabilities(struct weston_compositor *compositor,
|
|
|
|
uint32_t mask)
|
|
|
|
{
|
|
|
|
uint32_t missing = mask & ~compositor->capabilities;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (missing == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
weston_log("Quirk error, missing capabilities:\n");
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(capability_strings); i++) {
|
|
|
|
if (!(missing & capability_strings[i].bit))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
weston_log_continue(STAMP_SPACE "- %s\n",
|
|
|
|
capability_strings[i].desc);
|
|
|
|
missing &= ~capability_strings[i].bit;
|
|
|
|
}
|
|
|
|
if (missing) {
|
|
|
|
weston_log_continue(STAMP_SPACE "- unlisted bits 0x%x\n",
|
|
|
|
missing);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
static void
|
|
|
|
handle_primary_client_destroyed(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct wl_client *client = data;
|
|
|
|
|
|
|
|
weston_log("Primary client died. Closing...\n");
|
|
|
|
|
|
|
|
wl_display_terminate(wl_client_get_display(client));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
weston_create_listening_socket(struct wl_display *display, const char *socket_name)
|
|
|
|
{
|
2022-03-29 17:35:58 +03:00
|
|
|
char name_candidate[32];
|
compositor: avoid setting WAYLAND_DISPLAY=wayland-0
This commit alters the way that Weston picks a Wayland display socket
name. Instead of using wl_display_add_socket_auto to look for the first
available name in wayland-0, wayland-1, .... to wayland-32, the code now
checks names wayland-1, wayland-2, .... up to wayland-32.
This change is a workaround for a suboptimal behavior of
libwayland-client. If a client program calls wl_display_connect(NULL) and
the WAYLAND_DISPLAY environment variable is not set, then the program will
by default try to connect to 'wayland-0'. This is a problem when a
computer has a running Wayland compositor but is being accessed in some
other fashion, such as through an X session on a different virtual
terminal, over ssh, etc. Client programs launched through those means may
attempt to connect to an unrelated compositor. Changing libwayland
behavior to remove the default would also work, but a) libraries have
stronger backward compatibility expectations b) that would likely break
more people's setups than just changing Weston would.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-08-31 01:49:18 +03:00
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
if (socket_name) {
|
|
|
|
if (wl_display_add_socket(display, socket_name)) {
|
2019-04-27 00:57:31 +03:00
|
|
|
weston_log("fatal: failed to add socket: %s\n",
|
|
|
|
strerror(errno));
|
2014-10-12 01:24:25 +04:00
|
|
|
return -1;
|
|
|
|
}
|
compositor: avoid setting WAYLAND_DISPLAY=wayland-0
This commit alters the way that Weston picks a Wayland display socket
name. Instead of using wl_display_add_socket_auto to look for the first
available name in wayland-0, wayland-1, .... to wayland-32, the code now
checks names wayland-1, wayland-2, .... up to wayland-32.
This change is a workaround for a suboptimal behavior of
libwayland-client. If a client program calls wl_display_connect(NULL) and
the WAYLAND_DISPLAY environment variable is not set, then the program will
by default try to connect to 'wayland-0'. This is a problem when a
computer has a running Wayland compositor but is being accessed in some
other fashion, such as through an X session on a different virtual
terminal, over ssh, etc. Client programs launched through those means may
attempt to connect to an unrelated compositor. Changing libwayland
behavior to remove the default would also work, but a) libraries have
stronger backward compatibility expectations b) that would likely break
more people's setups than just changing Weston would.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-08-31 01:49:18 +03:00
|
|
|
|
|
|
|
setenv("WAYLAND_DISPLAY", socket_name, 1);
|
|
|
|
return 0;
|
2014-10-12 01:24:25 +04:00
|
|
|
} else {
|
compositor: avoid setting WAYLAND_DISPLAY=wayland-0
This commit alters the way that Weston picks a Wayland display socket
name. Instead of using wl_display_add_socket_auto to look for the first
available name in wayland-0, wayland-1, .... to wayland-32, the code now
checks names wayland-1, wayland-2, .... up to wayland-32.
This change is a workaround for a suboptimal behavior of
libwayland-client. If a client program calls wl_display_connect(NULL) and
the WAYLAND_DISPLAY environment variable is not set, then the program will
by default try to connect to 'wayland-0'. This is a problem when a
computer has a running Wayland compositor but is being accessed in some
other fashion, such as through an X session on a different virtual
terminal, over ssh, etc. Client programs launched through those means may
attempt to connect to an unrelated compositor. Changing libwayland
behavior to remove the default would also work, but a) libraries have
stronger backward compatibility expectations b) that would likely break
more people's setups than just changing Weston would.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-08-31 01:49:18 +03:00
|
|
|
for (int i = 1; i <= 32; i++) {
|
|
|
|
sprintf(name_candidate, "wayland-%d", i);
|
|
|
|
if (wl_display_add_socket(display, name_candidate) >= 0) {
|
|
|
|
setenv("WAYLAND_DISPLAY", name_candidate, 1);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-12 01:24:25 +04:00
|
|
|
}
|
compositor: avoid setting WAYLAND_DISPLAY=wayland-0
This commit alters the way that Weston picks a Wayland display socket
name. Instead of using wl_display_add_socket_auto to look for the first
available name in wayland-0, wayland-1, .... to wayland-32, the code now
checks names wayland-1, wayland-2, .... up to wayland-32.
This change is a workaround for a suboptimal behavior of
libwayland-client. If a client program calls wl_display_connect(NULL) and
the WAYLAND_DISPLAY environment variable is not set, then the program will
by default try to connect to 'wayland-0'. This is a problem when a
computer has a running Wayland compositor but is being accessed in some
other fashion, such as through an X session on a different virtual
terminal, over ssh, etc. Client programs launched through those means may
attempt to connect to an unrelated compositor. Changing libwayland
behavior to remove the default would also work, but a) libraries have
stronger backward compatibility expectations b) that would likely break
more people's setups than just changing Weston would.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2020-08-31 01:49:18 +03:00
|
|
|
weston_log("fatal: failed to add socket: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
2014-10-12 01:24:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-02 16:21:46 +03:00
|
|
|
WL_EXPORT int
|
|
|
|
wet_load_module(struct weston_compositor *compositor,
|
|
|
|
const char *name, int *argc, char *argv[])
|
|
|
|
{
|
|
|
|
int (*module_init)(struct weston_compositor *ec,
|
|
|
|
int *argc, char *argv[]);
|
|
|
|
|
2022-09-19 14:20:02 +03:00
|
|
|
module_init = weston_load_module(name, "wet_module_init", MODULEDIR);
|
2016-12-02 16:21:46 +03:00
|
|
|
if (!module_init)
|
|
|
|
return -1;
|
|
|
|
if (module_init(compositor, argc, argv) < 0)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-12-02 16:17:08 +03:00
|
|
|
static int
|
|
|
|
wet_load_shell(struct weston_compositor *compositor,
|
2022-12-29 18:38:37 +03:00
|
|
|
const char *_name, int *argc, char *argv[])
|
2016-12-02 16:17:08 +03:00
|
|
|
{
|
2022-12-29 18:38:37 +03:00
|
|
|
char *name;
|
2016-12-02 16:17:08 +03:00
|
|
|
int (*shell_init)(struct weston_compositor *ec,
|
|
|
|
int *argc, char *argv[]);
|
|
|
|
|
2022-12-29 18:38:37 +03:00
|
|
|
if (strstr(_name, "-shell.so"))
|
|
|
|
name = strdup(_name);
|
|
|
|
else
|
|
|
|
str_printf(&name, "%s-shell.so", _name);
|
|
|
|
assert(name);
|
|
|
|
|
2022-09-19 14:20:02 +03:00
|
|
|
shell_init = weston_load_module(name, "wet_shell_init", MODULEDIR);
|
2022-12-29 18:38:37 +03:00
|
|
|
free(name);
|
|
|
|
|
2016-12-02 16:17:08 +03:00
|
|
|
if (!shell_init)
|
|
|
|
return -1;
|
|
|
|
if (shell_init(compositor, argc, argv) < 0)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-15 16:51:57 +03:00
|
|
|
static char *
|
|
|
|
wet_get_binary_path(const char *name, const char *dir)
|
2016-11-24 23:45:45 +03:00
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
len = weston_module_path_from_env(name, path, sizeof path);
|
|
|
|
if (len > 0)
|
|
|
|
return strdup(path);
|
|
|
|
|
2018-12-15 16:51:57 +03:00
|
|
|
len = snprintf(path, sizeof path, "%s/%s", dir, name);
|
2016-11-24 23:45:45 +03:00
|
|
|
if (len >= sizeof path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return strdup(path);
|
|
|
|
}
|
|
|
|
|
2018-12-15 16:51:57 +03:00
|
|
|
WL_EXPORT char *
|
|
|
|
wet_get_libexec_path(const char *name)
|
|
|
|
{
|
|
|
|
return wet_get_binary_path(name, LIBEXECDIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT char *
|
|
|
|
wet_get_bindir_path(const char *name)
|
|
|
|
{
|
|
|
|
return wet_get_binary_path(name, BINDIR);
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
static int
|
|
|
|
load_modules(struct weston_compositor *ec, const char *modules,
|
2022-07-14 21:24:18 +03:00
|
|
|
int *argc, char *argv[])
|
2014-10-12 01:24:25 +04:00
|
|
|
{
|
|
|
|
const char *p, *end;
|
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
if (modules == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
p = modules;
|
|
|
|
while (*p) {
|
|
|
|
end = strchrnul(p, ',');
|
|
|
|
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
|
2016-06-29 12:54:27 +03:00
|
|
|
|
|
|
|
if (strstr(buffer, "xwayland.so")) {
|
2022-07-14 21:24:18 +03:00
|
|
|
weston_log("fatal: Old Xwayland module loading detected: "
|
2017-02-09 23:28:32 +03:00
|
|
|
"Please use --xwayland command line option "
|
|
|
|
"or set xwayland=true in the [core] section "
|
|
|
|
"in weston.ini\n");
|
2022-07-14 21:24:18 +03:00
|
|
|
return -1;
|
2016-06-29 12:54:27 +03:00
|
|
|
} else {
|
2016-12-02 16:21:46 +03:00
|
|
|
if (wet_load_module(ec, buffer, argc, argv) < 0)
|
2016-06-29 12:54:27 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2016-12-02 16:21:46 +03:00
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
p = end;
|
|
|
|
while (*p == ',')
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-15 10:02:56 +03:00
|
|
|
static int
|
|
|
|
save_touch_device_calibration(struct weston_compositor *compositor,
|
|
|
|
struct weston_touch_device *device,
|
|
|
|
const struct weston_touch_device_matrix *calibration)
|
|
|
|
{
|
|
|
|
struct weston_config_section *s;
|
|
|
|
struct weston_config *config = wet_get_config(compositor);
|
|
|
|
char *helper = NULL;
|
|
|
|
char *helper_cmd = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int status;
|
|
|
|
const float *m = calibration->m;
|
|
|
|
|
|
|
|
s = weston_config_get_section(config,
|
|
|
|
"libinput", NULL, NULL);
|
|
|
|
|
|
|
|
weston_config_section_get_string(s, "calibration_helper",
|
|
|
|
&helper, NULL);
|
|
|
|
|
|
|
|
if (!helper || strlen(helper) == 0) {
|
|
|
|
ret = 0;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asprintf(&helper_cmd, "\"%s\" '%s' %f %f %f %f %f %f",
|
|
|
|
helper, device->syspath,
|
|
|
|
m[0], m[1], m[2],
|
|
|
|
m[3], m[4], m[5]) < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
status = system(helper_cmd);
|
|
|
|
free(helper_cmd);
|
|
|
|
|
|
|
|
if (status < 0) {
|
|
|
|
weston_log("Error: failed to run calibration helper '%s'.\n",
|
|
|
|
helper);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!WIFEXITED(status)) {
|
|
|
|
weston_log("Error: calibration helper '%s' possibly killed.\n",
|
|
|
|
helper);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WEXITSTATUS(status) == 0) {
|
|
|
|
ret = 0;
|
|
|
|
} else {
|
|
|
|
weston_log("Calibration helper '%s' exited with status %d.\n",
|
|
|
|
helper, WEXITSTATUS(status));
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
free(helper);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-05-31 15:09:48 +03:00
|
|
|
static const struct {
|
|
|
|
const char *name;
|
|
|
|
enum require_outputs mode;
|
|
|
|
} require_outputs_modes [] = {
|
|
|
|
{ "all-found", REQUIRE_OUTPUTS_ALL_FOUND },
|
|
|
|
{ "any", REQUIRE_OUTPUTS_ANY },
|
|
|
|
{ "none", REQUIRE_OUTPUTS_NONE },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
weston_parse_require_outputs(const char *name, enum require_outputs *mode)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(require_outputs_modes); i++)
|
|
|
|
if (strcmp(require_outputs_modes[i].name, name) == 0) {
|
|
|
|
*mode = require_outputs_modes[i].mode;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
static int
|
|
|
|
weston_compositor_init_config(struct weston_compositor *ec,
|
|
|
|
struct weston_config *config)
|
|
|
|
{
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
struct wet_compositor *compositor = to_wet_compositor(ec);
|
2014-10-12 01:24:25 +04:00
|
|
|
struct xkb_rule_names xkb_names;
|
|
|
|
struct weston_config_section *s;
|
|
|
|
int repaint_msec;
|
2021-03-29 14:41:18 +03:00
|
|
|
bool color_management;
|
2019-11-26 03:14:24 +03:00
|
|
|
bool cal;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2017-12-15 10:02:56 +03:00
|
|
|
/* weston.ini [keyboard] */
|
2014-10-12 01:24:25 +04:00
|
|
|
s = weston_config_get_section(config, "keyboard", NULL, NULL);
|
|
|
|
weston_config_section_get_string(s, "keymap_rules",
|
|
|
|
(char **) &xkb_names.rules, NULL);
|
|
|
|
weston_config_section_get_string(s, "keymap_model",
|
|
|
|
(char **) &xkb_names.model, NULL);
|
|
|
|
weston_config_section_get_string(s, "keymap_layout",
|
|
|
|
(char **) &xkb_names.layout, NULL);
|
|
|
|
weston_config_section_get_string(s, "keymap_variant",
|
|
|
|
(char **) &xkb_names.variant, NULL);
|
|
|
|
weston_config_section_get_string(s, "keymap_options",
|
|
|
|
(char **) &xkb_names.options, NULL);
|
|
|
|
|
2016-06-02 21:48:08 +03:00
|
|
|
if (weston_compositor_set_xkb_rule_names(ec, &xkb_names) < 0)
|
2014-10-12 01:24:25 +04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
weston_config_section_get_int(s, "repeat-rate",
|
|
|
|
&ec->kb_repeat_rate, 40);
|
|
|
|
weston_config_section_get_int(s, "repeat-delay",
|
|
|
|
&ec->kb_repeat_delay, 400);
|
|
|
|
|
2016-01-12 13:21:47 +03:00
|
|
|
weston_config_section_get_bool(s, "vt-switching",
|
2019-11-26 03:14:24 +03:00
|
|
|
&ec->vt_switching, true);
|
2016-01-12 13:21:47 +03:00
|
|
|
|
2017-12-15 10:02:56 +03:00
|
|
|
/* weston.ini [core] */
|
2014-10-12 01:24:25 +04:00
|
|
|
s = weston_config_get_section(config, "core", NULL, NULL);
|
|
|
|
weston_config_section_get_int(s, "repaint-window", &repaint_msec,
|
|
|
|
ec->repaint_msec);
|
|
|
|
if (repaint_msec < -10 || repaint_msec > 1000) {
|
|
|
|
weston_log("Invalid repaint_window value in config: %d\n",
|
|
|
|
repaint_msec);
|
|
|
|
} else {
|
|
|
|
ec->repaint_msec = repaint_msec;
|
|
|
|
}
|
|
|
|
weston_log("Output repaint window is %d ms maximum.\n",
|
|
|
|
ec->repaint_msec);
|
|
|
|
|
2021-03-29 14:41:18 +03:00
|
|
|
weston_config_section_get_bool(s, "color-management",
|
|
|
|
&color_management, false);
|
|
|
|
if (color_management) {
|
|
|
|
if (weston_compositor_load_color_manager(ec) < 0)
|
|
|
|
return -1;
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
else
|
|
|
|
compositor->use_color_manager = true;
|
2021-03-29 14:41:18 +03:00
|
|
|
}
|
|
|
|
|
2017-12-15 10:02:56 +03:00
|
|
|
/* weston.ini [libinput] */
|
|
|
|
s = weston_config_get_section(config, "libinput", NULL, NULL);
|
|
|
|
weston_config_section_get_bool(s, "touchscreen_calibrator", &cal, 0);
|
|
|
|
if (cal)
|
|
|
|
weston_compositor_enable_touch_calibrator(ec,
|
|
|
|
save_touch_device_calibration);
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
weston_choose_default_backend(void)
|
|
|
|
{
|
|
|
|
char *backend = NULL;
|
|
|
|
|
|
|
|
if (getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET"))
|
2022-12-05 19:28:23 +03:00
|
|
|
backend = strdup("wayland");
|
2014-10-12 01:24:25 +04:00
|
|
|
else if (getenv("DISPLAY"))
|
2022-12-05 19:28:23 +03:00
|
|
|
backend = strdup("x11");
|
2014-10-12 01:24:25 +04:00
|
|
|
else
|
|
|
|
backend = strdup(WESTON_NATIVE_BACKEND);
|
|
|
|
|
|
|
|
return backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct { const char *name; uint32_t token; } transforms[] = {
|
Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.
As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.
All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.
Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as
c -s
s c
that is, it's column-major. This fooled me at first.
Fixing window.c fixes weston-terminal and weston-transformed.
In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical. The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.
Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.
https://gitlab.freedesktop.org/wayland/weston/issues/99
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-06 16:27:54 +03:00
|
|
|
{ "normal", WL_OUTPUT_TRANSFORM_NORMAL },
|
|
|
|
{ "rotate-90", WL_OUTPUT_TRANSFORM_90 },
|
|
|
|
{ "rotate-180", WL_OUTPUT_TRANSFORM_180 },
|
|
|
|
{ "rotate-270", WL_OUTPUT_TRANSFORM_270 },
|
|
|
|
{ "flipped", WL_OUTPUT_TRANSFORM_FLIPPED },
|
|
|
|
{ "flipped-rotate-90", WL_OUTPUT_TRANSFORM_FLIPPED_90 },
|
|
|
|
{ "flipped-rotate-180", WL_OUTPUT_TRANSFORM_FLIPPED_180 },
|
|
|
|
{ "flipped-rotate-270", WL_OUTPUT_TRANSFORM_FLIPPED_270 },
|
2014-10-12 01:24:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_parse_transform(const char *transform, uint32_t *out)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(transforms); i++)
|
|
|
|
if (strcmp(transforms[i].name, transform) == 0) {
|
|
|
|
*out = transforms[i].token;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT const char *
|
|
|
|
weston_transform_to_string(uint32_t output_transform)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(transforms); i++)
|
|
|
|
if (transforms[i].token == output_transform)
|
|
|
|
return transforms[i].name;
|
|
|
|
|
|
|
|
return "<illegal value>";
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
load_configuration(struct weston_config **config, int32_t noconfig,
|
|
|
|
const char *config_file)
|
|
|
|
{
|
|
|
|
const char *file = "weston.ini";
|
|
|
|
const char *full_path;
|
|
|
|
|
|
|
|
*config = NULL;
|
|
|
|
|
|
|
|
if (config_file)
|
|
|
|
file = config_file;
|
|
|
|
|
|
|
|
if (noconfig == 0)
|
|
|
|
*config = weston_config_parse(file);
|
|
|
|
|
|
|
|
if (*config) {
|
|
|
|
full_path = weston_config_get_full_path(*config);
|
|
|
|
|
|
|
|
weston_log("Using config file '%s'\n", full_path);
|
|
|
|
setenv(WESTON_CONFIG_FILE_ENV_VAR, full_path, 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config_file && noconfig == 0) {
|
|
|
|
weston_log("fatal: error opening or reading config file"
|
|
|
|
" '%s'.\n", config_file);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_log("Starting with no config file.\n");
|
|
|
|
setenv(WESTON_CONFIG_FILE_ENV_VAR, "", 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_exit(struct weston_compositor *c)
|
|
|
|
{
|
|
|
|
wl_display_terminate(c->wl_display);
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:04 +03:00
|
|
|
static void
|
|
|
|
wet_output_set_scale(struct weston_output *output,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
int32_t default_scale,
|
|
|
|
int32_t parsed_scale)
|
|
|
|
{
|
|
|
|
int32_t scale = default_scale;
|
|
|
|
|
|
|
|
if (section)
|
|
|
|
weston_config_section_get_int(section, "scale", &scale, default_scale);
|
|
|
|
|
|
|
|
if (parsed_scale)
|
|
|
|
scale = parsed_scale;
|
|
|
|
|
|
|
|
weston_output_set_scale(output, scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UINT32_MAX is treated as invalid because 0 is a valid
|
|
|
|
* enumeration value and the parameter is unsigned
|
|
|
|
*/
|
2020-03-07 00:45:50 +03:00
|
|
|
static int
|
2016-09-30 15:11:04 +03:00
|
|
|
wet_output_set_transform(struct weston_output *output,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
uint32_t default_transform,
|
|
|
|
uint32_t parsed_transform)
|
|
|
|
{
|
2019-11-26 02:35:36 +03:00
|
|
|
char *t = NULL;
|
2016-09-30 15:11:04 +03:00
|
|
|
uint32_t transform = default_transform;
|
|
|
|
|
|
|
|
if (section) {
|
|
|
|
weston_config_section_get_string(section,
|
2019-11-26 02:35:36 +03:00
|
|
|
"transform", &t, NULL);
|
|
|
|
}
|
2016-09-30 15:11:04 +03:00
|
|
|
|
2019-11-26 02:35:36 +03:00
|
|
|
if (t) {
|
2016-09-30 15:11:04 +03:00
|
|
|
if (weston_parse_transform(t, &transform) < 0) {
|
|
|
|
weston_log("Invalid transform \"%s\" for output %s\n",
|
|
|
|
t, output->name);
|
2020-03-07 00:45:50 +03:00
|
|
|
return -1;
|
2016-09-30 15:11:04 +03:00
|
|
|
}
|
|
|
|
free(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parsed_transform != UINT32_MAX)
|
|
|
|
transform = parsed_transform;
|
|
|
|
|
|
|
|
weston_output_set_transform(output, transform);
|
2020-03-07 00:45:50 +03:00
|
|
|
|
|
|
|
return 0;
|
2016-09-30 15:11:04 +03:00
|
|
|
}
|
|
|
|
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
static int
|
|
|
|
wet_output_set_color_profile(struct weston_output *output,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
struct weston_color_profile *parent_winsys_profile)
|
|
|
|
{
|
|
|
|
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
|
|
|
struct weston_color_profile *cprof;
|
|
|
|
char *icc_file = NULL;
|
|
|
|
bool ok;
|
|
|
|
|
|
|
|
if (!compositor->use_color_manager)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (section) {
|
|
|
|
weston_config_section_get_string(section, "icc_profile",
|
|
|
|
&icc_file, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (icc_file) {
|
|
|
|
cprof = weston_compositor_load_icc_file(output->compositor,
|
|
|
|
icc_file);
|
|
|
|
free(icc_file);
|
|
|
|
} else if (parent_winsys_profile) {
|
|
|
|
cprof = weston_color_profile_ref(parent_winsys_profile);
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cprof)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ok = weston_output_set_color_profile(output, cprof);
|
|
|
|
if (!ok) {
|
|
|
|
weston_log("Error: failed to set color profile '%s' for output %s\n",
|
|
|
|
weston_color_profile_get_description(cprof),
|
|
|
|
output->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_color_profile_unref(cprof);
|
|
|
|
return ok ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2021-07-16 17:43:43 +03:00
|
|
|
static int
|
|
|
|
wet_output_set_eotf_mode(struct weston_output *output,
|
|
|
|
struct weston_config_section *section)
|
|
|
|
{
|
|
|
|
static const struct {
|
|
|
|
const char *name;
|
|
|
|
enum weston_eotf_mode eotf_mode;
|
|
|
|
} modes[] = {
|
|
|
|
{ "sdr", WESTON_EOTF_MODE_SDR },
|
|
|
|
{ "hdr-gamma", WESTON_EOTF_MODE_TRADITIONAL_HDR },
|
|
|
|
{ "st2084", WESTON_EOTF_MODE_ST2084 },
|
|
|
|
{ "hlg", WESTON_EOTF_MODE_HLG },
|
|
|
|
};
|
|
|
|
struct wet_compositor *compositor;
|
|
|
|
enum weston_eotf_mode eotf_mode = WESTON_EOTF_MODE_SDR;
|
|
|
|
char *str = NULL;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
compositor = to_wet_compositor(output->compositor);
|
|
|
|
|
|
|
|
if (section) {
|
|
|
|
weston_config_section_get_string(section, "eotf-mode",
|
|
|
|
&str, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!str) {
|
|
|
|
/* The default SDR mode is always supported. */
|
|
|
|
assert(weston_output_get_supported_eotf_modes(output) & eotf_mode);
|
|
|
|
weston_output_set_eotf_mode(output, eotf_mode);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(modes); i++)
|
|
|
|
if (strcmp(str, modes[i].name) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == ARRAY_LENGTH(modes)) {
|
|
|
|
weston_log("Error in config for output '%s': '%s' is not a valid EOTF mode. Try one of:",
|
|
|
|
output->name, str);
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(modes); i++)
|
|
|
|
weston_log_continue(" %s", modes[i].name);
|
|
|
|
weston_log_continue("\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
eotf_mode = modes[i].eotf_mode;
|
|
|
|
|
|
|
|
if ((weston_output_get_supported_eotf_modes(output) & eotf_mode) == 0) {
|
|
|
|
weston_log("Error: output '%s' does not support EOTF mode %s.\n",
|
|
|
|
output->name, str);
|
2023-04-28 14:29:59 +03:00
|
|
|
#if !HAVE_LIBDISPLAY_INFO
|
|
|
|
weston_log_continue(STAMP_SPACE "Weston was built without libdisplay-info, "
|
|
|
|
"so HDR capabilities cannot be detected.\n");
|
|
|
|
#endif
|
2021-07-16 17:43:43 +03:00
|
|
|
free(str);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eotf_mode != WESTON_EOTF_MODE_SDR &&
|
|
|
|
!compositor->use_color_manager) {
|
|
|
|
weston_log("Error: EOTF mode %s on output '%s' requires color-management=true in weston.ini\n",
|
|
|
|
str, output->name);
|
|
|
|
free(str);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_output_set_eotf_mode(output, eotf_mode);
|
|
|
|
|
|
|
|
free(str);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-03-16 14:25:13 +03:00
|
|
|
struct wet_color_characteristics_keys {
|
|
|
|
const char *name;
|
|
|
|
enum weston_color_characteristics_groups group;
|
|
|
|
float minval;
|
|
|
|
float maxval;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define COLOR_CHARAC_NAME "color_characteristics"
|
|
|
|
|
|
|
|
static int
|
|
|
|
parse_color_characteristics(struct weston_color_characteristics *cc_out,
|
|
|
|
struct weston_config_section *section)
|
|
|
|
{
|
|
|
|
static const struct wet_color_characteristics_keys keys[] = {
|
|
|
|
{ "red_x", WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES, 0.0f, 1.0f },
|
|
|
|
{ "red_y", WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES, 0.0f, 1.0f },
|
|
|
|
{ "green_x", WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES, 0.0f, 1.0f },
|
|
|
|
{ "green_y", WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES, 0.0f, 1.0f },
|
|
|
|
{ "blue_x", WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES, 0.0f, 1.0f },
|
|
|
|
{ "blue_y", WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES, 0.0f, 1.0f },
|
|
|
|
{ "white_x", WESTON_COLOR_CHARACTERISTICS_GROUP_WHITE, 0.0f, 1.0f },
|
|
|
|
{ "white_y", WESTON_COLOR_CHARACTERISTICS_GROUP_WHITE, 0.0f, 1.0f },
|
|
|
|
{ "max_L", WESTON_COLOR_CHARACTERISTICS_GROUP_MAXL, 0.0f, 1e5f },
|
|
|
|
{ "min_L", WESTON_COLOR_CHARACTERISTICS_GROUP_MINL, 0.0f, 1e5f },
|
|
|
|
{ "maxFALL", WESTON_COLOR_CHARACTERISTICS_GROUP_MAXFALL, 0.0f, 1e5f },
|
|
|
|
};
|
|
|
|
static const char *msgpfx = "Config error in weston.ini [" COLOR_CHARAC_NAME "]";
|
|
|
|
struct weston_color_characteristics cc = {};
|
|
|
|
float *const keyvalp[ARRAY_LENGTH(keys)] = {
|
|
|
|
/* These must be in the same order as keys[]. */
|
|
|
|
&cc.primary[0].x, &cc.primary[0].y,
|
|
|
|
&cc.primary[1].x, &cc.primary[1].y,
|
|
|
|
&cc.primary[2].x, &cc.primary[2].y,
|
|
|
|
&cc.white.x, &cc.white.y,
|
|
|
|
&cc.max_luminance,
|
|
|
|
&cc.min_luminance,
|
|
|
|
&cc.maxFALL,
|
|
|
|
};
|
|
|
|
bool found[ARRAY_LENGTH(keys)] = {};
|
|
|
|
uint32_t missing_group_mask = 0;
|
|
|
|
unsigned i;
|
|
|
|
char *section_name;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "name",
|
|
|
|
§ion_name, "<unnamed>");
|
|
|
|
if (strchr(section_name, ':') != NULL) {
|
|
|
|
ret = -1;
|
|
|
|
weston_log("%s name=%s: reserved name. Do not use ':' character in the name.\n",
|
|
|
|
msgpfx, section_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse keys if they exist */
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(keys); i++) {
|
|
|
|
double value;
|
|
|
|
|
|
|
|
if (weston_config_section_get_double(section, keys[i].name,
|
|
|
|
&value, NAN) == 0) {
|
|
|
|
float f = value;
|
|
|
|
|
|
|
|
found[i] = true;
|
|
|
|
|
|
|
|
/* Range check, NaN shall not pass. */
|
|
|
|
if (f >= keys[i].minval && f <= keys[i].maxval) {
|
|
|
|
/* Key found, parsed, and good value. */
|
|
|
|
*keyvalp[i] = f;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = -1;
|
|
|
|
weston_log("%s name=%s: %s value %f is outside of the range %f - %f.\n",
|
|
|
|
msgpfx, section_name, keys[i].name, value,
|
|
|
|
keys[i].minval, keys[i].maxval);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errno == EINVAL) {
|
|
|
|
found[i] = true;
|
|
|
|
ret = -1;
|
|
|
|
weston_log("%s name=%s: failed to parse the value of key %s.\n",
|
|
|
|
msgpfx, section_name, keys[i].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Collect set and unset groups */
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(keys); i++) {
|
|
|
|
uint32_t group = keys[i].group;
|
|
|
|
|
|
|
|
if (found[i])
|
|
|
|
cc.group_mask |= group;
|
|
|
|
else
|
|
|
|
missing_group_mask |= group;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure groups are given fully or not at all. */
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(keys); i++) {
|
|
|
|
uint32_t group = keys[i].group;
|
|
|
|
|
|
|
|
if ((cc.group_mask & group) && (missing_group_mask & group)) {
|
|
|
|
ret = -1;
|
|
|
|
weston_log("%s name=%s: group %d key %s is %s. "
|
|
|
|
"You must set either none or all keys of a group.\n",
|
|
|
|
msgpfx, section_name, ffs(group), keys[i].name,
|
|
|
|
found[i] ? "set" : "missing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(section_name);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
*cc_out = cc;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
WESTON_EXPORT_FOR_TESTS int
|
|
|
|
wet_output_set_color_characteristics(struct weston_output *output,
|
|
|
|
struct weston_config *wc,
|
|
|
|
struct weston_config_section *section)
|
|
|
|
{
|
|
|
|
char *cc_name = NULL;
|
|
|
|
struct weston_config_section *cc_section;
|
|
|
|
struct weston_color_characteristics cc;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, COLOR_CHARAC_NAME,
|
|
|
|
&cc_name, NULL);
|
|
|
|
if (!cc_name)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cc_section = weston_config_get_section(wc, COLOR_CHARAC_NAME,
|
|
|
|
"name", cc_name);
|
|
|
|
if (!cc_section) {
|
|
|
|
weston_log("Config error in weston.ini, output %s: "
|
|
|
|
"no [" COLOR_CHARAC_NAME "] section with 'name=%s' found.\n",
|
|
|
|
output->name, cc_name);
|
|
|
|
goto out_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parse_color_characteristics(&cc, cc_section) < 0)
|
|
|
|
goto out_error;
|
|
|
|
|
|
|
|
weston_output_set_color_characteristics(output, &cc);
|
|
|
|
free(cc_name);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_error:
|
|
|
|
free(cc_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-03 07:44:59 +03:00
|
|
|
static void
|
|
|
|
allow_content_protection(struct weston_output *output,
|
|
|
|
struct weston_config_section *section)
|
|
|
|
{
|
2019-11-26 03:14:24 +03:00
|
|
|
bool allow_hdcp = true;
|
2019-04-03 07:44:59 +03:00
|
|
|
|
|
|
|
if (section)
|
2019-11-26 03:14:24 +03:00
|
|
|
weston_config_section_get_bool(section, "allow_hdcp",
|
|
|
|
&allow_hdcp, true);
|
2019-04-03 07:44:59 +03:00
|
|
|
|
|
|
|
weston_output_allow_protection(output, allow_hdcp);
|
|
|
|
}
|
|
|
|
|
2022-12-09 14:44:41 +03:00
|
|
|
static void
|
|
|
|
parse_simple_mode(struct weston_output *output,
|
|
|
|
struct weston_config_section *section, int *width,
|
|
|
|
int *height, struct wet_output_config *defaults,
|
|
|
|
struct wet_output_config *parsed_options)
|
|
|
|
{
|
|
|
|
*width = defaults->width;
|
|
|
|
*height = defaults->height;
|
|
|
|
|
|
|
|
if (section) {
|
|
|
|
char *mode;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "mode", &mode, NULL);
|
|
|
|
if (!mode || sscanf(mode, "%dx%d", width, height) != 2) {
|
|
|
|
weston_log("Invalid mode for output %s. Using defaults.\n",
|
|
|
|
output->name);
|
|
|
|
*width = defaults->width;
|
|
|
|
*height = defaults->height;
|
|
|
|
}
|
|
|
|
free(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parsed_options->width)
|
|
|
|
*width = parsed_options->width;
|
|
|
|
|
|
|
|
if (parsed_options->height)
|
|
|
|
*height = parsed_options->height;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:04 +03:00
|
|
|
static int
|
|
|
|
wet_configure_windowed_output_from_config(struct weston_output *output,
|
|
|
|
struct wet_output_config *defaults)
|
|
|
|
{
|
|
|
|
const struct weston_windowed_output_api *api =
|
|
|
|
weston_windowed_output_get_api(output->compositor);
|
|
|
|
|
|
|
|
struct weston_config *wc = wet_get_config(output->compositor);
|
|
|
|
struct weston_config_section *section = NULL;
|
|
|
|
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
|
|
|
struct wet_output_config *parsed_options = compositor->parsed_options;
|
2022-12-09 14:44:41 +03:00
|
|
|
int width;
|
|
|
|
int height;
|
2016-09-30 15:11:04 +03:00
|
|
|
|
|
|
|
assert(parsed_options);
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
weston_log("Cannot use weston_windowed_output_api.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
section = weston_config_get_section(wc, "output", "name", output->name);
|
|
|
|
|
2022-12-09 14:44:41 +03:00
|
|
|
parse_simple_mode(output, section, &width, &height, defaults,
|
|
|
|
parsed_options);
|
2016-09-30 15:11:04 +03:00
|
|
|
|
2019-04-03 07:44:59 +03:00
|
|
|
allow_content_protection(output, section);
|
|
|
|
|
2016-09-30 15:11:04 +03:00
|
|
|
wet_output_set_scale(output, section, defaults->scale, parsed_options->scale);
|
2020-03-07 00:45:50 +03:00
|
|
|
if (wet_output_set_transform(output, section, defaults->transform,
|
|
|
|
parsed_options->transform) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-30 15:11:04 +03:00
|
|
|
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
if (wet_output_set_color_profile(output, section, NULL) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2016-09-30 15:11:04 +03:00
|
|
|
if (api->output_set_size(output, width, height) < 0) {
|
|
|
|
weston_log("Cannot configure output \"%s\" using weston_windowed_output_api.\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
static int
|
|
|
|
count_remaining_heads(struct weston_output *output, struct weston_head *to_go)
|
|
|
|
{
|
|
|
|
struct weston_head *iter = NULL;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
while ((iter = weston_output_iterate_heads(output, iter))) {
|
|
|
|
if (iter != to_go)
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_head_tracker_destroy(struct wet_head_tracker *track)
|
|
|
|
{
|
|
|
|
wl_list_remove(&track->head_destroy_listener.link);
|
|
|
|
free(track);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_head_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_head *head = data;
|
|
|
|
struct weston_output *output;
|
|
|
|
struct wet_head_tracker *track =
|
|
|
|
container_of(listener, struct wet_head_tracker,
|
|
|
|
head_destroy_listener);
|
|
|
|
|
|
|
|
wet_head_tracker_destroy(track);
|
|
|
|
|
|
|
|
output = weston_head_get_output(head);
|
|
|
|
|
|
|
|
/* On shutdown path, the output might be already gone. */
|
|
|
|
if (!output)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (count_remaining_heads(output, head) > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_output_destroy(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wet_head_tracker *
|
|
|
|
wet_head_tracker_from_head(struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct wl_listener *lis;
|
|
|
|
|
|
|
|
lis = weston_head_get_destroy_listener(head, handle_head_destroy);
|
|
|
|
if (!lis)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(lis, struct wet_head_tracker,
|
|
|
|
head_destroy_listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Listen for head destroy signal.
|
|
|
|
*
|
|
|
|
* If a head is destroyed and it was the last head on the output, we
|
|
|
|
* destroy the associated output.
|
|
|
|
*
|
|
|
|
* Do not bother destroying the head trackers on shutdown, the backend will
|
|
|
|
* destroy the heads which calls our handler to destroy the trackers.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wet_head_tracker_create(struct wet_compositor *compositor,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct wet_head_tracker *track;
|
|
|
|
|
|
|
|
track = zalloc(sizeof *track);
|
|
|
|
if (!track)
|
|
|
|
return;
|
|
|
|
|
|
|
|
track->head_destroy_listener.notify = handle_head_destroy;
|
|
|
|
weston_head_add_destroy_listener(head, &track->head_destroy_listener);
|
|
|
|
}
|
|
|
|
|
2022-07-27 00:17:17 +03:00
|
|
|
/* Place output exactly to the right of the most recently enabled output.
|
|
|
|
*
|
|
|
|
* Historically, we haven't given much thought to output placement,
|
|
|
|
* simply adding outputs in a horizontal line as they're enabled. This
|
|
|
|
* function simply sets an output's x coordinate to the right of the
|
|
|
|
* most recently enabled output, and its y to zero.
|
|
|
|
*
|
|
|
|
* If you're adding new calls to this function, you're also not giving
|
|
|
|
* much thought to output placement, so please consider carefully if
|
|
|
|
* it's really doing what you want.
|
|
|
|
*
|
|
|
|
* You especially don't want to use this for any code that won't
|
|
|
|
* immediately enable the passed output.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
weston_output_lazy_align(struct weston_output *output)
|
|
|
|
{
|
|
|
|
struct weston_compositor *c;
|
|
|
|
struct weston_output *peer;
|
|
|
|
int next_x = 0;
|
|
|
|
|
|
|
|
/* Put this output to the right of the most recently enabled output */
|
|
|
|
c = output->compositor;
|
|
|
|
if (!wl_list_empty(&c->output_list)) {
|
|
|
|
peer = container_of(c->output_list.prev,
|
|
|
|
struct weston_output, link);
|
2022-11-09 23:28:15 +03:00
|
|
|
next_x = peer->pos.c.x + peer->width;
|
2022-07-27 00:17:17 +03:00
|
|
|
}
|
2022-11-09 23:28:15 +03:00
|
|
|
output->pos.c = weston_coord(next_x, 0);
|
2022-07-27 00:17:17 +03:00
|
|
|
}
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
static void
|
2017-11-02 16:38:24 +03:00
|
|
|
simple_head_enable(struct wet_compositor *wet, struct weston_head *head)
|
2017-08-17 13:10:28 +03:00
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
int ret = 0;
|
|
|
|
|
2021-03-29 14:51:31 +03:00
|
|
|
output = weston_compositor_create_output(wet->compositor, head,
|
|
|
|
head->name);
|
2017-08-17 13:10:28 +03:00
|
|
|
if (!output) {
|
|
|
|
weston_log("Could not create an output for head \"%s\".\n",
|
|
|
|
weston_head_get_name(head));
|
|
|
|
wet->init_failed = true;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-27 00:17:17 +03:00
|
|
|
weston_output_lazy_align(output);
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
if (wet->simple_output_configure)
|
|
|
|
ret = wet->simple_output_configure(output);
|
|
|
|
if (ret < 0) {
|
|
|
|
weston_log("Cannot configure output \"%s\".\n",
|
|
|
|
weston_head_get_name(head));
|
|
|
|
weston_output_destroy(output);
|
|
|
|
wet->init_failed = true;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_output_enable(output) < 0) {
|
|
|
|
weston_log("Enabling output \"%s\" failed.\n",
|
|
|
|
weston_head_get_name(head));
|
|
|
|
weston_output_destroy(output);
|
|
|
|
wet->init_failed = true;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wet_head_tracker_create(wet, head);
|
|
|
|
|
|
|
|
/* The weston_compositor will track and destroy the output on exit. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
simple_head_disable(struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct weston_output *output;
|
|
|
|
struct wet_head_tracker *track;
|
|
|
|
|
|
|
|
track = wet_head_tracker_from_head(head);
|
|
|
|
if (track)
|
|
|
|
wet_head_tracker_destroy(track);
|
|
|
|
|
|
|
|
output = weston_head_get_output(head);
|
|
|
|
assert(output);
|
|
|
|
weston_output_destroy(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
simple_heads_changed(struct wl_listener *listener, void *arg)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = arg;
|
2017-11-02 16:38:24 +03:00
|
|
|
struct wet_compositor *wet = to_wet_compositor(compositor);
|
2017-08-17 13:10:28 +03:00
|
|
|
struct weston_head *head = NULL;
|
|
|
|
bool connected;
|
|
|
|
bool enabled;
|
|
|
|
bool changed;
|
2018-08-30 18:41:42 +03:00
|
|
|
bool non_desktop;
|
2017-08-17 13:10:28 +03:00
|
|
|
|
2017-11-02 16:38:24 +03:00
|
|
|
while ((head = weston_compositor_iterate_heads(wet->compositor, head))) {
|
2017-08-17 13:10:28 +03:00
|
|
|
connected = weston_head_is_connected(head);
|
|
|
|
enabled = weston_head_is_enabled(head);
|
|
|
|
changed = weston_head_is_device_changed(head);
|
2018-08-30 18:41:42 +03:00
|
|
|
non_desktop = weston_head_is_non_desktop(head);
|
2017-08-17 13:10:28 +03:00
|
|
|
|
2018-08-30 18:41:42 +03:00
|
|
|
if (connected && !enabled && !non_desktop) {
|
2017-11-02 16:38:24 +03:00
|
|
|
simple_head_enable(wet, head);
|
2017-08-17 13:10:28 +03:00
|
|
|
} else if (!connected && enabled) {
|
|
|
|
simple_head_disable(head);
|
|
|
|
} else if (enabled && changed) {
|
|
|
|
weston_log("Detected a monitor change on head '%s', "
|
|
|
|
"not bothering to do anything about it.\n",
|
|
|
|
weston_head_get_name(head));
|
|
|
|
}
|
|
|
|
weston_head_reset_device_changed(head);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_set_simple_head_configurator(struct weston_compositor *compositor,
|
|
|
|
int (*fn)(struct weston_output *))
|
|
|
|
{
|
|
|
|
struct wet_compositor *wet = to_wet_compositor(compositor);
|
|
|
|
|
|
|
|
wet->simple_output_configure = fn;
|
|
|
|
|
|
|
|
wet->heads_changed_listener.notify = simple_heads_changed;
|
|
|
|
weston_compositor_add_heads_changed_listener(compositor,
|
|
|
|
&wet->heads_changed_listener);
|
|
|
|
}
|
|
|
|
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
static void
|
|
|
|
configure_input_device_accel(struct weston_config_section *s,
|
|
|
|
struct libinput_device *device)
|
|
|
|
{
|
|
|
|
char *profile_string = NULL;
|
|
|
|
int is_a_profile = 1;
|
|
|
|
uint32_t profiles;
|
|
|
|
enum libinput_config_accel_profile profile;
|
|
|
|
double speed;
|
|
|
|
|
|
|
|
if (weston_config_section_get_string(s, "accel-profile",
|
|
|
|
&profile_string, NULL) == 0) {
|
|
|
|
if (strcmp(profile_string, "flat") == 0)
|
|
|
|
profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
|
|
|
|
else if (strcmp(profile_string, "adaptive") == 0)
|
|
|
|
profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
|
|
|
|
else {
|
|
|
|
weston_log("warning: no such accel-profile: %s\n",
|
|
|
|
profile_string);
|
|
|
|
is_a_profile = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
profiles = libinput_device_config_accel_get_profiles(device);
|
|
|
|
if (is_a_profile && (profile & profiles) != 0) {
|
|
|
|
weston_log(" accel-profile=%s\n",
|
|
|
|
profile_string);
|
|
|
|
libinput_device_config_accel_set_profile(device,
|
|
|
|
profile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_config_section_get_double(s, "accel-speed",
|
|
|
|
&speed, 0) == 0 &&
|
|
|
|
speed >= -1. && speed <= 1.) {
|
|
|
|
weston_log(" accel-speed=%.3f\n", speed);
|
|
|
|
libinput_device_config_accel_set_speed(device, speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(profile_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
configure_input_device_scroll(struct weston_config_section *s,
|
|
|
|
struct libinput_device *device)
|
|
|
|
{
|
2019-11-26 03:14:24 +03:00
|
|
|
bool natural;
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
char *method_string = NULL;
|
|
|
|
uint32_t methods;
|
|
|
|
enum libinput_config_scroll_method method;
|
|
|
|
char *button_string = NULL;
|
|
|
|
int button;
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_has_natural_scroll(device) &&
|
|
|
|
weston_config_section_get_bool(s, "natural-scroll",
|
2019-11-26 03:14:24 +03:00
|
|
|
&natural, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" natural-scroll=%s\n",
|
|
|
|
natural ? "true" : "false");
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(
|
|
|
|
device, natural);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_config_section_get_string(s, "scroll-method",
|
|
|
|
&method_string, NULL) != 0)
|
|
|
|
goto done;
|
|
|
|
if (strcmp(method_string, "two-finger") == 0)
|
|
|
|
method = LIBINPUT_CONFIG_SCROLL_2FG;
|
|
|
|
else if (strcmp(method_string, "edge") == 0)
|
|
|
|
method = LIBINPUT_CONFIG_SCROLL_EDGE;
|
|
|
|
else if (strcmp(method_string, "button") == 0)
|
|
|
|
method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
|
|
|
|
else if (strcmp(method_string, "none") == 0)
|
|
|
|
method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
|
|
|
else {
|
|
|
|
weston_log("warning: no such scroll-method: %s\n",
|
|
|
|
method_string);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
methods = libinput_device_config_scroll_get_methods(device);
|
|
|
|
if (method != LIBINPUT_CONFIG_SCROLL_NO_SCROLL &&
|
|
|
|
(method & methods) == 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
weston_log(" scroll-method=%s\n", method_string);
|
|
|
|
libinput_device_config_scroll_set_method(device, method);
|
|
|
|
|
|
|
|
if (method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
|
|
|
|
if (weston_config_section_get_string(s, "scroll-button",
|
|
|
|
&button_string,
|
|
|
|
NULL) != 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
button = libevdev_event_code_from_name(EV_KEY, button_string);
|
|
|
|
if (button == -1) {
|
|
|
|
weston_log(" Bad scroll-button: %s\n",
|
|
|
|
button_string);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_log(" scroll-button=%s\n", button_string);
|
|
|
|
libinput_device_config_scroll_set_button(device, button);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
free(method_string);
|
|
|
|
free(button_string);
|
|
|
|
}
|
|
|
|
|
2016-06-02 21:48:12 +03:00
|
|
|
static void
|
|
|
|
configure_input_device(struct weston_compositor *compositor,
|
|
|
|
struct libinput_device *device)
|
|
|
|
{
|
|
|
|
struct weston_config_section *s;
|
|
|
|
struct weston_config *config = wet_get_config(compositor);
|
2019-11-26 03:14:24 +03:00
|
|
|
bool has_enable_tap = false;
|
|
|
|
bool enable_tap;
|
|
|
|
bool disable_while_typing;
|
|
|
|
bool middle_emulation;
|
|
|
|
bool tap_and_drag;
|
|
|
|
bool tap_and_drag_lock;
|
|
|
|
bool left_handed;
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
unsigned int rotation;
|
|
|
|
|
|
|
|
weston_log("libinput: configuring device \"%s\".\n",
|
|
|
|
libinput_device_get_name(device));
|
2016-06-02 21:48:12 +03:00
|
|
|
|
|
|
|
s = weston_config_get_section(config,
|
|
|
|
"libinput", NULL, NULL);
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) > 0) {
|
2019-02-01 02:24:04 +03:00
|
|
|
if (weston_config_section_get_bool(s, "enable_tap",
|
2019-11-26 03:14:24 +03:00
|
|
|
&enable_tap, false) == 0) {
|
2019-02-01 02:24:04 +03:00
|
|
|
weston_log("!!DEPRECATION WARNING!!: In weston.ini, "
|
|
|
|
"enable_tap is deprecated in favour of "
|
|
|
|
"enable-tap. Support for it may be removed "
|
|
|
|
"at any time!");
|
2019-11-26 03:14:24 +03:00
|
|
|
has_enable_tap = true;
|
2019-02-01 02:24:04 +03:00
|
|
|
}
|
|
|
|
if (weston_config_section_get_bool(s, "enable-tap",
|
2019-11-26 03:14:24 +03:00
|
|
|
&enable_tap, false) == 0)
|
|
|
|
has_enable_tap = true;
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
if (has_enable_tap) {
|
|
|
|
weston_log(" enable-tap=%s.\n",
|
|
|
|
enable_tap ? "true" : "false");
|
2019-02-01 02:24:04 +03:00
|
|
|
libinput_device_config_tap_set_enabled(device,
|
|
|
|
enable_tap);
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
}
|
|
|
|
if (weston_config_section_get_bool(s, "tap-and-drag",
|
2019-11-26 03:14:24 +03:00
|
|
|
&tap_and_drag, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" tap-and-drag=%s.\n",
|
|
|
|
tap_and_drag ? "true" : "false");
|
|
|
|
libinput_device_config_tap_set_drag_enabled(device,
|
|
|
|
tap_and_drag);
|
|
|
|
}
|
|
|
|
if (weston_config_section_get_bool(s, "tap-and-drag-lock",
|
2019-11-26 03:14:24 +03:00
|
|
|
&tap_and_drag_lock, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" tap-and-drag-lock=%s.\n",
|
|
|
|
tap_and_drag_lock ? "true" : "false");
|
|
|
|
libinput_device_config_tap_set_drag_lock_enabled(
|
|
|
|
device, tap_and_drag_lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (libinput_device_config_dwt_is_available(device) &&
|
|
|
|
weston_config_section_get_bool(s, "disable-while-typing",
|
2019-11-26 03:14:24 +03:00
|
|
|
&disable_while_typing, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" disable-while-typing=%s.\n",
|
|
|
|
disable_while_typing ? "true" : "false");
|
|
|
|
libinput_device_config_dwt_set_enabled(device,
|
|
|
|
disable_while_typing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (libinput_device_config_middle_emulation_is_available(device) &&
|
|
|
|
weston_config_section_get_bool(s, "middle-button-emulation",
|
2019-11-26 03:14:24 +03:00
|
|
|
&middle_emulation, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" middle-button-emulation=%s\n",
|
|
|
|
middle_emulation ? "true" : "false");
|
|
|
|
libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
device, middle_emulation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (libinput_device_config_left_handed_is_available(device) &&
|
|
|
|
weston_config_section_get_bool(s, "left-handed",
|
2019-11-26 03:14:24 +03:00
|
|
|
&left_handed, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" left-handed=%s\n",
|
|
|
|
left_handed ? "true" : "false");
|
|
|
|
libinput_device_config_left_handed_set(device, left_handed);
|
2016-06-02 21:48:12 +03:00
|
|
|
}
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
|
|
|
|
if (libinput_device_config_rotation_is_available(device) &&
|
|
|
|
weston_config_section_get_uint(s, "rotation",
|
2019-11-26 03:14:24 +03:00
|
|
|
&rotation, false) == 0) {
|
weston: add more libinput config options
This is so that, for instance, people using weston as their main Wayland
compositor can invert the sense of two finger scrolling or change
pointer acceleration using weston.ini, rather than having to edit C
code.
All of the options that libinput itself exposes through its API are now
exposed in weston.ini. The new options are called `tap-and-drag`,
`tap-and-drag-lock`, `disable-while-typing`, `middle-emulation`,
`left-handed`, `rotation`, `accel-profile`, `accel-speed`,
`scroll-method`, `natural-scroll`, and `scroll-button`. I have
successfully tested everything except for `rotation`, out of a lack of
hardware support.
weston now depends directly on libevdev for turning button name strings into
kernel input codes. This was needed for the `scroll-button` config
option. (weston already depends indirectly on libevdev through
libinput, so I figured people would be OK with this.) As a practical
matter for debian-style packagers, weston now has a build dependency on
libevdev-dev.
Right now, the code applies the same options to all attached devices
that a given option is relevant for. There are plans for multiple
[libinput] sections, each with different device filters, for users who
need more control here.
Signed-off-by: Eric Toombs <3672-ewtoombs@users.noreply.gitlab.freedesktop.org>
2019-02-01 05:53:25 +03:00
|
|
|
weston_log(" rotation=%u\n", rotation);
|
|
|
|
libinput_device_config_rotation_set_angle(device, rotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (libinput_device_config_accel_is_available(device))
|
|
|
|
configure_input_device_accel(s, device);
|
|
|
|
|
|
|
|
configure_input_device_scroll(s, device);
|
2016-06-02 21:48:12 +03:00
|
|
|
}
|
|
|
|
|
weston: migrate DRM to head-based output API
Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.
This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.
Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.
This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.
v9:
- Add the workaround in simple_head_enable().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-08-17 17:13:08 +03:00
|
|
|
static int
|
2017-11-03 10:56:05 +03:00
|
|
|
drm_backend_output_configure(struct weston_output *output,
|
|
|
|
struct weston_config_section *section)
|
2016-09-30 15:11:05 +03:00
|
|
|
{
|
2016-10-10 00:48:17 +03:00
|
|
|
struct wet_compositor *wet = to_wet_compositor(output->compositor);
|
2017-11-03 10:56:05 +03:00
|
|
|
const struct weston_drm_output_api *api;
|
2016-09-30 15:11:05 +03:00
|
|
|
enum weston_drm_backend_output_mode mode =
|
|
|
|
WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
|
2019-11-26 02:41:04 +03:00
|
|
|
uint32_t transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
2022-09-07 18:34:17 +03:00
|
|
|
uint32_t max_bpc = 0;
|
|
|
|
bool max_bpc_specified = false;
|
2016-09-30 15:11:05 +03:00
|
|
|
char *s;
|
|
|
|
char *modeline = NULL;
|
|
|
|
char *gbm_format = NULL;
|
2021-10-02 18:10:37 +03:00
|
|
|
char *content_type = NULL;
|
2016-09-30 15:11:05 +03:00
|
|
|
char *seat = NULL;
|
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
api = weston_drm_output_get_api(output->compositor);
|
2016-09-30 15:11:05 +03:00
|
|
|
if (!api) {
|
|
|
|
weston_log("Cannot use weston_drm_output_api.\n");
|
weston: migrate DRM to head-based output API
Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.
This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.
Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.
This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.
v9:
- Add the workaround in simple_head_enable().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-08-17 17:13:08 +03:00
|
|
|
return -1;
|
2016-09-30 15:11:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "mode", &s, "preferred");
|
2022-09-07 18:34:17 +03:00
|
|
|
if (weston_config_section_get_uint(section, "max-bpc", &max_bpc, 16) == 0)
|
|
|
|
max_bpc_specified = true;
|
2016-09-30 15:11:05 +03:00
|
|
|
|
|
|
|
if (strcmp(s, "off") == 0) {
|
2017-11-03 10:56:05 +03:00
|
|
|
assert(0 && "off was supposed to be pruned");
|
|
|
|
return -1;
|
2016-10-10 00:48:17 +03:00
|
|
|
} else if (wet->drm_use_current_mode || strcmp(s, "current") == 0) {
|
2016-09-30 15:11:05 +03:00
|
|
|
mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
|
2022-09-07 18:34:17 +03:00
|
|
|
/* If mode=current and no max-bpc was specfied on the .ini file,
|
|
|
|
use current max_bpc so full modeset is not done. */
|
2022-09-30 17:02:02 +03:00
|
|
|
if (!max_bpc_specified)
|
2022-09-07 18:34:17 +03:00
|
|
|
max_bpc = 0;
|
2016-09-30 15:11:05 +03:00
|
|
|
} else if (strcmp(s, "preferred") != 0) {
|
|
|
|
modeline = s;
|
|
|
|
s = NULL;
|
|
|
|
}
|
|
|
|
free(s);
|
|
|
|
|
|
|
|
if (api->set_mode(output, mode, modeline) < 0) {
|
2023-05-22 17:15:45 +03:00
|
|
|
weston_log("Cannot configure output \"%s\" using weston_drm_output_api.\n",
|
|
|
|
output->name);
|
2016-09-30 15:11:05 +03:00
|
|
|
free(modeline);
|
weston: migrate DRM to head-based output API
Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.
This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.
Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.
This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.
v9:
- Add the workaround in simple_head_enable().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-08-17 17:13:08 +03:00
|
|
|
return -1;
|
2016-09-30 15:11:05 +03:00
|
|
|
}
|
|
|
|
free(modeline);
|
|
|
|
|
2022-09-07 18:34:17 +03:00
|
|
|
api->set_max_bpc(output, max_bpc);
|
|
|
|
|
2019-11-26 02:41:04 +03:00
|
|
|
if (count_remaining_heads(output, NULL) == 1) {
|
|
|
|
struct weston_head *head = weston_output_get_first_head(output);
|
|
|
|
transform = weston_head_get_transform(head);
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:05 +03:00
|
|
|
wet_output_set_scale(output, section, 1, 0);
|
2019-11-26 02:41:04 +03:00
|
|
|
if (wet_output_set_transform(output, section, transform,
|
2020-03-07 00:45:50 +03:00
|
|
|
UINT32_MAX) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-30 15:11:05 +03:00
|
|
|
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
if (wet_output_set_color_profile(output, section, NULL) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2016-09-30 15:11:05 +03:00
|
|
|
weston_config_section_get_string(section,
|
|
|
|
"gbm-format", &gbm_format, NULL);
|
|
|
|
|
|
|
|
api->set_gbm_format(output, gbm_format);
|
|
|
|
free(gbm_format);
|
|
|
|
|
2021-10-02 18:10:37 +03:00
|
|
|
weston_config_section_get_string(section,
|
|
|
|
"content-type", &content_type, NULL);
|
|
|
|
if (api->set_content_type(output, content_type) < 0)
|
|
|
|
return -1;
|
|
|
|
free(content_type);
|
|
|
|
|
2016-09-30 15:11:05 +03:00
|
|
|
weston_config_section_get_string(section, "seat", &seat, "");
|
|
|
|
|
|
|
|
api->set_seat(output, seat);
|
|
|
|
free(seat);
|
|
|
|
|
2019-04-03 07:44:59 +03:00
|
|
|
allow_content_protection(output, section);
|
|
|
|
|
2021-07-16 17:43:43 +03:00
|
|
|
if (wet_output_set_eotf_mode(output, section) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2022-03-16 14:25:13 +03:00
|
|
|
if (wet_output_set_color_characteristics(output,
|
|
|
|
wet->config, section) < 0)
|
|
|
|
return -1;
|
|
|
|
|
weston: migrate DRM to head-based output API
Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.
This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.
Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.
This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.
v9:
- Add the workaround in simple_head_enable().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-08-17 17:13:08 +03:00
|
|
|
return 0;
|
2016-09-30 15:11:05 +03:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
/* Find the output section to use for configuring the output with the
|
|
|
|
* named head. If an output section with the given name contains
|
|
|
|
* a "same-as" key, ignore all other settings in the output section and
|
|
|
|
* instead find an output section named by the "same-as". Do this
|
|
|
|
* recursively.
|
|
|
|
*/
|
|
|
|
static struct weston_config_section *
|
|
|
|
drm_config_find_controlling_output_section(struct weston_config *config,
|
|
|
|
const char *head_name)
|
|
|
|
{
|
|
|
|
struct weston_config_section *section;
|
|
|
|
char *same_as;
|
|
|
|
int depth = 0;
|
|
|
|
|
|
|
|
same_as = strdup(head_name);
|
|
|
|
do {
|
|
|
|
section = weston_config_get_section(config, "output",
|
|
|
|
"name", same_as);
|
|
|
|
if (!section && depth > 0)
|
|
|
|
weston_log("Configuration error: "
|
|
|
|
"output section referred to with "
|
|
|
|
"'same-as=%s' not found.\n", same_as);
|
|
|
|
|
|
|
|
free(same_as);
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (++depth > 10) {
|
|
|
|
weston_log("Configuration error: "
|
|
|
|
"'same-as' nested too deep for output '%s'.\n",
|
|
|
|
head_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "same-as",
|
|
|
|
&same_as, NULL);
|
|
|
|
} while (same_as);
|
|
|
|
|
|
|
|
return section;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wet_layoutput *
|
|
|
|
wet_compositor_create_layoutput(struct wet_compositor *compositor,
|
|
|
|
const char *name,
|
|
|
|
struct weston_config_section *section)
|
|
|
|
{
|
|
|
|
struct wet_layoutput *lo;
|
|
|
|
|
|
|
|
lo = zalloc(sizeof *lo);
|
|
|
|
if (!lo)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
lo->compositor = compositor;
|
|
|
|
wl_list_insert(compositor->layoutput_list.prev, &lo->compositor_link);
|
|
|
|
wl_list_init(&lo->output_list);
|
|
|
|
lo->name = strdup(name);
|
|
|
|
lo->section = section;
|
|
|
|
|
|
|
|
return lo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_layoutput_destroy(struct wet_layoutput *lo)
|
|
|
|
{
|
|
|
|
wl_list_remove(&lo->compositor_link);
|
|
|
|
assert(wl_list_empty(&lo->output_list));
|
|
|
|
free(lo->name);
|
|
|
|
free(lo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_output_handle_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct wet_output *output;
|
|
|
|
|
|
|
|
output = wl_container_of(listener, output, output_destroy_listener);
|
|
|
|
assert(output->output == data);
|
|
|
|
|
|
|
|
output->output = NULL;
|
|
|
|
wl_list_remove(&output->output_destroy_listener.link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wet_output *
|
2021-03-24 11:08:20 +03:00
|
|
|
wet_layoutput_create_output_with_head(struct wet_layoutput *lo,
|
|
|
|
const char *name,
|
|
|
|
struct weston_head *head)
|
2017-11-03 10:56:05 +03:00
|
|
|
{
|
|
|
|
struct wet_output *output;
|
|
|
|
|
|
|
|
output = zalloc(sizeof *output);
|
|
|
|
if (!output)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
output->output =
|
|
|
|
weston_compositor_create_output(lo->compositor->compositor,
|
2021-03-24 11:08:20 +03:00
|
|
|
head, name);
|
2019-06-11 13:32:14 +03:00
|
|
|
if (!output->output) {
|
2017-11-03 10:56:05 +03:00
|
|
|
free(output);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
output->layoutput = lo;
|
|
|
|
wl_list_insert(lo->output_list.prev, &output->link);
|
|
|
|
output->output_destroy_listener.notify = wet_output_handle_destroy;
|
|
|
|
weston_output_add_destroy_listener(output->output,
|
|
|
|
&output->output_destroy_listener);
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wet_output *
|
|
|
|
wet_output_from_weston_output(struct weston_output *base)
|
|
|
|
{
|
|
|
|
struct wl_listener *lis;
|
|
|
|
|
|
|
|
lis = weston_output_get_destroy_listener(base,
|
|
|
|
wet_output_handle_destroy);
|
|
|
|
if (!lis)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(lis, struct wet_output, output_destroy_listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_output_destroy(struct wet_output *output)
|
|
|
|
{
|
2019-09-25 21:28:13 +03:00
|
|
|
if (output->output) {
|
|
|
|
/* output->output destruction may be deferred in some cases (see
|
|
|
|
* drm_output_destroy()), so we need to forcibly trigger the
|
|
|
|
* destruction callback now, or otherwise would later access
|
|
|
|
* data that we are about to free
|
|
|
|
*/
|
|
|
|
struct weston_output *save = output->output;
|
|
|
|
wet_output_handle_destroy(&output->output_destroy_listener, save);
|
|
|
|
weston_output_destroy(save);
|
|
|
|
}
|
2017-11-03 10:56:05 +03:00
|
|
|
|
|
|
|
wl_list_remove(&output->link);
|
|
|
|
free(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wet_layoutput *
|
|
|
|
wet_compositor_find_layoutput(struct wet_compositor *wet, const char *name)
|
|
|
|
{
|
|
|
|
struct wet_layoutput *lo;
|
|
|
|
|
|
|
|
wl_list_for_each(lo, &wet->layoutput_list, compositor_link)
|
|
|
|
if (strcmp(lo->name, name) == 0)
|
|
|
|
return lo;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_compositor_layoutput_add_head(struct wet_compositor *wet,
|
|
|
|
const char *output_name,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct wet_layoutput *lo;
|
|
|
|
|
|
|
|
lo = wet_compositor_find_layoutput(wet, output_name);
|
|
|
|
if (!lo) {
|
|
|
|
lo = wet_compositor_create_layoutput(wet, output_name, section);
|
|
|
|
if (!lo)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lo->add.n + 1 >= ARRAY_LENGTH(lo->add.heads))
|
|
|
|
return;
|
|
|
|
|
|
|
|
lo->add.heads[lo->add.n++] = head;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wet_compositor_destroy_layout(struct wet_compositor *wet)
|
|
|
|
{
|
|
|
|
struct wet_layoutput *lo, *lo_tmp;
|
|
|
|
struct wet_output *output, *output_tmp;
|
|
|
|
|
|
|
|
wl_list_for_each_safe(lo, lo_tmp,
|
|
|
|
&wet->layoutput_list, compositor_link) {
|
|
|
|
wl_list_for_each_safe(output, output_tmp,
|
|
|
|
&lo->output_list, link) {
|
|
|
|
wet_output_destroy(output);
|
|
|
|
}
|
|
|
|
wet_layoutput_destroy(lo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_head_prepare_enable(struct wet_compositor *wet,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
|
|
|
const char *name = weston_head_get_name(head);
|
|
|
|
struct weston_config_section *section;
|
|
|
|
char *output_name = NULL;
|
|
|
|
char *mode = NULL;
|
|
|
|
|
|
|
|
section = drm_config_find_controlling_output_section(wet->config, name);
|
|
|
|
if (section) {
|
2018-08-30 18:41:42 +03:00
|
|
|
/* skip outputs that are explicitly off, or non-desktop and not
|
|
|
|
* explicitly enabled. The backend turns them off automatically.
|
2017-11-03 10:56:05 +03:00
|
|
|
*/
|
|
|
|
weston_config_section_get_string(section, "mode", &mode, NULL);
|
|
|
|
if (mode && strcmp(mode, "off") == 0) {
|
|
|
|
free(mode);
|
|
|
|
return;
|
|
|
|
}
|
2018-08-30 18:41:42 +03:00
|
|
|
if (!mode && weston_head_is_non_desktop(head))
|
|
|
|
return;
|
2017-11-03 10:56:05 +03:00
|
|
|
free(mode);
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "name",
|
|
|
|
&output_name, NULL);
|
|
|
|
assert(output_name);
|
|
|
|
|
|
|
|
wet_compositor_layoutput_add_head(wet, output_name,
|
|
|
|
section, head);
|
|
|
|
free(output_name);
|
|
|
|
} else {
|
|
|
|
wet_compositor_layoutput_add_head(wet, name, NULL, head);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-23 14:34:36 +03:00
|
|
|
static bool
|
|
|
|
drm_head_should_force_enable(struct wet_compositor *wet,
|
|
|
|
struct weston_head *head)
|
|
|
|
{
|
|
|
|
const char *name = weston_head_get_name(head);
|
|
|
|
struct weston_config_section *section;
|
2019-11-26 03:14:24 +03:00
|
|
|
bool force;
|
2018-05-23 14:34:36 +03:00
|
|
|
|
|
|
|
section = drm_config_find_controlling_output_section(wet->config, name);
|
|
|
|
if (!section)
|
|
|
|
return false;
|
|
|
|
|
2019-11-26 03:14:24 +03:00
|
|
|
weston_config_section_get_bool(section, "force-on", &force, false);
|
|
|
|
return force;
|
2018-05-23 14:34:36 +03:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
static void
|
|
|
|
drm_try_attach(struct weston_output *output,
|
|
|
|
struct wet_head_array *add,
|
|
|
|
struct wet_head_array *failed)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2021-03-24 11:08:20 +03:00
|
|
|
/* try to attach remaining heads, this probably succeeds */
|
|
|
|
for (i = 1; i < add->n; i++) {
|
2017-11-03 10:56:05 +03:00
|
|
|
if (!add->heads[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (weston_output_attach_head(output, add->heads[i]) < 0) {
|
|
|
|
assert(failed->n < ARRAY_LENGTH(failed->heads));
|
|
|
|
|
|
|
|
failed->heads[failed->n++] = add->heads[i];
|
|
|
|
add->heads[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_try_enable(struct weston_output *output,
|
|
|
|
struct wet_head_array *undo,
|
|
|
|
struct wet_head_array *failed)
|
|
|
|
{
|
|
|
|
/* Try to enable, and detach heads one by one until it succeeds. */
|
|
|
|
while (!output->enabled) {
|
2022-07-27 00:17:17 +03:00
|
|
|
weston_output_lazy_align(output);
|
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
if (weston_output_enable(output) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* the next head to drop */
|
|
|
|
while (undo->n > 0 && undo->heads[--undo->n] == NULL)
|
|
|
|
;
|
|
|
|
|
|
|
|
/* No heads left to undo and failed to enable. */
|
|
|
|
if (undo->heads[undo->n] == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
assert(failed->n < ARRAY_LENGTH(failed->heads));
|
|
|
|
|
|
|
|
/* undo one head */
|
|
|
|
weston_head_detach(undo->heads[undo->n]);
|
|
|
|
failed->heads[failed->n++] = undo->heads[undo->n];
|
|
|
|
undo->heads[undo->n] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_try_attach_enable(struct weston_output *output, struct wet_layoutput *lo)
|
|
|
|
{
|
|
|
|
struct wet_head_array failed = {};
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
assert(!output->enabled);
|
|
|
|
|
|
|
|
drm_try_attach(output, &lo->add, &failed);
|
|
|
|
if (drm_backend_output_configure(output, lo->section) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (drm_try_enable(output, &lo->add, &failed) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* For all successfully attached/enabled heads */
|
|
|
|
for (i = 0; i < lo->add.n; i++)
|
|
|
|
if (lo->add.heads[i])
|
|
|
|
wet_head_tracker_create(lo->compositor,
|
|
|
|
lo->add.heads[i]);
|
|
|
|
|
|
|
|
/* Push failed heads to the next round. */
|
|
|
|
lo->add = failed;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_process_layoutput(struct wet_compositor *wet, struct wet_layoutput *lo)
|
|
|
|
{
|
|
|
|
struct wet_output *output, *tmp;
|
|
|
|
char *name = NULL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For each existing wet_output:
|
|
|
|
* try attach
|
|
|
|
* While heads left to enable:
|
|
|
|
* Create output
|
|
|
|
* try attach, try enable
|
|
|
|
*/
|
|
|
|
|
|
|
|
wl_list_for_each_safe(output, tmp, &lo->output_list, link) {
|
|
|
|
struct wet_head_array failed = {};
|
|
|
|
|
|
|
|
if (!output->output) {
|
|
|
|
/* Clean up left-overs from destroyed heads. */
|
|
|
|
wet_output_destroy(output);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(output->output->enabled);
|
|
|
|
|
|
|
|
drm_try_attach(output->output, &lo->add, &failed);
|
|
|
|
lo->add = failed;
|
|
|
|
if (lo->add.n == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!weston_compositor_find_output_by_name(wet->compositor, lo->name))
|
|
|
|
name = strdup(lo->name);
|
|
|
|
|
|
|
|
while (lo->add.n > 0) {
|
|
|
|
if (!wl_list_empty(&lo->output_list)) {
|
|
|
|
weston_log("Error: independent-CRTC clone mode is not implemented.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
ret = asprintf(&name, "%s:%s", lo->name,
|
|
|
|
weston_head_get_name(lo->add.heads[0]));
|
|
|
|
if (ret < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
2021-03-24 11:08:20 +03:00
|
|
|
output = wet_layoutput_create_output_with_head(lo, name,
|
|
|
|
lo->add.heads[0]);
|
2017-11-03 10:56:05 +03:00
|
|
|
free(name);
|
|
|
|
name = NULL;
|
|
|
|
|
|
|
|
if (!output)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (drm_try_attach_enable(output->output, lo) < 0) {
|
|
|
|
wet_output_destroy(output);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_process_layoutputs(struct wet_compositor *wet)
|
|
|
|
{
|
|
|
|
struct wet_layoutput *lo;
|
2023-05-31 15:09:48 +03:00
|
|
|
int failed_layoutputs = 0;
|
2017-11-03 10:56:05 +03:00
|
|
|
|
|
|
|
wl_list_for_each(lo, &wet->layoutput_list, compositor_link) {
|
|
|
|
if (lo->add.n == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (drm_process_layoutput(wet, lo) < 0) {
|
|
|
|
lo->add = (struct wet_head_array){};
|
2023-05-31 15:09:48 +03:00
|
|
|
failed_layoutputs += 1;
|
|
|
|
continue;
|
2017-11-03 10:56:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-31 15:09:48 +03:00
|
|
|
if (wet->require_outputs == REQUIRE_OUTPUTS_ALL_FOUND &&
|
|
|
|
failed_layoutputs > 0)
|
|
|
|
return -1;
|
|
|
|
if (wet->require_outputs == REQUIRE_OUTPUTS_ANY &&
|
|
|
|
failed_layoutputs == wl_list_length(&wet->layoutput_list))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
2017-11-03 10:56:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_head_disable(struct weston_head *head)
|
|
|
|
{
|
|
|
|
struct weston_output *output_base;
|
|
|
|
struct wet_output *output;
|
|
|
|
struct wet_head_tracker *track;
|
|
|
|
|
|
|
|
track = wet_head_tracker_from_head(head);
|
|
|
|
if (track)
|
|
|
|
wet_head_tracker_destroy(track);
|
|
|
|
|
|
|
|
output_base = weston_head_get_output(head);
|
|
|
|
assert(output_base);
|
|
|
|
output = wet_output_from_weston_output(output_base);
|
|
|
|
assert(output && output->output == output_base);
|
|
|
|
|
|
|
|
weston_head_detach(head);
|
|
|
|
if (count_remaining_heads(output->output, NULL) == 0)
|
|
|
|
wet_output_destroy(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_heads_changed(struct wl_listener *listener, void *arg)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = arg;
|
|
|
|
struct wet_compositor *wet = to_wet_compositor(compositor);
|
|
|
|
struct weston_head *head = NULL;
|
|
|
|
bool connected;
|
|
|
|
bool enabled;
|
|
|
|
bool changed;
|
2018-05-23 14:34:36 +03:00
|
|
|
bool forced;
|
2017-11-03 10:56:05 +03:00
|
|
|
|
|
|
|
/* We need to collect all cloned heads into outputs before enabling the
|
|
|
|
* output.
|
|
|
|
*/
|
|
|
|
while ((head = weston_compositor_iterate_heads(compositor, head))) {
|
|
|
|
connected = weston_head_is_connected(head);
|
|
|
|
enabled = weston_head_is_enabled(head);
|
|
|
|
changed = weston_head_is_device_changed(head);
|
2018-05-23 14:34:36 +03:00
|
|
|
forced = drm_head_should_force_enable(wet, head);
|
2017-11-03 10:56:05 +03:00
|
|
|
|
2018-05-23 14:34:36 +03:00
|
|
|
if ((connected || forced) && !enabled) {
|
2017-11-03 10:56:05 +03:00
|
|
|
drm_head_prepare_enable(wet, head);
|
2018-05-23 14:34:36 +03:00
|
|
|
} else if (!(connected || forced) && enabled) {
|
2017-11-03 10:56:05 +03:00
|
|
|
drm_head_disable(head);
|
|
|
|
} else if (enabled && changed) {
|
|
|
|
weston_log("Detected a monitor change on head '%s', "
|
|
|
|
"not bothering to do anything about it.\n",
|
|
|
|
weston_head_get_name(head));
|
|
|
|
}
|
|
|
|
weston_head_reset_device_changed(head);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drm_process_layoutputs(wet) < 0)
|
|
|
|
wet->init_failed = true;
|
|
|
|
}
|
|
|
|
|
2018-01-24 11:08:02 +03:00
|
|
|
static int
|
|
|
|
drm_backend_remoted_output_configure(struct weston_output *output,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
char *modeline,
|
|
|
|
const struct weston_remoting_api *api)
|
|
|
|
{
|
|
|
|
char *gbm_format = NULL;
|
|
|
|
char *seat = NULL;
|
|
|
|
char *host = NULL;
|
2019-05-22 06:21:32 +03:00
|
|
|
char *pipeline = NULL;
|
2018-01-24 11:08:02 +03:00
|
|
|
int port, ret;
|
|
|
|
|
|
|
|
ret = api->set_mode(output, modeline);
|
|
|
|
if (ret < 0) {
|
|
|
|
weston_log("Cannot configure an output \"%s\" using "
|
|
|
|
"weston_remoting_api. Invalid mode\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wet_output_set_scale(output, section, 1, 0);
|
2020-03-07 00:45:50 +03:00
|
|
|
if (wet_output_set_transform(output, section,
|
|
|
|
WL_OUTPUT_TRANSFORM_NORMAL,
|
|
|
|
UINT32_MAX) < 0) {
|
|
|
|
return -1;
|
|
|
|
};
|
2018-01-24 11:08:02 +03:00
|
|
|
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
if (wet_output_set_color_profile(output, section, NULL) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2018-01-24 11:08:02 +03:00
|
|
|
weston_config_section_get_string(section, "gbm-format", &gbm_format,
|
|
|
|
NULL);
|
|
|
|
api->set_gbm_format(output, gbm_format);
|
|
|
|
free(gbm_format);
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "seat", &seat, "");
|
|
|
|
|
|
|
|
api->set_seat(output, seat);
|
|
|
|
free(seat);
|
|
|
|
|
2019-05-22 06:21:32 +03:00
|
|
|
weston_config_section_get_string(section, "gst-pipeline", &pipeline,
|
|
|
|
NULL);
|
|
|
|
if (pipeline) {
|
|
|
|
api->set_gst_pipeline(output, pipeline);
|
|
|
|
free(pipeline);
|
|
|
|
return 0;
|
2018-01-24 11:08:02 +03:00
|
|
|
}
|
|
|
|
|
2019-05-22 06:21:32 +03:00
|
|
|
weston_config_section_get_string(section, "host", &host, NULL);
|
2018-01-24 11:08:02 +03:00
|
|
|
weston_config_section_get_int(section, "port", &port, 0);
|
2019-05-22 06:21:32 +03:00
|
|
|
if (!host || port <= 0 || 65533 < port) {
|
|
|
|
weston_log("Cannot configure an output \"%s\". "
|
|
|
|
"Need to specify gst-pipeline or "
|
|
|
|
"host and port (1-65533).\n", output->name);
|
2018-01-24 11:08:02 +03:00
|
|
|
}
|
2019-05-22 06:21:32 +03:00
|
|
|
api->set_host(output, host);
|
|
|
|
free(host);
|
2018-01-24 11:08:02 +03:00
|
|
|
api->set_port(output, port);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoted_output_init(struct weston_compositor *c,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
const struct weston_remoting_api *api)
|
|
|
|
{
|
|
|
|
struct weston_output *output = NULL;
|
|
|
|
char *output_name, *modeline = NULL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "name", &output_name,
|
|
|
|
NULL);
|
|
|
|
if (!output_name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "mode", &modeline, "off");
|
|
|
|
if (strcmp(modeline, "off") == 0)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
output = api->create_output(c, output_name);
|
|
|
|
if (!output) {
|
|
|
|
weston_log("Cannot create remoted output \"%s\".\n",
|
|
|
|
output_name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = drm_backend_remoted_output_configure(output, section, modeline,
|
|
|
|
api);
|
|
|
|
if (ret < 0) {
|
|
|
|
weston_log("Cannot configure remoted output \"%s\".\n",
|
|
|
|
output_name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_output_enable(output) < 0) {
|
|
|
|
weston_log("Enabling remoted output \"%s\" failed.\n",
|
|
|
|
output_name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(modeline);
|
|
|
|
free(output_name);
|
|
|
|
weston_log("remoted output '%s' enabled\n", output->name);
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
|
|
|
free(modeline);
|
|
|
|
free(output_name);
|
|
|
|
if (output)
|
|
|
|
weston_output_destroy(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_remoting(struct weston_compositor *c, struct weston_config *wc)
|
|
|
|
{
|
|
|
|
const struct weston_remoting_api *api = NULL;
|
|
|
|
int (*module_init)(struct weston_compositor *ec);
|
|
|
|
struct weston_config_section *section = NULL;
|
|
|
|
const char *section_name;
|
|
|
|
|
|
|
|
/* read remote-output section in weston.ini */
|
|
|
|
while (weston_config_next_section(wc, §ion, §ion_name)) {
|
|
|
|
if (strcmp(section_name, "remote-output"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
char *module_name;
|
|
|
|
struct weston_config_section *core_section =
|
|
|
|
weston_config_get_section(wc, "core", NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
weston_config_section_get_string(core_section,
|
|
|
|
"remoting",
|
|
|
|
&module_name,
|
|
|
|
"remoting-plugin.so");
|
|
|
|
module_init = weston_load_module(module_name,
|
2022-09-19 14:20:02 +03:00
|
|
|
"weston_module_init",
|
|
|
|
LIBWESTON_MODULEDIR);
|
2018-01-24 11:08:02 +03:00
|
|
|
free(module_name);
|
|
|
|
if (!module_init) {
|
|
|
|
weston_log("Can't load remoting-plugin\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (module_init(c) < 0) {
|
|
|
|
weston_log("Remoting-plugin init failed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
api = weston_remoting_get_api(c);
|
|
|
|
if (!api)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
remoted_output_init(c, section, api);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-23 13:34:05 +03:00
|
|
|
static int
|
|
|
|
drm_backend_pipewire_output_configure(struct weston_output *output,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
char *modeline,
|
|
|
|
const struct weston_pipewire_api *api)
|
|
|
|
{
|
|
|
|
char *seat = NULL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = api->set_mode(output, modeline);
|
|
|
|
if (ret < 0) {
|
|
|
|
weston_log("Cannot configure an output \"%s\" using "
|
|
|
|
"weston_pipewire_api. Invalid mode\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wet_output_set_scale(output, section, 1, 0);
|
2020-03-07 00:45:50 +03:00
|
|
|
if (wet_output_set_transform(output, section,
|
|
|
|
WL_OUTPUT_TRANSFORM_NORMAL,
|
|
|
|
UINT32_MAX) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2019-04-23 13:34:05 +03:00
|
|
|
|
compositor: add icc_profile weston.ini option for outputs
This adds "icc_profile" key support in [output] sections for backends
headless, x11, wayland, and drm, and also for remoted and pipewire
outputs FWIW. On the other hand, RDP-backend does not use output
sections from weston.ini, and fbdev-backend does not deserve anything
new (it wouldn't support color management anyway due to no GL-renderer).
This allows one to configure an ICC v2 or v4 file to be used as an
output profile. However, color-lcms does not actually use output
profiles yet, so trying this will fail until support is implemented.
The parent_winsys_profile argument is reserved for using the color
profile from a parent window system where applicable, if nothing else is
set in weston.ini. None of the nested backends provide an output color
profile yet. It is more of a reminder of a missing feature than a
serious implementation.
Note: cms-static Weston plugin uses the exact same weston.ini key for
loading VCGT from ICC profiles. If "color-management" option is set to
false, this new use of "icc_profile" is disabled and the old behavior
with cms-static is kept.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-08 16:17:20 +03:00
|
|
|
if (wet_output_set_color_profile(output, section, NULL) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2019-04-23 13:34:05 +03:00
|
|
|
weston_config_section_get_string(section, "seat", &seat, "");
|
|
|
|
|
|
|
|
api->set_seat(output, seat);
|
|
|
|
free(seat);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pipewire_output_init(struct weston_compositor *c,
|
|
|
|
struct weston_config_section *section,
|
|
|
|
const struct weston_pipewire_api *api)
|
|
|
|
{
|
|
|
|
struct weston_output *output = NULL;
|
|
|
|
char *output_name, *modeline = NULL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "name", &output_name,
|
|
|
|
NULL);
|
|
|
|
if (!output_name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "mode", &modeline, "off");
|
|
|
|
if (strcmp(modeline, "off") == 0)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
output = api->create_output(c, output_name);
|
|
|
|
if (!output) {
|
|
|
|
weston_log("Cannot create pipewire output \"%s\".\n",
|
|
|
|
output_name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = drm_backend_pipewire_output_configure(output, section, modeline,
|
|
|
|
api);
|
|
|
|
if (ret < 0) {
|
|
|
|
weston_log("Cannot configure pipewire output \"%s\".\n",
|
|
|
|
output_name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weston_output_enable(output) < 0) {
|
|
|
|
weston_log("Enabling pipewire output \"%s\" failed.\n",
|
|
|
|
output_name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(modeline);
|
|
|
|
free(output_name);
|
|
|
|
weston_log("pipewire output '%s' enabled\n", output->name);
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
|
|
|
free(modeline);
|
|
|
|
free(output_name);
|
|
|
|
if (output)
|
|
|
|
weston_output_destroy(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_pipewire(struct weston_compositor *c, struct weston_config *wc)
|
|
|
|
{
|
|
|
|
const struct weston_pipewire_api *api = NULL;
|
|
|
|
int (*module_init)(struct weston_compositor *ec);
|
|
|
|
struct weston_config_section *section = NULL;
|
|
|
|
const char *section_name;
|
|
|
|
|
|
|
|
/* read pipewire-output section in weston.ini */
|
|
|
|
while (weston_config_next_section(wc, §ion, §ion_name)) {
|
|
|
|
if (strcmp(section_name, "pipewire-output"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
char *module_name;
|
|
|
|
struct weston_config_section *core_section =
|
|
|
|
weston_config_get_section(wc, "core", NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
weston_config_section_get_string(core_section,
|
|
|
|
"pipewire",
|
|
|
|
&module_name,
|
|
|
|
"pipewire-plugin.so");
|
|
|
|
module_init = weston_load_module(module_name,
|
2022-09-19 14:20:02 +03:00
|
|
|
"weston_module_init",
|
|
|
|
LIBWESTON_MODULEDIR);
|
2019-04-23 13:34:05 +03:00
|
|
|
free(module_name);
|
|
|
|
if (!module_init) {
|
|
|
|
weston_log("Can't load pipewire-plugin\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (module_init(c) < 0) {
|
|
|
|
weston_log("Pipewire-plugin init failed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
api = weston_pipewire_get_api(c);
|
|
|
|
if (!api)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pipewire_output_init(c, section, api);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
static int
|
2022-12-30 00:12:24 +03:00
|
|
|
load_drm_backend(struct weston_compositor *c, int *argc, char **argv,
|
|
|
|
struct weston_config *wc, enum weston_renderer_type renderer)
|
2016-04-30 01:40:34 +03:00
|
|
|
{
|
|
|
|
struct weston_drm_backend_config config = {{ 0, }};
|
|
|
|
struct weston_config_section *section;
|
2016-10-10 00:48:17 +03:00
|
|
|
struct wet_compositor *wet = to_wet_compositor(c);
|
2020-12-06 14:10:18 +03:00
|
|
|
bool without_input = false;
|
2022-12-29 21:14:52 +03:00
|
|
|
bool force_pixman = false;
|
2016-04-30 01:40:34 +03:00
|
|
|
int ret = 0;
|
|
|
|
|
2016-10-10 00:48:17 +03:00
|
|
|
wet->drm_use_current_mode = false;
|
|
|
|
|
2018-09-21 12:50:32 +03:00
|
|
|
section = weston_config_get_section(wc, "core", NULL, NULL);
|
2022-07-31 13:20:13 +03:00
|
|
|
|
2022-12-29 21:14:52 +03:00
|
|
|
weston_config_section_get_bool(section, "use-pixman", &force_pixman,
|
|
|
|
false);
|
2018-09-21 12:50:32 +03:00
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
const struct weston_option options[] = {
|
|
|
|
{ WESTON_OPTION_STRING, "seat", 0, &config.seat_id },
|
2017-03-28 18:14:37 +03:00
|
|
|
{ WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device },
|
2021-11-11 19:40:54 +03:00
|
|
|
{ WESTON_OPTION_STRING, "additional-devices", 0, &config.additional_devices},
|
2019-11-26 03:32:22 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "current-mode", 0, &wet->drm_use_current_mode },
|
2022-12-29 21:14:52 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman },
|
2020-12-06 14:10:18 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "continue-without-input", false, &without_input }
|
2016-04-30 01:40:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(options, ARRAY_LENGTH(options), argc, argv);
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if (force_pixman && renderer != WESTON_RENDERER_AUTO) {
|
|
|
|
weston_log("error: conflicting renderer specification\n");
|
|
|
|
return -1;
|
|
|
|
} else if (force_pixman) {
|
2022-12-29 21:14:52 +03:00
|
|
|
config.renderer = WESTON_RENDERER_PIXMAN;
|
2022-12-30 00:12:24 +03:00
|
|
|
} else {
|
|
|
|
config.renderer = renderer;
|
|
|
|
}
|
2022-12-29 21:14:52 +03:00
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
section = weston_config_get_section(wc, "core", NULL, NULL);
|
|
|
|
weston_config_section_get_string(section,
|
|
|
|
"gbm-format", &config.gbm_format,
|
|
|
|
NULL);
|
2017-03-07 16:27:54 +03:00
|
|
|
weston_config_section_get_uint(section, "pageflip-timeout",
|
|
|
|
&config.pageflip_timeout, 0);
|
2019-11-26 03:32:22 +03:00
|
|
|
weston_config_section_get_bool(section, "pixman-shadow",
|
|
|
|
&config.use_pixman_shadow, true);
|
2020-12-06 14:10:18 +03:00
|
|
|
if (without_input)
|
|
|
|
c->require_input = !without_input;
|
2016-04-30 01:40:34 +03:00
|
|
|
|
|
|
|
config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
|
|
|
|
config.base.struct_size = sizeof(struct weston_drm_backend_config);
|
2016-06-02 21:48:12 +03:00
|
|
|
config.configure_device = configure_input_device;
|
2016-04-30 01:40:34 +03:00
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
wet->heads_changed_listener.notify = drm_heads_changed;
|
|
|
|
weston_compositor_add_heads_changed_listener(c,
|
|
|
|
&wet->heads_changed_listener);
|
weston: migrate DRM to head-based output API
Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.
This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.
Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.
This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.
v9:
- Add the workaround in simple_head_enable().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-08-17 17:13:08 +03:00
|
|
|
|
2016-06-03 15:23:46 +03:00
|
|
|
ret = weston_compositor_load_backend(c, WESTON_BACKEND_DRM,
|
|
|
|
&config.base);
|
2016-04-30 01:40:34 +03:00
|
|
|
|
2018-01-24 11:08:02 +03:00
|
|
|
/* remoting */
|
|
|
|
load_remoting(c, wc);
|
|
|
|
|
2019-04-23 13:34:05 +03:00
|
|
|
/* pipewire */
|
|
|
|
load_pipewire(c, wc);
|
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
free(config.gbm_format);
|
|
|
|
free(config.seat_id);
|
2021-06-18 23:16:14 +03:00
|
|
|
free(config.specific_device);
|
2016-04-30 01:40:34 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
static int
|
|
|
|
headless_backend_output_configure(struct weston_output *output)
|
2016-09-30 15:11:07 +03:00
|
|
|
{
|
|
|
|
struct wet_output_config defaults = {
|
|
|
|
.width = 1024,
|
|
|
|
.height = 640,
|
|
|
|
.scale = 1,
|
|
|
|
.transform = WL_OUTPUT_TRANSFORM_NORMAL
|
|
|
|
};
|
2021-07-16 17:43:43 +03:00
|
|
|
struct weston_config *wc = wet_get_config(output->compositor);
|
|
|
|
struct weston_config_section *section;
|
|
|
|
|
|
|
|
section = weston_config_get_section(wc, "output", "name", output->name);
|
|
|
|
if (wet_output_set_eotf_mode(output, section) < 0)
|
|
|
|
return -1;
|
2016-09-30 15:11:07 +03:00
|
|
|
|
2022-03-16 14:25:13 +03:00
|
|
|
if (wet_output_set_color_characteristics(output, wc, section) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
return wet_configure_windowed_output_from_config(output, &defaults);
|
2016-09-30 15:11:07 +03:00
|
|
|
}
|
|
|
|
|
2016-04-16 06:28:32 +03:00
|
|
|
static int
|
2016-06-03 15:28:40 +03:00
|
|
|
load_headless_backend(struct weston_compositor *c,
|
2022-12-30 00:12:24 +03:00
|
|
|
int *argc, char **argv, struct weston_config *wc,
|
|
|
|
enum weston_renderer_type renderer)
|
2016-04-16 06:28:32 +03:00
|
|
|
{
|
2016-09-30 15:11:07 +03:00
|
|
|
const struct weston_windowed_output_api *api;
|
2016-04-16 06:28:32 +03:00
|
|
|
struct weston_headless_backend_config config = {{ 0, }};
|
2018-09-21 12:50:32 +03:00
|
|
|
struct weston_config_section *section;
|
2022-12-29 21:20:26 +03:00
|
|
|
bool force_pixman;
|
|
|
|
bool force_gl;
|
2020-02-03 03:45:36 +03:00
|
|
|
bool no_outputs = false;
|
2016-04-16 06:28:32 +03:00
|
|
|
int ret = 0;
|
2016-04-29 16:21:54 +03:00
|
|
|
char *transform = NULL;
|
2016-04-16 06:28:32 +03:00
|
|
|
|
2016-09-30 15:11:07 +03:00
|
|
|
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
|
|
|
if (!parsed_options)
|
|
|
|
return -1;
|
2016-04-16 06:28:32 +03:00
|
|
|
|
2018-09-21 12:50:32 +03:00
|
|
|
section = weston_config_get_section(wc, "core", NULL, NULL);
|
2022-12-29 21:20:26 +03:00
|
|
|
weston_config_section_get_bool(section, "use-pixman", &force_pixman,
|
2019-11-26 03:14:24 +03:00
|
|
|
false);
|
2022-12-29 21:20:26 +03:00
|
|
|
weston_config_section_get_bool(section, "use-gl", &force_gl,
|
2019-11-26 03:14:24 +03:00
|
|
|
false);
|
2022-07-13 16:25:12 +03:00
|
|
|
weston_config_section_get_bool(section, "output-decorations", &config.decorate,
|
|
|
|
false);
|
2018-09-21 12:50:32 +03:00
|
|
|
|
2016-04-16 06:28:32 +03:00
|
|
|
const struct weston_option options[] = {
|
2016-09-30 15:11:07 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
|
|
|
|
{ WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
|
2020-01-22 12:33:34 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "scale", 0, &parsed_options->scale },
|
2022-12-29 21:20:26 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman },
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "use-gl", 0, &force_gl },
|
2016-04-16 06:28:32 +03:00
|
|
|
{ WESTON_OPTION_STRING, "transform", 0, &transform },
|
2016-09-30 15:11:07 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "no-outputs", 0, &no_outputs },
|
2016-04-16 06:28:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(options, ARRAY_LENGTH(options), argc, argv);
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if ((force_pixman && force_gl) ||
|
|
|
|
(renderer != WESTON_RENDERER_AUTO && (force_pixman || force_gl))) {
|
2022-12-29 21:20:26 +03:00
|
|
|
weston_log("Conflicting renderer specifications\n");
|
|
|
|
return -1;
|
|
|
|
} else if (force_pixman) {
|
|
|
|
config.renderer = WESTON_RENDERER_PIXMAN;
|
|
|
|
} else if (force_gl) {
|
|
|
|
config.renderer = WESTON_RENDERER_GL;
|
|
|
|
} else {
|
2022-12-30 00:12:24 +03:00
|
|
|
config.renderer = renderer;
|
2022-12-29 21:20:26 +03:00
|
|
|
}
|
|
|
|
|
2016-04-29 16:21:54 +03:00
|
|
|
if (transform) {
|
2016-09-30 15:11:07 +03:00
|
|
|
if (weston_parse_transform(transform, &parsed_options->transform) < 0) {
|
2016-04-29 16:21:54 +03:00
|
|
|
weston_log("Invalid transform \"%s\"\n", transform);
|
2020-03-09 19:26:34 +03:00
|
|
|
return -1;
|
2016-09-30 15:11:07 +03:00
|
|
|
}
|
2016-04-29 16:21:54 +03:00
|
|
|
free(transform);
|
|
|
|
}
|
2016-04-16 06:28:32 +03:00
|
|
|
|
|
|
|
config.base.struct_version = WESTON_HEADLESS_BACKEND_CONFIG_VERSION;
|
|
|
|
config.base.struct_size = sizeof(struct weston_headless_backend_config);
|
|
|
|
|
2017-08-17 13:10:28 +03:00
|
|
|
wet_set_simple_head_configurator(c, headless_backend_output_configure);
|
|
|
|
|
2016-04-16 06:28:32 +03:00
|
|
|
/* load the actual wayland backend and configure it */
|
2016-06-03 15:23:46 +03:00
|
|
|
ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS,
|
|
|
|
&config.base);
|
2016-04-16 06:28:32 +03:00
|
|
|
|
2016-09-30 15:11:07 +03:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (!no_outputs) {
|
|
|
|
api = weston_windowed_output_get_api(c);
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
weston_log("Cannot use weston_windowed_output_api.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-04-16 19:20:10 +03:00
|
|
|
if (api->create_head(c->backend, "headless") < 0)
|
2016-09-30 15:11:07 +03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2016-04-16 06:28:32 +03:00
|
|
|
}
|
|
|
|
|
2021-05-09 17:52:36 +03:00
|
|
|
static int
|
|
|
|
pipewire_backend_output_configure(struct weston_output *output)
|
|
|
|
{
|
|
|
|
struct wet_output_config defaults = {
|
|
|
|
.width = 640,
|
|
|
|
.height = 480,
|
|
|
|
};
|
|
|
|
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
|
|
|
struct wet_output_config *parsed_options = compositor->parsed_options;
|
|
|
|
const struct weston_pipewire_output_api *api = weston_pipewire_output_get_api(output->compositor);
|
|
|
|
struct weston_config *wc = wet_get_config(output->compositor);
|
|
|
|
struct weston_config_section *section;
|
|
|
|
char *gbm_format = NULL;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
assert(parsed_options);
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
weston_log("Cannot use weston_pipewire_output_api.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
section = weston_config_get_section(wc, "output", "name", output->name);
|
|
|
|
|
|
|
|
parse_simple_mode(output, section, &width, &height, &defaults,
|
|
|
|
parsed_options);
|
|
|
|
|
|
|
|
if (section)
|
|
|
|
weston_config_section_get_string(section, "gbm-format",
|
|
|
|
&gbm_format, NULL);
|
|
|
|
|
|
|
|
weston_output_set_scale(output, 1);
|
|
|
|
weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
|
|
|
|
|
|
|
|
api->set_gbm_format(output, gbm_format);
|
|
|
|
free(gbm_format);
|
|
|
|
|
|
|
|
if (api->output_set_size(output, width, height) < 0) {
|
|
|
|
weston_log("Cannot configure output \"%s\" using weston_pipewire_output_api.\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
weston_log("pipewire_backend_output_configure.. Done\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_pipewire_backend_config_init(struct weston_pipewire_backend_config *config)
|
|
|
|
{
|
|
|
|
config->base.struct_version = WESTON_PIPEWIRE_BACKEND_CONFIG_VERSION;
|
|
|
|
config->base.struct_size = sizeof(struct weston_pipewire_backend_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
load_pipewire_backend(struct weston_compositor *c,
|
|
|
|
int *argc, char *argv[], struct weston_config *wc,
|
|
|
|
enum weston_renderer_type renderer)
|
|
|
|
{
|
|
|
|
struct weston_pipewire_backend_config config = {{ 0, }};
|
|
|
|
struct weston_config_section *section;
|
|
|
|
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
|
|
|
|
|
|
|
if (!parsed_options)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
weston_pipewire_backend_config_init(&config);
|
|
|
|
|
|
|
|
const struct weston_option pipewire_options[] = {
|
|
|
|
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
|
|
|
|
{ WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
|
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(pipewire_options, ARRAY_LENGTH(pipewire_options), argc, argv);
|
|
|
|
|
|
|
|
config.renderer = renderer;
|
|
|
|
|
|
|
|
wet_set_simple_head_configurator(c, pipewire_backend_output_configure);
|
|
|
|
|
|
|
|
section = weston_config_get_section(wc, "core", NULL, NULL);
|
|
|
|
weston_config_section_get_string(section, "gbm-format",
|
|
|
|
&config.gbm_format, NULL);
|
|
|
|
|
|
|
|
section = weston_config_get_section(wc, "pipewire", NULL, NULL);
|
|
|
|
weston_config_section_get_int(section, "num-outputs",
|
|
|
|
&config.num_outputs, 1);
|
|
|
|
|
|
|
|
return weston_compositor_load_backend(c, WESTON_BACKEND_PIPEWIRE,
|
|
|
|
&config.base);
|
|
|
|
}
|
|
|
|
|
2016-04-22 18:05:26 +03:00
|
|
|
static void
|
|
|
|
weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
|
|
|
|
{
|
|
|
|
config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
|
|
|
|
config->base.struct_size = sizeof(struct weston_rdp_backend_config);
|
|
|
|
|
2022-12-29 23:36:20 +03:00
|
|
|
config->renderer = WESTON_RENDERER_AUTO;
|
2016-04-22 18:05:26 +03:00
|
|
|
config->bind_address = NULL;
|
|
|
|
config->port = 3389;
|
|
|
|
config->rdp_key = NULL;
|
|
|
|
config->server_cert = NULL;
|
|
|
|
config->server_key = NULL;
|
|
|
|
config->env_socket = 0;
|
2022-03-15 20:24:42 +03:00
|
|
|
config->external_listener_fd = -1;
|
2016-04-22 18:05:26 +03:00
|
|
|
config->no_clients_resize = 0;
|
2019-06-20 17:27:27 +03:00
|
|
|
config->force_no_compression = 0;
|
2022-04-14 20:25:43 +03:00
|
|
|
config->remotefx_codec = true;
|
2022-03-17 20:08:42 +03:00
|
|
|
config->refresh_rate = RDP_DEFAULT_FREQ;
|
2016-04-22 18:05:26 +03:00
|
|
|
}
|
|
|
|
|
2022-08-09 21:52:51 +03:00
|
|
|
static void
|
|
|
|
rdp_handle_layout(struct weston_compositor *ec)
|
|
|
|
{
|
|
|
|
struct wet_compositor *wc = to_wet_compositor(ec);
|
|
|
|
struct wet_output_config *parsed_options = wc->parsed_options;
|
|
|
|
const struct weston_rdp_output_api *api = weston_rdp_output_get_api(ec);
|
|
|
|
struct weston_rdp_monitor config;
|
|
|
|
struct weston_head *head = NULL;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int scale = 1;
|
|
|
|
|
|
|
|
while ((head = weston_compositor_iterate_heads(ec, head))) {
|
2022-02-07 19:13:01 +03:00
|
|
|
struct weston_coord_global pos;
|
2022-08-09 21:52:51 +03:00
|
|
|
struct weston_output *output = head->output;
|
|
|
|
struct weston_mode new_mode = {};
|
|
|
|
|
|
|
|
assert(output);
|
|
|
|
|
|
|
|
api->head_get_monitor(head, &config);
|
|
|
|
|
|
|
|
width = config.width;
|
|
|
|
height = config.height;
|
|
|
|
scale = config.desktop_scale / 100;
|
|
|
|
|
|
|
|
/* If these are invalid, the backend is expecting
|
|
|
|
* us to provide defaults.
|
|
|
|
*/
|
|
|
|
width = width ? width : parsed_options->width;
|
|
|
|
height = height ? height : parsed_options->height;
|
|
|
|
scale = scale ? scale : parsed_options->scale;
|
|
|
|
|
|
|
|
/* Fallback to 640 x 480 if we have nothing to use */
|
|
|
|
width = width ? width : 640;
|
|
|
|
height = height ? height : 480;
|
|
|
|
scale = scale ? scale : 1;
|
|
|
|
|
|
|
|
new_mode.width = width;
|
|
|
|
new_mode.height = height;
|
|
|
|
api->output_set_mode(output, &new_mode);
|
|
|
|
|
|
|
|
weston_output_set_scale(output, scale);
|
|
|
|
weston_output_set_transform(output,
|
|
|
|
WL_OUTPUT_TRANSFORM_NORMAL);
|
2022-02-07 19:13:01 +03:00
|
|
|
pos.c = weston_coord(config.x, config.y);
|
|
|
|
weston_output_move(output, pos);
|
2022-08-09 21:52:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rdp_heads_changed(struct wl_listener *listener, void *arg)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = arg;
|
|
|
|
struct wet_compositor *wet = to_wet_compositor(compositor);
|
|
|
|
struct weston_head *head = NULL;
|
|
|
|
|
|
|
|
while ((head = weston_compositor_iterate_heads(compositor, head))) {
|
|
|
|
if (head->output)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
struct weston_output *out;
|
|
|
|
|
|
|
|
out = weston_compositor_create_output(compositor,
|
|
|
|
head, head->name);
|
|
|
|
|
|
|
|
wet_head_tracker_create(wet, head);
|
|
|
|
weston_output_attach_head(out, head);
|
|
|
|
}
|
|
|
|
|
|
|
|
rdp_handle_layout(compositor);
|
|
|
|
|
|
|
|
while ((head = weston_compositor_iterate_heads(compositor, head))) {
|
|
|
|
if (!head->output->enabled)
|
|
|
|
weston_output_enable(head->output);
|
|
|
|
|
|
|
|
weston_head_reset_device_changed(head);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-22 18:05:26 +03:00
|
|
|
static int
|
2016-06-03 15:28:40 +03:00
|
|
|
load_rdp_backend(struct weston_compositor *c,
|
2022-12-30 00:12:24 +03:00
|
|
|
int *argc, char *argv[], struct weston_config *wc,
|
|
|
|
enum weston_renderer_type renderer)
|
2016-04-22 18:05:26 +03:00
|
|
|
{
|
|
|
|
struct weston_rdp_backend_config config = {{ 0, }};
|
2022-03-17 20:08:42 +03:00
|
|
|
struct weston_config_section *section;
|
2016-04-22 18:05:26 +03:00
|
|
|
int ret = 0;
|
2022-04-14 20:25:43 +03:00
|
|
|
bool no_remotefx_codec = false;
|
2016-09-30 15:11:08 +03:00
|
|
|
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
2022-08-09 21:52:51 +03:00
|
|
|
struct wet_compositor *wet = to_wet_compositor(c);
|
|
|
|
|
2016-09-30 15:11:08 +03:00
|
|
|
if (!parsed_options)
|
|
|
|
return -1;
|
|
|
|
|
2016-04-22 18:05:26 +03:00
|
|
|
weston_rdp_backend_config_init(&config);
|
|
|
|
|
|
|
|
const struct weston_option rdp_options[] = {
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
|
2022-03-15 20:24:42 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "external-listener-fd", 0, &config.external_listener_fd },
|
2016-09-30 15:11:08 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
|
|
|
|
{ WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
|
2016-04-22 18:05:26 +03:00
|
|
|
{ WESTON_OPTION_STRING, "address", 0, &config.bind_address },
|
|
|
|
{ WESTON_OPTION_INTEGER, "port", 0, &config.port },
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, &config.no_clients_resize },
|
|
|
|
{ WESTON_OPTION_STRING, "rdp4-key", 0, &config.rdp_key },
|
|
|
|
{ WESTON_OPTION_STRING, "rdp-tls-cert", 0, &config.server_cert },
|
2019-06-20 17:27:27 +03:00
|
|
|
{ WESTON_OPTION_STRING, "rdp-tls-key", 0, &config.server_key },
|
2022-08-09 21:52:51 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "scale", 0, &parsed_options->scale },
|
2019-06-20 17:27:27 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "force-no-compression", 0, &config.force_no_compression },
|
2022-04-14 20:25:43 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "no-remotefx-codec", 0, &no_remotefx_codec },
|
2016-04-22 18:05:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
|
2022-04-14 20:25:43 +03:00
|
|
|
config.remotefx_codec = !no_remotefx_codec;
|
2022-12-30 00:12:24 +03:00
|
|
|
config.renderer = renderer;
|
2016-04-22 18:05:26 +03:00
|
|
|
|
2022-03-17 20:08:42 +03:00
|
|
|
section = weston_config_get_section(wc, "rdp", NULL, NULL);
|
|
|
|
weston_config_section_get_int(section, "refresh-rate",
|
|
|
|
&config.refresh_rate,
|
|
|
|
RDP_DEFAULT_FREQ);
|
2023-07-11 14:54:50 +03:00
|
|
|
weston_config_section_get_string(section, "tls-cert",
|
|
|
|
&config.server_cert,
|
|
|
|
config.server_cert);
|
|
|
|
weston_config_section_get_string(section, "tls-key",
|
|
|
|
&config.server_key, config.server_key);
|
2017-08-17 17:09:01 +03:00
|
|
|
|
2022-08-09 21:52:51 +03:00
|
|
|
wet->heads_changed_listener.notify = rdp_heads_changed;
|
|
|
|
weston_compositor_add_heads_changed_listener(c,
|
|
|
|
&wet->heads_changed_listener);
|
|
|
|
|
2016-06-03 15:23:46 +03:00
|
|
|
ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
|
|
|
|
&config.base);
|
2016-04-22 18:05:26 +03:00
|
|
|
|
|
|
|
free(config.bind_address);
|
|
|
|
free(config.rdp_key);
|
|
|
|
free(config.server_cert);
|
|
|
|
free(config.server_key);
|
2016-09-30 15:11:08 +03:00
|
|
|
|
2016-04-22 18:05:26 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-22 20:40:04 +03:00
|
|
|
static int
|
|
|
|
vnc_backend_output_configure(struct weston_output *output)
|
|
|
|
{
|
2022-05-29 11:27:10 +03:00
|
|
|
struct wet_output_config defaults = {
|
|
|
|
.width = 640,
|
|
|
|
.height = 480,
|
|
|
|
};
|
2019-09-22 20:40:04 +03:00
|
|
|
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
|
|
|
struct wet_output_config *parsed_options = compositor->parsed_options;
|
|
|
|
const struct weston_vnc_output_api *api = weston_vnc_output_get_api(output->compositor);
|
2022-05-29 11:27:10 +03:00
|
|
|
struct weston_config *wc = wet_get_config(output->compositor);
|
|
|
|
struct weston_config_section *section;
|
|
|
|
int width;
|
|
|
|
int height;
|
2019-09-22 20:40:04 +03:00
|
|
|
|
|
|
|
assert(parsed_options);
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
weston_log("Cannot use weston_vnc_output_api.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-05-29 11:27:10 +03:00
|
|
|
section = weston_config_get_section(wc, "output", "name", output->name);
|
2019-09-22 20:40:04 +03:00
|
|
|
|
2022-05-29 11:27:10 +03:00
|
|
|
parse_simple_mode(output, section, &width, &height, &defaults,
|
|
|
|
compositor->parsed_options);
|
2019-09-22 20:40:04 +03:00
|
|
|
|
|
|
|
weston_output_set_scale(output, 1);
|
|
|
|
weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
|
|
|
|
|
|
|
|
if (api->output_set_size(output, width, height) < 0) {
|
|
|
|
weston_log("Cannot configure output \"%s\" using weston_vnc_output_api.\n",
|
|
|
|
output->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
weston_log("vnc_backend_output_configure.. Done\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_vnc_backend_config_init(struct weston_vnc_backend_config *config)
|
|
|
|
{
|
|
|
|
config->base.struct_version = WESTON_VNC_BACKEND_CONFIG_VERSION;
|
|
|
|
config->base.struct_size = sizeof(struct weston_vnc_backend_config);
|
|
|
|
|
2022-12-29 23:38:28 +03:00
|
|
|
config->renderer = WESTON_RENDERER_AUTO;
|
2019-09-22 20:40:04 +03:00
|
|
|
config->bind_address = NULL;
|
|
|
|
config->port = 5900;
|
|
|
|
config->refresh_rate = VNC_DEFAULT_FREQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
load_vnc_backend(struct weston_compositor *c,
|
2022-12-30 00:12:24 +03:00
|
|
|
int *argc, char *argv[], struct weston_config *wc,
|
|
|
|
enum weston_renderer_type renderer)
|
2019-09-22 20:40:04 +03:00
|
|
|
{
|
|
|
|
struct weston_vnc_backend_config config = {{ 0, }};
|
|
|
|
struct weston_config_section *section;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
|
|
|
if (!parsed_options)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
weston_vnc_backend_config_init(&config);
|
|
|
|
|
|
|
|
const struct weston_option vnc_options[] = {
|
|
|
|
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
|
|
|
|
{ WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
|
|
|
|
{ WESTON_OPTION_STRING, "address", 0, &config.bind_address },
|
|
|
|
{ WESTON_OPTION_INTEGER, "port", 0, &config.port },
|
2022-10-06 13:18:04 +03:00
|
|
|
{ WESTON_OPTION_STRING, "vnc-tls-cert", 0, &config.server_cert },
|
|
|
|
{ WESTON_OPTION_STRING, "vnc-tls-key", 0, &config.server_key },
|
2019-09-22 20:40:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(vnc_options, ARRAY_LENGTH(vnc_options), argc, argv);
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
config.renderer = renderer;
|
|
|
|
|
2019-09-22 20:40:04 +03:00
|
|
|
wet_set_simple_head_configurator(c, vnc_backend_output_configure);
|
|
|
|
section = weston_config_get_section(wc, "vnc", NULL, NULL);
|
|
|
|
weston_config_section_get_int(section, "refresh-rate",
|
|
|
|
&config.refresh_rate,
|
|
|
|
VNC_DEFAULT_FREQ);
|
2023-07-11 14:54:50 +03:00
|
|
|
weston_config_section_get_string(section, "tls-cert",
|
|
|
|
&config.server_cert,
|
|
|
|
config.server_cert);
|
|
|
|
weston_config_section_get_string(section, "tls-key",
|
|
|
|
&config.server_key, config.server_key);
|
2019-09-22 20:40:04 +03:00
|
|
|
|
|
|
|
ret = weston_compositor_load_backend(c, WESTON_BACKEND_VNC,
|
|
|
|
&config.base);
|
|
|
|
|
|
|
|
free(config.bind_address);
|
2022-10-06 13:18:04 +03:00
|
|
|
free(config.server_cert);
|
|
|
|
free(config.server_key);
|
2019-09-22 20:40:04 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-08-17 16:54:58 +03:00
|
|
|
static int
|
|
|
|
x11_backend_output_configure(struct weston_output *output)
|
2016-09-30 15:11:10 +03:00
|
|
|
{
|
|
|
|
struct wet_output_config defaults = {
|
|
|
|
.width = 1024,
|
|
|
|
.height = 600,
|
|
|
|
.scale = 1,
|
|
|
|
.transform = WL_OUTPUT_TRANSFORM_NORMAL
|
|
|
|
};
|
2016-04-16 06:28:31 +03:00
|
|
|
|
2017-08-17 16:54:58 +03:00
|
|
|
return wet_configure_windowed_output_from_config(output, &defaults);
|
2016-04-16 06:28:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-06-03 15:28:40 +03:00
|
|
|
load_x11_backend(struct weston_compositor *c,
|
2022-12-30 00:12:24 +03:00
|
|
|
int *argc, char **argv, struct weston_config *wc,
|
|
|
|
enum weston_renderer_type renderer)
|
2016-04-16 06:28:31 +03:00
|
|
|
{
|
2016-09-30 15:11:10 +03:00
|
|
|
char *default_output;
|
|
|
|
const struct weston_windowed_output_api *api;
|
2016-04-16 06:28:31 +03:00
|
|
|
struct weston_x11_backend_config config = {{ 0, }};
|
|
|
|
struct weston_config_section *section;
|
2022-12-29 23:31:37 +03:00
|
|
|
bool force_pixman;
|
2016-04-16 06:28:31 +03:00
|
|
|
int ret = 0;
|
|
|
|
int option_count = 1;
|
|
|
|
int output_count = 0;
|
|
|
|
char const *section_name;
|
|
|
|
int i;
|
2016-09-30 15:11:10 +03:00
|
|
|
|
|
|
|
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
|
|
|
if (!parsed_options)
|
|
|
|
return -1;
|
2016-04-16 06:28:31 +03:00
|
|
|
|
2018-09-21 12:50:32 +03:00
|
|
|
section = weston_config_get_section(wc, "core", NULL, NULL);
|
2022-12-29 23:31:37 +03:00
|
|
|
weston_config_section_get_bool(section, "use-pixman", &force_pixman,
|
2019-11-26 03:14:24 +03:00
|
|
|
false);
|
2018-09-21 12:50:32 +03:00
|
|
|
|
2016-04-16 06:28:31 +03:00
|
|
|
const struct weston_option options[] = {
|
2016-09-30 15:11:10 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
|
|
|
|
{ WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
|
|
|
|
{ WESTON_OPTION_INTEGER, "scale", 0, &parsed_options->scale },
|
2019-11-26 03:32:22 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "fullscreen", 'f', &config.fullscreen },
|
2016-04-16 06:28:31 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "output-count", 0, &option_count },
|
2019-11-26 03:32:22 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "no-input", 0, &config.no_input },
|
2022-12-29 23:31:37 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman },
|
2016-04-16 06:28:31 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(options, ARRAY_LENGTH(options), argc, argv);
|
|
|
|
|
2016-09-30 15:11:10 +03:00
|
|
|
config.base.struct_version = WESTON_X11_BACKEND_CONFIG_VERSION;
|
|
|
|
config.base.struct_size = sizeof(struct weston_x11_backend_config);
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if (force_pixman && renderer != WESTON_RENDERER_AUTO) {
|
|
|
|
weston_log("error: conflicting renderer specification\n");
|
|
|
|
return -1;
|
|
|
|
} else if (force_pixman) {
|
2022-12-29 23:31:37 +03:00
|
|
|
config.renderer = WESTON_RENDERER_PIXMAN;
|
2022-12-30 00:12:24 +03:00
|
|
|
} else {
|
2023-01-29 15:39:30 +03:00
|
|
|
config.renderer = renderer;
|
2022-12-30 00:12:24 +03:00
|
|
|
}
|
2022-12-29 23:31:37 +03:00
|
|
|
|
2017-08-17 16:54:58 +03:00
|
|
|
wet_set_simple_head_configurator(c, x11_backend_output_configure);
|
|
|
|
|
2016-09-30 15:11:10 +03:00
|
|
|
/* load the actual backend and configure it */
|
|
|
|
ret = weston_compositor_load_backend(c, WESTON_BACKEND_X11,
|
|
|
|
&config.base);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
api = weston_windowed_output_get_api(c);
|
|
|
|
|
|
|
|
if (!api) {
|
|
|
|
weston_log("Cannot use weston_windowed_output_api.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-04-16 06:28:31 +03:00
|
|
|
section = NULL;
|
|
|
|
while (weston_config_next_section(wc, §ion, §ion_name)) {
|
2016-09-30 15:11:10 +03:00
|
|
|
char *output_name;
|
|
|
|
|
|
|
|
if (output_count >= option_count)
|
|
|
|
break;
|
2016-04-16 06:28:31 +03:00
|
|
|
|
|
|
|
if (strcmp(section_name, "output") != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:10 +03:00
|
|
|
weston_config_section_get_string(section, "name", &output_name, NULL);
|
|
|
|
if (output_name == NULL || output_name[0] != 'X') {
|
|
|
|
free(output_name);
|
2016-04-16 06:28:31 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-04-16 19:20:10 +03:00
|
|
|
if (api->create_head(c->backend, output_name) < 0) {
|
2016-09-30 15:11:10 +03:00
|
|
|
free(output_name);
|
|
|
|
return -1;
|
2016-04-16 06:28:31 +03:00
|
|
|
}
|
2016-09-30 15:11:10 +03:00
|
|
|
free(output_name);
|
2016-04-16 06:28:31 +03:00
|
|
|
|
|
|
|
output_count++;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:10 +03:00
|
|
|
default_output = NULL;
|
2016-04-16 06:28:31 +03:00
|
|
|
|
|
|
|
for (i = output_count; i < option_count; i++) {
|
2016-09-30 15:11:10 +03:00
|
|
|
if (asprintf(&default_output, "screen%d", i) < 0) {
|
|
|
|
return -1;
|
2016-04-16 06:28:31 +03:00
|
|
|
}
|
|
|
|
|
2023-04-16 19:20:10 +03:00
|
|
|
if (api->create_head(c->backend, default_output) < 0) {
|
2016-09-30 15:11:10 +03:00
|
|
|
free(default_output);
|
|
|
|
return -1;
|
2016-04-16 06:28:31 +03:00
|
|
|
}
|
2016-09-30 15:11:10 +03:00
|
|
|
free(default_output);
|
2016-04-16 06:28:31 +03:00
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:10 +03:00
|
|
|
return 0;
|
2016-04-28 00:56:42 +03:00
|
|
|
}
|
|
|
|
|
2017-08-17 16:59:53 +03:00
|
|
|
static int
|
|
|
|
wayland_backend_output_configure(struct weston_output *output)
|
2016-05-10 23:47:49 +03:00
|
|
|
{
|
2016-09-30 15:11:09 +03:00
|
|
|
struct wet_output_config defaults = {
|
|
|
|
.width = 1024,
|
|
|
|
.height = 640,
|
|
|
|
.scale = 1,
|
|
|
|
.transform = WL_OUTPUT_TRANSFORM_NORMAL
|
|
|
|
};
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2017-08-17 16:59:53 +03:00
|
|
|
return wet_configure_windowed_output_from_config(output, &defaults);
|
2016-05-10 23:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-09-30 15:11:09 +03:00
|
|
|
load_wayland_backend(struct weston_compositor *c,
|
2022-12-30 00:12:24 +03:00
|
|
|
int *argc, char **argv, struct weston_config *wc,
|
|
|
|
enum weston_renderer_type renderer)
|
2016-05-10 23:47:49 +03:00
|
|
|
{
|
2016-09-30 15:11:09 +03:00
|
|
|
struct weston_wayland_backend_config config = {{ 0, }};
|
2016-05-10 23:47:49 +03:00
|
|
|
struct weston_config_section *section;
|
2016-09-30 15:11:09 +03:00
|
|
|
const struct weston_windowed_output_api *api;
|
2016-05-10 23:47:49 +03:00
|
|
|
const char *section_name;
|
2016-09-30 15:11:09 +03:00
|
|
|
char *output_name = NULL;
|
2022-12-29 23:26:18 +03:00
|
|
|
bool force_pixman = false;
|
2016-09-30 15:11:09 +03:00
|
|
|
int count = 1;
|
|
|
|
int ret = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
|
|
|
if (!parsed_options)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
config.cursor_size = 32;
|
|
|
|
config.cursor_theme = NULL;
|
|
|
|
config.display_name = NULL;
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2018-09-21 12:50:32 +03:00
|
|
|
section = weston_config_get_section(wc, "core", NULL, NULL);
|
2022-12-29 23:26:18 +03:00
|
|
|
weston_config_section_get_bool(section, "use-pixman", &force_pixman,
|
2019-11-26 03:14:24 +03:00
|
|
|
false);
|
2018-09-21 12:50:32 +03:00
|
|
|
|
2016-05-10 23:47:49 +03:00
|
|
|
const struct weston_option wayland_options[] = {
|
2016-09-30 15:11:09 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
|
|
|
|
{ WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
|
|
|
|
{ WESTON_OPTION_INTEGER, "scale", 0, &parsed_options->scale },
|
|
|
|
{ WESTON_OPTION_STRING, "display", 0, &config.display_name },
|
2022-12-29 23:26:18 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman },
|
2016-05-10 23:47:49 +03:00
|
|
|
{ WESTON_OPTION_INTEGER, "output-count", 0, &count },
|
2019-11-26 03:32:22 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "fullscreen", 0, &config.fullscreen },
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "sprawl", 0, &config.sprawl },
|
2016-05-10 23:47:49 +03:00
|
|
|
};
|
|
|
|
|
2016-09-30 15:11:09 +03:00
|
|
|
parse_options(wayland_options, ARRAY_LENGTH(wayland_options), argc, argv);
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2016-05-10 23:47:50 +03:00
|
|
|
section = weston_config_get_section(wc, "shell", NULL, NULL);
|
2016-05-10 23:47:49 +03:00
|
|
|
weston_config_section_get_string(section, "cursor-theme",
|
2016-09-30 15:11:09 +03:00
|
|
|
&config.cursor_theme, NULL);
|
2016-05-10 23:47:49 +03:00
|
|
|
weston_config_section_get_int(section, "cursor-size",
|
2016-09-30 15:11:09 +03:00
|
|
|
&config.cursor_size, 32);
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2016-09-30 15:11:09 +03:00
|
|
|
config.base.struct_size = sizeof(struct weston_wayland_backend_config);
|
|
|
|
config.base.struct_version = WESTON_WAYLAND_BACKEND_CONFIG_VERSION;
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if (force_pixman && renderer != WESTON_RENDERER_AUTO) {
|
|
|
|
weston_log("error: conflicting renderer specification\n");
|
|
|
|
return -1;
|
|
|
|
} else if (force_pixman) {
|
2022-12-29 23:26:18 +03:00
|
|
|
config.renderer = WESTON_RENDERER_PIXMAN;
|
2022-12-30 00:12:24 +03:00
|
|
|
} else {
|
|
|
|
config.renderer = renderer;
|
|
|
|
}
|
2022-12-29 23:26:18 +03:00
|
|
|
|
2016-09-30 15:11:09 +03:00
|
|
|
/* load the actual wayland backend and configure it */
|
|
|
|
ret = weston_compositor_load_backend(c, WESTON_BACKEND_WAYLAND,
|
|
|
|
&config.base);
|
|
|
|
|
|
|
|
free(config.cursor_theme);
|
|
|
|
free(config.display_name);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
api = weston_windowed_output_get_api(c);
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2016-09-30 15:11:09 +03:00
|
|
|
if (api == NULL) {
|
|
|
|
/* We will just assume if load_backend() finished cleanly and
|
|
|
|
* windowed_output_api is not present that wayland backend is
|
2017-08-17 16:59:53 +03:00
|
|
|
* started with --sprawl or runs on fullscreen-shell.
|
|
|
|
* In this case, all values are hardcoded, so nothing can be
|
|
|
|
* configured; simply create and enable an output. */
|
|
|
|
wet_set_simple_head_configurator(c, NULL);
|
2016-05-10 23:47:49 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-17 16:59:53 +03:00
|
|
|
wet_set_simple_head_configurator(c, wayland_backend_output_configure);
|
2016-09-30 15:11:09 +03:00
|
|
|
|
2016-05-10 23:47:49 +03:00
|
|
|
section = NULL;
|
2016-05-10 23:47:50 +03:00
|
|
|
while (weston_config_next_section(wc, §ion, §ion_name)) {
|
2016-09-30 15:11:09 +03:00
|
|
|
if (count == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (strcmp(section_name, "output") != 0) {
|
2016-05-10 23:47:49 +03:00
|
|
|
continue;
|
2016-09-30 15:11:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
weston_config_section_get_string(section, "name", &output_name, NULL);
|
|
|
|
|
|
|
|
if (output_name == NULL)
|
2016-05-10 23:47:49 +03:00
|
|
|
continue;
|
|
|
|
|
2016-09-30 15:11:09 +03:00
|
|
|
if (output_name[0] != 'W' || output_name[1] != 'L') {
|
|
|
|
free(output_name);
|
2016-05-10 23:47:49 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-04-16 19:20:10 +03:00
|
|
|
if (api->create_head(c->backend, output_name) < 0) {
|
2016-09-30 15:11:09 +03:00
|
|
|
free(output_name);
|
2016-05-10 23:47:57 +03:00
|
|
|
return -1;
|
2016-09-30 15:11:09 +03:00
|
|
|
}
|
|
|
|
free(output_name);
|
2016-05-10 23:47:49 +03:00
|
|
|
|
|
|
|
--count;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:11:09 +03:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
if (asprintf(&output_name, "wayland%d", i) < 0)
|
2016-05-10 23:47:57 +03:00
|
|
|
return -1;
|
2016-05-10 23:47:49 +03:00
|
|
|
|
2023-04-16 19:20:10 +03:00
|
|
|
if (api->create_head(c->backend, output_name) < 0) {
|
2016-09-30 15:11:09 +03:00
|
|
|
free(output_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
free(output_name);
|
2016-05-10 23:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-17 19:24:15 +03:00
|
|
|
static int
|
2022-12-29 20:27:58 +03:00
|
|
|
load_backend(struct weston_compositor *compositor, const char *name,
|
2022-12-30 00:12:24 +03:00
|
|
|
int *argc, char **argv, struct weston_config *config,
|
|
|
|
const char *renderer_name)
|
2015-10-17 19:24:15 +03:00
|
|
|
{
|
2022-12-29 20:27:58 +03:00
|
|
|
enum weston_compositor_backend backend;
|
2022-12-30 00:12:24 +03:00
|
|
|
enum weston_renderer_type renderer;
|
2022-12-29 20:27:58 +03:00
|
|
|
|
|
|
|
if (!get_backend_from_string(name, &backend)) {
|
|
|
|
weston_log("Error: unknown backend \"%s\"\n", name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if (!get_renderer_from_string(renderer_name, &renderer)) {
|
|
|
|
weston_log("Error: unknown renderer \"%s\"\n", renderer_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-12-29 20:27:58 +03:00
|
|
|
switch (backend) {
|
|
|
|
case WESTON_BACKEND_DRM:
|
2022-12-30 00:12:24 +03:00
|
|
|
return load_drm_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2022-12-29 20:27:58 +03:00
|
|
|
case WESTON_BACKEND_HEADLESS:
|
2022-12-30 00:12:24 +03:00
|
|
|
return load_headless_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2021-05-09 17:52:36 +03:00
|
|
|
case WESTON_BACKEND_PIPEWIRE:
|
|
|
|
return load_pipewire_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2022-12-29 20:27:58 +03:00
|
|
|
case WESTON_BACKEND_RDP:
|
2022-12-30 00:12:24 +03:00
|
|
|
return load_rdp_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2022-12-29 20:27:58 +03:00
|
|
|
case WESTON_BACKEND_VNC:
|
2022-12-30 00:12:24 +03:00
|
|
|
return load_vnc_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2022-12-29 20:27:58 +03:00
|
|
|
case WESTON_BACKEND_WAYLAND:
|
2022-12-30 00:12:24 +03:00
|
|
|
return load_wayland_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2022-12-29 20:27:58 +03:00
|
|
|
case WESTON_BACKEND_X11:
|
2022-12-30 00:12:24 +03:00
|
|
|
return load_x11_backend(compositor, argc, argv, config,
|
|
|
|
renderer);
|
2022-12-29 20:27:58 +03:00
|
|
|
default:
|
|
|
|
unreachable("unknown backend type in load_backend()");
|
|
|
|
}
|
2015-10-17 19:24:15 +03:00
|
|
|
}
|
|
|
|
|
2016-02-11 15:42:21 +03:00
|
|
|
static char *
|
|
|
|
copy_command_line(int argc, char * const argv[])
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
char *str = NULL;
|
|
|
|
size_t size = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fp = open_memstream(&str, &size);
|
|
|
|
if (!fp)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
fprintf(fp, "%s", argv[0]);
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
fprintf(fp, " %s", argv[i]);
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2019-02-13 17:59:59 +03:00
|
|
|
#if !defined(BUILD_XWAYLAND)
|
2023-05-01 21:15:52 +03:00
|
|
|
void *
|
2019-02-13 17:59:59 +03:00
|
|
|
wet_load_xwayland(struct weston_compositor *comp)
|
|
|
|
{
|
2023-05-01 21:15:52 +03:00
|
|
|
return NULL;
|
2019-02-13 17:59:59 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-06-24 06:50:53 +03:00
|
|
|
static int
|
|
|
|
execute_autolaunch(struct wet_compositor *wet, struct weston_config *config)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
pid_t tmp_pid = -1;
|
|
|
|
char *autolaunch_path = NULL;
|
|
|
|
struct weston_config_section *section = NULL;
|
|
|
|
|
|
|
|
section = weston_config_get_section(config, "autolaunch", NULL, NULL);
|
|
|
|
weston_config_section_get_string(section, "path", &autolaunch_path, "");
|
|
|
|
weston_config_section_get_bool(section, "watch", &wet->autolaunch_watch, false);
|
|
|
|
|
|
|
|
if (!strlen(autolaunch_path))
|
|
|
|
goto out_ok;
|
|
|
|
|
|
|
|
if (access(autolaunch_path, X_OK) != 0) {
|
|
|
|
weston_log("Specified autolaunch path (%s) is not executable\n", autolaunch_path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_pid = fork();
|
|
|
|
if (tmp_pid == -1) {
|
|
|
|
weston_log("Failed to fork autolaunch process: %s\n", strerror(errno));
|
|
|
|
goto out;
|
|
|
|
} else if (tmp_pid == 0) {
|
2022-12-08 16:53:24 +03:00
|
|
|
cleanup_for_child_process();
|
2021-06-24 06:50:53 +03:00
|
|
|
execl(autolaunch_path, autolaunch_path, NULL);
|
|
|
|
/* execl shouldn't return */
|
|
|
|
fprintf(stderr, "Failed to execute autolaunch: %s\n", strerror(errno));
|
|
|
|
_exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
out_ok:
|
|
|
|
ret = 0;
|
|
|
|
out:
|
|
|
|
wet->autolaunch_pid = tmp_pid;
|
|
|
|
free(autolaunch_path);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-06-22 23:39:19 +03:00
|
|
|
static void
|
|
|
|
weston_log_setup_scopes(struct weston_log_context *log_ctx,
|
|
|
|
struct weston_log_subscriber *subscriber,
|
|
|
|
const char *names)
|
|
|
|
{
|
|
|
|
assert(log_ctx);
|
|
|
|
assert(subscriber);
|
|
|
|
|
|
|
|
char *tokenize = strdup(names);
|
|
|
|
char *token = strtok(tokenize, ",");
|
|
|
|
while (token) {
|
|
|
|
weston_log_subscribe(log_ctx, subscriber, token);
|
|
|
|
token = strtok(NULL, ",");
|
|
|
|
}
|
|
|
|
free(tokenize);
|
|
|
|
}
|
|
|
|
|
2019-06-27 19:19:26 +03:00
|
|
|
static void
|
|
|
|
flight_rec_key_binding_handler(struct weston_keyboard *keyboard,
|
|
|
|
const struct timespec *time, uint32_t key,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct weston_log_subscriber *flight_rec = data;
|
|
|
|
weston_log_subscriber_display_flight_rec(flight_rec);
|
|
|
|
}
|
|
|
|
|
2019-07-08 13:20:02 +03:00
|
|
|
static void
|
|
|
|
weston_log_subscribe_to_scopes(struct weston_log_context *log_ctx,
|
|
|
|
struct weston_log_subscriber *logger,
|
|
|
|
struct weston_log_subscriber *flight_rec,
|
|
|
|
const char *log_scopes,
|
|
|
|
const char *flight_rec_scopes)
|
|
|
|
{
|
2021-09-23 22:06:57 +03:00
|
|
|
if (logger && log_scopes)
|
2019-07-08 13:20:02 +03:00
|
|
|
weston_log_setup_scopes(log_ctx, logger, log_scopes);
|
|
|
|
else
|
|
|
|
weston_log_subscribe(log_ctx, logger, "log");
|
|
|
|
|
2021-09-23 22:06:57 +03:00
|
|
|
if (flight_rec && flight_rec_scopes)
|
2019-07-08 13:20:02 +03:00
|
|
|
weston_log_setup_scopes(log_ctx, flight_rec, flight_rec_scopes);
|
|
|
|
}
|
|
|
|
|
2022-09-30 17:02:02 +03:00
|
|
|
static void
|
|
|
|
screenshot_allow_all(struct wl_listener *l,
|
|
|
|
struct weston_output_capture_attempt *att)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The effect of --debug option: indiscriminately allow everyone to
|
|
|
|
* take screenshots of any output.
|
|
|
|
*/
|
|
|
|
att->authorized = true;
|
|
|
|
}
|
|
|
|
|
2022-04-01 18:09:19 +03:00
|
|
|
static void
|
|
|
|
sigint_helper(int sig)
|
|
|
|
{
|
|
|
|
raise(SIGUSR2);
|
|
|
|
}
|
|
|
|
|
2019-07-08 17:12:41 +03:00
|
|
|
WL_EXPORT int
|
2020-10-19 22:06:22 +03:00
|
|
|
wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
|
2014-10-12 01:24:25 +04:00
|
|
|
{
|
|
|
|
int ret = EXIT_FAILURE;
|
2016-02-11 15:42:21 +03:00
|
|
|
char *cmdline;
|
2014-10-12 01:24:25 +04:00
|
|
|
struct wl_display *display;
|
2022-04-11 16:22:31 +03:00
|
|
|
struct wl_event_source *signals[3];
|
2014-10-12 01:24:25 +04:00
|
|
|
struct wl_event_loop *loop;
|
|
|
|
int i, fd;
|
|
|
|
char *backend = NULL;
|
2022-12-30 00:12:24 +03:00
|
|
|
char *renderer = NULL;
|
2014-10-12 01:24:25 +04:00
|
|
|
char *shell = NULL;
|
2019-11-26 03:32:22 +03:00
|
|
|
bool xwayland = false;
|
2014-10-12 01:24:25 +04:00
|
|
|
char *modules = NULL;
|
|
|
|
char *option_modules = NULL;
|
|
|
|
char *log = NULL;
|
2019-06-22 23:39:19 +03:00
|
|
|
char *log_scopes = NULL;
|
2019-06-24 13:27:44 +03:00
|
|
|
char *flight_rec_scopes = NULL;
|
2016-08-04 03:40:52 +03:00
|
|
|
char *server_socket = NULL;
|
2023-05-31 15:09:48 +03:00
|
|
|
char *require_outputs = NULL;
|
2014-10-12 01:24:25 +04:00
|
|
|
int32_t idle_time = -1;
|
|
|
|
int32_t help = 0;
|
|
|
|
char *socket_name = NULL;
|
|
|
|
int32_t version = 0;
|
|
|
|
int32_t noconfig = 0;
|
2017-10-12 14:13:43 +03:00
|
|
|
int32_t debug_protocol = 0;
|
2019-11-26 03:14:24 +03:00
|
|
|
bool numlock_on;
|
2014-10-12 01:24:25 +04:00
|
|
|
char *config_file = NULL;
|
|
|
|
struct weston_config *config = NULL;
|
|
|
|
struct weston_config_section *section;
|
|
|
|
struct wl_client *primary_client;
|
|
|
|
struct wl_listener primary_client_destroyed;
|
|
|
|
struct weston_seat *seat;
|
2017-11-02 16:42:51 +03:00
|
|
|
struct wet_compositor wet = { 0 };
|
2019-04-17 12:35:38 +03:00
|
|
|
struct weston_log_context *log_ctx = NULL;
|
2019-06-22 23:39:19 +03:00
|
|
|
struct weston_log_subscriber *logger = NULL;
|
2019-06-24 13:27:44 +03:00
|
|
|
struct weston_log_subscriber *flight_rec = NULL;
|
2023-05-01 21:39:17 +03:00
|
|
|
struct wet_process *process, *process_tmp;
|
2023-05-01 21:15:52 +03:00
|
|
|
void *wet_xwl = NULL;
|
2018-09-04 11:18:06 +03:00
|
|
|
sigset_t mask;
|
2022-04-01 18:09:19 +03:00
|
|
|
struct sigaction action;
|
2018-09-04 11:18:06 +03:00
|
|
|
|
2019-11-26 03:32:22 +03:00
|
|
|
bool wait_for_debugger = false;
|
2017-10-12 14:18:15 +03:00
|
|
|
struct wl_protocol_logger *protologger = NULL;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
const struct weston_option core_options[] = {
|
|
|
|
{ WESTON_OPTION_STRING, "backend", 'B', &backend },
|
2022-12-30 00:12:24 +03:00
|
|
|
{ WESTON_OPTION_STRING, "renderer", 0, &renderer },
|
2014-10-12 01:24:25 +04:00
|
|
|
{ WESTON_OPTION_STRING, "shell", 0, &shell },
|
|
|
|
{ WESTON_OPTION_STRING, "socket", 'S', &socket_name },
|
|
|
|
{ WESTON_OPTION_INTEGER, "idle-time", 'i', &idle_time },
|
2019-02-13 17:59:59 +03:00
|
|
|
#if defined(BUILD_XWAYLAND)
|
2016-07-04 15:34:48 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "xwayland", 0, &xwayland },
|
2019-02-13 17:59:59 +03:00
|
|
|
#endif
|
2014-10-12 01:24:25 +04:00
|
|
|
{ WESTON_OPTION_STRING, "modules", 0, &option_modules },
|
|
|
|
{ WESTON_OPTION_STRING, "log", 0, &log },
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
|
|
|
|
{ WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig },
|
|
|
|
{ WESTON_OPTION_STRING, "config", 'c', &config_file },
|
2017-11-01 11:26:46 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "wait-for-debugger", 0, &wait_for_debugger },
|
2017-10-12 14:13:43 +03:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "debug", 0, &debug_protocol },
|
2019-06-22 23:39:19 +03:00
|
|
|
{ WESTON_OPTION_STRING, "logger-scopes", 'l', &log_scopes },
|
2019-06-24 13:27:44 +03:00
|
|
|
{ WESTON_OPTION_STRING, "flight-rec-scopes", 'f', &flight_rec_scopes },
|
2014-10-12 01:24:25 +04:00
|
|
|
};
|
|
|
|
|
2017-11-03 10:56:05 +03:00
|
|
|
wl_list_init(&wet.layoutput_list);
|
|
|
|
|
2018-08-22 15:09:18 +03:00
|
|
|
os_fd_set_cloexec(fileno(stdin));
|
2017-03-24 17:41:12 +03:00
|
|
|
|
2016-02-11 15:42:21 +03:00
|
|
|
cmdline = copy_command_line(argc, argv);
|
2014-10-12 01:24:25 +04:00
|
|
|
parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
|
|
|
|
|
2016-02-11 15:42:21 +03:00
|
|
|
if (help) {
|
|
|
|
free(cmdline);
|
2014-10-12 01:24:25 +04:00
|
|
|
usage(EXIT_SUCCESS);
|
2016-02-11 15:42:21 +03:00
|
|
|
}
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
printf(PACKAGE_STRING "\n");
|
2016-02-11 15:42:21 +03:00
|
|
|
free(cmdline);
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-01-17 17:19:59 +03:00
|
|
|
log_ctx = weston_log_ctx_create();
|
2019-04-17 12:35:38 +03:00
|
|
|
if (!log_ctx) {
|
2019-04-07 17:07:58 +03:00
|
|
|
fprintf(stderr, "Failed to initialize weston debug framework.\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-12-18 21:21:03 +03:00
|
|
|
log_scope = weston_log_ctx_add_log_scope(log_ctx, "log",
|
2019-07-29 12:02:47 +03:00
|
|
|
"Weston and Wayland log\n", NULL, NULL, NULL);
|
2019-07-03 12:41:47 +03:00
|
|
|
|
2020-05-28 18:45:57 +03:00
|
|
|
if (!weston_log_file_open(log))
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2019-07-03 12:41:47 +03:00
|
|
|
weston_log_set_handler(vlog, vlog_continue);
|
|
|
|
|
2019-06-22 23:39:19 +03:00
|
|
|
logger = weston_log_subscriber_create_log(weston_logfile);
|
2021-09-23 22:06:57 +03:00
|
|
|
|
|
|
|
if (!flight_rec_scopes)
|
|
|
|
flight_rec_scopes = DEFAULT_FLIGHT_REC_SCOPES;
|
|
|
|
|
|
|
|
if (flight_rec_scopes && strlen(flight_rec_scopes) > 0)
|
|
|
|
flight_rec = weston_log_subscriber_create_flight_rec(DEFAULT_FLIGHT_REC_SIZE);
|
2019-07-08 13:20:02 +03:00
|
|
|
|
|
|
|
weston_log_subscribe_to_scopes(log_ctx, logger, flight_rec,
|
|
|
|
log_scopes, flight_rec_scopes);
|
2019-06-24 13:27:44 +03:00
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
weston_log("%s\n"
|
|
|
|
STAMP_SPACE "%s\n"
|
|
|
|
STAMP_SPACE "Bug reports to: %s\n"
|
|
|
|
STAMP_SPACE "Build: %s\n",
|
|
|
|
PACKAGE_STRING, PACKAGE_URL, PACKAGE_BUGREPORT,
|
|
|
|
BUILD_ID);
|
2016-02-11 15:42:21 +03:00
|
|
|
weston_log("Command line: %s\n", cmdline);
|
|
|
|
free(cmdline);
|
2014-10-12 01:24:25 +04:00
|
|
|
log_uname();
|
|
|
|
|
2021-09-23 22:06:57 +03:00
|
|
|
weston_log("Flight recorder: %s\n", flight_rec ? "enabled" : "disabled");
|
2014-10-12 01:24:25 +04:00
|
|
|
verify_xdg_runtime_dir();
|
|
|
|
|
|
|
|
display = wl_display_create();
|
2019-05-31 22:39:43 +03:00
|
|
|
if (display == NULL) {
|
|
|
|
weston_log("fatal: failed to create display\n");
|
|
|
|
goto out_display;
|
|
|
|
}
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(display);
|
|
|
|
signals[0] = wl_event_loop_add_signal(loop, SIGTERM, on_term_signal,
|
|
|
|
display);
|
2022-04-01 18:09:19 +03:00
|
|
|
signals[1] = wl_event_loop_add_signal(loop, SIGUSR2, on_term_signal,
|
2014-10-12 01:24:25 +04:00
|
|
|
display);
|
|
|
|
|
2021-06-29 20:33:04 +03:00
|
|
|
wl_list_init(&wet.child_process_list);
|
2022-04-11 16:22:31 +03:00
|
|
|
signals[2] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
|
2021-06-29 20:33:04 +03:00
|
|
|
&wet);
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2022-04-01 18:09:19 +03:00
|
|
|
/* When debugging weston, if use wl_event_loop_add_signal() to catch
|
|
|
|
* SIGINT, the debugger can't catch it, and attempting to stop
|
|
|
|
* weston from within the debugger results in weston exiting
|
|
|
|
* cleanly.
|
|
|
|
*
|
|
|
|
* Instead, use the sigaction() function, which sets up the signal
|
|
|
|
* in a way that gdb can successfully catch, but have the handler
|
|
|
|
* for SIGINT send SIGUSR2 (xwayland uses SIGUSR1), which we catch
|
|
|
|
* via wl_event_loop_add_signal().
|
|
|
|
*/
|
|
|
|
action.sa_handler = sigint_helper;
|
|
|
|
sigemptyset(&action.sa_mask);
|
|
|
|
action.sa_flags = 0;
|
|
|
|
sigaction(SIGINT, &action, NULL);
|
2022-04-11 16:22:31 +03:00
|
|
|
if (!signals[0] || !signals[1] || !signals[2])
|
2014-10-12 01:24:25 +04:00
|
|
|
goto out_signals;
|
|
|
|
|
2018-09-04 11:18:06 +03:00
|
|
|
/* Xwayland uses SIGUSR1 for communicating with weston. Since some
|
|
|
|
weston plugins may create additional threads, set up any necessary
|
|
|
|
signal blocking early so that these threads can inherit the settings
|
|
|
|
when created. */
|
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, SIGUSR1);
|
|
|
|
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
if (load_configuration(&config, noconfig, config_file) < 0)
|
|
|
|
goto out_signals;
|
2017-11-02 16:42:51 +03:00
|
|
|
wet.config = config;
|
|
|
|
wet.parsed_options = NULL;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
section = weston_config_get_section(config, "core", NULL, NULL);
|
|
|
|
|
2019-11-26 03:14:24 +03:00
|
|
|
if (!wait_for_debugger) {
|
2017-11-01 11:26:46 +03:00
|
|
|
weston_config_section_get_bool(section, "wait-for-debugger",
|
2019-11-26 03:32:22 +03:00
|
|
|
&wait_for_debugger, false);
|
2019-11-26 03:14:24 +03:00
|
|
|
}
|
2017-11-01 11:26:46 +03:00
|
|
|
if (wait_for_debugger) {
|
|
|
|
weston_log("Weston PID is %ld - "
|
|
|
|
"waiting for debugger, send SIGCONT to continue...\n",
|
|
|
|
(long)getpid());
|
|
|
|
raise(SIGSTOP);
|
|
|
|
}
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if (!renderer) {
|
|
|
|
weston_config_section_get_string(section, "renderer",
|
|
|
|
&renderer, NULL);
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
if (!backend) {
|
|
|
|
weston_config_section_get_string(section, "backend", &backend,
|
|
|
|
NULL);
|
|
|
|
if (!backend)
|
|
|
|
backend = weston_choose_default_backend();
|
|
|
|
}
|
|
|
|
|
2020-11-06 17:24:22 +03:00
|
|
|
wet.compositor = weston_compositor_create(display, log_ctx, &wet, test_data);
|
2017-11-02 16:42:51 +03:00
|
|
|
if (wet.compositor == NULL) {
|
2014-10-12 01:24:25 +04:00
|
|
|
weston_log("fatal: failed to create compositor\n");
|
2015-10-03 16:25:16 +03:00
|
|
|
goto out;
|
2014-10-12 01:24:25 +04:00
|
|
|
}
|
|
|
|
|
2017-10-12 14:18:15 +03:00
|
|
|
protocol_scope =
|
2019-12-18 21:21:03 +03:00
|
|
|
weston_log_ctx_add_log_scope(log_ctx, "proto",
|
|
|
|
"Wayland protocol dump for all clients.\n",
|
|
|
|
NULL, NULL, NULL);
|
2017-10-12 14:18:15 +03:00
|
|
|
|
2019-11-01 14:45:55 +03:00
|
|
|
protologger = wl_display_add_protocol_logger(display,
|
|
|
|
protocol_log_fn,
|
|
|
|
NULL);
|
2022-09-30 17:02:02 +03:00
|
|
|
if (debug_protocol) {
|
2017-10-12 14:13:43 +03:00
|
|
|
weston_compositor_enable_debug_protocol(wet.compositor);
|
2022-09-30 17:02:02 +03:00
|
|
|
weston_compositor_add_screenshot_authority(wet.compositor,
|
|
|
|
&wet.screenshot_auth,
|
|
|
|
screenshot_allow_all);
|
|
|
|
}
|
2017-10-12 14:13:43 +03:00
|
|
|
|
2021-09-23 22:06:57 +03:00
|
|
|
if (flight_rec)
|
|
|
|
weston_compositor_add_debug_binding(wet.compositor, KEY_D,
|
|
|
|
flight_rec_key_binding_handler,
|
|
|
|
flight_rec);
|
2019-06-27 19:19:26 +03:00
|
|
|
|
2017-11-02 16:42:51 +03:00
|
|
|
if (weston_compositor_init_config(wet.compositor, config) < 0)
|
2015-10-03 16:25:16 +03:00
|
|
|
goto out;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2016-10-21 22:03:13 +03:00
|
|
|
weston_config_section_get_bool(section, "require-input",
|
2019-11-26 03:14:24 +03:00
|
|
|
&wet.compositor->require_input, true);
|
2016-10-21 22:03:13 +03:00
|
|
|
|
2023-05-31 15:14:33 +03:00
|
|
|
wet.require_outputs = REQUIRE_OUTPUTS_ANY;
|
2023-05-31 15:09:48 +03:00
|
|
|
weston_config_section_get_string(section, "require-outputs",
|
|
|
|
&require_outputs, NULL);
|
|
|
|
if (require_outputs) {
|
|
|
|
weston_parse_require_outputs(require_outputs,
|
|
|
|
&wet.require_outputs);
|
|
|
|
free(require_outputs);
|
|
|
|
}
|
|
|
|
|
2022-12-30 00:12:24 +03:00
|
|
|
if (load_backend(wet.compositor, backend, &argc, argv, config,
|
|
|
|
renderer) < 0) {
|
2014-10-12 01:24:25 +04:00
|
|
|
weston_log("fatal: failed to create compositor backend\n");
|
2015-10-03 16:25:16 +03:00
|
|
|
goto out;
|
2014-10-12 01:24:25 +04:00
|
|
|
}
|
|
|
|
|
2021-03-16 20:54:08 +03:00
|
|
|
if (test_data && !check_compositor_capabilities(wet.compositor,
|
2021-03-01 12:24:59 +03:00
|
|
|
test_data->test_quirks.required_capabilities)) {
|
|
|
|
ret = WET_MAIN_RET_MISSING_CAPS;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-11-02 16:42:51 +03:00
|
|
|
weston_compositor_flush_heads_changed(wet.compositor);
|
|
|
|
if (wet.init_failed)
|
2017-08-17 13:10:28 +03:00
|
|
|
goto out;
|
2016-09-30 15:11:04 +03:00
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
if (idle_time < 0)
|
|
|
|
weston_config_section_get_int(section, "idle-time", &idle_time, -1);
|
|
|
|
if (idle_time < 0)
|
|
|
|
idle_time = 300; /* default idle timeout, in seconds */
|
|
|
|
|
2017-11-02 16:42:51 +03:00
|
|
|
wet.compositor->idle_time = idle_time;
|
|
|
|
wet.compositor->default_pointer_grab = NULL;
|
|
|
|
wet.compositor->exit = handle_exit;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2017-11-02 16:42:51 +03:00
|
|
|
weston_compositor_log_capabilities(wet.compositor);
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
server_socket = getenv("WAYLAND_SERVER_SOCKET");
|
|
|
|
if (server_socket) {
|
|
|
|
weston_log("Running with single client\n");
|
2016-08-04 03:40:52 +03:00
|
|
|
if (!safe_strtoint(server_socket, &fd))
|
2014-10-12 01:24:25 +04:00
|
|
|
fd = -1;
|
|
|
|
} else {
|
|
|
|
fd = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fd != -1) {
|
|
|
|
primary_client = wl_client_create(display, fd);
|
|
|
|
if (!primary_client) {
|
2019-04-27 00:57:31 +03:00
|
|
|
weston_log("fatal: failed to add client: %s\n",
|
|
|
|
strerror(errno));
|
2014-10-12 01:24:25 +04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
primary_client_destroyed.notify =
|
|
|
|
handle_primary_client_destroyed;
|
|
|
|
wl_client_add_destroy_listener(primary_client,
|
|
|
|
&primary_client_destroyed);
|
|
|
|
} else if (weston_create_listening_socket(display, socket_name)) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!shell)
|
|
|
|
weston_config_section_get_string(section, "shell", &shell,
|
2022-12-29 18:38:37 +03:00
|
|
|
"desktop");
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2017-11-02 16:42:51 +03:00
|
|
|
if (wet_load_shell(wet.compositor, shell, &argc, argv) < 0)
|
2014-10-12 01:24:25 +04:00
|
|
|
goto out;
|
|
|
|
|
2022-07-14 21:29:42 +03:00
|
|
|
/* Load xwayland before other modules - this way if we're using
|
|
|
|
* the systemd-notify module it will notify after we're ready
|
|
|
|
* to receive xwayland connections.
|
|
|
|
*/
|
2019-11-26 03:14:24 +03:00
|
|
|
if (!xwayland) {
|
2019-11-26 03:32:22 +03:00
|
|
|
weston_config_section_get_bool(section, "xwayland", &xwayland,
|
|
|
|
false);
|
2019-11-26 03:14:24 +03:00
|
|
|
}
|
2016-07-04 15:34:48 +03:00
|
|
|
if (xwayland) {
|
2023-05-01 21:15:52 +03:00
|
|
|
wet_xwl = wet_load_xwayland(wet.compositor);
|
|
|
|
if (!wet_xwl)
|
2016-07-04 15:34:48 +03:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2022-07-14 21:29:42 +03:00
|
|
|
weston_config_section_get_string(section, "modules", &modules, "");
|
|
|
|
if (load_modules(wet.compositor, modules, &argc, argv) < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (load_modules(wet.compositor, option_modules, &argc, argv) < 0)
|
|
|
|
goto out;
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
section = weston_config_get_section(config, "keyboard", NULL, NULL);
|
2019-11-26 03:14:24 +03:00
|
|
|
weston_config_section_get_bool(section, "numlock-on", &numlock_on, false);
|
2014-10-12 01:24:25 +04:00
|
|
|
if (numlock_on) {
|
2017-11-02 16:42:51 +03:00
|
|
|
wl_list_for_each(seat, &wet.compositor->seat_list, link) {
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
weston_seat_get_keyboard(seat);
|
|
|
|
|
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_set_locks(keyboard,
|
2014-10-12 01:24:25 +04:00
|
|
|
WESTON_NUM_LOCK,
|
|
|
|
WESTON_NUM_LOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
weston_log("fatal: unhandled option: %s\n", argv[i]);
|
|
|
|
if (argc > 1)
|
|
|
|
goto out;
|
|
|
|
|
2017-11-02 16:42:51 +03:00
|
|
|
weston_compositor_wake(wet.compositor);
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2021-06-24 06:50:53 +03:00
|
|
|
if (execute_autolaunch(&wet, config) < 0)
|
|
|
|
goto out;
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
wl_display_run(display);
|
|
|
|
|
|
|
|
/* Allow for setting return exit code after
|
|
|
|
* wl_display_run returns normally. This is
|
|
|
|
* useful for devs/testers and automated tests
|
|
|
|
* that want to indicate failure status to
|
|
|
|
* testing infrastructure above
|
|
|
|
*/
|
2017-11-02 16:42:51 +03:00
|
|
|
ret = wet.compositor->exit_code;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
|
|
|
out:
|
2016-09-30 15:11:04 +03:00
|
|
|
/* free(NULL) is valid, and it won't be NULL if it's used */
|
2017-11-02 16:42:51 +03:00
|
|
|
free(wet.parsed_options);
|
2016-09-30 15:11:04 +03:00
|
|
|
|
2017-10-12 14:18:15 +03:00
|
|
|
if (protologger)
|
|
|
|
wl_protocol_logger_destroy(protologger);
|
|
|
|
|
2023-05-01 21:20:32 +03:00
|
|
|
if (wet_xwl)
|
|
|
|
wet_xwayland_destroy(wet.compositor, wet_xwl);
|
|
|
|
|
2020-01-28 01:12:01 +03:00
|
|
|
weston_compositor_destroy(wet.compositor);
|
2022-06-22 18:28:44 +03:00
|
|
|
wet_compositor_destroy_layout(&wet);
|
2019-12-18 21:52:18 +03:00
|
|
|
weston_log_scope_destroy(protocol_scope);
|
2017-10-12 14:18:15 +03:00
|
|
|
protocol_scope = NULL;
|
2014-10-12 01:24:25 +04:00
|
|
|
|
2023-05-01 21:39:17 +03:00
|
|
|
wl_list_for_each_safe(process, process_tmp, &wet.child_process_list, link)
|
|
|
|
wet_process_destroy(process, 0, false);
|
|
|
|
|
2014-10-12 01:24:25 +04:00
|
|
|
out_signals:
|
|
|
|
for (i = ARRAY_LENGTH(signals) - 1; i >= 0; i--)
|
|
|
|
if (signals[i])
|
|
|
|
wl_event_source_remove(signals[i]);
|
|
|
|
|
|
|
|
wl_display_destroy(display);
|
|
|
|
|
2019-05-31 22:39:43 +03:00
|
|
|
out_display:
|
2020-11-19 14:24:11 +03:00
|
|
|
weston_log_scope_destroy(log_scope);
|
|
|
|
log_scope = NULL;
|
|
|
|
weston_log_subscriber_destroy(logger);
|
2021-09-23 22:06:57 +03:00
|
|
|
if (flight_rec)
|
|
|
|
weston_log_subscriber_destroy(flight_rec);
|
2020-11-19 14:24:11 +03:00
|
|
|
weston_log_ctx_destroy(log_ctx);
|
2014-10-12 01:24:25 +04:00
|
|
|
weston_log_file_close();
|
|
|
|
|
|
|
|
if (config)
|
|
|
|
weston_config_destroy(config);
|
|
|
|
free(config_file);
|
|
|
|
free(backend);
|
2023-04-11 17:48:15 +03:00
|
|
|
free(renderer);
|
2014-10-12 01:24:25 +04:00
|
|
|
free(shell);
|
|
|
|
free(socket_name);
|
|
|
|
free(option_modules);
|
|
|
|
free(log);
|
2021-06-15 16:22:34 +03:00
|
|
|
free(log_scopes);
|
2014-10-12 01:24:25 +04:00
|
|
|
free(modules);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|