1 module types;
2 
3 import deimos.X11.X;
4 import deimos.X11.Xlib;
5 import deimos.X11.keysymdef;
6 import deimos.X11.Xutil;
7 import deimos.X11.Xatom;
8 import std.conv;
9 import cboxapp;
10 import config;
11 import old;
12 import monitor;
13 
14 import std.traits;
15 
16 static string stext;
17 
18 struct Extnts 
19 {
20 	uint w;
21 	uint h;
22 }
23 
24 enum Keys 
25 {
26 	MOD1 = Mod1Mask,
27 	MOD4 = Mod4Mask,
28 	CONTROL = ControlMask,
29 	SHIFT = ShiftMask
30 };
31 
32 
33 
34 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
35        ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
36 
37 static int screen;
38 static int sw, sh;           /* X display screen geometry width, height */
39 static int bh, blw = 0;      /* bar geometry */
40 static uint numlockmask = 0;
41 static Monitor *mons, selmon;
42 static Window rootWin;
43 
44 auto range(string NextField)(Client* head) 
45 {
46     return Client.ClientRange!NextField(head);
47 }
48 
49 auto range(Monitor* head) 
50 {
51     return Monitor.MonitorRange(head);
52 }
53 
54 auto makeArg(TIN)(TIN val) 
55 {
56     alias T = Unqual!TIN;
57     return Arg(val);
58 }
59 
60 auto CLEANMASK(M)(auto ref in M mask) 
61 {
62     return (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask));
63 }
64 
65 auto INTERSECT(T, M)(T x, T y, T w, T h, M m) 
66 {
67     import std.algorithm;
68     return max(0, min(x + w, m.wx + m.ww) - max(x, m.wx)) * max(0, min(y + h, m.wy + m.wh) - max(y, m.wy));
69 }
70 
71 auto ISVISIBLE(C)(auto ref in C c) pure @safe @nogc nothrow 
72 {
73     return c.tags & c.mon.tagset[c.mon.seltags];
74 }
75 
76 auto LENGTH(X)(auto ref in X x) 
77 {
78     return x.length;
79 }
80 
81 auto WIDTH(X)(auto ref in X x) 
82 {
83     return x.w + 2 * x.bw;
84 }
85 
86 auto HEIGHT(X)(auto ref in X x) 
87 {
88     return x.h + 2 * x.bw;
89 }
90 
91 enum TAGMASK = ((1 << tags.length) - 1);
92 
93 struct Rule 
94 {
95     string klass;
96     string instance;
97     string title;
98     uint tags;
99     bool isfloating;
100     int monitor;
101 }
102 
103 struct Arg 
104 {
105     union Vals
106     {
107         int ival;
108         uint uival;
109         float fval;
110         string[] sval;
111         void* vptr;
112     }
113 
114     Vals val;
115 
116     //Variant val;
117     this(TIN)(TIN val) 
118     {
119         alias T = Unqual!TIN;
120         static if(isIntegral!T) {
121             this.val.ival = cast(int)(val);
122         } else static if(isFloatingPoint!T) {
123             this.val.fval = cast(float)(val);
124         } else static if(is(TIN == immutable(immutable(char)[])[])) {
125             this.val.sval = cast(string[])val;
126         } else {
127             this.val.vptr = cast(void*)(val);
128         }
129     }
130 
131     @property int i() const 
132     {
133         return this.val.ival;
134     }
135 
136     @property void i(int ival) 
137     {
138     	val.ival = cast(int)(ival);
139     }
140 
141     @property uint ui() const 
142     {
143         return this.val.uival;
144     }
145 
146     @property void ui(uint ival) 
147     {
148     	val.uival = cast(uint)(ival);
149     }
150 
151     @property float f() const 
152     {
153         return this.val.fval;
154     }
155 
156     @property void f(float ival) 
157     {
158     	val.fval = cast(float)(ival);
159     }
160 
161     @property const(string[]) s() const
162     {
163         return this.val.sval;
164     }
165 
166     @property void s(string[] ival) 
167     {
168     	val.sval = cast(string[])(ival);
169     }
170 
171     @property const(void*) v() const 
172     {
173         return this.val.vptr;
174     }
175 
176     @property void v(void* ival) 
177     {
178     	val.vptr = cast(void*)(ival);
179     }
180 }
181 
182 
183