aboutsummaryrefslogtreecommitdiff
path: root/lumina-wm-INCOMPLETE/LXcbEventFilter.h
blob: 4b2516e7c29da0767d38c085a58da58251b425d3 (plain)
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
//===========================================
//  Lumina-DE source code
//  Copyright (c) 2012, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
// This class provides the XCB ->Xlib conversion necessary for Qt5 usage
//===========================================
#ifndef _LUMINA_DESKTOP_XCB_FILTER_H
#define _LUMINA_DESKTOP_XCB_FILTER_H

#include <QAbstractNativeEventFilter>
#include <QList>
#include <QStringList>
#include <QX11Info>
#include <QCoreApplication>

#include <LuminaX11.h>

#include <xcb/xcb.h>
#include <xcb/xproto.h>
#include <xcb/damage.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_aux.h> //included in libxcb-util.so

/*
List of XCB response types (since almost impossible to find good docs on XCB)
switch (xcb_generic_event_t*->response_type  & ~0x80)
case values:
XCB_KEY_[PRESS | RELEASE]
XCB_BUTTON_[PRESS | RELEASE]
XCB_MOTION_NOTIFY
XCB_ENTER_NOTIFY
XCB_LEAVE_NOTIFY
XCB_FOCUS_[IN | OUT]
XCB_KEYMAP_NOTIFY
XCB_EXPOSE
XCB_GRAPHICS_EXPOSURE
XCB_VISIBILITY_NOTIFY
XCB_CREATE_NOTIFY
XCB_DESTROY_NOTIFY
XCB_UNMAP_NOTIFY
XCB_MAP_[NOTIFY | REQUEST]
XCB_REPARENT_NOTIFY
XCB_CONFIGURE_[NOTIFY | REQUEST]
XCB_GRAVITY_NOTIFY
XCB_RESIZE_REQUEST
XCB_CIRCULATE_[NOTIFY | REQUEST]
XCB_PROPERTY_NOTIFY
XCB_SELECTION_[CLEAR | REQUEST | NOTIFY]
XCB_COLORMAP_NOTIFY
XCB_CLIENT_MESSAGE
*/

//SYSTEM TRAY STANDARD DEFINITIONS
//#define SYSTEM_TRAY_REQUEST_DOCK 0
//#define SYSTEM_TRAY_BEGIN_MESSAGE 1
//#define SYSTEM_TRAY_CANCEL_MESSAGE 2


// ---------------------------------------------
// Lifted these mask definitions from the i3 window manager (BSD Licensed as well) 5/14/15 - Ken Moore
#define CHILD_EVENT_MASK (XCB_EVENT_MASK_PROPERTY_CHANGE |  \
                          XCB_EVENT_MASK_STRUCTURE_NOTIFY | \
                          XCB_EVENT_MASK_FOCUS_CHANGE)

/** The XCB_CW_EVENT_MASK for its frame */
#define FRAME_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | /* ...mouse is pressed/released */                       \
                          XCB_EVENT_MASK_BUTTON_RELEASE |                                                        \
                          XCB_EVENT_MASK_POINTER_MOTION |        /* ...mouse is moved */                         \
                          XCB_EVENT_MASK_EXPOSURE |              /* ...our window needs to be redrawn */         \
                          XCB_EVENT_MASK_STRUCTURE_NOTIFY |      /* ...the frame gets destroyed */               \
                          XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | /* ...the application tries to resize itself */ \
                          XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |   /* ...subwindows get notifies */                \
                          XCB_EVENT_MASK_ENTER_WINDOW)           /* ...user moves cursor inside our window */

#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |                                       \
                         XCB_EVENT_MASK_BUTTON_PRESS |                                                \
                         XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video \
                                                                  projector), the root window gets a  \
                                                                  ConfigureNotify */                  \
                         XCB_EVENT_MASK_POINTER_MOTION |                                              \
                         XCB_EVENT_MASK_PROPERTY_CHANGE |                                             \
                         XCB_EVENT_MASK_ENTER_WINDOW)
// ---------------------------------------------
			 
			 
class EventFilter : public QObject{
	Q_OBJECT
private:
	QAbstractNativeEventFilter* EF;
public:
	EventFilter();
	~EventFilter(){}

	void start();
	
signals:
	void NewInputEvent();
};
	
class XCBEventFilter : public QAbstractNativeEventFilter{
public:
	XCBEventFilter(EventFilter *parent);
	~XCBEventFilter(){}

	//This function format taken directly from the Qt5.3 documentation
	virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE;
		
private:
	LXCB *XCB;
	EventFilter *obj;
	QList<xcb_atom_t> WinNotifyAtoms, SysNotifyAtoms;

	void InitAtoms(){
	  //Initialize any special atoms that we need to save/use regularly
	  //NOTE: All the EWMH atoms are already saved in XCB->EWMH
	  WinNotifyAtoms.clear();
	    WinNotifyAtoms << XCB->EWMH._NET_WM_NAME \
					<< XCB->EWMH._NET_WM_VISIBLE_NAME \
					<< XCB->EWMH._NET_WM_ICON_NAME \
					<< XCB->EWMH._NET_WM_VISIBLE_ICON_NAME \
					<< XCB->EWMH._NET_WM_ICON \
					<< XCB->EWMH._NET_WM_ICON_GEOMETRY;
		
	  SysNotifyAtoms.clear();
	    SysNotifyAtoms << XCB->EWMH._NET_CLIENT_LIST \
					<< XCB->EWMH._NET_CLIENT_LIST_STACKING \
					<< XCB->EWMH._NET_CURRENT_DESKTOP \
					<< XCB->EWMH._NET_WM_STATE \
					<< XCB->EWMH._NET_ACTIVE_WINDOW \
					<< XCB->EWMH._NET_WM_ICON \
					<< XCB->EWMH._NET_WM_ICON_GEOMETRY;

	}
	
	//Event handling functions (return true if event accepted/blocked)
	//bool ParseKeyPressEvent();
	//bool ParseKeyReleaseEvent();
	//bool ParseButtonPressEvent();
	//bool ParseButtonReleaseEvent();
	//bool ParseMotionEvent();
	//bool ParsePropertyEvent();
	//bool ParseClientMessageEvent();
	//bool ParseDestroyEvent();
	//bool ParseConfigureEvent();
	//bool ParseKeySelectionClearEvent();
	
	

	
};

#endif
bgstack15