opt: animations logic all use the int type

avoid the coordinates being forcibly limited to positive numbers
This commit is contained in:
DreamMaoMao
2026-01-03 09:37:34 +08:00
parent 0d13b1002e
commit 2771053ee6
21 changed files with 876 additions and 861 deletions

View File

@@ -212,12 +212,12 @@ struct dvec2 {
};
struct ivec2 {
int x, y, width, height;
int32_t x, y, width, height;
};
typedef struct {
int i;
int i2;
int32_t i;
int32_t i2;
float f;
float f2;
char *v;
@@ -230,7 +230,7 @@ typedef struct {
typedef struct {
uint32_t mod;
uint32_t button;
int (*func)(const Arg *);
int32_t (*func)(const Arg *);
const Arg arg;
} Button; // 鼠标按键
@@ -242,7 +242,7 @@ typedef struct {
typedef struct {
uint32_t mod;
uint32_t dir;
int (*func)(const Arg *);
int32_t (*func)(const Arg *);
const Arg arg;
} Axis;
@@ -273,7 +273,7 @@ struct dwl_animation {
uint32_t duration;
struct wlr_box initial;
struct wlr_box current;
int action;
int32_t action;
};
struct dwl_opacity_animation {
@@ -291,8 +291,8 @@ struct dwl_opacity_animation {
typedef struct {
float width_scale;
float height_scale;
int width;
int height;
int32_t width;
int32_t height;
enum corner_location corner_location;
bool should_scale;
} BufferData;
@@ -336,14 +336,14 @@ struct Client {
bool dirty;
uint32_t configure_serial;
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
int isfloating, isurgent, isfullscreen, isfakefullscreen,
int32_t isfloating, isurgent, isfullscreen, isfakefullscreen,
need_float_size_reduce, isminimized, isoverlay, isnosizehint,
ignore_maximize, ignore_minimize;
int ismaximizescreen;
int overview_backup_bw;
int fullscreen_backup_x, fullscreen_backup_y, fullscreen_backup_w,
int32_t ismaximizescreen;
int32_t overview_backup_bw;
int32_t fullscreen_backup_x, fullscreen_backup_y, fullscreen_backup_w,
fullscreen_backup_h;
int overview_isfullscreenbak, overview_ismaximizescreenbak,
int32_t overview_isfullscreenbak, overview_ismaximizescreenbak,
overview_isfloatingbak;
struct wlr_xdg_toplevel_decoration_v1 *decoration;
@@ -358,53 +358,53 @@ struct Client {
const char *animation_type_open;
const char *animation_type_close;
int is_in_scratchpad;
int iscustomsize;
int iscustompos;
int is_scratchpad_show;
int isglobal;
int isnoborder;
int isnoshadow;
int isnoradius;
int isnoanimation;
int isopensilent;
int istagsilent;
int iskilling;
int istagswitching;
int isnamedscratchpad;
int32_t is_in_scratchpad;
int32_t iscustomsize;
int32_t iscustompos;
int32_t is_scratchpad_show;
int32_t isglobal;
int32_t isnoborder;
int32_t isnoshadow;
int32_t isnoradius;
int32_t isnoanimation;
int32_t isopensilent;
int32_t istagsilent;
int32_t iskilling;
int32_t istagswitching;
int32_t isnamedscratchpad;
bool is_pending_open_animation;
bool is_restoring_from_ov;
float scroller_proportion;
bool need_output_flush;
struct dwl_animation animation;
struct dwl_opacity_animation opacity_animation;
int isterm, noswallow;
int allow_csd;
int force_maximize;
int32_t isterm, noswallow;
int32_t allow_csd;
int32_t force_maximize;
pid_t pid;
Client *swallowing, *swallowedby;
bool is_clip_to_hide;
bool drag_to_tile;
bool scratchpad_switching_mon;
bool fake_no_border;
int nofocus;
int nofadein;
int nofadeout;
int no_force_center;
int isunglobal;
int32_t nofocus;
int32_t nofadein;
int32_t nofadeout;
int32_t no_force_center;
int32_t isunglobal;
float focused_opacity;
float unfocused_opacity;
char oldmonname[128];
int noblur;
int32_t noblur;
double master_mfact_per, master_inner_per, stack_inner_per;
double old_master_mfact_per, old_master_inner_per, old_stack_inner_per;
double old_scroller_pproportion;
bool ismaster;
bool cursor_in_upper_half, cursor_in_left_half;
bool isleftstack;
int tearing_hint;
int force_tearing;
int allow_shortcuts_inhibit;
int32_t tearing_hint;
int32_t force_tearing;
int32_t allow_shortcuts_inhibit;
float scroller_proportion_single;
bool isfocusing;
};
@@ -418,14 +418,14 @@ typedef struct {
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
int (*func)(const Arg *);
int32_t (*func)(const Arg *);
const Arg arg;
} Key;
typedef struct {
struct wlr_keyboard_group *wlr_group;
int nsyms;
int32_t nsyms;
const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
uint32_t mods; /* invalid if nsyms == 0 */
uint32_t keycode;
@@ -453,7 +453,7 @@ typedef struct {
struct wlr_scene_layer_surface_v1 *scene_layer;
struct wl_list link;
struct wl_list fadeout_link;
int mapped;
int32_t mapped;
struct wlr_layer_surface_v1 *layer_surface;
struct wl_listener destroy;
@@ -463,9 +463,9 @@ typedef struct {
struct dwl_animation animation;
bool dirty;
int noblur;
int noanim;
int noshadow;
int32_t noblur;
int32_t noanim;
int32_t noshadow;
char *animation_type_open;
char *animation_type_close;
bool need_output_flush;
@@ -495,18 +495,18 @@ struct Monitor {
uint32_t seltags;
uint32_t tagset[2];
double mfact;
int nmaster;
int32_t nmaster;
struct wl_list dwl_ipc_outputs;
int gappih; /* horizontal gap between windows */
int gappiv; /* vertical gap between windows */
int gappoh; /* horizontal outer gaps */
int gappov; /* vertical outer gaps */
int32_t gappih; /* horizontal gap between windows */
int32_t gappiv; /* vertical gap between windows */
int32_t gappoh; /* horizontal outer gaps */
int32_t gappov; /* vertical outer gaps */
Pertag *pertag;
Client *sel, *prevsel;
int isoverview;
int is_in_hotarea;
int asleep;
int32_t isoverview;
int32_t is_in_hotarea;
int32_t asleep;
uint32_t visible_clients;
uint32_t visible_tiling_clients;
uint32_t visible_scroll_tiling_clients;
@@ -537,14 +537,14 @@ static void applyrules(Client *c); // 窗口规则应用,应用config.h中定义
static void arrange(Monitor *m, bool want_animation,
bool from_view); // 布局函数,让窗口俺平铺规则移动和重置大小
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
struct wlr_box *usable_area, int32_t exclusive);
static void arrangelayers(Monitor *m);
static void handle_print_status(struct wl_listener *listener, void *data);
static void axisnotify(struct wl_listener *listener,
void *data); // 滚轮事件处理
static void buttonpress(struct wl_listener *listener,
void *data); // 鼠标按键事件处理
static int ongesture(struct wlr_pointer_swipe_end_event *event);
static int32_t ongesture(struct wlr_pointer_swipe_end_event *event);
static void swipe_begin(struct wl_listener *listener, void *data);
static void swipe_update(struct wl_listener *listener, void *data);
static void swipe_end(struct wl_listener *listener, void *data);
@@ -558,7 +558,7 @@ static void cleanup(void); // 退出清理
static void cleanupmon(struct wl_listener *listener, void *data); // 退出清理
static void closemon(Monitor *m);
static void cleanuplisteners(void);
static void toggle_hotarea(int x_root, int y_root); // 触发热区
static void toggle_hotarea(int32_t x_root, int32_t y_root); // 触发热区
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data);
@@ -585,7 +585,7 @@ static void destroydecoration(struct wl_listener *listener, void *data);
static void destroydragicon(struct wl_listener *listener, void *data);
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
static void destroylock(SessionLock *lock, int unlocked);
static void destroylock(SessionLock *lock, int32_t unlocked);
static void destroylocksurface(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data);
static void destroypointerconstraint(struct wl_listener *listener, void *data);
@@ -594,18 +594,18 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void setcursorshape(struct wl_listener *listener, void *data);
static void focusclient(Client *c, int lift);
static void focusclient(Client *c, int32_t lift);
static void setborder_color(Client *c);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static int keyrepeat(void *data);
static int32_t keyrepeat(void *data);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t state, bool locked, uint32_t mods,
xkb_keysym_t sym, uint32_t keycode);
static int32_t keybinding(uint32_t state, bool locked, uint32_t mods,
xkb_keysym_t sym, uint32_t keycode);
static void keypress(struct wl_listener *listener, void *data);
static void keypressmod(struct wl_listener *listener, void *data);
static bool keypressglobal(struct wlr_surface *last_surface,
@@ -628,26 +628,26 @@ static void add_foreign_topleve(Client *c);
static void exchange_two_client(Client *c1, Client *c2);
static void outputmgrapply(struct wl_listener *listener, void *data);
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config,
int test);
int32_t test);
static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface, double sx,
double sy, uint32_t time);
static void printstatus(void);
static void quitsignal(int signo);
static void quitsignal(int32_t signo);
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requestdrmlease(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void resize(Client *c, struct wlr_box geo, int32_t interact);
static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setfakefullscreen(Client *c, int fakefullscreen);
static void setfullscreen(Client *c, int fullscreen);
static void setmaximizescreen(Client *c, int maximizescreen);
static void setfloating(Client *c, int32_t floating);
static void setfakefullscreen(Client *c, int32_t fakefullscreen);
static void setfullscreen(Client *c, int32_t fullscreen);
static void setmaximizescreen(Client *c, int32_t maximizescreen);
static void reset_maximizescreen_size(Client *c);
static void setgaps(int oh, int ov, int ih, int iv);
static void setgaps(int32_t oh, int32_t ov, int32_t ih, int32_t iv);
static void setmon(Client *c, Monitor *m, uint32_t newtags, bool focus);
static void setpsel(struct wl_listener *listener, void *data);
@@ -663,7 +663,7 @@ static void updatetitle(struct wl_listener *listener, void *data);
static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg, bool want_animation);
static void handlesig(int signo);
static void handlesig(int32_t signo);
static void
handle_keyboard_shortcuts_inhibit_new_inhibitor(struct wl_listener *listener,
void *data);
@@ -675,7 +675,7 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void clear_fullscreen_flag(Client *c);
static pid_t getparentprocess(pid_t p);
static int isdescprocess(pid_t p, pid_t c);
static int32_t isdescprocess(pid_t p, pid_t c);
static Client *termforwin(Client *w);
static void swallow(Client *c, Client *w);
@@ -691,20 +691,21 @@ static void tag_client(const Arg *arg, Client *target_client);
static struct wlr_box setclient_coordinate_center(Client *c,
struct wlr_box geom,
int offsetx, int offsety);
int32_t offsetx,
int32_t offsety);
static uint32_t get_tags_first_tag(uint32_t tags);
static struct wlr_output_mode *
get_nearest_output_mode(struct wlr_output *output, int width, int height,
float refresh);
get_nearest_output_mode(struct wlr_output *output, int32_t width,
int32_t height, float refresh);
static void client_commit(Client *c);
static void layer_commit(LayerSurface *l);
static void apply_border(Client *c);
static void client_set_opacity(Client *c, double opacity);
static void init_baked_points(void);
static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx,
int sy, void *data);
static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer,
int32_t sx, int32_t sy, void *data);
static Client *direction_select(const Arg *arg);
static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m,
@@ -712,13 +713,14 @@ static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m,
static void buffer_set_effect(Client *c, BufferData buffer_data);
static void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer,
int sx, int sy, void *data);
int32_t sx, int32_t sy, void *data);
static void client_set_pending_state(Client *c);
static void layer_set_pending_state(LayerSurface *l);
static void set_rect_size(struct wlr_scene_rect *rect, int width, int height);
static void set_rect_size(struct wlr_scene_rect *rect, int32_t width,
int32_t height);
static Client *center_tiled_select(Monitor *m);
static void handlecursoractivity(void);
static int hidecursor(void *data);
static int32_t hidecursor(void *data);
static bool check_hit_no_border(Client *c);
static void reset_keyboard_layout(void);
static void client_update_oldmonname_record(Client *c, Monitor *m);
@@ -726,13 +728,12 @@ static void pending_kill_client(Client *c);
static uint32_t get_tags_first_tag_num(uint32_t source_tags);
static void set_layer_open_animaiton(LayerSurface *l, struct wlr_box geo);
static void init_fadeout_layers(LayerSurface *l);
static void layer_actual_size(LayerSurface *l, uint32_t *width,
uint32_t *height);
static void layer_actual_size(LayerSurface *l, int32_t *width, int32_t *height);
static void get_layer_target_geometry(LayerSurface *l,
struct wlr_box *target_box);
static void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
int sy, void *data);
static double find_animation_curve_at(double t, int type);
static void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer,
int32_t sx, int32_t sy, void *data);
static double find_animation_curve_at(double t, int32_t type);
static void apply_opacity_to_rect_nodes(Client *c, struct wlr_scene_node *node,
double animation_passed);
@@ -754,8 +755,8 @@ static void enable_adaptive_sync(Monitor *m, struct wlr_output_state *state);
static Client *get_next_stack_client(Client *c, bool reverse);
static void set_float_malposition(Client *tc);
static void set_size_per(Monitor *m, Client *c);
static void resize_tile_client(Client *grabc, bool isdrag, int offsetx,
int offsety, uint32_t time);
static void resize_tile_client(Client *grabc, bool isdrag, int32_t offsetx,
int32_t offsety, uint32_t time);
static void refresh_monitors_workspaces_status(Monitor *m);
static void init_client_properties(Client *c);
static float *get_border_color(Client *c);
@@ -768,7 +769,7 @@ static void clear_fullscreen_and_maximized_state(Monitor *m);
/* variables */
static const char broken[] = "broken";
static pid_t child_pid = -1;
static int locked;
static int32_t locked;
static uint32_t locked_mods = 0;
static void *exclusive_focus;
static struct wl_display *dpy;
@@ -809,7 +810,7 @@ static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock;
static const int layermap[] = {LyrBg, LyrBottom, LyrTop, LyrOverlay};
static const int32_t layermap[] = {LyrBg, LyrBottom, LyrTop, LyrOverlay};
static struct wlr_scene_tree *drag_icon;
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
static struct wlr_pointer_constraints_v1 *pointer_constraints;
@@ -822,20 +823,20 @@ static struct wl_list inputdevices;
static struct wl_list keyboard_shortcut_inhibitors;
static uint32_t cursor_mode;
static Client *grabc;
static int grabcx, grabcy; /* client-relative */
static int drag_begin_cursorx, drag_begin_cursory; /* client-relative */
static int32_t grabcx, grabcy; /* client-relative */
static int32_t drag_begin_cursorx, drag_begin_cursory; /* client-relative */
static bool start_drag_window = false;
static int last_apply_drap_time = 0;
static int32_t last_apply_drap_time = 0;
static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
static int enablegaps = 1; /* enables gaps, used by togglegaps */
static int axis_apply_time = 0;
static int axis_apply_dir = 0;
static int scroller_focus_lock = 0;
static int32_t enablegaps = 1; /* enables gaps, used by togglegaps */
static int32_t axis_apply_time = 0;
static int32_t axis_apply_dir = 0;
static int32_t scroller_focus_lock = 0;
static uint32_t swipe_fingers = 0;
static double swipe_dx = 0;
@@ -865,18 +866,18 @@ static KeyMode keymode = {
static struct {
enum wp_cursor_shape_device_v1_shape shape;
struct wlr_surface *surface;
int hotspot_x;
int hotspot_y;
int32_t hotspot_x;
int32_t hotspot_y;
} last_cursor;
#include "client/client.h"
#include "config/preset.h"
struct Pertag {
uint32_t curtag, prevtag; /* current and previous tag */
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
bool no_hide[LENGTH(tags) + 1]; /* no_hide per tag */
uint32_t curtag, prevtag; /* current and previous tag */
int32_t nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
bool no_hide[LENGTH(tags) + 1]; /* no_hide per tag */
const Layout
*ltidxs[LENGTH(tags) + 1]; /* matrix of tags and layouts indexes */
};
@@ -955,8 +956,8 @@ void client_change_mon(Client *c, Monitor *m) {
void applybounds(Client *c, struct wlr_box *bbox) {
/* set minimum possible */
c->geom.width = MAX(1 + 2 * (int)c->bw, c->geom.width);
c->geom.height = MAX(1 + 2 * (int)c->bw, c->geom.height);
c->geom.width = MAX(1 + 2 * (int32_t)c->bw, c->geom.width);
c->geom.height = MAX(1 + 2 * (int32_t)c->bw, c->geom.height);
if (c->geom.x >= bbox->x + bbox->width)
c->geom.x = bbox->x + bbox->width - c->geom.width;
@@ -1082,9 +1083,9 @@ bool switch_scratchpad_client_state(Client *c) {
// 根据新monitor调整窗口尺寸
c->float_geom.width =
(int)(c->float_geom.width * c->mon->w.width / oldmon->w.width);
c->float_geom.height =
(int)(c->float_geom.height * c->mon->w.height / oldmon->w.height);
(int32_t)(c->float_geom.width * c->mon->w.width / oldmon->w.width);
c->float_geom.height = (int32_t)(c->float_geom.height *
c->mon->w.height / oldmon->w.height);
c->float_geom = setclient_coordinate_center(c, c->float_geom, 0, 0);
@@ -1167,7 +1168,7 @@ void gpureset(struct wl_listener *listener, void *data) {
wlr_renderer_destroy(old_drw);
}
void handlesig(int signo) {
void handlesig(int32_t signo) {
if (signo == SIGCHLD)
while (waitpid(-1, NULL, WNOHANG) > 0)
;
@@ -1175,7 +1176,7 @@ void handlesig(int signo) {
quit(NULL);
}
void toggle_hotarea(int x_root, int y_root) {
void toggle_hotarea(int32_t x_root, int32_t y_root) {
// 左下角热区坐标计算,兼容多显示屏
Arg arg = {0};
@@ -1241,7 +1242,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
void set_float_malposition(Client *tc) {
Client *c = NULL;
int x, y, offset, xreverse, yreverse;
int32_t x, y, offset, xreverse, yreverse;
x = tc->geom.x;
y = tc->geom.y;
xreverse = 1;
@@ -1389,7 +1390,8 @@ void applyrules(Client *c) {
}
}
int fullscreen_state_backup = c->isfullscreen || client_wants_fullscreen(c);
int32_t fullscreen_state_backup =
c->isfullscreen || client_wants_fullscreen(c);
setmon(c, mon, newtags,
!c->isopensilent &&
!(client_is_x11_popup(c) && client_should_ignore_focus(c)) &&
@@ -1436,7 +1438,7 @@ void applyrules(Client *c) {
}
void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area,
int exclusive) {
int32_t exclusive) {
LayerSurface *l = NULL;
struct wlr_box full_area = m->m;
@@ -1455,14 +1457,14 @@ void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area,
}
void apply_window_snap(Client *c) {
int snap_up = 99999, snap_down = 99999, snap_left = 99999,
snap_right = 99999;
int snap_up_temp = 0, snap_down_temp = 0, snap_left_temp = 0,
snap_right_temp = 0;
int snap_up_screen = 0, snap_down_screen = 0, snap_left_screen = 0,
snap_right_screen = 0;
int snap_up_mon = 0, snap_down_mon = 0, snap_left_mon = 0,
snap_right_mon = 0;
int32_t snap_up = 99999, snap_down = 99999, snap_left = 99999,
snap_right = 99999;
int32_t snap_up_temp = 0, snap_down_temp = 0, snap_left_temp = 0,
snap_right_temp = 0;
int32_t snap_up_screen = 0, snap_down_screen = 0, snap_left_screen = 0,
snap_right_screen = 0;
int32_t snap_up_mon = 0, snap_down_mon = 0, snap_left_mon = 0,
snap_right_mon = 0;
uint32_t cbw = !render_border || c->fake_no_border ? borderpx : 0;
uint32_t tcbw;
@@ -1565,7 +1567,7 @@ void focuslayer(LayerSurface *l) {
void reset_exclusive_layer(Monitor *m) {
LayerSurface *l = NULL;
int i;
int32_t i;
uint32_t layers_above_shell[] = {
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
@@ -1575,7 +1577,7 @@ void reset_exclusive_layer(Monitor *m) {
if (!m)
return;
for (i = 0; i < (int)LENGTH(layers_above_shell); i++) {
for (i = 0; i < (int32_t)LENGTH(layers_above_shell); i++) {
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
if (l == exclusive_focus &&
l->layer_surface->current.keyboard_interactive !=
@@ -1601,7 +1603,7 @@ void reset_exclusive_layer(Monitor *m) {
}
void arrangelayers(Monitor *m) {
int i;
int32_t i;
struct wlr_box usable_area = m->m;
if (!m->wlr_output->enabled)
@@ -1633,7 +1635,7 @@ axisnotify(struct wl_listener *listener, void *data) {
struct wlr_keyboard *keyboard, *hard_keyboard;
uint32_t mods, hard_mods;
AxisBinding *a;
int ji;
int32_t ji;
uint32_t adir;
// IDLE_NOTIFY_ACTIVITY;
handlecursoractivity();
@@ -1687,15 +1689,15 @@ axisnotify(struct wl_listener *listener, void *data) {
event->relative_direction);
}
int ongesture(struct wlr_pointer_swipe_end_event *event) {
int32_t ongesture(struct wlr_pointer_swipe_end_event *event) {
struct wlr_keyboard *keyboard, *hard_keyboard;
uint32_t mods, hard_mods;
const GestureBinding *g;
uint32_t motion;
uint32_t adx = (int)round(fabs(swipe_dx));
uint32_t ady = (int)round(fabs(swipe_dy));
int handled = 0;
int ji;
uint32_t adx = (int32_t)round(fabs(swipe_dx));
uint32_t ady = (int32_t)round(fabs(swipe_dy));
int32_t handled = 0;
int32_t ji;
if (event->cancelled) {
return handled;
@@ -1811,12 +1813,12 @@ void place_drag_tile_client(Client *c) {
Client *closest_client = NULL;
long min_distant = LONG_MAX;
long temp_distant;
int x, y;
int32_t x, y;
wl_list_for_each(tc, &clients, link) {
if (tc != c && ISTILED(tc) && VISIBLEON(tc, c->mon)) {
x = tc->geom.x + (int)(tc->geom.width / 2) - cursor->x;
y = tc->geom.y + (int)(tc->geom.height / 2) - cursor->y;
x = tc->geom.x + (int32_t)(tc->geom.width / 2) - cursor->x;
y = tc->geom.y + (int32_t)(tc->geom.height / 2) - cursor->y;
temp_distant = x * x + y * y;
if (temp_distant < min_distant) {
min_distant = temp_distant;
@@ -1863,7 +1865,7 @@ buttonpress(struct wl_listener *listener, void *data) {
LayerSurface *l = NULL;
struct wlr_surface *surface;
Client *tmpc = NULL;
int ji;
int32_t ji;
const MouseBinding *m;
struct wlr_surface *old_pointer_focus_surface =
seat->pointer_state.focused_surface;
@@ -1971,7 +1973,7 @@ buttonpress(struct wl_listener *listener, void *data) {
}
void checkidleinhibitor(struct wlr_surface *exclude) {
int inhibited = 0;
int32_t inhibited = 0;
Client *c = NULL;
struct wlr_surface *surface = NULL;
struct wlr_idle_inhibitor_v1 *inhibitor;
@@ -2125,7 +2127,7 @@ void closemon(Monitor *m) {
/* update selmon if needed and
* move closed monitor's clients to the focused one */
Client *c = NULL;
int i = 0, nmons = wl_list_length(&mons);
int32_t i = 0, nmons = wl_list_length(&mons);
if (!nmons) {
selmon = NULL;
} else if (m == selmon) {
@@ -2158,8 +2160,8 @@ void closemon(Monitor *m) {
}
}
static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
int sy, void *user_data) {
static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer,
int32_t sx, int32_t sy, void *user_data) {
struct wlr_scene_surface *scene_surface =
wlr_scene_surface_try_from_buffer(buffer);
if (!scene_surface) {
@@ -2178,7 +2180,7 @@ static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
void maplayersurfacenotify(struct wl_listener *listener, void *data) {
LayerSurface *l = wl_container_of(listener, l, map);
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
int ji;
int32_t ji;
ConfigLayerRule *r;
l->mapped = 1;
@@ -2409,7 +2411,7 @@ void commitpopup(struct wl_listener *listener, void *data) {
LayerSurface *l = NULL;
Client *c = NULL;
struct wlr_box box;
int type = -1;
int32_t type = -1;
if (!popup->base->initial_commit)
return;
@@ -2596,7 +2598,7 @@ void createlocksurface(struct wl_listener *listener, void *data) {
}
struct wlr_output_mode *get_nearest_output_mode(struct wlr_output *output,
int width, int height,
int32_t width, int32_t height,
float refresh) {
struct wlr_output_mode *mode, *nearest_mode = NULL;
float min_diff = 99999.0f;
@@ -2634,7 +2636,7 @@ void createmon(struct wl_listener *listener, void *data) {
struct wlr_output *wlr_output = data;
const ConfigMonitorRule *r;
uint32_t i;
int ji, jk;
int32_t ji, jk;
struct wlr_output_state state;
Monitor *m = NULL;
struct wlr_output_mode *internal_mode = NULL;
@@ -2707,7 +2709,7 @@ void createmon(struct wl_listener *listener, void *data) {
custom_monitor_mode = true;
wlr_output_state_set_custom_mode(
&state, r->width, r->height,
(int)roundf(r->refresh * 1000));
(int32_t)roundf(r->refresh * 1000));
}
}
wlr_output_state_set_scale(&state, r->scale);
@@ -2928,7 +2930,7 @@ void switch_toggle(struct wl_listener *listener, void *data) {
// 处理切换事件
struct wlr_switch_toggle_event *event = data;
SwitchBinding *s;
int ji;
int32_t ji;
for (ji = 0; ji < config.switch_bindings_count; ji++) {
if (config.switch_bindings_count < 1)
@@ -3053,7 +3055,7 @@ void destroylayersurfacenotify(struct wl_listener *listener, void *data) {
free(l);
}
void destroylock(SessionLock *lock, int unlock) {
void destroylock(SessionLock *lock, int32_t unlock) {
wlr_seat_keyboard_notify_clear_focus(seat);
if ((locked = !unlock))
goto destroy;
@@ -3157,7 +3159,7 @@ void destroykeyboardgroup(struct wl_listener *listener, void *data) {
free(group);
}
void focusclient(Client *c, int lift) {
void focusclient(Client *c, int32_t lift) {
Client *last_focus_client = NULL;
Monitor *um = NULL;
@@ -3248,7 +3250,7 @@ void focusclient(Client *c, int lift) {
* layer is closed. */
Client *w = NULL;
LayerSurface *l = NULL;
int type =
int32_t type =
toplevel_from_wlr_surface(old_keyboard_focus_surface, &w, &l);
if (type == LayerShell && l->scene->node.enabled &&
l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP &&
@@ -3364,9 +3366,9 @@ void inputdevice(struct wl_listener *listener, void *data) {
wlr_seat_set_capabilities(seat, caps);
}
int keyrepeat(void *data) {
int32_t keyrepeat(void *data) {
KeyboardGroup *group = data;
int i;
int32_t i;
if (!group->nsyms || group->wlr_group->keyboard.repeat_info.rate <= 0)
return 0;
@@ -3392,7 +3394,7 @@ bool is_keyboard_shortcut_inhibitor(struct wlr_surface *surface) {
return false;
}
int // 17
int32_t // 17
keybinding(uint32_t state, bool locked, uint32_t mods, xkb_keysym_t sym,
uint32_t keycode) {
/*
@@ -3400,10 +3402,10 @@ keybinding(uint32_t state, bool locked, uint32_t mods, xkb_keysym_t sym,
* processing keys, rather than passing them on to the client for its
* own processing.
*/
int handled = 0;
int32_t handled = 0;
const KeyBinding *k;
int ji;
int isbreak = 0;
int32_t ji;
int32_t isbreak = 0;
// not allow modifier keys to be used as a keybinding
if (keycode == 50 || keycode == 37 || keycode == 133 || keycode == 64 ||
@@ -3466,10 +3468,10 @@ bool keypressglobal(struct wlr_surface *last_surface,
xkb_keysym_t keysym, uint32_t keycode) {
Client *c = NULL, *lastc = focustop(selmon);
uint32_t keycodes[32] = {0};
int reset = false;
int32_t reset = false;
const char *appid = NULL;
const char *title = NULL;
int ji;
int32_t ji;
const ConfigWinRule *r;
for (ji = 0; ji < config.window_rules_count; ji++) {
@@ -3523,7 +3525,7 @@ done:
}
void keypress(struct wl_listener *listener, void *data) {
int i;
int32_t i;
/* This event is raised when a key is pressed or released. */
KeyboardGroup *group = wl_container_of(listener, group, key);
struct wlr_keyboard_key_event *event = data;
@@ -3532,7 +3534,7 @@ void keypress(struct wl_listener *listener, void *data) {
struct wlr_xdg_surface *xdg_surface =
last_surface ? wlr_xdg_surface_try_from_wlr_surface(last_surface)
: NULL;
int pass = 0;
int32_t pass = 0;
bool hit_global = false;
#ifdef XWAYLAND
struct wlr_xwayland_surface *xsurface =
@@ -3544,10 +3546,10 @@ void keypress(struct wl_listener *listener, void *data) {
uint32_t keycode = event->keycode + 8;
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
int nsyms = xkb_state_key_get_syms(group->wlr_group->keyboard.xkb_state,
keycode, &syms);
int32_t nsyms = xkb_state_key_get_syms(group->wlr_group->keyboard.xkb_state,
keycode, &syms);
int handled = 0;
int32_t handled = 0;
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -3658,8 +3660,8 @@ void locksession(struct wl_listener *listener, void *data) {
wlr_session_lock_v1_send_locked(session_lock);
}
static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
int sy, void *user_data) {
static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int32_t sx,
int32_t sy, void *user_data) {
Client *c = user_data;
struct wlr_scene_surface *scene_surface =
@@ -4013,16 +4015,16 @@ void motionnotify(uint32_t time, struct wlr_input_device *device, double dx,
}
/* Update drag icon's position */
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x),
(int)round(cursor->y));
wlr_scene_node_set_position(&drag_icon->node, (int32_t)round(cursor->x),
(int32_t)round(cursor->y));
/* If we are currently grabbing the mouse, handle and return */
if (cursor_mode == CurMove) {
/* Move the grabbed client to the new position. */
grabc->iscustomsize = 1;
grabc->float_geom =
(struct wlr_box){.x = (int)round(cursor->x) - grabcx,
.y = (int)round(cursor->y) - grabcy,
(struct wlr_box){.x = (int32_t)round(cursor->x) - grabcx,
.y = (int32_t)round(cursor->y) - grabcy,
.width = grabc->geom.width,
.height = grabc->geom.height};
resize(grabc, grabc->float_geom, 1);
@@ -4033,8 +4035,8 @@ void motionnotify(uint32_t time, struct wlr_input_device *device, double dx,
grabc->float_geom = (struct wlr_box){
.x = grabc->geom.x,
.y = grabc->geom.y,
.width = (int)round(cursor->x) - grabc->geom.x,
.height = (int)round(cursor->y) - grabc->geom.y};
.width = (int32_t)round(cursor->x) - grabc->geom.x,
.height = (int32_t)round(cursor->y) - grabc->geom.y};
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_refresh_interval) {
resize(grabc, grabc->float_geom, 1);
@@ -4097,7 +4099,7 @@ void outputmgrapply(struct wl_listener *listener, void *data) {
}
void // 0.7 custom
outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test) {
outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int32_t test) {
/*
* Called when a client such as wlr-randr requests a change in output
* configuration. This is only one way that the layout can be changed,
@@ -4105,7 +4107,7 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test) {
* output_layout.change event, not here.
*/
struct wlr_output_configuration_head_v1 *config_head;
int ok = 1;
int32_t ok = 1;
wl_list_for_each(config_head, &config->heads, link) {
struct wlr_output *wlr_output = config_head->state.output;
@@ -4208,10 +4210,10 @@ void powermgrsetmode(struct wl_listener *listener, void *data) {
updatemons(NULL, NULL);
}
void quitsignal(int signo) { quit(NULL); }
void quitsignal(int32_t signo) { quit(NULL); }
void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx, int sy,
void *data) {
void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int32_t sx,
int32_t sy, void *data) {
wlr_scene_buffer_set_opacity(buffer, *(double *)data);
}
@@ -4225,7 +4227,7 @@ void rendermon(struct wl_listener *listener, void *data) {
Client *c = NULL, *tmp = NULL;
struct wlr_output_state pending = {0};
LayerSurface *l = NULL, *tmpl = NULL;
int i;
int32_t i;
struct wl_list *layer_list;
bool frame_allow_tearing = false;
struct timespec now;
@@ -4433,7 +4435,7 @@ run(char *startup_cmd) {
* startup command */
if (startup_cmd) {
int piperw[2];
int32_t piperw[2];
if (pipe(piperw) < 0)
die("startup: pipe:");
if ((child_pid = fork()) < 0)
@@ -4509,7 +4511,7 @@ void setcursor(struct wl_listener *listener, void *data) {
}
void // 0.5
setfloating(Client *c, int floating) {
setfloating(Client *c, int32_t floating) {
Client *fc = NULL;
struct wlr_box target_box;
@@ -4599,7 +4601,7 @@ void reset_maximizescreen_size(Client *c) {
resize(c, c->geom, 0);
}
void setmaximizescreen(Client *c, int maximizescreen) {
void setmaximizescreen(Client *c, int32_t maximizescreen) {
struct wlr_box maximizescreen_box;
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
return;
@@ -4647,7 +4649,7 @@ void setmaximizescreen(Client *c, int maximizescreen) {
arrange(c->mon, false, false);
}
void setfakefullscreen(Client *c, int fakefullscreen) {
void setfakefullscreen(Client *c, int32_t fakefullscreen) {
c->isfakefullscreen = fakefullscreen;
if (!c->mon)
return;
@@ -4657,7 +4659,7 @@ void setfakefullscreen(Client *c, int fakefullscreen) {
client_set_fullscreen(c, fakefullscreen);
}
void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带全屏
void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自带全屏
{
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
@@ -4707,7 +4709,7 @@ void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带
arrange(c->mon, false, false);
}
void setgaps(int oh, int ov, int ih, int iv) {
void setgaps(int32_t oh, int32_t ov, int32_t ih, int32_t iv) {
selmon->gappoh = MAX(oh, 0);
selmon->gappov = MAX(ov, 0);
selmon->gappih = MAX(ih, 0);
@@ -4730,7 +4732,7 @@ void reset_keyboard_layout(void) {
// Get current layout
xkb_layout_index_t current = xkb_state_serialize_layout(
keyboard->xkb_state, XKB_STATE_LAYOUT_EFFECTIVE);
const int num_layouts = xkb_keymap_num_layouts(keyboard->keymap);
const int32_t num_layouts = xkb_keymap_num_layouts(keyboard->keymap);
if (num_layouts < 1) {
wlr_log(WLR_INFO, "No layouts available");
return;
@@ -4754,7 +4756,7 @@ void reset_keyboard_layout(void) {
}
// 验证新keymap是否有布局
const int new_num_layouts = xkb_keymap_num_layouts(new_keymap);
const int32_t new_num_layouts = xkb_keymap_num_layouts(new_keymap);
if (new_num_layouts < 1) {
wlr_log(WLR_ERROR, "New keymap has no layouts");
xkb_keymap_unref(new_keymap);
@@ -4937,7 +4939,7 @@ void setup(void) {
parse_config();
init_baked_points();
int drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
int32_t drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
sigemptyset(&sa.sa_mask);
@@ -5361,7 +5363,7 @@ void handlecursoractivity(void) {
last_cursor.hotspot_x, last_cursor.hotspot_y);
}
int hidecursor(void *data) {
int32_t hidecursor(void *data) {
wlr_cursor_unset_image(cursor);
cursor_hidden = true;
return 1;
@@ -5488,7 +5490,7 @@ void updatemons(struct wl_listener *listener, void *data) {
Client *c = NULL;
struct wlr_output_configuration_head_v1 *config_head;
Monitor *m = NULL;
int mon_pos_offsetx, mon_pos_offsety, oldx, oldy;
int32_t mon_pos_offsetx, mon_pos_offsety, oldx, oldy;
/* First remove from the layout the disabled monitors */
wl_list_for_each(m, &mons, link) {
@@ -5738,7 +5740,7 @@ void handle_keyboard_shortcuts_inhibit_new_inhibitor(
Client *c = NULL;
LayerSurface *l = NULL;
int type = toplevel_from_wlr_surface(inhibitor->surface, &c, &l);
int32_t type = toplevel_from_wlr_surface(inhibitor->surface, &c, &l);
if (type < 0)
return;
@@ -5945,9 +5947,9 @@ static void setgeometrynotify(struct wl_listener *listener, void *data) {
}
#endif
int main(int argc, char *argv[]) {
int32_t main(int32_t argc, char *argv[]) {
char *startup_cmd = NULL;
int c;
int32_t c;
while ((c = getopt(argc, argv, "s:c:hdv")) != -1) {
if (c == 's')