Merge pull request #2507 from Elv13/xmas_2k18_1

New theme API groundwork
This commit is contained in:
Emmanuel Lepage Vallée 2019-04-18 13:00:58 -04:00 committed by GitHub
commit 7ff635bde0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 9 deletions

View File

@ -163,7 +163,7 @@ local tasklist_buttons = gears.table.join(
end)) end))
-- @DOC_WALLPAPER@ -- @DOC_WALLPAPER@
local function set_wallpaper(s) screen.connect_signal("request::wallpaper", function(s)
-- Wallpaper -- Wallpaper
if beautiful.wallpaper then if beautiful.wallpaper then
local wallpaper = beautiful.wallpaper local wallpaper = beautiful.wallpaper
@ -173,16 +173,10 @@ local function set_wallpaper(s)
end end
gears.wallpaper.maximized(wallpaper, s, true) gears.wallpaper.maximized(wallpaper, s, true)
end end
end end)
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
screen.connect_signal("property::geometry", set_wallpaper)
-- @DOC_FOR_EACH_SCREEN@ -- @DOC_FOR_EACH_SCREEN@
awful.screen.connect_for_each_screen(function(s) screen.connect_signal("request::desktop_decoration", function(s)
-- Wallpaper
set_wallpaper(s)
-- Each screen has its own tag table. -- Each screen has its own tag table.
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])

View File

@ -22,6 +22,8 @@
#include "common/luaclass.h" #include "common/luaclass.h"
#include "common/luaobject.h" #include "common/luaobject.h"
#define CONNECTED_SUFFIX "::connected"
struct lua_class_property struct lua_class_property
{ {
/** Name of the property */ /** Name of the property */
@ -300,6 +302,24 @@ luaA_class_connect_signal_from_stack(lua_State *L, lua_class_t *lua_class,
const char *name, int ud) const char *name, int ud)
{ {
luaA_checkfunction(L, ud); luaA_checkfunction(L, ud);
/* Duplicate the function in the stack */
lua_pushvalue(L, ud);
char *buf = p_alloca(char, a_strlen(name) + a_strlen(CONNECTED_SUFFIX) + 1);
/* Create a new signal to notify there is a global connection. */
sprintf(buf, "%s%s", name, CONNECTED_SUFFIX);
/* Emit a signal to notify Lua of the global connection.
*
* This can useful during initialization where the signal needs to be
* artificially emitted for existing objects as soon as something connects
* to it
*/
luaA_class_emit_signal(L, lua_class, buf, 1);
/* Register the signal to the CAPI list */
signal_connect(&lua_class->signals, name, luaA_object_ref(L, ud)); signal_connect(&lua_class->signals, name, luaA_object_ref(L, ud));
} }
@ -512,4 +532,6 @@ luaA_class_new(lua_State *L, lua_class_t *lua_class)
return 1; return 1;
} }
#undef CONNECTED_SUFFIX
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -14,6 +14,9 @@ This document was last updated at commit v4.3-197-g9085ed631.
## New features ## New features
* `awful.screen` now has a `request::wallpaper` and a
`request::desktop_decoration` signal. They make some workflow implementation
cleaner.
* Lua code can interact with the selection contents via the new * Lua code can interact with the selection contents via the new
`selection.acquire`, `selection.getter`, and `selection.watcher` objects `selection.acquire`, `selection.getter`, and `selection.watcher` objects
* Pending delayed calls (`gears.timer.delayed_call`) can be dispatched via * Pending delayed calls (`gears.timer.delayed_call`) can be dispatched via

View File

@ -602,6 +602,54 @@ function screen.object.set_dpi(s, dpi)
s.data.dpi = dpi s.data.dpi = dpi
end end
--- Emitted when a new screen is added.
--
-- The handler(s) of this signal are responsible of adding elements such as
-- bars, docks or other elements to a screen. The signal is emitted when a
-- screen is added, including during startup.
--
-- The only default implementation is the one provided by `rc.lua`.
--
-- @signal request::desktop_decoration
-- @tparam screen s The screen object.
--- Emitted when a new screen needs a wallpaper.
--
-- The handler(s) of this signal are responsible to set the wallpaper. The
-- signal is emitted when a screen is added (including at startup), when its
-- DPI changes or when its geometry changes.
--
-- The only default implementation is the one provided by `rc.lua`.
--
-- @signal request::wallpaper
-- @tparam screen s The screen object.
-- Set the wallpaper(s) and create the bar(s) for new screens
capi.screen.connect_signal("added", function(s)
s:emit_signal("request::desktop_decoration")
s:emit_signal("request::wallpaper")
end)
-- Resize the wallpaper(s)
for _, prop in ipairs {"geometry", "dpi" } do
capi.screen.connect_signal("property::"..prop, function(s)
s:emit_signal("request::wallpaper")
end)
end
-- Create the bar for existing screens when an handler is added
capi.screen.connect_signal("request::desktop_decoration::connected", function(new_handler)
for s in capi.screen do
new_handler(s)
end
end)
-- Set the wallpaper when an handler is added.
capi.screen.connect_signal("request::wallpaper::connected", function(new_handler)
for s in capi.screen do
new_handler(s)
end
end)
--- When the tag history changed. --- When the tag history changed.
-- @signal tag::history::update -- @signal tag::history::update

View File

@ -6,6 +6,7 @@
local fake_screens = {} local fake_screens = {}
_G.screen = setmetatable({ _G.screen = setmetatable({
connect_signal = function() end,
set_index_miss_handler = function() end, set_index_miss_handler = function() end,
set_newindex_miss_handler = function() end, set_newindex_miss_handler = function() end,
}, { }, {