]> Dogcows Code - chaz/tint2/blob - src/systray/docker.c
a2e61526a6a82f9fdb3e58016fc6d947d58d7e21
[chaz/tint2] / src / systray / docker.c
1 #include "version.h"
2 #include "kde.h"
3 #include "icons.h"
4 #include "docker.h"
5 #include "net.h"
6
7 #include <assert.h>
8 #include <signal.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <X11/Xutil.h>
13
14 int argc;
15 char **argv;
16
17 Window win = None, hint_win = None, root = None;
18 gboolean wmaker = FALSE; /* WindowMakerMode!!! wheeee */
19 Display *display = NULL;
20 GSList *icons = NULL;
21 int width = 0, height = 0;
22 int border = 1; /* blank area around icons. must be > 0 */
23 gboolean horizontal = TRUE; /* layout direction */
24 int icon_size = 24; /* width and height of systray icons */
25
26 //static char *display_string = NULL;
27 /* excluding the border. sum of all child apps */
28 static gboolean exit_app = FALSE;
29
30 /*
31 void create_hint_win()
32 {
33 XWMHints hints;
34 XClassHint classhints;
35
36 hint_win = XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, 0, 0);
37 assert(hint_win);
38
39 hints.flags = StateHint | WindowGroupHint | IconWindowHint;
40 hints.initial_state = WithdrawnState;
41 hints.window_group = hint_win;
42 hints.icon_window = win;
43
44 classhints.res_name = "docker";
45 classhints.res_class = "Docker";
46
47 XSetWMProperties(display, hint_win, NULL, NULL, argv, argc,
48 NULL, &hints, &classhints);
49
50 XMapWindow(display, hint_win);
51 }
52
53
54 void create_main_window()
55 {
56 XWMHints hints;
57 XTextProperty text;
58 char *name = "Docker";
59
60 // the border must be > 0 if not in wmaker mode
61 assert(wmaker || border > 0);
62
63 if (!wmaker)
64 win = XCreateSimpleWindow(display, root, 0, 0,
65 border * 2, border * 2, 0, 0, 0);
66 else
67 win = XCreateSimpleWindow(display, root, 0, 0,
68 64, 64, 0, 0, 0);
69
70 assert(win);
71
72 XStringListToTextProperty(&name, 1, &text);
73 XSetWMName(display, win, &text);
74
75 hints.flags = StateHint;
76 hints.initial_state = WithdrawnState;
77 XSetWMHints(display, win, &hints);
78
79 create_hint_win();
80
81 XSync(display, False);
82 XSetWindowBackgroundPixmap(display, win, ParentRelative);
83 XClearWindow(display, win);
84 }
85 */
86
87 void reposition_icons()
88 {
89 int x = border + ((width % icon_size) / 2),
90 y = border + ((height % icon_size) / 2);
91 GSList *it;
92
93 for (it = icons; it != NULL; it = g_slist_next(it)) {
94 TrayWindow *traywin = it->data;
95 traywin->x = x;
96 traywin->y = y;
97 XMoveWindow(display, traywin->id, x, y);
98 XSync(display, False);
99 if (wmaker) {
100 x += icon_size;
101 if (x + icon_size > width) {
102 x = border;
103 y += icon_size;
104 }
105 } else if (horizontal)
106 x += icon_size;
107 else
108 y += icon_size;
109 }
110 }
111
112
113 void fix_geometry()
114 {
115 GSList *it;
116
117 // in wmaker mode we're a fixed size
118 if (wmaker) return;
119
120 //* find the proper width and height
121 width = horizontal ? 0 : icon_size;
122 height = horizontal ? icon_size : 0;
123 for (it = icons; it != NULL; it = g_slist_next(it)) {
124 if (horizontal)
125 width += icon_size;
126 else
127 height += icon_size;
128 }
129
130 XResizeWindow(display, win, width + border * 2, height + border * 2);
131 }
132
133 /*
134 int main(int c, char **v)
135 {
136 struct sigaction act;
137
138 argc = c; argv = v;
139
140 act.sa_handler = signal_handler;
141 act.sa_flags = 0;
142 sigaction(SIGSEGV, &act, NULL);
143 sigaction(SIGPIPE, &act, NULL);
144 sigaction(SIGFPE, &act, NULL);
145 sigaction(SIGTERM, &act, NULL);
146 sigaction(SIGINT, &act, NULL);
147 sigaction(SIGHUP, &act, NULL);
148
149 parse_cmd_line(argc, argv);
150
151 display = XOpenDisplay(display_string);
152 if (!display) {
153 g_printerr("Unable to open Display %s. Exiting.\n",
154 DisplayString(display_string));
155 }
156
157 root = RootWindow(display, DefaultScreen(display));
158 assert(root);
159
160 if (wmaker)
161 width = height = 64 - border * 2;
162
163 create_main_window();
164
165 // set up to find KDE systray icons, and get any that already exist
166 kde_init();
167
168 net_init();
169
170 // we want to get ConfigureNotify events, and assume our parent's background
171 // has changed when we do, so we need to refresh ourself to match
172 XSelectInput(display, win, StructureNotifyMask);
173
174 event_loop();
175
176 XCloseDisplay(display);
177
178 return 0;
179 }
180 */
This page took 0.04258 seconds and 4 git commands to generate.