From a55baf9e3c4e4d4b87752ed74da15586e82b08bb Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 28 Apr 2016 17:45:36 +0200 Subject: [PATCH 1/3] Default config: Allow beautiful.wallpaper to be a wallpaper This e.g. allows themes to specify different wallpapers for different screens. Signed-off-by: Uli Schlachter --- awesomerc.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/awesomerc.lua b/awesomerc.lua index 41d8fcb3..7d511e0a 100755 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -168,7 +168,12 @@ mytasklist.buttons = awful.util.table.join( awful.screen.connect_for_each_screen(function(s) -- Wallpaper if beautiful.wallpaper then - gears.wallpaper.maximized(beautiful.wallpaper, s, true) + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) end -- Each screen has its own tag table. From 1714a6513b8a72743c0544279b7b5e196bf878c4 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 28 Apr 2016 17:47:12 +0200 Subject: [PATCH 2/3] xresources theme: Let beautiful.wallpaper be a function This makes the code create a wallpaper of the correct size, instead of cairo later having to scale the wallpaper up to fill the screen (if it has a different size than screen 1). Signed-off-by: Uli Schlachter --- themes/xresources/assets.lua | 7 ++++--- themes/xresources/theme.lua | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/themes/xresources/assets.lua b/themes/xresources/assets.lua index 98803078..e7a7db72 100644 --- a/themes/xresources/assets.lua +++ b/themes/xresources/assets.lua @@ -47,9 +47,10 @@ function theme_assets.taglist_squares_unsel(size, fg) end -function theme_assets.wallpaper(bg, fg, alt_fg) - local height = screen[1].workarea.height - local width = screen[1].workarea.width +function theme_assets.wallpaper(bg, fg, alt_fg, s) + s = s or screen.primary + local height = s.workarea.height + local width = s.workarea.width local img = cairo.ImageSurface(cairo.Format.ARGB32, width, height) local cr = cairo.Context(img) diff --git a/themes/xresources/theme.lua b/themes/xresources/theme.lua index 50791479..a1cea1a2 100644 --- a/themes/xresources/theme.lua +++ b/themes/xresources/theme.lua @@ -91,9 +91,9 @@ local wallpaper_alt_fg = xrdb.color12 if not is_dark_bg then wallpaper_bg, wallpaper_fg = wallpaper_fg, wallpaper_bg end -theme.wallpaper = theme_assets.wallpaper( - wallpaper_bg, wallpaper_fg, wallpaper_alt_fg -) +theme.wallpaper = function(s) + return theme_assets.wallpaper(wallpaper_bg, wallpaper_fg, wallpaper_alt_fg, s) +end return theme From daf05e6eb11435a8ed095934ad36dfbd88b06ab2 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 28 Apr 2016 17:53:19 +0200 Subject: [PATCH 3/3] xresources theme: Use a RecordingSurface for wallpaper This theme draws a minimal wallpaper directly. This commit replaces the ImageSurface of the wallpaper with a RecordingSurface. This shouldn't have any visible effect, except for reducing memory usage, because an ImageSurface needs a lot of memory and is only eventually released by the garbage collector. A RecordingSurface instead just records the operations that were done which needs a lot less memory for the simple operations done here. Signed-off-by: Uli Schlachter --- themes/xresources/assets.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/xresources/assets.lua b/themes/xresources/assets.lua index e7a7db72..c8355024 100644 --- a/themes/xresources/assets.lua +++ b/themes/xresources/assets.lua @@ -51,7 +51,8 @@ function theme_assets.wallpaper(bg, fg, alt_fg, s) s = s or screen.primary local height = s.workarea.height local width = s.workarea.width - local img = cairo.ImageSurface(cairo.Format.ARGB32, width, height) + local img = cairo.RecordingSurface(cairo.Content.COLOR, + cairo.Rectangle { x = 0, y = 0, width = width, height = height }) local cr = cairo.Context(img) local letter_size = height/10