mirror of
https://github.com/labwc/labwc.git
synced 2025-11-01 22:58:47 -04:00
xwayland: Add xwayland.h and move more things to xwayland.c
- Move xwayland-specific struct definitions to new xwayland.h header - Move xwayland_move_sub_views_to_front() from desktop.c to xwayland.c - Split out xwayland_server_init/finish() from server_init/finish() - Rename new_xwayland_surface -> xwayland_new_surface and xwayland_surface_new() -> handle_new_surface() for consistency - Add "mapped" argument to xwayland_unmanaged_create() so that we can make unmanaged_handle_map() private to xwayland-unmanaged.c
This commit is contained in:
parent
b62159fe06
commit
45e0a4f48c
8 changed files with 179 additions and 152 deletions
|
|
@ -43,9 +43,6 @@
|
||||||
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
||||||
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
#include <wlr/xwayland.h>
|
|
||||||
#endif
|
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "config/keybind.h"
|
#include "config/keybind.h"
|
||||||
|
|
@ -217,7 +214,7 @@ struct server {
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
struct wlr_xwayland *xwayland;
|
struct wlr_xwayland *xwayland;
|
||||||
struct wl_listener xwayland_ready;
|
struct wl_listener xwayland_ready;
|
||||||
struct wl_listener new_xwayland_surface;
|
struct wl_listener xwayland_new_surface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct wlr_input_inhibit_manager *input_inhibit;
|
struct wlr_input_inhibit_manager *input_inhibit;
|
||||||
|
|
@ -322,24 +319,6 @@ struct output {
|
||||||
|
|
||||||
#undef LAB_NR_LAYERS
|
#undef LAB_NR_LAYERS
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
struct xwayland_unmanaged {
|
|
||||||
struct server *server;
|
|
||||||
struct wlr_xwayland_surface *xwayland_surface;
|
|
||||||
struct wlr_scene_node *node;
|
|
||||||
struct wl_list link;
|
|
||||||
|
|
||||||
struct wl_listener request_activate;
|
|
||||||
struct wl_listener request_configure;
|
|
||||||
/* struct wl_listener request_fullscreen; */
|
|
||||||
struct wl_listener set_geometry;
|
|
||||||
struct wl_listener map;
|
|
||||||
struct wl_listener unmap;
|
|
||||||
struct wl_listener destroy;
|
|
||||||
struct wl_listener override_redirect;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct constraint {
|
struct constraint {
|
||||||
struct seat *seat;
|
struct seat *seat;
|
||||||
struct wlr_pointer_constraint_v1 *constraint;
|
struct wlr_pointer_constraint_v1 *constraint;
|
||||||
|
|
@ -358,14 +337,6 @@ void xdg_toplevel_decoration(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
void xdg_surface_new(struct wl_listener *listener, void *data);
|
void xdg_surface_new(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
bool xwayland_apply_size_hints(struct view *view, int *w, int *h);
|
|
||||||
void xwayland_surface_new(struct wl_listener *listener, void *data);
|
|
||||||
struct xwayland_unmanaged *xwayland_unmanaged_create(struct server *server,
|
|
||||||
struct wlr_xwayland_surface *xsurface);
|
|
||||||
void unmanaged_handle_map(struct wl_listener *listener, void *data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void foreign_toplevel_handle_create(struct view *view);
|
void foreign_toplevel_handle_create(struct view *view);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -97,24 +97,6 @@ struct xdg_toplevel_view {
|
||||||
struct wl_listener new_popup;
|
struct wl_listener new_popup;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
struct xwayland_view {
|
|
||||||
struct view base;
|
|
||||||
struct wlr_xwayland_surface *xwayland_surface;
|
|
||||||
|
|
||||||
/* Events unique to XWayland views */
|
|
||||||
struct wl_listener request_configure;
|
|
||||||
struct wl_listener set_app_id; /* TODO: s/set_app_id/class/ */
|
|
||||||
struct wl_listener set_decorations;
|
|
||||||
struct wl_listener override_redirect;
|
|
||||||
|
|
||||||
/* Not (yet) implemented */
|
|
||||||
/* struct wl_listener set_role; */
|
|
||||||
/* struct wl_listener set_window_type; */
|
|
||||||
/* struct wl_listener set_hints; */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void view_set_activated(struct view *view);
|
void view_set_activated(struct view *view);
|
||||||
void view_close(struct view *view);
|
void view_close(struct view *view);
|
||||||
|
|
||||||
|
|
@ -169,9 +151,4 @@ void view_destroy(struct view *view);
|
||||||
/* xdg.c */
|
/* xdg.c */
|
||||||
struct wlr_xdg_surface *xdg_surface_from_view(struct view *view);
|
struct wlr_xdg_surface *xdg_surface_from_view(struct view *view);
|
||||||
|
|
||||||
/* xwayland.c */
|
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __LABWC_VIEW_H */
|
#endif /* __LABWC_VIEW_H */
|
||||||
|
|
|
||||||
56
include/xwayland.h
Normal file
56
include/xwayland.h
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#ifndef __LABWC_XWAYLAND_H
|
||||||
|
#define __LABWC_XWAYLAND_H
|
||||||
|
#include "config.h"
|
||||||
|
#if HAVE_XWAYLAND
|
||||||
|
#include "view.h"
|
||||||
|
|
||||||
|
struct wlr_compositor;
|
||||||
|
|
||||||
|
struct xwayland_unmanaged {
|
||||||
|
struct server *server;
|
||||||
|
struct wlr_xwayland_surface *xwayland_surface;
|
||||||
|
struct wlr_scene_node *node;
|
||||||
|
struct wl_list link;
|
||||||
|
|
||||||
|
struct wl_listener request_activate;
|
||||||
|
struct wl_listener request_configure;
|
||||||
|
/* struct wl_listener request_fullscreen; */
|
||||||
|
struct wl_listener set_geometry;
|
||||||
|
struct wl_listener map;
|
||||||
|
struct wl_listener unmap;
|
||||||
|
struct wl_listener destroy;
|
||||||
|
struct wl_listener override_redirect;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xwayland_view {
|
||||||
|
struct view base;
|
||||||
|
struct wlr_xwayland_surface *xwayland_surface;
|
||||||
|
|
||||||
|
/* Events unique to XWayland views */
|
||||||
|
struct wl_listener request_configure;
|
||||||
|
struct wl_listener set_app_id; /* TODO: s/set_app_id/class/ */
|
||||||
|
struct wl_listener set_decorations;
|
||||||
|
struct wl_listener override_redirect;
|
||||||
|
|
||||||
|
/* Not (yet) implemented */
|
||||||
|
/* struct wl_listener set_role; */
|
||||||
|
/* struct wl_listener set_window_type; */
|
||||||
|
/* struct wl_listener set_hints; */
|
||||||
|
};
|
||||||
|
|
||||||
|
void xwayland_unmanaged_create(struct server *server,
|
||||||
|
struct wlr_xwayland_surface *xsurface, bool mapped);
|
||||||
|
|
||||||
|
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
|
||||||
|
|
||||||
|
bool xwayland_apply_size_hints(struct view *view, int *w, int *h);
|
||||||
|
void xwayland_move_sub_views_to_front(struct view *parent,
|
||||||
|
void (*move_to_front)(struct view *view));
|
||||||
|
|
||||||
|
void xwayland_server_init(struct server *server,
|
||||||
|
struct wlr_compositor *compositor);
|
||||||
|
void xwayland_server_finish(struct server *server);
|
||||||
|
|
||||||
|
#endif /* HAVE_XWAYLAND */
|
||||||
|
#endif /* __LABWC_XWAYLAND_H */
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
#include "xwayland.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
move_to_front(struct view *view)
|
move_to_front(struct view *view)
|
||||||
|
|
@ -19,47 +20,6 @@ move_to_front(struct view *view)
|
||||||
wlr_scene_node_raise_to_top(&view->scene_tree->node);
|
wlr_scene_node_raise_to_top(&view->scene_tree->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
static struct wlr_xwayland_surface *
|
|
||||||
top_parent_of(struct view *view)
|
|
||||||
{
|
|
||||||
struct wlr_xwayland_surface *s = xwayland_surface_from_view(view);
|
|
||||||
while (s->parent) {
|
|
||||||
s = s->parent;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
move_xwayland_sub_views_to_front(struct view *parent)
|
|
||||||
{
|
|
||||||
if (!parent || parent->type != LAB_XWAYLAND_VIEW) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct wlr_xwayland_surface *parent_xwayland_surface =
|
|
||||||
xwayland_surface_from_view(parent);
|
|
||||||
struct view *view, *next;
|
|
||||||
wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
|
|
||||||
{
|
|
||||||
/* need to stop here, otherwise loops keeps going forever */
|
|
||||||
if (view == parent) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (view->type != LAB_XWAYLAND_VIEW) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!view->mapped && !view->minimized) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (top_parent_of(view) != parent_xwayland_surface) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
move_to_front(view);
|
|
||||||
/* TODO: we should probably focus on these too here */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
desktop_move_to_front(struct view *view)
|
desktop_move_to_front(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +28,7 @@ desktop_move_to_front(struct view *view)
|
||||||
}
|
}
|
||||||
move_to_front(view);
|
move_to_front(view);
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
move_xwayland_sub_views_to_front(view);
|
xwayland_move_sub_views_to_front(view, move_to_front);
|
||||||
#endif
|
#endif
|
||||||
cursor_update_focus(view->server);
|
cursor_update_focus(view->server);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
50
src/server.c
50
src/server.c
|
|
@ -11,6 +11,9 @@
|
||||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||||
#include <wlr/types/wlr_screencopy_v1.h>
|
#include <wlr/types/wlr_screencopy_v1.h>
|
||||||
#include <wlr/types/wlr_viewporter.h>
|
#include <wlr/types/wlr_viewporter.h>
|
||||||
|
#if HAVE_XWAYLAND
|
||||||
|
#include <wlr/xwayland.h>
|
||||||
|
#endif
|
||||||
#include "drm-lease-v1-protocol.h"
|
#include "drm-lease-v1-protocol.h"
|
||||||
#include "config/rcxml.h"
|
#include "config/rcxml.h"
|
||||||
#include "config/session.h"
|
#include "config/session.h"
|
||||||
|
|
@ -20,6 +23,7 @@
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
#include "xwayland.h"
|
||||||
|
|
||||||
#define LAB_XDG_SHELL_VERSION (2)
|
#define LAB_XDG_SHELL_VERSION (2)
|
||||||
|
|
||||||
|
|
@ -148,16 +152,6 @@ handle_drm_lease_request(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
|
||||||
static void
|
|
||||||
handle_xwayland_ready(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct server *server =
|
|
||||||
wl_container_of(listener, server, xwayland_ready);
|
|
||||||
wlr_xwayland_set_seat(server->xwayland, server->seat.seat);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
server_global_filter(const struct wl_client *client, const struct wl_global *global, void *data)
|
server_global_filter(const struct wl_client *client, const struct wl_global *global, void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -396,40 +390,8 @@ server_init(struct server *server)
|
||||||
layers_init(server);
|
layers_init(server);
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
/* Init xwayland */
|
xwayland_server_init(server, compositor);
|
||||||
server->xwayland =
|
|
||||||
wlr_xwayland_create(server->wl_display, compositor, true);
|
|
||||||
if (!server->xwayland) {
|
|
||||||
wlr_log(WLR_ERROR, "cannot create xwayland server");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
server->new_xwayland_surface.notify = xwayland_surface_new;
|
|
||||||
wl_signal_add(&server->xwayland->events.new_surface,
|
|
||||||
&server->new_xwayland_surface);
|
|
||||||
|
|
||||||
server->xwayland_ready.notify = handle_xwayland_ready;
|
|
||||||
wl_signal_add(&server->xwayland->events.ready,
|
|
||||||
&server->xwayland_ready);
|
|
||||||
|
|
||||||
if (setenv("DISPLAY", server->xwayland->display_name, true) < 0) {
|
|
||||||
wlr_log_errno(WLR_ERROR, "unable to set DISPLAY for xwayland");
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_DEBUG, "xwayland is running on display %s",
|
|
||||||
server->xwayland->display_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor;
|
|
||||||
xcursor = wlr_xcursor_manager_get_xcursor(server->seat.xcursor_manager,
|
|
||||||
XCURSOR_DEFAULT, 1);
|
|
||||||
if (xcursor) {
|
|
||||||
struct wlr_xcursor_image *image = xcursor->images[0];
|
|
||||||
wlr_xwayland_set_cursor(server->xwayland, image->buffer,
|
|
||||||
image->width * 4, image->width,
|
|
||||||
image->height, image->hotspot_x,
|
|
||||||
image->hotspot_y);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* used when handling SIGHUP */
|
/* used when handling SIGHUP */
|
||||||
g_server = server;
|
g_server = server;
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +426,7 @@ void
|
||||||
server_finish(struct server *server)
|
server_finish(struct server *server)
|
||||||
{
|
{
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
wlr_xwayland_destroy(server->xwayland);
|
xwayland_server_finish(server);
|
||||||
#endif
|
#endif
|
||||||
if (sighup_source) {
|
if (sighup_source) {
|
||||||
wl_event_source_remove(sighup_source);
|
wl_event_source_remove(sighup_source);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
#include "xwayland.h"
|
||||||
|
|
||||||
#define LAB_MIN_VIEW_WIDTH 100
|
#define LAB_MIN_VIEW_WIDTH 100
|
||||||
#define LAB_MIN_VIEW_HEIGHT 60
|
#define LAB_MIN_VIEW_HEIGHT 60
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <wlr/xwayland.h>
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
#include "xwayland.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unmanaged_handle_request_configure(struct wl_listener *listener, void *data)
|
unmanaged_handle_request_configure(struct wl_listener *listener, void *data)
|
||||||
|
|
@ -30,7 +32,7 @@ unmanaged_handle_set_geometry(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
unmanaged_handle_map(struct wl_listener *listener, void *data)
|
unmanaged_handle_map(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct xwayland_unmanaged *unmanaged =
|
struct xwayland_unmanaged *unmanaged =
|
||||||
|
|
@ -140,9 +142,9 @@ unmanaged_handle_request_activate(struct wl_listener *listener, void *data)
|
||||||
wlr_log(WLR_DEBUG, "request_activate not handled\n");
|
wlr_log(WLR_DEBUG, "request_activate not handled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct xwayland_unmanaged *
|
void
|
||||||
xwayland_unmanaged_create(struct server *server,
|
xwayland_unmanaged_create(struct server *server,
|
||||||
struct wlr_xwayland_surface *xsurface)
|
struct wlr_xwayland_surface *xsurface, bool mapped)
|
||||||
{
|
{
|
||||||
struct xwayland_unmanaged *unmanaged = znew(*unmanaged);
|
struct xwayland_unmanaged *unmanaged = znew(*unmanaged);
|
||||||
unmanaged->server = server;
|
unmanaged->server = server;
|
||||||
|
|
@ -170,5 +172,7 @@ xwayland_unmanaged_create(struct server *server,
|
||||||
&unmanaged->request_activate);
|
&unmanaged->request_activate);
|
||||||
unmanaged->request_activate.notify = unmanaged_handle_request_activate;
|
unmanaged->request_activate.notify = unmanaged_handle_request_activate;
|
||||||
|
|
||||||
return unmanaged;
|
if (mapped) {
|
||||||
|
unmanaged_handle_map(&unmanaged->map, xsurface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
114
src/xwayland.c
114
src/xwayland.c
|
|
@ -1,11 +1,15 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wlr/xwayland.h>
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
#include "xwayland.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
round_to_increment(int val, int base, int inc)
|
round_to_increment(int val, int base, int inc)
|
||||||
|
|
@ -18,6 +22,7 @@ round_to_increment(int val, int base, int inc)
|
||||||
bool
|
bool
|
||||||
xwayland_apply_size_hints(struct view *view, int *w, int *h)
|
xwayland_apply_size_hints(struct view *view, int *w, int *h)
|
||||||
{
|
{
|
||||||
|
assert(view);
|
||||||
if (view->type == LAB_XWAYLAND_VIEW) {
|
if (view->type == LAB_XWAYLAND_VIEW) {
|
||||||
xcb_size_hints_t *hints =
|
xcb_size_hints_t *hints =
|
||||||
xwayland_surface_from_view(view)->size_hints;
|
xwayland_surface_from_view(view)->size_hints;
|
||||||
|
|
@ -42,6 +47,50 @@ xwayland_apply_size_hints(struct view *view, int *w, int *h)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct wlr_xwayland_surface *
|
||||||
|
top_parent_of(struct view *view)
|
||||||
|
{
|
||||||
|
struct wlr_xwayland_surface *s = xwayland_surface_from_view(view);
|
||||||
|
while (s->parent) {
|
||||||
|
s = s->parent;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xwayland_move_sub_views_to_front(struct view *parent,
|
||||||
|
void (*move_to_front)(struct view *view))
|
||||||
|
{
|
||||||
|
assert(parent);
|
||||||
|
assert(move_to_front);
|
||||||
|
|
||||||
|
if (parent->type != LAB_XWAYLAND_VIEW) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_xwayland_surface *parent_xwayland_surface =
|
||||||
|
xwayland_surface_from_view(parent);
|
||||||
|
struct view *view, *next;
|
||||||
|
wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
|
||||||
|
{
|
||||||
|
/* need to stop here, otherwise loops keeps going forever */
|
||||||
|
if (view == parent) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (view->type != LAB_XWAYLAND_VIEW) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!view->mapped && !view->minimized) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (top_parent_of(view) != parent_xwayland_surface) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
move_to_front(view);
|
||||||
|
/* TODO: we should probably focus on these too here */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct xwayland_view *
|
static struct xwayland_view *
|
||||||
xwayland_view_from_view(struct view *view)
|
xwayland_view_from_view(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -360,11 +409,7 @@ handle_override_redirect(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
handle_destroy(&view->destroy, xsurface);
|
handle_destroy(&view->destroy, xsurface);
|
||||||
/* view is invalid after this point */
|
/* view is invalid after this point */
|
||||||
struct xwayland_unmanaged *unmanaged =
|
xwayland_unmanaged_create(server, xsurface, mapped);
|
||||||
xwayland_unmanaged_create(server, xsurface);
|
|
||||||
if (mapped) {
|
|
||||||
unmanaged_handle_map(&unmanaged->map, xsurface);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -534,11 +579,11 @@ static const struct view_impl xwl_view_impl = {
|
||||||
.maximize = maximize
|
.maximize = maximize
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static void
|
||||||
xwayland_surface_new(struct wl_listener *listener, void *data)
|
handle_new_surface(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct server *server =
|
struct server *server =
|
||||||
wl_container_of(listener, server, new_xwayland_surface);
|
wl_container_of(listener, server, xwayland_new_surface);
|
||||||
struct wlr_xwayland_surface *xsurface = data;
|
struct wlr_xwayland_surface *xsurface = data;
|
||||||
wlr_xwayland_surface_ping(xsurface);
|
wlr_xwayland_surface_ping(xsurface);
|
||||||
|
|
||||||
|
|
@ -547,7 +592,7 @@ xwayland_surface_new(struct wl_listener *listener, void *data)
|
||||||
* but add them to server.unmanaged_surfaces so that we can render them
|
* but add them to server.unmanaged_surfaces so that we can render them
|
||||||
*/
|
*/
|
||||||
if (xsurface->override_redirect) {
|
if (xsurface->override_redirect) {
|
||||||
xwayland_unmanaged_create(server, xsurface);
|
xwayland_unmanaged_create(server, xsurface, /* mapped */ false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -614,3 +659,54 @@ xwayland_surface_new(struct wl_listener *listener, void *data)
|
||||||
|
|
||||||
wl_list_insert(&view->server->views, &view->link);
|
wl_list_insert(&view->server->views, &view->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_ready(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct server *server =
|
||||||
|
wl_container_of(listener, server, xwayland_ready);
|
||||||
|
wlr_xwayland_set_seat(server->xwayland, server->seat.seat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xwayland_server_init(struct server *server, struct wlr_compositor *compositor)
|
||||||
|
{
|
||||||
|
server->xwayland =
|
||||||
|
wlr_xwayland_create(server->wl_display, compositor, true);
|
||||||
|
if (!server->xwayland) {
|
||||||
|
wlr_log(WLR_ERROR, "cannot create xwayland server");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
server->xwayland_new_surface.notify = handle_new_surface;
|
||||||
|
wl_signal_add(&server->xwayland->events.new_surface,
|
||||||
|
&server->xwayland_new_surface);
|
||||||
|
|
||||||
|
server->xwayland_ready.notify = handle_ready;
|
||||||
|
wl_signal_add(&server->xwayland->events.ready,
|
||||||
|
&server->xwayland_ready);
|
||||||
|
|
||||||
|
if (setenv("DISPLAY", server->xwayland->display_name, true) < 0) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "unable to set DISPLAY for xwayland");
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_DEBUG, "xwayland is running on display %s",
|
||||||
|
server->xwayland->display_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_xcursor *xcursor;
|
||||||
|
xcursor = wlr_xcursor_manager_get_xcursor(server->seat.xcursor_manager,
|
||||||
|
XCURSOR_DEFAULT, 1);
|
||||||
|
if (xcursor) {
|
||||||
|
struct wlr_xcursor_image *image = xcursor->images[0];
|
||||||
|
wlr_xwayland_set_cursor(server->xwayland, image->buffer,
|
||||||
|
image->width * 4, image->width,
|
||||||
|
image->height, image->hotspot_x,
|
||||||
|
image->hotspot_y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xwayland_server_finish(struct server *server)
|
||||||
|
{
|
||||||
|
wlr_xwayland_destroy(server->xwayland);
|
||||||
|
server->xwayland = NULL;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue