-
Notifications
You must be signed in to change notification settings - Fork 5
/
rpbar.hh
128 lines (97 loc) · 2.65 KB
/
rpbar.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright (C) 2010 Daniel Maturana
// This file is part of rpbar.
//
// rpbar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rpbar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with rpbar. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef RPBAR_Y2DAPIQS
#define RPBAR_Y2DAPIQS
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include <fontconfig/fontconfig.h>
#include <X11/Xft/Xft.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include "settings.hh"
namespace rpbar
{
class RpBarException : public std::runtime_error {
public:
RpBarException(const std::string& what_arg) :
std::runtime_error(what_arg) { }
};
class RpBar {
public:
RpBar() { }
~RpBar();
void run();
private:
RpBar (const RpBar& other);
RpBar& operator=(const RpBar& other);
void init_socket();
void
init_font(const char *fontstr);
XftFont *
load_font_by_pattern(FcPattern * const);
int
get_font_height();
void init_gui();
void refresh();
int
draw_text(const int, const int, const char * const,
const char * const, const bool);
bool
draw_character(XftDraw *, const XftColor,
int * const, const int, const char * const, size_t * const,
const bool);
XftFont *
load_font_for_codepoint(long);
void handle_fd();
void handle_timeout();
void handle_xev();
void select_window(int win_ix);
void get_rp_info();
int
text_width_in_font(XftFont * const, const char * const,
const int);
int
text_width(const char * const);
unsigned long get_color(const char *colstr);
// this class does too much stuff.
int sock_fd, x11_fd;
fd_set fds;
std::string socket_path;
int bar_x, bar_y, bar_w, bar_h;
unsigned long bordercolor, bgcolor, fgcolor, mainbgcolor, mainfgcolor;
char buffer[RPBAR_BUFSIZE];
std::vector<std::string> windows;
// X stuff
Drawable drawable;
GC gc;
Display *display;
int screen;
Window root, win;
std::vector<XftFont *> xft_fonts;
FcPattern * fc_pattern;
};
void rstrip(char *s);
void rpbarsend(int argc, const char *argv[]);
} /* */
#endif /* end of include guard: RPBAR_Y2DAPIQS */