aboutsummarylogtreecommitdiffstats
path: root/openbox-3.6.2-rounded-corners.patch
blob: cc4f0d1b8fb1e140f5256c25f717e8c20ebcf200 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
From 582568b08c354f4bb037bcfb00dd440a59d7cbe0 Mon Sep 17 00:00:00 2001
From: cpoakes <cpoakes@users.noreply.github.com>
Date: Tue, 29 Aug 2017 19:56:29 -0500
Subject: [PATCH] openbox-3.6.2-rounded-corners

---
 openbox/config.c      |  8 ++++++++
 openbox/config.h      |  4 ++++
 openbox/frame.c       | 30 +++++++++++++++++++++++++++++-
 openbox/framerender.c |  7 +++++++
 openbox/menuframe.c   |  4 ++++
 5 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/openbox/config.c b/openbox/config.c
index dad5d1bf..a387335c 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -48,6 +48,8 @@ StrutPartial config_margins;
 gchar   *config_theme;
 gboolean config_theme_keepborder;
 guint    config_theme_window_list_icon_size;
+guint    config_theme_cornerradius;
+gboolean config_theme_menuradius;
 
 gchar   *config_title_layout;
 
@@ -719,6 +721,10 @@ static void parse_theme(xmlNodePtr node, gpointer d)
         else if (config_theme_window_list_icon_size > 96)
             config_theme_window_list_icon_size = 96;
     }
+    if ((n = obt_xml_find_node(node, "cornerRadius"))) {
+	config_theme_cornerradius = obt_xml_node_int(n);
+	obt_xml_attr_bool(n, "menu", &config_theme_menuradius);
+    }
 
     for (n = obt_xml_find_node(node, "font");
          n;
@@ -1098,6 +1104,8 @@ void config_startup(ObtXmlInst *i)
     config_title_layout = g_strdup("NLIMC");
     config_theme_keepborder = TRUE;
     config_theme_window_list_icon_size = 36;
+    config_theme_cornerradius = 0;
+    config_theme_menuradius = TRUE;
 
     config_font_activewindow = NULL;
     config_font_inactivewindow = NULL;
diff --git a/openbox/config.h b/openbox/config.h
index 96a66cf1..5622d059 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -152,6 +152,10 @@ extern gchar *config_title_layout;
 extern gboolean config_animate_iconify;
 /*! Size of icons in focus switching dialogs */
 extern guint config_theme_window_list_icon_size;
+/*! Display rounded corners for decorated windows */
+extern guint config_theme_cornerradius;
+/*! Display rounded corners for root and client-list menus */
+extern gboolean config_theme_menuradius;
 
 /*! The font for the active window's title */
 extern RrFont *config_font_activewindow;
diff --git a/openbox/frame.c b/openbox/frame.c
index 89669726..db2c7531 100644
--- a/openbox/frame.c
+++ b/openbox/frame.c
@@ -334,6 +334,31 @@ void frame_adjust_shape(ObFrame *self)
 #endif
 }
 
+void frame_round_corners(Window window)
+{
+    XWindowAttributes win_attr;
+    XGetWindowAttributes(obt_display, window, &win_attr);
+    int width = win_attr.width + win_attr.border_width;
+    int height = win_attr.height + win_attr.border_width;
+    Pixmap mask = XCreatePixmap(obt_display, window, width, height, 1);
+    XGCValues xgcv;
+    GC shape_gc = XCreateGC(obt_display, mask, 0, &xgcv);
+    int rad = config_theme_cornerradius;
+    int dia = 2 * rad;
+    XSetForeground(obt_display, shape_gc, 0);
+    XFillRectangle(obt_display, mask, shape_gc, 0, 0, width, height);
+    XSetForeground(obt_display, shape_gc, 1);
+    XFillArc(obt_display, mask, shape_gc, 0, 0, dia, dia, 0, 23040);
+    XFillArc(obt_display, mask, shape_gc, width-dia-1, 0, dia, dia, 0, 23040);
+    XFillArc(obt_display, mask, shape_gc, 0, height-dia-1, dia, dia, 0, 23040);
+    XFillArc(obt_display, mask, shape_gc, width-dia-1, height-dia-1, dia, dia,
+        0, 23040);
+    XFillRectangle(obt_display, mask, shape_gc, rad, 0, width-dia, height);
+    XFillRectangle(obt_display, mask, shape_gc, 0, rad, width, height-dia);
+    XShapeCombineMask(obt_display, window, ShapeBounding, 0, 0, mask, ShapeSet);
+    XFreePixmap(obt_display, mask);
+}
+
 void frame_adjust_area(ObFrame *self, gboolean moved,
                        gboolean resized, gboolean fake)
 {
@@ -857,7 +882,6 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
 
         if (resized) {
             self->need_render = TRUE;
-            framerender_frame(self);
             frame_adjust_shape(self);
         }
 
@@ -884,7 +908,9 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
     {
         XResizeWindow(obt_display, self->label, self->label_width,
                       ob_rr_theme->label_height);
+	self->need_render = TRUE;
     }
+    framerender_frame(self);
 }
 
 static void frame_adjust_cursors(ObFrame *self)
@@ -958,6 +984,8 @@ void frame_adjust_client_area(ObFrame *self)
     XMoveResizeWindow(obt_display, self->backfront, 0, 0,
                       self->client->area.width,
                       self->client->area.height);
+    self->need_render = TRUE;
+    framerender_frame(self);
 }
 
 void frame_adjust_state(ObFrame *self)
diff --git a/openbox/framerender.c b/openbox/framerender.c
index 094d5962..54046580 100644
--- a/openbox/framerender.c
+++ b/openbox/framerender.c
@@ -21,6 +21,7 @@
 #include "openbox.h"
 #include "screen.h"
 #include "client.h"
+#include "config.h"
 #include "framerender.h"
 #include "obrender/theme.h"
 
@@ -42,6 +43,12 @@ void framerender_frame(ObFrame *self)
         return;
     self->need_render = FALSE;
 
+    if (config_theme_cornerradius &&
+            !self->client->fullscreen &&
+            !self->client->shaped &&
+            !(self->client->type == OB_CLIENT_TYPE_DOCK))
+        frame_round_corners(self->window);
+
     {
         gulong px;
 
diff --git a/openbox/menuframe.c b/openbox/menuframe.c
index c37fdcc5..f598cf15 100644
--- a/openbox/menuframe.c
+++ b/openbox/menuframe.c
@@ -17,6 +17,7 @@
    See the COPYING file for a copy of the GNU General Public License.
 */
 
+#include "frame.h"
 #include "menuframe.h"
 #include "client.h"
 #include "menu.h"
@@ -845,6 +846,9 @@ void menu_frame_render(ObMenuFrame *self)
 
     RECT_SET_SIZE(self->area, w, h);
 
+    if (config_theme_menuradius)
+        frame_round_corners(self->window);
+
     XFlush(obt_display);
 }
 
-- 
2.14.1