From 014214794a6ea5eebe4449a06bf9e78387e5f5b6 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 1 Jul 2008 21:39:00 +0200 Subject: [PATCH] client: merge screen_{set,get} into index Signed-off-by: Julien Danjou --- client.c | 43 ++++++++++--------------------------------- common/tokenize.gperf | 1 + lib/awful.lua | 12 ++++++------ 3 files changed, 17 insertions(+), 39 deletions(-) diff --git a/client.c b/client.c index 4343ae36..40c4f66e 100644 --- a/client.c +++ b/client.c @@ -969,36 +969,6 @@ client_setborder(client_t *c, int width) globalconf.screens[c->screen].need_arrange = true; } -/** Move the client to another screen. - * \param L The Lua VM state. - * \luastack - * \lvalue A client. - * \lparam A screen number. - */ -static int -luaA_client_screen_set(lua_State *L) -{ - client_t **c = luaA_checkudata(L, 1, "client"); - int screen = luaL_checknumber(L, 2) - 1; - luaA_checkscreen(screen); - screen_client_moveto(*c, screen, true); - return 0; -} - -/** Get the screen number the client is onto. - * \param L The Lua VM state. - * \luastack - * \lvalue A client. - * \lreturn A screen number. - */ -static int -luaA_client_screen_get(lua_State *L) -{ - client_t **c = luaA_checkudata(L, 1, "client"); - lua_pushnumber(L, 1 + (*c)->screen); - return 1; -} - /** Tag a client with a specified tag. * \param L The Lua VM state. * \luastack @@ -1299,6 +1269,7 @@ luaA_client_newindex(lua_State *L) const char *buf = luaL_checklstring(L, 2, &len); bool b; double d; + int i; xcolor_t color; switch(a_tokenize(buf, len)) @@ -1309,6 +1280,11 @@ luaA_client_newindex(lua_State *L) a_iso2utf8(&(*c)->name, buf, len); widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS); break; + case A_TK_SCREEN: + i = luaL_checknumber(L, 3) - 1; + luaA_checkscreen(i); + screen_client_moveto(*c, i, true); + break; case A_TK_HIDE: b = luaA_checkboolean(L, 3); if(b != (*c)->ishidden) @@ -1375,6 +1351,9 @@ luaA_client_index(lua_State *L) case A_TK_NAME: lua_pushstring(L, (*c)->name); break; + case A_TK_SCREEN: + lua_pushnumber(L, 1 + (*c)->screen); + break; case A_TK_HIDE: lua_pushboolean(L, (*c)->ishidden); break; @@ -1411,15 +1390,13 @@ const struct luaL_reg awesome_client_meta[] = { "floating_placement_set", luaA_client_floating_placement_set }, { "titlebar_set", luaA_client_titlebar_set }, { "titlebar_get", luaA_client_titlebar_get }, - { "screen_set", luaA_client_screen_set }, - { "screen_get", luaA_client_screen_get }, { "tag", luaA_client_tag }, { "istagged", luaA_client_istagged }, { "coords_get", luaA_client_coords_get }, { "coords_set", luaA_client_coords_set }, { "kill", luaA_client_kill }, { "swap", luaA_client_swap }, - { "focus_set", luaA_client_focus_set }, + { "focus_set", luaA_client_focus_set }, { "raise", luaA_client_raise }, { "redraw", luaA_client_redraw }, { "class_get", luaA_client_class_get }, diff --git a/common/tokenize.gperf b/common/tokenize.gperf index b6364c7c..780fdce7 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -38,6 +38,7 @@ plot_properties_set position resize right +screen selected shadow shadow_offset diff --git a/lib/awful.lua b/lib/awful.lua index bab292f4..78a2f9df 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -81,7 +81,7 @@ function P.client.next(i, c) local sel = c or client.focus_get() if sel then -- Get all visible clients - local cls = client.visible_get(sel:screen_get()) + local cls = client.visible_get(sel.screen) -- Loop upon each client for idx, c in ipairs(cls) do if c == sel then @@ -143,7 +143,7 @@ function P.screen.focus(i) local sel = client.focus_get() local s if sel then - s = sel:screen_get() + s = sel.screen else s = mouse.screen_get() end @@ -283,7 +283,7 @@ end -- @para c Optional client to move, otherwise the focused one is used. function P.client.movetotag(target, c) local sel = c or client.focus_get(); - local tags = tag.get(sel:screen_get()) + local tags = tag.get(sel.screen) for k, t in pairs(tags) do sel:tag(t, false) end @@ -299,7 +299,7 @@ function P.client.toggletag(target, c) if sel then -- Count how many tags has the client -- an only toggle tag if the client has at least one tag other than target - for k, v in pairs(tag.get(sel:screen_get())) do + for k, v in pairs(tag.get(sel.screen)) do if target ~= v and sel:istagged(v) then toggle = true break @@ -328,10 +328,10 @@ function P.client.movetoscreen(c, s) if sel then local sc = screen.count() if not s then - s = sel:screen_get() + 1 + s = sel.screen + 1 end if s > sc then s = 1 elseif s < 1 then s = sc end - sel:screen_set(s) + sel.screen = s mouse.coords_set(screen.coords_get(s)) sel:focus_set() end