mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-02-05 04:06:28 -05:00
Compare commits
28 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e898417a7 | ||
|
|
65fcd58949 | ||
|
|
2bda8e3bf1 | ||
|
|
a4faf2c494 | ||
|
|
b0f839468c | ||
|
|
8ba259fbb7 | ||
|
|
16e361e1ca | ||
|
|
336f873d83 | ||
|
|
50b67ac539 | ||
|
|
0546a2d4c4 | ||
|
|
eb0607501d | ||
|
|
bcee63fa76 | ||
|
|
5172444e08 | ||
|
|
ca09aa69db | ||
|
|
aa5241fb7b | ||
|
|
672706c71f | ||
|
|
d9f679a8e3 | ||
|
|
4591b69e4d | ||
|
|
e535aea28b | ||
|
|
30692f6da0 | ||
|
|
2e6e23633e | ||
|
|
6624d80522 | ||
|
|
05010a1114 | ||
|
|
00de523039 | ||
|
|
f1cca251b8 | ||
|
|
0652f99e6e | ||
|
|
334bc076a0 | ||
|
|
49921eadfa |
11 changed files with 816 additions and 374 deletions
|
|
@ -1,5 +1,5 @@
|
|||
project('mango', ['c', 'cpp'],
|
||||
version : '0.11.0',
|
||||
version : '0.12.0',
|
||||
)
|
||||
|
||||
subdir('protocols')
|
||||
|
|
|
|||
|
|
@ -363,7 +363,6 @@ void apply_border(Client *c) {
|
|||
current_corner_location = set_client_corner_location(c);
|
||||
}
|
||||
|
||||
// Handle no-border cases
|
||||
if (hit_no_border && smartgaps) {
|
||||
c->bw = 0;
|
||||
c->fake_no_border = true;
|
||||
|
|
@ -981,6 +980,12 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
|
|||
c->bw = 0;
|
||||
}
|
||||
|
||||
bool hit_no_border = check_hit_no_border(c);
|
||||
if (hit_no_border && smartgaps) {
|
||||
c->bw = 0;
|
||||
c->fake_no_border = true;
|
||||
}
|
||||
|
||||
// c->geom 是真实的窗口大小和位置,跟过度的动画无关,用于计算布局
|
||||
c->configure_serial = client_set_size(c, c->geom.width - 2 * c->bw,
|
||||
c->geom.height - 2 * c->bw);
|
||||
|
|
@ -1049,20 +1054,11 @@ void client_set_focused_opacity_animation(Client *c) {
|
|||
sizeof(c->opacity_animation.target_border_color));
|
||||
c->opacity_animation.target_opacity = c->focused_opacity;
|
||||
c->opacity_animation.time_started = get_now_in_ms();
|
||||
if (c->opacity_animation.running) {
|
||||
memcpy(c->opacity_animation.initial_border_color,
|
||||
c->opacity_animation.current_border_color,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
c->opacity_animation.initial_opacity =
|
||||
c->opacity_animation.current_opacity;
|
||||
} else {
|
||||
memcpy(c->opacity_animation.initial_border_color, border_color,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
memcpy(c->opacity_animation.current_border_color, border_color,
|
||||
sizeof(c->opacity_animation.current_border_color));
|
||||
c->opacity_animation.initial_opacity = c->unfocused_opacity;
|
||||
c->opacity_animation.current_opacity = c->unfocused_opacity;
|
||||
}
|
||||
memcpy(c->opacity_animation.initial_border_color,
|
||||
c->opacity_animation.current_border_color,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
c->opacity_animation.initial_opacity = c->opacity_animation.current_opacity;
|
||||
|
||||
c->opacity_animation.running = true;
|
||||
}
|
||||
|
||||
|
|
@ -1082,20 +1078,10 @@ void client_set_unfocused_opacity_animation(Client *c) {
|
|||
c->opacity_animation.target_opacity = c->unfocused_opacity;
|
||||
c->opacity_animation.time_started = get_now_in_ms();
|
||||
|
||||
if (c->opacity_animation.running) {
|
||||
memcpy(c->opacity_animation.initial_border_color,
|
||||
c->opacity_animation.current_border_color,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
c->opacity_animation.initial_opacity =
|
||||
c->opacity_animation.current_opacity;
|
||||
} else {
|
||||
memcpy(c->opacity_animation.initial_border_color, border_color,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
memcpy(c->opacity_animation.current_border_color, border_color,
|
||||
sizeof(c->opacity_animation.current_border_color));
|
||||
c->opacity_animation.initial_opacity = c->focused_opacity;
|
||||
c->opacity_animation.current_opacity = c->focused_opacity;
|
||||
}
|
||||
memcpy(c->opacity_animation.initial_border_color,
|
||||
c->opacity_animation.current_border_color,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
c->opacity_animation.initial_opacity = c->opacity_animation.current_opacity;
|
||||
|
||||
c->opacity_animation.running = true;
|
||||
}
|
||||
|
|
@ -1130,7 +1116,12 @@ bool client_apply_focus_opacity(Client *c) {
|
|||
if (target_opacity > opacity) {
|
||||
target_opacity = opacity;
|
||||
}
|
||||
memcpy(c->opacity_animation.current_border_color,
|
||||
c->opacity_animation.target_border_color,
|
||||
sizeof(c->opacity_animation.current_border_color));
|
||||
c->opacity_animation.current_opacity = target_opacity;
|
||||
client_set_opacity(c, target_opacity);
|
||||
client_set_border_color(c, c->opacity_animation.target_border_color);
|
||||
} else if (animations && c->opacity_animation.running) {
|
||||
|
||||
struct timespec now;
|
||||
|
|
@ -1161,7 +1152,7 @@ bool client_apply_focus_opacity(Client *c) {
|
|||
eased_progress;
|
||||
}
|
||||
client_set_border_color(c, c->opacity_animation.current_border_color);
|
||||
if (linear_progress == 1.0f) {
|
||||
if (linear_progress >= 1.0f) {
|
||||
c->opacity_animation.running = false;
|
||||
} else {
|
||||
return true;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -47,8 +47,9 @@ int32_t log_level = WLR_ERROR;
|
|||
uint32_t numlockon = 0; // 是否打开右边小键盘
|
||||
uint32_t capslock = 0; // 是否启用快捷键
|
||||
|
||||
uint32_t ov_tab_mode = 0; // alt tab切换模式
|
||||
uint32_t hotarea_size = 10; // 热区大小,10x10
|
||||
uint32_t ov_tab_mode = 0; // alt tab切换模式
|
||||
uint32_t hotarea_size = 10; // 热区大小,10x10
|
||||
uint32_t hotarea_corner = BOTTOM_LEFT;
|
||||
uint32_t enable_hotarea = 1; // 是否启用鼠标热区
|
||||
int32_t smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||
int32_t sloppyfocus = 1; /* focus follows mouse */
|
||||
|
|
@ -62,7 +63,7 @@ float scratchpad_height_ratio = 0.9;
|
|||
int32_t scroller_structs = 20;
|
||||
float scroller_default_proportion = 0.9;
|
||||
float scroller_default_proportion_single = 1.0;
|
||||
int32_t scroller_ignore_proportion_single = 0;
|
||||
int32_t scroller_ignore_proportion_single = 1;
|
||||
int32_t scroller_focus_center = 0;
|
||||
int32_t scroller_prefer_center = 0;
|
||||
int32_t focus_cross_monitor = 0;
|
||||
|
|
@ -101,12 +102,14 @@ int32_t overviewgappo = 30; /* overview时 窗口与窗口 缝隙大小 */
|
|||
* behavior */
|
||||
float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
||||
|
||||
int32_t warpcursor = 1; /* Warp cursor to focused client */
|
||||
int32_t warpcursor = 1;
|
||||
int32_t drag_corner = 3;
|
||||
int32_t drag_warp_cursor = 1;
|
||||
int32_t xwayland_persistence = 1; /* xwayland persistence */
|
||||
int32_t syncobj_enable = 0;
|
||||
int32_t adaptive_sync = 0;
|
||||
int32_t allow_lock_transparent = 0;
|
||||
double drag_refresh_interval = 16.0;
|
||||
double drag_tile_refresh_interval = 16.0;
|
||||
double drag_floating_refresh_interval = 8.0;
|
||||
int32_t allow_tearing = TEARING_DISABLED;
|
||||
int32_t allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||
|
||||
|
|
@ -233,4 +236,3 @@ double shadows_blur = 15;
|
|||
int32_t shadows_position_x = 0;
|
||||
int32_t shadows_position_y = 0;
|
||||
float shadowscolor[] = COLOR(0x000000ff);
|
||||
;
|
||||
|
|
|
|||
|
|
@ -338,6 +338,9 @@ int32_t killclient(const Arg *arg) {
|
|||
}
|
||||
|
||||
int32_t moveresize(const Arg *arg) {
|
||||
const char *cursors[] = {"nw-resize", "ne-resize", "sw-resize",
|
||||
"se-resize"};
|
||||
|
||||
if (cursor_mode != CurNormal && cursor_mode != CurPressed)
|
||||
return 0;
|
||||
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
|
||||
|
|
@ -363,10 +366,29 @@ int32_t moveresize(const Arg *arg) {
|
|||
/* Doesn't work for X11 output - the next absolute motion event
|
||||
* returns the cursor to where it started */
|
||||
if (grabc->isfloating) {
|
||||
wlr_cursor_warp_closest(cursor, NULL,
|
||||
grabc->geom.x + grabc->geom.width,
|
||||
grabc->geom.y + grabc->geom.height);
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "bottom_right_corner");
|
||||
rzcorner = drag_corner;
|
||||
grabcx = (int)round(cursor->x);
|
||||
grabcy = (int)round(cursor->y);
|
||||
if (rzcorner == 4)
|
||||
/* identify the closest corner index */
|
||||
rzcorner = (grabcx - grabc->geom.x <
|
||||
grabc->geom.x + grabc->geom.width - grabcx
|
||||
? 0
|
||||
: 1) +
|
||||
(grabcy - grabc->geom.y <
|
||||
grabc->geom.y + grabc->geom.height - grabcy
|
||||
? 0
|
||||
: 2);
|
||||
|
||||
if (drag_warp_cursor) {
|
||||
grabcx = rzcorner & 1 ? grabc->geom.x + grabc->geom.width
|
||||
: grabc->geom.x;
|
||||
grabcy = rzcorner & 2 ? grabc->geom.y + grabc->geom.height
|
||||
: grabc->geom.y;
|
||||
wlr_cursor_warp_closest(cursor, NULL, grabcx, grabcy);
|
||||
}
|
||||
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, cursors[rzcorner]);
|
||||
} else {
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "grab");
|
||||
}
|
||||
|
|
@ -1422,9 +1444,14 @@ int32_t viewcrossmon(const Arg *arg) {
|
|||
}
|
||||
|
||||
int32_t tagcrossmon(const Arg *arg) {
|
||||
if (!selmon->sel)
|
||||
if (!selmon || !selmon->sel)
|
||||
return 0;
|
||||
|
||||
if (regex_match(selmon->wlr_output->name, arg->v)) {
|
||||
tag_client(arg, selmon->sel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tagmon(&(Arg){.ui = arg->ui, .i = UNDIR, .v = arg->v});
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ bool check_hit_no_border(Client *c) {
|
|||
}
|
||||
}
|
||||
|
||||
if (no_border_when_single && c && c->mon && c->mon->visible_clients == 1) {
|
||||
if (no_border_when_single && c && c->mon &&
|
||||
((ISSCROLLTILED(c) && c->mon->visible_scroll_tiling_clients == 1) ||
|
||||
c->mon->visible_clients == 1)) {
|
||||
hit_no_border = true;
|
||||
}
|
||||
return hit_no_border;
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx,
|
|||
}
|
||||
|
||||
if (last_apply_drap_time == 0 ||
|
||||
time - last_apply_drap_time > drag_refresh_interval) {
|
||||
time - last_apply_drap_time > drag_tile_refresh_interval) {
|
||||
arrange(grabc->mon, false, false);
|
||||
last_apply_drap_time = time;
|
||||
}
|
||||
|
|
@ -367,7 +367,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx,
|
|||
}
|
||||
|
||||
if (last_apply_drap_time == 0 ||
|
||||
time - last_apply_drap_time > drag_refresh_interval) {
|
||||
time - last_apply_drap_time > drag_tile_refresh_interval) {
|
||||
arrange(grabc->mon, false, false);
|
||||
last_apply_drap_time = time;
|
||||
}
|
||||
|
|
@ -548,7 +548,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
|
|||
}
|
||||
|
||||
if (last_apply_drap_time == 0 ||
|
||||
time - last_apply_drap_time > drag_refresh_interval) {
|
||||
time - last_apply_drap_time > drag_tile_refresh_interval) {
|
||||
arrange(grabc->mon, false, false);
|
||||
last_apply_drap_time = time;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ void deck(Monitor *m) {
|
|||
Client *c = NULL;
|
||||
Client *fc = NULL;
|
||||
float mfact;
|
||||
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
|
||||
|
||||
int32_t cur_gappih = enablegaps ? m->gappih : 0;
|
||||
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
|
|
@ -142,8 +143,8 @@ void deck(Monitor *m) {
|
|||
: m->pertag->mfacts[m->pertag->curtag];
|
||||
|
||||
// Calculate master width including outer gaps
|
||||
if (n > m->nmaster)
|
||||
mw = m->nmaster ? round((m->w.width - 2 * cur_gappoh) * mfact) : 0;
|
||||
if (n > nmasters)
|
||||
mw = nmasters ? round((m->w.width - 2 * cur_gappoh) * mfact) : 0;
|
||||
else
|
||||
mw = m->w.width - 2 * cur_gappoh;
|
||||
|
||||
|
|
@ -151,7 +152,7 @@ void deck(Monitor *m) {
|
|||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || !ISTILED(c))
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
if (i < nmasters) {
|
||||
c->master_mfact_per = mfact;
|
||||
// Master area clients
|
||||
resize(
|
||||
|
|
@ -160,7 +161,7 @@ void deck(Monitor *m) {
|
|||
.y = m->w.y + cur_gappov + my,
|
||||
.width = mw,
|
||||
.height = (m->w.height - 2 * cur_gappov - my) /
|
||||
(MIN(n, m->nmaster) - i)},
|
||||
(MIN(n, nmasters) - i)},
|
||||
0);
|
||||
my += c->geom.height;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ static void tgmix(Monitor *m);
|
|||
Layout overviewlayout = {"", overview, "overview"};
|
||||
|
||||
enum {
|
||||
SCROLLER,
|
||||
TILE,
|
||||
SCROLLER,
|
||||
GRID,
|
||||
MONOCLE,
|
||||
DECK,
|
||||
|
|
@ -34,8 +34,8 @@ enum {
|
|||
Layout layouts[] = {
|
||||
// 最少两个,不能删除少于两个
|
||||
/* symbol arrange function name */
|
||||
{"S", scroller, "scroller", SCROLLER}, // 滚动布局
|
||||
{"T", tile, "tile", TILE}, // 平铺布局
|
||||
{"S", scroller, "scroller", SCROLLER}, // 滚动布局
|
||||
{"G", grid, "grid", GRID}, // 格子布局
|
||||
{"M", monocle, "monocle", MONOCLE}, // 单屏布局
|
||||
{"K", deck, "deck", DECK}, // 卡片布局
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ void vertical_deck(Monitor *m) {
|
|||
Client *c = NULL;
|
||||
Client *fc = NULL;
|
||||
float mfact;
|
||||
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
|
||||
|
||||
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
|
||||
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
|
|
@ -134,8 +135,8 @@ void vertical_deck(Monitor *m) {
|
|||
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
|
||||
: m->pertag->mfacts[m->pertag->curtag];
|
||||
|
||||
if (n > m->nmaster)
|
||||
mh = m->nmaster ? round((m->w.height - 2 * cur_gappov) * mfact) : 0;
|
||||
if (n > nmasters)
|
||||
mh = nmasters ? round((m->w.height - 2 * cur_gappov) * mfact) : 0;
|
||||
else
|
||||
mh = m->w.height - 2 * cur_gappov;
|
||||
|
||||
|
|
@ -143,13 +144,13 @@ void vertical_deck(Monitor *m) {
|
|||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || !ISTILED(c))
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
if (i < nmasters) {
|
||||
resize(
|
||||
c,
|
||||
(struct wlr_box){.x = m->w.x + cur_gappoh + mx,
|
||||
.y = m->w.y + cur_gappov,
|
||||
.width = (m->w.width - 2 * cur_gappoh - mx) /
|
||||
(MIN(n, m->nmaster) - i),
|
||||
(MIN(n, nmasters) - i),
|
||||
.height = mh},
|
||||
0);
|
||||
mx += c->geom.width;
|
||||
|
|
|
|||
249
src/mango.c
249
src/mango.c
|
|
@ -143,6 +143,8 @@
|
|||
#define BAKED_POINTS_COUNT 256
|
||||
|
||||
/* enums */
|
||||
enum { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
|
||||
|
||||
enum { VERTICAL, HORIZONTAL };
|
||||
enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT };
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
|
|
@ -478,6 +480,7 @@ typedef struct {
|
|||
char *animation_type_open;
|
||||
char *animation_type_close;
|
||||
bool need_output_flush;
|
||||
bool being_unmapped;
|
||||
} LayerSurface;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -500,11 +503,8 @@ struct Monitor {
|
|||
struct wlr_box m; /* monitor area, layout-relative */
|
||||
struct wlr_box w; /* window area, layout-relative */
|
||||
struct wl_list layers[4]; /* LayerSurface::link */
|
||||
const Layout *lt;
|
||||
uint32_t seltags;
|
||||
uint32_t tagset[2];
|
||||
double mfact;
|
||||
int32_t nmaster;
|
||||
|
||||
struct wl_list dwl_ipc_outputs;
|
||||
int32_t gappih; /* horizontal gap between windows */
|
||||
|
|
@ -593,7 +593,7 @@ static void cursorwarptohint(void);
|
|||
static void destroydecoration(struct wl_listener *listener, void *data);
|
||||
static void destroydragicon(struct wl_listener *listener, void *data);
|
||||
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
|
||||
static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
static void destroylayernodenotify(struct wl_listener *listener, void *data);
|
||||
static void destroylock(SessionLock *lock, int32_t unlocked);
|
||||
static void destroylocksurface(struct wl_listener *listener, void *data);
|
||||
static void destroynotify(struct wl_listener *listener, void *data);
|
||||
|
|
@ -841,6 +841,7 @@ static struct wl_list inputdevices;
|
|||
static struct wl_list keyboard_shortcut_inhibitors;
|
||||
static uint32_t cursor_mode;
|
||||
static Client *grabc;
|
||||
static int32_t rzcorner;
|
||||
static int32_t grabcx, grabcy; /* client-relative */
|
||||
static int32_t drag_begin_cursorx, drag_begin_cursory; /* client-relative */
|
||||
static bool start_drag_window = false;
|
||||
|
|
@ -897,6 +898,7 @@ struct Pertag {
|
|||
int32_t nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||
bool no_hide[LENGTH(tags) + 1]; /* no_hide per tag */
|
||||
bool no_render_border[LENGTH(tags) + 1]; /* no_render_border per tag */
|
||||
const Layout
|
||||
*ltidxs[LENGTH(tags) + 1]; /* matrix of tags and layouts indexes */
|
||||
};
|
||||
|
|
@ -967,7 +969,6 @@ static struct wlr_xwayland *xwayland;
|
|||
|
||||
void client_change_mon(Client *c, Monitor *m) {
|
||||
setmon(c, m, c->tags, true);
|
||||
reset_foreign_tolevel(c);
|
||||
if (c->isfloating) {
|
||||
c->float_geom = c->geom =
|
||||
setclient_coordinate_center(c, c->mon, c->geom, 0, 0);
|
||||
|
|
@ -1069,6 +1070,9 @@ void swallow(Client *c, Client *w) {
|
|||
c->tags = w->tags;
|
||||
c->geom = w->geom;
|
||||
c->float_geom = w->float_geom;
|
||||
c->stack_inner_per = w->stack_inner_per;
|
||||
c->master_inner_per = w->master_inner_per;
|
||||
c->master_mfact_per = w->master_mfact_per;
|
||||
c->scroller_proportion = w->scroller_proportion;
|
||||
c->next_in_stack = w->next_in_stack;
|
||||
c->prev_in_stack = w->prev_in_stack;
|
||||
|
|
@ -1216,17 +1220,59 @@ void toggle_hotarea(int32_t x_root, int32_t y_root) {
|
|||
if (grabc)
|
||||
return;
|
||||
|
||||
unsigned hx = selmon->m.x + hotarea_size;
|
||||
unsigned hy = selmon->m.y + selmon->m.height - hotarea_size;
|
||||
// 根据热角位置计算不同的热区坐标
|
||||
unsigned hx, hy;
|
||||
|
||||
if (enable_hotarea == 1 && selmon->is_in_hotarea == 0 && y_root > hy &&
|
||||
x_root < hx && x_root >= selmon->m.x &&
|
||||
y_root <= (selmon->m.y + selmon->m.height)) {
|
||||
switch (hotarea_corner) {
|
||||
case BOTTOM_RIGHT: // 右下角
|
||||
hx = selmon->m.x + selmon->m.width - hotarea_size;
|
||||
hy = selmon->m.y + selmon->m.height - hotarea_size;
|
||||
break;
|
||||
case TOP_LEFT: // 左上角
|
||||
hx = selmon->m.x + hotarea_size;
|
||||
hy = selmon->m.y + hotarea_size;
|
||||
break;
|
||||
case TOP_RIGHT: // 右上角
|
||||
hx = selmon->m.x + selmon->m.width - hotarea_size;
|
||||
hy = selmon->m.y + hotarea_size;
|
||||
break;
|
||||
case BOTTOM_LEFT: // 左下角(默认)
|
||||
default:
|
||||
hx = selmon->m.x + hotarea_size;
|
||||
hy = selmon->m.y + selmon->m.height - hotarea_size;
|
||||
break;
|
||||
}
|
||||
|
||||
// 判断鼠标是否在热区内
|
||||
int in_hotarea = 0;
|
||||
|
||||
switch (hotarea_corner) {
|
||||
case BOTTOM_RIGHT: // 右下角
|
||||
in_hotarea = (y_root > hy && x_root > hx &&
|
||||
x_root <= (selmon->m.x + selmon->m.width) &&
|
||||
y_root <= (selmon->m.y + selmon->m.height));
|
||||
break;
|
||||
case TOP_LEFT: // 左上角
|
||||
in_hotarea = (y_root < hy && x_root < hx && x_root >= selmon->m.x &&
|
||||
y_root >= selmon->m.y);
|
||||
break;
|
||||
case TOP_RIGHT: // 右上角
|
||||
in_hotarea = (y_root < hy && x_root > hx &&
|
||||
x_root <= (selmon->m.x + selmon->m.width) &&
|
||||
y_root >= selmon->m.y);
|
||||
break;
|
||||
case BOTTOM_LEFT: // 左下角(默认)
|
||||
default:
|
||||
in_hotarea = (y_root > hy && x_root < hx && x_root >= selmon->m.x &&
|
||||
y_root <= (selmon->m.y + selmon->m.height));
|
||||
break;
|
||||
}
|
||||
|
||||
if (enable_hotarea == 1 && selmon->is_in_hotarea == 0 && in_hotarea) {
|
||||
toggleoverview(&arg);
|
||||
selmon->is_in_hotarea = 1;
|
||||
} else if (enable_hotarea == 1 && selmon->is_in_hotarea == 1 &&
|
||||
(y_root <= hy || x_root >= hx || x_root < selmon->m.x ||
|
||||
y_root > (selmon->m.y + selmon->m.height))) {
|
||||
!in_hotarea) {
|
||||
selmon->is_in_hotarea = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1478,6 +1524,9 @@ void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area,
|
|||
!layer_surface->initialized)
|
||||
continue;
|
||||
|
||||
if (l->being_unmapped)
|
||||
continue;
|
||||
|
||||
wlr_scene_layer_surface_v1_configure(l->scene_layer, &full_area,
|
||||
usable_area);
|
||||
wlr_scene_node_set_position(&l->popups->node, l->scene->node.x,
|
||||
|
|
@ -1976,7 +2025,6 @@ buttonpress(struct wl_listener *listener, void *data) {
|
|||
selmon = xytomon(cursor->x, cursor->y);
|
||||
client_update_oldmonname_record(grabc, selmon);
|
||||
setmon(grabc, selmon, 0, true);
|
||||
reset_foreign_tolevel(grabc);
|
||||
selmon->prevsel = ISTILED(selmon->sel) ? selmon->sel : NULL;
|
||||
selmon->sel = grabc;
|
||||
tmpc = grabc;
|
||||
|
|
@ -2294,6 +2342,15 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
// 检查surface是否有buffer
|
||||
// 空buffer,只是隐藏,不改变mapped状态
|
||||
if (l->mapped && !layer_surface->surface->buffer) {
|
||||
wlr_scene_node_set_enabled(&l->scene->node, false);
|
||||
return;
|
||||
} else {
|
||||
wlr_scene_node_set_enabled(&l->scene->node, true);
|
||||
}
|
||||
|
||||
get_layer_target_geometry(l, &box);
|
||||
|
||||
if (animations && layer_animations && !l->noanim && l->mapped &&
|
||||
|
|
@ -2442,12 +2499,12 @@ void commitpopup(struct wl_listener *listener, void *data) {
|
|||
struct wlr_box box;
|
||||
int32_t type = -1;
|
||||
|
||||
if (!popup->base->initial_commit)
|
||||
return;
|
||||
if (!popup || !popup->base->initial_commit)
|
||||
goto commitpopup_listen_free;
|
||||
|
||||
type = toplevel_from_wlr_surface(popup->base->surface, &c, &l);
|
||||
if (!popup->parent || type < 0)
|
||||
return;
|
||||
if (!popup->parent || !popup->parent->data || type < 0)
|
||||
goto commitpopup_listen_free;
|
||||
|
||||
wlr_scene_node_raise_to_top(popup->parent->data);
|
||||
|
||||
|
|
@ -2455,13 +2512,14 @@ void commitpopup(struct wl_listener *listener, void *data) {
|
|||
wlr_scene_xdg_surface_create(popup->parent->data, popup->base);
|
||||
if ((l && !l->mon) || (c && !c->mon)) {
|
||||
wlr_xdg_popup_destroy(popup);
|
||||
return;
|
||||
goto commitpopup_listen_free;
|
||||
}
|
||||
box = type == LayerShell ? l->mon->m : c->mon->w;
|
||||
box.x -= (type == LayerShell ? l->scene->node.x : c->geom.x);
|
||||
box.y -= (type == LayerShell ? l->scene->node.y : c->geom.y);
|
||||
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
||||
|
||||
commitpopup_listen_free:
|
||||
wl_list_remove(&listener->link);
|
||||
free(listener);
|
||||
}
|
||||
|
|
@ -2589,8 +2647,6 @@ void createlayersurface(struct wl_listener *listener, void *data) {
|
|||
LISTEN(&surface->events.commit, &l->surface_commit,
|
||||
commitlayersurfacenotify);
|
||||
LISTEN(&surface->events.unmap, &l->unmap, unmaplayersurfacenotify);
|
||||
LISTEN(&layer_surface->events.destroy, &l->destroy,
|
||||
destroylayersurfacenotify);
|
||||
|
||||
l->layer_surface = layer_surface;
|
||||
l->mon = layer_surface->output->data;
|
||||
|
|
@ -2603,6 +2659,8 @@ void createlayersurface(struct wl_listener *listener, void *data) {
|
|||
: scene_layer);
|
||||
l->scene->node.data = l->popups->node.data = l;
|
||||
|
||||
LISTEN(&l->scene->node.events.destroy, &l->destroy, destroylayernodenotify);
|
||||
|
||||
wl_list_insert(&l->mon->layers[layer_surface->pending.layer], &l->link);
|
||||
wlr_surface_send_enter(surface, layer_surface->output);
|
||||
}
|
||||
|
|
@ -2665,7 +2723,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
struct wlr_output *wlr_output = data;
|
||||
const ConfigMonitorRule *r;
|
||||
uint32_t i;
|
||||
int32_t ji, jk;
|
||||
int32_t ji, vrr;
|
||||
struct wlr_output_state state;
|
||||
Monitor *m = NULL;
|
||||
struct wlr_output_mode *internal_mode = NULL;
|
||||
|
|
@ -2701,30 +2759,19 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
m->sel = NULL;
|
||||
m->is_in_hotarea = 0;
|
||||
float scale = 1;
|
||||
m->mfact = default_mfact;
|
||||
m->nmaster = default_nmaster;
|
||||
enum wl_output_transform rr = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
wlr_output_state_set_scale(&state, scale);
|
||||
wlr_output_state_set_transform(&state, rr);
|
||||
|
||||
m->lt = &layouts[0];
|
||||
for (ji = 0; ji < config.monitor_rules_count; ji++) {
|
||||
if (config.monitor_rules_count < 1)
|
||||
break;
|
||||
|
||||
r = &config.monitor_rules[ji];
|
||||
if (!r->name || regex_match(r->name, wlr_output->name)) {
|
||||
m->mfact = r->mfact;
|
||||
m->nmaster = r->nmaster;
|
||||
m->m.x = r->x;
|
||||
m->m.y = r->y;
|
||||
if (r->layout) {
|
||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||
if (strcmp(layouts[jk].name, r->layout) == 0) {
|
||||
m->lt = &layouts[jk];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regex_match(r->name, wlr_output->name)) {
|
||||
m->m.x = r->x == INT32_MAX ? INT32_MAX : r->x;
|
||||
m->m.y = r->y == INT32_MAX ? INT32_MAX : r->y;
|
||||
vrr = r->vrr >= 0 ? r->vrr : 0;
|
||||
scale = r->scale;
|
||||
rr = r->rr;
|
||||
|
||||
|
|
@ -2741,6 +2788,13 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
(int32_t)roundf(r->refresh * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
if (vrr) {
|
||||
enable_adaptive_sync(m, &state);
|
||||
} else {
|
||||
wlr_output_state_set_adaptive_sync_enabled(&state, false);
|
||||
}
|
||||
|
||||
wlr_output_state_set_scale(&state, r->scale);
|
||||
wlr_output_state_set_transform(&state, r->rr);
|
||||
break;
|
||||
|
|
@ -2755,10 +2809,6 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
wlr_output_state_set_mode(&state,
|
||||
wlr_output_preferred_mode(wlr_output));
|
||||
|
||||
if (adaptive_sync) {
|
||||
enable_adaptive_sync(m, &state);
|
||||
}
|
||||
|
||||
/* Set up event listeners */
|
||||
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
|
||||
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
|
||||
|
|
@ -2783,9 +2833,9 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
for (i = 0; i <= LENGTH(tags); i++) {
|
||||
m->pertag->nmasters[i] = m->nmaster;
|
||||
m->pertag->mfacts[i] = m->mfact;
|
||||
m->pertag->ltidxs[i] = m->lt;
|
||||
m->pertag->nmasters[i] = default_nmaster;
|
||||
m->pertag->mfacts[i] = default_mfact;
|
||||
m->pertag->ltidxs[i] = &layouts[0];
|
||||
}
|
||||
|
||||
// apply tag rule
|
||||
|
|
@ -2807,7 +2857,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
* output (such as DPI, scale factor, manufacturer, etc).
|
||||
*/
|
||||
m->scene_output = wlr_scene_output_create(scene, wlr_output);
|
||||
if (m->m.x == -1 && m->m.y == -1)
|
||||
if (m->m.x == INT32_MAX || m->m.y == INT32_MAX)
|
||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||
else
|
||||
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||
|
|
@ -2924,9 +2974,14 @@ void configure_pointer(struct libinput_device *device) {
|
|||
if (libinput_device_config_send_events_get_modes(device))
|
||||
libinput_device_config_send_events_set_mode(device, send_events_mode);
|
||||
|
||||
if (libinput_device_config_accel_is_available(device)) {
|
||||
if (accel_profile && libinput_device_config_accel_is_available(device)) {
|
||||
libinput_device_config_accel_set_profile(device, accel_profile);
|
||||
libinput_device_config_accel_set_speed(device, accel_speed);
|
||||
} else {
|
||||
// profile cannot be directly applied to 0, need to set to 1 first
|
||||
libinput_device_config_accel_set_profile(device, 1);
|
||||
libinput_device_config_accel_set_profile(device, 0);
|
||||
libinput_device_config_accel_set_speed(device, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3071,7 +3126,7 @@ void destroyidleinhibitor(struct wl_listener *listener, void *data) {
|
|||
free(listener);
|
||||
}
|
||||
|
||||
void destroylayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||
void destroylayernodenotify(struct wl_listener *listener, void *data) {
|
||||
LayerSurface *l = wl_container_of(listener, l, destroy);
|
||||
|
||||
wl_list_remove(&l->link);
|
||||
|
|
@ -3079,7 +3134,6 @@ void destroylayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&l->map.link);
|
||||
wl_list_remove(&l->unmap.link);
|
||||
wl_list_remove(&l->surface_commit.link);
|
||||
wlr_scene_node_destroy(&l->scene->node);
|
||||
wlr_scene_node_destroy(&l->popups->node);
|
||||
free(l);
|
||||
}
|
||||
|
|
@ -3772,6 +3826,12 @@ void init_client_properties(Client *c) {
|
|||
c->stack_proportion = 0.0f;
|
||||
c->next_in_stack = NULL;
|
||||
c->prev_in_stack = NULL;
|
||||
memcpy(c->opacity_animation.initial_border_color, bordercolor,
|
||||
sizeof(c->opacity_animation.initial_border_color));
|
||||
memcpy(c->opacity_animation.current_border_color, bordercolor,
|
||||
sizeof(c->opacity_animation.current_border_color));
|
||||
c->opacity_animation.initial_opacity = c->unfocused_opacity;
|
||||
c->opacity_animation.current_opacity = c->unfocused_opacity;
|
||||
}
|
||||
|
||||
void // old fix to 0.5
|
||||
|
|
@ -3988,6 +4048,30 @@ void motionabsolute(struct wl_listener *listener, void *data) {
|
|||
motionnotify(event->time_msec, &event->pointer->base, dx, dy, dx, dy);
|
||||
}
|
||||
|
||||
void resize_floating_window(Client *grabc) {
|
||||
int cdx = (int)round(cursor->x) - grabcx;
|
||||
int cdy = (int)round(cursor->y) - grabcy;
|
||||
|
||||
cdx = !(rzcorner & 1) && grabc->geom.width - 2 * (int)grabc->bw - cdx < 1
|
||||
? 0
|
||||
: cdx;
|
||||
cdy = !(rzcorner & 2) && grabc->geom.height - 2 * (int)grabc->bw - cdy < 1
|
||||
? 0
|
||||
: cdy;
|
||||
|
||||
const struct wlr_box box = {
|
||||
.x = grabc->geom.x + (rzcorner & 1 ? 0 : cdx),
|
||||
.y = grabc->geom.y + (rzcorner & 2 ? 0 : cdy),
|
||||
.width = grabc->geom.width + (rzcorner & 1 ? cdx : -cdx),
|
||||
.height = grabc->geom.height + (rzcorner & 2 ? cdy : -cdy)};
|
||||
|
||||
grabc->float_geom = box;
|
||||
|
||||
resize(grabc, box, 1);
|
||||
grabcx += cdx;
|
||||
grabcy += cdy;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
@ -4065,14 +4149,9 @@ void motionnotify(uint32_t time, struct wlr_input_device *device, double dx,
|
|||
} else if (cursor_mode == CurResize) {
|
||||
if (grabc->isfloating) {
|
||||
grabc->iscustomsize = 1;
|
||||
grabc->float_geom = (struct wlr_box){
|
||||
.x = grabc->geom.x,
|
||||
.y = grabc->geom.y,
|
||||
.width = (int32_t)round(cursor->x) - grabc->geom.x,
|
||||
.height = (int32_t)round(cursor->y) - grabc->geom.y};
|
||||
if (last_apply_drap_time == 0 ||
|
||||
time - last_apply_drap_time > drag_refresh_interval) {
|
||||
resize(grabc, grabc->float_geom, 1);
|
||||
time - last_apply_drap_time > drag_floating_refresh_interval) {
|
||||
resize_floating_window(grabc);
|
||||
last_apply_drap_time = time;
|
||||
}
|
||||
return;
|
||||
|
|
@ -4600,6 +4679,7 @@ setfloating(Client *c, int32_t floating) {
|
|||
|
||||
Client *fc = NULL;
|
||||
struct wlr_box target_box;
|
||||
int32_t old_floating_state = c->isfloating;
|
||||
c->isfloating = floating;
|
||||
bool window_size_outofrange = false;
|
||||
|
||||
|
|
@ -4669,7 +4749,7 @@ setfloating(Client *c, int32_t floating) {
|
|||
layers[c->isfloating ? LyrTop : LyrTile]);
|
||||
}
|
||||
|
||||
if (!c->isfloating) {
|
||||
if (!c->isfloating && old_floating_state) {
|
||||
set_size_per(c->mon, c);
|
||||
}
|
||||
|
||||
|
|
@ -4718,6 +4798,7 @@ void setmaximizescreen(Client *c, int32_t maximizescreen) {
|
|||
if (c->mon->isoverview)
|
||||
return;
|
||||
|
||||
int32_t old_maximizescreen_state = c->ismaximizescreen;
|
||||
c->ismaximizescreen = maximizescreen;
|
||||
|
||||
if (maximizescreen) {
|
||||
|
|
@ -4747,7 +4828,7 @@ void setmaximizescreen(Client *c, int32_t maximizescreen) {
|
|||
|
||||
wlr_scene_node_reparent(&c->scene->node,
|
||||
layers[c->isfloating ? LyrTop : LyrTile]);
|
||||
if (!c->ismaximizescreen) {
|
||||
if (!c->ismaximizescreen && old_maximizescreen_state) {
|
||||
set_size_per(c->mon, c);
|
||||
}
|
||||
|
||||
|
|
@ -4780,6 +4861,7 @@ void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自
|
|||
if (c->mon->isoverview)
|
||||
return;
|
||||
|
||||
int32_t old_fullscreen_state = c->isfullscreen;
|
||||
c->isfullscreen = fullscreen;
|
||||
|
||||
client_set_fullscreen(c, fullscreen);
|
||||
|
|
@ -4817,7 +4899,7 @@ void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自
|
|||
layers[fullscreen || c->isfloating ? LyrTop : LyrTile]);
|
||||
}
|
||||
|
||||
if (!c->isfullscreen) {
|
||||
if (!c->isfullscreen && old_fullscreen_state) {
|
||||
set_size_per(c->mon, c);
|
||||
}
|
||||
|
||||
|
|
@ -4946,6 +5028,7 @@ void setmon(Client *c, Monitor *m, uint32_t newtags, bool focus) {
|
|||
arrange(oldmon, false, false);
|
||||
if (m) {
|
||||
/* Make sure window actually overlaps with the monitor */
|
||||
reset_foreign_tolevel(c);
|
||||
resize(c, c->geom, 0);
|
||||
c->tags =
|
||||
newtags ? newtags
|
||||
|
|
@ -4957,21 +5040,6 @@ void setmon(Client *c, Monitor *m, uint32_t newtags, bool focus) {
|
|||
if (focus && !client_is_x11_popup(c)) {
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
|
||||
if (m) {
|
||||
|
||||
if (c->foreign_toplevel) {
|
||||
remove_foreign_topleve(c);
|
||||
}
|
||||
|
||||
add_foreign_toplevel(c);
|
||||
if (m->sel && m->sel->foreign_toplevel)
|
||||
wlr_foreign_toplevel_handle_v1_set_activated(
|
||||
m->sel->foreign_toplevel, false);
|
||||
if (c->foreign_toplevel)
|
||||
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
void setpsel(struct wl_listener *listener, void *data) {
|
||||
|
|
@ -5494,6 +5562,7 @@ void unmaplayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
LayerSurface *l = wl_container_of(listener, l, unmap);
|
||||
|
||||
l->mapped = 0;
|
||||
l->being_unmapped = true;
|
||||
|
||||
init_fadeout_layers(l);
|
||||
|
||||
|
|
@ -5505,6 +5574,9 @@ void unmaplayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||
focusclient(focustop(selmon), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
l->being_unmapped = false;
|
||||
wlr_scene_node_destroy(&l->shadow->node);
|
||||
l->shadow = NULL;
|
||||
}
|
||||
|
||||
void unmapnotify(struct wl_listener *listener, void *data) {
|
||||
|
|
@ -5722,7 +5794,8 @@ void updatemons(struct wl_listener *listener, void *data) {
|
|||
if (selmon && selmon->wlr_output->enabled) {
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!c->mon && client_surface(c)->mapped) {
|
||||
client_change_mon(c, selmon);
|
||||
c->mon = selmon;
|
||||
reset_foreign_tolevel(c);
|
||||
}
|
||||
}
|
||||
focusclient(focustop(selmon), 1);
|
||||
|
|
@ -6084,17 +6157,22 @@ int32_t main(int32_t argc, char *argv[]) {
|
|||
char *startup_cmd = NULL;
|
||||
int32_t c;
|
||||
|
||||
while ((c = getopt(argc, argv, "s:c:hdv")) != -1) {
|
||||
if (c == 's')
|
||||
while ((c = getopt(argc, argv, "s:c:hdvp")) != -1) {
|
||||
if (c == 's') {
|
||||
startup_cmd = optarg;
|
||||
else if (c == 'd')
|
||||
} else if (c == 'd') {
|
||||
log_level = WLR_DEBUG;
|
||||
else if (c == 'v')
|
||||
die("mango " VERSION);
|
||||
else if (c == 'c')
|
||||
} else if (c == 'v') {
|
||||
printf("mango " VERSION "\n");
|
||||
return EXIT_SUCCESS;
|
||||
} else if (c == 'c') {
|
||||
cli_config_path = optarg;
|
||||
else
|
||||
} else if (c == 'p') {
|
||||
parse_config();
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
if (optind < argc)
|
||||
goto usage;
|
||||
|
|
@ -6108,7 +6186,14 @@ int32_t main(int32_t argc, char *argv[]) {
|
|||
run(startup_cmd);
|
||||
cleanup();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
usage:
|
||||
die("Usage: %s [-v] [-d] [-c config file] [-s startup command]", argv[0]);
|
||||
printf("Usage: mango [OPTIONS]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -v Show mango version\n"
|
||||
" -d Enable debug log\n"
|
||||
" -c <file> Use custom configuration file\n"
|
||||
" -s <command> Execute startup command\n"
|
||||
" -p Check configuration file error\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue