mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
Add xwayland-unmanaged.c
Handle xwayland override_direct surfaces separately from the view struct - in order to simplify code, particularly in view.c
This commit is contained in:
parent
d831743b25
commit
8e7f2e78cd
8 changed files with 162 additions and 24 deletions
86
src/xwayland-unmanaged.c
Normal file
86
src/xwayland-unmanaged.c
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#include "labwc.h"
|
||||
|
||||
static void unmanaged_handle_request_configure(struct wl_listener *listener,
|
||||
void *data)
|
||||
{
|
||||
struct xwayland_unmanaged *unmanaged =
|
||||
wl_container_of(listener, unmanaged, request_configure);
|
||||
struct wlr_xwayland_surface *xsurface = unmanaged->xwayland_surface;
|
||||
struct wlr_xwayland_surface_configure_event *ev = data;
|
||||
wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, ev->width,
|
||||
ev->height);
|
||||
}
|
||||
|
||||
static void unmanaged_handle_commit(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct xwayland_unmanaged *unmanaged =
|
||||
wl_container_of(listener, unmanaged, commit);
|
||||
struct wlr_xwayland_surface *xsurface = unmanaged->xwayland_surface;
|
||||
unmanaged->lx = xsurface->x;
|
||||
unmanaged->ly = xsurface->y;
|
||||
}
|
||||
|
||||
static void unmanaged_handle_map(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct xwayland_unmanaged *unmanaged =
|
||||
wl_container_of(listener, unmanaged, map);
|
||||
struct wlr_xwayland_surface *xsurface = unmanaged->xwayland_surface;
|
||||
|
||||
wl_list_insert(server.unmanaged_surfaces.prev, &unmanaged->link);
|
||||
|
||||
wl_signal_add(&xsurface->surface->events.commit, &unmanaged->commit);
|
||||
unmanaged->commit.notify = unmanaged_handle_commit;
|
||||
|
||||
unmanaged->lx = xsurface->x;
|
||||
unmanaged->ly = xsurface->y;
|
||||
|
||||
if (wlr_xwayland_or_surface_wants_focus(xsurface))
|
||||
seat_focus_surface(xsurface->surface);
|
||||
}
|
||||
|
||||
static void unmanaged_handle_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct xwayland_unmanaged *unmanaged =
|
||||
wl_container_of(listener, unmanaged, unmap);
|
||||
struct wlr_xwayland_surface *xsurface = unmanaged->xwayland_surface;
|
||||
wl_list_remove(&unmanaged->link);
|
||||
wl_list_remove(&unmanaged->commit.link);
|
||||
|
||||
if (server.seat->keyboard_state.focused_surface == xsurface->surface) {
|
||||
struct xwayland_unmanaged *u;
|
||||
wl_list_for_each (u, &server.unmanaged_surfaces, link) {
|
||||
struct wlr_xwayland_surface *prev = u->xwayland_surface;
|
||||
if (!wlr_xwayland_or_surface_wants_focus(prev))
|
||||
continue;
|
||||
seat_focus_surface(prev->surface);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void unmanaged_handle_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct xwayland_unmanaged *unmanaged =
|
||||
wl_container_of(listener, unmanaged, destroy);
|
||||
wl_list_remove(&unmanaged->map.link);
|
||||
wl_list_remove(&unmanaged->unmap.link);
|
||||
wl_list_remove(&unmanaged->destroy.link);
|
||||
free(unmanaged);
|
||||
}
|
||||
|
||||
void xwayland_unmanaged_create(struct wlr_xwayland_surface *xsurface)
|
||||
{
|
||||
struct xwayland_unmanaged *unmanaged;
|
||||
unmanaged = calloc(1, sizeof(struct xwayland_unmanaged));
|
||||
unmanaged->xwayland_surface = xsurface;
|
||||
wl_signal_add(&xsurface->events.request_configure,
|
||||
&unmanaged->request_configure);
|
||||
unmanaged->request_configure.notify =
|
||||
unmanaged_handle_request_configure;
|
||||
wl_signal_add(&xsurface->events.map, &unmanaged->map);
|
||||
unmanaged->map.notify = unmanaged_handle_map;
|
||||
wl_signal_add(&xsurface->events.unmap, &unmanaged->unmap);
|
||||
unmanaged->unmap.notify = unmanaged_handle_unmap;
|
||||
wl_signal_add(&xsurface->events.destroy, &unmanaged->destroy);
|
||||
unmanaged->destroy.notify = unmanaged_handle_destroy;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue