1 module cboxapp;
2 
3 import std.stdio;
4 import x11.X;
5 import x11.Xlib;
6 import x11.keysymdef;
7 import x11.Xutil;
8 import x11.Xatom;
9 import window;
10 import types;
11 import theme.layout;
12 import monitor;
13 
14 alias DGC = core.memory.GC;
15 alias XGC = x11.Xlib.GC;
16 
17 import core.sys.posix.signal;
18 import core.sys.posix.sys.wait;
19 import core.sys.posix.unistd;
20 
21 /**
22 * Singleton to hold our main Display
23 **/
24 class AppDisplay
25 {
26 
27   Display *dpy;
28   bool running = true;
29 
30   static AppDisplay instance()
31   {
32     if (!instantiated_) {
33       synchronized {
34         if (instance_ is null) {
35           instance_ = new AppDisplay;
36           instance_.dpy = XOpenDisplay(null);
37         }
38         instantiated_ = true;
39       }
40     }
41     return instance_;
42   }
43 
44   void quit()
45   {
46      this.running = false;
47   }
48 
49  private:
50   this() {}
51   static bool instantiated_;  // Thread local
52   __gshared AppDisplay instance_;
53 
54  }
55 
56 struct Client
57 {
58   string name;
59   float mina, maxa;
60   int x, y, w, h;
61   int oldx, oldy, oldw, oldh;
62   int basew, baseh, incw, inch, maxw, maxh, minw, minh;
63   int bw, oldbw;
64   uint tags;
65   bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
66   Client *next;
67   Client *snext;
68   Monitor *mon;
69   Window win;
70 
71     /**
72      * A range to iterate over the client list via 'next' or 'snext',
73      * as specified by the template string.
74      * Example:
75      * ---
76      * auto r = ClientRange!"next"(clientPtr);
77      * auto sr = ClientRange!"snext"(clientPtr);
78      * ---
79      */
80     struct ClientRange(string NextField)
81     {
82         Client* client;
83         @property bool empty()
84         {
85           return client is null;
86         }
87 
88         @property auto front()
89         {
90           return client;
91         }
92 
93         auto popFront()
94         {
95             mixin(`client = client.`~NextField~`;`);
96         }
97     }
98 }