mirror of
https://codeberg.org/dwl/dwl.git
synced 2024-12-25 18:56:30 +00:00
Merge branch 'main' into push
This commit is contained in:
commit
7c3c5ffcc2
1 changed files with 31 additions and 36 deletions
67
dwl.c
67
dwl.c
|
@ -74,7 +74,7 @@
|
|||
/* enums */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11Managed, X11Unmanaged }; /* client types */
|
||||
enum { LyrBg, LyrBottom, LyrTop, LyrOverlay, LyrTile, LyrFloat, LyrFS, LyrDragIcon, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrFS, LyrTop, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
#ifdef XWAYLAND
|
||||
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
|
||||
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
|
||||
|
@ -330,6 +330,8 @@ static struct wl_display *dpy;
|
|||
static struct wlr_backend *backend;
|
||||
static struct wlr_scene *scene;
|
||||
static struct wlr_scene_tree *layers[NUM_LAYERS];
|
||||
/* Map from ZWLR_LAYER_SHELL_* constants to Lyr* enum */
|
||||
static const int layermap[] = { LyrBg, LyrBottom, LyrTop, LyrOverlay };
|
||||
static struct wlr_renderer *drw;
|
||||
static struct wlr_allocator *alloc;
|
||||
static struct wlr_compositor *compositor;
|
||||
|
@ -738,17 +740,16 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
|||
LayerSurface *layersurface = wl_container_of(listener, layersurface, surface_commit);
|
||||
struct wlr_layer_surface_v1 *wlr_layer_surface = layersurface->layer_surface;
|
||||
struct wlr_output *wlr_output = wlr_layer_surface->output;
|
||||
struct wlr_scene_tree *layer = layers[layermap[wlr_layer_surface->current.layer]];
|
||||
|
||||
/* For some reason this layersurface have no monitor, this can be because
|
||||
* its monitor has just been destroyed */
|
||||
if (!wlr_output || !(layersurface->mon = wlr_output->data))
|
||||
return;
|
||||
|
||||
if (layers[wlr_layer_surface->current.layer] != layersurface->scene->node.parent) {
|
||||
wlr_scene_node_reparent(&layersurface->scene->node,
|
||||
layers[wlr_layer_surface->current.layer]);
|
||||
wlr_scene_node_reparent(&layersurface->popups->node,
|
||||
layers[wlr_layer_surface->current.layer]);
|
||||
if (layer != layersurface->scene->node.parent) {
|
||||
wlr_scene_node_reparent(&layersurface->scene->node, layer);
|
||||
wlr_scene_node_reparent(&layersurface->popups->node, layer);
|
||||
wl_list_remove(&layersurface->link);
|
||||
wl_list_insert(&layersurface->mon->layers[wlr_layer_surface->current.layer],
|
||||
&layersurface->link);
|
||||
|
@ -834,6 +835,7 @@ createlayersurface(struct wl_listener *listener, void *data)
|
|||
struct wlr_layer_surface_v1 *wlr_layer_surface = data;
|
||||
LayerSurface *layersurface;
|
||||
struct wlr_layer_surface_v1_state old_state;
|
||||
struct wlr_scene_tree *l = layers[layermap[wlr_layer_surface->pending.layer]];
|
||||
|
||||
if (!wlr_layer_surface->output)
|
||||
wlr_layer_surface->output = selmon ? selmon->wlr_output : NULL;
|
||||
|
@ -858,11 +860,9 @@ createlayersurface(struct wl_listener *listener, void *data)
|
|||
layersurface->mon = wlr_layer_surface->output->data;
|
||||
wlr_layer_surface->data = layersurface;
|
||||
|
||||
layersurface->scene_layer = wlr_scene_layer_surface_v1_create(
|
||||
layers[wlr_layer_surface->pending.layer], wlr_layer_surface);
|
||||
layersurface->scene_layer = wlr_scene_layer_surface_v1_create(l, wlr_layer_surface);
|
||||
layersurface->scene = layersurface->scene_layer->tree;
|
||||
layersurface->popups = wlr_layer_surface->surface->data =
|
||||
wlr_scene_tree_create(layers[wlr_layer_surface->pending.layer]);
|
||||
layersurface->popups = wlr_layer_surface->surface->data = wlr_scene_tree_create(l);
|
||||
|
||||
layersurface->scene->node.data = layersurface;
|
||||
|
||||
|
@ -2129,6 +2129,8 @@ setsel(struct wl_listener *listener, void *data)
|
|||
void
|
||||
setup(void)
|
||||
{
|
||||
int layer;
|
||||
|
||||
/* Set up signal handlers */
|
||||
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = sigchld};
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
@ -2155,15 +2157,8 @@ setup(void)
|
|||
|
||||
/* Initialize the scene graph used to lay out windows */
|
||||
scene = wlr_scene_create();
|
||||
layers[LyrBg] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrBottom] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrTile] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrFloat] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrFS] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrTop] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrOverlay] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrDragIcon] = wlr_scene_tree_create(&scene->tree);
|
||||
layers[LyrBlock] = wlr_scene_tree_create(&scene->tree);
|
||||
for (layer = 0; layer < NUM_LAYERS; layer++)
|
||||
layers[layer] = wlr_scene_tree_create(&scene->tree);
|
||||
|
||||
/* Create a renderer with the default implementation */
|
||||
if (!(drw = wlr_renderer_autocreate(backend)))
|
||||
|
@ -2352,11 +2347,13 @@ void
|
|||
startdrag(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_drag *drag = data;
|
||||
struct wlr_scene_tree *icon;
|
||||
|
||||
if (!drag->icon)
|
||||
return;
|
||||
|
||||
drag->icon->data = wlr_scene_subsurface_tree_create(layers[LyrDragIcon], drag->icon->surface);
|
||||
drag->icon->data = icon = wlr_scene_subsurface_tree_create(&scene->tree, drag->icon->surface);
|
||||
wlr_scene_node_place_below(&icon->node, &layers[LyrBlock]->node);
|
||||
motionnotify(0);
|
||||
wl_signal_add(&drag->icon->events.destroy, &drag_icon_destroy);
|
||||
}
|
||||
|
@ -2654,24 +2651,22 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
|||
struct wlr_surface *surface = NULL;
|
||||
Client *c = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
const int *layer;
|
||||
int focus_order[] = { LyrBlock, LyrOverlay, LyrTop, LyrFS, LyrFloat, LyrTile, LyrBottom, LyrBg };
|
||||
int layer;
|
||||
|
||||
for (layer = focus_order; layer < END(focus_order); layer++) {
|
||||
if ((node = wlr_scene_node_at(&layers[*layer]->node, x, y, nx, ny))) {
|
||||
if (node->type == WLR_SCENE_NODE_BUFFER)
|
||||
surface = wlr_scene_surface_from_buffer(
|
||||
wlr_scene_buffer_from_node(node))->surface;
|
||||
/* Walk the tree to find a node that knows the client */
|
||||
for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
|
||||
c = pnode->data;
|
||||
if (c && c->type == LayerShell) {
|
||||
c = NULL;
|
||||
l = pnode->data;
|
||||
}
|
||||
for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) {
|
||||
if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
|
||||
continue;
|
||||
|
||||
if (node->type == WLR_SCENE_NODE_BUFFER)
|
||||
surface = wlr_scene_surface_from_buffer(
|
||||
wlr_scene_buffer_from_node(node))->surface;
|
||||
/* Walk the tree to find a node that knows the client */
|
||||
for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
|
||||
c = pnode->data;
|
||||
if (c && c->type == LayerShell) {
|
||||
c = NULL;
|
||||
l = pnode->data;
|
||||
}
|
||||
if (surface)
|
||||
break;
|
||||
}
|
||||
|
||||
if (psurface) *psurface = surface;
|
||||
|
|
Loading…
Reference in a new issue