-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathxsplash.c
84 lines (73 loc) · 1.77 KB
/
xsplash.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "shod.h"
/* create new splash screen */
static struct Splash *
splashnew(Window win, int w, int h)
{
struct Splash *splash;
splash = emalloc(sizeof(*splash));
*splash = (struct Splash){
.obj.win = win,
.obj.class = splash_class,
.w = w,
.h = h,
};
XMapWindow(dpy, win);
TAILQ_INSERT_HEAD(&wm.splashq, (struct Object *)splash, entry);
return splash;
}
/* center splash screen on monitor and raise it above other windows */
void
splashplace(struct Monitor *mon, struct Splash *splash)
{
fitmonitor(mon, &splash->x, &splash->y, &splash->w, &splash->h, 0.5);
splash->x = mon->wx + (mon->ww - splash->w) / 2;
splash->y = mon->wy + (mon->wh - splash->h) / 2;
XMoveWindow(dpy, splash->obj.win, splash->x, splash->y);
}
/* (un)hide splash screen */
void
splashhide(struct Splash *splash, int hide)
{
if (hide)
unmapwin(splash->obj.win);
else
mapwin(splash->obj.win);
}
void
splashrise(struct Splash *splash)
{
Window wins[2];
wins[1] = splash->obj.win;
wins[0] = wm.layers[LAYER_NORMAL].frame;
XRestackWindows(dpy, wins, 2);
}
static void
manage(struct Tab *tab, struct Monitor *mon, int desk, Window win,
Window leader, XRectangle rect, enum State state)
{
struct Splash *splash;
(void)tab;
(void)leader;
(void)state;
splash = splashnew(win, rect.width, rect.height);
splash->mon = mon;
splash->desk = desk;
splashplace(mon, splash);
splashrise(splash);
splashhide(splash, REMOVE);
}
static void
unmanage(struct Object *obj)
{
struct Splash *splash;
splash = (struct Splash *)obj;
TAILQ_REMOVE(&wm.splashq, (struct Object *)splash, entry);
icccmdeletestate(splash->obj.win);
free(splash);
}
struct Class *splash_class = &(struct Class){
.type = TYPE_SPLASH,
.setstate = NULL,
.manage = manage,
.unmanage = unmanage,
};