opt: optimize get client from surface
This commit is contained in:
@@ -153,20 +153,6 @@ static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
|||||||
*geom = c->surface.xdg->geometry;
|
*geom = c->surface.xdg->geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Client *get_client_from_surface(struct wlr_surface *surface) {
|
|
||||||
if (!surface)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// 从 surface 的 data 指针获取 scene tree
|
|
||||||
struct wlr_scene_tree *scene_tree = surface->data;
|
|
||||||
if (!scene_tree)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// 从 scene tree 的 node data 获取 Client
|
|
||||||
Client *c = scene_tree->node.data;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline Client *client_get_parent(Client *c) {
|
static inline Client *client_get_parent(Client *c) {
|
||||||
Client *p = NULL;
|
Client *p = NULL;
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ static void handle_controller_set_hint(struct wl_listener *listener,
|
|||||||
void *data) {
|
void *data) {
|
||||||
struct tearing_controller *controller =
|
struct tearing_controller *controller =
|
||||||
wl_container_of(listener, controller, set_hint);
|
wl_container_of(listener, controller, set_hint);
|
||||||
Client *c = get_client_from_surface(controller->tearing_control->surface);
|
Client *c = NULL;
|
||||||
|
|
||||||
|
toplevel_from_wlr_surface(controller->tearing_control->surface, &c, NULL);
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
/*
|
/*
|
||||||
* tearing_control->current is actually an enum:
|
* tearing_control->current is actually an enum:
|
||||||
|
|||||||
Reference in New Issue
Block a user