xwayland: move & split internal header file

This commit is contained in:
Dominique Martinet 2017-08-20 07:59:03 +02:00
parent fa0e1015c6
commit eb5b9cc6da
7 changed files with 40 additions and 18 deletions

View file

@ -12,7 +12,7 @@
#include <sys/un.h>
#include <errno.h>
#include "wlr/util/log.h"
#include "xwayland/internals.h"
#include "sockets.h"
static const char *lock_fmt = "/tmp/.X%d-lock";
static const char *socket_dir = "/tmp/.X11-unix";
@ -78,7 +78,7 @@ static bool open_sockets(int socks[2], int display) {
return true;
}
void unlink_sockets(int display) {
void unlink_display_sockets(int display) {
char sun_path[64];
snprintf(sun_path, sizeof(sun_path), socket_fmt, display);

7
xwayland/sockets.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef XWAYLAND_SOCKETS_H
#define XWAYLAND_SOCKETS_H
void unlink_display_sockets(int display);
int open_display_sockets(int socks[2]);
#endif

View file

@ -11,7 +11,8 @@
#include <wayland-server.h>
#include "wlr/util/log.h"
#include "wlr/xwayland.h"
#include "xwayland/internals.h"
#include "sockets.h"
#include "xwm.h"
static void safe_close(int fd) {
if (fd >= 0) {
@ -84,6 +85,10 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
execvpe("Xwayland", argv, envp);
}
static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
struct wl_display *wl_display, struct wlr_compositor *compositor);
static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland);
static void xwayland_destroy_event(struct wl_listener *listener, void *data) {
struct wl_client *client = data;
struct wlr_xwayland *wlr_xwayland = wl_container_of(client, wlr_xwayland, client);
@ -102,7 +107,7 @@ static struct wl_listener xwayland_destroy_listener = {
.notify = xwayland_destroy_event,
};
void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
if (wlr_xwayland->client) {
wl_list_remove(&xwayland_destroy_listener.link);
@ -122,7 +127,7 @@ void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) {
safe_close(wlr_xwayland->wm_fd[0]);
safe_close(wlr_xwayland->wm_fd[1]);
unlink_sockets(wlr_xwayland->display);
unlink_display_sockets(wlr_xwayland->display);
unsetenv("DISPLAY");
/* kill Xwayland process? */
}
@ -148,7 +153,7 @@ static int xserver_handle_ready(int signal_number, void *data) {
return 1;
}
bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
struct wl_display *wl_display, struct wlr_compositor *compositor) {
memset(wlr_xwayland, 0, sizeof(struct wlr_xwayland));
wlr_xwayland->wl_display = wl_display;
@ -204,3 +209,18 @@ bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland,
return true;
}
void wlr_xwayland_destroy(struct wlr_xwayland *wlr_xwayland) {
wlr_xwayland_finish(wlr_xwayland);
free(wlr_xwayland);
}
struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
struct wlr_compositor *compositor) {
struct wlr_xwayland *wlr_xwayland = calloc(1, sizeof(struct wlr_xwayland));
if (wlr_xwayland_init(wlr_xwayland, wl_display, compositor)) {
return wlr_xwayland;
}
free(wlr_xwayland);
return NULL;
}

View file

@ -4,9 +4,7 @@
#include "wlr/util/log.h"
#include "wlr/types/wlr_surface.h"
#include "wlr/xwayland.h"
#include "xwayland/internals.h"
#include "xwm.h"
static int x11_event_handler(int fd, uint32_t mask, void *data) {

83
xwayland/xwm.h Normal file
View file

@ -0,0 +1,83 @@
#ifndef XWAYLAND_INTERNALS_H
#define XWAYLAND_INTERNALS_H
#include <xcb/xcb.h>
#include <wayland-server-core.h>
#include <wlr/xwayland.h>
/* wlc's atom list:
WL_SURFACE_ID,
WM_DELETE_WINDOW,
WM_TAKE_FOCUS,
WM_PROTOCOLS,
WM_NORMAL_HINTS,
MOTIF_WM_HINTS,
TEXT,
UTF8_STRING,
CLIPBOARD,
CLIPBOARD_MANAGER,
TARGETS,
PRIMARY,
WM_S0,
STRING,
WLC_SELECTION,
NET_WM_S0,
NET_WM_PID,
NET_WM_NAME,
NET_WM_STATE,
NET_WM_STATE_FULLSCREEN,
NET_WM_STATE_MODAL,
NET_WM_STATE_ABOVE,
NET_SUPPORTED,
NET_SUPPORTING_WM_CHECK,
NET_WM_WINDOW_TYPE,
NET_WM_WINDOW_TYPE_DESKTOP,
NET_WM_WINDOW_TYPE_DOCK,
NET_WM_WINDOW_TYPE_TOOLBAR,
NET_WM_WINDOW_TYPE_MENU,
NET_WM_WINDOW_TYPE_UTILITY,
NET_WM_WINDOW_TYPE_SPLASH,
NET_WM_WINDOW_TYPE_DIALOG,
NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
NET_WM_WINDOW_TYPE_POPUP_MENU,
NET_WM_WINDOW_TYPE_TOOLTIP,
NET_WM_WINDOW_TYPE_NOTIFICATION,
NET_WM_WINDOW_TYPE_COMBO,
NET_WM_WINDOW_TYPE_DND,
NET_WM_WINDOW_TYPE_NORMAL,
*/
enum atom_name {
WL_SURFACE_ID,
WM_PROTOCOLS,
WM_S0,
NET_SUPPORTED,
NET_WM_S0,
NET_WM_STATE,
ATOM_LAST
};
static const char * const atom_map[ATOM_LAST] = {
"WL_SURFACE_ID",
"WM_PROTOCOLS",
"WM_S0",
"_NET_SUPPORTED",
"_NET_WM_S0",
"_NET_WM_STATE",
};
struct wlr_xwm {
struct wlr_xwayland *xwayland;
struct wl_event_source *event_source;
struct wl_listener surface_listener;
xcb_atom_t atoms[ATOM_LAST];
xcb_connection_t *xcb_conn;
xcb_screen_t *screen;
xcb_window_t window;
};
void xwm_destroy(struct wlr_xwm *xwm);
struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland);
#endif