wibox: move position handling to Lua
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
1ef09fa8e6
commit
7cc0b13eae
|
@ -170,7 +170,7 @@ for s = 1, screen.count() do
|
||||||
end, mytasklist.buttons)
|
end, mytasklist.buttons)
|
||||||
|
|
||||||
-- Create the wibox
|
-- Create the wibox
|
||||||
mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
|
mywibox[s] = awful.wibox({ position = "top", screen = s })
|
||||||
-- Add widgets to the wibox - order matters
|
-- Add widgets to the wibox - order matters
|
||||||
mywibox[s].widgets = { mylauncher,
|
mywibox[s].widgets = { mylauncher,
|
||||||
mytaglist[s],
|
mytaglist[s],
|
||||||
|
@ -179,7 +179,6 @@ for s = 1, screen.count() do
|
||||||
mytextbox,
|
mytextbox,
|
||||||
mylayoutbox[s],
|
mylayoutbox[s],
|
||||||
s == 1 and mysystray or nil }
|
s == 1 and mysystray or nil }
|
||||||
mywibox[s].screen = s
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
28
client.c
28
client.c
|
@ -215,10 +215,6 @@ client_ban(client_t *c)
|
||||||
|
|
||||||
c->isbanned = true;
|
c->isbanned = true;
|
||||||
|
|
||||||
/* All the wiboxes (may) need to be repositioned. */
|
|
||||||
if(client_hasstrut(c))
|
|
||||||
wibox_update_positions();
|
|
||||||
|
|
||||||
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
|
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
|
||||||
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
|
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
|
||||||
|
|
||||||
|
@ -683,7 +679,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
area_t area;
|
area_t area;
|
||||||
|
|
||||||
/* offscreen appearance fixes */
|
/* offscreen appearance fixes */
|
||||||
area = display_area_get(c->phys_screen, NULL);
|
area = display_area_get(c->phys_screen);
|
||||||
|
|
||||||
if(geometry.x > area.width)
|
if(geometry.x > area.width)
|
||||||
geometry.x = area.width - geometry.width;
|
geometry.x = area.width - geometry.width;
|
||||||
|
@ -814,7 +810,7 @@ client_setfullscreen(client_t *c, bool s)
|
||||||
client_setabove(c, false);
|
client_setabove(c, false);
|
||||||
client_setontop(c, false);
|
client_setontop(c, false);
|
||||||
|
|
||||||
geometry = screen_area_get(c->screen, NULL, false);
|
geometry = screen_area_get(c->screen, false);
|
||||||
c->geometries.fullscreen = c->geometry;
|
c->geometries.fullscreen = c->geometry;
|
||||||
c->border_fs = c->border;
|
c->border_fs = c->border;
|
||||||
client_setborder(c, 0);
|
client_setborder(c, 0);
|
||||||
|
@ -848,9 +844,7 @@ client_setmaxhoriz(client_t *c, bool s)
|
||||||
/* remove fullscreen mode */
|
/* remove fullscreen mode */
|
||||||
client_setfullscreen(c, false);
|
client_setfullscreen(c, false);
|
||||||
|
|
||||||
geometry = screen_area_get(c->screen,
|
geometry = screen_area_get(c->screen, true);
|
||||||
&c->screen->wiboxes,
|
|
||||||
true);
|
|
||||||
geometry.y = c->geometry.y;
|
geometry.y = c->geometry.y;
|
||||||
geometry.height = c->geometry.height;
|
geometry.height = c->geometry.height;
|
||||||
c->geometries.max.x = c->geometry.x;
|
c->geometries.max.x = c->geometry.x;
|
||||||
|
@ -887,9 +881,7 @@ client_setmaxvert(client_t *c, bool s)
|
||||||
/* remove fullscreen mode */
|
/* remove fullscreen mode */
|
||||||
client_setfullscreen(c, false);
|
client_setfullscreen(c, false);
|
||||||
|
|
||||||
geometry = screen_area_get(c->screen,
|
geometry = screen_area_get(c->screen, true);
|
||||||
&c->screen->wiboxes,
|
|
||||||
true);
|
|
||||||
geometry.x = c->geometry.x;
|
geometry.x = c->geometry.x;
|
||||||
geometry.width = c->geometry.width;
|
geometry.width = c->geometry.width;
|
||||||
c->geometries.max.y = c->geometry.y;
|
c->geometries.max.y = c->geometry.y;
|
||||||
|
@ -1020,10 +1012,6 @@ client_unban(client_t *c)
|
||||||
request);
|
request);
|
||||||
|
|
||||||
c->isbanned = false;
|
c->isbanned = false;
|
||||||
|
|
||||||
/* All the wiboxes (may) need to be repositioned. */
|
|
||||||
if(client_hasstrut(c))
|
|
||||||
wibox_update_positions();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,10 +1073,6 @@ client_unmanage(client_t *c)
|
||||||
|
|
||||||
ewmh_update_net_client_list(c->phys_screen);
|
ewmh_update_net_client_list(c->phys_screen);
|
||||||
|
|
||||||
/* All the wiboxes (may) need to be repositioned. */
|
|
||||||
if(client_hasstrut(c))
|
|
||||||
wibox_update_positions();
|
|
||||||
|
|
||||||
/* set client as invalid */
|
/* set client as invalid */
|
||||||
c->invalid = true;
|
c->invalid = true;
|
||||||
|
|
||||||
|
@ -1436,7 +1420,7 @@ luaA_client_struts(lua_State *L)
|
||||||
if(lua_gettop(L) == 2)
|
if(lua_gettop(L) == 2)
|
||||||
{
|
{
|
||||||
strut_t struts;
|
strut_t struts;
|
||||||
area_t screen_area = display_area_get(c->phys_screen, NULL);
|
area_t screen_area = display_area_get(c->phys_screen);
|
||||||
|
|
||||||
struts.left = luaA_getopt_number(L, 2, "left", c->strut.left);
|
struts.left = luaA_getopt_number(L, 2, "left", c->strut.left);
|
||||||
struts.right = luaA_getopt_number(L, 2, "right", c->strut.right);
|
struts.right = luaA_getopt_number(L, 2, "right", c->strut.right);
|
||||||
|
@ -1461,8 +1445,6 @@ luaA_client_struts(lua_State *L)
|
||||||
ewmh_update_client_strut(c);
|
ewmh_update_client_strut(c);
|
||||||
|
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
/* All the wiboxes (may) need to be repositioned. */
|
|
||||||
wibox_update_positions();
|
|
||||||
|
|
||||||
hook_property(client, c, "struts");
|
hook_property(client, c, "struts");
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,8 +114,6 @@ position_fromstr(const char *pos, ssize_t len)
|
||||||
return Right;
|
return Right;
|
||||||
case A_TK_LEFT:
|
case A_TK_LEFT:
|
||||||
return Left;
|
return Left;
|
||||||
case A_TK_FLOATING:
|
|
||||||
return Floating;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +130,6 @@ position_tostr(position_t p)
|
||||||
case Bottom: return "bottom";
|
case Bottom: return "bottom";
|
||||||
case Right: return "right";
|
case Right: return "right";
|
||||||
case Left: return "left";
|
case Left: return "left";
|
||||||
case Floating: return "floating";
|
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
East,
|
East = 0,
|
||||||
South,
|
South,
|
||||||
North,
|
North,
|
||||||
} orientation_t;
|
} orientation_t;
|
||||||
|
@ -46,11 +46,10 @@ typedef enum
|
||||||
/** A list of possible position, not sex related */
|
/** A list of possible position, not sex related */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Top,
|
Top = 0,
|
||||||
Bottom,
|
Bottom,
|
||||||
Right,
|
Right,
|
||||||
Left,
|
Left
|
||||||
Floating
|
|
||||||
} position_t;
|
} position_t;
|
||||||
|
|
||||||
/** Link a name to a function */
|
/** Link a name to a function */
|
||||||
|
|
5
event.c
5
event.c
|
@ -280,12 +280,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
geometry = titlebar_geometry_add(c->titlebar, c->border, geometry);
|
geometry = titlebar_geometry_add(c->titlebar, c->border, geometry);
|
||||||
|
|
||||||
if(client_resize(c, geometry, false))
|
if(client_resize(c, geometry, false))
|
||||||
{
|
|
||||||
/* All the wiboxes (may) need to be repositioned. */
|
|
||||||
if(client_hasstrut(c))
|
|
||||||
wibox_update_positions();
|
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Resize wasn't officially needed, but we don't want to break expectations. */
|
/* Resize wasn't officially needed, but we don't want to break expectations. */
|
||||||
|
|
11
ewmh.c
11
ewmh.c
|
@ -45,9 +45,7 @@
|
||||||
static void
|
static void
|
||||||
ewmh_update_desktop_geometry(int phys_screen)
|
ewmh_update_desktop_geometry(int phys_screen)
|
||||||
{
|
{
|
||||||
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
|
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen], false);
|
||||||
NULL,
|
|
||||||
false);
|
|
||||||
uint32_t sizes[] = { geom.width, geom.height };
|
uint32_t sizes[] = { geom.width, geom.height };
|
||||||
|
|
||||||
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
|
@ -231,10 +229,7 @@ ewmh_update_workarea(int phys_screen)
|
||||||
{
|
{
|
||||||
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
|
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
|
||||||
uint32_t *area = p_alloca(uint32_t, tags->len * 4);
|
uint32_t *area = p_alloca(uint32_t, tags->len * 4);
|
||||||
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
|
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen], true);
|
||||||
&globalconf.screens.tab[phys_screen].wiboxes,
|
|
||||||
true);
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < tags->len; i++)
|
for(int i = 0; i < tags->len; i++)
|
||||||
{
|
{
|
||||||
|
@ -634,8 +629,6 @@ ewmh_process_client_strut(client_t *c, xcb_get_property_reply_t *strut_r)
|
||||||
c->strut.bottom_end_x = strut[11];
|
c->strut.bottom_end_x = strut[11];
|
||||||
|
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
/* All the wiboxes (may) need to be repositioned. */
|
|
||||||
wibox_update_positions();
|
|
||||||
|
|
||||||
hook_property(client, c, "struts");
|
hook_property(client, c, "struts");
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ require("awful.mouse")
|
||||||
require("awful.remote")
|
require("awful.remote")
|
||||||
require("awful.key")
|
require("awful.key")
|
||||||
require("awful.button")
|
require("awful.button")
|
||||||
|
require("awful.wibox")
|
||||||
require("awful.startup_notification")
|
require("awful.startup_notification")
|
||||||
|
|
||||||
--- AWesome Functions very UsefuL
|
--- AWesome Functions very UsefuL
|
||||||
|
|
|
@ -11,6 +11,7 @@ local tag = require("awful.tag")
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local suit = require("awful.layout.suit")
|
local suit = require("awful.layout.suit")
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
|
local wibox = require("awful.wibox")
|
||||||
local ascreen = require("awful.screen")
|
local ascreen = require("awful.screen")
|
||||||
local capi =
|
local capi =
|
||||||
{
|
{
|
||||||
|
@ -64,7 +65,7 @@ end
|
||||||
local function on_arrange (screen)
|
local function on_arrange (screen)
|
||||||
local t = tag.selected(screen)
|
local t = tag.selected(screen)
|
||||||
local p = {}
|
local p = {}
|
||||||
p.workarea = capi.screen[screen].workarea
|
p.workarea = wibox.get_workarea(screen)
|
||||||
-- Handle padding
|
-- Handle padding
|
||||||
local padding = ascreen.padding(screen)
|
local padding = ascreen.padding(screen)
|
||||||
if padding then
|
if padding then
|
||||||
|
@ -97,6 +98,9 @@ hooks.property.register(function (c, prop)
|
||||||
on_arrange(c.screen)
|
on_arrange(c.screen)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
hooks.wibox_position.register(function(wibox)
|
||||||
|
on_arrange(wibox.screen)
|
||||||
|
end)
|
||||||
|
|
||||||
hooks.padding.register(function(screen) on_arrange(screen) end)
|
hooks.padding.register(function(screen) on_arrange(screen) end)
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ local capi =
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local tags = require("awful.tag")
|
local tags = require("awful.tag")
|
||||||
local awbeautiful = require("beautiful")
|
local awbeautiful = require("beautiful")
|
||||||
|
local awibox = require("awful.wibox")
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
||||||
--- Menu module for awful
|
--- Menu module for awful
|
||||||
|
@ -249,7 +250,7 @@ function clients(menu)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_coords(menu, screen_idx)
|
local function set_coords(menu, screen_idx)
|
||||||
local s_geometry = capi.screen[screen_idx].workarea
|
local s_geometry = awibox.get_workarea(screen_idx)
|
||||||
local screen_w = s_geometry.x + s_geometry.width
|
local screen_w = s_geometry.x + s_geometry.width
|
||||||
local screen_h = s_geometry.y + s_geometry.height
|
local screen_h = s_geometry.y + s_geometry.height
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ local tag = require("awful.tag")
|
||||||
local hooks = require("awful.hooks")
|
local hooks = require("awful.hooks")
|
||||||
local aclient = require("awful.client")
|
local aclient = require("awful.client")
|
||||||
local widget = require("awful.widget")
|
local widget = require("awful.widget")
|
||||||
|
local awibox = require("awful.wibox")
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local type = type
|
local type = type
|
||||||
local math = math
|
local math = math
|
||||||
|
@ -114,7 +115,7 @@ function client.snap(c, snap, x, y, fixed_x, fixed_y)
|
||||||
geom.y = y or geom.y
|
geom.y = y or geom.y
|
||||||
|
|
||||||
geom, edge = snap_inside(geom, capi.screen[c.screen].geometry, snap)
|
geom, edge = snap_inside(geom, capi.screen[c.screen].geometry, snap)
|
||||||
geom = snap_inside(geom, capi.screen[c.screen].workarea, snap)
|
geom = snap_inside(geom, awibox.get_workarea(c.screen), snap)
|
||||||
|
|
||||||
-- Allow certain windows to snap to the edge of the workarea.
|
-- Allow certain windows to snap to the edge of the workarea.
|
||||||
-- Only allow docking to workarea for consistency/to avoid problems.
|
-- Only allow docking to workarea for consistency/to avoid problems.
|
||||||
|
@ -240,7 +241,7 @@ function client.dragtotag.border(c)
|
||||||
for _, v in ipairs(mouse.buttons) do
|
for _, v in ipairs(mouse.buttons) do
|
||||||
if v then button_down = true end
|
if v then button_down = true end
|
||||||
end
|
end
|
||||||
local wa = capi.screen[c.screen].workarea
|
local wa = awibox.get_workarea(c.screen)
|
||||||
if mouse.x >= wa.x + wa.width then
|
if mouse.x >= wa.x + wa.width then
|
||||||
capi.mouse.coords({ x = wa.x + wa.width - 1 })
|
capi.mouse.coords({ x = wa.x + wa.width - 1 })
|
||||||
elseif mouse.x <= wa.x then
|
elseif mouse.x <= wa.x then
|
||||||
|
@ -289,7 +290,7 @@ function wibox.move(w)
|
||||||
y = capi.mouse.coords()["y"] + offset["y"],
|
y = capi.mouse.coords()["y"] + offset["y"],
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
local wa = capi.screen[capi.mouse.screen].workarea
|
local wa = awibox.get_workarea(capi.mouse.screen)
|
||||||
|
|
||||||
if capi.mouse.coords()["y"] > wa.y + wa.height - 10 then
|
if capi.mouse.coords()["y"] > wa.y + wa.height - 10 then
|
||||||
w.position = "bottom"
|
w.position = "bottom"
|
||||||
|
@ -362,7 +363,7 @@ local function client_resize_magnifier(c, corner)
|
||||||
local corner, x, y = client.corner(c, corner)
|
local corner, x, y = client.corner(c, corner)
|
||||||
capi.mouse.coords({ x = x, y = y })
|
capi.mouse.coords({ x = x, y = y })
|
||||||
|
|
||||||
local wa = capi.screen[c.screen].workarea
|
local wa = awibox.get_workarea(c.screen)
|
||||||
local center_x = wa.x + wa.width / 2
|
local center_x = wa.x + wa.width / 2
|
||||||
local center_y = wa.y + wa.height / 2
|
local center_y = wa.y + wa.height / 2
|
||||||
local maxdist_pow = (wa.width^2 + wa.height^2) / 4
|
local maxdist_pow = (wa.width^2 + wa.height^2) / 4
|
||||||
|
@ -385,7 +386,7 @@ local function client_resize_magnifier(c, corner)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function client_resize_tiled(c, lay)
|
local function client_resize_tiled(c, lay)
|
||||||
local wa = capi.screen[c.screen].workarea
|
local wa = awibox.get_workarea(c.screen)
|
||||||
local mwfact = tag.getmwfact()
|
local mwfact = tag.getmwfact()
|
||||||
local cursor
|
local cursor
|
||||||
local g = c:geometry()
|
local g = c:geometry()
|
||||||
|
|
|
@ -17,6 +17,7 @@ local capi =
|
||||||
}
|
}
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
local layout = require("awful.layout")
|
local layout = require("awful.layout")
|
||||||
|
local wibox = require("awful.wibox")
|
||||||
|
|
||||||
--- Placement module for awful
|
--- Placement module for awful
|
||||||
module("awful.placement")
|
module("awful.placement")
|
||||||
|
@ -105,7 +106,7 @@ end
|
||||||
function no_offscreen(c)
|
function no_offscreen(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
local geometry = c:geometry()
|
local geometry = c:geometry()
|
||||||
local screen_geometry = capi.screen[c.screen].workarea
|
local screen_geometry = wibox.get_workarea(c.screen)
|
||||||
|
|
||||||
if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then
|
if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then
|
||||||
geometry.x = screen_geometry.x + screen_geometry.width - geometry.width
|
geometry.x = screen_geometry.x + screen_geometry.width - geometry.width
|
||||||
|
@ -127,7 +128,7 @@ end
|
||||||
function no_overlap(c)
|
function no_overlap(c)
|
||||||
local cls = client.visible(c.screen)
|
local cls = client.visible(c.screen)
|
||||||
local curlay = layout.get()
|
local curlay = layout.get()
|
||||||
local areas = { capi.screen[c.screen].workarea }
|
local areas = { wibox.get_workarea(c.screen) }
|
||||||
local geometry = c:geometry()
|
local geometry = c:geometry()
|
||||||
for i, cl in pairs(cls) do
|
for i, cl in pairs(cls) do
|
||||||
if cl ~= c and (client.floating.get(cl) or curlay == layout.suit.floating) then
|
if cl ~= c and (client.floating.get(cl) or curlay == layout.suit.floating) then
|
||||||
|
|
|
@ -0,0 +1,284 @@
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
-- @author Julien Danjou <julien@danjou.info>
|
||||||
|
-- @copyright 2009 Julien Danjou
|
||||||
|
-- @release @AWESOME_VERSION@
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- Grab environment we need
|
||||||
|
local capi =
|
||||||
|
{
|
||||||
|
awesome = awesome,
|
||||||
|
screen = screen,
|
||||||
|
wibox = wibox
|
||||||
|
}
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local ipairs = ipairs
|
||||||
|
local table = table
|
||||||
|
local type = type
|
||||||
|
local hooks = require("awful.hooks")
|
||||||
|
|
||||||
|
--- Wibox module for awful.
|
||||||
|
module("awful.wibox")
|
||||||
|
|
||||||
|
-- Array of table with wiboxes inside.
|
||||||
|
-- It's an array so it is ordered.
|
||||||
|
local wiboxes = {}
|
||||||
|
|
||||||
|
hooks.user.create("wibox_position")
|
||||||
|
|
||||||
|
--- Get the workarea space without wiboxes geometry.
|
||||||
|
-- @param s The screen number.
|
||||||
|
-- @return The screen workarea.
|
||||||
|
function get_workarea(s)
|
||||||
|
local area = capi.screen[s].workarea
|
||||||
|
for _, wprop in ipairs(wiboxes) do
|
||||||
|
if wprop.wibox.visible and wprop.wibox.screen == s then
|
||||||
|
if wprop.position == "top" then
|
||||||
|
area.y = area.y + wprop.wibox:geometry().height
|
||||||
|
area.height = area.height - wprop.wibox:geometry().height
|
||||||
|
elseif wprop.position == "bottom" then
|
||||||
|
area.height = area.height - wprop.wibox:geometry().height
|
||||||
|
elseif wprop.position == "left" then
|
||||||
|
area.x = area.x + wprop.wibox:geometry().width
|
||||||
|
area.width = area.width - wprop.wibox:geometry().width
|
||||||
|
elseif wprop.position == "right" then
|
||||||
|
area.width = area.width - wprop.wibox:geometry().width
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return area
|
||||||
|
end
|
||||||
|
|
||||||
|
local function compute_area(wibox, position, s)
|
||||||
|
local s = wibox.screen or s or 1
|
||||||
|
local area = capi.screen[s].workarea
|
||||||
|
local ignore = false
|
||||||
|
for _, wprop in ipairs(wiboxes) do
|
||||||
|
if wprop.wibox == wibox then
|
||||||
|
ignore = true
|
||||||
|
elseif wprop.wibox.visible and wprop.wibox.screen == s
|
||||||
|
and not (ignore and wprop.position == position) then
|
||||||
|
if (wprop.position == "right" or wprop.position == "left")
|
||||||
|
and wprop.position == position then
|
||||||
|
area.x = area.x + wibox:geometry().width
|
||||||
|
elseif wprop.position == "top" then
|
||||||
|
if position == "top" then
|
||||||
|
area.y = area.y + wprop.wibox:geometry().height
|
||||||
|
elseif position == "left" or position == "right" then
|
||||||
|
area.height = area.height - wprop.wibox:geometry().height
|
||||||
|
area.y = area.y + wprop.wibox:geometry().height
|
||||||
|
end
|
||||||
|
elseif wprop.position == "bottom" then
|
||||||
|
if position == "bottom" then
|
||||||
|
area.y = area.y - wprop.wibox:geometry().height
|
||||||
|
elseif position == "left" or position == "right" then
|
||||||
|
area.height = area.height - wprop.wibox:geometry().height
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return area
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get a wibox position if it has been set, or return top.
|
||||||
|
-- @param wibox The wibox
|
||||||
|
-- @return The wibox position.
|
||||||
|
function get_position(wibox)
|
||||||
|
for _, wprop in ipairs(wiboxes) do
|
||||||
|
if wprop.wibox == wibox then
|
||||||
|
return wprop.position
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "top"
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Attach a wibox to a screen at the position.
|
||||||
|
-- @param wibox The wibox to attach.
|
||||||
|
-- @param position The position: top, bottom left or right.
|
||||||
|
-- @param screen If the wibox it not attached to a screen, specified on which
|
||||||
|
-- screen the position should be set.
|
||||||
|
function set_position(wibox, position, screen)
|
||||||
|
local area = compute_area(wibox, position, screen)
|
||||||
|
|
||||||
|
local wingeom = wibox:geometry()
|
||||||
|
|
||||||
|
-- The "length" of a wibox is always chosen to be the optimal size
|
||||||
|
-- (non-floating).
|
||||||
|
-- The "width" of a wibox is kept if it exists.
|
||||||
|
if position == "right" then
|
||||||
|
wingeom.x = area.x + area.width - wingeom.width
|
||||||
|
elseif position == "left" then
|
||||||
|
wingeom.x = area.x
|
||||||
|
elseif position == "bottom" then
|
||||||
|
wingeom.y = (area.y + area.height) - wingeom.height
|
||||||
|
elseif position == "top" then
|
||||||
|
wingeom.y = area.y
|
||||||
|
end
|
||||||
|
|
||||||
|
wibox:geometry(wingeom)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Reset all wiboxes positions.
|
||||||
|
local function update_all_wiboxes_position()
|
||||||
|
for _, wprop in ipairs(wiboxes) do
|
||||||
|
set_position(wprop.wibox, wprop.position)
|
||||||
|
hooks.user.call("wibox_position", wprop.wibox)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Attach a wibox to a screen.
|
||||||
|
-- If a wibox is attached, it will be automatically be moved when other wiboxes
|
||||||
|
-- will be attached.
|
||||||
|
-- @param wibox The wibox to attach.
|
||||||
|
-- @param position The position of the wibox: top, bottom, left or right.
|
||||||
|
function attach(wibox, position)
|
||||||
|
-- Store wibox as attached in a weak-valued table
|
||||||
|
local wibox_prop_table
|
||||||
|
-- Start from end since we sometimes remove items
|
||||||
|
for i = #wiboxes, 1, -1 do
|
||||||
|
-- Since wiboxes are stored as weak value, they can disappear.
|
||||||
|
-- If they did, remove their entries
|
||||||
|
if wiboxes[i].wibox == nil then
|
||||||
|
table.remove(wiboxes, i)
|
||||||
|
elseif wiboxes[i].wibox == wibox then
|
||||||
|
wibox_prop_table = wiboxes[i]
|
||||||
|
-- We could break here, but well, let's check if there is no other
|
||||||
|
-- table with their wiboxes been garbage collected.
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not wibox_prop_table then
|
||||||
|
table.insert(wiboxes,
|
||||||
|
setmetatable({ wibox = wibox, position = position }, { __mode = 'v' }))
|
||||||
|
else
|
||||||
|
wibox_prop_table.position = position
|
||||||
|
end
|
||||||
|
|
||||||
|
if wibox.screen and wibox.visible then
|
||||||
|
update_all_wiboxes_position()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Align a wibox.
|
||||||
|
-- @param wibox The wibox.
|
||||||
|
-- @param align The alignment: left, right or center.
|
||||||
|
-- @param screen If the wibox is not attached to any screen, you can specify the
|
||||||
|
-- screen where to align. Otherwise 1 is assumed.
|
||||||
|
function align(wibox, align, screen)
|
||||||
|
local position = get_position(wibox)
|
||||||
|
local area = compute_area(wibox, position, screen)
|
||||||
|
local wingeom = wibox:geometry()
|
||||||
|
|
||||||
|
if position == "right" then
|
||||||
|
if align == "right" then
|
||||||
|
wingeom.y = area.y
|
||||||
|
elseif align == "left" then
|
||||||
|
wingeom.y = area.y + area.height - wingeom.height
|
||||||
|
elseif align == "center" then
|
||||||
|
wingeom.y = area.y + (area.height - wingeom.height) / 2
|
||||||
|
end
|
||||||
|
elseif position == "left" then
|
||||||
|
if align == "right" then
|
||||||
|
wingeom.y = (area.y + area.height) - wingeom.height
|
||||||
|
elseif align == "left" then
|
||||||
|
wingeom.y = area.y
|
||||||
|
elseif align == "center" then
|
||||||
|
wingeom.y = area.y + (area.height - wingeom.height) / 2
|
||||||
|
end
|
||||||
|
elseif position == "bottom" then
|
||||||
|
if align == "right" then
|
||||||
|
wingeom.x = area.x + area.width - wingeom.width
|
||||||
|
elseif align == "left" then
|
||||||
|
wingeom.x = area.x
|
||||||
|
elseif align == "center" then
|
||||||
|
wingeom.x = area.x + (area.width - wingeom.width) / 2
|
||||||
|
end
|
||||||
|
elseif position == "top" then
|
||||||
|
if align == "right" then
|
||||||
|
wingeom.x = area.x + area.width - wingeom.width
|
||||||
|
elseif align == "left" then
|
||||||
|
wingeom.x = area.x
|
||||||
|
elseif align == "center" then
|
||||||
|
wingeom.x = area.x + (area.width - wingeom.width) / 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wibox:geometry(wingeom)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Stretch a wibox so it takes all screen width or height.
|
||||||
|
-- @param wibox The wibox.
|
||||||
|
function stretch(wibox)
|
||||||
|
local position = get_position(wibox)
|
||||||
|
local area = compute_area(wibox, position)
|
||||||
|
local wingeom = {}
|
||||||
|
if position == "right" or position == "left" then
|
||||||
|
wingeom.height = area.height
|
||||||
|
wibox:geometry(wingeom)
|
||||||
|
align(wibox, "center")
|
||||||
|
else
|
||||||
|
wingeom.width = area.width
|
||||||
|
wibox:geometry(wingeom)
|
||||||
|
align(wibox, "left")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create a new wibox and attach it to a screen edge.
|
||||||
|
-- @see capi.wibox
|
||||||
|
-- @param args A table with standard arguments to wibox() creator.
|
||||||
|
-- You can add also position key with value top, bottom, left or right.
|
||||||
|
-- You can also set the screen key with a screen number to attach the wibox.
|
||||||
|
-- If not specified, 1 is assumed.
|
||||||
|
-- @return The wibox created.
|
||||||
|
function new(arg)
|
||||||
|
local screen = screen or 1
|
||||||
|
local arg = arg or {}
|
||||||
|
local position = arg.position or "top"
|
||||||
|
-- Empty position and align in arg so we are passing deprecation warning
|
||||||
|
arg.position = nil
|
||||||
|
|
||||||
|
local w = capi.wibox(arg)
|
||||||
|
|
||||||
|
if position == "left" then
|
||||||
|
w.orientation = "north"
|
||||||
|
w:geometry({ width = capi.awesome.font_height * 1.5 })
|
||||||
|
elseif position == "right" then
|
||||||
|
w.orientation = "south"
|
||||||
|
w:geometry({ width = capi.awesome.font_height * 1.5 })
|
||||||
|
end
|
||||||
|
|
||||||
|
w.screen = arg.screen or 1
|
||||||
|
|
||||||
|
attach(w, position)
|
||||||
|
stretch(w)
|
||||||
|
|
||||||
|
return w
|
||||||
|
end
|
||||||
|
|
||||||
|
local function update_wiboxes_position(obj, prop)
|
||||||
|
if (type(obj) == "wibox"
|
||||||
|
and (prop == nil
|
||||||
|
or prop == "visible"
|
||||||
|
or prop == "screen"))
|
||||||
|
or (type(obj) == "client"
|
||||||
|
and prop == "struts") then
|
||||||
|
update_all_wiboxes_position()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function update_wiboxes_on_struts(c)
|
||||||
|
local struts = c:struts()
|
||||||
|
if struts.left ~= 0 or struts.right ~= 0
|
||||||
|
or struts.top ~= 0 or struts.bottom ~= 0 then
|
||||||
|
update_all_wiboxes_position()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Hook registered to reset all wiboxes position.
|
||||||
|
hooks.property.register(update_wiboxes_position)
|
||||||
|
hooks.manage.register(update_wiboxes_on_struts)
|
||||||
|
hooks.unmanage.register(update_wiboxes_on_struts)
|
||||||
|
|
||||||
|
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||||
|
|
||||||
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -61,8 +61,7 @@ local shots = { }
|
||||||
local enemies = { }
|
local enemies = { }
|
||||||
|
|
||||||
function player.new ()
|
function player.new ()
|
||||||
p = wibox({ position = "floating",
|
p = wibox({ bg = gamedata.solidbg or "#12345600" })
|
||||||
bg = gamedata.solidbg or "#12345600" })
|
|
||||||
p:geometry({ width = 24,
|
p:geometry({ width = 24,
|
||||||
height = 16,
|
height = 16,
|
||||||
x = gamedata.field.x + (gamedata.field.w / 2),
|
x = gamedata.field.x + (gamedata.field.w / 2),
|
||||||
|
@ -99,8 +98,7 @@ function player.fire()
|
||||||
end
|
end
|
||||||
|
|
||||||
function shots.fire (x, y, color)
|
function shots.fire (x, y, color)
|
||||||
local s = wibox({ position = "floating",
|
local s = wibox({ bg = color })
|
||||||
bg = color })
|
|
||||||
s:geometry({ width = 4,
|
s:geometry({ width = 4,
|
||||||
height = 10,
|
height = 10,
|
||||||
x = x,
|
x = x,
|
||||||
|
@ -115,8 +113,7 @@ end
|
||||||
function shots.fire_enemy (x, y, color)
|
function shots.fire_enemy (x, y, color)
|
||||||
if gamedata.enemies.shots.fired < gamedata.enemies.shots.max then
|
if gamedata.enemies.shots.fired < gamedata.enemies.shots.max then
|
||||||
gamedata.enemies.shots.fired = gamedata.enemies.shots.fired + 1
|
gamedata.enemies.shots.fired = gamedata.enemies.shots.fired + 1
|
||||||
local s = wibox({ position = "floating",
|
local s = wibox({ bg = color })
|
||||||
bg = color })
|
|
||||||
s:geometry({ width = 4,
|
s:geometry({ width = 4,
|
||||||
height = 10,
|
height = 10,
|
||||||
x = x,
|
x = x,
|
||||||
|
@ -173,8 +170,7 @@ function shots.handle_enemy ()
|
||||||
end
|
end
|
||||||
|
|
||||||
function enemies.new (t)
|
function enemies.new (t)
|
||||||
e = wibox({ position = "floating",
|
e = wibox({ bg = gamedata.solidbg or "#12345600" })
|
||||||
bg = gamedata.solidbg or "#12345600" })
|
|
||||||
e:geometry({ height = gamedata.enemies.h,
|
e:geometry({ height = gamedata.enemies.h,
|
||||||
width = gamedata.enemies.w,
|
width = gamedata.enemies.w,
|
||||||
x = gamedata.field.x,
|
x = gamedata.field.x,
|
||||||
|
@ -443,8 +439,7 @@ function game.highscore (score)
|
||||||
if s <= score then newentry = true end
|
if s <= score then newentry = true end
|
||||||
end
|
end
|
||||||
|
|
||||||
gamedata.highscore.window = wibox({ position = "floating",
|
gamedata.highscore.window = wibox({ bg = gamedata.btheme.bg_focus or "#333333",
|
||||||
bg = gamedata.btheme.bg_focus or "#333333",
|
|
||||||
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
||||||
gamedata.highscore.window:geometry({ height = 20,
|
gamedata.highscore.window:geometry({ height = 20,
|
||||||
width = 300,
|
width = 300,
|
||||||
|
@ -491,8 +486,7 @@ function run(args)
|
||||||
gamedata.cachedir = awful.util.getdir("cache")
|
gamedata.cachedir = awful.util.getdir("cache")
|
||||||
|
|
||||||
if gamedata.solidbg then
|
if gamedata.solidbg then
|
||||||
gamedata.field.background = wibox({ position = "floating",
|
gamedata.field.background = wibox({ bg = gamedata.solidbg })
|
||||||
bg = gamedata.solidbg })
|
|
||||||
gamedata.field.background:geometry({ x = gamedata.field.x,
|
gamedata.field.background:geometry({ x = gamedata.field.x,
|
||||||
y = gamedata.field.y,
|
y = gamedata.field.y,
|
||||||
height = gamedata.field.h,
|
height = gamedata.field.h,
|
||||||
|
@ -500,8 +494,7 @@ function run(args)
|
||||||
gamedata.field.background.screen = gamedata.screen
|
gamedata.field.background.screen = gamedata.screen
|
||||||
end
|
end
|
||||||
|
|
||||||
gamedata.field.north = wibox({ position = "floating",
|
gamedata.field.north = wibox({ bg = gamedata.btheme.bg_focus or "#333333",
|
||||||
bg = gamedata.btheme.bg_focus or "#333333",
|
|
||||||
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
||||||
gamedata.field.north:geometry({ width = gamedata.field.w + 10,
|
gamedata.field.north:geometry({ width = gamedata.field.w + 10,
|
||||||
height = 15,
|
height = 15,
|
||||||
|
@ -519,8 +512,7 @@ function run(args)
|
||||||
|
|
||||||
gamedata.field.north.widgets = { gamedata.field.caption, gamedata.field.status }
|
gamedata.field.north.widgets = { gamedata.field.caption, gamedata.field.status }
|
||||||
|
|
||||||
gamedata.field.south = wibox({ position = "floating",
|
gamedata.field.south = wibox({ bg = gamedata.btheme.bg_focus or "#333333",
|
||||||
bg = gamedata.btheme.bg_focus or "#333333",
|
|
||||||
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
||||||
gamedata.field.south:geometry({ width = gamedata.field.w,
|
gamedata.field.south:geometry({ width = gamedata.field.w,
|
||||||
height = 5,
|
height = 5,
|
||||||
|
@ -528,8 +520,7 @@ function run(args)
|
||||||
y = gamedata.field.y + gamedata.field.h - 5 })
|
y = gamedata.field.y + gamedata.field.h - 5 })
|
||||||
gamedata.field.south.screen = gamedata.screen
|
gamedata.field.south.screen = gamedata.screen
|
||||||
|
|
||||||
gamedata.field.west = wibox({ position = "floating",
|
gamedata.field.west = wibox({ bg = gamedata.btheme.bg_focus or "#333333",
|
||||||
bg = gamedata.btheme.bg_focus or "#333333",
|
|
||||||
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
||||||
gamedata.field.west:geometry({ width = 5,
|
gamedata.field.west:geometry({ width = 5,
|
||||||
height = gamedata.field.h,
|
height = gamedata.field.h,
|
||||||
|
@ -537,8 +528,7 @@ function run(args)
|
||||||
y = gamedata.field.y })
|
y = gamedata.field.y })
|
||||||
gamedata.field.west.screen = gamedata.screen
|
gamedata.field.west.screen = gamedata.screen
|
||||||
|
|
||||||
gamedata.field.east = wibox({ position = "floating",
|
gamedata.field.east = wibox({ bg = gamedata.btheme.bg_focus or "#333333",
|
||||||
bg = gamedata.btheme.bg_focus or "#333333",
|
|
||||||
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
fg = gamedata.btheme.fg_focus or "#FFFFFF" })
|
||||||
gamedata.field.east:geometry({ width = 5,
|
gamedata.field.east:geometry({ width = 5,
|
||||||
height = gamedata.field.h,
|
height = gamedata.field.h,
|
||||||
|
|
|
@ -18,6 +18,7 @@ local capi = { screen = screen,
|
||||||
local hooks = require("awful.hooks")
|
local hooks = require("awful.hooks")
|
||||||
local button = require("awful.button")
|
local button = require("awful.button")
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
|
local wibox = require("awful.wibox")
|
||||||
local bt = require("beautiful")
|
local bt = require("beautiful")
|
||||||
|
|
||||||
--- Notification library
|
--- Notification library
|
||||||
|
@ -118,7 +119,7 @@ end
|
||||||
-- @param width Popup width (optional)
|
-- @param width Popup width (optional)
|
||||||
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
|
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
|
||||||
local function get_offset(screen, position, idx, width, height)
|
local function get_offset(screen, position, idx, width, height)
|
||||||
local ws = capi.screen[screen].workarea
|
local ws = wibox.get_workarea(screen)
|
||||||
local v = {}
|
local v = {}
|
||||||
local idx = idx or #notifications[screen][position] + 1
|
local idx = idx or #notifications[screen][position] + 1
|
||||||
local width = width or notifications[screen][position][idx].width
|
local width = width or notifications[screen][position][idx].width
|
||||||
|
@ -344,8 +345,7 @@ function notify(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create container wibox
|
-- create container wibox
|
||||||
notification.box = capi.wibox({ position = "floating",
|
notification.box = capi.wibox({ fg = fg,
|
||||||
fg = fg,
|
|
||||||
bg = bg,
|
bg = bg,
|
||||||
border_color = border_color,
|
border_color = border_color,
|
||||||
border_width = border_width })
|
border_width = border_width })
|
||||||
|
@ -365,11 +365,12 @@ function notify(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- crop to workarea size if too big
|
-- crop to workarea size if too big
|
||||||
if width > capi.screen[screen].workarea.width - 2 * (border_width or 0) - 2 * (config.padding or 0) then
|
local workarea = wibox.get_workarea(screen)
|
||||||
width = capi.screen[screen].workarea.width - 2 * (border_width or 0) - 2 * (config.padding or 0)
|
if width > workarea.width - 2 * (border_width or 0) - 2 * (config.padding or 0) then
|
||||||
|
width = workarea.width - 2 * (border_width or 0) - 2 * (config.padding or 0)
|
||||||
end
|
end
|
||||||
if height > capi.screen[screen].workarea.height - 2 * (border_width or 0) - 2 * (config.padding or 0) then
|
if height > workarea.height - 2 * (border_width or 0) - 2 * (config.padding or 0) then
|
||||||
height = capi.screen[screen].workarea.height - 2 * (border_width or 0) - 2 * (config.padding or 0)
|
height = workarea.height - 2 * (border_width or 0) - 2 * (config.padding or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set size in notification object
|
-- set size in notification object
|
||||||
|
|
|
@ -50,7 +50,7 @@ local function new(_, args)
|
||||||
if not args or not args.image then return end
|
if not args or not args.image then return end
|
||||||
|
|
||||||
-- Create wibox
|
-- Create wibox
|
||||||
local w = capi.wibox({ position = "floating" })
|
local w = capi.wibox{}
|
||||||
data[w] = { image = args.image }
|
data[w] = { image = args.image }
|
||||||
local wimg = capi.widget({ type = "imagebox" })
|
local wimg = capi.widget({ type = "imagebox" })
|
||||||
w.widgets = wimg
|
w.widgets = wimg
|
||||||
|
|
47
screen.c
47
screen.c
|
@ -147,7 +147,7 @@ screen_getbycoord(screen_t *screen, int x, int y)
|
||||||
* \return The screen area.
|
* \return The screen area.
|
||||||
*/
|
*/
|
||||||
area_t
|
area_t
|
||||||
screen_area_get(screen_t *screen, wibox_array_t *wiboxes, bool strut)
|
screen_area_get(screen_t *screen, bool strut)
|
||||||
{
|
{
|
||||||
area_t area = screen->geometry;
|
area_t area = screen->geometry;
|
||||||
uint16_t top = 0, bottom = 0, left = 0, right = 0;
|
uint16_t top = 0, bottom = 0, left = 0, right = 0;
|
||||||
|
@ -189,31 +189,6 @@ screen_area_get(screen_t *screen, wibox_array_t *wiboxes, bool strut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(wiboxes)
|
|
||||||
foreach(_w, *wiboxes)
|
|
||||||
{
|
|
||||||
wibox_t *w = *_w;
|
|
||||||
if(w->isvisible)
|
|
||||||
switch(w->position)
|
|
||||||
{
|
|
||||||
case Top:
|
|
||||||
top = MAX(top, (uint16_t) (w->sw.geometry.y - area.y) + w->sw.geometry.height + 2 * w->sw.border.width);
|
|
||||||
break;
|
|
||||||
case Bottom:
|
|
||||||
bottom = MAX(bottom, (uint16_t) (area.y + area.height) - w->sw.geometry.y);
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
left = MAX(left, (uint16_t) (w->sw.geometry.x - area.x) + w->sw.geometry.width + 2 * w->sw.border.width);
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
right = MAX(right, (uint16_t) (area.x + area.width) - w->sw.geometry.x);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
area.x += left;
|
area.x += left;
|
||||||
area.y += top;
|
area.y += top;
|
||||||
area.width -= left + right;
|
area.width -= left + right;
|
||||||
|
@ -224,26 +199,16 @@ screen_area_get(screen_t *screen, wibox_array_t *wiboxes, bool strut)
|
||||||
|
|
||||||
/** Get display info.
|
/** Get display info.
|
||||||
* \param phys_screen Physical screen number.
|
* \param phys_screen Physical screen number.
|
||||||
* \param wiboxes The wiboxes.
|
|
||||||
* \return The display area.
|
* \return The display area.
|
||||||
*/
|
*/
|
||||||
area_t
|
area_t
|
||||||
display_area_get(int phys_screen, wibox_array_t *wiboxes)
|
display_area_get(int phys_screen)
|
||||||
{
|
{
|
||||||
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||||
area_t area = { .x = 0,
|
area_t area = { .x = 0,
|
||||||
.y = 0,
|
.y = 0,
|
||||||
.width = s->width_in_pixels,
|
.width = s->width_in_pixels,
|
||||||
.height = s->height_in_pixels };
|
.height = s->height_in_pixels };
|
||||||
|
|
||||||
if(wiboxes)
|
|
||||||
foreach(_w, *wiboxes)
|
|
||||||
{
|
|
||||||
wibox_t *w = *_w;
|
|
||||||
area.y += w->position == Top ? w->sw.geometry.height : 0;
|
|
||||||
area.height -= (w->position == Top || w->position == Bottom) ? w->sw.geometry.height : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,8 +272,8 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool dotag, bool doresiz
|
||||||
if(!doresize)
|
if(!doresize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
from = screen_area_get(old_screen, NULL, false);
|
from = screen_area_get(old_screen, false);
|
||||||
to = screen_area_get(c->screen, NULL, false);
|
to = screen_area_get(c->screen, false);
|
||||||
|
|
||||||
area_t new_geometry = c->geometry;
|
area_t new_geometry = c->geometry;
|
||||||
|
|
||||||
|
@ -424,7 +389,7 @@ luaA_screen_tags(lua_State *L)
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
* \luastack
|
* \luastack
|
||||||
* \lfield coords The screen coordinates. Immutable.
|
* \lfield coords The screen coordinates. Immutable.
|
||||||
* \lfield workarea The screen workarea, i.e. without wiboxes.
|
* \lfield workarea The screen workarea.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_screen_index(lua_State *L)
|
luaA_screen_index(lua_State *L)
|
||||||
|
@ -445,7 +410,7 @@ luaA_screen_index(lua_State *L)
|
||||||
luaA_pusharea(L, s->geometry);
|
luaA_pusharea(L, s->geometry);
|
||||||
break;
|
break;
|
||||||
case A_TK_WORKAREA:
|
case A_TK_WORKAREA:
|
||||||
luaA_pusharea(L, screen_area_get(s, &s->wiboxes, true));
|
luaA_pusharea(L, screen_area_get(s, true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
4
screen.h
4
screen.h
|
@ -52,8 +52,8 @@ ARRAY_FUNCS(screen_t, screen, DO_NOTHING)
|
||||||
|
|
||||||
void screen_scan(void);
|
void screen_scan(void);
|
||||||
screen_t *screen_getbycoord(screen_t *, int, int);
|
screen_t *screen_getbycoord(screen_t *, int, int);
|
||||||
area_t screen_area_get(screen_t *, wibox_array_t *, bool);
|
area_t screen_area_get(screen_t *, bool);
|
||||||
area_t display_area_get(int, wibox_array_t *);
|
area_t display_area_get(int);
|
||||||
int screen_virttophys(int);
|
int screen_virttophys(int);
|
||||||
void screen_client_moveto(client_t *, screen_t *, bool, bool);
|
void screen_client_moveto(client_t *, screen_t *, bool, bool);
|
||||||
|
|
||||||
|
|
|
@ -254,8 +254,6 @@ titlebar_client_attach(client_t *c)
|
||||||
|
|
||||||
switch(t->position)
|
switch(t->position)
|
||||||
{
|
{
|
||||||
case Floating:
|
|
||||||
t->position = Top;
|
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
if(!t->sw.geometry.height)
|
if(!t->sw.geometry.height)
|
||||||
|
@ -363,7 +361,6 @@ luaA_titlebar_newindex(lua_State *L, wibox_t *titlebar, awesome_token_t tok)
|
||||||
break;
|
break;
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
case Floating:
|
|
||||||
tmp = titlebar->sw.geometry.width;
|
tmp = titlebar->sw.geometry.width;
|
||||||
titlebar->sw.geometry.width = titlebar->sw.geometry.height;
|
titlebar->sw.geometry.width = titlebar->sw.geometry.height;
|
||||||
titlebar->sw.geometry.height = tmp;
|
titlebar->sw.geometry.height = tmp;
|
||||||
|
@ -380,7 +377,6 @@ luaA_titlebar_newindex(lua_State *L, wibox_t *titlebar, awesome_token_t tok)
|
||||||
break;
|
break;
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
case Floating:
|
|
||||||
tmp = titlebar->sw.geometry.width;
|
tmp = titlebar->sw.geometry.width;
|
||||||
titlebar->sw.geometry.width = titlebar->sw.geometry.height;
|
titlebar->sw.geometry.width = titlebar->sw.geometry.height;
|
||||||
titlebar->sw.geometry.height = tmp;
|
titlebar->sw.geometry.height = tmp;
|
||||||
|
@ -390,7 +386,6 @@ luaA_titlebar_newindex(lua_State *L, wibox_t *titlebar, awesome_token_t tok)
|
||||||
break;
|
break;
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
case Floating:
|
|
||||||
switch(titlebar->position)
|
switch(titlebar->position)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
|
@ -402,7 +397,6 @@ luaA_titlebar_newindex(lua_State *L, wibox_t *titlebar, awesome_token_t tok)
|
||||||
break;
|
break;
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
case Floating:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simplewindow_orientation_set(&titlebar->sw, East);
|
simplewindow_orientation_set(&titlebar->sw, East);
|
||||||
|
|
317
wibox.c
317
wibox.c
|
@ -23,7 +23,6 @@
|
||||||
#include "wibox.h"
|
#include "wibox.h"
|
||||||
#include "titlebar.h"
|
#include "titlebar.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "ewmh.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "common/xcursor.h"
|
#include "common/xcursor.h"
|
||||||
|
@ -102,41 +101,6 @@ wibox_resize(wibox_t *wibox, uint16_t width, uint16_t height)
|
||||||
wibox_need_update(wibox);
|
wibox_need_update(wibox);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
wibox_setposition(wibox_t *wibox, position_t p)
|
|
||||||
{
|
|
||||||
if(p != wibox->position)
|
|
||||||
{
|
|
||||||
switch((wibox->position = p))
|
|
||||||
{
|
|
||||||
case Bottom:
|
|
||||||
case Top:
|
|
||||||
case Floating:
|
|
||||||
simplewindow_orientation_set(&wibox->sw, East);
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
simplewindow_orientation_set(&wibox->sw, North);
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
simplewindow_orientation_set(&wibox->sw, South);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* reset width/height to 0 */
|
|
||||||
if(wibox->position != Floating)
|
|
||||||
wibox->sw.geometry.width = wibox->sw.geometry.height = 0;
|
|
||||||
|
|
||||||
/* recompute position */
|
|
||||||
wibox_position_update(wibox);
|
|
||||||
|
|
||||||
/* reset all wibox position */
|
|
||||||
foreach(w, wibox->screen->wiboxes)
|
|
||||||
wibox_position_update(*w);
|
|
||||||
|
|
||||||
ewmh_update_workarea(screen_virttophys(screen_array_indexof(&globalconf.screens, wibox->screen)));
|
|
||||||
|
|
||||||
wibox_need_update(wibox);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Kick out systray windows.
|
/** Kick out systray windows.
|
||||||
* \param phys_screen Physical screen number.
|
* \param phys_screen Physical screen number.
|
||||||
|
@ -319,200 +283,6 @@ wibox_systray_refresh(wibox_t *wibox)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only called by wibox_position_update() */
|
|
||||||
static void
|
|
||||||
wibox_position_update_floating(wibox_t *wibox)
|
|
||||||
{
|
|
||||||
area_t wingeom = wibox->sw.geometry;
|
|
||||||
|
|
||||||
/* We only make sure the wibox is at least 1x1 pixel big. */
|
|
||||||
wingeom.width = MAX(1, wibox->sw.geometry.width);
|
|
||||||
wingeom.height = MAX(1, wibox->sw.geometry.height);
|
|
||||||
|
|
||||||
if(wingeom.width != wibox->sw.geometry.width
|
|
||||||
|| wingeom.height != wibox->sw.geometry.height)
|
|
||||||
wibox_resize(wibox, wingeom.width, wingeom.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only called by wibox_position_update() */
|
|
||||||
static void
|
|
||||||
wibox_position_update_non_floating(wibox_t *wibox)
|
|
||||||
{
|
|
||||||
area_t area, wingeom = wibox->sw.geometry;
|
|
||||||
bool ignore = false;
|
|
||||||
|
|
||||||
/* Everything we do below needs the wibox' screen.
|
|
||||||
* No screen, nothing to do.
|
|
||||||
*/
|
|
||||||
if (!wibox->screen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* This wibox limits the space available to clients and thus clients
|
|
||||||
* need to be repositioned.
|
|
||||||
*/
|
|
||||||
wibox->screen->need_arrange = true;
|
|
||||||
|
|
||||||
area = screen_area_get(wibox->screen, NULL,
|
|
||||||
&wibox->screen->padding, true);
|
|
||||||
|
|
||||||
/* Top and Bottom wibox_t have prio */
|
|
||||||
foreach(_w, wibox->screen->wiboxes)
|
|
||||||
{
|
|
||||||
wibox_t *w = *_w;
|
|
||||||
/* Ignore every wibox after me that is in the same position */
|
|
||||||
if(wibox == w)
|
|
||||||
{
|
|
||||||
ignore = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if((ignore && wibox->position == w->position) || !w->isvisible)
|
|
||||||
continue;
|
|
||||||
switch(w->position)
|
|
||||||
{
|
|
||||||
case Floating:
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
if(wibox->position == Left)
|
|
||||||
area.x += wibox->sw.geometry.width;
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
if(wibox->position == Right)
|
|
||||||
area.x -= wibox->sw.geometry.width;
|
|
||||||
break;
|
|
||||||
case Top:
|
|
||||||
switch(wibox->position)
|
|
||||||
{
|
|
||||||
case Top:
|
|
||||||
area.y += w->sw.geometry.height;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
case Right:
|
|
||||||
area.height -= w->sw.geometry.height;
|
|
||||||
area.y += w->sw.geometry.height;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Bottom:
|
|
||||||
switch(wibox->position)
|
|
||||||
{
|
|
||||||
case Bottom:
|
|
||||||
area.y -= w->sw.geometry.height;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
case Right:
|
|
||||||
area.height -= w->sw.geometry.height;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The "length" of a wibox is always chosen to be the optimal size (non-floating).
|
|
||||||
* The "width" of a wibox is kept if it exists.
|
|
||||||
*/
|
|
||||||
switch(wibox->position)
|
|
||||||
{
|
|
||||||
case Right:
|
|
||||||
wingeom.height = area.height - 2 * wibox->sw.border.width;
|
|
||||||
wingeom.width = wibox->sw.geometry.width > 0 ? wibox->sw.geometry.width : 1.5 * globalconf.font->height;
|
|
||||||
wingeom.x = area.x + area.width - wingeom.width;
|
|
||||||
switch(wibox->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
wingeom.y = area.y;
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
wingeom.y = area.y + area.height - wingeom.height;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
wingeom.y = (area.y + area.height - wingeom.height) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
wingeom.height = area.height - 2 * wibox->sw.border.width;
|
|
||||||
wingeom.width = wibox->sw.geometry.width > 0 ? wibox->sw.geometry.width : 1.5 * globalconf.font->height;
|
|
||||||
wingeom.x = area.x;
|
|
||||||
switch(wibox->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
wingeom.y = (area.y + area.height) - wingeom.height;
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
wingeom.y = area.y;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
wingeom.y = (area.y + area.height - wingeom.height) / 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Bottom:
|
|
||||||
wingeom.height = wibox->sw.geometry.height > 0 ? wibox->sw.geometry.height : 1.5 * globalconf.font->height;
|
|
||||||
wingeom.width = area.width - 2 * wibox->sw.border.width;
|
|
||||||
wingeom.y = (area.y + area.height) - wingeom.height;
|
|
||||||
wingeom.x = area.x;
|
|
||||||
switch(wibox->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
wingeom.x += area.width - wingeom.width;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
wingeom.x += (area.width - wingeom.width) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Top:
|
|
||||||
wingeom.height = wibox->sw.geometry.height > 0 ? wibox->sw.geometry.height : 1.5 * globalconf.font->height;
|
|
||||||
wingeom.width = area.width - 2 * wibox->sw.border.width;
|
|
||||||
wingeom.x = area.x;
|
|
||||||
wingeom.y = area.y;
|
|
||||||
switch(wibox->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
wingeom.x += area.width - wingeom.width;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
wingeom.x += (area.width - wingeom.width) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Floating:
|
|
||||||
/* Floating wiboxes are not handled here, but in
|
|
||||||
* wibox_position_update_floating(), but the compiler insists...
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* same window size and position ? */
|
|
||||||
if(wingeom.width != wibox->sw.geometry.width
|
|
||||||
|| wingeom.height != wibox->sw.geometry.height)
|
|
||||||
wibox_resize(wibox, wingeom.width, wingeom.height);
|
|
||||||
|
|
||||||
if(wingeom.x != wibox->sw.geometry.x
|
|
||||||
|| wingeom.y != wibox->sw.geometry.y)
|
|
||||||
wibox_move(wibox, wingeom.x, wingeom.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Update the wibox position. It deletes every wibox resources and
|
|
||||||
* create them back.
|
|
||||||
* \param wibox The wibox.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
wibox_position_update(wibox_t *wibox)
|
|
||||||
{
|
|
||||||
if(wibox->position == Floating)
|
|
||||||
wibox_position_update_floating(wibox);
|
|
||||||
else
|
|
||||||
wibox_position_update_non_floating(wibox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get a wibox by its window.
|
/** Get a wibox by its window.
|
||||||
* \param w The window id.
|
* \param w The window id.
|
||||||
* \return A wibox if found, NULL otherwise.
|
* \return A wibox if found, NULL otherwise.
|
||||||
|
@ -570,16 +340,6 @@ wibox_refresh(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reposition all wiboxes.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
wibox_update_positions(void)
|
|
||||||
{
|
|
||||||
foreach(screen, globalconf.screens)
|
|
||||||
foreach(w, screen->wiboxes)
|
|
||||||
wibox_position_update(*w);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set a wibox visible or not.
|
/** Set a wibox visible or not.
|
||||||
* \param wibox The wibox.
|
* \param wibox The wibox.
|
||||||
* \param v The visible value.
|
* \param v The visible value.
|
||||||
|
@ -592,7 +352,7 @@ wibox_setvisible(wibox_t *wibox, bool v)
|
||||||
wibox->isvisible = v;
|
wibox->isvisible = v;
|
||||||
wibox->mouse_over = NULL;
|
wibox->mouse_over = NULL;
|
||||||
|
|
||||||
if(wibox->screen != NULL)
|
if(wibox->screen)
|
||||||
{
|
{
|
||||||
if(wibox->isvisible)
|
if(wibox->isvisible)
|
||||||
wibox_map(wibox);
|
wibox_map(wibox);
|
||||||
|
@ -601,11 +361,6 @@ wibox_setvisible(wibox_t *wibox, bool v)
|
||||||
|
|
||||||
/* kick out systray if needed */
|
/* kick out systray if needed */
|
||||||
wibox_systray_refresh(wibox);
|
wibox_systray_refresh(wibox);
|
||||||
|
|
||||||
/* All the other wibox and ourselves need to be repositioned */
|
|
||||||
foreach(w, wibox->screen->wiboxes)
|
|
||||||
wibox_position_update(*w);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hook_property(wibox, wibox, "visible");
|
hook_property(wibox, wibox, "visible");
|
||||||
|
@ -615,10 +370,10 @@ wibox_setvisible(wibox_t *wibox, bool v)
|
||||||
/** Remove a wibox from a screen.
|
/** Remove a wibox from a screen.
|
||||||
* \param wibox Wibox to detach from screen.
|
* \param wibox Wibox to detach from screen.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
wibox_detach(wibox_t *wibox)
|
wibox_detach(wibox_t *wibox)
|
||||||
{
|
{
|
||||||
if(wibox->screen != NULL)
|
if(wibox->screen)
|
||||||
{
|
{
|
||||||
bool v;
|
bool v;
|
||||||
|
|
||||||
|
@ -626,8 +381,7 @@ wibox_detach(wibox_t *wibox)
|
||||||
v = wibox->isvisible;
|
v = wibox->isvisible;
|
||||||
wibox->isvisible = false;
|
wibox->isvisible = false;
|
||||||
wibox_systray_refresh(wibox);
|
wibox_systray_refresh(wibox);
|
||||||
wibox_position_update(wibox);
|
/* restore visibility */
|
||||||
/* restore position */
|
|
||||||
wibox->isvisible = v;
|
wibox->isvisible = v;
|
||||||
|
|
||||||
wibox->mouse_over = NULL;
|
wibox->mouse_over = NULL;
|
||||||
|
@ -676,9 +430,6 @@ wibox_attach(screen_t *s)
|
||||||
|
|
||||||
wibox_array_append(&s->wiboxes, wibox);
|
wibox_array_append(&s->wiboxes, wibox);
|
||||||
|
|
||||||
/* compute x/y/width/height if not set */
|
|
||||||
wibox_position_update(wibox);
|
|
||||||
|
|
||||||
simplewindow_init(&wibox->sw, phys_screen,
|
simplewindow_init(&wibox->sw, phys_screen,
|
||||||
wibox->sw.geometry,
|
wibox->sw.geometry,
|
||||||
wibox->sw.border.width,
|
wibox->sw.border.width,
|
||||||
|
@ -689,13 +440,6 @@ wibox_attach(screen_t *s)
|
||||||
|
|
||||||
simplewindow_cursor_set(&wibox->sw,
|
simplewindow_cursor_set(&wibox->sw,
|
||||||
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
|
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
|
||||||
|
|
||||||
/* All the other wibox and ourselves need to be repositioned */
|
|
||||||
foreach(w, s->wiboxes)
|
|
||||||
wibox_position_update(*w);
|
|
||||||
|
|
||||||
ewmh_update_workarea(phys_screen);
|
|
||||||
|
|
||||||
if(wibox->isvisible)
|
if(wibox->isvisible)
|
||||||
wibox_map(wibox);
|
wibox_map(wibox);
|
||||||
else
|
else
|
||||||
|
@ -709,7 +453,7 @@ wibox_attach(screen_t *s)
|
||||||
*
|
*
|
||||||
* \luastack
|
* \luastack
|
||||||
* \lparam A table with optionaly defined values:
|
* \lparam A table with optionaly defined values:
|
||||||
* position, align, fg, bg, border_width, border_color, ontop, width and height.
|
* fg, bg, border_width, border_color, ontop, width and height.
|
||||||
* \lreturn A brand new wibox.
|
* \lreturn A brand new wibox.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
@ -740,32 +484,11 @@ luaA_wibox_new(lua_State *L)
|
||||||
|
|
||||||
w->ontop = luaA_getopt_boolean(L, 2, "ontop", false);
|
w->ontop = luaA_getopt_boolean(L, 2, "ontop", false);
|
||||||
|
|
||||||
buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
|
|
||||||
w->align = draw_align_fromstr(buf, len);
|
|
||||||
|
|
||||||
w->sw.border.width = luaA_getopt_number(L, 2, "border_width", 0);
|
w->sw.border.width = luaA_getopt_number(L, 2, "border_width", 0);
|
||||||
|
|
||||||
buf = luaA_getopt_lstring(L, 2, "position", "top", &len);
|
|
||||||
|
|
||||||
switch((w->position = position_fromstr(buf, len)))
|
|
||||||
{
|
|
||||||
case Bottom:
|
|
||||||
case Top:
|
|
||||||
case Floating:
|
|
||||||
w->sw.orientation = East;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
w->sw.orientation = North;
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
w->sw.orientation = South;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
w->sw.geometry.x = luaA_getopt_number(L, 2, "x", 0);
|
w->sw.geometry.x = luaA_getopt_number(L, 2, "x", 0);
|
||||||
w->sw.geometry.y = luaA_getopt_number(L, 2, "y", 0);
|
w->sw.geometry.y = luaA_getopt_number(L, 2, "y", 0);
|
||||||
w->sw.geometry.width = luaA_getopt_number(L, 2, "width", 0);
|
w->sw.geometry.width = luaA_getopt_number(L, 2, "width", 100);
|
||||||
w->sw.geometry.height = luaA_getopt_number(L, 2, "height", 0);
|
w->sw.geometry.height = luaA_getopt_number(L, 2, "height", globalconf.font->height * 1.5);
|
||||||
|
|
||||||
w->isvisible = true;
|
w->isvisible = true;
|
||||||
w->cursor = a_strdup("left_ptr");
|
w->cursor = a_strdup("left_ptr");
|
||||||
|
@ -848,11 +571,11 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
|
||||||
* \lfield client The client attached to (titlebar).
|
* \lfield client The client attached to (titlebar).
|
||||||
* \lfield border_width Border width.
|
* \lfield border_width Border width.
|
||||||
* \lfield border_color Border color.
|
* \lfield border_color Border color.
|
||||||
* \lfield align The alignment.
|
* \lfield align The alignment (titlebar).
|
||||||
* \lfield fg Foreground color.
|
* \lfield fg Foreground color.
|
||||||
* \lfield bg Background color.
|
* \lfield bg Background color.
|
||||||
* \lfield bg_image Background image.
|
* \lfield bg_image Background image.
|
||||||
* \lfield position The position.
|
* \lfield position The position (titlebar).
|
||||||
* \lfield ontop On top of other windows.
|
* \lfield ontop On top of other windows.
|
||||||
* \lfield cursor The mouse cursor.
|
* \lfield cursor The mouse cursor.
|
||||||
* \lfield visible Visibility.
|
* \lfield visible Visibility.
|
||||||
|
@ -891,6 +614,8 @@ luaA_wibox_index(lua_State *L)
|
||||||
luaA_pushxcolor(L, &wibox->sw.border.color);
|
luaA_pushxcolor(L, &wibox->sw.border.color);
|
||||||
break;
|
break;
|
||||||
case A_TK_ALIGN:
|
case A_TK_ALIGN:
|
||||||
|
if(wibox->type == WIBOX_TYPE_NORMAL)
|
||||||
|
luaA_deprecate(L, "awful.wibox.align");
|
||||||
lua_pushstring(L, draw_align_tostr(wibox->align));
|
lua_pushstring(L, draw_align_tostr(wibox->align));
|
||||||
break;
|
break;
|
||||||
case A_TK_FG:
|
case A_TK_FG:
|
||||||
|
@ -903,6 +628,8 @@ luaA_wibox_index(lua_State *L)
|
||||||
image_push(L, wibox->bg_image);
|
image_push(L, wibox->bg_image);
|
||||||
break;
|
break;
|
||||||
case A_TK_POSITION:
|
case A_TK_POSITION:
|
||||||
|
if(wibox->type == WIBOX_TYPE_NORMAL)
|
||||||
|
luaA_deprecate(L, "awful.wibox.attach");
|
||||||
lua_pushstring(L, position_tostr(wibox->position));
|
lua_pushstring(L, position_tostr(wibox->position));
|
||||||
break;
|
break;
|
||||||
case A_TK_ONTOP:
|
case A_TK_ONTOP:
|
||||||
|
@ -976,14 +703,7 @@ luaA_wibox_geometry(lua_State *L)
|
||||||
wibox_resize(wibox, wingeom.width, wingeom.height);
|
wibox_resize(wibox, wingeom.width, wingeom.height);
|
||||||
break;
|
break;
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
if(wibox->position == Floating)
|
|
||||||
wibox_moveresize(wibox, wingeom);
|
wibox_moveresize(wibox, wingeom);
|
||||||
else if(wingeom.width != wibox->sw.geometry.width
|
|
||||||
|| wingeom.height != wibox->sw.geometry.height)
|
|
||||||
{
|
|
||||||
wibox_resize(wibox, wingeom.width, wingeom.height);
|
|
||||||
wibox->screen->need_arrange = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +748,7 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
switch(wibox->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
wibox_position_update(wibox);
|
luaA_deprecate(L, "awful.wibox.align");
|
||||||
break;
|
break;
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
titlebar_update_geometry(client_getbytitlebar(wibox));
|
titlebar_update_geometry(client_getbytitlebar(wibox));
|
||||||
|
@ -1038,12 +758,15 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
case A_TK_POSITION:
|
case A_TK_POSITION:
|
||||||
switch(wibox->type)
|
switch(wibox->type)
|
||||||
{
|
{
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
|
||||||
return luaA_titlebar_newindex(L, wibox, tok);
|
|
||||||
case WIBOX_TYPE_NORMAL:
|
case WIBOX_TYPE_NORMAL:
|
||||||
if((buf = luaL_checklstring(L, 3, &len)))
|
if((buf = luaL_checklstring(L, 3, &len)))
|
||||||
wibox_setposition(wibox, position_fromstr(buf, len));
|
{
|
||||||
|
luaA_deprecate(L, "awful.wibox.attach");
|
||||||
|
wibox->position = position_fromstr(buf, len);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
case WIBOX_TYPE_TITLEBAR:
|
||||||
|
return luaA_titlebar_newindex(L, wibox, tok);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_CLIENT:
|
case A_TK_CLIENT:
|
||||||
|
|
3
wibox.h
3
wibox.h
|
@ -75,13 +75,10 @@ void wibox_unref_simplified(wibox_t **);
|
||||||
DO_ARRAY(wibox_t *, wibox, wibox_unref_simplified)
|
DO_ARRAY(wibox_t *, wibox, wibox_unref_simplified)
|
||||||
|
|
||||||
void wibox_refresh(void);
|
void wibox_refresh(void);
|
||||||
void wibox_update_positions(void);
|
|
||||||
|
|
||||||
void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
||||||
|
|
||||||
void wibox_position_update(wibox_t *);
|
|
||||||
wibox_t * wibox_getbywin(xcb_window_t);
|
wibox_t * wibox_getbywin(xcb_window_t);
|
||||||
void wibox_detach(wibox_t *);
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
wibox_moveresize(wibox_t *wibox, area_t geometry)
|
wibox_moveresize(wibox_t *wibox, area_t geometry)
|
||||||
|
|
Loading…
Reference in New Issue