mirror of
https://codeberg.org/dwl/dwl.git
synced 2024-12-27 03:36:31 +00:00
Make drag_icon a persistent scene node
If there is no current drag icon, this node will be empty, but we now have `drag_icon != NULL` as an invariant. This allows us to eliminate a conditional, since there's no harm in moving an empty node's coordinates around with the pointer. ΔSLOC: -1
This commit is contained in:
parent
1841527871
commit
831fc36bc9
1 changed files with 7 additions and 7 deletions
14
dwl.c
14
dwl.c
|
@ -331,6 +331,7 @@ static struct wl_event_source *sighandler[4];
|
||||||
static struct wlr_backend *backend;
|
static struct wlr_backend *backend;
|
||||||
static struct wlr_scene *scene;
|
static struct wlr_scene *scene;
|
||||||
static struct wlr_scene_tree *layers[NUM_LAYERS];
|
static struct wlr_scene_tree *layers[NUM_LAYERS];
|
||||||
|
static struct wlr_scene_tree *drag_icon;
|
||||||
/* Map from ZWLR_LAYER_SHELL_* constants to Lyr* enum */
|
/* Map from ZWLR_LAYER_SHELL_* constants to Lyr* enum */
|
||||||
static const int layermap[] = { LyrBg, LyrBottom, LyrTop, LyrOverlay };
|
static const int layermap[] = { LyrBg, LyrBottom, LyrTop, LyrOverlay };
|
||||||
static struct wlr_renderer *drw;
|
static struct wlr_renderer *drw;
|
||||||
|
@ -1663,7 +1664,6 @@ motionnotify(uint32_t time)
|
||||||
LayerSurface *l = NULL;
|
LayerSurface *l = NULL;
|
||||||
int type;
|
int type;
|
||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
struct wlr_drag_icon *icon;
|
|
||||||
|
|
||||||
/* time is 0 in internal calls meant to restore pointer focus. */
|
/* time is 0 in internal calls meant to restore pointer focus. */
|
||||||
if (time) {
|
if (time) {
|
||||||
|
@ -1674,10 +1674,9 @@ motionnotify(uint32_t time)
|
||||||
selmon = xytomon(cursor->x, cursor->y);
|
selmon = xytomon(cursor->x, cursor->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update drag icon's position if any */
|
/* Update drag icon's position */
|
||||||
if (seat->drag && (icon = seat->drag->icon))
|
wlr_scene_node_set_position(&drag_icon->node, cursor->x, cursor->y);
|
||||||
wlr_scene_node_set_position(icon->data, cursor->x + icon->surface->sx,
|
|
||||||
cursor->y + icon->surface->sy);
|
|
||||||
/* If we are currently grabbing the mouse, handle and return */
|
/* If we are currently grabbing the mouse, handle and return */
|
||||||
if (cursor_mode == CurMove) {
|
if (cursor_mode == CurMove) {
|
||||||
/* Move the grabbed client to the new position. */
|
/* Move the grabbed client to the new position. */
|
||||||
|
@ -2167,6 +2166,8 @@ setup(void)
|
||||||
scene = wlr_scene_create();
|
scene = wlr_scene_create();
|
||||||
for (i = 0; i < NUM_LAYERS; i++)
|
for (i = 0; i < NUM_LAYERS; i++)
|
||||||
layers[i] = wlr_scene_tree_create(&scene->tree);
|
layers[i] = wlr_scene_tree_create(&scene->tree);
|
||||||
|
drag_icon = wlr_scene_tree_create(&scene->tree);
|
||||||
|
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
|
||||||
|
|
||||||
/* Create a renderer with the default implementation */
|
/* Create a renderer with the default implementation */
|
||||||
if (!(drw = wlr_renderer_autocreate(backend)))
|
if (!(drw = wlr_renderer_autocreate(backend)))
|
||||||
|
@ -2338,8 +2339,7 @@ startdrag(struct wl_listener *listener, void *data)
|
||||||
if (!drag->icon)
|
if (!drag->icon)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
drag->icon->data = icon = wlr_scene_subsurface_tree_create(&scene->tree, drag->icon->surface);
|
drag->icon->data = icon = wlr_scene_subsurface_tree_create(drag_icon, drag->icon->surface);
|
||||||
wlr_scene_node_place_below(&icon->node, &layers[LyrBlock]->node);
|
|
||||||
motionnotify(0);
|
motionnotify(0);
|
||||||
wl_signal_add(&drag->icon->events.destroy, &drag_icon_destroy);
|
wl_signal_add(&drag->icon->events.destroy, &drag_icon_destroy);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue