aboutsummarylogtreecommitdiffstats
path: root/kwin-aurorae-optional-titlebar.patch
blob: a8b6c2127027305c221141554c077b8694e9dee5 (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
diff --git a/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp b/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp
index ba8554fe5..889b4120a 100644
--- a/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp
+++ b/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp
@@ -24,9 +24,14 @@
 #include <QDebug>
 #include <QHash>
 #include <QStandardPaths>
+#include <QDir>
+#include <QFile>
 // KDE
 #include <KConfig>
 #include <KConfigGroup>
+#include <KDecoration2/Decoration>
+#include <KDecoration2/DecoratedClient>
+#include <KWindowInfo>
 
 Q_LOGGING_CATEGORY(AURORAE, "aurorae", QtCriticalMsg)
 
@@ -87,6 +92,24 @@ AuroraeTheme::AuroraeTheme(QObject* parent)
 {
     connect(this, SIGNAL(themeChanged()), SIGNAL(borderSizesChanged()));
     connect(this, SIGNAL(buttonSizesChanged()), SIGNAL(borderSizesChanged()));
+
+    // HACK: Hide title bar for windows whose classes are specified in ~/.aurorae_notitle
+    QFile hideTitleConf(QDir::homePath() + "/.aurorae_notitle");
+    if (hideTitleConf.open(QFile::ReadOnly | QFile::Text)) {
+        QString classes = "\n" + QTextStream(&hideTitleConf).readAll() + "\n";
+        KDecoration2::Decoration* decoration = (KDecoration2::Decoration*) parent;
+        auto client = decoration->client().data();
+        KWindowInfo info(client->windowId(), nullptr, NET::WM2WindowClass);
+        QString window_className(QString::fromUtf8(info.windowClassName()));
+        QString window_classClass(QString::fromUtf8(info.windowClassClass()));
+
+        if ((!window_className.isEmpty() 
+                    && classes.contains("\n" + window_className + "\n"))
+                || (!window_classClass.isEmpty()
+                    && classes.contains("\n" + window_classClass + "\n"))) {
+            this->hideTitleBar = true;
+        }
+    }
 }
 
 AuroraeTheme::~AuroraeTheme()
@@ -185,7 +208,7 @@ void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool ma
                                    d->themeConfig.buttonHeight()*buttonSizeFactor() +
                                    d->themeConfig.buttonMarginTop());
     if (maximized) {
-        const qreal title = titleHeight + d->themeConfig.titleEdgeTopMaximized() + d->themeConfig.titleEdgeBottomMaximized();
+        const qreal title = hideTitleBar ? 0 : (titleHeight + d->themeConfig.titleEdgeTopMaximized() + d->themeConfig.titleEdgeBottomMaximized());
         switch ((DecorationPosition)d->themeConfig.decorationPosition()) {
         case DecorationTop:
             left = right = bottom = 0;
@@ -240,29 +263,29 @@ void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool ma
         default:
             left = right = bottom = top = 0;
         }
-        const qreal title = titleHeight + d->themeConfig.titleEdgeTop() + d->themeConfig.titleEdgeBottom();
+        const qreal title = hideTitleBar ? 0 : (titleHeight + d->themeConfig.titleEdgeTop() + d->themeConfig.titleEdgeBottom());
         switch ((DecorationPosition)d->themeConfig.decorationPosition()) {
         case DecorationTop:
             left   += d->themeConfig.borderLeft();
             right  += d->themeConfig.borderRight();
             bottom += d->themeConfig.borderBottom();
-            top     = title;
+            top     = title == 0 ? d->themeConfig.borderBottom() : title;
             break;
         case DecorationBottom:
             left   += d->themeConfig.borderLeft();
             right  += d->themeConfig.borderRight();
-            bottom  = title;
+            bottom  = title == 0 ? d->themeConfig.borderTop() : title;
             top    += d->themeConfig.borderTop();
             break;
         case DecorationLeft:
-            left    = title;
+            left    = title == 0 ? d->themeConfig.borderRight() : title;
             right  += d->themeConfig.borderRight();
             bottom += d->themeConfig.borderBottom();
             top    += d->themeConfig.borderTop();
             break;
         case DecorationRight:
             left   += d->themeConfig.borderLeft();
-            right   = title;
+            right   = title == 0 ? d->themeConfig.borderLeft() : title;
             bottom += d->themeConfig.borderBottom();
             top    += d->themeConfig.borderTop();
             break;
diff --git a/plugins/kdecorations/aurorae/src/lib/auroraetheme.h b/plugins/kdecorations/aurorae/src/lib/auroraetheme.h
index f3f7b9943..cb46754e1 100644
--- a/plugins/kdecorations/aurorae/src/lib/auroraetheme.h
+++ b/plugins/kdecorations/aurorae/src/lib/auroraetheme.h
@@ -222,6 +222,7 @@ private:
     void padding(int &left, int &top, int &right, int &bottom) const;
 
     AuroraeThemePrivate* const d;
+    bool hideTitleBar = false;
 };
 
 } // namespace