mirror of
https://github.com/swaywm/sway.git
synced 2025-10-08 21:25:58 +00:00
Merge 129a5a0d7c
into 90d3270970
This commit is contained in:
commit
51d8d8bba6
11 changed files with 97 additions and 3 deletions
|
@ -284,6 +284,7 @@ sway_cmd input_cmd_xkb_switch_layout;
|
||||||
sway_cmd input_cmd_xkb_variant;
|
sway_cmd input_cmd_xkb_variant;
|
||||||
|
|
||||||
sway_cmd output_cmd_adaptive_sync;
|
sway_cmd output_cmd_adaptive_sync;
|
||||||
|
sway_cmd output_cmd_allow_drm_leasing;
|
||||||
sway_cmd output_cmd_allow_tearing;
|
sway_cmd output_cmd_allow_tearing;
|
||||||
sway_cmd output_cmd_background;
|
sway_cmd output_cmd_background;
|
||||||
sway_cmd output_cmd_color_profile;
|
sway_cmd output_cmd_color_profile;
|
||||||
|
|
|
@ -291,6 +291,7 @@ struct output_config {
|
||||||
bool set_color_transform;
|
bool set_color_transform;
|
||||||
struct wlr_color_transform *color_transform;
|
struct wlr_color_transform *color_transform;
|
||||||
int allow_tearing;
|
int allow_tearing;
|
||||||
|
int allow_drm_leasing;
|
||||||
int hdr;
|
int hdr;
|
||||||
|
|
||||||
char *background;
|
char *background;
|
||||||
|
|
|
@ -70,6 +70,7 @@ struct sway_output {
|
||||||
struct wl_event_source *repaint_timer;
|
struct wl_event_source *repaint_timer;
|
||||||
|
|
||||||
bool allow_tearing;
|
bool allow_tearing;
|
||||||
|
bool allow_drm_leasing;
|
||||||
bool hdr;
|
bool hdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// must be in order for the bsearch
|
// must be in order for the bsearch
|
||||||
static const struct cmd_handler output_handlers[] = {
|
static const struct cmd_handler output_handlers[] = {
|
||||||
{ "adaptive_sync", output_cmd_adaptive_sync },
|
{ "adaptive_sync", output_cmd_adaptive_sync },
|
||||||
|
{ "allow_drm_leasing", output_cmd_allow_drm_leasing },
|
||||||
{ "allow_tearing", output_cmd_allow_tearing },
|
{ "allow_tearing", output_cmd_allow_tearing },
|
||||||
{ "background", output_cmd_background },
|
{ "background", output_cmd_background },
|
||||||
{ "bg", output_cmd_background },
|
{ "bg", output_cmd_background },
|
||||||
|
|
60
sway/commands/output/allow_drm_leasing.c
Normal file
60
sway/commands/output/allow_drm_leasing.c
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/output.h"
|
||||||
|
#include "sway/server.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#if WLR_HAS_DRM_BACKEND
|
||||||
|
#include <wlr/backend/drm.h>
|
||||||
|
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct cmd_results *output_cmd_allow_drm_leasing(int argc, char **argv) {
|
||||||
|
if (!server.drm_lease_manager) {
|
||||||
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"DRM lease manager interface not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config->handler_context.output_config) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "Missing output config");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc == 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "Missing allow_leasing argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *oc_name = config->handler_context.output_config->name;
|
||||||
|
if (strcmp(oc_name, "*") == 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
"Cannot apply leasing to all outputs");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sway_output *sway_output = all_output_by_name_or_id(oc_name);
|
||||||
|
|
||||||
|
if (parse_boolean(argv[0],
|
||||||
|
(config->handler_context.output_config->allow_drm_leasing == 1))) {
|
||||||
|
config->handler_context.output_config->allow_drm_leasing = 1;
|
||||||
|
|
||||||
|
#if WLR_HAS_DRM_BACKEND
|
||||||
|
if (sway_output) {
|
||||||
|
sway_log(SWAY_DEBUG, "Offering output %s for leasing", oc_name);
|
||||||
|
wlr_drm_lease_v1_manager_offer_output(server.drm_lease_manager,
|
||||||
|
sway_output->wlr_output);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
config->handler_context.output_config->allow_drm_leasing = 0;
|
||||||
|
|
||||||
|
#if WLR_HAS_DRM_BACKEND
|
||||||
|
if (sway_output) {
|
||||||
|
sway_log(SWAY_DEBUG, "Withdrawing output %s from leasing", oc_name);
|
||||||
|
wlr_drm_lease_v1_manager_withdraw_output(server.drm_lease_manager,
|
||||||
|
sway_output->wlr_output);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
config->handler_context.leftovers.argc = argc - 1;
|
||||||
|
config->handler_context.leftovers.argv = argv + 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -79,6 +79,7 @@ struct output_config *new_output_config(const char *name) {
|
||||||
oc->color_transform = NULL;
|
oc->color_transform = NULL;
|
||||||
oc->power = -1;
|
oc->power = -1;
|
||||||
oc->allow_tearing = -1;
|
oc->allow_tearing = -1;
|
||||||
|
oc->allow_drm_leasing = -1;
|
||||||
oc->hdr = -1;
|
oc->hdr = -1;
|
||||||
return oc;
|
return oc;
|
||||||
}
|
}
|
||||||
|
@ -155,6 +156,9 @@ static void supersede_output_config(struct output_config *dst, struct output_con
|
||||||
if (src->allow_tearing != -1) {
|
if (src->allow_tearing != -1) {
|
||||||
dst->allow_tearing = -1;
|
dst->allow_tearing = -1;
|
||||||
}
|
}
|
||||||
|
if (src->allow_drm_leasing != -1) {
|
||||||
|
dst->allow_drm_leasing = -1;
|
||||||
|
}
|
||||||
if (src->hdr != -1) {
|
if (src->hdr != -1) {
|
||||||
dst->hdr = -1;
|
dst->hdr = -1;
|
||||||
}
|
}
|
||||||
|
@ -233,6 +237,9 @@ static void merge_output_config(struct output_config *dst, struct output_config
|
||||||
if (src->allow_tearing != -1) {
|
if (src->allow_tearing != -1) {
|
||||||
dst->allow_tearing = src->allow_tearing;
|
dst->allow_tearing = src->allow_tearing;
|
||||||
}
|
}
|
||||||
|
if (src->allow_drm_leasing != -1) {
|
||||||
|
dst->allow_drm_leasing = src->allow_drm_leasing;
|
||||||
|
}
|
||||||
if (src->hdr != -1) {
|
if (src->hdr != -1) {
|
||||||
dst->hdr = src->hdr;
|
dst->hdr = src->hdr;
|
||||||
}
|
}
|
||||||
|
@ -278,11 +285,11 @@ void store_output_config(struct output_config *oc) {
|
||||||
|
|
||||||
sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
|
sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
|
||||||
"position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) "
|
"position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) "
|
||||||
"(max render time: %d) (allow tearing: %d) (hdr: %d)",
|
"(max render time: %d) (allow tearing: %d) (allow drm leasing: %d) (hdr: %d)",
|
||||||
oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
|
oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
|
||||||
oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel),
|
oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel),
|
||||||
oc->transform, oc->background, oc->background_option, oc->power,
|
oc->transform, oc->background, oc->background_option, oc->power,
|
||||||
oc->max_render_time, oc->allow_tearing, oc->hdr);
|
oc->max_render_time, oc->allow_tearing, oc->allow_drm_leasing, oc->hdr);
|
||||||
|
|
||||||
// If the configuration was not merged into an existing configuration, add
|
// If the configuration was not merged into an existing configuration, add
|
||||||
// it to the list. Otherwise we're done with it and can free it.
|
// it to the list. Otherwise we're done with it and can free it.
|
||||||
|
@ -622,6 +629,7 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output
|
||||||
|
|
||||||
output->max_render_time = oc && oc->max_render_time > 0 ? oc->max_render_time : 0;
|
output->max_render_time = oc && oc->max_render_time > 0 ? oc->max_render_time : 0;
|
||||||
output->allow_tearing = oc && oc->allow_tearing > 0;
|
output->allow_tearing = oc && oc->allow_tearing > 0;
|
||||||
|
output->allow_drm_leasing = oc && oc->allow_drm_leasing > 0;
|
||||||
output->hdr = applied->image_description != NULL;
|
output->hdr = applied->image_description != NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -597,6 +597,16 @@ void handle_new_output(struct wl_listener *listener, void *data) {
|
||||||
sway_session_lock_add_output(server->session_lock.lock, output);
|
sway_session_lock_add_output(server->session_lock.lock, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct output_config *oc = find_output_config(output);
|
||||||
|
if (oc && oc->allow_drm_leasing > 0) {
|
||||||
|
#if WLR_HAS_DRM_BACKEND
|
||||||
|
if (server->drm_lease_manager) {
|
||||||
|
wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager,
|
||||||
|
wlr_output);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
request_modeset();
|
request_modeset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -409,6 +409,8 @@ static void ipc_json_describe_enabled_output(struct sway_output *output,
|
||||||
|
|
||||||
json_object_object_add(object, "max_render_time", json_object_new_int(output->max_render_time));
|
json_object_object_add(object, "max_render_time", json_object_new_int(output->max_render_time));
|
||||||
json_object_object_add(object, "allow_tearing", json_object_new_boolean(output->allow_tearing));
|
json_object_object_add(object, "allow_tearing", json_object_new_boolean(output->allow_tearing));
|
||||||
|
json_object_object_add(object, "allow_drm_leasing",
|
||||||
|
json_object_new_boolean(output->allow_drm_leasing));
|
||||||
json_object_object_add(object, "hdr", json_object_new_boolean(output->hdr));
|
json_object_object_add(object, "hdr", json_object_new_boolean(output->hdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,7 @@ sway_sources = files(
|
||||||
'commands/input/xkb_variant.c',
|
'commands/input/xkb_variant.c',
|
||||||
|
|
||||||
'commands/output/adaptive_sync.c',
|
'commands/output/adaptive_sync.c',
|
||||||
|
'commands/output/allow_drm_leasing.c',
|
||||||
'commands/output/allow_tearing.c',
|
'commands/output/allow_tearing.c',
|
||||||
'commands/output/background.c',
|
'commands/output/background.c',
|
||||||
'commands/output/disable.c',
|
'commands/output/disable.c',
|
||||||
|
|
|
@ -210,6 +210,11 @@ must be separated by one space. For example:
|
||||||
|
|
||||||
This setting only has effect when a window is fullscreen on the output.
|
This setting only has effect when a window is fullscreen on the output.
|
||||||
|
|
||||||
|
*output* <name> allow_drm_leasing yes|no
|
||||||
|
Allows or disallows leasing a DRM output. The DRM lease interface must be
|
||||||
|
active when calling this command. Outputs offered for leasing will be
|
||||||
|
disabled when leased by a client.
|
||||||
|
|
||||||
*output* <name> hdr on|off|toggle
|
*output* <name> hdr on|off|toggle
|
||||||
Enables or disables HDR (High Dynamic Range). HDR enables a larger color
|
Enables or disables HDR (High Dynamic Range). HDR enables a larger color
|
||||||
gamut and brightness range. HDR uses the BT2020 primaries and the PQ
|
gamut and brightness range. HDR uses the BT2020 primaries and the PQ
|
||||||
|
|
|
@ -189,7 +189,7 @@ static void pretty_print_output(json_object *o) {
|
||||||
json_object_object_get_ex(o, "current_workspace", &ws);
|
json_object_object_get_ex(o, "current_workspace", &ws);
|
||||||
json_object_object_get_ex(o, "non_desktop", &non_desktop);
|
json_object_object_get_ex(o, "non_desktop", &non_desktop);
|
||||||
json_object *make, *model, *serial, *scale, *scale_filter, *subpixel,
|
json_object *make, *model, *serial, *scale, *scale_filter, *subpixel,
|
||||||
*transform, *max_render_time, *adaptive_sync_status, *allow_tearing,
|
*transform, *max_render_time, *adaptive_sync_status, *allow_tearing, *allow_drm_leasing,
|
||||||
*hdr;
|
*hdr;
|
||||||
json_object_object_get_ex(o, "make", &make);
|
json_object_object_get_ex(o, "make", &make);
|
||||||
json_object_object_get_ex(o, "model", &model);
|
json_object_object_get_ex(o, "model", &model);
|
||||||
|
@ -201,6 +201,7 @@ static void pretty_print_output(json_object *o) {
|
||||||
json_object_object_get_ex(o, "max_render_time", &max_render_time);
|
json_object_object_get_ex(o, "max_render_time", &max_render_time);
|
||||||
json_object_object_get_ex(o, "adaptive_sync_status", &adaptive_sync_status);
|
json_object_object_get_ex(o, "adaptive_sync_status", &adaptive_sync_status);
|
||||||
json_object_object_get_ex(o, "allow_tearing", &allow_tearing);
|
json_object_object_get_ex(o, "allow_tearing", &allow_tearing);
|
||||||
|
json_object_object_get_ex(o, "allow_drm_leasing", &allow_drm_leasing);
|
||||||
json_object_object_get_ex(o, "hdr", &hdr);
|
json_object_object_get_ex(o, "hdr", &hdr);
|
||||||
json_object *x, *y;
|
json_object *x, *y;
|
||||||
json_object_object_get_ex(rect, "x", &x);
|
json_object_object_get_ex(rect, "x", &x);
|
||||||
|
@ -265,6 +266,9 @@ static void pretty_print_output(json_object *o) {
|
||||||
printf(" Allow tearing: %s\n",
|
printf(" Allow tearing: %s\n",
|
||||||
json_object_get_boolean(allow_tearing) ? "yes" : "no");
|
json_object_get_boolean(allow_tearing) ? "yes" : "no");
|
||||||
|
|
||||||
|
printf(" Allow DRM leasing: %s\n",
|
||||||
|
json_object_get_boolean(allow_drm_leasing) ? "yes" : "no");
|
||||||
|
|
||||||
const char *hdr_str = "unsupported";
|
const char *hdr_str = "unsupported";
|
||||||
if (json_object_get_boolean(features_hdr)) {
|
if (json_object_get_boolean(features_hdr)) {
|
||||||
hdr_str = json_object_get_boolean(hdr) ? "on" : "off";
|
hdr_str = json_object_get_boolean(hdr) ? "on" : "off";
|
||||||
|
|
Loading…
Add table
Reference in a new issue