diff options
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | meson.build | 3 | ||||
-rw-r--r-- | sway/main.c | 29 | ||||
-rw-r--r-- | sway/server.c | 32 |
4 files changed, 36 insertions, 30 deletions
diff --git a/include/sway/server.h b/include/sway/server.h index 1b3166ce..bf195706 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -163,6 +163,8 @@ struct sway_debug { | |||
163 | 163 | ||
164 | extern struct sway_debug debug; | 164 | extern struct sway_debug debug; |
165 | 165 | ||
166 | extern bool allow_unsupported_gpu; | ||
167 | |||
166 | bool server_init(struct sway_server *server); | 168 | bool server_init(struct sway_server *server); |
167 | void server_fini(struct sway_server *server); | 169 | void server_fini(struct sway_server *server); |
168 | bool server_start(struct sway_server *server); | 170 | bool server_start(struct sway_server *server); |
diff --git a/meson.build b/meson.build index adf49c19..e65723b6 100644 --- a/meson.build +++ b/meson.build | |||
@@ -77,8 +77,7 @@ pixman = dependency('pixman-1') | |||
77 | libevdev = dependency('libevdev') | 77 | libevdev = dependency('libevdev') |
78 | libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep | 78 | libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep |
79 | xcb = dependency('xcb', required: get_option('xwayland')) | 79 | xcb = dependency('xcb', required: get_option('xwayland')) |
80 | drm_full = dependency('libdrm') # only needed for drm_fourcc.h | 80 | drm = dependency('libdrm') |
81 | drm = drm_full.partial_dependency(compile_args: true, includes: true) | ||
82 | libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep | 81 | libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep |
83 | math = cc.find_library('m') | 82 | math = cc.find_library('m') |
84 | rt = cc.find_library('rt') | 83 | rt = cc.find_library('rt') |
diff --git a/sway/main.c b/sway/main.c index 0db116d3..98aba7f2 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -49,32 +49,6 @@ void sig_handler(int signal) { | |||
49 | sway_terminate(EXIT_SUCCESS); | 49 | sway_terminate(EXIT_SUCCESS); |
50 | } | 50 | } |
51 | 51 | ||
52 | void detect_proprietary(int allow_unsupported_gpu) { | ||
53 | FILE *f = fopen("/proc/modules", "r"); | ||
54 | if (!f) { | ||
55 | return; | ||
56 | } | ||
57 | char *line = NULL; | ||
58 | size_t line_size = 0; | ||
59 | while (getline(&line, &line_size, f) != -1) { | ||
60 | if (strncmp(line, "nvidia ", 7) == 0) { | ||
61 | if (allow_unsupported_gpu) { | ||
62 | sway_log(SWAY_ERROR, | ||
63 | "!!! Proprietary Nvidia drivers are in use !!!"); | ||
64 | } else { | ||
65 | sway_log(SWAY_ERROR, | ||
66 | "Proprietary Nvidia drivers are NOT supported. " | ||
67 | "Use Nouveau. To launch sway anyway, launch with " | ||
68 | "--unsupported-gpu and DO NOT report issues."); | ||
69 | exit(EXIT_FAILURE); | ||
70 | } | ||
71 | break; | ||
72 | } | ||
73 | } | ||
74 | free(line); | ||
75 | fclose(f); | ||
76 | } | ||
77 | |||
78 | void run_as_ipc_client(char *command, char *socket_path) { | 52 | void run_as_ipc_client(char *command, char *socket_path) { |
79 | int socketfd = ipc_open_socket(socket_path); | 53 | int socketfd = ipc_open_socket(socket_path); |
80 | uint32_t len = strlen(command); | 54 | uint32_t len = strlen(command); |
@@ -243,7 +217,7 @@ static const char usage[] = | |||
243 | "\n"; | 217 | "\n"; |
244 | 218 | ||
245 | int main(int argc, char **argv) { | 219 | int main(int argc, char **argv) { |
246 | static bool verbose = false, debug = false, validate = false, allow_unsupported_gpu = false; | 220 | static bool verbose = false, debug = false, validate = false; |
247 | 221 | ||
248 | char *config_path = NULL; | 222 | char *config_path = NULL; |
249 | 223 | ||
@@ -351,7 +325,6 @@ int main(int argc, char **argv) { | |||
351 | return 0; | 325 | return 0; |
352 | } | 326 | } |
353 | 327 | ||
354 | detect_proprietary(allow_unsupported_gpu); | ||
355 | increase_nofile_limit(); | 328 | increase_nofile_limit(); |
356 | 329 | ||
357 | // handle SIGTERM signals | 330 | // handle SIGTERM signals |
diff --git a/sway/server.c b/sway/server.c index be521621..267e46c0 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <wlr/types/wlr_xdg_foreign_v1.h> | 37 | #include <wlr/types/wlr_xdg_foreign_v1.h> |
38 | #include <wlr/types/wlr_xdg_foreign_v2.h> | 38 | #include <wlr/types/wlr_xdg_foreign_v2.h> |
39 | #include <wlr/types/wlr_xdg_output_v1.h> | 39 | #include <wlr/types/wlr_xdg_output_v1.h> |
40 | #include <xf86drm.h> | ||
40 | #include "config.h" | 41 | #include "config.h" |
41 | #include "list.h" | 42 | #include "list.h" |
42 | #include "log.h" | 43 | #include "log.h" |
@@ -60,6 +61,8 @@ | |||
60 | #define SWAY_XDG_SHELL_VERSION 2 | 61 | #define SWAY_XDG_SHELL_VERSION 2 |
61 | #define SWAY_LAYER_SHELL_VERSION 4 | 62 | #define SWAY_LAYER_SHELL_VERSION 4 |
62 | 63 | ||
64 | bool allow_unsupported_gpu = false; | ||
65 | |||
63 | #if WLR_HAS_DRM_BACKEND | 66 | #if WLR_HAS_DRM_BACKEND |
64 | static void handle_drm_lease_request(struct wl_listener *listener, void *data) { | 67 | static void handle_drm_lease_request(struct wl_listener *listener, void *data) { |
65 | /* We only offer non-desktop outputs, but in the future we might want to do | 68 | /* We only offer non-desktop outputs, but in the future we might want to do |
@@ -113,6 +116,33 @@ static bool filter_global(const struct wl_client *client, | |||
113 | return true; | 116 | return true; |
114 | } | 117 | } |
115 | 118 | ||
119 | static void detect_proprietary(struct wlr_backend *backend, void *data) { | ||
120 | int drm_fd = wlr_backend_get_drm_fd(backend); | ||
121 | if (drm_fd < 0) { | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | drmVersion *version = drmGetVersion(drm_fd); | ||
126 | if (version == NULL) { | ||
127 | sway_log(SWAY_ERROR, "drmGetVersion() failed"); | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | if (strcmp(version->name, "nvidia-drm") == 0) { | ||
132 | if (allow_unsupported_gpu) { | ||
133 | sway_log(SWAY_ERROR, "!!! Proprietary Nvidia drivers are in use !!!"); | ||
134 | } else { | ||
135 | sway_log(SWAY_ERROR, | ||
136 | "Proprietary Nvidia drivers are NOT supported. " | ||
137 | "Use Nouveau. To launch sway anyway, launch with " | ||
138 | "--unsupported-gpu and DO NOT report issues."); | ||
139 | exit(EXIT_FAILURE); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | drmFreeVersion(version); | ||
144 | } | ||
145 | |||
116 | bool server_init(struct sway_server *server) { | 146 | bool server_init(struct sway_server *server) { |
117 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); | 147 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); |
118 | server->wl_display = wl_display_create(); | 148 | server->wl_display = wl_display_create(); |
@@ -128,6 +158,8 @@ bool server_init(struct sway_server *server) { | |||
128 | return false; | 158 | return false; |
129 | } | 159 | } |
130 | 160 | ||
161 | wlr_multi_for_each_backend(server->backend, detect_proprietary, NULL); | ||
162 | |||
131 | server->renderer = wlr_renderer_autocreate(server->backend); | 163 | server->renderer = wlr_renderer_autocreate(server->backend); |
132 | if (!server->renderer) { | 164 | if (!server->renderer) { |
133 | sway_log(SWAY_ERROR, "Failed to create renderer"); | 165 | sway_log(SWAY_ERROR, "Failed to create renderer"); |