mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: optimize handle xdg commit request
This commit is contained in:
parent
6d08d4ca54
commit
f19790de45
1 changed files with 18 additions and 29 deletions
47
src/maomao.c
47
src/maomao.c
|
|
@ -2173,9 +2173,6 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
void commitnotify(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, commit);
|
||||
|
||||
if (!c->surface.xdg->initialized)
|
||||
return;
|
||||
|
||||
if (c->surface.xdg->initial_commit) {
|
||||
// xdg client will first enter this before mapnotify
|
||||
applyrules(c);
|
||||
|
|
@ -2184,12 +2181,18 @@ void commitnotify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
setmon(c, NULL, 0,
|
||||
true); /* Make sure to reapply rules in mapnotify() */
|
||||
wlr_xdg_toplevel_set_wm_capabilities(
|
||||
c->surface.xdg->toplevel,
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
|
||||
wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
|
||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
|
||||
WLR_EDGE_RIGHT);
|
||||
|
||||
uint32_t serial = wlr_xdg_surface_schedule_configure(c->surface.xdg);
|
||||
if (serial > 0) {
|
||||
c->configure_serial = serial;
|
||||
}
|
||||
|
||||
uint32_t wm_caps = WLR_XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU |
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE |
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN |
|
||||
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE;
|
||||
wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, wm_caps);
|
||||
|
||||
if (c->decoration)
|
||||
requestdecorationmode(&c->set_decoration_mode, c->decoration);
|
||||
return;
|
||||
|
|
@ -2202,28 +2205,14 @@ void commitnotify(struct wl_listener *listener, void *data) {
|
|||
if (c == grabc)
|
||||
return;
|
||||
|
||||
if (client_is_unmanaged(c))
|
||||
return;
|
||||
struct wlr_box *new_geo = &c->surface.xdg->geometry;
|
||||
bool need_resize = new_geo->width != c->geom.width - 2 * c->bw ||
|
||||
new_geo->height != c->geom.height - 2 * c->bw ||
|
||||
new_geo->x != 0 || new_geo->y != 0;
|
||||
|
||||
unsigned int serial = c->surface.xdg->current.configure_serial;
|
||||
if (!c->dirty || serial < c->configure_serial)
|
||||
return;
|
||||
|
||||
struct wlr_box geometry;
|
||||
client_get_geometry(c, &geometry);
|
||||
|
||||
if (geometry.width == c->geom.width - 2 * c->bw &&
|
||||
geometry.height == c->geom.height - 2 * c->bw) {
|
||||
c->dirty = false;
|
||||
return;
|
||||
if (need_resize) {
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
|
||||
if (geometry.width == c->animation.current.width - 2 * c->bw &&
|
||||
geometry.height == c->animation.current.height - 2 * c->bw) {
|
||||
return;
|
||||
}
|
||||
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
|
||||
void destroydecoration(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue