wmail: added command-line option to specify a different config-file.
[dockapps.git] / wmmemfree / draw.c
blob7323e479a353fb028fbda0cfc50facd46e66cba0
1 /*
2 * draw.c - drawing code
4 * Copyright (C) 2003 Draghicioiu Mihai <misuceldestept@go.ro>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
21 #include <X11/Xlib.h>
23 #include "dockapp.h"
24 #include "draw.h"
25 #include "mem_linux.h"
26 #include "options.h"
28 void draw_window()
30 int n;
31 long long int mem, swp;
32 int mem_percent, swp_percent;
34 mem_getfree();
35 mem = mem_used;
36 if(!opt_buffers) mem -= mem_buffers;
37 if(!opt_cache) mem -= mem_cached;
38 swp = swp_used;
39 for(n=0;n<25;n++)
41 if(n < (mem * 25 / mem_total))
42 XCopyArea(display, on, buffer, gc, 0, 0, 2, 11, 7 + n * 2, 27);
43 else
44 XCopyArea(display, off, buffer, gc, 0, 0, 2, 11, 7 + n * 2, 27);
45 if(n < (swp * 25 / swp_total))
46 XCopyArea(display, on, buffer, gc, 0, 0, 2, 11, 7 + n * 2, 47);
47 else
48 XCopyArea(display, off, buffer, gc, 0, 0, 2, 11, 7 + n * 2, 47);
50 mem_percent = mem * 100 / mem_total;
51 swp_percent = swp * 100 / swp_total;
52 if(mem_percent == 100)
53 XCopyArea(display, numbers, buffer, gc, 5, 0, 5, 6, 33, 20);
54 else
55 XCopyArea(display, numbers, buffer, gc, 50, 0, 5, 6, 33, 20);
56 if(mem_percent > 9)
57 XCopyArea(display, numbers, buffer, gc, 5*((mem_percent%100)/10), 0, 5, 6, 39, 20);
58 else
59 XCopyArea(display, numbers, buffer, gc, 50, 0, 5, 6, 39, 20);
60 XCopyArea(display, numbers, buffer, gc, 5*(mem_percent%10), 0, 5, 6, 45, 20);
61 if(swp_percent == 100)
62 XCopyArea(display, numbers, buffer, gc, 5, 0, 5, 6, 33, 40);
63 else
64 XCopyArea(display, numbers, buffer, gc, 50, 0, 5, 6, 33, 40);
65 if(swp_percent > 9)
66 XCopyArea(display, numbers, buffer, gc, 5*((swp_percent%100)/10), 0, 5, 6, 39, 40);
67 else
68 XCopyArea(display, numbers, buffer, gc, 50, 0, 5, 6, 39, 40);
69 XCopyArea(display, numbers, buffer, gc, 5*(swp_percent%10), 0, 5, 6, 45, 40);
70 update_window();
71 XSync(display, False);