]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Make xwayland support optional
authorJohan Malm <jgm323@gmail.com>
Wed, 30 Dec 2020 10:29:21 +0000 (10:29 +0000)
committerJohan Malm <jgm323@gmail.com>
Wed, 30 Dec 2020 10:29:21 +0000 (10:29 +0000)
README.md
include/labwc.h
include/meson.build [new file with mode: 0644]
meson.build
meson_options.txt [new file with mode: 0644]
src/desktop.c
src/meson.build
src/osd.c
src/output.c
src/server.c

index 2f4f506eba8584393dd3b962ff9d0c3fbdf3c8e0..51f67fdb305ce607ba466862a49c20ca0f723983 100644 (file)
--- 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
 
index 83c0801f19cd3dd0466566809d128fa700a9f438..b1932ba20a8f78ec39c5ef06afe33eaca89eb627 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __LABWC_H
 #define __LABWC_H
-
+#include "config.h"
 #include <getopt.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -27,7 +27,9 @@
 #include <wlr/types/wlr_xdg_decoration_v1.h>
 #include <wlr/types/wlr_xdg_shell.h>
 #include <wlr/util/log.h>
+#if HAVE_XWAYLAND
 #include <wlr/xwayland.h>
+#endif
 #include <xkbcommon/xkbcommon.h>
 
 #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 (file)
index 0000000..65ed027
--- /dev/null
@@ -0,0 +1 @@
+configure_file(output: 'config.h',  configuration: conf_data)
index d72a63ee3fc34c56d90839eea3fbbbdadada03c4..a52a05d7f0713adf45eb71b654608f99b0cd706f 100644 (file)
@@ -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 <wlr/config.h>', 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 (file)
index 0000000..d34c617
--- /dev/null
@@ -0,0 +1 @@
+option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')
index c3777b1c7837b47cfe83637952dbc4536740dab8..534966a04e6a13a0add60dfd856d2588b01dc1bb 100644 (file)
@@ -1,3 +1,4 @@
+#include "config.h"
 #include <assert.h>
 #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) {
index 03eaf6708629fae582bac903a6619d6d69b4b4cd..7251875652e3a1a0204dfa1c6af7395b06999b3f 100644 (file)
@@ -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')
index 7ff71387cd6c73dd941b98876b8a61b570aa8687..705af2454a7d56859a1aa0d775ff80f1b8ffb21c 100644 (file)
--- 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
        }
 }
 
index b1563afe2b754d7415915b0ea88848873a1242ec..99cec3776ca692b228700183eb77c15c44cb4510 100644 (file)
@@ -1,4 +1,5 @@
 #define _POSIX_C_SOURCE 200809L
+#include "config.h"
 #include <wlr/types/wlr_xdg_output_v1.h>
 #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]);
index 54ebe931f8bc29ce9c6e53378e7d1a22ef1e3f5e..b19f803644ced21b43bfd09d95fd3a143b34fe27 100644 (file)
@@ -1,4 +1,5 @@
 #define _POSIX_C_SOURCE 200809L
+#include "config.h"
 #include <signal.h>
 #include <sys/wait.h>
 #include <wlr/types/wlr_data_control_v1.h>
@@ -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);
        }