-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

I'm currently trying to make my config work with current master. One thing I
found: awful.widget.graph and .progressbar don't offer the same features their C
counterparts had. I'll see if I write some patches on this...

The first patch makes awful.wibox() work with non-north orientation and
user-specified geometries.

The second one is some cleanup and a fix to naughty (I wonder why no one ran
into this yet...).

The last one fixes the SIGSEGV handling, because we can't use libev for this.
See the commit msg for an explanation.

Let's see which other patches I will come up with... (Anyone wants to enhance
awful.widget.*? vertical progressbars and graphs with more than one graph sound
like a goal (I use one graph which shows used mem and caches/buffers at the same
time))

Cheers,
Uli
- --
"Do you know that books smell like nutmeg or some spice from a foreign land?"
                                                  -- Faber in Fahrenheit 451
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQEcBAEBCAAGBQJKKk1gAAoJECLkKOvLj8sGkEoIAJq43QLn24uLcCGUKxHmV7ZQ
k7M7/WJmGb08ZzvxgHIZOxy0joBgGFibxk9jSPWFPt0kVQXR9FGvMBrWfPglUOLY
igBp8TtaJl8fc1daeA8jI0fLpJk49Tu9+GVnN5Hi09l1SzP0DBSyNr6eEDP7JfIw
iUiNDWRvqyKBIUIVpYS3uv5SlnjyLQOeT3ctQhnIFOQOtDWbr+MJvFhrNWZBL9V9
NFxv9/utenY9O57RJSVmbSPTuVPPAWTpPazfpwRkmC6fVF/kEWkjn4TZ593rRBYg
STQfafRS4IJhHVNj0I+ilt8tHkOJ8L0knXITBfGU7W+PedC7bUwsccXhsjZGUJI=
=zYBq
-----END PGP SIGNATURE-----
>From 304cc3c9f787719a043d81368bd0171f1dbbca5c Mon Sep 17 00:00:00 2001
From: Uli Schlachter <psyc...@znc.in>
Date: Fri, 5 Jun 2009 23:28:54 +0200
Subject: [PATCH 1/3] awful.wibox(): Honour user specified geometries

If a wibox with non-north geometry was created and a wibox size was specified,
this function happily ignored it when it made the wibox fit.

The hunk in wibox.c partly reverts 7cc0b13eae2638aaab40bfd1632036a6bea4d8d4.
No idea if this is a good idea or why that one was done...

Thanks to Garoth who found this bug.

Signed-off-by: Uli Schlachter <psyc...@znc.in>
---
 lib/awful/wibox.lua.in |   24 ++++++++++++++++++------
 wibox.c                |    4 ++--
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in
index 190caea..48c710c 100644
--- a/lib/awful/wibox.lua.in
+++ b/lib/awful/wibox.lua.in
@@ -237,14 +237,26 @@ function new(arg)
     -- Empty position and align in arg so we are passing deprecation warning
     arg.position = nil
 
+    -- Set default size
+    if position == "left" or position == "right" then
+        arg.width = arg.width or capi.awesome.font_height * 1.5
+        arg.height = arg.height or 100
+    else
+        arg.width = arg.width or 100
+        arg.height = arg.height or capi.awesome.font_height * 1.5
+    end
+
     local w = capi.wibox(arg)
 
-    if position == "left" then
-        w.orientation = "north"
-        w:geometry({ width = capi.awesome.font_height * 1.5 })
-    elseif position == "right" then
-        w.orientation = "south"
-        w:geometry({ width = capi.awesome.font_height * 1.5 })
+    if position == "left" or position == "right" then
+        if position == "left" then
+            w.orientation = "north"
+        else
+            w.orientation = "south"
+        end
+        -- We need to swap width and height
+        local old_geom = w:geometry()
+        w:geometry({ width = old_geom.height, height = old_geom.width })
     end
 
     w.screen = arg.screen or 1
diff --git a/wibox.c b/wibox.c
index 69009c9..a54634c 100644
--- a/wibox.c
+++ b/wibox.c
@@ -488,8 +488,8 @@ luaA_wibox_new(lua_State *L)
     w->sw.border.width = luaA_getopt_number(L, 2, "border_width", 0);
     w->sw.geometry.x = luaA_getopt_number(L, 2, "x", 0);
     w->sw.geometry.y = luaA_getopt_number(L, 2, "y", 0);
-    w->sw.geometry.width = luaA_getopt_number(L, 2, "width", 100);
-    w->sw.geometry.height = luaA_getopt_number(L, 2, "height", globalconf.font->height * 1.5);
+    w->sw.geometry.width = luaA_getopt_number(L, 2, "width", 0);
+    w->sw.geometry.height = luaA_getopt_number(L, 2, "height", 0);
 
     w->isvisible = true;
     w->cursor = a_strdup("left_ptr");
-- 
1.6.3.1

>From e3f5970ad30d2e601a5766ee1d2932f814d8e4c9 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <psyc...@znc.in>
Date: Sat, 6 Jun 2009 12:28:25 +0200
Subject: [PATCH 2/3] Minor fixes

Remove an unused var and fix a reference to capi.awesome

Signed-off-by: Uli Schlachter <psyc...@znc.in>
---
 lib/awful/wibox.lua.in |    1 -
 lib/naughty.lua.in     |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in
index 48c710c..111f6ec 100644
--- a/lib/awful/wibox.lua.in
+++ b/lib/awful/wibox.lua.in
@@ -231,7 +231,6 @@ end
 -- If not specified, 1 is assumed.
 -- @return The wibox created.
 function new(arg)
-    local screen = screen or 1
     local arg = arg or {}
     local position = arg.position or "top"
     -- Empty position and align in arg so we are passing deprecation warning
diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in
index 7be4a81..c8a049c 100644
--- a/lib/naughty.lua.in
+++ b/lib/naughty.lua.in
@@ -261,7 +261,7 @@ function notify(args)
 
     -- beautiful
     local beautiful = bt.get()
-    local font = args.font or preset.font or beautiful.font or awesome.font
+    local font = args.font or preset.font or beautiful.font or capi.awesome.font
     local fg = args.fg or preset.fg or beautiful.fg_normal or '#ffffff'
     local bg = args.bg or preset.bg or beautiful.bg_normal or '#535d6c'
     local border_color = args.border_color or preset.border_color or beautiful.bg_focus or '#535d6c'
-- 
1.6.3.1

>From 51c5a4ad6f76d455f96c4bfdc24da52082df1660 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <psyc...@znc.in>
Date: Fri, 5 Jun 2009 23:44:37 +0200
Subject: [PATCH 3/3] Fix the SIGSEGV handling

We can't use libev's signal handling here but have to use sigaction() directly,
because libev only writes to a pipe in the real signal handler and then calls
our callback in the next main loop iteration.
The problem here is that returning from a SIGSEGV signal handler is a in
general a Bad Idea (tm) and thus we need to use a "direct" signal handler.

Signed-off-by: Uli Schlachter <psyc...@znc.in>
---
 awesome.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/awesome.c b/awesome.c
index fd8ecd7..ecb8dfb 100644
--- a/awesome.c
+++ b/awesome.c
@@ -236,7 +236,7 @@ xerrorstart(void * data __attribute__ ((unused)),
 }
 
 static void
-signal_fatal(EV_P_ ev_signal *w, int revents)
+signal_fatal(int signum)
 {
     buffer_t buf;
     backtrace_get(&buf);
@@ -408,7 +408,6 @@ main(int argc, char **argv)
     ev_signal_init(&sigint, exit_on_signal, SIGINT);
     ev_signal_init(&sigterm, exit_on_signal, SIGTERM);
     ev_signal_init(&sighup, restart_on_signal, SIGHUP);
-    ev_signal_init(&sighup, signal_fatal, SIGSEGV);
     ev_signal_start(globalconf.loop, &sigint);
     ev_signal_start(globalconf.loop, &sigterm);
     ev_signal_start(globalconf.loop, &sighup);
@@ -416,6 +415,12 @@ main(int argc, char **argv)
     ev_unref(globalconf.loop);
     ev_unref(globalconf.loop);
 
+    struct sigaction sa;
+    sa.sa_handler = signal_fatal;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = 0;
+    sigaction(SIGSEGV, &sa, 0);
+
     /* X stuff */
     globalconf.connection = xcb_connect(NULL, &globalconf.default_screen);
     if(xcb_connection_has_error(globalconf.connection))
-- 
1.6.3.1

Reply via email to