From 95b0724cff864a5866554da1362597e915456ebb Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Mon, 22 Jun 2026 14:31:43 +0800 Subject: [PATCH] opt: add common for struct type It must be placed first; otherwise, after the xytonode's null pointer is forcibly converted, the reading type will encounter an incorrect address --- src/draw/text-node.h | 2 +- src/ext-protocol/text-input.h | 2 +- src/mango.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/draw/text-node.h b/src/draw/text-node.h index 2eb3c4e8..23ac4f9a 100644 --- a/src/draw/text-node.h +++ b/src/draw/text-node.h @@ -72,7 +72,7 @@ typedef struct { } MangoJumpLabel; typedef struct { - uint32_t type; + uint32_t type; // must at first in struct struct wlr_scene_buffer *scene_buffer; struct mango_text_buffer *buffer; cairo_surface_t *surface; diff --git a/src/ext-protocol/text-input.h b/src/ext-protocol/text-input.h index ebe8c7b1..0eb89881 100644 --- a/src/ext-protocol/text-input.h +++ b/src/ext-protocol/text-input.h @@ -27,7 +27,7 @@ struct dwl_input_method_relay { }; struct dwl_input_method_popup { - uint32_t type; + uint32_t type; // must at first in struct struct wlr_input_popup_surface_v2 *popup_surface; struct wlr_scene_tree *tree; struct wlr_scene_tree *scene_surface; diff --git a/src/mango.c b/src/mango.c index 95ca4e91..b0dcbc80 100644 --- a/src/mango.c +++ b/src/mango.c @@ -328,7 +328,7 @@ typedef struct { struct Client { /* Must keep these three elements in this order */ - uint32_t type; /* XDGShell or X11* */ + uint32_t type; // must at first in struct struct wlr_box geom, pending, float_geom, animainit_geom, overview_backup_geom, current, drag_begin_geom; /* layout-relative, includes border */ @@ -509,7 +509,7 @@ typedef struct { typedef struct { /* Must keep these three elements in this order */ - uint32_t type; /* LayerShell */ + uint32_t type; // must at first in struct struct wlr_box geom, current, pending, animainit_geom; Monitor *mon; struct wlr_scene_tree *scene; @@ -539,7 +539,7 @@ typedef struct { } LayerSurface; typedef struct { - uint32_t type; + uint32_t type; // must at first in struct struct wlr_xdg_popup *wlr_popup; struct wl_listener destroy; struct wl_listener commit; @@ -651,7 +651,7 @@ struct TagScrollerState { }; typedef struct { - uint32_t type; + uint32_t type; // must at first in struct int32_t orig_width; int32_t orig_height; bool is_subsurface;