Merge pull request #2507 from Elv13/xmas_2k18_1
New theme API groundwork
This commit is contained in:
commit
7ff635bde0
|
@ -163,7 +163,7 @@ local tasklist_buttons = gears.table.join(
|
|||
end))
|
||||
|
||||
-- @DOC_WALLPAPER@
|
||||
local function set_wallpaper(s)
|
||||
screen.connect_signal("request::wallpaper", function(s)
|
||||
-- Wallpaper
|
||||
if beautiful.wallpaper then
|
||||
local wallpaper = beautiful.wallpaper
|
||||
|
@ -173,16 +173,10 @@ local function set_wallpaper(s)
|
|||
end
|
||||
gears.wallpaper.maximized(wallpaper, s, true)
|
||||
end
|
||||
end
|
||||
|
||||
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
|
||||
screen.connect_signal("property::geometry", set_wallpaper)
|
||||
end)
|
||||
|
||||
-- @DOC_FOR_EACH_SCREEN@
|
||||
awful.screen.connect_for_each_screen(function(s)
|
||||
-- Wallpaper
|
||||
set_wallpaper(s)
|
||||
|
||||
screen.connect_signal("request::desktop_decoration", function(s)
|
||||
-- Each screen has its own tag table.
|
||||
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "common/luaclass.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
#define CONNECTED_SUFFIX "::connected"
|
||||
|
||||
struct lua_class_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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -512,4 +532,6 @@ luaA_class_new(lua_State *L, lua_class_t *lua_class)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#undef CONNECTED_SUFFIX
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -14,6 +14,9 @@ This document was last updated at commit v4.3-197-g9085ed631.
|
|||
|
||||
## 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
|
||||
`selection.acquire`, `selection.getter`, and `selection.watcher` objects
|
||||
* Pending delayed calls (`gears.timer.delayed_call`) can be dispatched via
|
||||
|
|
|
@ -602,6 +602,54 @@ function screen.object.set_dpi(s, dpi)
|
|||
s.data.dpi = dpi
|
||||
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.
|
||||
-- @signal tag::history::update
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
local fake_screens = {}
|
||||
|
||||
_G.screen = setmetatable({
|
||||
connect_signal = function() end,
|
||||
set_index_miss_handler = function() end,
|
||||
set_newindex_miss_handler = function() end,
|
||||
}, {
|
||||
|
|
Loading…
Reference in New Issue