You are not logged in.

#76 2017-03-04 19:09:06

hhh
Meep!
Registered: 2015-09-17
Posts: 9,587
Website

Re: Openbox with rounded corners

New thread to discuss xfce4-notifyd...
https://forums.bunsenlabs.org/viewtopic.php?id=3440

Offline

#77 2017-03-06 22:22:32

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Openbox with rounded corners

Per hhh's wish, the openbox patch has been extended to mask round corners on root- and client-list- menus in addition to decorated (normal) windows. The rc.xml parameter <cornerRadius> (in <theme> section) is augmented with an optional attribute "menu". New configuration examples:

<cornerRadius>8</cornerRadius>
<cornerRadius menu="yes">8</cornerRadius>
<cornerRadius menu="no">8</cornerRadius>

The "menu" attribute can be set to any openbox boolean value (true, false, yes, no, on, off). When omitted (or invalid value), it defaults to true. A true value gives rounded OB menu corners and a false value gives square menu corners.

The masking algorithm is encapsulated as a single function applied to both decorated windows and menus; the change in code size is minimal. The OB prompt and popup windows and their display methods are structured differently and require more time than I want to commit creating or adapting a solution for them.

The patch is designed for jessie (openbox-3.5.2), but can be applied to stretch (openbox-3.6.2; patch correctly offsets hunks as needed). Caveats from post 42814 still apply. The patch:

--- a/openbox/config.h	2017-03-03 21:48:15.000000000 -0700
+++ b/openbox/config.h	2017-03-06 14:35:56.084377574 -0700
@@ -152,6 +152,9 @@
 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;
+extern gboolean config_theme_menuradius;
 
 /*! The font for the active window's title */
 extern RrFont *config_font_activewindow;
--- a/openbox/config.c	2017-03-03 21:48:15.000000000 -0700
+++ b/openbox/config.c	2017-03-06 14:37:06.400883218 -0700
@@ -48,6 +48,8 @@
 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;
 
@@ -702,6 +704,10 @@
         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);
+    }
 
     n = obt_xml_find_node(node, "font");
     while (n) {
@@ -1078,6 +1084,8 @@
     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;
--- a/openbox/frame.c	2013-08-11 18:33:24.000000000 -0700
+++ b/openbox/frame.c	2017-03-06 14:35:56.088377603 -0700
@@ -334,6 +334,31 @@
 #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 @@
 
         if (resized) {
             self->need_render = TRUE;
-            framerender_frame(self);
             frame_adjust_shape(self);
         }
 
@@ -884,7 +908,9 @@
     {
         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 @@
     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)
--- a/openbox/framerender.c	2013-08-11 18:33:24.000000000 -0700
+++ b/openbox/framerender.c	2017-03-06 14:35:56.088377603 -0700
@@ -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,9 @@
         return;
     self->need_render = FALSE;
 
+    if ( !self->max_horz && !self->max_vert && config_theme_cornerradius )
+        frame_round_corners(self->window);
+
     {
         gulong px;
 
--- a/openbox/menuframe.c	2013-08-11 18:33:24.000000000 -0700
+++ b/openbox/menuframe.c	2017-03-06 14:35:56.088377603 -0700
@@ -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"
@@ -838,6 +839,9 @@
 
     RECT_SET_SIZE(self->area, w, h);
 
+    if ( config_theme_menuradius )
+        frame_round_corners(self->window);
+
     XFlush(obt_display);
 }
 

After using round-corner OB menus, I prefer the square as they match my GTK2 and GTK3 drop-down menus. A comprehensive application of round corners would require modification of the GTK themes as well.

EDIT 08 Mar 17 - Removed extra space causing warning with quilt.

Last edited by cpoakes (2017-03-08 14:53:01)

Offline

#78 2017-03-06 22:54:45

hhh
Meep!
Registered: 2015-09-17
Posts: 9,587
Website

Re: Openbox with rounded corners

@cpoakes, super-cool! Thanks for your work on this. smile

And I'm with you, I've grown to like sharp corners because pixels.

Offline

#79 2017-03-07 20:15:07

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Openbox with rounded corners

I have rebuilt the custom openbox packages with the new patch, the instructions in this post still apply:

https://forums.bunsenlabs.org/viewtopic … 248#p43248

The version has been bumped to 3.5.2-8.2 so it should upgrade OK.


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#80 2017-03-07 20:39:57

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Openbox with rounded corners

^ Thanks for your continued diligence. No problems with stretch?

Offline

#81 2017-03-07 20:42:32

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Openbox with rounded corners

cpoakes wrote:

No problems with stretch?

I haven't tried yet, I will report back later smile


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#82 2017-03-07 21:53:22

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Openbox with rounded corners

cpoakes wrote:

No problems with stretch?

The same message as last time...

`quilt push` seemed fine:

Applying patch rounded-corners.patch
patching file openbox/config.h
patching file openbox/config.c
Hunk #2 succeeded at 721 with fuzz 2 (offset 17 lines).
Hunk #3 succeeded at 1104 (offset 20 lines).
patching file openbox/frame.c
patching file openbox/framerender.c
patching file openbox/menuframe.c
Hunk #2 succeeded at 846 (offset 7 lines).

Now at patch rounded-corners.patch

But `debuild -us -uc` failed:

dpkg-buildpackage -rfakeroot -us -uc
dpkg-buildpackage: info: source package openbox
dpkg-buildpackage: info: source version 3.6.1-4.3
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by HoaS :)
 dpkg-source --before-build openbox-3.6.1
dpkg-buildpackage: info: host architecture amd64
 fakeroot debian/rules clean
dh clean
   dh_testdir
   debian/rules override_dh_auto_clean
make[1]: Entering directory '/home/empty/Builds/ob-round/openbox-3.6.1'
rm -f openbox.1
#rm -f kdetrayproxy.1
rm -f gnome-panel-control.1
rm -f gdm-control.1
dh_auto_clean
make[1]: Leaving directory '/home/empty/Builds/ob-round/openbox-3.6.1'
   dh_autoreconf_clean
   dh_clean
 dpkg-source -b openbox-3.6.1
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building openbox using existing ./openbox_3.6.1.orig.tar.gz
patching file openbox/config.h
patching file openbox/config.c
Hunk #2 FAILED at 704.
Hunk #3 succeeded at 1100 (offset 20 lines).
1 out of 3 hunks FAILED
patching file openbox/frame.c
patching file openbox/framerender.c
patching file openbox/menuframe.c
Hunk #2 succeeded at 846 (offset 7 lines).
dpkg-source: info: the patch has fuzz which is not allowed, or is malformed
dpkg-source: info: if patch 'rounded-corners.patch' is correctly applied by quilt, use 'quilt refresh' to update it
dpkg-source: error: LC_ALL=C patch -t -F 0 -N -p1 -u -V never -E -b -B .pc/rounded-corners.patch/ --reject-file=- < openbox-3.6.1.orig.40Jzul/debian/patches/rounded-corners.patch gave error exit status 1
dpkg-buildpackage: error: dpkg-source -b openbox-3.6.1 gave error exit status 2
debuild: fatal error at line 1116:
dpkg-buildpackage -rfakeroot -us -uc failed

The error code was 29.

I then ran `quilt refresh`:

Warning: trailing whitespace in line 354 of openbox/frame.c
Refreshed patch rounded-corners.patch

The package then built fine, here is the 64-bit .deb file:

https://drive.google.com/open?id=0BxKgG … 2F1MjRVNjg

I will add a link for the 32-bit .deb in a bit...

EDIT: here is the 32-bit (i386) .deb file:

https://drive.google.com/open?id=0BxKgG … k9sUWFsSm8

Built in Arch, weirdly...

Last edited by Head_on_a_Stick (2017-03-08 07:51:39)


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#83 2017-03-08 14:50:13

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Openbox with rounded corners

dpkg-buildpackage wrote:

dpkg-source: info: the patch has fuzz which is not allowed, or is malformed

quilt wrote:

Warning: trailing whitespace in line 354 of openbox/frame.c

The patch is designed for openbox-3.5.2, and tested by applying it to openbox-3.6.1 with patch where it applies correctly using fuzz. Seems dpkg-buildpackage is simply more stringent. And one bloody space? Fine. Here is an unfuzzed version with the errant space removed. Hope this alleviates the quilt refresh step:

openbox-3.6.1-radius.patch:

--- a/openbox/config.h	2014-11-05 08:19:42.000000000 -0700
+++ b/openbox/config.h	2017-03-06 14:40:38.982567786 -0700
@@ -152,6 +152,9 @@
 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;
+extern gboolean config_theme_menuradius;
 
 /*! The font for the active window's title */
 extern RrFont *config_font_activewindow;
--- a/openbox/config.c	2014-11-05 08:19:42.000000000 -0700
+++ b/openbox/config.c	2017-03-06 14:40:38.982567786 -0700
@@ -48,6 +48,8 @@
 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 @@
         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 @@
     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;
--- a/openbox/frame.c	2014-11-05 08:19:42.000000000 -0700
+++ b/openbox/frame.c	2017-03-06 14:40:38.982567786 -0700
@@ -334,6 +334,31 @@
 #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 @@
 
         if (resized) {
             self->need_render = TRUE;
-            framerender_frame(self);
             frame_adjust_shape(self);
         }
 
@@ -884,7 +908,9 @@
     {
         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 @@
     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)
--- a/openbox/framerender.c	2014-11-05 09:00:49.000000000 -0700
+++ b/openbox/framerender.c	2017-03-06 14:40:38.986567825 -0700
@@ -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,9 @@
         return;
     self->need_render = FALSE;
 
+    if ( !self->max_horz && !self->max_vert && config_theme_cornerradius )
+        frame_round_corners(self->window);
+
     {
         gulong px;
 
--- a/openbox/menuframe.c	2014-11-05 08:19:42.000000000 -0700
+++ b/openbox/menuframe.c	2017-03-06 14:40:38.986567825 -0700
@@ -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 @@
 
     RECT_SET_SIZE(self->area, w, h);
 
+    if ( config_theme_menuradius )
+        frame_round_corners(self->window);
+
     XFlush(obt_display);
 }
 

Caveats: Still not tested on stretch or with packaging tools - simply adjusted per error messages and run through patch. There are no fuzz messages and the outcome is identical sans one space. Hope this satisfies dpkg-buildpackage.

Offline

#84 2017-03-08 18:38:05

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Openbox with rounded corners

cpoakes wrote:

Hope this satisfies dpkg-buildpackage.

Yes it does, good work!

cool


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#85 2017-04-05 18:45:04

o9000
tint2 developer
From: Network Neighborhood
Registered: 2015-10-24
Posts: 400
Website

Re: Openbox with rounded corners

Slightly off topic...

If you are planning to create a patched Openbox for BL, you might want to include this patch: https://github.com/danakj/openbox/pull/26

I got Openbox to crash as I was fiddling with some settings. It only happened occasionally when the title bar contained only the close button, nothing else. I tracked it down to that line.

By the way, that's some crappy code. I took a look around, the frame drawing is silly, it's creating a separate X window for every little item, such as each edge of the border, each handle, each icon... I think there are about 2 dozen windows created overall for a single frame. Because of this, the layout and drawing code is very complicated. No wonder it's so hard to make the corners rounded.

But maybe I shouldn't complain, tint2 isn't much better, it used to be a mess actually, although it's cleaner now...

Anyways. It might be a good idea to report this upstream, but the website (bugzilla.icculus.org) is dead. Github has the bugtracker disabled, but Dana should get a notification for the pull request. If nothing happens, I guess forwarding to debian remains as a measure of last resort.

Offline

#86 2017-04-06 08:34:39

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Re: Openbox with rounded corners

^Thanks. I don't think the patch is destined to be part of BL but I expect a patched package to be available for interested users.

I think the frame rendering only looks silly in a modern context. X was designed to work over remote connections which historically were pretty slow. With this structure, only the (sub)window of the frame that actually changes needs to be updated. Once upon a time it was an optimization! Blame the legacy of a 30 year old standard.

Offline

#87 2017-04-06 17:27:12

cloverskull
Member
Registered: 2015-10-01
Posts: 307

Re: Openbox with rounded corners

I vote we fork OpenBox.

big_smile

Offline

#88 2017-04-06 19:27:35

damo
....moderator....
Registered: 2015-08-20
Posts: 5,971

Re: Openbox with rounded corners

cloverskull wrote:

I vote we fork OpenBox.

big_smile

You volunteering to maintain and package it?  devil


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#89 2017-04-06 23:34:42

cloverskull
Member
Registered: 2015-10-01
Posts: 307

Re: Openbox with rounded corners

*runs*

Offline

#90 2017-09-17 00:07:23

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Openbox with rounded corners

I just realized: In my post above (Nr. 55) there is a wrong filename as it should be openbox_3.5.2-8.2_amd64.deb. I'll correct it. After a fools upgrade I lost the rounded corners feature. I did like those corners though, is it maybe available for 9.0?

Offline

#91 2017-09-17 00:59:05

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Openbox with rounded corners

martix wrote:

I did like those corners though, is it maybe available for 9.0?

I can make a stretch-based package now but the jessie one should still work with 9.0  wink


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#92 2017-09-17 12:35:51

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Openbox with rounded corners

^Do you mean to simply remove openbox 3.6.1-4 - which I currently have - and install openbox_3.5.2-8.2_amd64.deb instead?
The cornerRadius line is still there in the .rc file.

Offline

#93 2017-09-17 16:18:06

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Openbox with rounded corners

martix wrote:

Do you mean to simply remove openbox 3.6.1-4 - which I currently have - and install openbox_3.5.2-8.2_amd64.deb instead?

Yes, clearly that won't work and I was talking out of my *ss (again), thank you for pulling me up on that one.

I will look at patching the stretch openbox package when I have a moment.

If you get impatient, here is the guide that I use for patching .debs:

https://raphaelhertzog.com/2012/08/08/h … -packages/

The openSUSE Build Repository that I use to host the packages is open to all, here is @stevep's awesome usage guide from fdn:

http://forums.debian.net/viewtopic.php?f=16&t=130057

Last edited by Head_on_a_Stick (2017-09-17 20:30:00)


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

Board footer

Powered by FluxBB