tie xdg_toplevel_decorations to Client
a xdg_toplevel can only have one xdg_toplevel_decoration so there is no need to have a new struct for decorations
This commit is contained in:
parent
396840cdf2
commit
e39d931430
1 changed files with 28 additions and 31 deletions
59
dwl.c
59
dwl.c
|
@ -111,6 +111,7 @@ typedef struct {
|
|||
struct wlr_xdg_surface *xdg;
|
||||
struct wlr_xwayland_surface *xwayland;
|
||||
} surface;
|
||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||
struct wl_listener commit;
|
||||
struct wl_listener map;
|
||||
struct wl_listener maximize;
|
||||
|
@ -118,6 +119,8 @@ typedef struct {
|
|||
struct wl_listener destroy;
|
||||
struct wl_listener set_title;
|
||||
struct wl_listener fullscreen;
|
||||
struct wl_listener set_decoration_mode;
|
||||
struct wl_listener destroy_decoration;
|
||||
struct wlr_box prev; /* layout-relative, includes border */
|
||||
struct wlr_box bounds;
|
||||
#ifdef XWAYLAND
|
||||
|
@ -133,11 +136,6 @@ typedef struct {
|
|||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
struct wl_listener request_mode;
|
||||
struct wl_listener destroy;
|
||||
} Decoration;
|
||||
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
xkb_keysym_t keysym;
|
||||
|
@ -256,6 +254,7 @@ static void createmon(struct wl_listener *listener, void *data);
|
|||
static void createnotify(struct wl_listener *listener, void *data);
|
||||
static void createpointer(struct wlr_pointer *pointer);
|
||||
static void cursorframe(struct wl_listener *listener, void *data);
|
||||
static void destroydecoration(struct wl_listener *listener, void *data);
|
||||
static void destroydragicon(struct wl_listener *listener, void *data);
|
||||
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
|
||||
static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
|
@ -264,14 +263,12 @@ static void destroylocksurface(struct wl_listener *listener, void *data);
|
|||
static void destroynotify(struct wl_listener *listener, void *data);
|
||||
static void destroysessionlock(struct wl_listener *listener, void *data);
|
||||
static void destroysessionmgr(struct wl_listener *listener, void *data);
|
||||
static void destroyxdeco(struct wl_listener *listener, void *data);
|
||||
static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void getxdecomode(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
|
@ -297,6 +294,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface,
|
|||
static void printstatus(void);
|
||||
static void quit(const Arg *arg);
|
||||
static void rendermon(struct wl_listener *listener, void *data);
|
||||
static void requestdecorationmode(struct wl_listener *listener, void *data);
|
||||
static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void requestmonstate(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
|
@ -743,13 +741,14 @@ commitnotify(struct wl_listener *listener, void *data)
|
|||
void
|
||||
createdecoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data;
|
||||
Decoration *d = wlr_deco->data = calloc(1, sizeof(*d));
|
||||
struct wlr_xdg_toplevel_decoration_v1 *deco = data;
|
||||
Client *c = deco->toplevel->base->data;
|
||||
c->decoration = deco;
|
||||
|
||||
LISTEN(&wlr_deco->events.request_mode, &d->request_mode, getxdecomode);
|
||||
LISTEN(&wlr_deco->events.destroy, &d->destroy, destroyxdeco);
|
||||
LISTEN(&deco->events.request_mode, &c->set_decoration_mode, requestdecorationmode);
|
||||
LISTEN(&deco->events.destroy, &c->destroy_decoration, destroydecoration);
|
||||
|
||||
getxdecomode(&d->request_mode, wlr_deco);
|
||||
requestdecorationmode(&c->set_decoration_mode, deco);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1017,6 +1016,15 @@ cursorframe(struct wl_listener *listener, void *data)
|
|||
wlr_seat_pointer_notify_frame(seat);
|
||||
}
|
||||
|
||||
void
|
||||
destroydecoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, destroy_decoration);
|
||||
|
||||
wl_list_remove(&c->destroy_decoration.link);
|
||||
wl_list_remove(&c->set_decoration_mode.link);
|
||||
}
|
||||
|
||||
void
|
||||
destroydragicon(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
@ -1131,17 +1139,6 @@ destroysessionmgr(struct wl_listener *listener, void *data)
|
|||
wl_list_remove(&listener->link);
|
||||
}
|
||||
|
||||
void
|
||||
destroyxdeco(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data;
|
||||
Decoration *d = wlr_deco->data;
|
||||
|
||||
wl_list_remove(&d->destroy.link);
|
||||
wl_list_remove(&d->request_mode.link);
|
||||
free(d);
|
||||
}
|
||||
|
||||
Monitor *
|
||||
dirtomon(enum wlr_direction dir)
|
||||
{
|
||||
|
@ -1292,14 +1289,6 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
|||
setfullscreen(c, client_wants_fullscreen(c));
|
||||
}
|
||||
|
||||
void
|
||||
getxdecomode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data;
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(wlr_deco,
|
||||
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
|
@ -1903,6 +1892,14 @@ skip:
|
|||
wlr_output_state_finish(&pending);
|
||||
}
|
||||
|
||||
void
|
||||
requestdecorationmode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_decoration_mode);
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(c->decoration,
|
||||
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
|
||||
void
|
||||
requeststartdrag(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue