Compare commits

..

39 Commits

Author SHA1 Message Date
rasmusq
9d04eff5ea Merge branch 'main' into feature/dual-row-scroller 2025-12-10 22:05:56 +01:00
DreamMaoMao
f771e56c31 opt: optimize handle foreign toplevel
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-12-10 22:35:45 +08:00
DreamMaoMao
64d350ee9b feat: add bing flag p 2025-12-10 20:11:55 +08:00
DreamMaoMao
4e296671c2 feat: handle foreign toplevel minimize and maximize request 2025-12-10 19:36:32 +08:00
DreamMaoMao
31d29fb48c opt: format code 2025-12-10 18:32:06 +08:00
DreamMaoMao
2aa7e58d7c opt: optimize get client from surface 2025-12-10 18:30:45 +08:00
DreamMaoMao
01e957f2ae opt: allow layershell surface toggle shortcut inhibit 2025-12-10 18:29:16 +08:00
DreamMaoMao
318dc85b22 opt: eliminate the positional deviation in master layout 2025-12-09 20:49:28 +08:00
DreamMaoMao
dfb59d12c2 fix: excrescent border in grid layout 2025-12-09 09:40:22 +08:00
DreamMaoMao
c3253af75d Merge pull request #490 from Mental-Vortex/main
feat: Move window to center when in scroller layout
2025-12-08 22:15:40 +08:00
Mental-Vortex
9a2d2397c1 feat: support centerwin in scroller window 2025-12-08 22:14:14 +08:00
DreamMaoMao
dd72e472bf update readme 2025-12-08 09:42:18 +08:00
DreamMaoMao
f3f3215791 fix: nmaster num caculate error in master layout 2025-12-07 21:34:05 +08:00
DreamMaoMao
1e8e4677dd Merge pull request #488 from Owen-sz/main
doc: add Fedora install instructions
2025-12-07 10:12:00 +08:00
Owen-sz
6086507c5a doc: add Fedora install instructions
Signed-off-by: Owen-sz <owen@fyralabs.com>
2025-12-06 14:50:54 -06:00
rasmusq
178fa5220e Merge branch 'main' into feature/dual-row-scroller 2025-12-04 16:26:20 +01:00
DreamMaoMao
0e59209d2b opt: focusdir use same monitor client first
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-12-04 17:41:25 +08:00
DreamMaoMao
e602605fa4 opt: optimize focus change when change monitor 2025-12-04 09:58:16 +08:00
DreamMaoMao
1b739a1c7e update readme 2025-12-04 09:22:42 +08:00
DreamMaoMao
11b425faad opt: avoid unnecessary focus animations 2025-12-03 22:06:17 +08:00
DreamMaoMao
44c271ee52 opt: optimize border color set when change monitor 2025-12-03 21:58:46 +08:00
DreamMaoMao
2258574e25 bump version to 0.10.7 2025-12-03 18:15:56 +08:00
DreamMaoMao
02377e2867 fix: change u_int32_t to uint32_t 2025-12-03 18:15:35 +08:00
DreamMaoMao
4277159219 opt: add some usage message 2025-12-03 18:15:35 +08:00
DreamMaoMao
e965264f3b fix: dont use evenmask 2025-12-03 17:22:27 +08:00
DreamMaoMao
5c314be8c6 break change: remove autostar.sh and MANGOCONFIG env 2025-12-03 16:22:13 +08:00
DreamMaoMao
1ffdc1ef38 feat: support -c option to specified config file 2025-12-03 16:12:05 +08:00
DreamMaoMao
a2902a469b opt: optimize code struct 2025-12-03 13:47:47 +08:00
DreamMaoMao
068ec120de fix: curtag overflow when view arg is -1 in view dispatch 2025-12-03 09:29:14 +08:00
DreamMaoMao
559de3c66b feat: support view multi tag in view dispatch 2025-12-03 09:11:17 +08:00
DreamMaoMao
bfcde37aba opt: optimize namedscratchpad when swallow 2025-12-03 08:18:35 +08:00
DreamMaoMao
88e868caf8 opt: simple printstatus signal 2025-12-02 18:41:12 +08:00
DreamMaoMao
b9952f03b5 opt: change unsigned int to uint32_t 2025-12-02 16:57:24 +08:00
DreamMaoMao
9196e2a50b opt: use event mask to decide whether print ipc message 2025-12-02 16:46:11 +08:00
DreamMaoMao
075d4979b6 opt: use signal to handle printstauts 2025-12-02 16:19:31 +08:00
DreamMaoMao
e0c80af6b1 update readme 2025-12-01 11:23:18 +08:00
DreamMaoMao
1b7e998b67 opt: optimize scroller layout center client judge 2025-11-30 13:40:48 +08:00
DreamMaoMao
992822e309 opt: not handle virtual group keyborad ov_tab_mode detect 2025-11-30 13:40:48 +08:00
DreamMaoMao
113e73fe4a opt: avoid toggle overview when setfullscreen and setmaximziescreen 2025-11-30 13:40:48 +08:00
23 changed files with 697 additions and 528 deletions

View File

@@ -71,6 +71,8 @@ https://github.com/user-attachments/assets/014c893f-115c-4ae9-8342-f9ae3e9a0df0
- hwdata
- seatd
- pcre2
- xorg-xwayland
- libxcb
## Arch Linux
The package is in the Arch User Repository and is availble for manual download [here](https://aur.archlinux.org/packages/mangowc-git) or through a AUR helper like yay:
@@ -80,7 +82,6 @@ yay -S mangowc-git
```
## Gentoo Linux
The package is in the community-maintained repository called GURU.
First, add GURU repository:
@@ -98,6 +99,16 @@ Finally, install the package:
emerge --ask --verbose gui-wm/mangowc
```
## Fedora Linux
The package is in the third-party Terra repository.
First, add the [Terra Repository](https://terra.fyralabs.com/).
Then, install the package:
```bash
dnf install mangowc
```
## Other
```bash
@@ -170,7 +181,9 @@ git clone https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
## Config Documentation
Refer to the [wiki](https://github.com/DreamMaoMao/mango/wiki/)
Refer to the repo wiki [wiki](https://github.com/DreamMaoMao/mango/wiki/)
or the website docs [docs](https://mangowc.vercel.app/docs)
# NixOS + Home-manager
@@ -248,14 +261,6 @@ Here's an example of using the modules in a flake:
}
```
# Sponsor
My current device is a bit outdated and doesn't support certain features like HDR or VRR. If you'd like to support this project, here's how you can help. Thanks!
![Screenshot_2025-10-13-20-06-49-26_ee1cec40dcf6eb3](https://github.com/user-attachments/assets/240a0727-9eb5-4212-a84c-10fa9f093147)
# Packaging mango
To package mango for other distributions, you can check the reference setup for:

View File

@@ -1,5 +1,5 @@
project('mango', ['c', 'cpp'],
version : '0.10.6',
version : '0.10.7',
)
subdir('protocols')

View File

@@ -86,7 +86,7 @@ static void noop_description(void *data, struct wl_output *wl_output,
const char *description) {}
// 将 n 转换为 9 位二进制字符串,结果存入 buf至少长度 10
void bin_str_9bits(char *buf, unsigned int n) {
void bin_str_9bits(char *buf, uint32_t n) {
for (int i = 8; i >= 0; i--) {
*buf++ = ((n >> i) & 1) ? '1' : '0';
}
@@ -268,7 +268,7 @@ static void dwl_ipc_output_kb_layout(void *data,
static void
dwl_ipc_output_scalefactor(void *data,
struct zdwl_ipc_output_v2 *dwl_ipc_output,
const unsigned int scalefactor) {
const uint32_t scalefactor) {
if (!Aflag)
return;
char *output_name = data;

View File

@@ -1,4 +1,4 @@
void client_actual_size(Client *c, unsigned int *width, unsigned int *height) {
void client_actual_size(Client *c, uint32_t *width, uint32_t *height) {
*width = c->animation.current.width - c->bw;
*height = c->animation.current.height - c->bw;
@@ -183,8 +183,8 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
if (buffer_data->should_scale) {
unsigned int surface_width = surface->current.width;
unsigned int surface_height = surface->current.height;
uint32_t surface_width = surface->current.width;
uint32_t surface_height = surface->current.height;
surface_width = buffer_data->width_scale < 1
? surface_width
@@ -270,7 +270,7 @@ void client_draw_shadow(Client *c) {
? CORNER_LOCATION_NONE
: CORNER_LOCATION_ALL;
unsigned int bwoffset = c->bw != 0 && hit_no_border ? c->bw : 0;
uint32_t bwoffset = c->bw != 0 && hit_no_border ? c->bw : 0;
uint32_t width, height;
client_actual_size(c, &width, &height);
@@ -546,7 +546,7 @@ void client_apply_clip(Client *c, float factor) {
}
// 获取窗口动画实时位置矩形
unsigned int width, height;
uint32_t width, height;
client_actual_size(c, &width, &height);
// 计算出除了边框的窗口实际剪切大小
@@ -630,16 +630,15 @@ void fadeout_client_animation_next_tick(Client *c) {
int type = c->animation.action = c->animation.action;
double factor = find_animation_curve_at(animation_passed, type);
unsigned int width =
c->animation.initial.width +
uint32_t width = c->animation.initial.width +
(c->current.width - c->animation.initial.width) * factor;
unsigned int height =
uint32_t height =
c->animation.initial.height +
(c->current.height - c->animation.initial.height) * factor;
unsigned int x = c->animation.initial.x +
uint32_t x = c->animation.initial.x +
(c->current.x - c->animation.initial.x) * factor;
unsigned int y = c->animation.initial.y +
uint32_t y = c->animation.initial.y +
(c->current.y - c->animation.initial.y) * factor;
wlr_scene_node_set_position(&c->scene->node, x, y);
@@ -696,16 +695,15 @@ void client_animation_next_tick(Client *c) {
double sx = 0, sy = 0;
struct wlr_surface *surface = NULL;
unsigned int width =
c->animation.initial.width +
uint32_t width = c->animation.initial.width +
(c->current.width - c->animation.initial.width) * factor;
unsigned int height =
uint32_t height =
c->animation.initial.height +
(c->current.height - c->animation.initial.height) * factor;
unsigned int x = c->animation.initial.x +
uint32_t x = c->animation.initial.x +
(c->current.x - c->animation.initial.x) * factor;
unsigned int y = c->animation.initial.y +
uint32_t y = c->animation.initial.y +
(c->current.y - c->animation.initial.y) * factor;
wlr_scene_node_set_position(&c->scene->node, x, y);

View File

@@ -33,33 +33,33 @@ void init_baked_points(void) {
baked_points_focus =
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_focus));
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_move[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), MOVE);
}
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_open[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), OPEN);
}
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_tag[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), TAG);
}
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_close[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), CLOSE);
}
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_focus[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), FOCUS);
}
}
double find_animation_curve_at(double t, int type) {
unsigned int down = 0;
unsigned int up = BAKED_POINTS_COUNT - 1;
uint32_t down = 0;
uint32_t up = BAKED_POINTS_COUNT - 1;
unsigned int middle = (up + down) / 2;
uint32_t middle = (up + down) / 2;
struct dvec2 *baked_points;
if (type == MOVE) {
baked_points = baked_points_move;

View File

@@ -1,5 +1,4 @@
void layer_actual_size(LayerSurface *l, unsigned int *width,
unsigned int *height) {
void layer_actual_size(LayerSurface *l, uint32_t *width, uint32_t *height) {
struct wlr_box box;
if (l->animation.running) {
@@ -213,9 +212,8 @@ void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
struct wlr_surface *surface = scene_surface->surface;
unsigned int surface_width =
surface->current.width * buffer_data->width_scale;
unsigned int surface_height =
uint32_t surface_width = surface->current.width * buffer_data->width_scale;
uint32_t surface_height =
surface->current.height * buffer_data->height_scale;
if (surface_height > 0 && surface_width > 0) {
@@ -245,16 +243,15 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
int type = l->animation.action = l->animation.action;
double factor = find_animation_curve_at(animation_passed, type);
unsigned int width =
l->animation.initial.width +
uint32_t width = l->animation.initial.width +
(l->current.width - l->animation.initial.width) * factor;
unsigned int height =
uint32_t height =
l->animation.initial.height +
(l->current.height - l->animation.initial.height) * factor;
unsigned int x = l->animation.initial.x +
uint32_t x = l->animation.initial.x +
(l->current.x - l->animation.initial.x) * factor;
unsigned int y = l->animation.initial.y +
uint32_t y = l->animation.initial.y +
(l->current.y - l->animation.initial.y) * factor;
wlr_scene_node_set_position(&l->scene->node, x, y);
@@ -310,16 +307,15 @@ void layer_animation_next_tick(LayerSurface *l) {
int type = l->animation.action == NONE ? MOVE : l->animation.action;
double factor = find_animation_curve_at(animation_passed, type);
unsigned int width =
l->animation.initial.width +
uint32_t width = l->animation.initial.width +
(l->current.width - l->animation.initial.width) * factor;
unsigned int height =
uint32_t height =
l->animation.initial.height +
(l->current.height - l->animation.initial.height) * factor;
unsigned int x = l->animation.initial.x +
uint32_t x = l->animation.initial.x +
(l->current.x - l->animation.initial.x) * factor;
unsigned int y = l->animation.initial.y +
uint32_t y = l->animation.initial.y +
(l->current.y - l->animation.initial.y) * factor;
double opacity = MIN(fadein_begin_opacity +

View File

@@ -153,20 +153,6 @@ static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
*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) {
Client *p = NULL;
#ifdef XWAYLAND
@@ -526,16 +512,16 @@ static inline void client_set_size_bound(Client *c) {
if (!size_hints)
return;
if ((unsigned int)c->geom.width - 2 * c->bw < size_hints->min_width &&
if ((uint32_t)c->geom.width - 2 * c->bw < size_hints->min_width &&
size_hints->min_width > 0)
c->geom.width = size_hints->min_width + 2 * c->bw;
if ((unsigned int)c->geom.height - 2 * c->bw < size_hints->min_height &&
if ((uint32_t)c->geom.height - 2 * c->bw < size_hints->min_height &&
size_hints->min_height > 0)
c->geom.height = size_hints->min_height + 2 * c->bw;
if ((unsigned int)c->geom.width - 2 * c->bw > size_hints->max_width &&
if ((uint32_t)c->geom.width - 2 * c->bw > size_hints->max_width &&
size_hints->max_width > 0)
c->geom.width = size_hints->max_width + 2 * c->bw;
if ((unsigned int)c->geom.height - 2 * c->bw > size_hints->max_height &&
if ((uint32_t)c->geom.height - 2 * c->bw > size_hints->max_height &&
size_hints->max_height > 0)
c->geom.height = size_hints->max_height + 2 * c->bw;
return;
@@ -544,19 +530,19 @@ static inline void client_set_size_bound(Client *c) {
toplevel = c->surface.xdg->toplevel;
state = toplevel->current;
if ((unsigned int)c->geom.width - 2 * c->bw < state.min_width &&
if ((uint32_t)c->geom.width - 2 * c->bw < state.min_width &&
state.min_width > 0) {
c->geom.width = state.min_width + 2 * c->bw;
}
if ((unsigned int)c->geom.height - 2 * c->bw < state.min_height &&
if ((uint32_t)c->geom.height - 2 * c->bw < state.min_height &&
state.min_height > 0) {
c->geom.height = state.min_height + 2 * c->bw;
}
if ((unsigned int)c->geom.width - 2 * c->bw > state.max_width &&
if ((uint32_t)c->geom.width - 2 * c->bw > state.max_width &&
state.max_width > 0) {
c->geom.width = state.max_width + 2 * c->bw;
}
if ((unsigned int)c->geom.height - 2 * c->bw > state.max_height &&
if ((uint32_t)c->geom.height - 2 * c->bw > state.max_height &&
state.max_height > 0) {
c->geom.height = state.max_height + 2 * c->bw;
}

View File

@@ -82,14 +82,13 @@ void wl_list_append(struct wl_list *list, struct wl_list *object) {
wl_list_insert(list->prev, object);
}
unsigned int get_now_in_ms(void) {
uint32_t get_now_in_ms(void) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return timespec_to_ms(&now);
}
unsigned int timespec_to_ms(struct timespec *ts) {
return (unsigned int)ts->tv_sec * 1000 +
(unsigned int)ts->tv_nsec / 1000000;
uint32_t timespec_to_ms(struct timespec *ts) {
return (uint32_t)ts->tv_sec * 1000 + (uint32_t)ts->tv_nsec / 1000000;
}

View File

@@ -6,5 +6,5 @@ void *ecalloc(size_t nmemb, size_t size);
int fd_set_nonblock(int fd);
int regex_match(const char *pattern_mb, const char *str_mb);
void wl_list_append(struct wl_list *list, struct wl_list *object);
unsigned int get_now_in_ms(void);
unsigned int timespec_to_ms(struct timespec *ts);
uint32_t get_now_in_ms(void);
uint32_t timespec_to_ms(struct timespec *ts);

View File

@@ -1,4 +1,5 @@
#include <ctype.h>
#include <libgen.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
@@ -42,6 +43,7 @@ typedef struct {
bool isdefaultmode;
bool islockapply;
bool isreleaseapply;
bool ispassapply;
} KeyBinding;
typedef struct {
@@ -52,7 +54,7 @@ typedef struct {
typedef struct {
const char *id;
const char *title;
unsigned int tags;
uint32_t tags;
int isfloating;
int isfullscreen;
float scroller_proportion;
@@ -124,29 +126,29 @@ KeyBinding default_key_bindings[] = {CHVT(1), CHVT(2), CHVT(3), CHVT(4),
CHVT(9), CHVT(10), CHVT(11), CHVT(12)};
typedef struct {
unsigned int mod;
unsigned int button;
uint32_t mod;
uint32_t button;
int (*func)(const Arg *);
Arg arg;
} MouseBinding;
typedef struct {
unsigned int mod;
unsigned int dir;
uint32_t mod;
uint32_t dir;
int (*func)(const Arg *);
Arg arg;
} AxisBinding;
typedef struct {
unsigned int fold;
uint32_t fold;
int (*func)(const Arg *);
Arg arg;
} SwitchBinding;
typedef struct {
unsigned int mod;
unsigned int motion;
unsigned int fingers_count;
uint32_t mod;
uint32_t motion;
uint32_t fingers_count;
int (*func)(const Arg *);
Arg arg;
} GestureBinding;
@@ -211,7 +213,7 @@ typedef struct {
int snap_distance;
int enable_floating_snap;
int drag_tile_to_tile;
unsigned int swipe_min_threshold;
uint32_t swipe_min_threshold;
float focused_opacity;
float unfocused_opacity;
float *scroller_proportion_preset;
@@ -220,21 +222,21 @@ typedef struct {
char **circle_layout;
int circle_layout_count;
unsigned int new_is_master;
uint32_t new_is_master;
float default_mfact;
unsigned int default_nmaster;
uint32_t default_nmaster;
int center_master_overspread;
int center_when_single_stack;
unsigned int hotarea_size;
unsigned int enable_hotarea;
unsigned int ov_tab_mode;
uint32_t hotarea_size;
uint32_t enable_hotarea;
uint32_t ov_tab_mode;
int overviewgappi;
int overviewgappo;
unsigned int cursor_hide_timeout;
uint32_t cursor_hide_timeout;
unsigned int axis_bind_apply_timeout;
unsigned int focus_on_activate;
uint32_t axis_bind_apply_timeout;
uint32_t focus_on_activate;
int inhibit_regardless_of_visibility;
int sloppyfocus;
int warpcursor;
@@ -242,7 +244,7 @@ typedef struct {
/* keyboard */
int repeat_rate;
int repeat_delay;
unsigned int numlockon;
uint32_t numlockon;
/* Trackpad */
int disable_trackpad;
@@ -254,13 +256,13 @@ typedef struct {
int disable_while_typing;
int left_handed;
int middle_button_emulation;
unsigned int accel_profile;
uint32_t accel_profile;
double accel_speed;
unsigned int scroll_method;
unsigned int scroll_button;
unsigned int click_method;
unsigned int send_events_mode;
unsigned int button_map;
uint32_t scroll_method;
uint32_t scroll_button;
uint32_t click_method;
uint32_t send_events_mode;
uint32_t button_map;
int blur;
int blur_layer;
@@ -270,18 +272,18 @@ typedef struct {
int shadows;
int shadow_only_floating;
int layer_shadows;
unsigned int shadows_size;
uint32_t shadows_size;
float shadows_blur;
int shadows_position_x;
int shadows_position_y;
float shadowscolor[4];
int smartgaps;
unsigned int gappih;
unsigned int gappiv;
unsigned int gappoh;
unsigned int gappov;
unsigned int borderpx;
uint32_t gappih;
uint32_t gappiv;
uint32_t gappoh;
uint32_t gappov;
uint32_t borderpx;
float scratchpad_width_ratio;
float scratchpad_height_ratio;
float rootcolor[4];
@@ -332,7 +334,7 @@ typedef struct {
int exec_once_count;
char *cursor_theme;
unsigned int cursor_size;
uint32_t cursor_size;
int single_scratchpad;
int xwayland_persistence;
@@ -443,6 +445,9 @@ void parse_bind_flags(const char *str, KeyBinding *kb) {
case 'r':
kb->isreleaseapply = true;
break;
case 'p':
kb->ispassapply = true;
break;
default:
// 忽略其他字符或可根据需要处理错误
break;
@@ -790,7 +795,7 @@ void convert_hex_to_rgba(float *color, unsigned long int hex) {
color[3] = (hex & 0xFF) / 255.0f;
}
unsigned int parse_num_type(char *str) {
uint32_t parse_num_type(char *str) {
switch (str[0]) {
case '-':
return NUM_TYPE_MINUS;
@@ -994,7 +999,31 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
(*arg).i = atoi(arg_value2);
} else if (strcmp(func_name, "view") == 0) {
func = bind_to_view;
(*arg).ui = 1 << (atoi(arg_value) - 1);
uint32_t mask = 0;
char *token;
char *arg_copy = strdup(arg_value);
if (arg_copy != NULL) {
char *saveptr = NULL;
token = strtok_r(arg_copy, "|", &saveptr);
while (token != NULL) {
int num = atoi(token);
if (num > 0 && num <= LENGTH(tags)) {
mask |= (1 << (num - 1));
}
token = strtok_r(NULL, "|", &saveptr);
}
free(arg_copy);
}
if (mask) {
(*arg).ui = mask;
} else {
(*arg).ui = atoi(arg_value);
}
(*arg).i = atoi(arg_value2);
} else if (strcmp(func_name, "viewcrossmon") == 0) {
func = viewcrossmon;
@@ -1939,7 +1968,7 @@ void parse_option(Config *config, char *key, char *value) {
config->exec_once_count++;
} else if (regex_match("^bind[s|l|r]*$", key)) {
} else if (regex_match("^bind[s|l|r|p]*$", key)) {
config->key_bindings =
realloc(config->key_bindings,
(config->key_bindings_count + 1) * sizeof(KeyBinding));
@@ -2290,10 +2319,12 @@ void parse_config_file(Config *config, const char *file_path) {
if (file_path[0] == '.' && file_path[1] == '/') {
// Relative path
const char *mangoconfig = getenv("MANGOCONFIG");
if (mangoconfig && mangoconfig[0] != '\0') {
snprintf(full_path, sizeof(full_path), "%s/%s", mangoconfig,
if (cli_config_path) {
char *config_path = strdup(cli_config_path);
char *config_dir = dirname(config_path);
snprintf(full_path, sizeof(full_path), "%s/%s", config_dir,
file_path + 1);
free(config_path);
} else {
const char *home = getenv("HOME");
if (!home) {
@@ -3023,11 +3054,9 @@ void parse_config(void) {
create_config_keymap();
// 获取 MANGOCONFIG 环境变量
const char *mangoconfig = getenv("MANGOCONFIG");
// 如果 MANGOCONFIG 环境变量不存在或为空,则使用 HOME 环境变量
if (!mangoconfig || mangoconfig[0] == '\0') {
if (cli_config_path) {
snprintf(filename, sizeof(filename), "%s", cli_config_path);
} else {
// 获取当前用户家目录
const char *homedir = getenv("HOME");
if (!homedir) {
@@ -3044,9 +3073,6 @@ void parse_config(void) {
snprintf(filename, sizeof(filename), "%s/mango/config.conf",
SYSCONFDIR);
}
} else {
// 使用 MANGOCONFIG 环境变量作为配置文件夹路径
snprintf(filename, sizeof(filename), "%s/config.conf", mangoconfig);
}
set_value_default();

View File

@@ -33,27 +33,27 @@ double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
double animation_curve_focus[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
/* appearance */
unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
unsigned int focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦
unsigned int new_is_master = 1; // 新窗口是否插在头部
uint32_t axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
uint32_t focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦
uint32_t new_is_master = 1; // 新窗口是否插在头部
double default_mfact = 0.55f; // master 窗口比例
unsigned int default_nmaster = 1; // 默认master数量
uint32_t default_nmaster = 1; // 默认master数量
int center_master_overspread = 0; // 中心master时是否铺满
int center_when_single_stack = 1; // 单个stack时是否居中
/* logging */
int log_level = WLR_ERROR;
unsigned int numlockon = 0; // 是否打开右边小键盘
unsigned int capslock = 0; // 是否启用快捷键
uint32_t numlockon = 0; // 是否打开右边小键盘
uint32_t capslock = 0; // 是否启用快捷键
unsigned int ov_tab_mode = 0; // alt tab切换模式
unsigned int hotarea_size = 10; // 热区大小,10x10
unsigned int enable_hotarea = 1; // 是否启用鼠标热区
uint32_t ov_tab_mode = 0; // alt tab切换模式
uint32_t hotarea_size = 10; // 热区大小,10x10
uint32_t enable_hotarea = 1; // 是否启用鼠标热区
int smartgaps = 0; /* 1 means no outer gap when there is only one window */
int sloppyfocus = 1; /* focus follows mouse */
unsigned int gappih = 5; /* horiz inner gap between windows */
unsigned int gappiv = 5; /* vert inner gap between windows */
unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
uint32_t gappih = 5; /* horiz inner gap between windows */
uint32_t gappiv = 5; /* vert inner gap between windows */
uint32_t gappoh = 10; /* horiz outer gap between windows and screen edge */
uint32_t gappov = 10; /* vert outer gap between windows and screen edge */
float scratchpad_width_ratio = 0.8;
float scratchpad_height_ratio = 0.9;
@@ -74,15 +74,15 @@ int no_radius_when_single = 0;
int snap_distance = 30;
int enable_floating_snap = 0;
int drag_tile_to_tile = 0;
unsigned int cursor_size = 24;
unsigned int cursor_hide_timeout = 0;
uint32_t cursor_size = 24;
uint32_t cursor_hide_timeout = 0;
unsigned int swipe_min_threshold = 1;
uint32_t swipe_min_threshold = 1;
int inhibit_regardless_of_visibility =
0; /* 1 means idle inhibitors will disable idle tracking even if it's
surface isn't visible */
unsigned int borderpx = 4; /* border pixel of windows */
uint32_t borderpx = 4; /* border pixel of windows */
float rootcolor[] = COLOR(0x323232ff);
float bordercolor[] = COLOR(0x444444ff);
float focuscolor[] = COLOR(0xc66b25ff);
@@ -167,7 +167,7 @@ LIBINPUT_CONFIG_SCROLL_EDGE
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN
*/
enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
unsigned int scroll_button = 274;
uint32_t scroll_button = 274;
/* You can choose between:
LIBINPUT_CONFIG_CLICK_METHOD_NONE
@@ -225,7 +225,7 @@ float blur_params_saturation = 1.2;
int shadows = 0;
int shadow_only_floating = 1;
int layer_shadows = 0;
unsigned int shadows_size = 10;
uint32_t shadows_size = 10;
double shadows_blur = 15;
int shadows_position_x = 0;
int shadows_position_y = 0;

View File

@@ -1,6 +1,6 @@
int bind_to_view(const Arg *arg) {
unsigned int target = arg->ui;
uint32_t target = arg->ui;
if (view_current_to_back && selmon->pertag->curtag &&
(target & TAGMASK) == (selmon->tagset[selmon->seltags])) {
@@ -153,7 +153,7 @@ int focuslast(const Arg *arg) {
Client *c = NULL;
Client *tc = NULL;
bool begin = false;
unsigned int target = 0;
uint32_t target = 0;
wl_list_for_each(c, &fstack, flink) {
if (c->iskilling || c->isminimized || c->isunglobal ||
@@ -194,7 +194,7 @@ int toggle_trackpad_enable(const Arg *arg) {
}
int focusmon(const Arg *arg) {
Client *c = NULL, *old_selmon_sel = NULL;
Client *c = NULL;
Monitor *m = NULL;
if (arg->i != UNDIR) {
@@ -215,7 +215,6 @@ int focusmon(const Arg *arg) {
if (!m || !m->wlr_output->enabled || m == selmon)
return 0;
old_selmon_sel = selmon->sel;
selmon = m;
if (warpcursor) {
warp_cursor_to_selmon(selmon);
@@ -225,12 +224,10 @@ int focusmon(const Arg *arg) {
selmon->sel = NULL;
wlr_seat_pointer_notify_clear_focus(seat);
wlr_seat_keyboard_notify_clear_focus(seat);
focusclient(NULL, 0);
} else
focusclient(c, 1);
if (old_selmon_sel) {
client_set_unfocused_opacity_animation(old_selmon_sel);
}
return 0;
}
@@ -576,7 +573,7 @@ int set_proportion(const Arg *arg) {
return 0;
if (selmon->sel) {
unsigned int max_client_width =
uint32_t max_client_width =
selmon->w.width - 2 * scroller_structs - gappih;
selmon->sel->scroller_proportion = arg->f;
selmon->sel->geom.width = max_client_width * arg->f;
@@ -761,15 +758,27 @@ int centerwin(const Arg *arg) {
Client *c = NULL;
c = selmon->sel;
if (!c || c->isfullscreen)
if (!c || c->isfullscreen || c->ismaximizescreen)
return 0;
if (!c->isfloating)
setfloating(c, true);
if (c->isfloating) {
c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0);
c->iscustomsize = 1;
resize(c, c->float_geom, 1);
return 0;
}
if (!is_scroller_layout(selmon))
return 0;
if (selmon->pertag->ltidxs[selmon->pertag->curtag]->id == SCROLLER) {
c->geom.x = selmon->w.x + (selmon->w.width - c->geom.width) / 2;
} else {
c->geom.y = selmon->w.y + (selmon->w.height - c->geom.height) / 2;
}
arrange(selmon, false);
return 0;
}
int spawn_shell(const Arg *arg) {
@@ -882,9 +891,9 @@ int switch_keyboard_layout(const Arg *arg) {
xkb_layout_index_t next = (current + 1) % num_layouts;
// 6. 应用新 keymap
unsigned int depressed = keyboard->modifiers.depressed;
unsigned int latched = keyboard->modifiers.latched;
unsigned int locked = keyboard->modifiers.locked;
uint32_t depressed = keyboard->modifiers.depressed;
uint32_t latched = keyboard->modifiers.latched;
uint32_t locked = keyboard->modifiers.locked;
wlr_keyboard_set_keymap(keyboard, keyboard->keymap);
wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, next);
@@ -919,7 +928,7 @@ int switch_layout(const Arg *arg) {
int jk, ji;
char *target_layout_name = NULL;
unsigned int len;
uint32_t len;
if (config.circle_layout_count != 0) {
for (jk = 0; jk < config.circle_layout_count; jk++) {
@@ -1004,7 +1013,7 @@ int switch_proportion_preset(const Arg *arg) {
target_proportion = config.scroller_proportion_preset[0];
}
unsigned int max_client_width =
uint32_t max_client_width =
selmon->w.width - 2 * scroller_structs - gappih;
selmon->sel->scroller_proportion = target_proportion;
selmon->sel->geom.width = max_client_width * target_proportion;
@@ -1046,8 +1055,8 @@ int tagmon(const Arg *arg) {
if (!m || !m->wlr_output->enabled)
return 0;
unsigned int newtags = arg->ui ? arg->ui : arg->i2 ? c->tags : 0;
unsigned int target;
uint32_t newtags = arg->ui ? arg->ui : arg->i2 ? c->tags : 0;
uint32_t target;
if (c->mon == m) {
view(&(Arg){.ui = newtags}, true);
@@ -1287,7 +1296,7 @@ int toggleoverlay(const Arg *arg) {
}
int toggletag(const Arg *arg) {
unsigned int newtags;
uint32_t newtags;
Client *sel = focustop(selmon);
if (!sel)
return 0;
@@ -1310,8 +1319,8 @@ int toggletag(const Arg *arg) {
}
int toggleview(const Arg *arg) {
unsigned int newtagset;
unsigned int target;
uint32_t newtagset;
uint32_t target;
target = arg->ui == 0 ? ~0 & TAGMASK : arg->ui;
@@ -1328,7 +1337,7 @@ int toggleview(const Arg *arg) {
}
int viewtoleft(const Arg *arg) {
unsigned int target = selmon->tagset[selmon->seltags];
uint32_t target = selmon->tagset[selmon->seltags];
if (selmon->isoverview || selmon->pertag->curtag == 0) {
return 0;
@@ -1351,7 +1360,7 @@ int viewtoright(const Arg *arg) {
if (selmon->isoverview || selmon->pertag->curtag == 0) {
return 0;
}
unsigned int target = selmon->tagset[selmon->seltags];
uint32_t target = selmon->tagset[selmon->seltags];
target <<= 1;
if (!selmon || (target) == selmon->tagset[selmon->seltags])
@@ -1365,9 +1374,8 @@ int viewtoright(const Arg *arg) {
}
int viewtoleft_have_client(const Arg *arg) {
unsigned int n;
unsigned int current =
get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
uint32_t n;
uint32_t current = get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
bool found = false;
if (selmon->isoverview) {
@@ -1390,9 +1398,8 @@ int viewtoleft_have_client(const Arg *arg) {
}
int viewtoright_have_client(const Arg *arg) {
unsigned int n;
unsigned int current =
get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
uint32_t n;
uint32_t current = get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
bool found = false;
if (selmon->isoverview) {
@@ -1429,7 +1436,7 @@ int tagcrossmon(const Arg *arg) {
}
int comboview(const Arg *arg) {
unsigned int newtags = arg->ui & TAGMASK;
uint32_t newtags = arg->ui & TAGMASK;
if (!newtags || !selmon)
return 0;
@@ -1507,8 +1514,8 @@ int toggleoverview(const Arg *arg) {
}
selmon->isoverview ^= 1;
unsigned int target;
unsigned int visible_client_number = 0;
uint32_t target;
uint32_t visible_client_number = 0;
if (selmon->isoverview) {
wl_list_for_each(c, &clients, link) if (c && c->mon == selmon &&

View File

@@ -1,12 +1,11 @@
#include "dwl-ipc-unstable-v2-protocol.h"
static void dwl_ipc_manager_bind(struct wl_client *client, void *data,
unsigned int version, unsigned int id);
uint32_t version, uint32_t id);
static void dwl_ipc_manager_destroy(struct wl_resource *resource);
static void dwl_ipc_manager_get_output(struct wl_client *client,
struct wl_resource *resource,
unsigned int id,
struct wl_resource *output);
uint32_t id, struct wl_resource *output);
static void dwl_ipc_manager_release(struct wl_client *client,
struct wl_resource *resource);
static void dwl_ipc_output_destroy(struct wl_resource *resource);
@@ -14,15 +13,14 @@ static void dwl_ipc_output_printstatus(Monitor *monitor);
static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output);
static void dwl_ipc_output_set_client_tags(struct wl_client *client,
struct wl_resource *resource,
unsigned int and_tags,
unsigned int xor_tags);
uint32_t and_tags,
uint32_t xor_tags);
static void dwl_ipc_output_set_layout(struct wl_client *client,
struct wl_resource *resource,
unsigned int index);
uint32_t index);
static void dwl_ipc_output_set_tags(struct wl_client *client,
struct wl_resource *resource,
unsigned int tagmask,
unsigned int toggle_tagset);
uint32_t tagmask, uint32_t toggle_tagset);
static void dwl_ipc_output_quit(struct wl_client *client,
struct wl_resource *resource);
static void dwl_ipc_output_dispatch(struct wl_client *client,
@@ -46,7 +44,7 @@ static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {
.set_client_tags = dwl_ipc_output_set_client_tags};
void dwl_ipc_manager_bind(struct wl_client *client, void *data,
unsigned int version, unsigned int id) {
uint32_t version, uint32_t id) {
struct wl_resource *manager_resource =
wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id);
if (!manager_resource) {
@@ -59,7 +57,7 @@ void dwl_ipc_manager_bind(struct wl_client *client, void *data,
zdwl_ipc_manager_v2_send_tags(manager_resource, LENGTH(tags));
for (unsigned int i = 0; i < LENGTH(layouts); i++)
for (uint32_t i = 0; i < LENGTH(layouts); i++)
zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol);
}
@@ -68,7 +66,7 @@ void dwl_ipc_manager_destroy(struct wl_resource *resource) {
}
void dwl_ipc_manager_get_output(struct wl_client *client,
struct wl_resource *resource, unsigned int id,
struct wl_resource *resource, uint32_t id,
struct wl_resource *output) {
DwlIpcOutput *ipc_output;
struct wlr_output *op = wlr_output_from_resource(output);
@@ -101,12 +99,14 @@ static void dwl_ipc_output_destroy(struct wl_resource *resource) {
free(ipc_output);
}
// 修改IPC输出函数接受掩码参数
void dwl_ipc_output_printstatus(Monitor *monitor) {
DwlIpcOutput *ipc_output;
wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link)
dwl_ipc_output_printstatus_to(ipc_output);
}
// 修改主IPC输出函数根据掩码发送相应事件
void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
Monitor *monitor = ipc_output->mon;
Client *c = NULL, *focused = NULL;
@@ -216,12 +216,11 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
void dwl_ipc_output_set_client_tags(struct wl_client *client,
struct wl_resource *resource,
unsigned int and_tags,
unsigned int xor_tags) {
uint32_t and_tags, uint32_t xor_tags) {
DwlIpcOutput *ipc_output;
Monitor *monitor = NULL;
Client *selected_client = NULL;
unsigned int newtags = 0;
uint32_t newtags = 0;
ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output)
@@ -244,8 +243,7 @@ void dwl_ipc_output_set_client_tags(struct wl_client *client,
}
void dwl_ipc_output_set_layout(struct wl_client *client,
struct wl_resource *resource,
unsigned int index) {
struct wl_resource *resource, uint32_t index) {
DwlIpcOutput *ipc_output;
Monitor *monitor = NULL;
@@ -264,11 +262,11 @@ void dwl_ipc_output_set_layout(struct wl_client *client,
}
void dwl_ipc_output_set_tags(struct wl_client *client,
struct wl_resource *resource, unsigned int tagmask,
unsigned int toggle_tagset) {
struct wl_resource *resource, uint32_t tagmask,
uint32_t toggle_tagset) {
DwlIpcOutput *ipc_output;
Monitor *monitor = NULL;
unsigned int newtags = tagmask & TAGMASK;
uint32_t newtags = tagmask & TAGMASK;
ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output)

View File

@@ -8,7 +8,7 @@ typedef struct Monitor Monitor;
struct workspace {
struct wl_list link; // Link in global workspaces list
unsigned int tag; // Numeric identifier (1-9, 0=overview)
uint32_t tag; // Numeric identifier (1-9, 0=overview)
Monitor *m; // Associated monitor
struct wlr_ext_workspace_handle_v1 *ext_workspace; // Protocol object
/* Event listeners */
@@ -22,7 +22,7 @@ struct wlr_ext_workspace_manager_v1 *ext_manager;
struct wl_list workspaces;
void goto_workspace(struct workspace *target) {
unsigned int tag;
uint32_t tag;
tag = 1 << (target->tag - 1);
if (target->tag == 0) {
toggleoverview(&(Arg){.i = -1});
@@ -33,7 +33,7 @@ void goto_workspace(struct workspace *target) {
}
void toggle_workspace(struct workspace *target) {
unsigned int tag;
uint32_t tag;
tag = 1 << (target->tag - 1);
if (target->tag == 0) {
toggleview(&(Arg){.i = -1});
@@ -69,7 +69,7 @@ static void handle_ext_workspace_deactivate(struct wl_listener *listener,
wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag);
}
static const char *get_name_from_tag(unsigned int tag) {
static const char *get_name_from_tag(uint32_t tag) {
static const char *names[] = {"overview", "1", "2", "3", "4",
"5", "6", "7", "8", "9"};
return (tag < sizeof(names) / sizeof(names[0])) ? names[tag] : NULL;
@@ -92,7 +92,7 @@ void cleanup_workspaces_by_monitor(Monitor *m) {
}
}
static void remove_workspace_by_tag(unsigned int tag, Monitor *m) {
static void remove_workspace_by_tag(uint32_t tag, Monitor *m) {
struct workspace *workspace, *tmp;
wl_list_for_each_safe(workspace, tmp, &workspaces, link) {
if (workspace->tag == tag && workspace->m == m) {
@@ -127,7 +127,7 @@ static void add_workspace_by_tag(int tag, Monitor *m) {
void dwl_ext_workspace_printstatus(Monitor *m) {
struct workspace *w;
unsigned int tag_status = 0;
uint32_t tag_status = 0;
wl_list_for_each(w, &workspaces, link) {
if (w && w->m == m) {

View File

@@ -4,16 +4,11 @@ static struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_activate_request);
unsigned int target;
uint32_t target;
if (c && c->swallowing)
if (c->swallowing)
return;
if (c && !c->isminimized && c == selmon->sel) {
set_minimized(c);
return;
}
if (c->isminimized) {
c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0;
@@ -27,29 +22,82 @@ void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
target = get_tags_first_tag(c->tags);
view_in_mon(&(Arg){.ui = target}, true, c->mon, true);
focusclient(c, 1);
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, true);
}
void handle_foreign_maximize_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_maximize_request);
struct wlr_foreign_toplevel_handle_v1_maximized_event *event = data;
if (c->swallowing)
return;
if (c->ismaximizescreen && !event->maximized) {
setmaximizescreen(c, 0);
return;
}
if (!c->ismaximizescreen && event->maximized) {
setmaximizescreen(c, 1);
return;
}
}
void handle_foreign_minimize_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_minimize_request);
struct wlr_foreign_toplevel_handle_v1_minimized_event *event = data;
if (c->swallowing)
return;
if (!c->isminimized && event->minimized) {
set_minimized(c);
return;
}
if (c->isminimized && !event->minimized) {
c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0;
c->is_scratchpad_show = 0;
setborder_color(c);
show_hide_client(c);
arrange(c->mon, true);
return;
}
}
void handle_foreign_fullscreen_request(struct wl_listener *listener,
void *data) {
Client *c = wl_container_of(listener, c, foreign_fullscreen_request);
struct wlr_foreign_toplevel_handle_v1_fullscreen_event *event = data;
if (c->swallowing)
return;
if (c->isfullscreen && !event->fullscreen) {
setfullscreen(c, 0);
return;
}
if (!c->isfullscreen && event->fullscreen) {
setfullscreen(c, 1);
return;
}
}
void handle_foreign_close_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_close_request);
if (c) {
pending_kill_client(c);
}
}
void handle_foreign_destroy(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_destroy);
if (c) {
wl_list_remove(&c->foreign_activate_request.link);
wl_list_remove(&c->foreign_minimize_request.link);
wl_list_remove(&c->foreign_maximize_request.link);
wl_list_remove(&c->foreign_fullscreen_request.link);
wl_list_remove(&c->foreign_close_request.link);
wl_list_remove(&c->foreign_destroy.link);
}
}
void remove_foreign_topleve(Client *c) {
@@ -67,6 +115,10 @@ void add_foreign_toplevel(Client *c) {
if (c->foreign_toplevel) {
LISTEN(&(c->foreign_toplevel->events.request_activate),
&c->foreign_activate_request, handle_foreign_activate_request);
LISTEN(&(c->foreign_toplevel->events.request_minimize),
&c->foreign_minimize_request, handle_foreign_minimize_request);
LISTEN(&(c->foreign_toplevel->events.request_maximize),
&c->foreign_maximize_request, handle_foreign_maximize_request);
LISTEN(&(c->foreign_toplevel->events.request_fullscreen),
&c->foreign_fullscreen_request,
handle_foreign_fullscreen_request);

View File

@@ -13,7 +13,10 @@ static void handle_controller_set_hint(struct wl_listener *listener,
void *data) {
struct tearing_controller *controller =
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) {
/*
* tearing_control->current is actually an enum:

View File

@@ -41,10 +41,21 @@ Client *get_client_by_id_or_title(const char *arg_id, const char *arg_title) {
continue;
}
if (!(appid = client_get_appid(c)))
if (c->swallowedby) {
appid = client_get_appid(c->swallowedby);
title = client_get_title(c->swallowedby);
} else {
appid = client_get_appid(c);
title = client_get_title(c);
}
if (!appid) {
appid = broken;
if (!(title = client_get_title(c)))
}
if (!title) {
title = broken;
}
if (arg_id && strncmp(arg_id, "none", 4) == 0)
arg_id = NULL;
@@ -70,7 +81,7 @@ setclient_coordinate_center(Client *c, struct wlr_box geom, int offsetx,
int len = 0;
Monitor *m = c->mon ? c->mon : selmon;
unsigned int cbw = check_hit_no_border(c) ? c->bw : 0;
uint32_t cbw = check_hit_no_border(c) ? c->bw : 0;
if (!c->no_force_center) {
tempbox.x = m->w.x + (m->w.width - geom.width) / 2;
@@ -128,8 +139,9 @@ Client *center_tiled_select(Monitor *m) {
int dirx, diry;
long int distance;
wl_list_for_each(c, &clients, link) {
if (c && VISIBLEON(c, m) && ISTILED(c) && client_surface(c)->mapped &&
!c->isfloating && !client_is_unmanaged(c)) {
if (c && VISIBLEON(c, m) && ISSCROLLTILED(c) &&
client_surface(c)->mapped && !c->isfloating &&
!client_is_unmanaged(c)) {
dirx = c->geom.x + c->geom.width / 2 - (m->w.x + m->w.width / 2);
diry = c->geom.y + c->geom.height / 2 - (m->w.y + m->w.height / 2);
distance = dirx * dirx + diry * diry;
@@ -182,7 +194,9 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
int sel_x = tc->geom.x;
int sel_y = tc->geom.y;
long long int distance = LLONG_MAX;
long long int same_monitor_distance = LLONG_MAX;
Client *tempFocusClients = NULL;
Client *tempSameMonitorFocusClients = NULL;
switch (arg->i) {
case UP:
@@ -213,6 +227,11 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
}
}
}
@@ -245,6 +264,11 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
}
}
}
@@ -277,6 +301,11 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
}
}
}
@@ -309,6 +338,11 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
}
}
}
@@ -316,7 +350,11 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
}
free(tempClients); // 释放内存
if (tempSameMonitorFocusClients) {
return tempSameMonitorFocusClients;
} else {
return tempFocusClients;
}
}
Client *direction_select(const Arg *arg) {

View File

@@ -1,5 +1,5 @@
pid_t getparentprocess(pid_t p) {
unsigned int v = 0;
uint32_t v = 0;
FILE *f;
char buf[256];
@@ -26,24 +26,6 @@ int isdescprocess(pid_t p, pid_t c) {
return (int)c;
}
char *get_autostart_path(char *autostart_path, unsigned int buf_size) {
const char *mangoconfig = getenv("MANGOCONFIG");
if (mangoconfig && mangoconfig[0] != '\0') {
snprintf(autostart_path, buf_size, "%s/autostart.sh", mangoconfig);
} else {
const char *homedir = getenv("HOME");
if (!homedir) {
fprintf(stderr, "Error: HOME environment variable not set.\n");
return NULL;
}
snprintf(autostart_path, buf_size, "%s/.config/mango/autostart.sh",
homedir);
}
return autostart_path;
}
void get_layout_abbr(char *abbr, const char *full_name) {
// 清空输出缓冲区
abbr[0] = '\0';
@@ -60,10 +42,10 @@ void get_layout_abbr(char *abbr, const char *full_name) {
const char *open = strrchr(full_name, '(');
const char *close = strrchr(full_name, ')');
if (open && close && close > open) {
unsigned int len = close - open - 1;
uint32_t len = close - open - 1;
if (len > 0 && len <= 4) {
// 提取并转换为小写
for (unsigned int j = 0; j < len; j++) {
for (uint32_t j = 0; j < len; j++) {
abbr[j] = tolower(open[j + 1]);
}
abbr[len] = '\0';
@@ -72,8 +54,8 @@ void get_layout_abbr(char *abbr, const char *full_name) {
}
// 3. 提取前2-3个字母并转换为小写
unsigned int j = 0;
for (unsigned int i = 0; full_name[i] != '\0' && j < 3; i++) {
uint32_t j = 0;
for (uint32_t i = 0; full_name[i] != '\0' && j < 3; i++) {
if (isalpha(full_name[i])) {
abbr[j++] = tolower(full_name[i]);
}

View File

@@ -39,9 +39,9 @@ bool is_row_layout(Monitor *m) {
return false;
}
unsigned int get_tag_status(unsigned int tag, Monitor *m) {
uint32_t get_tag_status(uint32_t tag, Monitor *m) {
Client *c = NULL;
unsigned int status = 0;
uint32_t status = 0;
wl_list_for_each(c, &clients, link) {
if (c->mon == m && c->tags & 1 << (tag - 1) & TAGMASK) {
if (c->isurgent) {
@@ -54,8 +54,8 @@ unsigned int get_tag_status(unsigned int tag, Monitor *m) {
return status;
}
unsigned int get_tags_first_tag_num(unsigned int source_tags) {
unsigned int i, tag;
uint32_t get_tags_first_tag_num(uint32_t source_tags) {
uint32_t i, tag;
tag = 0;
if (!source_tags) {
@@ -76,8 +76,8 @@ unsigned int get_tags_first_tag_num(unsigned int source_tags) {
}
// 获取tags中最前面的tag的tagmask
unsigned int get_tags_first_tag(unsigned int source_tags) {
unsigned int i, tag;
uint32_t get_tags_first_tag(uint32_t source_tags) {
uint32_t i, tag;
tag = 0;
if (!source_tags) {

View File

@@ -19,7 +19,7 @@ void set_size_per(Monitor *m, Client *c) {
}
void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
int offsety, unsigned int time, int type) {
int offsety, uint32_t time, int type) {
Client *tc = NULL;
float delta_x, delta_y;
Client *next = NULL;
@@ -213,7 +213,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
}
void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
int offsety, unsigned int time, int type) {
int offsety, uint32_t time, int type) {
Client *tc = NULL;
float delta_x, delta_y;
Client *next = NULL;
@@ -370,7 +370,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
}
void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
unsigned int time, bool isvertical) {
uint32_t time, bool isvertical) {
float delta_x, delta_y;
float new_scroller_proportion;
@@ -474,7 +474,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
}
void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
unsigned int time) {
uint32_t time) {
if (!grabc || grabc->isfullscreen || grabc->ismaximizescreen)
return;
@@ -511,24 +511,22 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
int stack_num) {
Client *c = NULL;
int i = 0;
unsigned int stack_index = 0;
unsigned int nmasters = m->pertag->nmasters[m->pertag->curtag];
uint32_t stack_index = 0;
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
if (m->pertag->ltidxs[m->pertag->curtag]->id != CENTER_TILE) {
wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) {
if (total_master_inner_percent <= 0.0)
return;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
if (total_master_inner_percent > 0.0 && i < nmasters) {
c->ismaster = true;
c->stack_innder_per = stack_num ? 1.0f / stack_num : 1.0f;
c->master_inner_per =
c->master_inner_per / total_master_inner_percent;
} else {
c->ismaster = false;
c->master_inner_per = 1.0f / master_num;
c->master_inner_per =
master_num > 0 ? 1.0f / master_num : 1.0f;
c->stack_innder_per =
total_stack_hight_percent
? c->stack_innder_per / total_stack_hight_percent
@@ -540,10 +538,7 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
} else {
wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) {
if (total_master_inner_percent <= 0.0)
return;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
if (total_master_inner_percent > 0.0 && i < nmasters) {
c->ismaster = true;
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
c->stack_innder_per =
@@ -560,7 +555,8 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
stack_index = i - nmasters;
c->ismaster = false;
c->master_inner_per = 1.0f / master_num;
c->master_inner_per =
master_num > 0 ? 1.0f / master_num : 1.0f;
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
c->stack_innder_per =
total_right_stack_hight_percent
@@ -639,7 +635,7 @@ arrange(Monitor *m, bool want_animation) {
if (VISIBLEON(c, m)) {
if (ISTILED(c)) {
if (i < m->pertag->nmasters[m->pertag->curtag]) {
if (i < nmasters) {
master_num++;
total_master_inner_percent += c->master_inner_per;
} else {
@@ -688,4 +684,6 @@ arrange(Monitor *m, bool want_animation) {
motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL);
}
printstatus();
}

View File

@@ -1,9 +1,9 @@
// 网格布局窗口大小和位置计算
void grid(Monitor *m) {
unsigned int i, n;
unsigned int cx, cy, cw, ch;
unsigned int dx;
unsigned int cols, rows, overcols;
uint32_t i, n;
uint32_t cx, cy, cw, ch;
uint32_t dx;
uint32_t cols, rows, overcols;
Client *c = NULL;
n = 0;
int target_gappo = enablegaps ? m->isoverview ? overviewgappo : gappoh : 0;
@@ -23,10 +23,6 @@ void grid(Monitor *m) {
if (c->mon != m)
continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
@@ -49,10 +45,6 @@ void grid(Monitor *m) {
if (c->mon != m)
continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
if (i == 0) {
@@ -99,10 +91,7 @@ void grid(Monitor *m) {
if (c->mon != m)
continue;
c->bw =
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
cx = m->w.x + (i % cols) * (cw + target_gappi);
@@ -121,15 +110,15 @@ void grid(Monitor *m) {
}
void deck(Monitor *m) {
unsigned int mw, my;
uint32_t mw, my;
int i, n = 0;
Client *c = NULL;
Client *fc = NULL;
float mfact;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
@@ -192,9 +181,9 @@ void deck(Monitor *m) {
void horizontal_scroll_adjust_fullandmax(Client *c,
struct wlr_box *target_geom) {
Monitor *m = c->mon;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
@@ -223,7 +212,7 @@ void horizontal_scroll_adjust_fullandmax(Client *c,
// 滚动布局
void scroller(Monitor *m) {
unsigned int i, n, j;
uint32_t i, n, j;
float single_proportion = 1.0;
Client *c = NULL, *root_client = NULL;
@@ -231,9 +220,9 @@ void scroller(Monitor *m) {
struct wlr_box target_geom;
int focus_client_index = 0;
bool need_scroller = false;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
@@ -242,8 +231,7 @@ void scroller(Monitor *m) {
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
unsigned int max_client_width =
m->w.width - 2 * scroller_structs - cur_gappih;
uint32_t max_client_width = m->w.width - 2 * scroller_structs - cur_gappih;
n = m->visible_scroll_tiling_clients;
@@ -284,7 +272,7 @@ void scroller(Monitor *m) {
return;
}
if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating) {
if (m->sel && !client_is_unmanaged(m->sel) && ISSCROLLTILED(m->sel)) {
root_client = m->sel;
} else if (m->prevsel && ISSCROLLTILED(m->prevsel) &&
VISIBLEON(m->prevsel, m) && !client_is_unmanaged(m->prevsel)) {
@@ -584,7 +572,7 @@ void dual_scroller(Monitor *m) {
}
void center_tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
uint32_t i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -593,6 +581,8 @@ void center_tile(Monitor *m) {
n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num;
if (n == 0)
@@ -605,10 +595,10 @@ void center_tile(Monitor *m) {
}
// 间隙参数处理
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙
unsigned int cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙
unsigned int cur_gappov = enablegaps ? m->gappov : 0; // 外部垂直间隙
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙
uint32_t cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙
uint32_t cur_gappov = enablegaps ? m->gappov : 0; // 外部垂直间隙
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙
// 智能间隙处理
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
@@ -616,7 +606,7 @@ void center_tile(Monitor *m) {
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
unsigned int nmasters = m->pertag->nmasters[m->pertag->curtag];
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
: m->pertag->mfacts[m->pertag->curtag];
@@ -629,6 +619,19 @@ void center_tile(Monitor *m) {
// 判断是否需要主区域铺满
int should_overspread = center_master_overspread && (n <= nmasters);
uint32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_left_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num / 2 - 1));
float slave_left_surplus_ratio = 1.0;
uint32_t slave_right_surplus_height =
(m->w.height - 2 * cur_gappov -
cur_gappiv * ie * ((stack_num + 1) / 2 - 1));
float slave_right_surplus_ratio = 1.0;
if (n > nmasters || !should_overspread) {
// 计算主区域宽度(居中模式)
mw = nmasters ? (m->w.width - 2 * cur_gappoh - cur_gappih * ie) * mfact
@@ -673,9 +676,11 @@ void center_tile(Monitor *m) {
// 主区域窗口
r = MIN(n, nmasters) - i;
if (c->master_inner_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * (master_num - 1)) *
c->master_inner_per;
h = master_surplus_height * c->master_inner_per /
master_surplus_ratio;
master_surplus_height = master_surplus_height - h;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - my - cur_gappov -
@@ -695,7 +700,7 @@ void center_tile(Monitor *m) {
my += c->geom.height + cur_gappiv * ie;
} else {
// 堆叠区域窗口
unsigned int stack_index = i - nmasters;
uint32_t stack_index = i - nmasters;
if (n - nmasters == 1) {
// 单个堆叠窗口
@@ -737,9 +742,12 @@ void center_tile(Monitor *m) {
if ((stack_index % 2) ^ (n % 2 == 0)) {
// 右侧堆叠窗口
if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * ((stack_num + 1) / 2 - 1)) *
c->stack_innder_per;
h = slave_right_surplus_height * c->stack_innder_per /
slave_right_surplus_ratio;
slave_right_surplus_height =
slave_right_surplus_height - h;
slave_right_surplus_ratio =
slave_right_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - ety - cur_gappov -
@@ -763,9 +771,12 @@ void center_tile(Monitor *m) {
} else {
// 左侧堆叠窗口
if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * (stack_num / 2 - 1)) *
c->stack_innder_per;
h = slave_left_surplus_height * c->stack_innder_per /
slave_left_surplus_ratio;
slave_left_surplus_height =
slave_left_surplus_height - h;
slave_left_surplus_ratio =
slave_left_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - oty - cur_gappov -
@@ -793,7 +804,7 @@ void center_tile(Monitor *m) {
}
void tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty;
uint32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -802,15 +813,16 @@ void tile(Monitor *m) {
n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num;
if (n == 0)
return;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
@@ -834,15 +846,26 @@ void tile(Monitor *m) {
mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie;
i = 0;
my = ty = cur_gappov;
uint32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
float slave_surplus_ratio = 1.0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c))
continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
if (c->master_inner_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * (master_num - 1)) *
c->master_inner_per;
h = master_surplus_height * c->master_inner_per /
master_surplus_ratio;
master_surplus_height = master_surplus_height - h;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - my - cur_gappov -
@@ -862,9 +885,10 @@ void tile(Monitor *m) {
} else {
r = n - i;
if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * (stack_num - 1)) *
c->stack_innder_per;
h = slave_surplus_height * c->stack_innder_per /
slave_surplus_ratio;
slave_surplus_height = slave_surplus_height - h;
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - ty - cur_gappov -
@@ -890,7 +914,7 @@ void tile(Monitor *m) {
}
void right_tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty;
uint32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -899,15 +923,16 @@ void right_tile(Monitor *m) {
n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num;
if (n == 0)
return;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
@@ -931,15 +956,26 @@ void right_tile(Monitor *m) {
mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie;
i = 0;
my = ty = cur_gappov;
uint32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
float slave_surplus_ratio = 1.0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c))
continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
if (c->master_inner_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * (master_num - 1)) *
c->master_inner_per;
h = master_surplus_height * c->master_inner_per /
master_surplus_ratio;
master_surplus_height = master_surplus_height - h;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - my - cur_gappov -
@@ -960,9 +996,10 @@ void right_tile(Monitor *m) {
} else {
r = n - i;
if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov -
cur_gappiv * ie * (stack_num - 1)) *
c->stack_innder_per;
h = slave_surplus_height * c->stack_innder_per /
slave_surplus_ratio;
slave_surplus_height = slave_surplus_height - h;
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact;
} else {
h = (m->w.height - ty - cur_gappov -
@@ -992,8 +1029,8 @@ monocle(Monitor *m) {
Client *c = NULL;
struct wlr_box geom;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;

View File

@@ -1,5 +1,5 @@
void vertical_tile(Monitor *m) {
unsigned int i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
uint32_t i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -8,15 +8,16 @@ void vertical_tile(Monitor *m) {
n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num;
if (n == 0)
return;
unsigned int cur_gapih = enablegaps ? m->gappih : 0;
unsigned int cur_gapiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gapoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gapov = enablegaps ? m->gappov : 0;
uint32_t cur_gapih = enablegaps ? m->gappih : 0;
uint32_t cur_gapiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gapoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gapov = enablegaps ? m->gappov : 0;
cur_gapih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih;
cur_gapiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv;
@@ -40,15 +41,26 @@ void vertical_tile(Monitor *m) {
i = 0;
mx = tx = cur_gapih;
uint32_t master_surplus_width =
(m->w.width - 2 * cur_gapih - cur_gapih * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_width =
(m->w.width - 2 * cur_gapih - cur_gapih * ie * (stack_num - 1));
float slave_surplus_ratio = 1.0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c))
continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
if (c->master_inner_per > 0.0f) {
w = (m->w.width - 2 * cur_gapih -
cur_gapih * ie * (master_num - 1)) *
c->master_inner_per;
w = master_surplus_width * c->master_inner_per /
master_surplus_ratio;
master_surplus_width = master_surplus_width - w;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact;
} else {
w = (m->w.width - mx - cur_gapih - cur_gapih * ie * (r - 1)) /
@@ -67,9 +79,10 @@ void vertical_tile(Monitor *m) {
} else {
r = n - i;
if (c->stack_innder_per > 0.0f) {
w = (m->w.width - 2 * cur_gapih -
cur_gapih * ie * (stack_num - 1)) *
c->stack_innder_per;
w = slave_surplus_width * c->stack_innder_per /
slave_surplus_ratio;
slave_surplus_width = slave_surplus_width - w;
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact;
} else {
w = (m->w.width - tx - cur_gapih - cur_gapih * ie * (r - 1)) /
@@ -92,15 +105,15 @@ void vertical_tile(Monitor *m) {
}
void vertical_deck(Monitor *m) {
unsigned int mh, mx;
uint32_t mh, mx;
int i, n = 0;
Client *c = NULL;
Client *fc = NULL;
float mfact;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
@@ -157,9 +170,9 @@ void vertical_deck(Monitor *m) {
void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
Monitor *m = c->mon;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
@@ -188,7 +201,7 @@ void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
// 竖屏滚动布局
void vertical_scroller(Monitor *m) {
unsigned int i, n, j;
uint32_t i, n, j;
float single_proportion = 1.0;
Client *c = NULL, *root_client = NULL;
@@ -196,9 +209,9 @@ void vertical_scroller(Monitor *m) {
struct wlr_box target_geom;
int focus_client_index = 0;
bool need_scroller = false;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
@@ -207,7 +220,7 @@ void vertical_scroller(Monitor *m) {
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
unsigned int max_client_height =
uint32_t max_client_height =
m->w.height - 2 * scroller_structs - cur_gappiv;
n = m->visible_scroll_tiling_clients;
@@ -246,7 +259,7 @@ void vertical_scroller(Monitor *m) {
return;
}
if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating) {
if (m->sel && !client_is_unmanaged(m->sel) && ISSCROLLTILED(m->sel)) {
root_client = m->sel;
} else if (m->prevsel && ISSCROLLTILED(m->prevsel) &&
VISIBLEON(m->prevsel, m) && !client_is_unmanaged(m->prevsel)) {
@@ -341,10 +354,10 @@ void vertical_scroller(Monitor *m) {
}
void vertical_grid(Monitor *m) {
unsigned int i, n;
unsigned int cx, cy, cw, ch;
unsigned int dy;
unsigned int rows, cols, overrows;
uint32_t i, n;
uint32_t cx, cy, cw, ch;
uint32_t dy;
uint32_t rows, cols, overrows;
Client *c = NULL;
int target_gappo = enablegaps ? m->isoverview ? overviewgappo : gappov : 0;
int target_gappi = enablegaps ? m->isoverview ? overviewgappi : gappiv : 0;
@@ -363,10 +376,6 @@ void vertical_grid(Monitor *m) {
if (c->mon != m)
continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
@@ -390,10 +399,6 @@ void vertical_grid(Monitor *m) {
if (c->mon != m)
continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
if (i == 0) {
@@ -436,10 +441,6 @@ void vertical_grid(Monitor *m) {
if (c->mon != m)
continue;
c->bw =
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
cx = m->w.x + (i / rows) * (cw + target_gappi);

View File

@@ -181,6 +181,28 @@ enum seat_config_shortcuts_inhibit {
SHORTCUTS_INHIBIT_ENABLE,
};
// 事件掩码枚举
enum print_event_type {
PRINT_ACTIVE = 1 << 0,
PRINT_TAG = 1 << 1,
PRINT_LAYOUT = 1 << 2,
PRINT_TITLE = 1 << 3,
PRINT_APPID = 1 << 4,
PRINT_LAYOUT_SYMBOL = 1 << 5,
PRINT_FULLSCREEN = 1 << 6,
PRINT_FLOATING = 1 << 7,
PRINT_X = 1 << 8,
PRINT_Y = 1 << 9,
PRINT_WIDTH = 1 << 10,
PRINT_HEIGHT = 1 << 11,
PRINT_LAST_LAYER = 1 << 12,
PRINT_KB_LAYOUT = 1 << 13,
PRINT_KEYMODE = 1 << 14,
PRINT_SCALEFACTOR = 1 << 15,
PRINT_FRAME = 1 << 16,
PRINT_ALL = (1 << 17) - 1 // 所有位都设为1
};
typedef struct Pertag Pertag;
typedef struct Monitor Monitor;
typedef struct Client Client;
@@ -201,13 +223,13 @@ typedef struct {
char *v;
char *v2;
char *v3;
unsigned int ui;
unsigned int ui2;
uint32_t ui;
uint32_t ui2;
} Arg;
typedef struct {
unsigned int mod;
unsigned int button;
uint32_t mod;
uint32_t button;
int (*func)(const Arg *);
const Arg arg;
} Button; // 鼠标按键
@@ -218,8 +240,8 @@ typedef struct {
} KeyMode;
typedef struct {
unsigned int mod;
unsigned int dir;
uint32_t mod;
uint32_t dir;
int (*func)(const Arg *);
const Arg arg;
} Axis;
@@ -247,8 +269,8 @@ struct dwl_animation {
bool tagouting;
bool begin_fade_in;
bool tag_from_rule;
unsigned int time_started;
unsigned int duration;
uint32_t time_started;
uint32_t duration;
struct wlr_box initial;
struct wlr_box current;
int action;
@@ -259,8 +281,8 @@ struct dwl_opacity_animation {
float current_opacity;
float target_opacity;
float initial_opacity;
unsigned int time_started;
unsigned int duration;
uint32_t time_started;
uint32_t duration;
float current_border_color[4];
float target_border_color[4];
float initial_border_color[4];
@@ -277,7 +299,7 @@ typedef struct {
struct Client {
/* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */
uint32_t type; /* XDGShell or X11* */
struct wlr_box geom, pending, float_geom, animainit_geom,
overview_backup_geom, current,
drag_begin_geom; /* layout-relative, includes border */
@@ -309,10 +331,10 @@ struct Client {
struct wl_listener set_hints;
struct wl_listener set_geometry;
#endif
unsigned int bw;
unsigned int tags, oldtags, mini_restore_tag;
uint32_t bw;
uint32_t tags, oldtags, mini_restore_tag;
bool dirty;
unsigned int configure_serial;
uint32_t configure_serial;
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
int isfloating, isurgent, isfullscreen, isfakefullscreen,
need_float_size_reduce, isminimized, isoverlay, isnosizehint,
@@ -329,6 +351,8 @@ struct Client {
struct wl_listener foreign_fullscreen_request;
struct wl_listener foreign_close_request;
struct wl_listener foreign_destroy;
struct wl_listener foreign_minimize_request;
struct wl_listener foreign_maximize_request;
struct wl_listener set_decoration_mode;
struct wl_listener destroy_decoration;
@@ -381,6 +405,7 @@ struct Client {
int force_tearing;
int allow_shortcuts_inhibit;
float scroller_proportion_single;
bool isfocusing;
};
typedef struct {
@@ -390,7 +415,7 @@ typedef struct {
} DwlIpcOutput;
typedef struct {
unsigned int mod;
uint32_t mod;
xkb_keysym_t keysym;
int (*func)(const Arg *);
const Arg arg;
@@ -401,8 +426,8 @@ typedef struct {
int nsyms;
const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
unsigned int mods; /* invalid if nsyms == 0 */
unsigned int keycode;
uint32_t mods; /* invalid if nsyms == 0 */
uint32_t keycode;
struct wl_event_source *key_repeat_source;
struct wl_listener modifiers;
@@ -418,7 +443,7 @@ typedef struct {
typedef struct {
/* Must keep these three elements in this order */
unsigned int type; /* LayerShell */
uint32_t type; /* LayerShell */
struct wlr_box geom, current, pending, animainit_geom;
Monitor *mon;
struct wlr_scene_tree *scene;
@@ -449,7 +474,7 @@ typedef struct {
const char *symbol;
void (*arrange)(Monitor *);
const char *name;
unsigned int id;
uint32_t id;
} Layout;
struct Monitor {
@@ -466,8 +491,8 @@ struct Monitor {
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface::link */
const Layout *lt;
unsigned int seltags;
unsigned int tagset[2];
uint32_t seltags;
uint32_t tagset[2];
double mfact;
int nmaster;
@@ -481,9 +506,9 @@ struct Monitor {
int isoverview;
int is_in_hotarea;
int asleep;
unsigned int visible_clients;
unsigned int visible_tiling_clients;
unsigned int visible_scroll_tiling_clients;
uint32_t visible_clients;
uint32_t visible_tiling_clients;
uint32_t visible_scroll_tiling_clients;
bool has_visible_fullscreen_client;
struct wlr_scene_optimized_blur *blur;
char last_surface_ws_name[256];
@@ -515,7 +540,7 @@ arrange(Monitor *m,
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static char *get_autostart_path(char *, unsigned int); // 自启动命令执行
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,
@@ -580,21 +605,20 @@ static void gpureset(struct wl_listener *listener, void *data);
static int keyrepeat(void *data);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(unsigned int state, bool locked, unsigned int mods,
xkb_keysym_t sym, unsigned int keycode);
static int 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,
struct wlr_keyboard *keyboard,
struct wlr_keyboard_key_event *event,
unsigned int mods, xkb_keysym_t keysym,
unsigned int keycode);
struct wlr_keyboard_key_event *event, uint32_t mods,
xkb_keysym_t keysym, uint32_t keycode);
static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
static void minimizenotify(struct wl_listener *listener, void *data);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(unsigned int time, struct wlr_input_device *device,
static void motionnotify(uint32_t time, struct wlr_input_device *device,
double sx, double sy, double sx_unaccel,
double sy_unaccel);
static void motionrelative(struct wl_listener *listener, void *data);
@@ -608,7 +632,7 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config,
int test);
static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface, double sx,
double sy, unsigned int time);
double sy, uint32_t time);
static void printstatus(void);
static void quitsignal(int signo);
static void powermgrsetmode(struct wl_listener *listener, void *data);
@@ -626,7 +650,7 @@ static void setmaximizescreen(Client *c, int maximizescreen);
static void reset_maximizescreen_size(Client *c);
static void setgaps(int oh, int ov, int ih, int iv);
static void setmon(Client *c, Monitor *m, unsigned int newtags, bool focus);
static void setmon(Client *c, Monitor *m, uint32_t newtags, bool focus);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -657,7 +681,7 @@ static Client *termforwin(Client *w);
static void swallow(Client *c, Client *w);
static void warp_cursor_to_selmon(Monitor *m);
unsigned int want_restore_fullscreen(Client *target_client);
uint32_t want_restore_fullscreen(Client *target_client);
static void overview_restore(Client *c, const Arg *arg);
static void overview_backup(Client *c);
static int applyrulesgeom(Client *c);
@@ -670,7 +694,7 @@ 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);
static unsigned int get_tags_first_tag(unsigned int tags);
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,
@@ -701,11 +725,11 @@ static bool check_hit_no_border(Client *c);
static void reset_keyboard_layout(void);
static void client_update_oldmonname_record(Client *c, Monitor *m);
static void pending_kill_client(Client *c);
static unsigned int get_tags_first_tag_num(unsigned int source_tags);
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, unsigned int *width,
unsigned int *height);
static void layer_actual_size(LayerSurface *l, uint32_t *width,
uint32_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,
@@ -728,13 +752,13 @@ static Client *get_client_by_id_or_title(const char *arg_id,
const char *arg_title);
static bool switch_scratchpad_client_state(Client *c);
static bool check_trackpad_disabled(struct wlr_pointer *pointer);
static unsigned int get_tag_status(unsigned int tag, Monitor *m);
static uint32_t get_tag_status(uint32_t tag, Monitor *m);
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, unsigned int time);
int 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);
@@ -749,7 +773,7 @@ static void clear_fullscreen_and_maximized_state(Monitor *m);
static const char broken[] = "broken";
static pid_t child_pid = -1;
static int locked;
static unsigned int locked_mods = 0;
static uint32_t locked_mods = 0;
static void *exclusive_focus;
static struct wl_display *dpy;
static struct wl_event_loop *event_loop;
@@ -779,6 +803,7 @@ static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
static struct wlr_output_power_manager_v1 *power_mgr;
static struct wlr_pointer_gestures_v1 *pointer_gestures;
static struct wlr_drm_lease_v1_manager *drm_lease_manager;
struct mango_print_status_manager *print_status_manager;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
@@ -799,7 +824,7 @@ static struct wlr_seat *seat;
static KeyboardGroup *kb_group;
static struct wl_list inputdevices;
static struct wl_list keyboard_shortcut_inhibitors;
static unsigned int cursor_mode;
static uint32_t cursor_mode;
static Client *grabc;
static int grabcx, grabcy; /* client-relative */
static int drag_begin_cursorx, drag_begin_cursory; /* client-relative */
@@ -816,7 +841,7 @@ static int axis_apply_time = 0;
static int axis_apply_dir = 0;
static int scroller_focus_lock = 0;
static unsigned int swipe_fingers = 0;
static uint32_t swipe_fingers = 0;
static double swipe_dx = 0;
static double swipe_dy = 0;
@@ -831,6 +856,7 @@ struct dvec2 *baked_points_focus;
static struct wl_event_source *hide_source;
static bool cursor_hidden = false;
static bool tag_combo = false;
static const char *cli_config_path = NULL;
static KeyMode keymode = {
.mode = {'d', 'e', 'f', 'a', 'u', 'l', 't', '\0'},
.isdefault = true,
@@ -846,7 +872,7 @@ static struct {
#include "config/preset.h"
struct Pertag {
unsigned int curtag, prevtag; /* current and previous tag */
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 */
@@ -854,6 +880,10 @@ struct Pertag {
*ltidxs[LENGTH(tags) + 1]; /* matrix of tags and layouts indexes */
};
static struct wl_signal mango_print_status;
static struct wl_listener print_status_listener = {.notify =
handle_print_status};
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
static struct wl_listener cursor_frame = {.notify = cursorframe};
@@ -1291,7 +1321,7 @@ void set_float_malposition(Client *tc) {
void applyrules(Client *c) {
/* rule matching */
const char *appid, *title;
unsigned int i, newtags = 0;
uint32_t i, newtags = 0;
const ConfigWinRule *r;
Monitor *m = NULL;
Client *fc = NULL;
@@ -1466,9 +1496,9 @@ void apply_window_snap(Client *c) {
int snap_up_mon = 0, snap_down_mon = 0, snap_left_mon = 0,
snap_right_mon = 0;
unsigned int cbw = !render_border || c->fake_no_border ? borderpx : 0;
unsigned int tcbw;
unsigned int cx, cy, cw, ch, tcx, tcy, tcw, tch;
uint32_t cbw = !render_border || c->fake_no_border ? borderpx : 0;
uint32_t tcbw;
uint32_t cx, cy, cw, ch, tcx, tcy, tcw, tch;
cx = c->geom.x + cbw;
cy = c->geom.y + cbw;
cw = c->geom.width - 2 * cbw;
@@ -1568,7 +1598,7 @@ void focuslayer(LayerSurface *l) {
void reset_exclusive_layer(Monitor *m) {
LayerSurface *l = NULL;
int i;
unsigned int layers_above_shell[] = {
uint32_t layers_above_shell[] = {
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM,
@@ -1633,10 +1663,10 @@ axisnotify(struct wl_listener *listener, void *data) {
* for example when you move the scroll wheel. */
struct wlr_pointer_axis_event *event = data;
struct wlr_keyboard *keyboard, *hard_keyboard;
unsigned int mods, hard_mods;
uint32_t mods, hard_mods;
AxisBinding *a;
int ji;
unsigned int adir;
uint32_t adir;
// IDLE_NOTIFY_ACTIVITY;
handlecursoractivity();
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -1690,11 +1720,11 @@ axisnotify(struct wl_listener *listener, void *data) {
int ongesture(struct wlr_pointer_swipe_end_event *event) {
struct wlr_keyboard *keyboard, *hard_keyboard;
unsigned int mods, hard_mods;
uint32_t mods, hard_mods;
const GestureBinding *g;
unsigned int motion;
unsigned int adx = (int)round(fabs(swipe_dx));
unsigned int ady = (int)round(fabs(swipe_dy));
uint32_t motion;
uint32_t adx = (int)round(fabs(swipe_dx));
uint32_t ady = (int)round(fabs(swipe_dy));
int handled = 0;
int ji;
@@ -1859,7 +1889,7 @@ void // 鼠标按键事件
buttonpress(struct wl_listener *listener, void *data) {
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *hard_keyboard, *keyboard;
unsigned int hard_mods, mods;
uint32_t hard_mods, mods;
Client *c = NULL;
LayerSurface *l = NULL;
struct wlr_surface *surface;
@@ -2006,6 +2036,7 @@ void setcursorshape(struct wl_listener *listener, void *data) {
}
void cleanuplisteners(void) {
wl_list_remove(&print_status_listener.link);
wl_list_remove(&cursor_axis.link);
wl_list_remove(&cursor_button.link);
wl_list_remove(&cursor_frame.link);
@@ -2076,7 +2107,7 @@ void cleanup(void) {
void cleanupmon(struct wl_listener *listener, void *data) {
Monitor *m = wl_container_of(listener, m, destroy);
LayerSurface *l = NULL, *tmp = NULL;
unsigned int i;
uint32_t i;
/* m->layers[i] are intentionally not unlinked */
for (i = 0; i < LENGTH(m->layers); i++) {
@@ -2490,14 +2521,14 @@ KeyboardGroup *createkeyboardgroup(void) {
xkb_mod_index_t mod_index =
xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM);
if (mod_index != XKB_MOD_INVALID)
locked_mods |= (unsigned int)1 << mod_index;
locked_mods |= (uint32_t)1 << mod_index;
}
if (capslock) {
xkb_mod_index_t mod_index =
xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CAPS);
if (mod_index != XKB_MOD_INVALID)
locked_mods |= (unsigned int)1 << mod_index;
locked_mods |= (uint32_t)1 << mod_index;
}
if (locked_mods)
@@ -2621,7 +2652,7 @@ void createmon(struct wl_listener *listener, void *data) {
* monitor) becomes available. */
struct wlr_output *wlr_output = data;
const ConfigMonitorRule *r;
unsigned int i;
uint32_t i;
int ji, jk;
struct wlr_output_state state;
Monitor *m = NULL;
@@ -3141,6 +3172,7 @@ void destroykeyboardgroup(struct wl_listener *listener, void *data) {
void focusclient(Client *c, int lift) {
Client *last_focus_client = NULL;
Monitor *um = NULL;
struct wlr_surface *old_keyboard_focus_surface =
seat->keyboard_state.focused_surface;
@@ -3180,9 +3212,11 @@ void focusclient(Client *c, int lift) {
selmon = c->mon;
selmon->prevsel = selmon->sel;
selmon->sel = c;
c->isfocusing = true;
if (last_focus_client && !last_focus_client->iskilling &&
last_focus_client != c) {
last_focus_client->isfocusing = false;
client_set_unfocused_opacity_animation(last_focus_client);
}
@@ -3205,6 +3239,15 @@ void focusclient(Client *c, int lift) {
c->isurgent = 0;
}
// update other monitor focus disappear
wl_list_for_each(um, &mons, link) {
if (um->wlr_output->enabled && um != selmon && um->sel &&
!um->sel->iskilling && um->sel->isfocusing) {
um->sel->isfocusing = false;
client_set_unfocused_opacity_animation(um->sel);
}
}
if (c && !c->iskilling && c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, true);
@@ -3283,7 +3326,7 @@ void inputdevice(struct wl_listener *listener, void *data) {
/* This event is raised by the backend when a new input device becomes
* available. */
struct wlr_input_device *device = data;
unsigned int caps;
uint32_t caps;
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:
@@ -3340,8 +3383,8 @@ bool is_keyboard_shortcut_inhibitor(struct wlr_surface *surface) {
}
int // 17
keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
unsigned int keycode) {
keybinding(uint32_t state, bool locked, uint32_t mods, xkb_keysym_t sym,
uint32_t keycode) {
/*
* Here we handle compositor keybindings. This is when the compositor is
* processing keys, rather than passing them on to the client for its
@@ -3394,7 +3437,11 @@ keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
k->func) {
isbreak = k->func(&k->arg);
if (!k->ispassapply)
handled = 1;
else
handled = 0;
if (isbreak)
break;
@@ -3405,10 +3452,10 @@ keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
bool keypressglobal(struct wlr_surface *last_surface,
struct wlr_keyboard *keyboard,
struct wlr_keyboard_key_event *event, unsigned int mods,
xkb_keysym_t keysym, unsigned int keycode) {
struct wlr_keyboard_key_event *event, uint32_t mods,
xkb_keysym_t keysym, uint32_t keycode) {
Client *c = NULL, *lastc = focustop(selmon);
unsigned int keycodes[32] = {0};
uint32_t keycodes[32] = {0};
int reset = false;
const char *appid = NULL;
const char *title = NULL;
@@ -3484,19 +3531,19 @@ void keypress(struct wl_listener *listener, void *data) {
#endif
/* Translate libinput keycode -> xkbcommon */
unsigned int keycode = event->keycode + 8;
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);
int handled = 0;
unsigned int mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
// ov tab mode detect moe key release
if (ov_tab_mode && !locked &&
if (ov_tab_mode && !locked && group == kb_group &&
event->state == WL_KEYBOARD_KEY_STATE_RELEASED &&
(keycode == 133 || keycode == 37 || keycode == 64 || keycode == 50 ||
keycode == 134 || keycode == 105 || keycode == 108 || keycode == 62) &&
@@ -3630,6 +3677,7 @@ static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
}
void init_client_properties(Client *c) {
c->isfocusing = false;
c->ismaximizescreen = 0;
c->isfullscreen = 0;
c->need_float_size_reduce = 0;
@@ -3893,7 +3941,7 @@ void motionabsolute(struct wl_listener *listener, void *data) {
motionnotify(event->time_msec, &event->pointer->base, dx, dy, dx, dy);
}
void motionnotify(unsigned int time, struct wlr_input_device *device, double dx,
void motionnotify(uint32_t time, struct wlr_input_device *device, double dx,
double dy, double dx_unaccel, double dy_unaccel) {
double sx = 0, sy = 0, sx_confined, sy_confined;
Client *c = NULL, *w = NULL;
@@ -3988,35 +4036,18 @@ void motionnotify(unsigned int time, struct wlr_input_device *device, double dx,
if (!surface && !seat->drag && !cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
if (c && c->mon && !c->animation.running &&
(!(c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width ||
c->geom.x < c->mon->m.x ||
c->geom.y + c->geom.height > c->mon->m.y + c->mon->m.height ||
c->geom.y < c->mon->m.y) ||
!ISTILED(c))) {
if (c && c->mon && !c->animation.running && (INSIDEMON(c) || !ISTILED(c))) {
scroller_focus_lock = 0;
}
should_lock = false;
if (!scroller_focus_lock ||
!(c && c->mon &&
(c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width ||
c->geom.x < c->mon->m.x ||
c->geom.y + c->geom.height > c->mon->m.y + c->mon->m.height ||
c->geom.y < c->mon->m.y))) {
if (c && c->mon && is_scroller_layout(c->mon) &&
(c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width ||
c->geom.x < c->mon->m.x ||
c->geom.y + c->geom.height > c->mon->m.y + c->mon->m.height ||
c->geom.y < c->mon->m.y)) {
if (!scroller_focus_lock || !(c && c->mon && !INSIDEMON(c))) {
if (c && c->mon && is_scroller_layout(c->mon) && !INSIDEMON(c)) {
should_lock = true;
}
if (!(!edge_scroller_pointer_focus && c && c->mon &&
is_scroller_layout(c->mon) &&
(c->geom.x < c->mon->m.x || c->geom.y < c->mon->m.y ||
c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width ||
c->geom.y + c->geom.height > c->mon->m.y + c->mon->m.height)))
is_scroller_layout(c->mon) && !INSIDEMON(c)))
pointerfocus(c, surface, sx, sy, time);
if (should_lock && c && c->mon && ISTILED(c) && c == c->mon->sel) {
@@ -4118,7 +4149,7 @@ void outputmgrtest(struct wl_listener *listener, void *data) {
}
void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
unsigned int time) {
uint32_t time) {
struct timespec now;
if (surface != seat->pointer_state.focused_surface && sloppyfocus && time &&
@@ -4143,20 +4174,8 @@ void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
}
void // 17
printstatus(void) {
Monitor *m = NULL;
wl_list_for_each(m, &mons, link) {
if (!m->wlr_output->enabled) {
continue;
}
// Update workspace active states
dwl_ext_workspace_printstatus(m);
// Update IPC output status
dwl_ipc_output_printstatus(m);
}
}
// 修改printstatus函数接受掩码参数
void printstatus(void) { wl_signal_emit(&mango_print_status, NULL); }
void powermgrsetmode(struct wl_listener *listener, void *data) {
struct wlr_output_power_v1_set_mode_event *event = data;
@@ -4297,7 +4316,7 @@ void setborder_color(Client *c) {
void exchange_two_client(Client *c1, Client *c2) {
Monitor *tmp_mon = NULL;
unsigned int tmp_tags;
uint32_t tmp_tags;
double master_inner_per = 0.0f;
double master_mfact_per = 0.0f;
double stack_innder_per = 0.0f;
@@ -4375,7 +4394,6 @@ run(char *startup_cmd) {
set_env();
char autostart_temp_path[1024];
/* Add a Unix socket to the Wayland display. */
const char *socket = wl_display_add_socket_auto(dpy);
if (!socket)
@@ -4389,9 +4407,7 @@ run(char *startup_cmd) {
/* Now that the socket exists and the backend is started, run the
* startup command */
if (!startup_cmd)
startup_cmd = get_autostart_path(autostart_temp_path,
sizeof(autostart_temp_path));
if (startup_cmd) {
int piperw[2];
if (pipe(piperw) < 0)
@@ -4734,9 +4750,9 @@ void reset_keyboard_layout(void) {
}
// Apply the new keymap
unsigned int depressed = keyboard->modifiers.depressed;
unsigned int latched = keyboard->modifiers.latched;
unsigned int locked = keyboard->modifiers.locked;
uint32_t depressed = keyboard->modifiers.depressed;
uint32_t latched = keyboard->modifiers.latched;
uint32_t locked = keyboard->modifiers.locked;
wlr_keyboard_set_keymap(keyboard, new_keymap);
@@ -4771,7 +4787,7 @@ cleanup_context:
xkb_context_unref(context);
}
void setmon(Client *c, Monitor *m, unsigned int newtags, bool focus) {
void setmon(Client *c, Monitor *m, uint32_t newtags, bool focus) {
Monitor *oldmon = c->mon;
if (oldmon == m)
@@ -4841,7 +4857,7 @@ void setsel(struct wl_listener *listener, void *data) {
}
void show_hide_client(Client *c) {
unsigned int target = 1;
uint32_t target = 1;
set_size_per(c->mon, c);
target = get_tags_first_tag(c->oldtags);
@@ -4879,6 +4895,20 @@ void create_output(struct wlr_backend *backend, void *data) {
#endif
}
// 修改信号处理函数,接收掩码参数
void handle_print_status(struct wl_listener *listener, void *data) {
Monitor *m = NULL;
wl_list_for_each(m, &mons, link) {
if (!m->wlr_output->enabled) {
continue;
}
dwl_ext_workspace_printstatus(m);
dwl_ipc_output_printstatus(m);
}
}
void setup(void) {
setenv("XCURSOR_SIZE", "24", 1);
@@ -4974,6 +5004,10 @@ void setup(void) {
wlr_alpha_modifier_v1_create(dpy);
wlr_ext_data_control_manager_v1_create(dpy, 1);
// 在 setup 函数中
wl_signal_init(&mango_print_status);
wl_signal_add(&mango_print_status, &print_status_listener);
/* Initializes the interface used to implement urgency hints */
activation = wlr_xdg_activation_v1_create(dpy);
wl_signal_add(&activation->events.request_activate, &request_activate);
@@ -5214,7 +5248,7 @@ void tag_client(const Arg *arg, Client *target_client) {
void overview(Monitor *m) { grid(m); }
// 目标窗口有其他窗口和它同个tag就返回0
unsigned int want_restore_fullscreen(Client *target_client) {
uint32_t want_restore_fullscreen(Client *target_client) {
Client *c = NULL;
wl_list_for_each(c, &clients, link) {
if (c && c != target_client && c->tags == target_client->tags &&
@@ -5590,7 +5624,7 @@ urgent(struct wl_listener *listener, void *data) {
void view_in_mon(const Arg *arg, bool want_animation, Monitor *m,
bool changefocus) {
unsigned int i, tmptag;
uint32_t i, tmptag;
if (!m || (arg->ui != (~0 & TAGMASK) && m->isoverview)) {
return;
@@ -5601,9 +5635,9 @@ void view_in_mon(const Arg *arg, bool want_animation, Monitor *m,
}
if (arg->ui == UINT32_MAX) {
m->pertag->prevtag = m->tagset[m->seltags];
m->pertag->prevtag = get_tags_first_tag_num(m->tagset[m->seltags]);
m->seltags ^= 1; /* toggle sel tagset */
m->pertag->curtag = m->tagset[m->seltags];
m->pertag->curtag = get_tags_first_tag_num(m->tagset[m->seltags]);
goto toggleseltags;
}
@@ -5680,8 +5714,15 @@ void handle_keyboard_shortcuts_inhibit_new_inhibitor(
}
// per-view, seat-agnostic config via criteria
Client *c = get_client_from_surface(inhibitor->surface);
if (c && !c->allow_shortcuts_inhibit) {
Client *c = NULL;
LayerSurface *l = NULL;
int type = toplevel_from_wlr_surface(inhibitor->surface, &c, &l);
if (type < 0)
return;
if (type != LayerShell && c && !c->allow_shortcuts_inhibit) {
return;
}
@@ -5888,13 +5929,15 @@ int main(int argc, char *argv[]) {
char *startup_cmd = NULL;
int c;
while ((c = getopt(argc, argv, "s:hdv")) != -1) {
while ((c = getopt(argc, argv, "s:c:hdv")) != -1) {
if (c == 's')
startup_cmd = optarg;
else if (c == 'd')
log_level = WLR_DEBUG;
else if (c == 'v')
die("mango " VERSION);
else if (c == 'c')
cli_config_path = optarg;
else
goto usage;
}
@@ -5912,5 +5955,5 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
usage:
die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
die("Usage: %s [-v] [-d] [-c config file] [-s startup command]", argv[0]);
}