-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecorator.cpp
More file actions
121 lines (107 loc) · 3.3 KB
/
decorator.cpp
File metadata and controls
121 lines (107 loc) · 3.3 KB
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
#include "decorator.h"
#include <QWidget>
#include <QX11Info>
#include <QDebug>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <xcb/xcb.h>
/*!
* \brief Decorator::wrapWindow
* \param w
* \details
* Make window do not draw title bar but managed by window manager.
*/
void Decorator::wrapWindow(QWidget *w, bool csd)
{
MotifWmHints new_hints;
/* initialize to zero to avoid writing uninitialized data to socket */
memset(&new_hints, 0, sizeof(new_hints));
new_hints.flags = MWM_HINTS_DECORATIONS;
new_hints.decorations = 0;
// Atom frame_extents;
// ulong data[4] = {
// 10,
// 10,
// 10,
// 10
// };
// frame_extents = XInternAtom (QX11Info::display(), "_GTK_FRAME_EXTENTS", true);
// if (frame_extents == None)
// qDebug()<<"no frame extents";
Atom mwm_hints;
uchar *hints_data;
MotifWmHints *hints;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
mwm_hints = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true);
// if (mwm_hints == None)
// qDebug()<<"no mwm_hints";
// else {
// qDebug()<<w->winId();
// XChangeProperty(QX11Info::display(),
// w->winId(),
// frame_extents,
// XA_CARDINAL,
// 32,
// PropModeReplace,
// (uchar*)&data,
// 4);
// }
XGetWindowProperty (QX11Info::display(),
w->winId(),
mwm_hints,
0,
sizeof (MotifWmHints)/sizeof (long),
false,
AnyPropertyType,
&type,
&format,
&nitems,
&bytes_after,
&hints_data);
hints = &new_hints;
if (type == None)
hints = &new_hints;
else {
hints = (MotifWmHints *)hints_data;
if (!csd) {
if (new_hints.flags & MWM_HINTS_FUNCTIONS)
{
hints->flags |= MWM_HINTS_FUNCTIONS;
hints->functions = new_hints.functions;
}
if (new_hints.flags & MWM_HINTS_DECORATIONS)
{
hints->flags |= MWM_HINTS_DECORATIONS;
//effect in ukwm, but uneffect in kwin
hints->decorations = MWM_DECOR_ALL;
}
} else {
if (new_hints.flags & MWM_HINTS_FUNCTIONS)
{
hints->flags |= MWM_HINTS_FUNCTIONS;
hints->functions = new_hints.functions;
}
if (new_hints.flags & MWM_HINTS_DECORATIONS)
{
hints->flags |= MWM_HINTS_DECORATIONS;
//effect in ukwm, but uneffect in kwin
hints->decorations = MWM_DECOR_BORDER;
}
}
}
//_MOTIF_WM_HINTS
qDebug()<<XChangeProperty(QX11Info::display(),
w->winId(),
mwm_hints,
mwm_hints,
32,
PropModeReplace,
(uchar*)hints,
sizeof (MotifWmHints)/sizeof (long));
}
Decorator::Decorator(QObject *parent) : QObject(parent)
{
}