From 2bdbd019022f762e629882e864d6b86b23c9dd94 Mon Sep 17 00:00:00 2001 From: "Pierre-Loup A. Griffais" Date: Fri, 22 Nov 2019 22:58:07 -0800 Subject: [PATCH] Some cleanup, --- meson.build | 1 - src/main.c | 4 +++- src/main.cpp | 6 +++--- src/rootston.h | 6 ------ src/steamcompmgr.c | 6 ++---- src/wlserver.c | 35 +++++++++++++++++++++++++++++++++-- src/wlserver.h | 19 +++++++++++++++++++ src/xwayland.c | 45 --------------------------------------------- src/xwayland.h | 2 -- 9 files changed, 60 insertions(+), 64 deletions(-) delete mode 100644 src/rootston.h delete mode 100644 src/xwayland.c delete mode 100644 src/xwayland.h diff --git a/meson.build b/meson.build index 6f98427..a0cbf54 100644 --- a/meson.build +++ b/meson.build @@ -55,7 +55,6 @@ executable( 'src/main.cpp', 'src/main.c', 'src/wlserver.c', - 'src/xwayland.c', dependencies : [ dep_x11, dep_xdamage, dep_xcomposite, dep_xrender, dep_xext, dep_gl, dep_xxf86vm, pixman_dep, drm_dep, wlroots_dep, wayland_server, diff --git a/src/main.c b/src/main.c index 33f6c73..14d14c7 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,10 @@ -#include "wlserver.h" + #define C_SIDE #include "main.hpp" +#include "wlserver.h" + static void xwayland_ready(struct wl_listener *listener, void *data) { diff --git a/src/main.cpp b/src/main.cpp index 7bf338f..b673c70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ #include -#include "rootston.h" +#include "wlserver.h" #include "steamcompmgr.h" #include "main.hpp" @@ -54,11 +54,11 @@ int main(int argc, char **argv) initOutput(); - rootston_init(argc, argv); + wlserver_init(argc, argv); register_signal(); - rootston_run(); + wlserver_run(); } void steamCompMgrThreadRun(void) diff --git a/src/rootston.h b/src/rootston.h deleted file mode 100644 index 50e19fd..0000000 --- a/src/rootston.h +++ /dev/null @@ -1,6 +0,0 @@ -extern "C" { - -int rootston_init(int argc, char **argv); - -int rootston_run(void); -} diff --git a/src/steamcompmgr.c b/src/steamcompmgr.c index 4ef8dae..913b2bb 100644 --- a/src/steamcompmgr.c +++ b/src/steamcompmgr.c @@ -57,12 +57,10 @@ #include "GL/gl.h" #include "glext.h" -#include "wlr/xwayland.h" -#include "wlserver.h" -#include "xwayland.h" - #define C_SIDE + #include "main.hpp" +#include "wlserver.h" #define WAFFLE_API_VERSION 0x0106 #include diff --git a/src/wlserver.c b/src/wlserver.c index 7d67dd0..281f26d 100644 --- a/src/wlserver.c +++ b/src/wlserver.c @@ -18,7 +18,38 @@ struct wlserver_t wlserver; -int rootston_init(int argc, char **argv) { +static void xwayland_surface_role_commit(struct wlr_surface *wlr_surface) { + assert(wlr_surface->role == &xwayland_surface_role); + + struct wlr_texture *tex = wlr_surface_get_texture( wlr_surface ); + + struct wlr_dmabuf_attributes dmabuf_attribs = {}; + bool result = False; + result = wlr_texture_to_dmabuf( tex, &dmabuf_attribs ); + + if (result == False) + { + // + } + + wayland_PushSurface( wlr_surface, &dmabuf_attribs ); +} + +static void xwayland_surface_role_precommit(struct wlr_surface *wlr_surface) { + assert(wlr_surface->role == &xwayland_surface_role); + struct wlr_xwayland_surface *surface = wlr_surface->role_data; + if (surface == NULL) { + return; + } +} + +const struct wlr_surface_role xwayland_surface_role = { + .name = "wlr_xwayland_surface", + .commit = xwayland_surface_role_commit, + .precommit = xwayland_surface_role_precommit, +}; + +int wlserver_init(int argc, char **argv) { bool bIsDRM = False; if ( getenv("DISPLAY") == NULL ) @@ -102,7 +133,7 @@ int rootston_init(int argc, char **argv) { return 0; } -int rootston_run(void) +int wlserver_run(void) { wl_display_run(wlserver.wl_display); // We need to shutdown Xwayland before disconnecting all clients, otherwise diff --git a/src/wlserver.h b/src/wlserver.h index c7e222e..3664a86 100644 --- a/src/wlserver.h +++ b/src/wlserver.h @@ -2,6 +2,9 @@ #pragma once +// Only define wlserver_t on the C side, as wlroots can't build as C++ +#ifdef C_SIDE + #include #include #include @@ -28,3 +31,19 @@ struct wlserver_t { }; extern struct wlserver_t wlserver; + +#endif + +#ifndef C_SIDE +extern "C" { +#endif + +extern const struct wlr_surface_role xwayland_surface_role; + +int wlserver_init(int argc, char **argv); + +int wlserver_run(void); + +#ifndef C_SIDE +} +#endif diff --git a/src/xwayland.c b/src/xwayland.c deleted file mode 100644 index eb86bc1..0000000 --- a/src/xwayland.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "wlserver.h" -#include "xwayland.h" - -#define C_SIDE -#include "main.hpp" - -static void xwayland_surface_role_commit(struct wlr_surface *wlr_surface) { - assert(wlr_surface->role == &xwayland_surface_role); - - struct wlr_texture *tex = wlr_surface_get_texture( wlr_surface ); - - struct wlr_dmabuf_attributes dmabuf_attribs = {}; - bool result = False; - result = wlr_texture_to_dmabuf( tex, &dmabuf_attribs ); - - if (result == False) - { - // - } - - wayland_PushSurface( wlr_surface, &dmabuf_attribs ); -} - -static void xwayland_surface_role_precommit(struct wlr_surface *wlr_surface) { - assert(wlr_surface->role == &xwayland_surface_role); - struct wlr_xwayland_surface *surface = wlr_surface->role_data; - if (surface == NULL) { - return; - } -} - -const struct wlr_surface_role xwayland_surface_role = { - .name = "wlr_xwayland_surface", - .commit = xwayland_surface_role_commit, - .precommit = xwayland_surface_role_precommit, -}; diff --git a/src/xwayland.h b/src/xwayland.h deleted file mode 100644 index 3a3070e..0000000 --- a/src/xwayland.h +++ /dev/null @@ -1,2 +0,0 @@ - -extern const struct wlr_surface_role xwayland_surface_role;