diff --git a/README.md b/README.md index 2f4f506e..51f67fdb 100644 --- a/README.md +++ b/README.md @@ -38,13 +38,15 @@ Dependencies include: - wlroots (>=0.11.0) - wayland (>=1.16) - wayland-protocols -- xwayland +- xwayland, xcb (optional) - libinput (>=1.14) - libxml2 - cairo, pango, glib-2.0 - xcb - xkbcommon +Disable xwayland with `meson -Dxwayland=disabled build` + For further details see [wiki/Build](https://github.com/johanmalm/labwc/wiki/Build). ## 3. Configure @@ -87,21 +89,21 @@ Suggested apps to use with labwc: No acceptance criteria exists, but the following list indicates the inteded high level roadmap: -- [x] Support xwayland +- [x] Optionally support xwayland - [x] Parse openbox config files (rc.xml, autostart, environment) - [x] Parse openbox themes files and associated xbm icons - [x] Show maximize, iconify, close buttons - [x] Catch SIGHUP to re-load config file and theme - [x] Support layer-shell protocol ('exclusive' not yet implemented) - [ ] Support root-menu and parse menu.xml (very simple implementation, not submenus yet) +- [ ] Support damage tracking to reduce CPU usage - [ ] Support 'maximize' - [ ] Support wlr-output-management protocol and [kanshi](https://github.com/emersion/kanshi.git) -- [ ] Show window title - [ ] Support foreign-toplevel protocol (e.g. to integrate with wlroots panels/bars) -- [ ] Support damage tracking to reduce CPU usage - [ ] Implement client-menu - [ ] Support on-screen display (osd), for example to support alt-tab window list - [ ] Support HiDPI +- [ ] Support libinput configuration (tap is enabled for the time being) ## 7. Scope diff --git a/include/labwc.h b/include/labwc.h index 83c0801f..b1932ba2 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -1,6 +1,6 @@ #ifndef __LABWC_H #define __LABWC_H - +#include "config.h" #include #include #include @@ -27,7 +27,9 @@ #include #include #include +#if HAVE_XWAYLAND #include +#endif #include #include "common/log.h" @@ -90,8 +92,10 @@ struct server { struct wl_listener new_layer_surface; struct wl_listener xdg_toplevel_decoration; +#if HAVE_XWAYLAND struct wlr_xwayland *xwayland; struct wl_listener new_xwayland_surface; +#endif struct wl_list views; struct wl_list unmanaged_surfaces; @@ -124,7 +128,12 @@ struct output { struct wl_listener destroy; }; -enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW }; +enum view_type { + LAB_XDG_SHELL_VIEW, +#if HAVE_XWAYLAND + LAB_XWAYLAND_VIEW, +#endif +}; enum deco_part { LAB_DECO_NONE = 0, @@ -164,7 +173,9 @@ struct view { union { struct wlr_xdg_surface *xdg_surface; +#if HAVE_XWAYLAND struct wlr_xwayland_surface *xwayland_surface; +#endif }; struct wlr_surface *surface; @@ -202,6 +213,7 @@ struct view { struct wl_listener request_configure; }; +#if HAVE_XWAYLAND struct xwayland_unmanaged { struct server *server; struct wlr_xwayland_surface *xwayland_surface; @@ -214,13 +226,16 @@ struct xwayland_unmanaged { struct wl_listener unmap; struct wl_listener destroy; }; +#endif void xdg_toplevel_decoration(struct wl_listener *listener, void *data); void xdg_surface_new(struct wl_listener *listener, void *data); +#if HAVE_XWAYLAND void xwayland_surface_new(struct wl_listener *listener, void *data); void xwayland_unmanaged_create(struct server *server, struct wlr_xwayland_surface *xsurface); +#endif void view_move_resize(struct view *view, struct wlr_box geo); void view_move(struct view *view, double x, double y); diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 00000000..65ed027a --- /dev/null +++ b/include/meson.build @@ -0,0 +1 @@ +configure_file(output: 'config.h', configuration: conf_data) diff --git a/meson.build b/meson.build index d72a63ee..a52a05d7 100644 --- a/meson.build +++ b/meson.build @@ -34,17 +34,28 @@ wlroots_proj = subproject( if wlroots_proj.found() wlroots = wlroots_proj.get_variable('wlroots') + wlroots_conf = wlroots_proj.get_variable('conf_data') + wlroots_has_xwayland = wlroots_conf.get('WLR_HAS_XWAYLAND') == 1 else - wlroots = dependency('wlroots', version: '>= 0.10.0') + wlroots = dependency('wlroots', version: '>= 0.11.0') + wlroots_has_xwayland = cc.get_define('WLR_HAS_XWAYLAND', prefix: '#include ', dependencies: wlroots) == '1' endif wayland_server = dependency('wayland-server') wayland_protos = dependency('wayland-protocols') xkbcommon = dependency('xkbcommon') +xcb = dependency('xcb', required: get_option('xwayland')) xml2 = dependency('libxml-2.0') glib = dependency('glib-2.0') cairo = dependency('cairo') pangocairo = dependency('pangocairo') +if get_option('xwayland').enabled() and not wlroots_has_xwayland + error('no wlroots Xwayland support') +endif +have_xwayland = xcb.found() and wlroots_has_xwayland +conf_data = configuration_data() +conf_data.set10('HAVE_XWAYLAND', have_xwayland) + labwc_inc = include_directories('include') subdir('protocols') @@ -54,6 +65,7 @@ labwc_deps = [ cairo, pangocairo ] +subdir('include') subdir('src') subdir('docs') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..d34c6170 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications') diff --git a/src/desktop.c b/src/desktop.c index c3777b1c..534966a0 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -1,3 +1,4 @@ +#include "config.h" #include #include "labwc.h" @@ -8,6 +9,7 @@ move_to_front(struct view *view) wl_list_insert(&view->server->views, &view->link); } +#if HAVE_XWAYLAND static struct wlr_xwayland_surface * top_parent_of(struct view *view) { @@ -44,6 +46,7 @@ move_xwayland_sub_views_to_front(struct view *parent) /* TODO: we should probably focus on these too here */ } } +#endif /* Activate/deactivate toplevel surface */ static void @@ -56,10 +59,12 @@ set_activated(struct wlr_surface *surface, bool activated) struct wlr_xdg_surface *s; s = wlr_xdg_surface_from_wlr_surface(surface); wlr_xdg_toplevel_set_activated(s, activated); +#if HAVE_XWAYLAND } else if (wlr_surface_is_xwayland_surface(surface)) { struct wlr_xwayland_surface *s; s = wlr_xwayland_surface_from_wlr_surface(surface); wlr_xwayland_surface_activate(s, activated); +#endif } } @@ -87,7 +92,9 @@ desktop_focus_view(struct seat *seat, struct view *view) move_to_front(view); set_activated(view->surface, true); seat_focus_surface(seat, view->surface); +#if HAVE_XWAYLAND move_xwayland_sub_views_to_front(view); +#endif } } @@ -200,10 +207,12 @@ _view_at(struct view *view, double lx, double ly, struct wlr_surface **surface, _surface = wlr_xdg_surface_surface_at( view->xdg_surface, view_sx, view_sy, &_sx, &_sy); break; +#if HAVE_XWAYLAND case LAB_XWAYLAND_VIEW: _surface = wlr_surface_surface_at(view->surface, view_sx, view_sy, &_sx, &_sy); break; +#endif } if (_surface) { diff --git a/src/meson.build b/src/meson.build index 03eaf670..72518756 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,10 +13,16 @@ labwc_sources = files( 'server.c', 'view.c', 'xdg.c', - 'xwayland.c', - 'xwayland-unmanaged.c', ) +if have_xwayland + labwc_sources += files( + 'xwayland.c', + 'xwayland-unmanaged.c', + ) +endif + + subdir('common') subdir('config') subdir('theme') diff --git a/src/osd.c b/src/osd.c index 7ff71387..705af245 100644 --- a/src/osd.c +++ b/src/osd.c @@ -1,8 +1,10 @@ +#include "config.h" #include "common/log.h" #include "config/keybind.h" #include "config/rcxml.h" #include "labwc.h" +#if HAVE_XWAYLAND static int xwl_nr_parents(struct view *view) { @@ -19,6 +21,7 @@ xwl_nr_parents(struct view *view) } return i; } +#endif static void show_one_xdg_view(struct view *view) @@ -41,6 +44,7 @@ show_one_xdg_view(struct view *view) view->h); } +#if HAVE_XWAYLAND static void show_one_xwl_view(struct view *view) { @@ -69,6 +73,7 @@ show_one_xwl_view(struct view *view) * view->xwayland_surface->surface->sy); */ } +#endif void dbg_show_one_view(struct view *view) @@ -81,8 +86,10 @@ dbg_show_one_view(struct view *view) } if (view->type == LAB_XDG_SHELL_VIEW) { show_one_xdg_view(view); +#if HAVE_XWAYLAND } else if (view->type == LAB_XWAYLAND_VIEW) { show_one_xwl_view(view); +#endif } } diff --git a/src/output.c b/src/output.c index b1563afe..99cec377 100644 --- a/src/output.c +++ b/src/output.c @@ -1,4 +1,5 @@ #define _POSIX_C_SOURCE 200809L +#include "config.h" #include #include "labwc.h" #include "menu/menu.h" @@ -367,6 +368,7 @@ output_frame_notify(struct wl_listener *listener, void *data) /* If in cycle (alt-tab) mode, highlight selected view */ render_cycle_box(output); +#if HAVE_XWAYLAND /* Render xwayland override_redirect surfaces */ struct xwayland_unmanaged *unmanaged; wl_list_for_each_reverse (unmanaged, @@ -383,6 +385,7 @@ output_frame_notify(struct wl_listener *listener, void *data) struct wlr_surface *s = unmanaged->xwayland_surface->surface; render_surface(s, 0, 0, &rdata); } +#endif render_layer(&now, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); render_layer(&now, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); diff --git a/src/server.c b/src/server.c index 54ebe931..b19f8036 100644 --- a/src/server.c +++ b/src/server.c @@ -1,4 +1,5 @@ #define _POSIX_C_SOURCE 200809L +#include "config.h" #include #include #include @@ -175,6 +176,7 @@ server_init(struct server *server) layers_init(server); +#if HAVE_XWAYLAND /* Init xwayland */ server->xwayland = wlr_xwayland_create(server->wl_display, compositor, true); @@ -192,11 +194,13 @@ server_init(struct server *server) wlr_log(WLR_DEBUG, "xwayland is running on display %s", server->xwayland->display_name); } +#endif if (!wlr_xcursor_manager_load(server->seat.xcursor_manager, 1)) { - wlr_log(WLR_ERROR, "cannot load xwayland xcursor theme"); + wlr_log(WLR_ERROR, "cannot load xcursor theme"); } +#if HAVE_XWAYLAND struct wlr_xcursor *xcursor; xcursor = wlr_xcursor_manager_get_xcursor(server->seat.xcursor_manager, XCURSOR_DEFAULT, 1); @@ -207,6 +211,7 @@ server_init(struct server *server) image->height, image->hotspot_x, image->hotspot_y); } +#endif } void @@ -237,13 +242,17 @@ server_start(struct server *server) wl_display_init_shm(server->wl_display); +#if HAVE_XWAYLAND wlr_xwayland_set_seat(server->xwayland, server->seat.seat); +#endif } void server_finish(struct server *server) { +#if HAVE_XWAYLAND wlr_xwayland_destroy(server->xwayland); +#endif if (sighup_source) { wl_event_source_remove(sighup_source); }