-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel.h
202 lines (155 loc) · 6.27 KB
/
panel.h
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
///
/// @file panel.h @brief panel header file
///
/// Copyright (c) 2009 - 2011, 2021 by Lutz Sammer. All Rights Reserved.
///
/// Contributor(s):
///
/// License: AGPLv3
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
/// published by the Free Software Foundation, either version 3 of the
/// License.
///
/// This program 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 Affero General Public License for more details.
///
/// $Id$
//////////////////////////////////////////////////////////////////////////////
/// @addtogroup panel
/// @{
//////////////////////////////////////////////////////////////////////////////
// Declares
//////////////////////////////////////////////////////////////////////////////
/**
** Panel typedef.
*/
typedef struct _panel_ Panel;
/**
** Panel common panel plugin data typedef.
*/
typedef struct _panel_plugin_ Plugin;
/**
** Structure to hold common panel plugin data.
*/
struct _panel_plugin_
{
STAILQ_ENTRY(_panel_plugin_) Next; ///< singly-linked panel list
Panel *Panel; ///< owner of plugin
void *Object; ///< plugin private data
int16_t X; ///< x-coordinate in panel
int16_t Y; ///< y-coordinate in panel
uint16_t Width; ///< actual width
uint16_t Height; ///< actual height
int16_t ScreenX; ///< x-coordinate on screen
int16_t ScreenY; ///< y-coordinate on screen
uint16_t RequestedWidth; ///< requested width
uint16_t RequestedHeight; ///< requested height
unsigned UserWidth:1; ///< user-specified width flag
unsigned UserHeight:1; ///< user-specified width flag
unsigned Grabbed:1; ///< mouse was grabbed by plugin
xcb_window_t Window; ///< content of window (plugin frees)
xcb_pixmap_t Pixmap; ///< content of pixmap (plugin frees)
/// callback to create new plugin
void (*Create)(Plugin *);
/// callback to delete plugin
void (*Delete)(Plugin *);
/// callback to set size known so far
void (*SetSize)(Plugin *, unsigned, unsigned);
/// callback to resize plugin
void (*Resize)(Plugin *);
/// callback to show tooltip of plugin
void (*Tooltip)(const Plugin *, int, int);
/// callback for mouse presse event
void (*HandleButtonPress)(Plugin *, int, int, int);
/// callback for mouse release event
void (*HandleButtonRelease)(Plugin *, int, int, int);
/// callback for mouse motion event
void (*HandleMotionNotify)(Plugin *, int, int, int);
/// callback for timeout of plugin
void (*Timeout)(Plugin *, uint32_t, int, int);
};
/**
** Enumeration of panel layouts.
*/
typedef enum
{
PANEL_LAYOUT_HORIZONTAL, ///< left-to-right
PANEL_LAYOUT_VERTICAL ///< top-to-bottom
} PanelLayout;
/**
** Panel structure.
*/
struct _panel_
{
SLIST_ENTRY(_panel_) Next; ///< singly-linked panel list
int16_t X; ///< x-coordinate of panel
int16_t Y; ///< y-coordinate of panel
uint16_t Width; ///< actual width of panel
uint16_t Height; ///< actual height of panel
int16_t RequestedX; ///< requested x-coordinate of panel
int16_t RequestedY; ///< requested y-coordinate of panel
uint16_t RequestedWidth; ///< requested width of panel
uint16_t RequestedHeight; ///< requested height of panel
int8_t Border; ///< border size in pixels
int8_t HiddenSize; ///< hidden size in pixels
Layer OnLayer:8; ///< layer for panel
unsigned Hidden:1; ///< true if hidden by autohide
unsigned AutoHide:1; ///< true autohide panel
unsigned MaximizeOver:1; ///< true if maximized over panel
PanelLayout Layout:1; ///< layout
Gravity Gravity:4; ///< placement and alignment on screen
xcb_window_t Window; ///< panel window
/// single tail queue list of plugins belonging of panel
STAILQ_HEAD(_plugin_head_, _panel_plugin_) Plugins;
};
SLIST_HEAD(_panel_head_, _panel_); ///< panel head structure
//////////////////////////////////////////////////////////////////////////////
// Variables
//////////////////////////////////////////////////////////////////////////////
extern struct _panel_head_ Panels; /// list of all panels
//////////////////////////////////////////////////////////////////////////////
// Prototypes
//////////////////////////////////////////////////////////////////////////////
extern void PanelsDraw(void); ///< Draw all panels.
/// Hide/show/toggle panel (for commands).
extern void PanelToggle(int, int);
/// Execute pointer button command
extern void PanelExecuteButton(const Plugin *, MenuButton *, int);
/// Create an empty panel plugin.
extern Plugin *PanelPluginNew(void);
/// Clear panel plugin background with given color.
extern void PanelClearPluginBackgroundWithColor(const Plugin *,
const uint32_t *);
/// Clear panel plugin background.
extern void PanelClearPluginBackground(const Plugin *);
/// Update plugin on a panel.
extern void PanelUpdatePlugin(const Panel *, const Plugin *);
/// Default panel plugin create method.
extern void PanelPluginCreatePixmap(Plugin *);
/// Default panel plugin delete method.
extern void PanelPluginDeletePixmap(Plugin *);
/// Handle a button press on a panel.
extern int PanelHandleButtonPress(const xcb_button_press_event_t *);
/// Handle a button release on a panel.
extern int PanelHandleButtonRelease(const xcb_button_release_event_t *);
/// Handle a motion notify event over a panel.
extern int PanelHandleMotionNotify(const xcb_motion_notify_event_t *);
/// Handle a panel enter notify.
extern int PanelHandleEnterNotify(const xcb_enter_notify_event_t *);
/// Handle a panel expose event.
extern int PanelHandleExpose(const xcb_expose_event_t *);
/// Handle timeout for the panel.
extern void PanelTimeout(uint32_t, int, int);
/// Resize a panel.
extern void PanelResize(Panel *);
extern void PanelInit(void); ///< Initialize panel support.
extern void PanelExit(void); ///< Cleanup panel support.
/// Parse a panel plugin size configuration.
extern void PanelPluginConfigSize(const ConfigObject *, Plugin *);
/// Configure panel support.
extern void PanelConfig(const Config *);
/// @}