selection_acquire: Change the API to a table

As requested in the review, instead of just having a single string
argument, selection_acquire() now has a table as its argument. It
searches the string under the "selection" key here.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2019-02-17 08:00:57 +01:00
parent c3338c5a74
commit 01bd2d1896
2 changed files with 10 additions and 7 deletions

View File

@ -139,7 +139,10 @@ luaA_selection_acquire_new(lua_State *L)
xcb_atom_t name_atom;
selection_acquire_t *selection;
name = luaL_checklstring(L, 2, &name_length);
luaA_checktable(L, 2);
lua_pushliteral(L, "selection");
lua_gettable(L, 2);
name = luaL_checklstring(L, -1, &name_length);
/* Get the atom identifying the selection */
reply = xcb_intern_atom_reply(globalconf.connection,

View File

@ -66,20 +66,20 @@ end
runner.run_steps{
function()
-- Get the selection
local s = assert(selection_acquire("CLIPBOARD"),
local s = assert(selection_acquire{ selection = "CLIPBOARD" },
"Failed to acquire the clipboard selection")
-- Steal selection ownership from ourselves and test that it works
local s_released
s:connect_signal("release", function() s_released = true end)
selection = assert(selection_acquire("CLIPBOARD"),
selection = assert(selection_acquire{ selection = "CLIPBOARD" },
"Failed to acquire the clipboard selection")
assert(s_released)
-- Now test selection transfers
selection = assert(selection_acquire("CLIPBOARD"),
selection = assert(selection_acquire{ selection = "CLIPBOARD" },
"Failed to acquire the clipboard selection")
selection:connect_signal("request", function(_, target, transfer)
if target == "TARGETS" then
@ -108,7 +108,7 @@ runner.run_steps{
continue = false
-- Now test piece-wise selection transfers
selection = assert(selection_acquire("CLIPBOARD"),
selection = assert(selection_acquire{ selection = "CLIPBOARD" },
"Failed to acquire the clipboard selection")
selection:connect_signal("request", function(_, target, transfer)
if target == "TARGETS" then
@ -148,7 +148,7 @@ runner.run_steps{
continue = false
-- Now test a huge transfer
selection = assert(selection_acquire("CLIPBOARD"),
selection = assert(selection_acquire{ selection = "CLIPBOARD" },
"Failed to acquire the clipboard selection")
selection:connect_signal("request", function(_, target, transfer)
if target == "TARGETS" then
@ -212,7 +212,7 @@ runner.run_steps{
continue = false
-- Test for "release" signal when we lose selection
selection = assert(selection_acquire("CLIPBOARD"),
selection = assert(selection_acquire{ selection = "CLIPBOARD" },
"Failed to acquire the clipboard selection")
selection:connect_signal("release", function() selection_released = true end)
awesome.sync()