opt: format code
fix: correct version message
This commit is contained in:
535
client.h
535
client.h
@@ -6,403 +6,366 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Leave these functions first; they're used in the others */
|
/* Leave these functions first; they're used in the others */
|
||||||
static inline int
|
static inline int client_is_x11(Client *c) {
|
||||||
client_is_x11(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
return c->type == X11;
|
return c->type == X11;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct wlr_surface *
|
static inline struct wlr_surface *client_surface(Client *c) {
|
||||||
client_surface(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return c->surface.xwayland->surface;
|
return c->surface.xwayland->surface;
|
||||||
#endif
|
#endif
|
||||||
return c->surface.xdg->surface;
|
return c->surface.xdg->surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
|
||||||
toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
|
LayerSurface **pl) {
|
||||||
{
|
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
|
||||||
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
|
struct wlr_surface *root_surface;
|
||||||
struct wlr_surface *root_surface;
|
struct wlr_layer_surface_v1 *layer_surface;
|
||||||
struct wlr_layer_surface_v1 *layer_surface;
|
Client *c = NULL;
|
||||||
Client *c = NULL;
|
LayerSurface *l = NULL;
|
||||||
LayerSurface *l = NULL;
|
int type = -1;
|
||||||
int type = -1;
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
struct wlr_xwayland_surface *xsurface;
|
struct wlr_xwayland_surface *xsurface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return -1;
|
return -1;
|
||||||
root_surface = wlr_surface_get_root_surface(s);
|
root_surface = wlr_surface_get_root_surface(s);
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) {
|
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) {
|
||||||
c = xsurface->data;
|
c = xsurface->data;
|
||||||
type = c->type;
|
type = c->type;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
if ((layer_surface =
|
||||||
l = layer_surface->data;
|
wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
||||||
type = LayerShell;
|
l = layer_surface->data;
|
||||||
goto end;
|
type = LayerShell;
|
||||||
}
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
|
xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
|
||||||
while (xdg_surface) {
|
while (xdg_surface) {
|
||||||
tmp_xdg_surface = NULL;
|
tmp_xdg_surface = NULL;
|
||||||
switch (xdg_surface->role) {
|
switch (xdg_surface->role) {
|
||||||
case WLR_XDG_SURFACE_ROLE_POPUP:
|
case WLR_XDG_SURFACE_ROLE_POPUP:
|
||||||
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
||||||
return -1;
|
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)
|
if (!tmp_xdg_surface)
|
||||||
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
||||||
|
|
||||||
xdg_surface = tmp_xdg_surface;
|
xdg_surface = tmp_xdg_surface;
|
||||||
break;
|
break;
|
||||||
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
||||||
c = xdg_surface->data;
|
c = xdg_surface->data;
|
||||||
type = c->type;
|
type = c->type;
|
||||||
goto end;
|
goto end;
|
||||||
case WLR_XDG_SURFACE_ROLE_NONE:
|
case WLR_XDG_SURFACE_ROLE_NONE:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (pl)
|
if (pl)
|
||||||
*pl = l;
|
*pl = l;
|
||||||
if (pc)
|
if (pc)
|
||||||
*pc = c;
|
*pc = c;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The others */
|
/* The others */
|
||||||
static inline void
|
static inline void client_activate_surface(struct wlr_surface *s,
|
||||||
client_activate_surface(struct wlr_surface *s, int activated)
|
int activated) {
|
||||||
{
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
struct wlr_xwayland_surface *xsurface;
|
struct wlr_xwayland_surface *xsurface;
|
||||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||||
wlr_xwayland_surface_activate(xsurface, activated);
|
wlr_xwayland_surface_activate(xsurface, activated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s)))
|
if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s)))
|
||||||
wlr_xdg_toplevel_set_activated(toplevel, activated);
|
wlr_xdg_toplevel_set_activated(toplevel, activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t
|
static inline uint32_t client_set_bounds(Client *c, int32_t width,
|
||||||
client_set_bounds(Client *c, int32_t width, int32_t height)
|
int32_t height) {
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0
|
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION &&
|
||||||
&& (c->bounds.width != width || c->bounds.height != height)) {
|
width >= 0 && height >= 0 &&
|
||||||
c->bounds.width = width;
|
(c->bounds.width != width || c->bounds.height != height)) {
|
||||||
c->bounds.height = height;
|
c->bounds.width = width;
|
||||||
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
c->bounds.height = height;
|
||||||
}
|
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *
|
static inline const char *client_get_appid(Client *c) {
|
||||||
client_get_appid(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return c->surface.xwayland->class;
|
return c->surface.xwayland->class;
|
||||||
#endif
|
#endif
|
||||||
return c->surface.xdg->toplevel->app_id;
|
return c->surface.xdg->toplevel->app_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_get_clip(Client *c, struct wlr_box *clip) {
|
||||||
client_get_clip(Client *c, struct wlr_box *clip)
|
struct wlr_box xdg_geom = {0};
|
||||||
{
|
*clip = (struct wlr_box){
|
||||||
struct wlr_box xdg_geom = {0};
|
.x = 0,
|
||||||
*clip = (struct wlr_box){
|
.y = 0,
|
||||||
.x = 0,
|
.width = c->geom.width - c->bw,
|
||||||
.y = 0,
|
.height = c->geom.height - c->bw,
|
||||||
.width = c->geom.width - c->bw,
|
};
|
||||||
.height = c->geom.height - c->bw,
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
|
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
|
||||||
clip->x = xdg_geom.x;
|
clip->x = xdg_geom.x;
|
||||||
clip->y = xdg_geom.y;
|
clip->y = xdg_geom.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
||||||
client_get_geometry(Client *c, struct wlr_box *geom)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
geom->x = c->surface.xwayland->x;
|
geom->x = c->surface.xwayland->x;
|
||||||
geom->y = c->surface.xwayland->y;
|
geom->y = c->surface.xwayland->y;
|
||||||
geom->width = c->surface.xwayland->width;
|
geom->width = c->surface.xwayland->width;
|
||||||
geom->height = c->surface.xwayland->height;
|
geom->height = c->surface.xwayland->height;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
|
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Client *
|
static inline Client *client_get_parent(Client *c) {
|
||||||
client_get_parent(Client *c)
|
Client *p = NULL;
|
||||||
{
|
|
||||||
Client *p = NULL;
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
if (c->surface.xwayland->parent)
|
if (c->surface.xwayland->parent)
|
||||||
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
|
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (c->surface.xdg->toplevel->parent)
|
if (c->surface.xdg->toplevel->parent)
|
||||||
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
|
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface,
|
||||||
return p;
|
&p, NULL);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_has_children(Client *c) {
|
||||||
client_has_children(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return !wl_list_empty(&c->surface.xwayland->children);
|
return !wl_list_empty(&c->surface.xwayland->children);
|
||||||
#endif
|
#endif
|
||||||
/* surface.xdg->link is never empty because it always contains at least the
|
/* surface.xdg->link is never empty because it always contains at least the
|
||||||
* surface itself. */
|
* surface itself. */
|
||||||
return wl_list_length(&c->surface.xdg->link) > 1;
|
return wl_list_length(&c->surface.xdg->link) > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *
|
static inline const char *client_get_title(Client *c) {
|
||||||
client_get_title(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return c->surface.xwayland->title;
|
return c->surface.xwayland->title;
|
||||||
#endif
|
#endif
|
||||||
return c->surface.xdg->toplevel->title;
|
return c->surface.xdg->toplevel->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_is_float_type(Client *c) {
|
||||||
client_is_float_type(Client *c)
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
{
|
struct wlr_xdg_toplevel_state state;
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
|
||||||
struct wlr_xdg_toplevel_state state;
|
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||||
size_t i;
|
size_t i;
|
||||||
if (surface->modal)
|
if (surface->modal)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < surface->window_type_len; i++)
|
for (i = 0; i < surface->window_type_len; i++)
|
||||||
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog]
|
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] ||
|
||||||
|| surface->window_type[i] == netatom[NetWMWindowTypeSplash]
|
surface->window_type[i] == netatom[NetWMWindowTypeSplash] ||
|
||||||
|| surface->window_type[i] == netatom[NetWMWindowTypeToolbar]
|
surface->window_type[i] == netatom[NetWMWindowTypeToolbar] ||
|
||||||
|| surface->window_type[i] == netatom[NetWMWindowTypeUtility])
|
surface->window_type[i] == netatom[NetWMWindowTypeUtility])
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
|
return size_hints && size_hints->min_width > 0 &&
|
||||||
&& (size_hints->max_width == size_hints->min_width
|
size_hints->min_height > 0 &&
|
||||||
|| size_hints->max_height == size_hints->min_height);
|
(size_hints->max_width == size_hints->min_width ||
|
||||||
}
|
size_hints->max_height == size_hints->min_height);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
toplevel = c->surface.xdg->toplevel;
|
toplevel = c->surface.xdg->toplevel;
|
||||||
state = toplevel->current;
|
state = toplevel->current;
|
||||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0
|
return toplevel->parent || (state.min_width != 0 && state.min_height != 0 &&
|
||||||
&& (state.min_width == state.max_width
|
(state.min_width == state.max_width ||
|
||||||
|| state.min_height == state.max_height));
|
state.min_height == state.max_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_is_rendered_on_mon(Client *c, Monitor *m) {
|
||||||
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.
|
||||||
/* This is needed for when you don't want to check formal assignment,
|
* Usually VISIBLEON suffices and is also faster. */
|
||||||
* but rather actual displaying of the pixels.
|
struct wlr_surface_output *s;
|
||||||
* Usually VISIBLEON suffices and is also faster. */
|
int unused_lx, unused_ly;
|
||||||
struct wlr_surface_output *s;
|
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
||||||
int unused_lx, unused_ly;
|
return 0;
|
||||||
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
wl_list_for_each(s, &client_surface(c)->current_outputs,
|
||||||
return 0;
|
link) if (s->output == m->wlr_output) return 1;
|
||||||
wl_list_for_each(s, &client_surface(c)->current_outputs, link)
|
return 0;
|
||||||
if (s->output == m->wlr_output)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_is_stopped(Client *c) {
|
||||||
client_is_stopped(Client *c)
|
int pid;
|
||||||
{
|
siginfo_t in = {0};
|
||||||
int pid;
|
|
||||||
siginfo_t in = {0};
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||||
if (waitid(P_PID, pid, &in, WNOHANG|WCONTINUED|WSTOPPED|WNOWAIT) < 0) {
|
if (waitid(P_PID, pid, &in, WNOHANG | WCONTINUED | WSTOPPED | WNOWAIT) < 0) {
|
||||||
/* This process is not our child process, while is very unluckely that
|
/* 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. */
|
* it is stopped, in order to do not skip frames assume that it is. */
|
||||||
if (errno == ECHILD)
|
if (errno == ECHILD)
|
||||||
return 1;
|
return 1;
|
||||||
} else if (in.si_pid) {
|
} else if (in.si_pid) {
|
||||||
if (in.si_code == CLD_STOPPED || in.si_code == CLD_TRAPPED)
|
if (in.si_code == CLD_STOPPED || in.si_code == CLD_TRAPPED)
|
||||||
return 1;
|
return 1;
|
||||||
if (in.si_code == CLD_CONTINUED)
|
if (in.si_code == CLD_CONTINUED)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_is_unmanaged(Client *c) {
|
||||||
client_is_unmanaged(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return c->surface.xwayland->override_redirect;
|
return c->surface.xwayland->override_redirect;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_notify_enter(struct wlr_surface *s,
|
||||||
client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
|
struct wlr_keyboard *kb) {
|
||||||
{
|
if (kb)
|
||||||
if (kb)
|
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes, kb->num_keycodes,
|
||||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
|
&kb->modifiers);
|
||||||
kb->num_keycodes, &kb->modifiers);
|
else
|
||||||
else
|
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_restack_surface(Client *c) {
|
||||||
client_restack_surface(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
|
wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
|
||||||
XCB_STACK_MODE_ABOVE);
|
XCB_STACK_MODE_ABOVE);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_send_close(Client *c) {
|
||||||
client_send_close(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
wlr_xwayland_surface_close(c->surface.xwayland);
|
wlr_xwayland_surface_close(c->surface.xwayland);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
|
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_set_border_color(Client *c,
|
||||||
client_set_border_color(Client *c, const float color[static 4])
|
const float color[static 4]) {
|
||||||
{
|
int i;
|
||||||
int i;
|
for (i = 0; i < 4; i++)
|
||||||
for (i = 0; i < 4; i++)
|
wlr_scene_rect_set_color(c->border[i], color);
|
||||||
wlr_scene_rect_set_color(c->border[i], color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
||||||
client_set_fullscreen(Client *c, int fullscreen)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
|
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t
|
static inline uint32_t client_set_size(Client *c, uint32_t width,
|
||||||
client_set_size(Client *c, uint32_t width, uint32_t height)
|
uint32_t height) {
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
wlr_xwayland_surface_configure(c->surface.xwayland,
|
wlr_xwayland_surface_configure(c->surface.xwayland, c->geom.x, c->geom.y,
|
||||||
c->geom.x, c->geom.y, width, height);
|
width, height);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width
|
if ((int32_t)width == c->surface.xdg->toplevel->current.width &&
|
||||||
&& (int32_t)height == c->surface.xdg->toplevel->current.height)
|
(int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||||
return 0;
|
return 0;
|
||||||
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width,
|
||||||
|
(int32_t)height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
||||||
client_set_tiled(Client *c, uint32_t edges)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||||
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||||
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
||||||
} else {
|
} else {
|
||||||
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE);
|
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel,
|
||||||
}
|
edges != WLR_EDGE_NONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void client_set_suspended(Client *c, int suspended) {
|
||||||
client_set_suspended(Client *c, int suspended)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_wants_focus(Client *c) {
|
||||||
client_wants_focus(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
return client_is_unmanaged(c)
|
return client_is_unmanaged(c) &&
|
||||||
&& wlr_xwayland_or_surface_wants_focus(c->surface.xwayland)
|
wlr_xwayland_or_surface_wants_focus(c->surface.xwayland) &&
|
||||||
&& wlr_xwayland_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
|
wlr_xwayland_icccm_input_model(c->surface.xwayland) !=
|
||||||
|
WLR_ICCCM_INPUT_MODEL_NONE;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int client_wants_fullscreen(Client *c) {
|
||||||
client_wants_fullscreen(Client *c)
|
|
||||||
{
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c))
|
if (client_is_x11(c))
|
||||||
return c->surface.xwayland->fullscreen;
|
return c->surface.xwayland->fullscreen;
|
||||||
#endif
|
#endif
|
||||||
return c->surface.xdg->toplevel->requested.fullscreen;
|
return c->surface.xdg->toplevel->requested.fullscreen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
project('maomao', ['c', 'cpp'],
|
project('maomao', ['c', 'cpp'],
|
||||||
version : '0.1'
|
version : '0.1.1'
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('protocols')
|
subdir('protocols')
|
||||||
|
|||||||
1305
parse_config.h
1305
parse_config.h
File diff suppressed because it is too large
Load Diff
135
preset_config.h
135
preset_config.h
@@ -1,89 +1,86 @@
|
|||||||
/* speedie's maomao config */
|
/* speedie's maomao config */
|
||||||
|
|
||||||
#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \
|
#define COLOR(hex) \
|
||||||
((hex >> 16) & 0xFF) / 255.0f, \
|
{((hex >> 24) & 0xFF) / 255.0f, ((hex >> 16) & 0xFF) / 255.0f, \
|
||||||
((hex >> 8) & 0xFF) / 255.0f, \
|
((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f}
|
||||||
(hex & 0xFF) / 255.0f }
|
|
||||||
|
|
||||||
/* animaion */
|
/* animaion */
|
||||||
char *animation_type = "slide"; //是否启用动画 //slide,zoom
|
char *animation_type = "slide"; // 是否启用动画 //slide,zoom
|
||||||
int animations = 1; //是否启用动画
|
int animations = 1; // 是否启用动画
|
||||||
char animation_fade_in = 1; // Enable animation fade in
|
char animation_fade_in = 1; // Enable animation fade in
|
||||||
float zoom_initial_ratio = 0.5; //动画起始窗口比例
|
float zoom_initial_ratio = 0.5; // 动画起始窗口比例
|
||||||
float fadein_begin_opacity = 0; // Begin opac window ratio for animations
|
float fadein_begin_opacity = 0; // Begin opac window ratio for animations
|
||||||
uint32_t animation_duration_move = 500; // Animation move speed
|
uint32_t animation_duration_move = 500; // Animation move speed
|
||||||
uint32_t animation_duration_open = 400; // Animation open speed
|
uint32_t animation_duration_open = 400; // Animation open speed
|
||||||
uint32_t animation_duration_tag = 300; // Animation tag speed
|
uint32_t animation_duration_tag = 300; // Animation tag speed
|
||||||
double animation_curve[4] = {0.46,1.0,0.29,0.99}; //动画曲线
|
double animation_curve[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
unsigned int axis_bind_apply_timeout = 100; //滚轮绑定动作的触发的时间间隔
|
unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
|
||||||
unsigned int focus_on_activate = 1; //收到窗口激活请求是否自动跳转聚焦
|
unsigned int focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦
|
||||||
unsigned int new_is_master = 1; //新窗口是否插在头部
|
unsigned int new_is_master = 1; // 新窗口是否插在头部
|
||||||
double default_mfact = 0.55f; // master 窗口比例
|
double default_mfact = 0.55f; // master 窗口比例
|
||||||
unsigned int default_nmaster = 1; //默认master数量
|
unsigned int default_nmaster = 1; // 默认master数量
|
||||||
/* logging */
|
/* logging */
|
||||||
int log_level = WLR_ERROR;
|
int log_level = WLR_ERROR;
|
||||||
unsigned int numlockon = 1; //是否打开右边小键盘
|
unsigned int numlockon = 1; // 是否打开右边小键盘
|
||||||
|
|
||||||
unsigned int ov_tab_mode = 0; // alt tab切换模式
|
|
||||||
unsigned int hotarea_size = 10; //热区大小,10x10
|
|
||||||
unsigned int enable_hotarea = 1; //是否启用鼠标热区
|
|
||||||
int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
|
||||||
int sloppyfocus = 1; /* focus follows mouse */
|
|
||||||
unsigned int gappih = 5; /* horiz inner gap between windows */
|
|
||||||
unsigned int gappiv = 5; /* vert inner gap between windows */
|
|
||||||
unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
|
||||||
unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
|
||||||
|
|
||||||
|
unsigned int ov_tab_mode = 0; // alt tab切换模式
|
||||||
|
unsigned int hotarea_size = 10; // 热区大小,10x10
|
||||||
|
unsigned int enable_hotarea = 1; // 是否启用鼠标热区
|
||||||
|
int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||||
|
int sloppyfocus = 1; /* focus follows mouse */
|
||||||
|
unsigned int gappih = 5; /* horiz inner gap between windows */
|
||||||
|
unsigned int gappiv = 5; /* vert inner gap between windows */
|
||||||
|
unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
||||||
|
unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
||||||
|
|
||||||
int scroller_structs = 20;
|
int scroller_structs = 20;
|
||||||
float scroller_default_proportion = 0.9;
|
float scroller_default_proportion = 0.9;
|
||||||
int scoller_focus_center = 0;
|
int scoller_focus_center = 0;
|
||||||
float scroller_proportion_preset[] = {0.5,0.9,1.0};
|
float scroller_proportion_preset[] = {0.5, 0.9, 1.0};
|
||||||
|
|
||||||
int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
|
int bypass_surface_visibility =
|
||||||
unsigned int borderpx = 4; /* border pixel of windows */
|
0; /* 1 means idle inhibitors will disable idle tracking even if it's
|
||||||
float rootcolor[] = COLOR(0x323232ff);
|
surface isn't visible */
|
||||||
float bordercolor[] = COLOR(0x444444ff);
|
unsigned int borderpx = 4; /* border pixel of windows */
|
||||||
float focuscolor[] = COLOR(0xc66b25ff);
|
float rootcolor[] = COLOR(0x323232ff);
|
||||||
float maxmizescreencolor[] = COLOR(0x89aa61ff);
|
float bordercolor[] = COLOR(0x444444ff);
|
||||||
float urgentcolor[] = COLOR(0xad401fff);
|
float focuscolor[] = COLOR(0xc66b25ff);
|
||||||
float scratchpadcolor[] = COLOR(0x516c93ff);
|
float maxmizescreencolor[] = COLOR(0x89aa61ff);
|
||||||
float globalcolor[] = COLOR(0xb153a7ff);
|
float urgentcolor[] = COLOR(0xad401fff);
|
||||||
|
float scratchpadcolor[] = COLOR(0x516c93ff);
|
||||||
|
float globalcolor[] = COLOR(0xb153a7ff);
|
||||||
// char *cursor_theme = "Bibata-Modern-Ice";
|
// char *cursor_theme = "Bibata-Modern-Ice";
|
||||||
|
|
||||||
int overviewgappi = 5; /* overview时 窗口与边缘 缝隙大小 */
|
int overviewgappi = 5; /* overview时 窗口与边缘 缝隙大小 */
|
||||||
int overviewgappo = 30; /* overview时 窗口与窗口 缝隙大小 */
|
int overviewgappo = 30; /* overview时 窗口与窗口 缝隙大小 */
|
||||||
|
|
||||||
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
/* To conform the xdg-protocol, set the alpha to zero to restore the old
|
||||||
float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
* behavior */
|
||||||
|
float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
||||||
|
|
||||||
int warpcursor = 1; /* Warp cursor to focused client */
|
int warpcursor = 1; /* Warp cursor to focused client */
|
||||||
|
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
Layout overviewlayout = { "", overview, "overview" };
|
Layout overviewlayout = {"", overview, "overview"};
|
||||||
|
|
||||||
Layout layouts[] = { //最少两个,不能删除少于两个
|
Layout layouts[] = {
|
||||||
/* symbol arrange function name */
|
// 最少两个,不能删除少于两个
|
||||||
{ "S", scroller, "scroller" }, //滚动布局
|
/* symbol arrange function name */
|
||||||
{ "T", tile, "tile" }, //堆栈布局
|
{"S", scroller, "scroller"}, // 滚动布局
|
||||||
{"G", grid, "grid"},
|
{"T", tile, "tile"}, // 堆栈布局
|
||||||
{"M",monocle,"monocle"},
|
{"G", grid, "grid"}, {"M", monocle, "monocle"},
|
||||||
{"D",dwindle,"dwindle"},
|
{"D", dwindle, "dwindle"}, {"P", spiral, "spiral"},
|
||||||
{"P",spiral,"spiral"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* keyboard */
|
/* keyboard */
|
||||||
struct xkb_rule_names xkb_rules = {
|
struct xkb_rule_names xkb_rules = {
|
||||||
/* can specify fields: rules, model, layout, variant, options */
|
/* can specify fields: rules, model, layout, variant, options */
|
||||||
/* example:
|
/* example:
|
||||||
.options = "ctrl:nocaps",
|
.options = "ctrl:nocaps",
|
||||||
*/
|
*/
|
||||||
.options = NULL,
|
.options = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
int repeat_rate = 25;
|
int repeat_rate = 25;
|
||||||
@@ -110,7 +107,8 @@ LIBINPUT_CONFIG_CLICK_METHOD_NONE
|
|||||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS
|
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS
|
||||||
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
|
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
|
||||||
*/
|
*/
|
||||||
enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
enum libinput_config_click_method click_method =
|
||||||
|
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||||
|
|
||||||
/* You can choose between:
|
/* You can choose between:
|
||||||
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
||||||
@@ -123,7 +121,8 @@ uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
|||||||
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
|
||||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
|
||||||
*/
|
*/
|
||||||
enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
|
enum libinput_config_accel_profile accel_profile =
|
||||||
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
|
||||||
double accel_speed = 0.0;
|
double accel_speed = 0.0;
|
||||||
/* You can choose between:
|
/* You can choose between:
|
||||||
LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
|
LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
|
||||||
@@ -135,21 +134,9 @@ enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
|||||||
#define MODKEY WLR_MODIFIER_ALT
|
#define MODKEY WLR_MODIFIER_ALT
|
||||||
|
|
||||||
static const char *tags[] = {
|
static const char *tags[] = {
|
||||||
"1",
|
"1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
"2",
|
|
||||||
"3",
|
|
||||||
"4",
|
|
||||||
"5",
|
|
||||||
"6",
|
|
||||||
"7",
|
|
||||||
"8",
|
|
||||||
"9",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const autostart[] = {
|
static const char *const autostart[] = {
|
||||||
"/bin/sh",
|
"/bin/sh", "-c", "~/.config/maomao/autostart.sh", NULL, NULL,
|
||||||
"-c",
|
|
||||||
"~/.config/maomao/autostart.sh",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
};
|
};
|
||||||
37
util.c
37
util.c
@@ -6,30 +6,27 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
void
|
void die(const char *fmt, ...) {
|
||||||
die(const char *fmt, ...) {
|
va_list ap;
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
if (fmt[0] && fmt[strlen(fmt) - 1] == ':') {
|
||||||
fputc(' ', stderr);
|
fputc(' ', stderr);
|
||||||
perror(NULL);
|
perror(NULL);
|
||||||
} else {
|
} else {
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *ecalloc(size_t nmemb, size_t size) {
|
||||||
ecalloc(size_t nmemb, size_t size)
|
void *p;
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if (!(p = calloc(nmemb, size)))
|
if (!(p = calloc(nmemb, size)))
|
||||||
die("calloc:");
|
die("calloc:");
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user