💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Menkar › files › a4cd047c05a7fee8da00630cac5… captured on 2023-06-16 at 16:40:29. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
0 /*
1 * Modular hinting support
2 */
3
4 /*
5 * Copyright 2006 Johan Veenhuizen
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28
29 #include "hints.h"
30 #include "lib.h"
31
32 extern struct hints icccm_hints;
33
34 #if CONFIG_EWMH
35 extern struct hints ewmh_hints;
36 #endif
37
38 static struct hints *hints[] = {
39 &icccm_hints,
40
41 #if CONFIG_EWMH
42 &ewmh_hints,
43 #endif
44 };
45
46 void hints_init(void)
47 {
48 int i;
49
50 for (i = 0; i < NELEM(hints); i++)
51 if (hints[i]->init != NULL)
52 hints[i]->init();
53 }
54
55 void hints_fini(void)
56 {
57 int i;
58
59 for (i = 0; i < NELEM(hints); i++)
60 if (hints[i]->fini != NULL)
61 hints[i]->fini();
62 }
63
64 void hints_manage(struct window *win)
65 {
66 int i;
67
68 for (i = 0; i < NELEM(hints); i++)
69 if (hints[i]->manage != NULL)
70 hints[i]->manage(win);
71 }
72
73 void hints_unmanage(struct window *win)
74 {
75 int i;
76
77 for (i = 0; i < NELEM(hints); i++)
78 if (hints[i]->unmanage != NULL)
79 hints[i]->unmanage(win);
80 }
81
82 void hints_map(struct window *win)
83 {
84 int i;
85
86 for (i = 0; i < NELEM(hints); i++)
87 if (hints[i]->map != NULL)
88 hints[i]->map(win);
89 }
90
91 void hints_unmap(struct window *win)
92 {
93 int i;
94
95 for (i = 0; i < NELEM(hints); i++)
96 if (hints[i]->unmap != NULL)
97 hints[i]->unmap(win);
98 }
99
100 void hints_withdraw(struct window *win)
101 {
102 int i;
103
104 for (i = 0; i < NELEM(hints); i++)
105 if (hints[i]->withdraw != NULL)
106 hints[i]->withdraw(win);
107 }
108
109 void hints_activate(struct window *win)
110 {
111 int i;
112
113 for (i = 0; i < NELEM(hints); i++)
114 if (hints[i]->activate != NULL)
115 hints[i]->activate(win);
116 }
117
118 void hints_deactivate(struct window *win)
119 {
120 int i;
121
122 for (i = 0; i < NELEM(hints); i++)
123 if (hints[i]->deactivate != NULL)
124 hints[i]->deactivate(win);
125 }
126
127 void hints_move(struct window *win)
128 {
129 int i;
130
131 for (i = 0; i < NELEM(hints); i++)
132 if (hints[i]->move != NULL)
133 hints[i]->move(win);
134 }
135
136 void hints_resize(struct window *win)
137 {
138 int i;
139
140 for (i = 0; i < NELEM(hints); i++)
141 if (hints[i]->resize != NULL)
142 hints[i]->resize(win);
143 }
144
145 void hints_moveresize(struct window *win)
146 {
147 int i;
148
149 for (i = 0; i < NELEM(hints); i++)
150 if (hints[i]->moveresize != NULL)
151 hints[i]->moveresize(win);
152 }
153
154 void hints_clientmessage(struct window *win, XClientMessageEvent *ep)
155 {
156 int i;
157
158 for (i = 0; i < NELEM(hints); i++)
159 if (hints[i]->clientmessage != NULL)
160 if (hints[i]->clientmessage(win, ep))
161 return;
162 }
163
164 void hints_propertynotify(struct window *win, XPropertyEvent *ep)
165 {
166 int i;
167
168 for (i = 0; i < NELEM(hints); i++)
169 if (hints[i]->propertynotify != NULL)
170 if (hints[i]->propertynotify(win, ep))
171 return;
172 }
173
174 int hints_delete(struct window *win)
175 {
176 int i;
177
178 for (i = 0; i < NELEM(hints); i++)
179 if (hints[i]->delete != NULL)
180 if (hints[i]->delete(win))
181 return 1;
182 return 0;
183 }
184
185 void hints_restack(void)
186 {
187 int i;
188
189 for (i = 0; i < NELEM(hints); i++)
190 if (hints[i]->restack != NULL)
191 hints[i]->restack();
192 }
193