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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
#ifndef _DOCK_H_
#define _DOCK_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <time.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h>
#include <X11/extensions/shape.h>
#include <X11/cursorfont.h>
#include <libmb/mb.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef USE_XSETTINGS
#include <xsettings-client.h>
#endif
#define NEW(OBJ) ((OBJ *)(malloc(sizeof(OBJ))))
#ifdef DEBUG
#define DBG(txt, args... ) fprintf(stderr, "MB-PANEL-DEBUG: " txt , ##args )
#else
#define DBG(txt, args... ) /* nothing */
#endif
#define SWAP(a,b) { \
(a)^=(b); \
(b)^=(a); \
(a)^=(b); \
}
#define PANEL_IS_VERTICAL(p) ((p)->orientation == East || (p)->orientation == West)
#define SYSTEM_TRAY_REQUEST_DOCK 0
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
#define ATOM_WM_WINDOW_TYPE 0
#define ATOM_WM_WINDOW_TYPE_DOCK 1
#define ATOM_WM_WINDOW_TYPE_SPLASH 10
#define ATOM_SYSTEM_TRAY 2
#define ATOM_SYSTEM_TRAY_OPCODE 3
#define ATOM_XEMBED_INFO 4
#define ATOM_XEMBED_MESSAGE 5
#define ATOM_MANAGER 6
#define ATOM_MB_DOCK_ALIGN 7
#define ATOM_MB_DOCK_ALIGN_EAST 8
#define ATOM_NET_SYSTEM_TRAY_MESSAGE_DATA 9
#define ATOM_WM_PROTOCOLS 11
#define ATOM_WM_DELETE_WINDOW 12
#define ATOM_MB_THEME 13
#define ATOM_MB_PANEL_BG 16
#define ATOM_MB_DOCK_TIMESTAMP 14
#define ATOM_NET_WM_STRUT 15
#define ATOM_WM_CLIENT_LEADER 17
#define ATOM_NET_WM_ICON 18
#define ATOM_NET_WM_PID 19
#define ATOM_XROOTPMAP_ID 20
#define ATOM_NET_SYSTEM_TRAY_ORIENTATION 21
#define ATOM_MB_THEME_NAME 22
#define ATOM_MB_COMMAND 23
#define ATOM_NET_WM_NAME 24
#define ATOM_UTF8_STRING 25
#define ATOM_NET_CLIENT_LIST 26
#define ATOM_NET_WM_STATE 27
#define ATOM_NET_WM_STATE_TITLEBAR 28
#define ATOM_MB_SYSTEM_TRAY_CONTEXT 29
#define ATOM_MB_REQ_CLIENT_ORDER 30
#define ATOM_MB_DOCK_TITLEBAR_SHOW_ON_DESKTOP 31
#define XEMBED_EMBEDDED_NOTIFY 0
#define XEMBED_WINDOW_ACTIVATE 1
/* ID's for various MB COMMAND X Messages */
#define MB_CMD_PANEL_TOGGLE_VISIBILITY 1
#define MB_CMD_PANEL_SIZE 2
#define MB_CMD_PANEL_ORIENTATION 3
#define MB_PANEL_ORIENTATION_NORTH 1
#define MB_PANEL_ORIENTATION_EAST 2
#define MB_PANEL_ORIENTATION_SOUTH 3
#define MB_PANEL_ORIENTATION_WEST 4
#define SESSION_TIMEOUT 10 /* 5 second session timeout */
#define DBL_CLICK_TIME 200
#define DEFAULT_COLOR_SPEC "#e2e2de" /* Same as gnome ? */
#define MB_MSG_FONT "Sans 14px"
#define MAX_DEFERED_WINS 32 /* *very* Unlikely as much as 32 */
enum {
BG_SOLID_COLOR,
BG_PIXMAP,
BG_TRANS
};
typedef enum {
PAPP_GRAVITY_START,
PAPP_GRAVITY_END,
} PanelAppGravity;
typedef enum {
North = 1,
East,
South,
West
} MBPanelOrientation;
typedef struct _panel_app {
Window win;
unsigned char *name;
int x;
int y;
int w;
int h;
int offset;
Bool mapped;
struct _panel_app *next;
char *cmd_str;
struct _panel *panel;
Bool ignore; /* set so client cant be removed */
int ignore_unmap;
PanelAppGravity gravity;
MBPixbufImage *icon;
} MBPanelApp;
typedef struct _message_queue {
MBPanelApp *sender;
unsigned long starttime;
int timeout;
int total_msg_length;
int current_msg_length;
int id;
unsigned char *data;
Bool has_extra_context;
unsigned char *extra_context_data;
Bool pending; /* Set to true if all data */
struct _message_queue *next;
} MBPanelMessageQueue;
typedef struct _panel {
/* General */
Display *dpy;
int screen;
MBPixbuf *pb;
Window win, win_root;
GC gc, band_gc;
XColor xcol;
int x,y,w,h;
MBPanelApp *apps_start_head;
MBPanelApp *apps_end_head;
Atom atoms[32];
int padding;
int margin_topbottom;
int margin_sides;
/* Message windows */
struct _message_queue *msg_queue_start;
struct _message_queue *msg_queue_end;
Window msg_win;
unsigned long msg_starttime;
int msg_timeout;
MBPanelApp *msg_win_sender;
Bool msg_has_context;
int msg_context_y1, msg_context_y2;
GC msg_gc;
MBColor *msg_col;
MBColor *msg_urgent_col;
MBColor *msg_fg_col;
MBColor *msg_link_col;
MBFont *msg_font;
/* Various state bits */
Bool use_flip;
Bool use_session;
Bool use_alt_session_defaults;
Bool use_overide_wins;
Bool reload_pending;
MBPanelOrientation orientation;
int system_tray_id;
Bool use_themes;
char *theme_name;
char *theme_path;
Bool want_titlebar_dest;
Bool ignore_next_config;
int default_panel_size;
/* Session */
Bool session_preexisting_lock;
int session_init_offset;
char session_entry_cur[512];
pid_t session_needed_pid;
time_t session_start_time;
FILE *session_fp;
PanelAppGravity session_cur_gravity;
Bool session_run_first_time;
char *session_defaults_cur_pos;
Window last_click_window;
Time last_click_time;
Bool next_click_is_not_double;
Bool is_hidden;
/* Background */
XColor bg_col;
Pixmap bg_tile;
Pixmap bg_pxm;
char *bg_spec;
int bg_type;
/* Popup menu */
MBMenu* mbmenu;
Bool use_menu;
MBMenuMenu *remove_menu;
/* co-ords of where mouse click happened for menu */
int click_x;
int click_y;
Time click_time;
char *bg_trans;
long root_pixmap_id;
/* Defered apps list - win ids that start while session is
* starting but *arnt* in the session, so they are docked
* after starting.
*
* XXX: should really use a list here.
*/
Window session_defered_wins[MAX_DEFERED_WINS];
int n_session_defered_wins;
#ifdef USE_XSETTINGS
XSettingsClient *xsettings_client;
#endif
} MBPanel;
void
panel_handle_full_panel (MBPanel *panel, MBPanelApp *bad_papp);
void
panel_toggle_visibilty(MBPanel *panel);
void
panel_change_orientation (MBPanel *panel,
MBPanelOrientation new_orientation,
int dpy_w,
int dpy_h);
void
panel_update_client_list_prop (MBPanel *panel);
void
panel_reorder_apps(MBPanel *panel);
void
panel_handle_dock_request(MBPanel *panel, Window win);
#include "panel_menu.h"
#include "panel_util.h"
#include "panel_app.h"
#include "session.h"
#endif
|