This commit is contained in:
David Cohen 2026-04-05 20:57:32 +02:00 committed by GitHub
commit d4f238ccc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 51 additions and 29 deletions

19
cage.c
View file

@ -248,6 +248,9 @@ usage(FILE *file, const char *cage)
" -m last Use only the last connected output\n" " -m last Use only the last connected output\n"
" -s\t Allow VT switching\n" " -s\t Allow VT switching\n"
" -v\t Show the version number and exit\n" " -v\t Show the version number and exit\n"
#if CAGE_HAS_XWAYLAND
" -x\t Disable XWayland\n"
#endif
"\n" "\n"
" Use -- when you want to pass arguments to APPLICATION\n", " Use -- when you want to pass arguments to APPLICATION\n",
cage); cage);
@ -256,8 +259,12 @@ usage(FILE *file, const char *cage)
static bool static bool
parse_args(struct cg_server *server, int argc, char *argv[]) parse_args(struct cg_server *server, int argc, char *argv[])
{ {
#if CAGE_HAS_XWAYLAND
server->enable_xwayland = true;
#endif
int c; int c;
while ((c = getopt(argc, argv, "dDhm:sv")) != -1) { while ((c = getopt(argc, argv, "dDhm:svx")) != -1) {
switch (c) { switch (c) {
case 'd': case 'd':
server->xdg_decoration = true; server->xdg_decoration = true;
@ -281,6 +288,11 @@ parse_args(struct cg_server *server, int argc, char *argv[])
case 'v': case 'v':
fprintf(stdout, "Cage version " CAGE_VERSION "\n"); fprintf(stdout, "Cage version " CAGE_VERSION "\n");
exit(0); exit(0);
#if CAGE_HAS_XWAYLAND
case 'x':
server->enable_xwayland = false;
break;
#endif
default: default:
usage(stderr, argv[0]); usage(stderr, argv[0]);
return false; return false;
@ -562,7 +574,9 @@ main(int argc, char *argv[])
#if CAGE_HAS_XWAYLAND #if CAGE_HAS_XWAYLAND
struct wlr_xcursor_manager *xcursor_manager = NULL; struct wlr_xcursor_manager *xcursor_manager = NULL;
struct wlr_xwayland *xwayland = wlr_xwayland_create(server.wl_display, compositor, true); struct wlr_xwayland *xwayland = NULL;
if (server.enable_xwayland) {
xwayland = wlr_xwayland_create(server.wl_display, compositor, true);
if (!xwayland) { if (!xwayland) {
wlr_log(WLR_ERROR, "Cannot create XWayland server"); wlr_log(WLR_ERROR, "Cannot create XWayland server");
} else { } else {
@ -593,6 +607,7 @@ main(int argc, char *argv[])
image->hotspot_y); image->hotspot_y);
} }
} }
}
#endif #endif
const char *socket = wl_display_add_socket_auto(server.wl_display); const char *socket = wl_display_add_socket_auto(server.wl_display);

View file

@ -40,7 +40,12 @@ wayland_server = dependency('wayland-server')
xkbcommon = dependency('xkbcommon') xkbcommon = dependency('xkbcommon')
math = cc.find_library('m') math = cc.find_library('m')
have_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true' xwayland_opt = get_option('xwayland')
_wlroots_has_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true'
if xwayland_opt.enabled() and not _wlroots_has_xwayland
error('wlroots was built without XWayland support')
endif
have_xwayland = _wlroots_has_xwayland and not xwayland_opt.disabled()
version = '@0@'.format(meson.project_version()) version = '@0@'.format(meson.project_version())
git = find_program('git', native: true, required: false) git = find_program('git', native: true, required: false)

View file

@ -1 +1,2 @@
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('xwayland', type: 'feature', value: 'auto', description: 'Enable XWayland support')

View file

@ -72,6 +72,7 @@ struct cg_server {
bool xdg_decoration; bool xdg_decoration;
bool allow_vt_switch; bool allow_vt_switch;
bool enable_xwayland;
bool return_app_code; bool return_app_code;
bool terminated; bool terminated;
enum wlr_log_importance log_level; enum wlr_log_importance log_level;