mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
Basic client-side decorations
This commit is contained in:
parent
2fb2ce403e
commit
f0d50cb57d
2 changed files with 19 additions and 1 deletions
|
|
@ -17,7 +17,22 @@ static void free_xdg_decoration_mode(struct wl_listener *listener, void *data)
|
|||
static void handle_xdg_decoration_mode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_xdg_toplevel_decoration_v1 *toplevel_decoration = data;
|
||||
struct wb_decoration *decoration = wl_container_of(listener, decoration, request_mode);
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(toplevel_decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE);
|
||||
if (decoration->server)
|
||||
{
|
||||
struct wb_view *view = wl_container_of(decoration->server->views.next, view, link);
|
||||
struct wlr_box geo_box;
|
||||
wlr_xdg_surface_get_geometry(toplevel_decoration->surface, &geo_box);
|
||||
/* TODO: Figure out how to get the actual height of the CSD
|
||||
* titlebar, which may or may not be 30px.
|
||||
* Logically, geo_box.height should have the height of the
|
||||
* decoration, but for some reason, it's 0. */
|
||||
/* view->y += geo_box.height; */
|
||||
view->y = view->y > 0 ? view->y : (geo_box.height > 0 ? geo_box.height : 30);
|
||||
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
|
||||
wlr_xdg_toplevel_set_size(view->xdg_surface, geo_box.width - view->x, geo_box.height - view->y);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_new_xdg_toplevel_decoration(struct wl_listener *listener, void *data)
|
||||
|
|
@ -33,6 +48,9 @@ static void handle_new_xdg_toplevel_decoration(struct wl_listener *listener, voi
|
|||
wl_signal_add(&toplevel_decoration->events.request_mode, &decoration->request_mode);
|
||||
decoration->mode_destroy.notify = free_xdg_decoration_mode;
|
||||
wl_signal_add(&toplevel_decoration->events.destroy, &decoration->mode_destroy);
|
||||
/* TODO: Only call when the user's settings specify to always apply
|
||||
* decorations */
|
||||
handle_xdg_decoration_mode(&decoration->request_mode, toplevel_decoration);
|
||||
}
|
||||
|
||||
void init_xdg_decoration(struct wb_server *server)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
void focus_view(struct wb_view *view, struct wlr_surface *surface) {
|
||||
/* Note: this function only deals with keyboard focus. */
|
||||
if (view == NULL || surface == NULL) {
|
||||
if (view == NULL || surface == NULL || !wlr_surface_is_xdg_surface(surface)) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(surface);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue