client: deprecate client_get() and client_set()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-12 12:08:20 +02:00
parent 125c259204
commit c2f8275bf8
6 changed files with 104 additions and 45 deletions

View file

@ -106,7 +106,7 @@ mytaglist.label = awful.widget.taglist.label.all
-- Create a tasklist widget
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
mytasklist:mouse_add(mouse({ }, 1, function (object, c) client.focus = c; c:raise() end))
mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
mytasklist.label = awful.widget.tasklist.label.currenttags
@ -187,7 +187,7 @@ for i = 1, keynumber do
end):add()
keybinding({ modkey, "Shift" }, i,
function ()
local sel = client.focus_get()
local sel = client.focus
if sel then
if tags[sel.screen][i] then
awful.client.movetotag(tags[sel.screen][i])
@ -196,7 +196,7 @@ for i = 1, keynumber do
end):add()
keybinding({ modkey, "Control", "Shift" }, i,
function ()
local sel = client.focus_get()
local sel = client.focus
if sel then
if tags[sel.screen][i] then
awful.client.toggletag(tags[sel.screen][i])
@ -217,15 +217,15 @@ keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
-- Client manipulation
keybinding({ modkey }, "m", awful.client.maximize):add()
keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus_get():raise() end):add()
keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus_get():raise() end):add()
keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus:raise() end):add()
keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus:raise() end):add()
keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
keybinding({ modkey }, "o", awful.client.movetoscreen):add()
keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
@ -259,7 +259,7 @@ keybinding({ modkey, "Control" }, "y", function ()
tabbedview = tabulous.tab_create()
tabulous.tab(tabbedview, nextclient)
else
tabulous.tab(tabbedview, client.focus_get())
tabulous.tab(tabbedview, client.focus)
end
else
tabulous.tab(tabbedview, nextclient)
@ -336,7 +336,7 @@ end
function hook_mouseover(c)
-- Sloppy focus, but disabled for magnifier layout
if awful.layout.get(c.screen) ~= "magnifier" then
c:focus_set()
client.focus = c
end
end
@ -349,14 +349,14 @@ function hook_manage(c)
awful.titlebar.add(c, { modkey = modkey })
end
-- Add mouse bindings
c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
c:mouse_add(mouse({ }, 1, function (c) client.focus = c; c:raise() end))
c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
-- New client may not receive focus
-- if they're not focusable, so set border anyway.
c.border_width = beautiful.border_width
c.border_color = beautiful.border_normal
c:focus_set()
client.focus = c
-- Check if the application should be floating.
local cls = c.class
@ -395,14 +395,14 @@ function hook_arrange(screen)
end
-- If no window has focus, give focus to the latest in history
if not client.focus_get() then
if not client.focus then
local c = awful.client.focus.history.get(screen, 0)
if c then c:focus_set() end
if c then client.focus = c end
end
-- Uncomment if you want mouse warping
--[[
local sel = client.focus_get()
local sel = client.focus
if sel then
local c_c = sel.coords
local m_c = mouse.coords

View file

@ -79,10 +79,12 @@ for i, line in ipairs(ilines) do
if not libname and line:find("^luaA_.*_index") then
local fctname, fctdef
_, _, fctdef, fctname = line:find("^(luaA_(.+)_index)")
print(function_doc[fctdef]:comment_translate())
print("-- @class table")
print("-- @name " .. fctname)
print(fctname)
if function_doc[fctdef] and not fctdef:find("_module_") then
print(function_doc[fctdef]:comment_translate())
print("-- @class table")
print("-- @name " .. fctname)
print(fctname)
end
end
else
if line:find("};") then

View file

@ -914,7 +914,7 @@ luaA_client_visible_get(lua_State *L)
return 1;
}
/** Get the currently focused client.
/** Get the currently focused client (DEPRECATED).
* \param L The Lua VM state.
* \luastack
* \lreturn The currently focused client.
@ -924,6 +924,7 @@ luaA_client_focus_get(lua_State *L)
{
if(globalconf.screen_focus->client_focus)
return luaA_client_userdata_new(L, globalconf.screen_focus->client_focus);
deprecate();
return 0;
}
@ -982,7 +983,7 @@ luaA_client_swap(lua_State *L)
return 0;
}
/** Focus a client.
/** Focus a client (DEPRECATED).
* \param L The Lua VM state.
*
* \luastack
@ -993,6 +994,7 @@ luaA_client_focus_set(lua_State *L)
{
client_t **c = luaA_checkudata(L, 1, "client");
client_focus(*c);
deprecate();
return 0;
}
@ -1208,6 +1210,7 @@ luaA_client_newindex(lua_State *L)
* \lfield titlebar The client titlebar.
* \lfield urgent The client urgent state.
* \lfield tags The clients tags.
* \lfield focus The focused client.
*/
static int
luaA_client_index(lua_State *L)
@ -1334,11 +1337,62 @@ luaA_client_index(lua_State *L)
return 1;
}
/* Client module.
* \param L The Lua VM state.
* \return The number of pushed elements.
*/
static int
luaA_client_module_index(lua_State *L)
{
size_t len;
const char *buf = luaL_checklstring(L, 2, &len);
switch(a_tokenize(buf, len))
{
case A_TK_FOCUS:
if(globalconf.screen_focus->client_focus)
luaA_client_userdata_new(L, globalconf.screen_focus->client_focus);
else
return 0;
break;
default:
return 0;
}
return 1;
}
/* Client module new index.
* \param L The Lua VM state.
* \return The number of pushed elements.
*/
static int
luaA_client_module_newindex(lua_State *L)
{
size_t len;
const char *buf = luaL_checklstring(L, 2, &len);
client_t **c;
switch(a_tokenize(buf, len))
{
case A_TK_FOCUS:
c = luaA_checkudata(L, 3, "client");
client_focus(*c);
break;
default:
break;
}
return 0;
}
const struct luaL_reg awesome_client_methods[] =
{
{ "get", luaA_client_get },
{ "focus_get", luaA_client_focus_get },
{ "visible_get", luaA_client_visible_get },
{ "__index", luaA_client_module_index },
{ "__newindex", luaA_client_module_newindex },
{ NULL, NULL }
};
const struct luaL_reg awesome_client_meta[] =

View file

@ -123,7 +123,7 @@ end
--- Focus the previous client in history.
function client.focus.history.previous()
local sel = capi.client.focus_get()
local sel = capi.client.focus
local s
if sel then
s = sel.screen
@ -131,7 +131,7 @@ function client.focus.history.previous()
s = capi.mouse.screen
end
local c = client.focus.history.get(s, 1)
if c then c:focus_set() end
if c then capi.client.focus = c end
end
--- Get a client by its relative index to the focused window.
@ -141,7 +141,7 @@ end
-- @return A client, or nil if no client is available.
function client.next(i, c)
-- Get currently focused client
local sel = c or capi.client.focus_get()
local sel = c or capi.client.focus
if sel then
-- Get all visible clients
local cls = capi.client.visible_get(sel.screen)
@ -206,7 +206,7 @@ end
-- @param dir The direction, can be either "up", "down", "left" or "right".
-- @param c Optional client.
function client.focusbydirection(dir, c)
local sel = c or capi.client.focus_get()
local sel = c or capi.client.focus
if sel then
local coords = sel.coords
local dist, dist_min
@ -231,7 +231,7 @@ function client.focusbydirection(dir, c)
-- If we found a client to focus, then do it.
if target then
target:focus_set()
capi.client.focus = target
end
end
end
@ -242,7 +242,7 @@ end
function client.focusbyidx(i, c)
local target = client.next(i, c)
if target then
target:focus_set()
capi.client.focus = target
end
end
@ -250,7 +250,7 @@ end
-- @param i The index.
-- @param c Optional client, otherwise focused one is used.
function client.swap(i, c)
local sel = c or capi.client.focus_get()
local sel = c or capi.client.focus
local target = client.next(i, sel)
if target then
target:swap(sel)
@ -272,7 +272,7 @@ end
-- @param h The relative height.
-- @param c The optional client, otherwise focused one is used.
function client.moveresize(x, y, w, h, c)
local sel = c or capi.client.focus_get()
local sel = c or capi.client.focus
local coords = sel.coords
coords['x'] = coords['x'] + x
coords['y'] = coords['y'] + y
@ -284,7 +284,7 @@ end
--- Maximize a client to use the full workarea.
-- @param c A client, or the focused one if nil.
function client.maximize(c)
local sel = c or capi.client.focus_get()
local sel = c or capi.client.focus
if sel then
local ws = capi.screen[sel.screen].workarea
ws.width = ws.width - 2 * sel.border_width
@ -317,7 +317,7 @@ end
--- Give the focus to a screen, and move pointer.
-- @param Screen number.
function screen.focus(i)
local sel = capi.client.focus_get()
local sel = capi.client.focus
local s
if sel then
s = sel.screen
@ -326,7 +326,7 @@ function screen.focus(i)
end
s = cycle(capi.screen.count(), s + i)
local c = client.focus.history.get(s, 0)
if c then c:focus_set() end
if c then capi.client.focus = c end
-- Move the mouse on the screen
capi.mouse.coords = capi.screen[s].coords
end
@ -508,7 +508,7 @@ end
-- @param target The tag to move the client to.
-- @para c Optional client to move, otherwise the focused one is used.
function client.movetotag(target, c)
local sel = c or capi.client.focus_get();
local sel = c or capi.client.focus
if sel then
-- Check that tag and client screen are identical
if sel.screen ~= target.screen then return end
@ -521,7 +521,7 @@ end
-- @param target The tag to toggle.
-- @param c Optional client to toggle, otherwise the focused one is used.
function client.toggletag(target, c)
local sel = c or capi.client.focus_get();
local sel = c or capi.client.focus
-- Check that tag and client screen are identical
if sel and sel.screen == target.screen then
local tags = sel.tags
@ -537,7 +537,7 @@ end
--- Toggle the floating status of a client.
-- @param c Optional client, the focused on if not set.
function client.togglefloating(c)
local sel = c or capi.client.focus_get();
local sel = c or capi.client.focus
if sel then
sel.floating = not sel.floating
end
@ -547,7 +547,7 @@ end
-- @param c The client to move.
-- @param s The screen number, default to current + 1.
function client.movetoscreen(c, s)
local sel = c or capi.client.focus_get();
local sel = c or capi.client.focus
if sel then
local sc = capi.screen.count()
if not s then
@ -556,7 +556,7 @@ function client.movetoscreen(c, s)
if s > sc then s = 1 elseif s < 1 then s = sc end
sel.screen = s
capi.mouse.coords = capi.screen[s].coords
sel:focus_set()
capi.client.focus = sel
end
end
@ -604,7 +604,7 @@ hooks.user.create('unmarked')
-- @param c The client to mark, the focused one if not specified.
-- @return True if the client has been marked. False if the client was already marked.
function client.mark (c)
local cl = c or capi.client.focus_get()
local cl = c or capi.client.focus
if cl then
for k, v in pairs(awfulmarked) do
if cl == v then
@ -624,7 +624,7 @@ end
-- @param c The client to unmark, or the focused one if not specified.
-- @return True if the client has been unmarked. False if the client was not marked.
function client.unmark(c)
local cl = c or capi.client.focus_get()
local cl = c or capi.client.focus
for k, v in pairs(awfulmarked) do
if cl == v then
@ -640,7 +640,7 @@ end
--- Check if a client is marked.
-- @param c The client to check, or the focused one otherwise.
function client.ismarked(c)
local cl = c or capi.client.focus_get()
local cl = c or capi.client.focus
if cl then
for k, v in pairs(awfulmarked) do
if cl == v then
@ -654,7 +654,7 @@ end
--- Toggle a client as marked.
-- @param c The client to toggle mark.
function client.togglemarked(c)
local cl = c or capi.client.focus_get()
local cl = c or capi.client.focus
if not client.mark(c) then
client.unmark(c)
@ -1151,7 +1151,7 @@ function widget.taglist.label.all(t, args)
local bg_urgent = args.bg_urgent or theme.bg_urgent
local text
local background = ""
local sel = capi.client.focus_get()
local sel = capi.client.focus
local bg_color = nil
local fg_color = nil
if t.selected then
@ -1237,7 +1237,7 @@ local function widget_tasklist_label_common(c, args)
else
name = escape(c.name)
end
if capi.client.focus_get() == c then
if capi.client.focus == c then
text = text .. " <bg color='"..bg_focus.."'/><span color='"..fg_focus.."'>"..name.."</span> "
elseif c.urgent and bg_urgent and fg_urgent then
text = text .. " <bg color='"..bg_urgent.."'/><span color='"..fg_urgent.."'>"..name.."</span> "
@ -1358,7 +1358,7 @@ function titlebar.update(c)
if title then
title.text = " " .. escape(c.name)
end
if capi.client.focus_get() == c then
if capi.client.focus == c then
c.titlebar.fg = titlebar.data[c].fg_focus
c.titlebar.bg = titlebar.data[c].bg_focus
if close then

4
lua.h
View file

@ -39,6 +39,10 @@ typedef enum
/** Type for Lua function */
typedef int luaA_ref;
#define deprecate(string, ...) _warn(__LINE__, \
__FUNCTION__, \
"This function is deprecated and will be removed.")
#define DO_LUA_NEW(decl, type, prefix, lua_type, type_ref) \
decl int \
luaA_##prefix##_userdata_new(lua_State *L, type *p) \

View file

@ -219,8 +219,7 @@ screen_client_moveto(client_t *c, int new_screen, bool doresize)
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lfield coords The screen coordinates.
* \lfield padding The screen padding.
* \lfield number The screen number, to get a screen.
*/
static int
luaA_screen_module_index(lua_State *L)