From b9295e8cee8d3e057f92a9fea1523c379c298f03 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sat, 27 Aug 2022 16:29:23 -0500 Subject: sort client.h functions --- client.h | 132 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 64 insertions(+), 68 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index c54a2f3..5988db3 100644 --- a/client.h +++ b/client.h @@ -16,16 +16,6 @@ client_is_x11(Client *c) #endif } -static inline struct wlr_surface * -client_surface(Client *c) -{ -#ifdef XWAYLAND - if (client_is_x11(c)) - return c->surface.xwayland->surface; -#endif - return c->surface.xdg->surface; -} - static inline Client * client_from_wlr_surface(struct wlr_surface *s) { @@ -48,6 +38,56 @@ client_from_wlr_surface(struct wlr_surface *s) return NULL; } +static inline Client * +client_get_parent(Client *c) +{ + Client *p; +#ifdef XWAYLAND + if (client_is_x11(c) && c->surface.xwayland->parent) + return client_from_wlr_surface(c->surface.xwayland->parent->surface); +#endif + if (c->surface.xdg->toplevel->parent) + return client_from_wlr_surface(c->surface.xdg->toplevel->parent->surface); + + return NULL; +} + +static inline void +client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min) +{ + struct wlr_xdg_toplevel *toplevel; + struct wlr_xdg_toplevel_state *state; +#ifdef XWAYLAND + if (client_is_x11(c)) { + struct wlr_xwayland_surface_size_hints *size_hints; + size_hints = c->surface.xwayland->size_hints; + if (size_hints) { + max->width = size_hints->max_width; + max->height = size_hints->max_height; + min->width = size_hints->min_width; + min->height = size_hints->min_height; + } + return; + } +#endif + toplevel = c->surface.xdg->toplevel; + state = &toplevel->current; + max->width = state->max_width; + max->height = state->max_height; + min->width = state->min_width; + min->height = state->min_height; +} + +static inline struct wlr_surface * +client_surface(Client *c) +{ +#ifdef XWAYLAND + if (client_is_x11(c)) + return c->surface.xwayland->surface; +#endif + return c->surface.xdg->surface; +} + /* The others */ static inline void client_activate_surface(struct wlr_surface *s, int activated) @@ -103,32 +143,6 @@ client_get_geometry(Client *c, struct wlr_box *geom) wlr_xdg_surface_get_geometry(c->surface.xdg, geom); } -static inline void -client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min) -{ - struct wlr_xdg_toplevel *toplevel; - struct wlr_xdg_toplevel_state *state; -#ifdef XWAYLAND - if (client_is_x11(c)) { - struct wlr_xwayland_surface_size_hints *size_hints; - size_hints = c->surface.xwayland->size_hints; - if (size_hints) { - max->width = size_hints->max_width; - max->height = size_hints->max_height; - min->width = size_hints->min_width; - min->height = size_hints->min_height; - } - return; - } -#endif - toplevel = c->surface.xdg->toplevel; - state = &toplevel->current; - max->width = state->max_width; - max->height = state->max_height; - min->width = state->min_width; - min->height = state->min_height; -} - static inline const char * client_get_title(Client *c) { @@ -139,19 +153,6 @@ client_get_title(Client *c) return c->surface.xdg->toplevel->title; } -static inline Client * -client_get_parent(Client *c) -{ - Client *p; -#ifdef XWAYLAND - if (client_is_x11(c) && c->surface.xwayland->parent) - return client_from_wlr_surface(c->surface.xwayland->parent->surface); -#endif - if (c->surface.xdg->toplevel->parent) - return client_from_wlr_surface(c->surface.xdg->toplevel->parent->surface); - - return NULL; -} static inline int client_is_float_type(Client *c) @@ -171,16 +172,11 @@ client_is_float_type(Client *c) || surface->window_type[i] == netatom[NetWMWindowTypeToolbar] || surface->window_type[i] == netatom[NetWMWindowTypeUtility]) return 1; - - return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0) - && (min.width == max.width || min.height == max.height)) - || c->surface.xwayland->parent; } #endif - return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0) && (min.width == max.width || min.height == max.height)) - || c->surface.xdg->toplevel->parent; + || client_get_parent(c); } static inline int @@ -194,22 +190,23 @@ client_is_mapped(Client *c) } static inline int -client_wants_fullscreen(Client *c) +client_is_unmanaged(Client *c) { #ifdef XWAYLAND - if (client_is_x11(c)) - return c->surface.xwayland->fullscreen; + return c->type == X11Unmanaged; #endif - return c->surface.xdg->toplevel->requested.fullscreen; + return 0; } -static inline int -client_is_unmanaged(Client *c) +static inline void +client_restack_surface(Client *c) { #ifdef XWAYLAND - return c->type == X11Unmanaged; + if (client_is_x11(c)) + wlr_xwayland_surface_restack(c->surface.xwayland, NULL, + XCB_STACK_MODE_ABOVE); #endif - return 0; + return; } static inline void @@ -270,15 +267,14 @@ client_surface_at(Client *c, double cx, double cy, double *sx, double *sy) return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy); } -static inline void -client_restack_surface(Client *c) +static inline int +client_wants_fullscreen(Client *c) { #ifdef XWAYLAND if (client_is_x11(c)) - wlr_xwayland_surface_restack(c->surface.xwayland, NULL, - XCB_STACK_MODE_ABOVE); + return c->surface.xwayland->fullscreen; #endif - return; + return c->surface.xdg->toplevel->requested.fullscreen; } static inline void * -- cgit v1.2.3 From d738573e22649dfb01f70eca00cef221839c9efb Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sat, 27 Aug 2022 16:05:12 -0500 Subject: new function to notify keyboard enter --- client.h | 10 ++++++++++ dwl.c | 15 ++------------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 5988db3..a881131 100644 --- a/client.h +++ b/client.h @@ -198,6 +198,16 @@ client_is_unmanaged(Client *c) 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_restack_surface(Client *c) { diff --git a/dwl.c b/dwl.c index f76e30f..66aea65 100644 --- a/dwl.c +++ b/dwl.c @@ -590,7 +590,6 @@ arrangelayers(Monitor *m) ZWLR_LAYER_SHELL_V1_LAYER_TOP, }; LayerSurface *layersurface; - struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat); /* Arrange exclusive surfaces from top->bottom */ for (i = 3; i >= 0; i--) @@ -614,11 +613,7 @@ arrangelayers(Monitor *m) /* Deactivate the focused client. */ focusclient(NULL, 0); exclusive_focus = layersurface->layer_surface->surface; - if (kb) - wlr_seat_keyboard_notify_enter(seat, exclusive_focus, - kb->keycodes, kb->num_keycodes, &kb->modifiers); - else - wlr_seat_keyboard_notify_enter(seat, exclusive_focus, NULL, 0, NULL); + client_notify_enter(exclusive_focus, wlr_seat_get_keyboard(seat)); return; } } @@ -1117,7 +1112,6 @@ void focusclient(Client *c, int lift) { struct wlr_surface *old = seat->keyboard_state.focused_surface; - struct wlr_keyboard *kb; int i; /* Do not focus clients if a layer surface is focused */ if (exclusive_focus) @@ -1178,12 +1172,7 @@ focusclient(Client *c, int lift) } /* Have a client, so focus its top-level wlr_surface */ - kb = wlr_seat_get_keyboard(seat); - if (kb) - wlr_seat_keyboard_notify_enter(seat, client_surface(c), - kb->keycodes, kb->num_keycodes, &kb->modifiers); - else - wlr_seat_keyboard_notify_enter(seat, client_surface(c), NULL, 0, NULL); + client_notify_enter(client_surface(c), wlr_seat_get_keyboard(seat)); /* Activate the new client */ client_activate_surface(client_surface(c), 1); -- cgit v1.2.3 From 2385d826122d24b72cab2ce531ad538d87407622 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 20 Sep 2022 23:40:35 -0500 Subject: remove unused variables --- client.h | 2 -- dwl.c | 1 - 2 files changed, 3 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index a881131..4ecdd47 100644 --- a/client.h +++ b/client.h @@ -20,7 +20,6 @@ static inline Client * client_from_wlr_surface(struct wlr_surface *s) { struct wlr_xdg_surface *surface; - struct wlr_surface *parent; #ifdef XWAYLAND struct wlr_xwayland_surface *xsurface; @@ -41,7 +40,6 @@ client_from_wlr_surface(struct wlr_surface *s) static inline Client * client_get_parent(Client *c) { - Client *p; #ifdef XWAYLAND if (client_is_x11(c) && c->surface.xwayland->parent) return client_from_wlr_surface(c->surface.xwayland->parent->surface); diff --git a/dwl.c b/dwl.c index 270f8f0..6fbc771 100644 --- a/dwl.c +++ b/dwl.c @@ -922,7 +922,6 @@ createmon(struct wl_listener *listener, void *data) * monitor) becomes available. */ struct wlr_output *wlr_output = data; const MonitorRule *r; - Client *c; size_t i; Monitor *m = wlr_output->data = ecalloc(1, sizeof(*m)); m->wlr_output = wlr_output; -- cgit v1.2.3