-
Notifications
You must be signed in to change notification settings - Fork 6
/
sniproxy.h
152 lines (126 loc) · 3.9 KB
/
sniproxy.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
/*
* Holds one embedded window, registers as DBus entry
* Copyright (C) 2015 <[email protected]> David Edmundson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef SNI_PROXY_H
#define SNI_PROXY_H
#include <QObject>
#include <QDBusArgument>
#include <QDBusConnection>
#include <QDBusObjectPath>
#include <QPixmap>
#include <xcb/xcb.h>
#include "snidbus.h"
class SNIProxy : public QObject
{
Q_OBJECT
Q_PROPERTY(QString Category READ Category)
Q_PROPERTY(QString Id READ Id)
Q_PROPERTY(QString Title READ Title)
Q_PROPERTY(QString Status READ Status)
Q_PROPERTY(int WindowId READ WindowId)
Q_PROPERTY(bool ItemIsMenu READ ItemIsMenu)
Q_PROPERTY(KDbusImageVector IconPixmap READ IconPixmap)
public:
SNIProxy(xcb_window_t wid, QObject *parent=0);
~SNIProxy();
void update();
/**
* @return the category of the application associated to this item
* @see Category
*/
QString Category() const;
/**
* @return the id of this item
*/
QString Id() const;
/**
* @return the title of this item
*/
QString Title() const;
/**
* @return The status of this item
* @see Status
*/
QString Status() const;
/**
* @return The id of the main window of the application that controls the item
*/
int WindowId() const;
/**
* @return The item only support the context menu, the visualization should prefer sending ContextMenu() instead of Activate()
*/
bool ItemIsMenu() const;
/**
* @return a serialization of the icon data
*/
KDbusImageVector IconPixmap() const;
public Q_SLOTS:
//interaction
/**
* Shows the context menu associated to this item
* at the desired screen position
*/
void ContextMenu(int x, int y);
/**
* Shows the main widget and try to position it on top
* of the other windows, if the widget is already visible, hide it.
*/
void Activate(int x, int y);
/**
* The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
*/
void SecondaryActivate(int x, int y);
/**
* Inform this item that the mouse wheel was used on its representation
*/
void Scroll(int delta, const QString &orientation);
Q_SIGNALS:
/**
* Inform the systemtray that the own main icon has been changed,
* so should be reloaded
*/
void NewIcon();
/**
* Inform the systemtray that there is a new icon to be used as overlay
*/
void NewOverlayIcon();
/**
* Inform the systemtray that the requesting attention icon
* has been changed, so should be reloaded
*/
void NewAttentionIcon();
/**
* Inform the systemtray that something in the tooltip has been changed
*/
void NewToolTip();
/**
* Signal the new status when it has been changed
* @see Status
*/
void NewStatus(const QString &status);
private:
void sendClick(uint8_t mouseButton, int x, int y);
QImage getImageNonComposite();
QDBusConnection m_dbus;
xcb_window_t m_windowId;
xcb_window_t m_containerWid;
static int s_serviceCount;
QPixmap m_pixmap;
};
#endif // SNIPROXY_H