mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-01 22:58:44 -04:00
format code
This commit is contained in:
parent
b3ccf3b8b8
commit
7e66d5390e
8 changed files with 1085 additions and 1174 deletions
|
|
@ -6,410 +6,378 @@
|
|||
*/
|
||||
|
||||
/* Leave these functions first; they're used in the others */
|
||||
static inline int
|
||||
client_is_x11(Client *c)
|
||||
{
|
||||
static inline int client_is_x11(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
return c->type == X11;
|
||||
return c->type == X11;
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct wlr_surface *
|
||||
client_surface(Client *c)
|
||||
{
|
||||
static inline struct wlr_surface *client_surface(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->surface;
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->surface;
|
||||
#endif
|
||||
return c->surface.xdg->surface;
|
||||
return c->surface.xdg->surface;
|
||||
}
|
||||
|
||||
static inline int
|
||||
toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
|
||||
{
|
||||
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
|
||||
struct wlr_surface *root_surface;
|
||||
struct wlr_layer_surface_v1 *layer_surface;
|
||||
Client *c = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
int type = -1;
|
||||
static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
|
||||
LayerSurface **pl) {
|
||||
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
|
||||
struct wlr_surface *root_surface;
|
||||
struct wlr_layer_surface_v1 *layer_surface;
|
||||
Client *c = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
int type = -1;
|
||||
#ifdef XWAYLAND
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
#endif
|
||||
|
||||
if (!s)
|
||||
return -1;
|
||||
root_surface = wlr_surface_get_root_surface(s);
|
||||
if (!s)
|
||||
return -1;
|
||||
root_surface = wlr_surface_get_root_surface(s);
|
||||
|
||||
#ifdef XWAYLAND
|
||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) {
|
||||
c = xsurface->data;
|
||||
type = c->type;
|
||||
goto end;
|
||||
}
|
||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) {
|
||||
c = xsurface->data;
|
||||
type = c->type;
|
||||
goto end;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
||||
l = layer_surface->data;
|
||||
type = LayerShell;
|
||||
goto end;
|
||||
}
|
||||
if ((layer_surface =
|
||||
wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
||||
l = layer_surface->data;
|
||||
type = LayerShell;
|
||||
goto end;
|
||||
}
|
||||
|
||||
xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
|
||||
while (xdg_surface) {
|
||||
tmp_xdg_surface = NULL;
|
||||
switch (xdg_surface->role) {
|
||||
case WLR_XDG_SURFACE_ROLE_POPUP:
|
||||
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
||||
return -1;
|
||||
xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
|
||||
while (xdg_surface) {
|
||||
tmp_xdg_surface = NULL;
|
||||
switch (xdg_surface->role) {
|
||||
case WLR_XDG_SURFACE_ROLE_POPUP:
|
||||
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
||||
return -1;
|
||||
|
||||
tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
||||
tmp_xdg_surface =
|
||||
wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
||||
|
||||
if (!tmp_xdg_surface)
|
||||
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
||||
if (!tmp_xdg_surface)
|
||||
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
||||
|
||||
xdg_surface = tmp_xdg_surface;
|
||||
break;
|
||||
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
||||
c = xdg_surface->data;
|
||||
type = c->type;
|
||||
goto end;
|
||||
case WLR_XDG_SURFACE_ROLE_NONE:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
xdg_surface = tmp_xdg_surface;
|
||||
break;
|
||||
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
||||
c = xdg_surface->data;
|
||||
type = c->type;
|
||||
goto end;
|
||||
case WLR_XDG_SURFACE_ROLE_NONE:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (pl)
|
||||
*pl = l;
|
||||
if (pc)
|
||||
*pc = c;
|
||||
return type;
|
||||
if (pl)
|
||||
*pl = l;
|
||||
if (pc)
|
||||
*pc = c;
|
||||
return type;
|
||||
}
|
||||
|
||||
/* The others */
|
||||
static inline void
|
||||
client_activate_surface(struct wlr_surface *s, int activated)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
static inline void client_activate_surface(struct wlr_surface *s,
|
||||
int activated) {
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
wlr_xwayland_surface_activate(xsurface, activated);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s)))
|
||||
wlr_xdg_toplevel_set_activated(toplevel, activated);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
client_set_bounds(Client *c, int32_t width, int32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return 0;
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0
|
||||
&& (c->bounds.width != width || c->bounds.height != height)) {
|
||||
c->bounds.width = width;
|
||||
c->bounds.height = height;
|
||||
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
client_get_appid(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken";
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_get_pid(Client *c)
|
||||
{
|
||||
pid_t pid;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->pid;
|
||||
#endif
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
return pid;
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_get_clip(Client *c, struct wlr_box *clip)
|
||||
{
|
||||
*clip = (struct wlr_box){
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = c->geom.width - c->bw,
|
||||
.height = c->geom.height - c->bw,
|
||||
};
|
||||
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return;
|
||||
#endif
|
||||
|
||||
clip->x = c->surface.xdg->geometry.x;
|
||||
clip->y = c->surface.xdg->geometry.y;
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_get_geometry(Client *c, struct wlr_box *geom)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
geom->x = c->surface.xwayland->x;
|
||||
geom->y = c->surface.xwayland->y;
|
||||
geom->width = c->surface.xwayland->width;
|
||||
geom->height = c->surface.xwayland->height;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
*geom = c->surface.xdg->geometry;
|
||||
}
|
||||
|
||||
static inline Client *
|
||||
client_get_parent(Client *c)
|
||||
{
|
||||
Client *p = NULL;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
if (c->surface.xwayland->parent)
|
||||
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
if (c->surface.xdg->toplevel->parent)
|
||||
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_has_children(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return !wl_list_empty(&c->surface.xwayland->children);
|
||||
#endif
|
||||
/* surface.xdg->link is never empty because it always contains at least the
|
||||
* surface itself. */
|
||||
return wl_list_length(&c->surface.xdg->link) > 1;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
client_get_title(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title : "broken";
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_is_float_type(Client *c)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
struct wlr_xdg_toplevel_state state;
|
||||
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||
if (surface->modal)
|
||||
return 1;
|
||||
|
||||
if (wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
|
||||
&& (size_hints->max_width == size_hints->min_width
|
||||
|| size_hints->max_height == size_hints->min_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
toplevel = c->surface.xdg->toplevel;
|
||||
state = toplevel->current;
|
||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0
|
||||
&& (state.min_width == state.max_width
|
||||
|| state.min_height == state.max_height));
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_is_rendered_on_mon(Client *c, Monitor *m)
|
||||
{
|
||||
/* This is needed for when you don't want to check formal assignment,
|
||||
* but rather actual displaying of the pixels.
|
||||
* Usually VISIBLEON suffices and is also faster. */
|
||||
struct wlr_surface_output *s;
|
||||
int unused_lx, unused_ly;
|
||||
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
||||
return 0;
|
||||
wl_list_for_each(s, &client_surface(c)->current_outputs, link)
|
||||
if (s->output == m->wlr_output)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_is_stopped(Client *c)
|
||||
{
|
||||
int pid;
|
||||
siginfo_t in = {0};
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
if (waitid(P_PID, pid, &in, WNOHANG|WCONTINUED|WSTOPPED|WNOWAIT) < 0) {
|
||||
/* This process is not our child process, while is very unluckely that
|
||||
* it is stopped, in order to do not skip frames assume that it is. */
|
||||
if (errno == ECHILD)
|
||||
return 1;
|
||||
} else if (in.si_pid) {
|
||||
if (in.si_code == CLD_STOPPED || in.si_code == CLD_TRAPPED)
|
||||
return 1;
|
||||
if (in.si_code == CLD_CONTINUED)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_is_unmanaged(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->override_redirect;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
|
||||
{
|
||||
if (kb)
|
||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
|
||||
kb->num_keycodes, &kb->modifiers);
|
||||
else
|
||||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_send_close(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_close(c->surface.xwayland);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_set_border_color(Client *c, const float color[static 4])
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
wlr_scene_rect_set_color(c->border[i], color);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_set_fullscreen(Client *c, int fullscreen)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_set_scale(struct wlr_surface *s, float scale)
|
||||
{
|
||||
wlr_fractional_scale_v1_notify_scale(s, scale);
|
||||
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland,
|
||||
c->geom.x + c->bw, c->geom.y + c->bw, width, height);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width
|
||||
&& (int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
return 0;
|
||||
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_set_tiled(Client *c, uint32_t edges)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
||||
edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
||||
return;
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
wlr_xwayland_surface_activate(xsurface, activated);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
||||
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
||||
}
|
||||
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE);
|
||||
if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s)))
|
||||
wlr_xdg_toplevel_set_activated(toplevel, activated);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_set_suspended(Client *c, int suspended)
|
||||
{
|
||||
static inline uint32_t client_set_bounds(Client *c, int32_t width,
|
||||
int32_t height) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return;
|
||||
if (client_is_x11(c))
|
||||
return 0;
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION &&
|
||||
width >= 0 && height >= 0 &&
|
||||
(c->bounds.width != width || c->bounds.height != height)) {
|
||||
c->bounds.width = width;
|
||||
c->bounds.height = height;
|
||||
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline const char *client_get_appid(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id
|
||||
: "broken";
|
||||
}
|
||||
|
||||
static inline int client_get_pid(Client *c) {
|
||||
pid_t pid;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->pid;
|
||||
#endif
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
return pid;
|
||||
}
|
||||
|
||||
static inline void client_get_clip(Client *c, struct wlr_box *clip) {
|
||||
*clip = (struct wlr_box){
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = c->geom.width - c->bw,
|
||||
.height = c->geom.height - c->bw,
|
||||
};
|
||||
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return;
|
||||
#endif
|
||||
|
||||
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
||||
clip->x = c->surface.xdg->geometry.x;
|
||||
clip->y = c->surface.xdg->geometry.y;
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_wants_focus(Client *c)
|
||||
{
|
||||
static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
||||
#ifdef XWAYLAND
|
||||
return client_is_unmanaged(c)
|
||||
&& wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland)
|
||||
&& wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
if (client_is_x11(c)) {
|
||||
geom->x = c->surface.xwayland->x;
|
||||
geom->y = c->surface.xwayland->y;
|
||||
geom->width = c->surface.xwayland->width;
|
||||
geom->height = c->surface.xwayland->height;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
*geom = c->surface.xdg->geometry;
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_wants_fullscreen(Client *c)
|
||||
{
|
||||
static inline Client *client_get_parent(Client *c) {
|
||||
Client *p = NULL;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->fullscreen;
|
||||
if (client_is_x11(c)) {
|
||||
if (c->surface.xwayland->parent)
|
||||
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->requested.fullscreen;
|
||||
if (c->surface.xdg->toplevel->parent)
|
||||
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface,
|
||||
&p, NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline int client_has_children(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return !wl_list_empty(&c->surface.xwayland->children);
|
||||
#endif
|
||||
/* surface.xdg->link is never empty because it always contains at least the
|
||||
* surface itself. */
|
||||
return wl_list_length(&c->surface.xdg->link) > 1;
|
||||
}
|
||||
|
||||
static inline const char *client_get_title(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title
|
||||
: "broken";
|
||||
}
|
||||
|
||||
static inline int client_is_float_type(Client *c) {
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
struct wlr_xdg_toplevel_state state;
|
||||
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||
if (surface->modal)
|
||||
return 1;
|
||||
|
||||
if (wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG) ||
|
||||
wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH) ||
|
||||
wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR) ||
|
||||
wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return size_hints && size_hints->min_width > 0 &&
|
||||
size_hints->min_height > 0 &&
|
||||
(size_hints->max_width == size_hints->min_width ||
|
||||
size_hints->max_height == size_hints->min_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
toplevel = c->surface.xdg->toplevel;
|
||||
state = toplevel->current;
|
||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0 &&
|
||||
(state.min_width == state.max_width ||
|
||||
state.min_height == state.max_height));
|
||||
}
|
||||
|
||||
static inline int client_is_rendered_on_mon(Client *c, Monitor *m) {
|
||||
/* This is needed for when you don't want to check formal assignment,
|
||||
* but rather actual displaying of the pixels.
|
||||
* Usually VISIBLEON suffices and is also faster. */
|
||||
struct wlr_surface_output *s;
|
||||
int unused_lx, unused_ly;
|
||||
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
||||
return 0;
|
||||
wl_list_for_each(s, &client_surface(c)->current_outputs,
|
||||
link) if (s->output == m->wlr_output) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int client_is_stopped(Client *c) {
|
||||
int pid;
|
||||
siginfo_t in = {0};
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
if (waitid(P_PID, pid, &in, WNOHANG | WCONTINUED | WSTOPPED | WNOWAIT) < 0) {
|
||||
/* This process is not our child process, while is very unluckely that
|
||||
* it is stopped, in order to do not skip frames assume that it is. */
|
||||
if (errno == ECHILD)
|
||||
return 1;
|
||||
} else if (in.si_pid) {
|
||||
if (in.si_code == CLD_STOPPED || in.si_code == CLD_TRAPPED)
|
||||
return 1;
|
||||
if (in.si_code == CLD_CONTINUED)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int client_is_unmanaged(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->override_redirect;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void client_notify_enter(struct wlr_surface *s,
|
||||
struct wlr_keyboard *kb) {
|
||||
if (kb)
|
||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes, kb->num_keycodes,
|
||||
&kb->modifiers);
|
||||
else
|
||||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static inline void client_send_close(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_close(c->surface.xwayland);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
|
||||
}
|
||||
|
||||
static inline void client_set_border_color(Client *c,
|
||||
const float color[static 4]) {
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
wlr_scene_rect_set_color(c->border[i], color);
|
||||
}
|
||||
|
||||
static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
||||
}
|
||||
|
||||
static inline void client_set_scale(struct wlr_surface *s, float scale) {
|
||||
wlr_fractional_scale_v1_notify_scale(s, scale);
|
||||
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
||||
}
|
||||
|
||||
static inline uint32_t client_set_size(Client *c, uint32_t width,
|
||||
uint32_t height) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland, c->geom.x + c->bw,
|
||||
c->geom.y + c->bw, width, height);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width &&
|
||||
(int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
return 0;
|
||||
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width,
|
||||
(int32_t)height);
|
||||
}
|
||||
|
||||
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_maximized(
|
||||
c->surface.xwayland, edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
||||
}
|
||||
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel,
|
||||
edges != WLR_EDGE_NONE);
|
||||
}
|
||||
|
||||
static inline void client_set_suspended(Client *c, int suspended) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return;
|
||||
#endif
|
||||
|
||||
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
||||
}
|
||||
|
||||
static inline int client_wants_focus(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
return client_is_unmanaged(c) &&
|
||||
wlr_xwayland_surface_override_redirect_wants_focus(
|
||||
c->surface.xwayland) &&
|
||||
wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) !=
|
||||
WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int client_wants_fullscreen(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->fullscreen;
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->requested.fullscreen;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,40 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* Based on labwc (https://github.com/labwc/labwc) */
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "mem.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "mem.h"
|
||||
|
||||
static void
|
||||
die_if_null(void *ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
perror("Failed to allocate memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
static void die_if_null(void *ptr) {
|
||||
if (!ptr) {
|
||||
perror("Failed to allocate memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
xzalloc(size_t size)
|
||||
{
|
||||
if (!size) {
|
||||
return NULL;
|
||||
}
|
||||
void *ptr = calloc(1, size);
|
||||
die_if_null(ptr);
|
||||
return ptr;
|
||||
void *xzalloc(size_t size) {
|
||||
if (!size) {
|
||||
return NULL;
|
||||
}
|
||||
void *ptr = calloc(1, size);
|
||||
die_if_null(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(void *ptr, size_t size)
|
||||
{
|
||||
if (!size) {
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
ptr = realloc(ptr, size);
|
||||
die_if_null(ptr);
|
||||
return ptr;
|
||||
void *xrealloc(void *ptr, size_t size) {
|
||||
if (!size) {
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
ptr = realloc(ptr, size);
|
||||
die_if_null(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
char *
|
||||
xstrdup(const char *str)
|
||||
{
|
||||
assert(str);
|
||||
char *copy = strdup(str);
|
||||
die_if_null(copy);
|
||||
return copy;
|
||||
char *xstrdup(const char *str) {
|
||||
assert(str);
|
||||
char *copy = strdup(str);
|
||||
die_if_null(copy);
|
||||
return copy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ void *xzalloc(size_t size);
|
|||
* struct wlr_box *box = znew(*box);
|
||||
* char *buf = znew_n(char, 80);
|
||||
*/
|
||||
#define znew(expr) ((__typeof__(expr) *)xzalloc(sizeof(expr)))
|
||||
#define znew_n(expr, n) ((__typeof__(expr) *)xzalloc((n) * sizeof(expr)))
|
||||
#define znew(expr) ((__typeof__(expr) *)xzalloc(sizeof(expr)))
|
||||
#define znew_n(expr, n) ((__typeof__(expr) *)xzalloc((n) * sizeof(expr)))
|
||||
|
||||
/*
|
||||
* As defined in FreeBSD.
|
||||
|
|
@ -49,16 +49,20 @@ char *xstrdup(const char *str);
|
|||
* Same as ptr = xstrdup(str) but free
|
||||
* <ptr> before assigning the result.
|
||||
*/
|
||||
#define xstrdup_replace(ptr, str) do { \
|
||||
free(ptr); (ptr) = xstrdup(str); \
|
||||
} while (0)
|
||||
#define xstrdup_replace(ptr, str) \
|
||||
do { \
|
||||
free(ptr); \
|
||||
(ptr) = xstrdup(str); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Frees memory pointed to by <ptr> and sets <ptr> to NULL.
|
||||
* Does nothing if <ptr> is already NULL.
|
||||
*/
|
||||
#define zfree(ptr) do { \
|
||||
free(ptr); (ptr) = NULL; \
|
||||
} while (0)
|
||||
#define zfree(ptr) \
|
||||
do { \
|
||||
free(ptr); \
|
||||
(ptr) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#endif /* LABWC_MEM_H */
|
||||
|
|
|
|||
|
|
@ -1,51 +1,47 @@
|
|||
/* See LICENSE.dwm file for copyright and license details. */
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void
|
||||
die(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
void die(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
if (fmt[0] && fmt[strlen(fmt) - 1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *p;
|
||||
void *ecalloc(size_t nmemb, size_t size) {
|
||||
void *p;
|
||||
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
|
||||
int
|
||||
fd_set_nonblock(int fd) {
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
if (flags < 0) {
|
||||
perror("fcntl(F_GETFL):");
|
||||
return -1;
|
||||
}
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||
perror("fcntl(F_SETFL):");
|
||||
return -1;
|
||||
}
|
||||
int fd_set_nonblock(int fd) {
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
if (flags < 0) {
|
||||
perror("fcntl(F_GETFL):");
|
||||
return -1;
|
||||
}
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||
perror("fcntl(F_SETFL):");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ typedef struct {
|
|||
} AxisBinding;
|
||||
|
||||
typedef struct {
|
||||
unsigned int mod;
|
||||
unsigned int motion;
|
||||
unsigned int fingers_count;
|
||||
void (*func)(const Arg *);
|
||||
Arg arg;
|
||||
unsigned int mod;
|
||||
unsigned int motion;
|
||||
unsigned int fingers_count;
|
||||
void (*func)(const Arg *);
|
||||
Arg arg;
|
||||
} GestureBinding;
|
||||
typedef struct {
|
||||
int animations;
|
||||
|
|
@ -258,20 +258,31 @@ long int parse_color(const char *hex_str) {
|
|||
xkb_keysym_t normalize_keysym(xkb_keysym_t sym) {
|
||||
// 首先转换为小写
|
||||
sym = xkb_keysym_to_lower(sym);
|
||||
|
||||
|
||||
// 将数字小键盘键转换为普通数字键
|
||||
switch (sym) {
|
||||
case XKB_KEY_KP_0: return XKB_KEY_0;
|
||||
case XKB_KEY_KP_1: return XKB_KEY_1;
|
||||
case XKB_KEY_KP_2: return XKB_KEY_2;
|
||||
case XKB_KEY_KP_3: return XKB_KEY_3;
|
||||
case XKB_KEY_KP_4: return XKB_KEY_4;
|
||||
case XKB_KEY_KP_5: return XKB_KEY_5;
|
||||
case XKB_KEY_KP_6: return XKB_KEY_6;
|
||||
case XKB_KEY_KP_7: return XKB_KEY_7;
|
||||
case XKB_KEY_KP_8: return XKB_KEY_8;
|
||||
case XKB_KEY_KP_9: return XKB_KEY_9;
|
||||
default: return sym;
|
||||
case XKB_KEY_KP_0:
|
||||
return XKB_KEY_0;
|
||||
case XKB_KEY_KP_1:
|
||||
return XKB_KEY_1;
|
||||
case XKB_KEY_KP_2:
|
||||
return XKB_KEY_2;
|
||||
case XKB_KEY_KP_3:
|
||||
return XKB_KEY_3;
|
||||
case XKB_KEY_KP_4:
|
||||
return XKB_KEY_4;
|
||||
case XKB_KEY_KP_5:
|
||||
return XKB_KEY_5;
|
||||
case XKB_KEY_KP_6:
|
||||
return XKB_KEY_6;
|
||||
case XKB_KEY_KP_7:
|
||||
return XKB_KEY_7;
|
||||
case XKB_KEY_KP_8:
|
||||
return XKB_KEY_8;
|
||||
case XKB_KEY_KP_9:
|
||||
return XKB_KEY_9;
|
||||
default:
|
||||
return sym;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -469,13 +480,13 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value) {
|
|||
func = spawn;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "spawn_on_empty") == 0) {
|
||||
char cmd[256],tag_num[256];
|
||||
char cmd[256], tag_num[256];
|
||||
if (sscanf(arg_value, "%255[^,],%255s", cmd, tag_num) == 2) {
|
||||
func = spawn_on_empty;
|
||||
(*arg).v = strdup(cmd); // 注意:之后需要释放这个内存
|
||||
(*arg).ui = 1 << (atoi(tag_num) - 1);
|
||||
} else {
|
||||
fprintf(stderr, "Error: Invalid value format: %s\n", arg_value);
|
||||
fprintf(stderr, "Error: Invalid value format: %s\n", arg_value);
|
||||
}
|
||||
} else if (strcmp(func_name, "quit") == 0) {
|
||||
func = quit;
|
||||
|
|
@ -524,9 +535,11 @@ void parse_config_line(Config *config, const char *line) {
|
|||
if (strcmp(key, "animations") == 0) {
|
||||
config->animations = atoi(value);
|
||||
} else if (strcmp(key, "animation_type_open") == 0) {
|
||||
snprintf(config->animation_type_open, sizeof(config->animation_type_open), "%.9s", value); // string limit to 9 char
|
||||
snprintf(config->animation_type_open, sizeof(config->animation_type_open),
|
||||
"%.9s", value); // string limit to 9 char
|
||||
} else if (strcmp(key, "animation_type_close") == 0) {
|
||||
snprintf(config->animation_type_close, sizeof(config->animation_type_close), "%.9s", value); // string limit to 9 char
|
||||
snprintf(config->animation_type_close, sizeof(config->animation_type_close),
|
||||
"%.9s", value); // string limit to 9 char
|
||||
} else if (strcmp(key, "animation_fade_in") == 0) {
|
||||
config->animation_fade_in = atoi(value);
|
||||
} else if (strcmp(key, "tag_animation_direction") == 0) {
|
||||
|
|
@ -569,9 +582,11 @@ void parse_config_line(Config *config, const char *line) {
|
|||
}
|
||||
} else if (strcmp(key, "animation_curve_close") == 0) {
|
||||
if (sscanf(value, "%lf,%lf,%lf,%lf", &config->animation_curve_close[0],
|
||||
&config->animation_curve_close[1], &config->animation_curve_close[2],
|
||||
&config->animation_curve_close[1],
|
||||
&config->animation_curve_close[2],
|
||||
&config->animation_curve_close[3]) != 4) {
|
||||
fprintf(stderr, "Error: Invalid animation_curve_close format: %s\n", value);
|
||||
fprintf(stderr, "Error: Invalid animation_curve_close format: %s\n",
|
||||
value);
|
||||
}
|
||||
} else if (strcmp(key, "scroller_structs") == 0) {
|
||||
config->scroller_structs = atoi(value);
|
||||
|
|
@ -1041,16 +1056,19 @@ void parse_config_line(Config *config, const char *line) {
|
|||
realloc(config->gesture_bindings,
|
||||
(config->gesture_bindings_count + 1) * sizeof(GestureBinding));
|
||||
if (!config->gesture_bindings) {
|
||||
fprintf(stderr, "Error: Failed to allocate memory for axis gesturebind\n");
|
||||
fprintf(stderr,
|
||||
"Error: Failed to allocate memory for axis gesturebind\n");
|
||||
return;
|
||||
}
|
||||
|
||||
GestureBinding *binding = &config->gesture_bindings[config->gesture_bindings_count];
|
||||
GestureBinding *binding =
|
||||
&config->gesture_bindings[config->gesture_bindings_count];
|
||||
memset(binding, 0, sizeof(GestureBinding));
|
||||
|
||||
char mod_str[256], motion_str[256], fingers_count_str[256] , func_name[256], arg_value[256] = "none";
|
||||
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, motion_str, fingers_count_str, func_name,
|
||||
arg_value) < 4) {
|
||||
char mod_str[256], motion_str[256], fingers_count_str[256], func_name[256],
|
||||
arg_value[256] = "none";
|
||||
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^\n]", mod_str, motion_str,
|
||||
fingers_count_str, func_name, arg_value) < 4) {
|
||||
fprintf(stderr, "Error: Invalid gesturebind format: %s\n", value);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1191,11 +1209,12 @@ void override_config(void) {
|
|||
memcpy(animation_curve_tag, config.animation_curve_tag,
|
||||
sizeof(animation_curve_tag));
|
||||
memcpy(animation_curve_close, config.animation_curve_close,
|
||||
sizeof(animation_curve_close));
|
||||
sizeof(animation_curve_close));
|
||||
|
||||
scroller_structs = config.scroller_structs;
|
||||
scroller_default_proportion = config.scroller_default_proportion;
|
||||
scroller_default_proportion_single = config.scroller_default_proportion_single;
|
||||
scroller_default_proportion_single =
|
||||
config.scroller_default_proportion_single;
|
||||
scroller_focus_center = config.scroller_focus_center;
|
||||
focus_cross_monitor = config.focus_cross_monitor;
|
||||
focus_cross_tag = config.focus_cross_tag;
|
||||
|
|
@ -1247,50 +1266,61 @@ void override_config(void) {
|
|||
|
||||
void set_value_default() {
|
||||
/* animaion */
|
||||
config.animations = animations; // 是否启用动画
|
||||
config.animation_fade_in = animation_fade_in; // Enable animation fade in
|
||||
config.animations = animations; // 是否启用动画
|
||||
config.animation_fade_in = animation_fade_in; // Enable animation fade in
|
||||
config.tag_animation_direction = tag_animation_direction; // 标签动画方向
|
||||
config.zoom_initial_ratio = zoom_initial_ratio; // 动画起始窗口比例
|
||||
config.fadein_begin_opacity = fadein_begin_opacity; // Begin opac window ratio for animations
|
||||
config.zoom_initial_ratio = zoom_initial_ratio; // 动画起始窗口比例
|
||||
config.fadein_begin_opacity =
|
||||
fadein_begin_opacity; // Begin opac window ratio for animations
|
||||
config.fadeout_begin_opacity = fadeout_begin_opacity;
|
||||
config.animation_duration_move = animation_duration_move; // Animation move speed
|
||||
config.animation_duration_open = animation_duration_open; // Animation open speed
|
||||
config.animation_duration_tag = animation_duration_tag; // Animation tag speed
|
||||
config.animation_duration_close = animation_duration_close; // Animation tag speed
|
||||
config.animation_duration_move =
|
||||
animation_duration_move; // Animation move speed
|
||||
config.animation_duration_open =
|
||||
animation_duration_open; // Animation open speed
|
||||
config.animation_duration_tag = animation_duration_tag; // Animation tag speed
|
||||
config.animation_duration_close =
|
||||
animation_duration_close; // Animation tag speed
|
||||
|
||||
/* appearance */
|
||||
config.axis_bind_apply_timeout = axis_bind_apply_timeout; // 滚轮绑定动作的触发的时间间隔
|
||||
config.focus_on_activate = focus_on_activate; // 收到窗口激活请求是否自动跳转聚焦
|
||||
config.new_is_master = new_is_master; // 新窗口是否插在头部
|
||||
config.default_mfact = default_mfact; // master 窗口比例
|
||||
config.default_smfact = default_smfact; // 第一个stack比例
|
||||
config.default_nmaster = default_nmaster; // 默认master数量
|
||||
config.axis_bind_apply_timeout =
|
||||
axis_bind_apply_timeout; // 滚轮绑定动作的触发的时间间隔
|
||||
config.focus_on_activate =
|
||||
focus_on_activate; // 收到窗口激活请求是否自动跳转聚焦
|
||||
config.new_is_master = new_is_master; // 新窗口是否插在头部
|
||||
config.default_mfact = default_mfact; // master 窗口比例
|
||||
config.default_smfact = default_smfact; // 第一个stack比例
|
||||
config.default_nmaster = default_nmaster; // 默认master数量
|
||||
|
||||
config.numlockon = numlockon; // 是否打开右边小键盘
|
||||
|
||||
config.ov_tab_mode = ov_tab_mode; // alt tab切换模式
|
||||
config.hotarea_size = hotarea_size; // 热区大小,10x10
|
||||
config.ov_tab_mode = ov_tab_mode; // alt tab切换模式
|
||||
config.hotarea_size = hotarea_size; // 热区大小,10x10
|
||||
config.enable_hotarea = enable_hotarea; // 是否启用鼠标热区
|
||||
config.smartgaps = smartgaps; /* 1 means no outer gap when there is only one window */
|
||||
config.smartgaps =
|
||||
smartgaps; /* 1 means no outer gap when there is only one window */
|
||||
config.sloppyfocus = sloppyfocus; /* focus follows mouse */
|
||||
config.gappih = gappih; /* horiz inner gap between windows */
|
||||
config.gappiv = gappiv; /* vert inner gap between windows */
|
||||
config.gappoh = gappoh; /* horiz outer gap between windows and screen edge */
|
||||
config.gappov = gappov; /* vert outer gap between windows and screen edge */
|
||||
config.gappih = gappih; /* horiz inner gap between windows */
|
||||
config.gappiv = gappiv; /* vert inner gap between windows */
|
||||
config.gappoh = gappoh; /* horiz outer gap between windows and screen edge */
|
||||
config.gappov = gappov; /* vert outer gap between windows and screen edge */
|
||||
|
||||
config.scroller_structs = scroller_structs;
|
||||
config.scroller_default_proportion = scroller_default_proportion;
|
||||
config.scroller_default_proportion_single = scroller_default_proportion_single;
|
||||
config.scroller_default_proportion_single =
|
||||
scroller_default_proportion_single;
|
||||
config.scroller_focus_center = scroller_focus_center;
|
||||
config.scroller_prefer_center = scroller_prefer_center;
|
||||
config.focus_cross_monitor = focus_cross_monitor;
|
||||
config.focus_cross_tag = focus_cross_tag;
|
||||
config.swipe_min_threshold = swipe_min_threshold;
|
||||
|
||||
config.bypass_surface_visibility = bypass_surface_visibility; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
|
||||
config.bypass_surface_visibility =
|
||||
bypass_surface_visibility; /* 1 means idle inhibitors will disable idle
|
||||
tracking even if it's surface isn't visible
|
||||
*/
|
||||
|
||||
config.borderpx = borderpx;
|
||||
config.overviewgappi = overviewgappi; /* overview时 窗口与边缘 缝隙大小 */
|
||||
config.overviewgappi = overviewgappi; /* overview时 窗口与边缘 缝隙大小 */
|
||||
config.overviewgappo = overviewgappo; /* overview时 窗口与窗口 缝隙大小 */
|
||||
|
||||
config.warpcursor = warpcursor; /* Warp cursor to focused client */
|
||||
|
|
@ -1315,7 +1345,7 @@ void set_value_default() {
|
|||
memcpy(config.animation_curve_tag, animation_curve_tag,
|
||||
sizeof(animation_curve_tag));
|
||||
memcpy(config.animation_curve_close, animation_curve_close,
|
||||
sizeof(animation_curve_close));
|
||||
sizeof(animation_curve_close));
|
||||
|
||||
memcpy(config.rootcolor, rootcolor, sizeof(rootcolor));
|
||||
memcpy(config.bordercolor, bordercolor, sizeof(bordercolor));
|
||||
|
|
@ -1328,27 +1358,27 @@ void set_value_default() {
|
|||
}
|
||||
|
||||
void set_default_key_bindings(Config *config) {
|
||||
// 计算默认按键绑定的数量
|
||||
size_t default_key_bindings_count =
|
||||
sizeof(default_key_bindings) / sizeof(KeyBinding);
|
||||
// 计算默认按键绑定的数量
|
||||
size_t default_key_bindings_count =
|
||||
sizeof(default_key_bindings) / sizeof(KeyBinding);
|
||||
|
||||
// 重新分配内存以容纳新的默认按键绑定
|
||||
config->key_bindings =
|
||||
realloc(config->key_bindings,
|
||||
(config->key_bindings_count + default_key_bindings_count) *
|
||||
sizeof(KeyBinding));
|
||||
if (!config->key_bindings) {
|
||||
return;
|
||||
}
|
||||
// 重新分配内存以容纳新的默认按键绑定
|
||||
config->key_bindings =
|
||||
realloc(config->key_bindings,
|
||||
(config->key_bindings_count + default_key_bindings_count) *
|
||||
sizeof(KeyBinding));
|
||||
if (!config->key_bindings) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 将默认按键绑定复制到配置的按键绑定数组中
|
||||
for (size_t i = 0; i < default_key_bindings_count; i++) {
|
||||
config->key_bindings[config->key_bindings_count + i] =
|
||||
default_key_bindings[i];
|
||||
}
|
||||
// 将默认按键绑定复制到配置的按键绑定数组中
|
||||
for (size_t i = 0; i < default_key_bindings_count; i++) {
|
||||
config->key_bindings[config->key_bindings_count + i] =
|
||||
default_key_bindings[i];
|
||||
}
|
||||
|
||||
// 更新按键绑定的总数
|
||||
config->key_bindings_count += default_key_bindings_count;
|
||||
// 更新按键绑定的总数
|
||||
config->key_bindings_count += default_key_bindings_count;
|
||||
}
|
||||
|
||||
void parse_config(void) {
|
||||
|
|
|
|||
|
|
@ -5,22 +5,22 @@
|
|||
((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f}
|
||||
|
||||
/* animaion */
|
||||
char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom
|
||||
char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom
|
||||
int animations = 1; // 是否启用动画
|
||||
char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom
|
||||
char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom
|
||||
int animations = 1; // 是否启用动画
|
||||
int tag_animation_direction = HORIZONTAL; // 标签动画方向
|
||||
char animation_fade_in = 1; // Enable animation fade in
|
||||
float zoom_initial_ratio = 0.5; // 动画起始窗口比例
|
||||
char animation_fade_in = 1; // Enable animation fade in
|
||||
float zoom_initial_ratio = 0.5; // 动画起始窗口比例
|
||||
float fadein_begin_opacity = 0.5; // Begin opac window ratio for animations
|
||||
float fadeout_begin_opacity = 0.5; // Begin opac window ratio for animations
|
||||
uint32_t animation_duration_move = 500; // Animation move speed
|
||||
uint32_t animation_duration_open = 400; // Animation open speed
|
||||
uint32_t animation_duration_tag = 300; // Animation tag speed
|
||||
uint32_t animation_duration_close = 300; // Animation close speed
|
||||
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_tag[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_tag[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||
|
||||
/* appearance */
|
||||
unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
|
||||
|
|
@ -32,7 +32,7 @@ unsigned int default_nmaster = 1; // 默认master数量
|
|||
/* logging */
|
||||
int log_level = WLR_ERROR;
|
||||
unsigned int numlockon = 1; // 是否打开右边小键盘
|
||||
unsigned int capslock = 0; // 是否启用快捷键
|
||||
unsigned int capslock = 0; // 是否启用快捷键
|
||||
|
||||
unsigned int ov_tab_mode = 0; // alt tab切换模式
|
||||
unsigned int hotarea_size = 10; // 热区大小,10x10
|
||||
|
|
@ -54,7 +54,6 @@ int focus_cross_tag = 0;
|
|||
|
||||
unsigned int swipe_min_threshold = 20;
|
||||
|
||||
|
||||
int bypass_surface_visibility =
|
||||
0; /* 1 means idle inhibitors will disable idle tracking even if it's
|
||||
surface isn't visible */
|
||||
|
|
|
|||
97
src/maomao.c
97
src/maomao.c
|
|
@ -78,8 +78,8 @@
|
|||
#include <xcb/xcb_icccm.h>
|
||||
#endif
|
||||
|
||||
#include "dwl-ipc-unstable-v2-protocol.h"
|
||||
#include "common/util.h"
|
||||
#include "dwl-ipc-unstable-v2-protocol.h"
|
||||
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
||||
|
||||
/* macros */
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
#define BAKED_POINTS_COUNT 256
|
||||
|
||||
/* enums */
|
||||
enum { VERTICAL, HORIZONTAL};
|
||||
enum { VERTICAL, HORIZONTAL };
|
||||
enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT };
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
|
|
@ -1341,10 +1341,10 @@ pid_t getparentprocess(pid_t p) {
|
|||
|
||||
// 检查fscanf返回值,确保成功读取了1个参数
|
||||
if (fscanf(f, "%*u %*s %*c %u", &v) != 1) {
|
||||
fclose(f);
|
||||
return 0;
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
|
||||
return (pid_t)v;
|
||||
|
|
@ -1560,8 +1560,9 @@ applyrulesgeom(Client *c) {
|
|||
break;
|
||||
r = &config.window_rules[ji];
|
||||
if ((r->title && strstr(title, r->title) && !r->id) ||
|
||||
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||
(r->id && strstr(appid, r->id) && r->title && strstr(title, r->title))) {
|
||||
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||
(r->id && strstr(appid, r->id) && r->title &&
|
||||
strstr(title, r->title))) {
|
||||
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
||||
c->geom.height = r->height > 0 ? r->height : c->geom.height;
|
||||
// 重新计算居中的坐标
|
||||
|
|
@ -1597,8 +1598,9 @@ applyrules(Client *c) {
|
|||
r = &config.window_rules[ji];
|
||||
|
||||
if ((r->title && strstr(title, r->title) && !r->id) ||
|
||||
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||
(r->id && strstr(appid, r->id) && r->title && strstr(title, r->title))) {
|
||||
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||
(r->id && strstr(appid, r->id) && r->title &&
|
||||
strstr(title, r->title))) {
|
||||
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
|
||||
c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow;
|
||||
c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating;
|
||||
|
|
@ -1691,11 +1693,9 @@ arrange(Monitor *m, bool want_animation) {
|
|||
wlr_scene_node_set_enabled(&c->scene->node, true);
|
||||
}
|
||||
client_set_suspended(c, false);
|
||||
if (!c->animation.from_rule &&
|
||||
want_animation &&
|
||||
m->pertag->prevtag != 0 &&
|
||||
m->pertag->curtag != 0 &&
|
||||
animations && !c->animation.running) {
|
||||
if (!c->animation.from_rule && want_animation &&
|
||||
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations &&
|
||||
!c->animation.running) {
|
||||
c->animation.tagining = true;
|
||||
if (m->pertag->curtag > m->pertag->prevtag) {
|
||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
||||
|
|
@ -1706,12 +1706,12 @@ arrange(Monitor *m, bool want_animation) {
|
|||
: c->animation.current.y;
|
||||
|
||||
} else {
|
||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
||||
? c->animation.current.x
|
||||
: m->m.x - c->geom.width;
|
||||
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
||||
? m->m.y - c->geom.height
|
||||
: c->animation.current.y;
|
||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
||||
? c->animation.current.x
|
||||
: m->m.x - c->geom.width;
|
||||
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
||||
? m->m.y - c->geom.height
|
||||
: c->animation.current.y;
|
||||
}
|
||||
} else {
|
||||
c->animainit_geom.x = c->animation.current.x;
|
||||
|
|
@ -1725,28 +1725,27 @@ arrange(Monitor *m, bool want_animation) {
|
|||
|
||||
} else {
|
||||
if ((c->tags & (1 << (selmon->pertag->prevtag - 1))) &&
|
||||
m->pertag->prevtag != 0 &&
|
||||
m->pertag->curtag != 0 && animations) {
|
||||
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
|
||||
c->animation.tagouting = true;
|
||||
c->animation.tagining = false;
|
||||
if (m->pertag->curtag > m->pertag->prevtag) {
|
||||
c->pending = c->geom;
|
||||
c->pending.x = tag_animation_direction == VERTICAL
|
||||
? c->animation.current.x
|
||||
: c->mon->m.x - c->geom.width;
|
||||
? c->animation.current.x
|
||||
: c->mon->m.x - c->geom.width;
|
||||
c->pending.y = tag_animation_direction == VERTICAL
|
||||
? c->mon->m.y - c->geom.height
|
||||
: c->animation.current.y;
|
||||
|
||||
? c->mon->m.y - c->geom.height
|
||||
: c->animation.current.y;
|
||||
|
||||
resize(c, c->geom, 0);
|
||||
} else {
|
||||
c->pending = c->geom;
|
||||
c->pending.x = tag_animation_direction == VERTICAL
|
||||
? c->animation.current.x
|
||||
: c->mon->m.x + c->mon->m.width;
|
||||
? c->animation.current.x
|
||||
: c->mon->m.x + c->mon->m.width;
|
||||
c->pending.y = tag_animation_direction == VERTICAL
|
||||
? c->mon->m.y + c->mon->m.height
|
||||
: c->animation.current.y;
|
||||
? c->mon->m.y + c->mon->m.height
|
||||
: c->animation.current.y;
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2302,7 +2301,7 @@ buttonpress(struct wl_listener *listener, void *data) {
|
|||
wlr_seat_pointer_clear_focus(seat);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
/* Drop the window off on its new monitor */
|
||||
if(grabc == selmon->sel){
|
||||
if (grabc == selmon->sel) {
|
||||
selmon->sel = NULL;
|
||||
}
|
||||
selmon = xytomon(cursor->x, cursor->y);
|
||||
|
|
@ -2590,7 +2589,8 @@ void client_commit(Client *c) {
|
|||
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->initialized)
|
||||
return;
|
||||
|
||||
if (c->surface.xdg->initial_commit) {
|
||||
// xdg client will first enter this before mapnotify
|
||||
|
|
@ -2603,7 +2603,7 @@ void commitnotify(struct wl_listener *listener, void *data) {
|
|||
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);
|
||||
WLR_EDGE_RIGHT);
|
||||
if (c->decoration)
|
||||
requestdecorationmode(&c->set_decoration_mode, c->decoration);
|
||||
return;
|
||||
|
|
@ -2620,23 +2620,24 @@ void commitnotify(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
|
||||
uint32_t serial = c->surface.xdg->current.configure_serial;
|
||||
if(!c->dirty || serial < c->configure_serial) return;
|
||||
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) {
|
||||
geometry.height == c->geom.height - 2 * c->bw) {
|
||||
c->dirty = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (geometry.width == c->animation.current.width - 2 * c->bw &&
|
||||
geometry.height == c->animation.current.height - 2 * c->bw) {
|
||||
return;
|
||||
}
|
||||
|
||||
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
|
||||
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
|
||||
}
|
||||
|
||||
void destroydecoration(struct wl_listener *listener, void *data) {
|
||||
|
|
@ -3691,7 +3692,7 @@ keybinding(uint32_t mods, xkb_keysym_t sym) {
|
|||
break;
|
||||
k = &config.key_bindings[ji];
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod) &&
|
||||
normalize_keysym(sym) == normalize_keysym(k->keysym) && k->func) {
|
||||
normalize_keysym(sym) == normalize_keysym(k->keysym) && k->func) {
|
||||
k->func(&k->arg);
|
||||
handled = 1;
|
||||
}
|
||||
|
|
@ -3728,8 +3729,9 @@ bool keypressglobal(struct wlr_surface *last_surface,
|
|||
title = client_get_title(c);
|
||||
|
||||
if ((r->title && strstr(title, r->title) && !r->id) ||
|
||||
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||
(r->id && strstr(appid, r->id) && r->title && strstr(title, r->title))) {
|
||||
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||
(r->id && strstr(appid, r->id) && r->title &&
|
||||
strstr(title, r->title))) {
|
||||
reset = true;
|
||||
wlr_seat_keyboard_enter(seat, client_surface(c), keycodes, 0,
|
||||
&keyboard->modifiers);
|
||||
|
|
@ -3831,7 +3833,7 @@ void keypress(struct wl_listener *listener, void *data) {
|
|||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||
/* Pass unhandled keycodes along to the client. */
|
||||
wlr_seat_keyboard_notify_key(seat, event->time_msec, event->keycode,
|
||||
event->state);
|
||||
event->state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3845,7 +3847,7 @@ void keypressmod(struct wl_listener *listener, void *data) {
|
|||
/* Send modifiers to the client. */
|
||||
wlr_seat_keyboard_notify_modifiers(seat,
|
||||
&group->wlr_group->keyboard.modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
|
||||
|
|
@ -4798,7 +4800,8 @@ void resize(Client *c, struct wlr_box geo, int interact) {
|
|||
bbox = interact ? &sgeom : &c->mon->w;
|
||||
|
||||
if (strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name,
|
||||
"scroller") == 0 && !c->isfloating) {
|
||||
"scroller") == 0 &&
|
||||
!c->isfloating) {
|
||||
c->geom = geo;
|
||||
c->geom.width = MAX(1 + 2 * (int)c->bw, c->geom.width);
|
||||
c->geom.height = MAX(1 + 2 * (int)c->bw, c->geom.height);
|
||||
|
|
@ -6506,10 +6509,10 @@ void unmapnotify(struct wl_listener *listener, void *data) {
|
|||
if (!m->wlr_output->enabled) {
|
||||
continue;
|
||||
}
|
||||
if(c == m->sel){
|
||||
if (c == m->sel) {
|
||||
m->sel = NULL;
|
||||
}
|
||||
if(c == m->prevsel){
|
||||
if (c == m->prevsel) {
|
||||
m->prevsel = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -7326,7 +7329,7 @@ void sethints(struct wl_listener *listener, void *data) {
|
|||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
printstatus();
|
||||
|
||||
if (c->isurgent && surface && surface->mapped)
|
||||
if (c->isurgent && surface && surface->mapped)
|
||||
client_set_border_color(c, urgentcolor);
|
||||
}
|
||||
|
||||
|
|
|
|||
1123
src/text_input/ime.h
1123
src/text_input/ime.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue