mirror of
https://github.com/swaywm/sway.git
synced 2026-03-17 05:34:07 -04:00
sway: change unsupported GPU message to swaynag
This commit shows a swaynag message when an unsupported GPU is detected which must be acknowledged by users. It also adds an environment variable (`SWAY_UNSUPPORTED_GPU`) which may be used instead of the `--unsupported-gpu` argument. The `static` storage class for flag variables in main has also been removed, as this should have no effect on the program. Resolves: #8999
This commit is contained in:
parent
b081eba05d
commit
992d201512
3 changed files with 27 additions and 16 deletions
|
|
@ -160,7 +160,7 @@ struct sway_debug {
|
||||||
|
|
||||||
extern struct sway_debug debug;
|
extern struct sway_debug debug;
|
||||||
|
|
||||||
extern bool allow_unsupported_gpu;
|
extern bool unsupported_gpu_detected;
|
||||||
|
|
||||||
void sway_terminate(int exit_code);
|
void sway_terminate(int exit_code);
|
||||||
|
|
||||||
|
|
|
||||||
24
sway/main.c
24
sway/main.c
|
|
@ -224,7 +224,7 @@ static const char usage[] =
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
static bool verbose = false, debug = false, validate = false;
|
bool verbose = false, debug = false, validate = false, allow_unsupported_gpu = false;
|
||||||
|
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
|
|
||||||
|
|
@ -286,6 +286,12 @@ int main(int argc, char **argv) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *unsupported_gpu_env = getenv("SWAY_UNSUPPORTED_GPU");
|
||||||
|
// we let the flag override the environment variable
|
||||||
|
if (!allow_unsupported_gpu && unsupported_gpu_env) {
|
||||||
|
allow_unsupported_gpu = parse_boolean(unsupported_gpu_env, false);
|
||||||
|
}
|
||||||
|
|
||||||
// As the 'callback' function for wlr_log is equivalent to that for
|
// As the 'callback' function for wlr_log is equivalent to that for
|
||||||
// sway, we do not need to override it.
|
// sway, we do not need to override it.
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
|
@ -373,6 +379,18 @@ int main(int argc, char **argv) {
|
||||||
swaynag_show(&config->swaynag_config_errors);
|
swaynag_show(&config->swaynag_config_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct swaynag_instance nag_gpu = (struct swaynag_instance){
|
||||||
|
.args = "--type error "
|
||||||
|
"--message 'Proprietary GPU drivers are not supported by sway. Do not report issues.' ",
|
||||||
|
.detailed = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (unsupported_gpu_detected && !allow_unsupported_gpu) {
|
||||||
|
if (!swaynag_spawn(config->swaynag_command, &nag_gpu)) {
|
||||||
|
sway_log(SWAY_ERROR, "Unable to start swaynag");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server_run(&server);
|
server_run(&server);
|
||||||
|
|
||||||
shutdown:
|
shutdown:
|
||||||
|
|
@ -385,6 +403,10 @@ shutdown:
|
||||||
free(config_path);
|
free(config_path);
|
||||||
free_config(config);
|
free_config(config);
|
||||||
|
|
||||||
|
if (nag_gpu.client != NULL) {
|
||||||
|
wl_client_destroy(nag_gpu.client);
|
||||||
|
}
|
||||||
|
|
||||||
pango_cairo_font_map_set_default(NULL);
|
pango_cairo_font_map_set_default(NULL);
|
||||||
|
|
||||||
return exit_value;
|
return exit_value;
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
|
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
|
||||||
#define SWAY_PRESENTATION_VERSION 2
|
#define SWAY_PRESENTATION_VERSION 2
|
||||||
|
|
||||||
bool allow_unsupported_gpu = false;
|
bool unsupported_gpu_detected = false;
|
||||||
|
|
||||||
#if WLR_HAS_DRM_BACKEND
|
#if WLR_HAS_DRM_BACKEND
|
||||||
static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
|
static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -161,27 +161,16 @@ static void detect_proprietary(struct wlr_backend *backend, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_unsupported = false;
|
|
||||||
if (strcmp(version->name, "nvidia-drm") == 0) {
|
if (strcmp(version->name, "nvidia-drm") == 0) {
|
||||||
is_unsupported = true;
|
unsupported_gpu_detected = true;
|
||||||
sway_log(SWAY_ERROR, "!!! Proprietary Nvidia drivers are in use !!!");
|
sway_log(SWAY_ERROR, "!!! Proprietary Nvidia drivers are in use !!!");
|
||||||
if (!allow_unsupported_gpu) {
|
|
||||||
sway_log(SWAY_ERROR, "Use Nouveau instead");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(version->name, "evdi") == 0) {
|
if (strcmp(version->name, "evdi") == 0) {
|
||||||
is_unsupported = true;
|
unsupported_gpu_detected = true;
|
||||||
sway_log(SWAY_ERROR, "!!! Proprietary DisplayLink drivers are in use !!!");
|
sway_log(SWAY_ERROR, "!!! Proprietary DisplayLink drivers are in use !!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allow_unsupported_gpu && is_unsupported) {
|
|
||||||
sway_log(SWAY_ERROR,
|
|
||||||
"Proprietary drivers are NOT supported. To launch sway anyway, "
|
|
||||||
"launch with --unsupported-gpu and DO NOT report issues.");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
drmFreeVersion(version);
|
drmFreeVersion(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue